You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🎯 Feature Design: The Self-Documenting Knowledge Portal & README Spec
1. Context & Goal
A great developer-facing, agent-native tool needs documentation that is as high-fidelity as its code.
We will design a unified Documentation Suite that immediately explains the "Why" and "How" of CGIS. The crown jewel of this suite is our README.md, which is self-documenting: it automatically embeds live, color-coded, compile-time architecture diagrams generated by CGIS itself during CI/CD.
2. Documentation Architecture Map
We establish a 3-tier documentation structure inside the /docs directory:
.
├── README.md # 🚀 The Entrypoint: Pitch, Quickstart, Live Self-Graph
└── docs/
├── architecture/
│ ├── HOW_IT_WORKS.md # ⚙️ The Deep-Dive: 3-Pass Compiler Pipelines & SQLite/DuckDB Schemas
│ └── ONTOLOGY.md # 🧬 The Schema: Formal L1-L3 mappings (Nodes, Edges, Domains)
└── how-to/
├── AGENT_ONBOARDING.md# 🤖 The AI Guide: Connecting Cursor, Claude, and using MCP
└── CLI_USAGE.md # 💻 The Human Guide: cgis ingest, trace, impact, structure, health
3. The "Wow-Effect" README.md Spec
The main README.md must immediately hook the reader by showcasing Self-Parsing and Zero-Noise RAG.
Proposed README Outline:
# 🧠 CGIS: Code Graph Intelligence System> Transforming source code into a deterministic, computable, and zero-noise architectural model for AI Agents.[](https://github.com/user/cgis/actions/workflows/ci.yml)[](https://shields.io)
⚡ The "Wow" Effect: Self-Modeling Engine
CGIS is a self-referential compiler frontend. It is the only graph engine that documents its own source code dynamically.
Every time we commit to main, CGIS runs its parser on src/cgis/, generates a local graph.db, and automatically injects its own execution call-tree directly into this README!
📊 Live System Architecture (Auto-Generated by CGIS)
# 1. Install via uv (ultra-fast)
uv pip install cgis
# 2. Ingest your codebase (Generates optimized, cached graph.db)
cgis ingest ./src --output graph.db
# 3. Analyze impact of a critical change (Who calls this?)
cgis impact "my_package.auth.verify_token"# 4. Check your overall graph health
cgis health --db graph.db
4. The Agentic Onboarding Guide (AGENT_ONBOARDING.md)
This document is specifically tailored for LLMs and developers setting up local AI workflows. It explains how to let Claude/Cursor "self-drive" the codebase.
Core Sections:
FastMCP Registration: Step-by-step JSON configs for Claude Desktop (claude_desktop_config.json) and Cursor.
The "Self-Driving" Prompts: Concrete prompts to trigger autonomous debugging.
Example:"Claude, use cgis_analyze_impact on models.py:Node to find out what files we need to update if we add a new metadata field, then write the PR."
Why this beats Vector RAG: A simple comparison showing how CGIS cuts token costs by 85% by emitting 1-depth subgraphs instead of dumping whole files.
5. The "How It Works" Deep-Dive (HOW_IT_WORKS.md)
For Knowledge Engineers, Architects, and Compiler Enthusiasts, explaining our execution pipeline.
Pass 2: Local Namespace Import Mapping (LNM per file).
Pass 3: Linkage & Type Propagation (resolving var.method() to absolute FQN).
Dual-Store Database Schema: SQLite (OLTP) for traversing, DuckDB (OLAP) for PageRank and metrics.
🧪 TDD Acceptance Criteria
Test 1 (Documentation Existence): Verify that running the documentation build script or linting step checks that all files in the docs/ tree are present and have valid markdown formatting.
Test 2 (Readme Anchor Verification): Confirm that README.md contains the strict HTML comment blocks <!-- START_CGIS_GRAPH --> and <!-- END_CGIS_GRAPH --> to ensure the autodoc pipeline can inject diagrams.
A professional developer-facing, agent-native tool must have documentation that is as high-fidelity and strictly validated as its code.
We will establish a Self-Documenting Knowledge Portal. The core architectural goal is to make documentation a dynamic, self-parsing, and self-validating artifact.
Our main README.md and MCP reference guides will be compiled automatically during CI/CD using CGIS's own graph database, and we will enforce a strict 90% docstring coverage guardrail using interrogate.
2. Hardened Documentation Map (The Monorepo Tree)
We establish a 3-tier directory layout inside our monoreпо:
.
├── README.md # 🚀 Entrypoint: Pitch, Quickstart, Live Self-Graph
├── scripts/
│ ├── inject_readme_graph.py # Inserts compiled Mermaid into README.md
│ └── generate_mcp_ref.py # Auto-compiles FastMCP tools schema to Markdown
└── docs/
├── architecture/
│ ├── HOW_IT_WORKS.md # ⚙️ Technical Deep-Dive: 3-Pass Compiler & DB Schemas
│ └── ONTOLOGY.md # 🧬 L1-L3 Formal Ontology Mapping Contracts
└── how-to/
├── AGENT_ONBOARDING.md# 🤖 AI Agent Onboarding: FastMCP, prompts, token metrics
├── CLI_USAGE.md # 💻 Human Manual: ingest, trace, impact, structure, health
└── MCP_REFERENCE.md # 📑 [AUTO-GENERATED] Formal API schema of all MCP tools
3. GitHub Actions Workflows
A. The Verification Pipeline (.github/workflows/ci.yml)
Enforces strict linting, type-checking, docstring coverage, and runs the fast Bun-powered Vite frontend build.
name: Continuous Integrationon:
push:
branches: [ main, dev, "feat/**" ]pull_request:
branches: [ main ]jobs:
python-ci:
name: Python Backend Verificationruns-on: ubuntu-lateststeps:
- name: Checkout Codeuses: actions/checkout@v4
- name: Setup Astral 'uv'uses: astral-sh/setup-uv@v3with:
enable-cache: truepython-version: "3.12"
- name: Install Dependenciesrun: uv pip install -e .[dev]
- name: Run Ruff (Format & Lint Check)run: | uv run ruff format --check . uv run ruff check .
- name: Run Interrogate (90% Docstring Coverage Guardrail)run: | # Fails the build if code documentation falls below 90% uv run interrogate -v src
- name: Run Mypy (Strict Type Checking)run: uv run mypy src
- name: Run Pytest (Includes Self-Parsing & Ontology Compliance)run: uv run pytest --cov=src --cov-report=term-missingreact-ci:
name: React Frontend (Bun-powered)runs-on: ubuntu-lateststeps:
- name: Checkout Codeuses: actions/checkout@v4
- name: Setup Bunuses: oven-sh/setup-bun@v2with:
bun-version: latest
- name: Install Dependenciesrun: cd ui && bun install
- name: Lint & Format Checkrun: cd ui && bun run lint
- name: Run Vite Production Buildrun: cd ui && bun run build
B. The Self-Documenting Pipeline (.github/workflows/autodoc.yml)
Runs strictly on merges to main. It self-ingests the codebase, generates Mermaid diagrams, compiles the dynamic MCP reference, and commits changes back with [skip ci].
name: Self-Documenting Architecture Syncon:
push:
branches: [ main ]permissions:
contents: write # Grants write permissions to commit generated docs back to mainjobs:
sync-architecture-docs:
runs-on: ubuntu-lateststeps:
- name: Checkout Codeuses: actions/checkout@v4with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Python via 'uv'uses: astral-sh/setup-uv@v3with:
enable-cache: truepython-version: "3.12"
- name: Install CGISrun: uv pip install -e .
- name: Step 1: Self-Ingest Core Enginerun: uv run cgis ingest ./src --output docs/architecture/self_graph.db
- name: Step 2: Generate Raw Mermaid Diagramsrun: | mkdir -p docs/architecture/diagrams # Compile the execution trace of the core IngestionPipeline.run method uv run cgis trace "cgis.pipeline.IngestionPipeline.run" --depth 2 -f mermaid > docs/architecture/diagrams/pipeline_flow.mermaid
- name: Step 3: Run Python Script to Inject Graph into Root README.mdrun: uv run python scripts/inject_readme_graph.py
- name: Step 4: Run Python Script to Compile MCP Reference Manualrun: uv run python scripts/generate_mcp_ref.py
- name: Step 5: Auto-Commit Back to Main [with skip ci]run: | git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" git add README.md docs/ if ! git diff-index --quiet HEAD; then # [skip ci] prevents infinite recursive GHA workflow loops git commit -m "docs: auto-sync README.md and MCP reference [skip ci]" git push origin main fi
Performs programmatical introspection of the FastMCP server instance to generate MCP_REFERENCE.md [INDEX_1.1.2, INDEX_1.1.8, INDEX_3].
# src/cgis/scripts/generate_mcp_ref.pyfrompathlibimportPathfromcgis.api.mcp_serverimportmcp# Import our active server instancedefgenerate_reference():
output_path=Path("docs/how-to/MCP_REFERENCE.md")
output_path.parent.mkdir(parents=True, exist_ok=True)
lines= [
"# 📑 MCP Tools Reference Manual",
"*Auto-compiled from FastMCP docstrings and type annotations.*",
""
]
# Introspect the registered FastMCP tools# E.g. traversing mcp.tools dictionaryfortool_name, toolinsorted(mcp.tools.items()):
lines.append(f"## `cgis_{tool_name}`")
lines.append(f"**Description:** {tool.descriptionor'No description provided.'}\n")
lines.append("### Arguments:")
# Generate markdown table for arguments schemaslines.append("| Argument | Type | Required | Description |")
lines.append("| :--- | :--- | :--- | :--- |")
# FastMCP stores arguments in pydantic fields or propertiesforparam_name, paramintool.parameters.model_fields.items():
req_str="Yes"ifparam.is_required() else"No"lines.append(f"| `{param_name}` | `{param.annotation.__name__}` | {req_str} | {param.descriptionor'N/A'} |")
lines.append("\n---\n")
output_path.write_text("\n".join(lines), encoding="utf-8")
print("✅ Successfully generated docs/how-to/MCP_REFERENCE.md")
if__name__=="__main__":
generate_reference()
5. TDD Acceptance Criteria
Test 1 (Docstring Coverage Guardrail): Adding a public function inside src/cgis without a docstring must cause interrogate to exit with code 1 and fail the CI pipeline.
Test 2 (Idempotent Markdown Replacement): Running inject_readme_graph.py multiple times consecutively must result in the exact same README.md content without duplicating tags.
Test 3 (FastMCP Schema Introspection): Running generate_mcp_ref.py must successfully extract all four tools (cgis_ingest, cgis_trace_flow, cgis_analyze_impact, cgis_get_structure) and correctly map their Pydantic property schemas.
🎯 Feature Design: The Self-Documenting Knowledge Portal & README Spec
1. Context & Goal
A great developer-facing, agent-native tool needs documentation that is as high-fidelity as its code.
We will design a unified Documentation Suite that immediately explains the "Why" and "How" of CGIS. The crown jewel of this suite is our README.md, which is self-documenting: it automatically embeds live, color-coded, compile-time architecture diagrams generated by CGIS itself during CI/CD.
2. Documentation Architecture Map
We establish a 3-tier documentation structure inside the
/docsdirectory:3. The "Wow-Effect" README.md Spec
The main
README.mdmust immediately hook the reader by showcasing Self-Parsing and Zero-Noise RAG.Proposed README Outline:
⚡ The "Wow" Effect: Self-Modeling Engine
CGIS is a self-referential compiler frontend. It is the only graph engine that documents its own source code dynamically.
Every time we commit to
main, CGIS runs its parser onsrc/cgis/, generates a localgraph.db, and automatically injects its own execution call-tree directly into this README!📊 Live System Architecture (Auto-Generated by CGIS)
graph TD n_cli["cgis.cli.ingest (cli.py:54)"] -- CALLS --> n_pipe["cgis.pipeline.IngestionPipeline.run (pipeline.py:36)"] n_pipe -- CALLS --> n_ext["cgis.extractors.python_extractor.PythonExtractor.parse (python_extractor.py:60)"] n_pipe -- CALLS --> n_res["cgis.resolver.engine.ResolverEngine.resolve (engine.py:60)"] n_pipe -- CALLS --> n_db["cgis.storage.sqlite_store.SQLiteStore.save_incremental_batch (sqlite_store.py:255)"]🚀 Quickstart in 30 Seconds
4. The Agentic Onboarding Guide (
AGENT_ONBOARDING.md)This document is specifically tailored for LLMs and developers setting up local AI workflows. It explains how to let Claude/Cursor "self-drive" the codebase.
Core Sections:
claude_desktop_config.json) and Cursor.cgis_analyze_impactonmodels.py:Nodeto find out what files we need to update if we add a new metadata field, then write the PR."5. The "How It Works" Deep-Dive (
HOW_IT_WORKS.md)For Knowledge Engineers, Architects, and Compiler Enthusiasts, explaining our execution pipeline.
Core Sections:
CONTAINS/DECLARESvia Tree-sitter).var.method()to absolute FQN).🧪 TDD Acceptance Criteria
docs/tree are present and have valid markdown formatting.README.mdcontains the strict HTML comment blocks<!-- START_CGIS_GRAPH -->and<!-- END_CGIS_GRAPH -->to ensure the autodoc pipeline can inject diagrams.UPDATES
🎯 Feature Design: The Self-Documenting Knowledge Portal & README Spec (Issue #62)
1. Context & Goal
A professional developer-facing, agent-native tool must have documentation that is as high-fidelity and strictly validated as its code.
We will establish a Self-Documenting Knowledge Portal. The core architectural goal is to make documentation a dynamic, self-parsing, and self-validating artifact.
Our main
README.mdand MCP reference guides will be compiled automatically during CI/CD using CGIS's own graph database, and we will enforce a strict 90% docstring coverage guardrail usinginterrogate.2. Hardened Documentation Map (The Monorepo Tree)
We establish a 3-tier directory layout inside our monoreпо:
3. GitHub Actions Workflows
A. The Verification Pipeline (
.github/workflows/ci.yml)Enforces strict linting, type-checking, docstring coverage, and runs the fast Bun-powered Vite frontend build.
B. The Self-Documenting Pipeline (
.github/workflows/autodoc.yml)Runs strictly on merges to
main. It self-ingests the codebase, generates Mermaid diagrams, compiles the dynamic MCP reference, and commits changes back with[skip ci].4. Algorithmic Blueprints (Automation Scripts)
Script 1: README.md Graph Injector (
scripts/inject_readme_graph.py)Performs a safe, idempotent string-block replacement using HTML comment delimiters.
Script 2: FastMCP Documenter (
scripts/generate_mcp_ref.py)Performs programmatical introspection of the
FastMCPserver instance to generateMCP_REFERENCE.md[INDEX_1.1.2, INDEX_1.1.8, INDEX_3].5. TDD Acceptance Criteria
src/cgiswithout a docstring must causeinterrogateto exit with code1and fail the CI pipeline.inject_readme_graph.pymultiple times consecutively must result in the exact sameREADME.mdcontent without duplicating tags.generate_mcp_ref.pymust successfully extract all four tools (cgis_ingest,cgis_trace_flow,cgis_analyze_impact,cgis_get_structure) and correctly map their Pydantic property schemas.