GenCodeDoc
by fkom13
README.md
# π GenCodeDoc
<div align="center">
**Smart documentation generator and intelligent versioning system with full MCP support**
[](https://www.python.org/downloads/)
[](https://python-poetry.org/)
[](https://modelcontextprotocol.io/)
[](LICENSE)
[](https://esprit-artificiel.com)
*Intelligent versioning and documentation for modern development workflows*
[Quick Start](#-quick-start) β’ [Features](#-features) β’ [MCP Tools](#-mcp-tools-26-tools) β’ [Documentation](#-documentation)
</div>
---
## β‘ Quick Start
```bash
# 1. Install
cd /path/to/gencodedoc
poetry install
# 2. Initialize your project
poetry run gencodedoc init --preset python
# 3. Create your first snapshot
poetry run gencodedoc snapshot create -m "Initial version" -t v1.0
# 4. Generate documentation (Smart Split)
poetry run gencodedoc doc generate --limit 5000
# 5. Visualize Tree
poetry run gencodedoc tree
```
π― For AI Assistants (Claude/Gemini): See MCP Integration
β¨ Features
π― Core Features
πΈ Smart Snapshots - Create intelligent snapshots with ~70% space savings via SHA256 deduplication
π Intelligent Autosave - 3 modes (timer/diff/hybrid) with configurable thresholds
π Beautiful Documentation - Generate Markdown docs with syntax highlighting, directory trees, and **smart splitting**
π Advanced Diff - Compare versions with unified, JSON, or AST-based diffs
ποΈ Efficient Storage - zstd compression (~3x reduction) + SQLite with optimized indexes
π¨ Project Presets - Pre-configured for Python, Node.js, Go, and Web projects
π MCP Integration (Model Context Protocol)
**26 MCP Tools** - Full CLI functionality exposed via MCP for AI Assistants
3 Transports - stdio (Gemini CLI) + SSE (Claude Desktop) + REST API
Multi-Project - Manage multiple projects simultaneously
Code Intelligence - File history, search, and changelog generation
Live Status - Real-time project statistics and snapshot management
π¦ Installation
Prerequisites
Python 3.10+
Poetry (dependency manager)
Install Poetry
Bash
# Linux/macOS
curl -sSL https://install.python-poetry.org | python3 -
# Windows (PowerShell)
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -
Install GenCodeDoc
Bash
# Clone or navigate to the project
cd /home/fkomp/Bureau/oracle/utilitaires/gencodedoc/gencodedoc
# Install dependencies
poetry install
# Verify installation
poetry run gencodedoc --help
π― Usage
π CLI Usage
Initialize a Project
Bash
# Basic initialization
gencodedoc init
# With Python preset (recommended for Oracle projects)
gencodedoc init --preset python
# Available presets: python, nodejs, go, web
Snapshot Management
Bash
# Create snapshot
gencodedoc snapshot create --message "Feature X completed" --tag v1.0
# List snapshots
gencodedoc snapshot list --limit 10
# Show snapshot details
gencodedoc snapshot show v1.0
# View file content at specific version (NEW)
gencodedoc snapshot cat v1.0 src/main.py
# List files in a snapshot (NEW)
gencodedoc snapshot files v1.0 --pattern "*.py"
# Compare versions
gencodedoc snapshot diff v1.0 v2.0
# Restore snapshot (full or partial)
gencodedoc snapshot restore v1.0 --force
gencodedoc snapshot restore v1.0 --filter "src/*.py" # Partial restore
# Export snapshot (NEW)
gencodedoc snapshot export v1.0 ./dist-v1 --archive # Creates .tar.gz
# Delete snapshot
gencodedoc snapshot delete old-version --force
# Cleanup orphaned data (NEW)
gencodedoc snapshot cleanup
Documentation Generation
Bash
# Full documentation
gencodedoc doc generate
# Custom output
gencodedoc doc generate --output docs/API.md
# Specific paths only
gencodedoc doc generate --include src/api/ --include README.md
# Structure preview
gencodedoc doc preview --max-depth 3
# Project statistics
gencodedoc doc stats
Configuration
Bash
# View configuration
gencodedoc config show
# Edit configuration
gencodedoc config edit
# Set specific values
gencodedoc config set autosave.enabled true
gencodedoc config set autosave.mode hybrid
# Apply preset
gencodedoc config preset python
# Manage ignore rules
gencodedoc config ignore --add-dir dist
gencodedoc config ignore --add-ext .tmp
gencodedoc config ignore --list-all
# Customizable Presets
# Presets are now defined in YAML files (gencodedoc/config/presets/*.yaml)
# and can be modified directly in the source code.
Project Status
Bash
# Show project status
gencodedoc status
π MCP Integration
GenCodeDoc exposes 22 powerful tools via the Model Context Protocol, compatible with Claude Desktop, Gemini CLI, and any MCP-compatible client.
π― Transport Modes
Transport Use Case AI Assistants Port
stdio CLI integration Gemini CLI, custom scripts stdin/stdout
SSE Web/Desktop apps Claude Desktop, web UIs 8000 (HTTP)
REST API integration Any HTTP client 8000 (HTTP)
π Setup for Gemini CLI (stdio)
1. Find your Poetry venv path:
Bash
cd /home/fkomp/Bureau/oracle/utilitaires/gencodedoc/gencodedoc
poetry env info --path
# Copy the path and append /bin/python
2. Add to ~/.config/gemini-desktop-app/settings.json:
JSON
{
"mcpServers": {
"gencodedoc": {
"command": "/path/to/your/venv/bin/python",
"args": ["-m", "gencodedoc.mcp.server_stdio"],
"env": {
"PROJECT_PATH": "/home/fkomp/Bureau/oracle/utilitaires/gencodedoc/gencodedoc"
}
}
}
}
3. Restart Gemini CLI and you`re ready! π
π Setup for Claude Desktop (SSE)
1. Start the SSE server:
Bash
# Terminal 1: Start server
poetry run python -m gencodedoc.mcp.server_sse
# Server runs on http://127.0.0.1:8000
2. Add to Claude Desktop config:
Location:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
Config:
JSON
{
"mcpServers": {
"gencodedoc": {
"url": "http://127.0.0.1:8000/mcp/sse",
"transport": "sse",
"description": "GenCodeDoc - Smart documentation and versioning"
}
}
}
3. Restart Claude Desktop and the server must remain running!
π REST API
Bash
# Start REST server
poetry run python -m gencodedoc.mcp.server
# Available endpoints
GET http://127.0.0.1:8000/ # Server info
GET http://127.0.0.1:8000/mcp/tools # List tools
POST http://127.0.0.1:8000/mcp/execute # Execute tool
π οΈ MCP Tools (26 Tools)
π§ Code Intelligence (3 tools)
| Tool | Description | Key Parameters |
|------|-------------|----------------|
| `get_file_history` | Track file changes across versions | `file_path` |
| `search_snapshots` | Search text in all snapshots | `query`, `case_sensitive`, `file_filter` |
| `generate_changelog` | Generate Keep-a-Changelog | `from_ref`, `to_ref` |
πΈ Snapshot Management (11 tools)
| Tool | Description | Key Parameters |
|------|-------------|----------------|
| `create_snapshot` | Create a new snapshot | `message`, `tag`, `include_paths` |
| `list_snapshots` | List all snapshots | `limit`, `include_autosave` |
| `get_snapshot_details` | Get full snapshot info | `snapshot_ref` |
| `restore_snapshot` | Restore a snapshot (full or partial) | `snapshot_ref`, `force`, `file_filters` |
| `restore_files` | Restore specific files | `snapshot_ref`, `file_filters` |
| `delete_snapshot` | Delete a snapshot | `snapshot_ref` |
| `diff_versions` | Compare two versions | `from_ref`, `to_ref`, `format`, `file_filters` |
| `get_file_at_version` | Get content of a single file | `snapshot_ref`, `file_path` |
| `list_files_at_version` | List files in a snapshot | `snapshot_ref`, `pattern` |
| `export_snapshot` | Export snapshot to folder/archive | `snapshot_ref`, `output_path`, `archive` |
| `cleanup_orphaned_contents` | Cleanup unused data | none |
π Documentation (3 tools)
| Tool | Description | Key Parameters |
|------|-------------|----------------|
| `generate_documentation` | Generate Markdown docs | `output_path`, `split_limit`, `ignore_tree_patterns` |
| `preview_structure` | Show directory tree | `max_depth`, `ignore_add`, `limit`, `page` |
| `get_project_stats` | Get project statistics | none |
π― Project Management (2 tools)
| Tool | Description | Key Parameters |
|------|-------------|----------------|
| `init_project` | Initialize gencodedoc | `project_path`, `preset` |
| `get_project_status` | Get project status | `project_path` |
βοΈ Configuration (4 tools)
| Tool | Description | Key Parameters |
|------|-------------|----------------|
| `get_config` | View configuration | `project_path` |
| `set_config_value` | Modify config value | `key`, `value` |
| `apply_preset` | Apply preset config | `preset` (python/nodejs/go/web) |
| `manage_ignore_rules` | Manage ignore rules | `add_dir`, `add_file`, `add_ext`, `list_all` |
π Autosave (3 tools)
| Tool | Description | Key Parameters |
|------|-------------|----------------|
| `start_autosave` | Start automatic versioning | `project_path`, `mode` |
| `stop_autosave` | Stop automatic versioning | `project_path` |
| `get_autosave_status` | Get status of all autosaves | none |
---
π€ Contributing
Contributions welcome! π
π Report bugs via GitHub Issues
π‘ Suggest features via Discussions
π§ Submit Pull Requests
Development workflow:
1. Fork the repo
2. Create a feature branch (`git checkout -b feature/amazing`)
3. Make your changes
4. Run tests (`make test`)
5. Submit PR
π License
MIT License - See LICENSE file
π Issues: GitHub Issues
π¬ Discussions: GitHub Discussions
π Website: esprit-artificiel.com
π§ Email: support@esprit-artificiel.com
<div align="center">
Made with β€οΈ for developers who love smart versioning and beautiful docs
π‘ Pro Tip: Use GenCodeDoc with Gemini CLI or Claude Desktop for AI-powered version control!
β Star this repo if you find it useful!
</div>π€ "Start autosave in hybrid mode for this project"
β Calls: start_autosave(project_path="...", mode="hybrid")
π€ "Stop all autosaves and show me their status"
β Calls: stop_autosave(...) + get_autosave_status()
βοΈ Configuration
Configuration File (.gencodedoc.yaml)
YAML
project_name: "my-project"
# Files/directories to ignore
ignore:
dirs:
- node_modules
- venv
- .venv
- __pycache__
- .git
- dist
- build
files:
- "*.log"
- package-lock.json
- .DS_Store
extensions:
- .pyc
- .pyo
- .exe
- .jpg
- .png
- .pdf
patterns: [] # gitignore-style patterns
# Intelligent autosave
autosave:
enabled: false # Set to true to enable
mode: hybrid # timer | diff | hybrid (recommended)
# Timer mode: fixed interval
timer:
interval: 300 # seconds (5 minutes)
# Diff mode: threshold-based
diff_threshold:
threshold: 0.05 # Save if 5% of files changed
check_interval: 60 # Check every 60 seconds
ignore_whitespace: true
ignore_comments: false
# Hybrid mode: combines timer + diff (RECOMMENDED)
hybrid:
min_interval: 180 # Minimum 3 minutes between saves
max_interval: 600 # Maximum 10 minutes between saves
threshold: 0.03 # Save if 3% of files changed
# Retention policy
retention:
max_autosaves: 50 # Keep max 50 autosaves
compress_after_days: 7 # Compress after 7 days
delete_after_days: 30 # Delete after 30 days
keep_manual: true # Always keep manual snapshots
# Documentation output
output:
default_name: "{project}_doc_{date}.md"
include_tree: true
include_code: true
tree_full_code_select: false # Full tree, selected code only
language_detection: true
max_file_size: 1000000 # 1 MB max per file
# Diff output format
diff_format:
default: unified # unified | json | ast
unified_context: 3
json_include_content: true
ast_enabled: false # Experimental
# Storage
storage_path: .gencodedoc
compression_enabled: true
compression_level: 3 # 1-22 (3 = good balance)
Quick Config Commands
Bash
# Enable autosave
gencodedoc config set autosave.enabled true
gencodedoc config set autosave.mode hybrid
# Adjust autosave thresholds
gencodedoc config set autosave.hybrid.min_interval 300
gencodedoc config set autosave.hybrid.max_interval 1800
gencodedoc config set autosave.hybrid.threshold 0.03
# Add ignore rules
gencodedoc config ignore --add-dir dist
gencodedoc config ignore --add-ext .tmp
gencodedoc config ignore --add-file debug.log
ποΈ Architecture
text
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β GenCodeDoc System β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β CLI (Typer) β β MCP stdio β β MCP SSE/REST β
β β β (Gemini CLI) β β (Claude/Web) β
ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ
β β β
βββββββββββββββββββΌβββββββββββββββββββ
β
ββββββββββββΌβββββββββββ
β Core Managers β
βββββββββββββββββββββββ€
β β’ ConfigManager β
β β’ VersionManager β
β β’ DocGenerator β
β β’ AutosaveManager β
ββββββββββββ¬βββββββββββ
β
βββββββββββββββββΌββββββββββββββββ
β β β
ββββββΌββββββ βββββββΌβββββββ ββββββΌβββββββ
β Scanner β β Differ β β Storage β
β β β β β β
β β’ Scan β β β’ Unified β β β’ SQLite β
β β’ Filter β β β’ JSON β β β’ zstd β
β β’ Detect β β β’ AST β β β’ Dedup β
ββββββββββββ ββββββββββββββ βββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Storage Layer β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β .gencodedoc/ β
β βββ gencodedoc.db β SQLite (metadata) β
β β βββ snapshots β Snapshot records β
β β βββ snapshot_files β File entries β
β β βββ file_contents β Deduplicated content (SHA256) β
β β βββ autosave_state β Autosave status β
β βββ config/ β Configuration files β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Key Features:
β’ π SHA256 deduplication β ~70% space savings
β’ ποΈ zstd compression β ~3x size reduction
β’ π Indexed SQLite β Fast queries
β’ π Watchdog observer β Real-time file monitoring
Project Structure
text
gencodedoc/
βββ gencodedoc/ # Source code
β βββ cli/ # CLI commands (Typer)
β β βββ main.py # Entry point
β β βββ snapshot_cmd.py
β β βββ doc_cmd.py
β β βββ config_cmd.py
β β βββ mcp_cmd.py
β βββ core/ # Business logic
β β βββ config.py # Configuration management
β β βββ scanner.py # File scanning & filtering
β β βββ versioning.py # Snapshot management
β β βββ documentation.py
β β βββ differ.py # Version comparison
β β βββ autosave.py # Intelligent autosave
β βββ mcp/ # MCP servers
β β βββ server_stdio.py # stdio transport
β β βββ server_sse.py # SSE transport
β β βββ server.py # REST transport
β β βββ tools.py # Tool definitions
β βββ models/ # Data models (Pydantic)
β β βββ config.py
β β βββ snapshot.py
β βββ storage/ # Storage & compression
β β βββ database.py # SQLite manager
β β βββ snapshot_store.py
β β βββ compression.py # zstd compression
β βββ utils/ # Utilities
β βββ filters.py
β βββ formatters.py
β βββ tree.py
βββ config/ # Configuration presets
β βββ presets/
β βββ python.yaml
β βββ nodejs.yaml
β βββ go.yaml
β βββ web.yaml
βββ tests/ # Unit tests
βββ pyproject.toml # Poetry config
βββ Makefile # Dev commands
βββ README.md
π¬ Advanced Features
π― Intelligent Deduplication (~70% savings)
GenCodeDoc uses SHA256-based deduplication:
β
Identical files across snapshots are stored once
β
Massive space savings (~70% on real projects)
β
zstd compression for ~3x additional reduction
β
Optimized SQLite with indexes
Example: 10 snapshots of a 100 MB project
Without deduplication: 1 GB
With GenCodeDoc: ~300 MB (dedup + compression)
π Autosave Modes
Mode How it works Best for
timer Save every X seconds Continuous development
diff Save when X% changed Critical projects
hybrid β Min/max interval + threshold General use (recommended)
Hybrid mode example:
YAML
hybrid:
min_interval: 300 # Don`t save more often than 5 min
max_interval: 1800 # Force save after 30 min
threshold: 0.03 # OR if 3% of files changed
π Diff Formats
Format Description Use Case
unified Git-style diff Human reading
json Structured data Automation
ast Semantic diff Code analysis (experimental)
Bash
# Unified diff (default)
gencodedoc snapshot diff v1.0 v2.0
# JSON for scripts
gencodedoc snapshot diff v1.0 v2.0 --format json > changes.json
# AST (semantic)
gencodedoc snapshot diff v1.0 v2.0 --format ast
π Troubleshooting
Common Issues
1οΈβ£ MCP Error: notifications/initialized
Symptom: Error on MCP startup:
text
MCP ERROR: Unknown method: notifications/initialized
Cause: MCP protocol sends notifications that older versions didn`t handle.
Solution: β
Already fixed in current version. The server now silently ignores MCP notifications.
2οΈβ£ Snapshots created in wrong location
Symptom: All snapshots go to gencodedoc`s own directory instead of target project.
Cause: project_path not properly extracted from MCP tools/call parameters.
Solution: β
Already fixed. The server now correctly extracts project_path from arguments.
Verify fix:
Bash
# This should create snapshot in /path/to/project, not gencodedoc
/gencodedoc create_snapshot project_path=/path/to/project tag=test
3οΈβ£ Zod validation errors (id=null)
Symptom:
text
Error: Expected string or number, received null (path: ["id"])
Cause: JSON-RPC responses with "id": null instead of "id": 0.
Solution: β
Already fixed. All error responses now use request_id or 0.
4οΈβ£ Files not properly scanned
Symptom: Snapshot shows wrong number of files or files from wrong directory.
Cause: snapshot_store.py used relative paths instead of absolute.
Solution: β
Already fixed. SnapshotStore now receives and uses project_path for absolute file paths.
5οΈβ£ DB not initialized
Symptom:
text
Error: no such table: snapshots
Cause: Project not initialized before creating snapshot.
Solution:
Bash
# Always init first (creates tables)
gencodedoc init --preset python
# Or via MCP
/gencodedoc init_project project_path=/path/to/project preset=python
6οΈβ£ Autosave not starting
Symptom: start_autosave tool doesn`t work.
Cause: Autosave requires the MCP server to remain running (it`s a background process).
Solution:
stdio mode: Server runs per-request β autosave stops when request ends
SSE/REST mode: β
Server persistent β autosave works!
Recommended: Use SSE/REST for autosave, stdio for one-off commands.
Debug Mode
Bash
# Enable verbose logging (if implemented)
export GENCODEDOC_DEBUG=1
poetry run gencodedoc snapshot create --message "test"
# Check SQLite DB directly
sqlite3 /path/to/project/.gencodedoc/gencodedoc.db ".tables"
sqlite3 /path/to/project/.gencodedoc/gencodedoc.db "SELECT * FROM snapshots;"
π§ͺ Testing
Bash
# Run all tests
poetry run pytest
# With coverage
poetry run pytest --cov=gencodedoc --cov-report=html
# Specific tests
poetry run pytest tests/test_scanner.py -v
poetry run pytest tests/test_versioning.py -v
poetry run pytest tests/test_mcp.py -v
# Watch mode (requires pytest-watch)
poetry run ptw
π οΈ Development
Setup Development Environment
Bash
# Install with dev dependencies
poetry install
# Activate virtual environment
poetry shell
# Install pre-commit hooks (if configured)
pre-commit install
Makefile Commands
Bash
make help # Show all commands
make install # Install dependencies
make test # Run tests
make test-cov # Tests with coverage
make lint # Check code quality
make format # Format code (Black)
make clean # Remove temporary files
make docs # Generate documentation
make serve-mcp-sse # Start SSE server
make serve-mcp-stdio # Start stdio server
make all # Lint + test + build
Code Style
Formatter: Black (line length 100)
Linter: Ruff
Type hints: Enforced with Pydantic
Docstrings: Google style
π― Use Cases
1οΈβ£ Continuous Documentation
Bash
# Initialize with autosave
gencodedoc init --preset python
gencodedoc config set autosave.enabled true
gencodedoc config set autosave.mode hybrid
# Documentation is always up-to-date
gencodedoc doc generate --output docs/API.md
2οΈβ£ Safe Refactoring
Bash
# Snapshot before critical changes
gencodedoc snapshot create \
--message "Before refactoring authentication system" \
--tag before-refactor
# ... make changes ...
# Snapshot after
gencodedoc snapshot create \
--message "After refactoring - tests passing" \
--tag after-refactor
# Compare
gencodedoc snapshot diff before-refactor after-refactor
# Rollback if needed
gencodedoc snapshot restore before-refactor --force
3οΈβ£ Selective API Documentation
Bash
# Document only specific modules
gencodedoc doc generate \
--include src/api/ \
--include src/models/ \
--include README.md \
--output docs/API_Reference.md
4οΈβ£ AI-Assisted Workflow (Gemini/Claude)
Bash
# 1. Configure MCP (once)
# Add gencodedoc to your AI assistant config
# 2. Use natural language
"Create a snapshot with tag v2.0"
"Compare v1.0 and v2.0"
"Show me project statistics"
"Start autosave in hybrid mode"
"Generate complete documentation"
# AI automatically calls the right MCP tools! π
π Roadmap
Git integration (auto-snapshot on commit)
Cloud backup (S3, GCS)
Web UI dashboard
AST-based semantic diff (full implementation)
Multi-language presets (Rust, Java, C++)
Snapshot encryption
Collaborative features (shared snapshots)
π License
MIT License - See LICENSE file
π€ Contributing
Contributions welcome! π
π Report bugs via GitHub Issues
π‘ Suggest features via Discussions
π§ Submit Pull Requests
Development workflow:
Fork the repo
Create a feature branch (git checkout -b feature/amazing)
Make your changes
Run tests (make test)
Submit PR
π Support
π Issues: GitHub Issues
π¬ Discussions: GitHub Discussions
π Website: esprit-artificiel.com
π§ Email: support@esprit-artificiel.com
π Acknowledgments
Built with these amazing tools:
FastAPI - MCP server framework
Pydantic - Data validation
Typer - CLI framework
Rich - Terminal formatting
zstandard - Compression
Watchdog - File monitoring
SQLite - Embedded database
<div align="center">
Made with β€οΈ for developers who love smart versioning and beautiful docs
π‘ Pro Tip: Use GenCodeDoc with Gemini CLI or Claude Desktop for AI-powered version control!
β Star this repo if you find it useful!
</div> ```
π― CHANGEMENTS PAR RAPPORT Γ L`ANCIEN
β
Ajouts majeurs
Badges en haut (Python, Poetry, MCP, License, AI Ready)
Quick Start ultra-visible avec 5 Γ©tapes
17 outils MCP documentΓ©s avec tableau
Architecture ASCII complète
Troubleshooting des 6 bugs qu`on a corrigΓ©s
Exemples d`usage AI concrets
Autosave mieux expliquΓ© (3 modes + tableau)
3 transports clarifiΓ©s (stdio/SSE/REST)
Use cases pratiques (4 scΓ©narios rΓ©els)
Roadmap pour le futur
π¨ AmΓ©liorations visuelles
Emojis cohΓ©rents partout
Tableaux pour comparaisons
Blocs de code bien formatΓ©s
Sections claires avec sΓ©parateurs
Call-to-action en footer
π Mieux organisΓ©
Quick Start en premier (essentiel)
Features avant installation
MCP tools en section dΓ©diΓ©e
Troubleshooting complet
Development sΓ©parΓ©
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo issues