codewiki 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codewiki-0.1.0/PKG-INFO +289 -0
- codewiki-0.1.0/README.md +238 -0
- codewiki-0.1.0/backend/__init__.py +2 -0
- codewiki-0.1.0/backend/app/__init__.py +2 -0
- codewiki-0.1.0/backend/app/api/__init__.py +2 -0
- codewiki-0.1.0/backend/app/api/ask.py +37 -0
- codewiki-0.1.0/backend/app/api/dependencies.py +63 -0
- codewiki-0.1.0/backend/app/api/files.py +101 -0
- codewiki-0.1.0/backend/app/api/graph.py +183 -0
- codewiki-0.1.0/backend/app/api/repos.py +74 -0
- codewiki-0.1.0/backend/app/api/runs.py +148 -0
- codewiki-0.1.0/backend/app/api/settings.py +50 -0
- codewiki-0.1.0/backend/app/api/wiki.py +224 -0
- codewiki-0.1.0/backend/app/cli.py +538 -0
- codewiki-0.1.0/backend/app/config.py +49 -0
- codewiki-0.1.0/backend/app/database.py +25 -0
- codewiki-0.1.0/backend/app/db/__init__.py +24 -0
- codewiki-0.1.0/backend/app/db/base.py +124 -0
- codewiki-0.1.0/backend/app/db/mappers.py +158 -0
- codewiki-0.1.0/backend/app/db/records.py +21 -0
- codewiki-0.1.0/backend/app/db/repositories/__init__.py +21 -0
- codewiki-0.1.0/backend/app/db/repositories/analysis_runs.py +56 -0
- codewiki-0.1.0/backend/app/db/repositories/code_chunks.py +145 -0
- codewiki-0.1.0/backend/app/db/repositories/code_graph.py +101 -0
- codewiki-0.1.0/backend/app/db/repositories/communities.py +41 -0
- codewiki-0.1.0/backend/app/db/repositories/embeddings.py +210 -0
- codewiki-0.1.0/backend/app/db/repositories/graphrag.py +11 -0
- codewiki-0.1.0/backend/app/db/repositories/llm_runs.py +102 -0
- codewiki-0.1.0/backend/app/db/repositories/repos.py +83 -0
- codewiki-0.1.0/backend/app/db/repositories/wiki.py +184 -0
- codewiki-0.1.0/backend/app/db/schema.py +12 -0
- codewiki-0.1.0/backend/app/db/store.py +30 -0
- codewiki-0.1.0/backend/app/db/utils.py +14 -0
- codewiki-0.1.0/backend/app/main.py +35 -0
- codewiki-0.1.0/backend/app/models/__init__.py +20 -0
- codewiki-0.1.0/backend/app/models/base.py +48 -0
- codewiki-0.1.0/backend/app/models/graph.py +117 -0
- codewiki-0.1.0/backend/app/models/rag.py +109 -0
- codewiki-0.1.0/backend/app/models/repo.py +115 -0
- codewiki-0.1.0/backend/app/models/wiki.py +72 -0
- codewiki-0.1.0/backend/app/prompts/catalog.md +112 -0
- codewiki-0.1.0/backend/app/prompts/community_summary.md +18 -0
- codewiki-0.1.0/backend/app/prompts/page.md +104 -0
- codewiki-0.1.0/backend/app/prompts/qa.md +8 -0
- codewiki-0.1.0/backend/app/prompts/translation.md +26 -0
- codewiki-0.1.0/backend/app/schemas/__init__.py +2 -0
- codewiki-0.1.0/backend/app/schemas/ask.py +26 -0
- codewiki-0.1.0/backend/app/schemas/graph.py +43 -0
- codewiki-0.1.0/backend/app/schemas/wiki.py +25 -0
- codewiki-0.1.0/backend/app/services/__init__.py +2 -0
- codewiki-0.1.0/backend/app/services/analysis_pipeline.py +91 -0
- codewiki-0.1.0/backend/app/services/analyzer.py +164 -0
- codewiki-0.1.0/backend/app/services/ast_cache.py +86 -0
- codewiki-0.1.0/backend/app/services/ast_parser.py +65 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/__init__.py +32 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/augmenters/__init__.py +1 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/augmenters/c.py +12 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/augmenters/capture_only.py +14 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/augmenters/cpp.py +12 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/augmenters/csharp.py +12 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/augmenters/ecma.py +43 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/augmenters/go.py +390 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/augmenters/java.py +398 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/augmenters/python.py +238 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/augmenters/rust.py +12 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/base.py +33 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/c.py +28 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/capture_engine/__init__.py +10 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/capture_engine/captures.py +144 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/capture_engine/models.py +36 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/capture_engine/normalization.py +24 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/capture_engine/parser.py +117 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/capture_engine/symbols.py +50 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/capture_engine/topology.py +26 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/capture_specs/__init__.py +1 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/capture_specs/c.py +16 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/capture_specs/cpp.py +37 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/capture_specs/csharp.py +34 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/capture_specs/ecma.py +67 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/capture_specs/go.py +43 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/capture_specs/java.py +35 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/capture_specs/python.py +24 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/capture_specs/rust.py +34 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/common.py +15 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/cpp.py +28 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/csharp.py +28 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/ecma/__init__.py +6 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/ecma/declarations.py +286 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/ecma/endpoints.py +83 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/ecma/imports.py +27 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/ecma/parser.py +52 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/ecma/schemas.py +74 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/go.py +28 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/java.py +28 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/python.py +28 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/registry.py +100 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/rust.py +28 -0
- codewiki-0.1.0/backend/app/services/ast_parsers/tree.py +40 -0
- codewiki-0.1.0/backend/app/services/chunk_builder.py +84 -0
- codewiki-0.1.0/backend/app/services/community_detector.py +172 -0
- codewiki-0.1.0/backend/app/services/community_namer.py +129 -0
- codewiki-0.1.0/backend/app/services/community_naming/__init__.py +49 -0
- codewiki-0.1.0/backend/app/services/community_naming/batching.py +6 -0
- codewiki-0.1.0/backend/app/services/community_naming/constants.py +6 -0
- codewiki-0.1.0/backend/app/services/community_naming/fallback.py +66 -0
- codewiki-0.1.0/backend/app/services/community_naming/models.py +12 -0
- codewiki-0.1.0/backend/app/services/community_naming/payloads.py +116 -0
- codewiki-0.1.0/backend/app/services/community_naming/response.py +135 -0
- codewiki-0.1.0/backend/app/services/community_records.py +220 -0
- codewiki-0.1.0/backend/app/services/embedding_index.py +115 -0
- codewiki-0.1.0/backend/app/services/graph/__init__.py +4 -0
- codewiki-0.1.0/backend/app/services/graph/builder.py +459 -0
- codewiki-0.1.0/backend/app/services/graph/call_resolver.py +117 -0
- codewiki-0.1.0/backend/app/services/graph/confidence.py +49 -0
- codewiki-0.1.0/backend/app/services/graph/config_detector.py +140 -0
- codewiki-0.1.0/backend/app/services/graph/ids.py +22 -0
- codewiki-0.1.0/backend/app/services/graph/import_resolver.py +130 -0
- codewiki-0.1.0/backend/app/services/graph/models.py +37 -0
- codewiki-0.1.0/backend/app/services/graph/node_factory.py +169 -0
- codewiki-0.1.0/backend/app/services/graph/nodes.py +23 -0
- codewiki-0.1.0/backend/app/services/graph_provenance.py +127 -0
- codewiki-0.1.0/backend/app/services/graphrag/__init__.py +5 -0
- codewiki-0.1.0/backend/app/services/graphrag/chunking.py +3 -0
- codewiki-0.1.0/backend/app/services/graphrag/constants.py +19 -0
- codewiki-0.1.0/backend/app/services/graphrag/context.py +175 -0
- codewiki-0.1.0/backend/app/services/graphrag/embedding.py +3 -0
- codewiki-0.1.0/backend/app/services/graphrag/expansion.py +74 -0
- codewiki-0.1.0/backend/app/services/graphrag/indexer.py +42 -0
- codewiki-0.1.0/backend/app/services/graphrag/models.py +41 -0
- codewiki-0.1.0/backend/app/services/graphrag/ranking.py +197 -0
- codewiki-0.1.0/backend/app/services/graphrag/retriever.py +189 -0
- codewiki-0.1.0/backend/app/services/graphrag/search.py +103 -0
- codewiki-0.1.0/backend/app/services/graphrag/utils.py +72 -0
- codewiki-0.1.0/backend/app/services/incremental/__init__.py +19 -0
- codewiki-0.1.0/backend/app/services/incremental/models.py +63 -0
- codewiki-0.1.0/backend/app/services/incremental/planning.py +84 -0
- codewiki-0.1.0/backend/app/services/incremental/symbol_recovery.py +81 -0
- codewiki-0.1.0/backend/app/services/incremental/updater.py +198 -0
- codewiki-0.1.0/backend/app/services/incremental/wiki_regeneration.py +49 -0
- codewiki-0.1.0/backend/app/services/language_detector.py +94 -0
- codewiki-0.1.0/backend/app/services/llm_gateway.py +125 -0
- codewiki-0.1.0/backend/app/services/llm_operations.py +41 -0
- codewiki-0.1.0/backend/app/services/llm_run_recorder.py +248 -0
- codewiki-0.1.0/backend/app/services/model_router.py +92 -0
- codewiki-0.1.0/backend/app/services/prompts.py +5 -0
- codewiki-0.1.0/backend/app/services/question_answerer.py +109 -0
- codewiki-0.1.0/backend/app/services/repo_context.py +192 -0
- codewiki-0.1.0/backend/app/services/repo_metadata.py +85 -0
- codewiki-0.1.0/backend/app/services/repo_scanner/__init__.py +42 -0
- codewiki-0.1.0/backend/app/services/repo_scanner/file_info.py +34 -0
- codewiki-0.1.0/backend/app/services/repo_scanner/filesystem.py +61 -0
- codewiki-0.1.0/backend/app/services/repo_scanner/git.py +165 -0
- codewiki-0.1.0/backend/app/services/repo_scanner/git_ops.py +32 -0
- codewiki-0.1.0/backend/app/services/repo_scanner/ignore.py +91 -0
- codewiki-0.1.0/backend/app/services/repo_scanner/models.py +32 -0
- codewiki-0.1.0/backend/app/services/repo_scanner/scanner.py +135 -0
- codewiki-0.1.0/backend/app/services/wiki/__init__.py +4 -0
- codewiki-0.1.0/backend/app/services/wiki/agent_tools.py +117 -0
- codewiki-0.1.0/backend/app/services/wiki/catalog/__init__.py +298 -0
- codewiki-0.1.0/backend/app/services/wiki/catalog/source_hints.py +81 -0
- codewiki-0.1.0/backend/app/services/wiki/catalog_generator.py +261 -0
- codewiki-0.1.0/backend/app/services/wiki/catalog_planner.py +96 -0
- codewiki-0.1.0/backend/app/services/wiki/diagrams/__init__.py +271 -0
- codewiki-0.1.0/backend/app/services/wiki/diagrams/components.py +162 -0
- codewiki-0.1.0/backend/app/services/wiki/diagrams/data_flow.py +40 -0
- codewiki-0.1.0/backend/app/services/wiki/diagrams/data_model.py +220 -0
- codewiki-0.1.0/backend/app/services/wiki/diagrams/models.py +55 -0
- codewiki-0.1.0/backend/app/services/wiki/diagrams/rendering.py +165 -0
- codewiki-0.1.0/backend/app/services/wiki/diagrams/sequence.py +45 -0
- codewiki-0.1.0/backend/app/services/wiki/diagrams/symbol_flow.py +174 -0
- codewiki-0.1.0/backend/app/services/wiki/generator.py +139 -0
- codewiki-0.1.0/backend/app/services/wiki/incremental_strategy.py +86 -0
- codewiki-0.1.0/backend/app/services/wiki/language.py +30 -0
- codewiki-0.1.0/backend/app/services/wiki/markdown.py +22 -0
- codewiki-0.1.0/backend/app/services/wiki/mermaid_validation.py +68 -0
- codewiki-0.1.0/backend/app/services/wiki/page_generator.py +239 -0
- codewiki-0.1.0/backend/app/services/wiki/page_orchestrator.py +212 -0
- codewiki-0.1.0/backend/app/services/wiki/page_payload.py +90 -0
- codewiki-0.1.0/backend/app/services/wiki/page_payload_context.py +151 -0
- codewiki-0.1.0/backend/app/services/wiki/page_payload_template.py +175 -0
- codewiki-0.1.0/backend/app/services/wiki/page_validation.py +145 -0
- codewiki-0.1.0/backend/app/services/wiki/prompts.py +80 -0
- codewiki-0.1.0/backend/app/services/wiki/sources/__init__.py +41 -0
- codewiki-0.1.0/backend/app/services/wiki/sources/citations.py +272 -0
- codewiki-0.1.0/backend/app/services/wiki/sources/rendering.py +279 -0
- codewiki-0.1.0/backend/app/services/wiki/sources/urls.py +42 -0
- codewiki-0.1.0/backend/app/services/wiki/translation.py +269 -0
- codewiki-0.1.0/backend/app/services/wiki/translation_orchestrator.py +264 -0
- codewiki-0.1.0/backend/app/services/wiki/translation_support.py +175 -0
- codewiki-0.1.0/backend/app/services/wiki/tree.py +91 -0
- codewiki-0.1.0/backend/app/services/wiki/utils.py +17 -0
- codewiki-0.1.0/codewiki.egg-info/PKG-INFO +289 -0
- codewiki-0.1.0/codewiki.egg-info/SOURCES.txt +197 -0
- codewiki-0.1.0/codewiki.egg-info/dependency_links.txt +1 -0
- codewiki-0.1.0/codewiki.egg-info/entry_points.txt +2 -0
- codewiki-0.1.0/codewiki.egg-info/requires.txt +32 -0
- codewiki-0.1.0/codewiki.egg-info/top_level.txt +1 -0
- codewiki-0.1.0/pyproject.toml +86 -0
- codewiki-0.1.0/setup.cfg +4 -0
codewiki-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codewiki
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Local-first code wiki platform with AST graph analysis, GraphRAG, and LiteLLM.
|
|
5
|
+
Author-email: PorunC <09982.misaka@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/PorunC/CodeWiki
|
|
7
|
+
Project-URL: Repository, https://github.com/PorunC/CodeWiki
|
|
8
|
+
Project-URL: Issues, https://github.com/PorunC/CodeWiki/issues
|
|
9
|
+
Keywords: code-wiki,graphrag,fastapi,llm,documentation
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Framework :: FastAPI
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Documentation
|
|
18
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
20
|
+
Requires-Python: >=3.12
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
Requires-Dist: aiosqlite>=0.20.0
|
|
23
|
+
Requires-Dist: click>=8.1.0
|
|
24
|
+
Requires-Dist: fastapi>=0.115.0
|
|
25
|
+
Requires-Dist: graspologic>=3.4.4; python_version < "3.13"
|
|
26
|
+
Requires-Dist: httpx[socks]>=0.28.1
|
|
27
|
+
Requires-Dist: litellm>=1.60.0
|
|
28
|
+
Requires-Dist: mermaid-parser-py>=0.0.4
|
|
29
|
+
Requires-Dist: networkx>=3.4.0
|
|
30
|
+
Requires-Dist: pathspec>=0.12.1
|
|
31
|
+
Requires-Dist: pydantic>=2.10.0
|
|
32
|
+
Requires-Dist: pydantic-settings>=2.7.0
|
|
33
|
+
Requires-Dist: python-dotenv>=1.0.1
|
|
34
|
+
Requires-Dist: sqlite-vec>=0.1.9
|
|
35
|
+
Requires-Dist: sqlalchemy>=2.0.35
|
|
36
|
+
Requires-Dist: tree-sitter>=0.23.0
|
|
37
|
+
Requires-Dist: tree-sitter-c>=0.24.2
|
|
38
|
+
Requires-Dist: tree-sitter-c-sharp>=0.23.5
|
|
39
|
+
Requires-Dist: tree-sitter-cpp>=0.23.4
|
|
40
|
+
Requires-Dist: tree-sitter-go>=0.25.0
|
|
41
|
+
Requires-Dist: tree-sitter-java>=0.23.5
|
|
42
|
+
Requires-Dist: tree-sitter-javascript>=0.25.0
|
|
43
|
+
Requires-Dist: tree-sitter-python>=0.25.0
|
|
44
|
+
Requires-Dist: tree-sitter-rust>=0.24.2
|
|
45
|
+
Requires-Dist: tree-sitter-typescript>=0.23.2
|
|
46
|
+
Requires-Dist: uvicorn[standard]>=0.34.0
|
|
47
|
+
Provides-Extra: dev
|
|
48
|
+
Requires-Dist: pytest>=8.3.0; extra == "dev"
|
|
49
|
+
Requires-Dist: pytest-asyncio>=0.25.0; extra == "dev"
|
|
50
|
+
Requires-Dist: ruff>=0.8.0; extra == "dev"
|
|
51
|
+
|
|
52
|
+
# CodeWiki
|
|
53
|
+
|
|
54
|
+
Single-user CodeWiki platform for AST-based code graph analysis, GraphRAG retrieval,
|
|
55
|
+
source-grounded wiki generation, and LiteLLM-powered Q&A.
|
|
56
|
+
|
|
57
|
+
## Current Scope
|
|
58
|
+
|
|
59
|
+
- FastAPI backend with repository management, analysis runs, GraphRAG, wiki, ask, graph,
|
|
60
|
+
file, run, and settings APIs.
|
|
61
|
+
- React/Vite frontend with repository management plus graph explorer, wiki reader,
|
|
62
|
+
ask, and settings pages.
|
|
63
|
+
- AST-backed code graph extraction for Python, TypeScript/TSX, JavaScript/JSX, Java,
|
|
64
|
+
Go, Rust, C, C++, and C#.
|
|
65
|
+
- Deterministic graph edges for imports, exports, definitions, inheritance,
|
|
66
|
+
implementations, calls, route handlers, source references, and configuration usage.
|
|
67
|
+
- GraphRAG retrieval with source chunks, optional embeddings, community summaries,
|
|
68
|
+
and cached LLM runs.
|
|
69
|
+
- DeepWiki-style wiki generation with catalog planning, detailed page generation,
|
|
70
|
+
source citations, automatic diagrams, multi-language translation, and incremental
|
|
71
|
+
updates.
|
|
72
|
+
- Pure frontend wiki exports: interactive standalone HTML and Obsidian vault ZIP.
|
|
73
|
+
- Design notes live in `docs/design.md`.
|
|
74
|
+
|
|
75
|
+
## Installation
|
|
76
|
+
|
|
77
|
+
Install the Python package from PyPI:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pip install codewiki
|
|
81
|
+
codewiki --help
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Start the backend API after installation:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
codewiki serve
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The source checkout is still the recommended way to run the full backend + Vite
|
|
91
|
+
frontend development stack.
|
|
92
|
+
|
|
93
|
+
## Wiki Workflow
|
|
94
|
+
|
|
95
|
+
1. Register and analyze a repository.
|
|
96
|
+
2. Build GraphRAG source chunks, optionally with embeddings.
|
|
97
|
+
3. Generate a wiki catalog.
|
|
98
|
+
4. Generate wiki pages from the catalog.
|
|
99
|
+
5. Use update/regenerate flows when code changes.
|
|
100
|
+
|
|
101
|
+
Wiki pages are generated from deterministic graph facts and retrieved source chunks.
|
|
102
|
+
The page prompt enforces a gather/think/write workflow and includes ReadFile evidence so
|
|
103
|
+
the model must stay close to real source files. Source references are validated before a
|
|
104
|
+
page is promoted to `generated`; otherwise the page is saved as `draft` with validation
|
|
105
|
+
errors.
|
|
106
|
+
|
|
107
|
+
Mermaid diagrams are generated server-side from validated graph facts. Invalid diagrams
|
|
108
|
+
are filtered out instead of failing the whole page, so a bad graph block should not turn
|
|
109
|
+
a good wiki page into a draft.
|
|
110
|
+
|
|
111
|
+
## Wiki Languages
|
|
112
|
+
|
|
113
|
+
The base wiki language is generated first. Other languages are produced by translating
|
|
114
|
+
the base catalog and pages while preserving slugs, source references, code identifiers,
|
|
115
|
+
links, and Markdown structure.
|
|
116
|
+
|
|
117
|
+
Set configured translation languages in `.env`:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
CODEWIKI_WIKI_BASE_LANGUAGE=en
|
|
121
|
+
CODEWIKI_WIKI_TRANSLATION_LANGUAGES=zh
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The frontend wiki page has an English/Chinese language switch above the left catalog
|
|
125
|
+
navigation. If a requested non-base language is missing, the backend generates the base
|
|
126
|
+
wiki first and then translates it.
|
|
127
|
+
|
|
128
|
+
## Wiki Export
|
|
129
|
+
|
|
130
|
+
The frontend wiki toolbar can export the currently selected language as:
|
|
131
|
+
|
|
132
|
+
- Interactive HTML: a standalone static page with catalog navigation, page switching,
|
|
133
|
+
rendered Markdown, source sections, related pages, and Mermaid rendering.
|
|
134
|
+
- Obsidian vault: a ZIP containing Markdown pages, wiki links, source metadata, and
|
|
135
|
+
minimal `.obsidian` settings.
|
|
136
|
+
|
|
137
|
+
Exports are built entirely in the browser from already-loaded wiki data and do not
|
|
138
|
+
require a backend export API.
|
|
139
|
+
|
|
140
|
+
## LLM Configuration
|
|
141
|
+
|
|
142
|
+
Copy `.env.example` and fill in a default model profile:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
cp .env.example .env
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
The default profile is used for every task unless a task-specific profile overrides it.
|
|
149
|
+
This is the simplest "use one model for everything" setup:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
CODEWIKI_LLM__MODE=sdk
|
|
153
|
+
CODEWIKI_LLM__DEFAULT__MODEL=provider/strong-coding-model
|
|
154
|
+
CODEWIKI_LLM__DEFAULT__PROVIDER_TYPE=
|
|
155
|
+
CODEWIKI_LLM__DEFAULT__ENDPOINT=
|
|
156
|
+
CODEWIKI_LLM__DEFAULT__API_KEY=
|
|
157
|
+
CODEWIKI_LLM__TIMEOUT_SECONDS=120
|
|
158
|
+
CODEWIKI_LLM__MAX_RETRIES=3
|
|
159
|
+
CODEWIKI_LLM__CACHE_ENABLED=true
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Each LLM task can override model, provider type, endpoint, and API key:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# Fast/cheap catalog planning
|
|
166
|
+
CODEWIKI_LLM__PROFILES__CATALOG__MODEL=
|
|
167
|
+
CODEWIKI_LLM__PROFILES__CATALOG__PROVIDER_TYPE=
|
|
168
|
+
CODEWIKI_LLM__PROFILES__CATALOG__ENDPOINT=
|
|
169
|
+
CODEWIKI_LLM__PROFILES__CATALOG__API_KEY=
|
|
170
|
+
|
|
171
|
+
# Strong source-grounded wiki page generation
|
|
172
|
+
CODEWIKI_LLM__PROFILES__PAGE__MODEL=
|
|
173
|
+
CODEWIKI_LLM__PROFILES__PAGE__PROVIDER_TYPE=
|
|
174
|
+
CODEWIKI_LLM__PROFILES__PAGE__ENDPOINT=
|
|
175
|
+
CODEWIKI_LLM__PROFILES__PAGE__API_KEY=
|
|
176
|
+
|
|
177
|
+
# Translation
|
|
178
|
+
CODEWIKI_LLM__PROFILES__TRANSLATION__MODEL=
|
|
179
|
+
CODEWIKI_LLM__PROFILES__TRANSLATION__PROVIDER_TYPE=
|
|
180
|
+
CODEWIKI_LLM__PROFILES__TRANSLATION__ENDPOINT=
|
|
181
|
+
CODEWIKI_LLM__PROFILES__TRANSLATION__API_KEY=
|
|
182
|
+
|
|
183
|
+
# Ask / QA
|
|
184
|
+
CODEWIKI_LLM__PROFILES__QA__MODEL=
|
|
185
|
+
CODEWIKI_LLM__PROFILES__QA__PROVIDER_TYPE=
|
|
186
|
+
CODEWIKI_LLM__PROFILES__QA__ENDPOINT=
|
|
187
|
+
CODEWIKI_LLM__PROFILES__QA__API_KEY=
|
|
188
|
+
|
|
189
|
+
# Embeddings, used when GraphRAG vector indexing is enabled
|
|
190
|
+
CODEWIKI_LLM__PROFILES__EMBEDDING__MODEL=
|
|
191
|
+
CODEWIKI_LLM__PROFILES__EMBEDDING__PROVIDER_TYPE=
|
|
192
|
+
CODEWIKI_LLM__PROFILES__EMBEDDING__ENDPOINT=
|
|
193
|
+
CODEWIKI_LLM__PROFILES__EMBEDDING__API_KEY=
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Provider examples depend on LiteLLM. For OpenAI-compatible endpoints, set an endpoint
|
|
197
|
+
and API key. For native LiteLLM providers, set `PROVIDER_TYPE` and model according to
|
|
198
|
+
LiteLLM's provider naming.
|
|
199
|
+
|
|
200
|
+
Failed LLM provider calls are recorded in `llm_run` with `status=error`; API responses
|
|
201
|
+
return a `run_id` where possible so failures can be traced without exposing API keys.
|
|
202
|
+
|
|
203
|
+
## Development
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
# Install backend and frontend dependencies
|
|
207
|
+
make install
|
|
208
|
+
|
|
209
|
+
# Start FastAPI and Vite
|
|
210
|
+
make start
|
|
211
|
+
|
|
212
|
+
# Stop local dev servers on the configured ports
|
|
213
|
+
make kill
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Default local URLs:
|
|
217
|
+
|
|
218
|
+
- Backend: `http://127.0.0.1:8000`
|
|
219
|
+
- Frontend: `http://127.0.0.1:5173`
|
|
220
|
+
|
|
221
|
+
Useful checks:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
make lint
|
|
225
|
+
make test
|
|
226
|
+
make build
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## CLI
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
# Register or inspect repositories
|
|
233
|
+
codewiki repos add . --name my-repo
|
|
234
|
+
codewiki repos list
|
|
235
|
+
codewiki repos scan .
|
|
236
|
+
|
|
237
|
+
# Full analysis and GraphRAG
|
|
238
|
+
codewiki analyze .
|
|
239
|
+
codewiki graphrag build .
|
|
240
|
+
codewiki graphrag build . --embeddings
|
|
241
|
+
|
|
242
|
+
# Wiki generation
|
|
243
|
+
codewiki wiki catalog .
|
|
244
|
+
codewiki wiki pages .
|
|
245
|
+
codewiki wiki update . --language en
|
|
246
|
+
codewiki wiki page overview .
|
|
247
|
+
|
|
248
|
+
# Incremental graph update, with wiki regeneration enabled by default
|
|
249
|
+
codewiki update .
|
|
250
|
+
|
|
251
|
+
# GraphRAG grounded Q&A
|
|
252
|
+
codewiki ask "How does the main workflow fit together?"
|
|
253
|
+
codewiki ask --repo my-repo "Where are wiki pages generated?"
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Most commands accept a repository id, id prefix, registered name, path, or Git URL.
|
|
257
|
+
Use `--json` on CLI commands when machine-readable output is useful.
|
|
258
|
+
|
|
259
|
+
## HTTP API Highlights
|
|
260
|
+
|
|
261
|
+
| Method | Path | Purpose |
|
|
262
|
+
|---|---|---|
|
|
263
|
+
| `POST` | `/api/repos/{repo_id}/wiki/catalog?language=en` | Generate a wiki catalog |
|
|
264
|
+
| `POST` | `/api/repos/{repo_id}/wiki/pages/generate?language=en` | Generate all wiki pages |
|
|
265
|
+
| `POST` | `/api/repos/{repo_id}/wiki/pages/update?language=en` | Incrementally update stale/missing pages |
|
|
266
|
+
| `POST` | `/api/repos/{repo_id}/wiki/pages/{slug}/regenerate?language=en` | Regenerate one page |
|
|
267
|
+
| `POST` | `/api/repos/{repo_id}/wiki/translate` | Translate catalog and pages |
|
|
268
|
+
| `GET` | `/api/repos/{repo_id}/wiki?language=en` | Read the wiki catalog and pages |
|
|
269
|
+
| `POST` | `/api/repos/{repo_id}/ask` | Ask a GraphRAG-grounded question |
|
|
270
|
+
|
|
271
|
+
## Supported AST Languages
|
|
272
|
+
|
|
273
|
+
| Language | Parser | Extracted facts |
|
|
274
|
+
|---|---|---|
|
|
275
|
+
| Python | tree-sitter capture parser | imports, classes, functions, methods, decorators, calls, references, FastAPI-style endpoints |
|
|
276
|
+
| TypeScript / TSX | tree-sitter capture parser | imports/exports, classes, interfaces, type aliases, functions, methods, calls, route endpoints |
|
|
277
|
+
| JavaScript / JSX | tree-sitter capture parser | imports/exports, classes, functions, methods, calls, route endpoints |
|
|
278
|
+
| Java | tree-sitter capture parser | package/imports, classes, interfaces, records, enums, methods, constructors, inheritance, implementations, Spring-style endpoints |
|
|
279
|
+
| Go | tree-sitter capture parser | package/imports, structs, interfaces, type aliases, functions, receiver methods, calls, router-style endpoints |
|
|
280
|
+
| Rust | tree-sitter capture parser | imports, structs, enums, traits, impls, functions, methods, calls |
|
|
281
|
+
| C | tree-sitter capture parser | includes, structs, functions, calls |
|
|
282
|
+
| C++ | tree-sitter capture parser | includes, classes, structs, functions, methods, inheritance, calls |
|
|
283
|
+
| C# | tree-sitter capture parser | usings, namespaces, classes, interfaces, methods, inheritance, calls |
|
|
284
|
+
|
|
285
|
+
## Notes
|
|
286
|
+
|
|
287
|
+
The core contract is that code facts come from deterministic scanners and AST parsers
|
|
288
|
+
first. GraphRAG and LLM workflows consume those facts for retrieval, synthesis, and wiki
|
|
289
|
+
generation rather than inventing structure.
|
codewiki-0.1.0/README.md
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# CodeWiki
|
|
2
|
+
|
|
3
|
+
Single-user CodeWiki platform for AST-based code graph analysis, GraphRAG retrieval,
|
|
4
|
+
source-grounded wiki generation, and LiteLLM-powered Q&A.
|
|
5
|
+
|
|
6
|
+
## Current Scope
|
|
7
|
+
|
|
8
|
+
- FastAPI backend with repository management, analysis runs, GraphRAG, wiki, ask, graph,
|
|
9
|
+
file, run, and settings APIs.
|
|
10
|
+
- React/Vite frontend with repository management plus graph explorer, wiki reader,
|
|
11
|
+
ask, and settings pages.
|
|
12
|
+
- AST-backed code graph extraction for Python, TypeScript/TSX, JavaScript/JSX, Java,
|
|
13
|
+
Go, Rust, C, C++, and C#.
|
|
14
|
+
- Deterministic graph edges for imports, exports, definitions, inheritance,
|
|
15
|
+
implementations, calls, route handlers, source references, and configuration usage.
|
|
16
|
+
- GraphRAG retrieval with source chunks, optional embeddings, community summaries,
|
|
17
|
+
and cached LLM runs.
|
|
18
|
+
- DeepWiki-style wiki generation with catalog planning, detailed page generation,
|
|
19
|
+
source citations, automatic diagrams, multi-language translation, and incremental
|
|
20
|
+
updates.
|
|
21
|
+
- Pure frontend wiki exports: interactive standalone HTML and Obsidian vault ZIP.
|
|
22
|
+
- Design notes live in `docs/design.md`.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
Install the Python package from PyPI:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install codewiki
|
|
30
|
+
codewiki --help
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Start the backend API after installation:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
codewiki serve
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The source checkout is still the recommended way to run the full backend + Vite
|
|
40
|
+
frontend development stack.
|
|
41
|
+
|
|
42
|
+
## Wiki Workflow
|
|
43
|
+
|
|
44
|
+
1. Register and analyze a repository.
|
|
45
|
+
2. Build GraphRAG source chunks, optionally with embeddings.
|
|
46
|
+
3. Generate a wiki catalog.
|
|
47
|
+
4. Generate wiki pages from the catalog.
|
|
48
|
+
5. Use update/regenerate flows when code changes.
|
|
49
|
+
|
|
50
|
+
Wiki pages are generated from deterministic graph facts and retrieved source chunks.
|
|
51
|
+
The page prompt enforces a gather/think/write workflow and includes ReadFile evidence so
|
|
52
|
+
the model must stay close to real source files. Source references are validated before a
|
|
53
|
+
page is promoted to `generated`; otherwise the page is saved as `draft` with validation
|
|
54
|
+
errors.
|
|
55
|
+
|
|
56
|
+
Mermaid diagrams are generated server-side from validated graph facts. Invalid diagrams
|
|
57
|
+
are filtered out instead of failing the whole page, so a bad graph block should not turn
|
|
58
|
+
a good wiki page into a draft.
|
|
59
|
+
|
|
60
|
+
## Wiki Languages
|
|
61
|
+
|
|
62
|
+
The base wiki language is generated first. Other languages are produced by translating
|
|
63
|
+
the base catalog and pages while preserving slugs, source references, code identifiers,
|
|
64
|
+
links, and Markdown structure.
|
|
65
|
+
|
|
66
|
+
Set configured translation languages in `.env`:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
CODEWIKI_WIKI_BASE_LANGUAGE=en
|
|
70
|
+
CODEWIKI_WIKI_TRANSLATION_LANGUAGES=zh
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The frontend wiki page has an English/Chinese language switch above the left catalog
|
|
74
|
+
navigation. If a requested non-base language is missing, the backend generates the base
|
|
75
|
+
wiki first and then translates it.
|
|
76
|
+
|
|
77
|
+
## Wiki Export
|
|
78
|
+
|
|
79
|
+
The frontend wiki toolbar can export the currently selected language as:
|
|
80
|
+
|
|
81
|
+
- Interactive HTML: a standalone static page with catalog navigation, page switching,
|
|
82
|
+
rendered Markdown, source sections, related pages, and Mermaid rendering.
|
|
83
|
+
- Obsidian vault: a ZIP containing Markdown pages, wiki links, source metadata, and
|
|
84
|
+
minimal `.obsidian` settings.
|
|
85
|
+
|
|
86
|
+
Exports are built entirely in the browser from already-loaded wiki data and do not
|
|
87
|
+
require a backend export API.
|
|
88
|
+
|
|
89
|
+
## LLM Configuration
|
|
90
|
+
|
|
91
|
+
Copy `.env.example` and fill in a default model profile:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
cp .env.example .env
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The default profile is used for every task unless a task-specific profile overrides it.
|
|
98
|
+
This is the simplest "use one model for everything" setup:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
CODEWIKI_LLM__MODE=sdk
|
|
102
|
+
CODEWIKI_LLM__DEFAULT__MODEL=provider/strong-coding-model
|
|
103
|
+
CODEWIKI_LLM__DEFAULT__PROVIDER_TYPE=
|
|
104
|
+
CODEWIKI_LLM__DEFAULT__ENDPOINT=
|
|
105
|
+
CODEWIKI_LLM__DEFAULT__API_KEY=
|
|
106
|
+
CODEWIKI_LLM__TIMEOUT_SECONDS=120
|
|
107
|
+
CODEWIKI_LLM__MAX_RETRIES=3
|
|
108
|
+
CODEWIKI_LLM__CACHE_ENABLED=true
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Each LLM task can override model, provider type, endpoint, and API key:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Fast/cheap catalog planning
|
|
115
|
+
CODEWIKI_LLM__PROFILES__CATALOG__MODEL=
|
|
116
|
+
CODEWIKI_LLM__PROFILES__CATALOG__PROVIDER_TYPE=
|
|
117
|
+
CODEWIKI_LLM__PROFILES__CATALOG__ENDPOINT=
|
|
118
|
+
CODEWIKI_LLM__PROFILES__CATALOG__API_KEY=
|
|
119
|
+
|
|
120
|
+
# Strong source-grounded wiki page generation
|
|
121
|
+
CODEWIKI_LLM__PROFILES__PAGE__MODEL=
|
|
122
|
+
CODEWIKI_LLM__PROFILES__PAGE__PROVIDER_TYPE=
|
|
123
|
+
CODEWIKI_LLM__PROFILES__PAGE__ENDPOINT=
|
|
124
|
+
CODEWIKI_LLM__PROFILES__PAGE__API_KEY=
|
|
125
|
+
|
|
126
|
+
# Translation
|
|
127
|
+
CODEWIKI_LLM__PROFILES__TRANSLATION__MODEL=
|
|
128
|
+
CODEWIKI_LLM__PROFILES__TRANSLATION__PROVIDER_TYPE=
|
|
129
|
+
CODEWIKI_LLM__PROFILES__TRANSLATION__ENDPOINT=
|
|
130
|
+
CODEWIKI_LLM__PROFILES__TRANSLATION__API_KEY=
|
|
131
|
+
|
|
132
|
+
# Ask / QA
|
|
133
|
+
CODEWIKI_LLM__PROFILES__QA__MODEL=
|
|
134
|
+
CODEWIKI_LLM__PROFILES__QA__PROVIDER_TYPE=
|
|
135
|
+
CODEWIKI_LLM__PROFILES__QA__ENDPOINT=
|
|
136
|
+
CODEWIKI_LLM__PROFILES__QA__API_KEY=
|
|
137
|
+
|
|
138
|
+
# Embeddings, used when GraphRAG vector indexing is enabled
|
|
139
|
+
CODEWIKI_LLM__PROFILES__EMBEDDING__MODEL=
|
|
140
|
+
CODEWIKI_LLM__PROFILES__EMBEDDING__PROVIDER_TYPE=
|
|
141
|
+
CODEWIKI_LLM__PROFILES__EMBEDDING__ENDPOINT=
|
|
142
|
+
CODEWIKI_LLM__PROFILES__EMBEDDING__API_KEY=
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Provider examples depend on LiteLLM. For OpenAI-compatible endpoints, set an endpoint
|
|
146
|
+
and API key. For native LiteLLM providers, set `PROVIDER_TYPE` and model according to
|
|
147
|
+
LiteLLM's provider naming.
|
|
148
|
+
|
|
149
|
+
Failed LLM provider calls are recorded in `llm_run` with `status=error`; API responses
|
|
150
|
+
return a `run_id` where possible so failures can be traced without exposing API keys.
|
|
151
|
+
|
|
152
|
+
## Development
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Install backend and frontend dependencies
|
|
156
|
+
make install
|
|
157
|
+
|
|
158
|
+
# Start FastAPI and Vite
|
|
159
|
+
make start
|
|
160
|
+
|
|
161
|
+
# Stop local dev servers on the configured ports
|
|
162
|
+
make kill
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Default local URLs:
|
|
166
|
+
|
|
167
|
+
- Backend: `http://127.0.0.1:8000`
|
|
168
|
+
- Frontend: `http://127.0.0.1:5173`
|
|
169
|
+
|
|
170
|
+
Useful checks:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
make lint
|
|
174
|
+
make test
|
|
175
|
+
make build
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## CLI
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Register or inspect repositories
|
|
182
|
+
codewiki repos add . --name my-repo
|
|
183
|
+
codewiki repos list
|
|
184
|
+
codewiki repos scan .
|
|
185
|
+
|
|
186
|
+
# Full analysis and GraphRAG
|
|
187
|
+
codewiki analyze .
|
|
188
|
+
codewiki graphrag build .
|
|
189
|
+
codewiki graphrag build . --embeddings
|
|
190
|
+
|
|
191
|
+
# Wiki generation
|
|
192
|
+
codewiki wiki catalog .
|
|
193
|
+
codewiki wiki pages .
|
|
194
|
+
codewiki wiki update . --language en
|
|
195
|
+
codewiki wiki page overview .
|
|
196
|
+
|
|
197
|
+
# Incremental graph update, with wiki regeneration enabled by default
|
|
198
|
+
codewiki update .
|
|
199
|
+
|
|
200
|
+
# GraphRAG grounded Q&A
|
|
201
|
+
codewiki ask "How does the main workflow fit together?"
|
|
202
|
+
codewiki ask --repo my-repo "Where are wiki pages generated?"
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Most commands accept a repository id, id prefix, registered name, path, or Git URL.
|
|
206
|
+
Use `--json` on CLI commands when machine-readable output is useful.
|
|
207
|
+
|
|
208
|
+
## HTTP API Highlights
|
|
209
|
+
|
|
210
|
+
| Method | Path | Purpose |
|
|
211
|
+
|---|---|---|
|
|
212
|
+
| `POST` | `/api/repos/{repo_id}/wiki/catalog?language=en` | Generate a wiki catalog |
|
|
213
|
+
| `POST` | `/api/repos/{repo_id}/wiki/pages/generate?language=en` | Generate all wiki pages |
|
|
214
|
+
| `POST` | `/api/repos/{repo_id}/wiki/pages/update?language=en` | Incrementally update stale/missing pages |
|
|
215
|
+
| `POST` | `/api/repos/{repo_id}/wiki/pages/{slug}/regenerate?language=en` | Regenerate one page |
|
|
216
|
+
| `POST` | `/api/repos/{repo_id}/wiki/translate` | Translate catalog and pages |
|
|
217
|
+
| `GET` | `/api/repos/{repo_id}/wiki?language=en` | Read the wiki catalog and pages |
|
|
218
|
+
| `POST` | `/api/repos/{repo_id}/ask` | Ask a GraphRAG-grounded question |
|
|
219
|
+
|
|
220
|
+
## Supported AST Languages
|
|
221
|
+
|
|
222
|
+
| Language | Parser | Extracted facts |
|
|
223
|
+
|---|---|---|
|
|
224
|
+
| Python | tree-sitter capture parser | imports, classes, functions, methods, decorators, calls, references, FastAPI-style endpoints |
|
|
225
|
+
| TypeScript / TSX | tree-sitter capture parser | imports/exports, classes, interfaces, type aliases, functions, methods, calls, route endpoints |
|
|
226
|
+
| JavaScript / JSX | tree-sitter capture parser | imports/exports, classes, functions, methods, calls, route endpoints |
|
|
227
|
+
| Java | tree-sitter capture parser | package/imports, classes, interfaces, records, enums, methods, constructors, inheritance, implementations, Spring-style endpoints |
|
|
228
|
+
| Go | tree-sitter capture parser | package/imports, structs, interfaces, type aliases, functions, receiver methods, calls, router-style endpoints |
|
|
229
|
+
| Rust | tree-sitter capture parser | imports, structs, enums, traits, impls, functions, methods, calls |
|
|
230
|
+
| C | tree-sitter capture parser | includes, structs, functions, calls |
|
|
231
|
+
| C++ | tree-sitter capture parser | includes, classes, structs, functions, methods, inheritance, calls |
|
|
232
|
+
| C# | tree-sitter capture parser | usings, namespaces, classes, interfaces, methods, inheritance, calls |
|
|
233
|
+
|
|
234
|
+
## Notes
|
|
235
|
+
|
|
236
|
+
The core contract is that code facts come from deterministic scanners and AST parsers
|
|
237
|
+
first. GraphRAG and LLM workflows consume those facts for retrieval, synthesis, and wiki
|
|
238
|
+
generation rather than inventing structure.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from fastapi import APIRouter, HTTPException
|
|
2
|
+
|
|
3
|
+
from backend.app.config import get_settings
|
|
4
|
+
from backend.app.database import get_store
|
|
5
|
+
from backend.app.schemas.ask import AskRequest, AskResponse
|
|
6
|
+
from backend.app.services.graphrag import GraphRAGRetriever
|
|
7
|
+
from backend.app.services.llm_gateway import LLMGateway
|
|
8
|
+
from backend.app.services.llm_run_recorder import LLMCallError
|
|
9
|
+
from backend.app.services.question_answerer import QuestionAnswerer
|
|
10
|
+
|
|
11
|
+
router = APIRouter()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@router.post("/{repo_id}/ask")
|
|
15
|
+
async def ask_repo(repo_id: str, payload: AskRequest) -> AskResponse:
|
|
16
|
+
settings = get_settings()
|
|
17
|
+
store = get_store()
|
|
18
|
+
answerer = QuestionAnswerer(
|
|
19
|
+
GraphRAGRetriever(store=store, settings=settings),
|
|
20
|
+
LLMGateway(settings),
|
|
21
|
+
store=store,
|
|
22
|
+
)
|
|
23
|
+
try:
|
|
24
|
+
return await answerer.answer(repo_id, payload)
|
|
25
|
+
except LLMCallError as exc:
|
|
26
|
+
raise HTTPException(
|
|
27
|
+
status_code=502,
|
|
28
|
+
detail={
|
|
29
|
+
"message": str(exc),
|
|
30
|
+
"task_type": exc.task_type,
|
|
31
|
+
"run_id": exc.run_id,
|
|
32
|
+
},
|
|
33
|
+
) from exc
|
|
34
|
+
except ValueError as exc:
|
|
35
|
+
message = str(exc)
|
|
36
|
+
status_code = 404 if message.startswith("Repository not found") else 400
|
|
37
|
+
raise HTTPException(status_code=status_code, detail=message) from exc
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
from functools import cached_property, lru_cache
|
|
2
|
+
from typing import Annotated
|
|
3
|
+
|
|
4
|
+
from fastapi import Depends
|
|
5
|
+
|
|
6
|
+
from backend.app.config import Settings, get_settings
|
|
7
|
+
from backend.app.database import SQLiteStore, get_store
|
|
8
|
+
from backend.app.services.graphrag import GraphRAGRetriever
|
|
9
|
+
from backend.app.services.incremental import IncrementalUpdater
|
|
10
|
+
from backend.app.services.llm_gateway import LLMGateway
|
|
11
|
+
from backend.app.services.wiki import WikiGenerator
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ServiceContainer:
|
|
15
|
+
def __init__(self, *, settings: Settings, store: SQLiteStore) -> None:
|
|
16
|
+
self.settings = settings
|
|
17
|
+
self.store = store
|
|
18
|
+
|
|
19
|
+
@cached_property
|
|
20
|
+
def llm_gateway(self) -> LLMGateway:
|
|
21
|
+
return LLMGateway(self.settings)
|
|
22
|
+
|
|
23
|
+
@cached_property
|
|
24
|
+
def graph_retriever(self) -> GraphRAGRetriever:
|
|
25
|
+
return GraphRAGRetriever(store=self.store, settings=self.settings)
|
|
26
|
+
|
|
27
|
+
@cached_property
|
|
28
|
+
def wiki_generator(self) -> WikiGenerator:
|
|
29
|
+
return WikiGenerator(
|
|
30
|
+
self.graph_retriever,
|
|
31
|
+
self.llm_gateway,
|
|
32
|
+
store=self.store,
|
|
33
|
+
settings=self.settings,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
@cached_property
|
|
37
|
+
def incremental_updater(self) -> IncrementalUpdater:
|
|
38
|
+
return IncrementalUpdater(
|
|
39
|
+
store=self.store,
|
|
40
|
+
graphrag=self.graph_retriever,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@lru_cache
|
|
45
|
+
def get_service_container() -> ServiceContainer:
|
|
46
|
+
return ServiceContainer(settings=get_settings(), store=get_store())
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def get_store_dependency() -> SQLiteStore:
|
|
50
|
+
return get_service_container().store
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def get_wiki_generator() -> WikiGenerator:
|
|
54
|
+
return get_service_container().wiki_generator
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def get_incremental_updater() -> IncrementalUpdater:
|
|
58
|
+
return get_service_container().incremental_updater
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
StoreDep = Annotated[SQLiteStore, Depends(get_store_dependency)]
|
|
62
|
+
WikiGeneratorDep = Annotated[WikiGenerator, Depends(get_wiki_generator)]
|
|
63
|
+
IncrementalUpdaterDep = Annotated[IncrementalUpdater, Depends(get_incremental_updater)]
|