codebookx 3.0.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.
- codebookx-3.0.0/NOTICE.md +20 -0
- codebookx-3.0.0/PKG-INFO +115 -0
- codebookx-3.0.0/README.md +93 -0
- codebookx-3.0.0/codebookx/__init__.py +1 -0
- codebookx-3.0.0/codebookx/cli.py +85 -0
- codebookx-3.0.0/codebookx/core.py +452 -0
- codebookx-3.0.0/codebookx/engine/graph.py +144 -0
- codebookx-3.0.0/codebookx/engine/indexer.py +127 -0
- codebookx-3.0.0/codebookx/engine/parser.py +337 -0
- codebookx-3.0.0/codebookx/engine/vendor/claude_mem_lite.py +39 -0
- codebookx-3.0.0/codebookx/engine/vendor/repomix_lite.py +30 -0
- codebookx-3.0.0/codebookx/llm.py +73 -0
- codebookx-3.0.0/codebookx/prompts.py +43 -0
- codebookx-3.0.0/codebookx/webapp/app.py +153 -0
- codebookx-3.0.0/codebookx.egg-info/PKG-INFO +115 -0
- codebookx-3.0.0/codebookx.egg-info/SOURCES.txt +20 -0
- codebookx-3.0.0/codebookx.egg-info/dependency_links.txt +1 -0
- codebookx-3.0.0/codebookx.egg-info/entry_points.txt +3 -0
- codebookx-3.0.0/codebookx.egg-info/requires.txt +14 -0
- codebookx-3.0.0/codebookx.egg-info/top_level.txt +1 -0
- codebookx-3.0.0/pyproject.toml +35 -0
- codebookx-3.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# NOTICE
|
|
2
|
+
|
|
3
|
+
Codebase-X includes code from the following open-source projects, used under their respective licenses:
|
|
4
|
+
|
|
5
|
+
1. **GitNexus** (https://github.com/abhigyanpatwari/GitNexus)
|
|
6
|
+
- License: Apache License 2.0
|
|
7
|
+
- Adapted modules: AST parsing, symbol extraction logic.
|
|
8
|
+
- Original copyright (c) 2024 Abhigyan Patwari.
|
|
9
|
+
|
|
10
|
+
2. **claude-mem** (https://github.com/thedotmack/claude-mem)
|
|
11
|
+
- License: MIT License
|
|
12
|
+
- Adapted modules: Structural skeleton extraction.
|
|
13
|
+
- Original copyright (c) 2024 thedotmack.
|
|
14
|
+
|
|
15
|
+
3. **repomix** (https://github.com/yamadashy/repomix)
|
|
16
|
+
- License: MIT License
|
|
17
|
+
- Adapted logic: File packing algorithm.
|
|
18
|
+
- Original copyright (c) 2024 yamadashy.
|
|
19
|
+
|
|
20
|
+
All original copyright notices have been preserved in the adapted source files where applicable.
|
codebookx-3.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codebookx
|
|
3
|
+
Version: 3.0.0
|
|
4
|
+
Summary: Codebase-X: Production-grade, offline code comprehension and AI-tasking platform
|
|
5
|
+
Author-email: Satvik Jain <klickbae8yt@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/satvikjain/codebook
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: NOTICE.md
|
|
11
|
+
Requires-Dist: requests>=2.28.0
|
|
12
|
+
Requires-Dist: tqdm>=4.64.0
|
|
13
|
+
Requires-Dist: questionary>=2.0.0
|
|
14
|
+
Requires-Dist: tomli>=2.0.0; python_version < "3.11"
|
|
15
|
+
Provides-Extra: ui
|
|
16
|
+
Requires-Dist: flask>=2.0.0; extra == "ui"
|
|
17
|
+
Provides-Extra: dev
|
|
18
|
+
Requires-Dist: black; extra == "dev"
|
|
19
|
+
Requires-Dist: ruff; extra == "dev"
|
|
20
|
+
Requires-Dist: tree-sitter; extra == "dev"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# Codebase-X
|
|
24
|
+
|
|
25
|
+
**The Intelligent AI Assistant for Your Entire Codebase.**
|
|
26
|
+
|
|
27
|
+
Codebase-X is a production-grade, offline platform designed to give you total control over your code. By building a deep, persistent Knowledge Graph of your repository, Codebase-X enables advanced architectural analysis, atomic task decomposition, and prompt engineering—all while keeping your data 100% private and local.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 🗺️ User Journey
|
|
32
|
+
|
|
33
|
+
1. **`codebookx analyze`**: Scan your repository to build a Knowledge Graph and architectural teardown.
|
|
34
|
+
2. **`codebookx view`**: Launch the interactive Knowledge Graph browser to explore your code visually.
|
|
35
|
+
3. **`codebookx ask "..."`**: Ask technical questions about your codebase, powered by the Knowledge Graph context.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 🚀 Core Capabilities
|
|
40
|
+
|
|
41
|
+
### 🏛️ Codebase Teardown (Analyze)
|
|
42
|
+
Stop guessing how your system works. Codebase-X scans your entire repository to generate a high-level architectural blueprint.
|
|
43
|
+
* **Elevator Pitch:** Get an instant summary of any project.
|
|
44
|
+
* **Architecture Blueprint:** Automatically mapped folder roles and purposes.
|
|
45
|
+
* **Data Flow:** Understand how the core components of your system interact.
|
|
46
|
+
```bash
|
|
47
|
+
codebookx analyze
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 🔨 Atomic Task Decomposition (Decompose)
|
|
51
|
+
Break complex features into small, manageable pieces. Codebase-X analyzes your feature request against your actual codebase to produce a series of atomic tasks.
|
|
52
|
+
* **AI-Ready:** Each task includes a "copy-paste" prompt specifically designed for AI coding assistants.
|
|
53
|
+
* **Context-Aware:** Tasks reference the exact files and symbols needed.
|
|
54
|
+
```bash
|
|
55
|
+
codebookx decompose "Add a user settings page"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### ✨ Prompt Enhancement (Enhance)
|
|
59
|
+
Stop writing vague prompts. The Prompt Enhancer uses the Knowledge Graph to inject relevant file paths, function signatures, and dependencies into your request, creating a high-context prompt that gets it right the first time.
|
|
60
|
+
```bash
|
|
61
|
+
codebookx enhance "Refactor the authentication flow"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 🕸️ Knowledge Graph Browser (View)
|
|
65
|
+
Explore your code visually. Launch an interactive local web UI to traverse your project's dependency graph, find symbols, and manage your AI tasks.
|
|
66
|
+
* **Visual Map:** Interactive D3.js force-directed graph available at `/graph`.
|
|
67
|
+
* **Relations:** Track CALLS, IMPORTS, and CONTAINS relationships cross-file.
|
|
68
|
+
```bash
|
|
69
|
+
codebookx view
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### ❓ Technical Q&A (Ask)
|
|
73
|
+
Knowledge Graph-backed Q&A for your codebase. Answers are saved automatically.
|
|
74
|
+
```bash
|
|
75
|
+
# Single question
|
|
76
|
+
codebookx ask "How is the authentication handled in this project?"
|
|
77
|
+
|
|
78
|
+
# Interactive chat mode (multi-turn, context carry-over)
|
|
79
|
+
codebookx ask -c "Walk me through the data flow"
|
|
80
|
+
|
|
81
|
+
# Save Q&A logs to a custom directory
|
|
82
|
+
codebookx ask "What does run_ask do?" --dir ~/my-notes
|
|
83
|
+
```
|
|
84
|
+
* **Auto-save:** Every Q&A and chat session is saved to `ask_history/` by default (`--dir` to override, or set `CODEBOOK_ASK_DIR` env var).
|
|
85
|
+
* **Chat mode (`-c`):** Multi-turn conversation with full context carry-over. Each turn is saved incrementally — no history lost on crash.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 🛠️ Getting Started
|
|
90
|
+
|
|
91
|
+
**1. Install**
|
|
92
|
+
```bash
|
|
93
|
+
pip install .
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**2. Local LLM Setup**
|
|
97
|
+
Codebase-X is designed to work with **LM Studio**, **Ollama**, or any OpenAI-compatible local server. Ensure your server is running.
|
|
98
|
+
|
|
99
|
+
**3. Initial Analysis**
|
|
100
|
+
Scan your repository to build the Knowledge Graph:
|
|
101
|
+
```bash
|
|
102
|
+
codebookx analyze
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 🔒 Privacy & Performance
|
|
108
|
+
* **100% Offline:** Your code never leaves your machine. No cloud APIs, no subscriptions.
|
|
109
|
+
* **Persistent Indexing:** Uses a lightning-fast SQLite-backed Knowledge Graph with hash-based caching.
|
|
110
|
+
* **Multi-Language:** Deep support for Python, TypeScript, JavaScript, and more.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## 📄 License
|
|
115
|
+
Codebase-X is released under the MIT License.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Codebase-X
|
|
2
|
+
|
|
3
|
+
**The Intelligent AI Assistant for Your Entire Codebase.**
|
|
4
|
+
|
|
5
|
+
Codebase-X is a production-grade, offline platform designed to give you total control over your code. By building a deep, persistent Knowledge Graph of your repository, Codebase-X enables advanced architectural analysis, atomic task decomposition, and prompt engineering—all while keeping your data 100% private and local.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🗺️ User Journey
|
|
10
|
+
|
|
11
|
+
1. **`codebookx analyze`**: Scan your repository to build a Knowledge Graph and architectural teardown.
|
|
12
|
+
2. **`codebookx view`**: Launch the interactive Knowledge Graph browser to explore your code visually.
|
|
13
|
+
3. **`codebookx ask "..."`**: Ask technical questions about your codebase, powered by the Knowledge Graph context.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 🚀 Core Capabilities
|
|
18
|
+
|
|
19
|
+
### 🏛️ Codebase Teardown (Analyze)
|
|
20
|
+
Stop guessing how your system works. Codebase-X scans your entire repository to generate a high-level architectural blueprint.
|
|
21
|
+
* **Elevator Pitch:** Get an instant summary of any project.
|
|
22
|
+
* **Architecture Blueprint:** Automatically mapped folder roles and purposes.
|
|
23
|
+
* **Data Flow:** Understand how the core components of your system interact.
|
|
24
|
+
```bash
|
|
25
|
+
codebookx analyze
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 🔨 Atomic Task Decomposition (Decompose)
|
|
29
|
+
Break complex features into small, manageable pieces. Codebase-X analyzes your feature request against your actual codebase to produce a series of atomic tasks.
|
|
30
|
+
* **AI-Ready:** Each task includes a "copy-paste" prompt specifically designed for AI coding assistants.
|
|
31
|
+
* **Context-Aware:** Tasks reference the exact files and symbols needed.
|
|
32
|
+
```bash
|
|
33
|
+
codebookx decompose "Add a user settings page"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### ✨ Prompt Enhancement (Enhance)
|
|
37
|
+
Stop writing vague prompts. The Prompt Enhancer uses the Knowledge Graph to inject relevant file paths, function signatures, and dependencies into your request, creating a high-context prompt that gets it right the first time.
|
|
38
|
+
```bash
|
|
39
|
+
codebookx enhance "Refactor the authentication flow"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 🕸️ Knowledge Graph Browser (View)
|
|
43
|
+
Explore your code visually. Launch an interactive local web UI to traverse your project's dependency graph, find symbols, and manage your AI tasks.
|
|
44
|
+
* **Visual Map:** Interactive D3.js force-directed graph available at `/graph`.
|
|
45
|
+
* **Relations:** Track CALLS, IMPORTS, and CONTAINS relationships cross-file.
|
|
46
|
+
```bash
|
|
47
|
+
codebookx view
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### ❓ Technical Q&A (Ask)
|
|
51
|
+
Knowledge Graph-backed Q&A for your codebase. Answers are saved automatically.
|
|
52
|
+
```bash
|
|
53
|
+
# Single question
|
|
54
|
+
codebookx ask "How is the authentication handled in this project?"
|
|
55
|
+
|
|
56
|
+
# Interactive chat mode (multi-turn, context carry-over)
|
|
57
|
+
codebookx ask -c "Walk me through the data flow"
|
|
58
|
+
|
|
59
|
+
# Save Q&A logs to a custom directory
|
|
60
|
+
codebookx ask "What does run_ask do?" --dir ~/my-notes
|
|
61
|
+
```
|
|
62
|
+
* **Auto-save:** Every Q&A and chat session is saved to `ask_history/` by default (`--dir` to override, or set `CODEBOOK_ASK_DIR` env var).
|
|
63
|
+
* **Chat mode (`-c`):** Multi-turn conversation with full context carry-over. Each turn is saved incrementally — no history lost on crash.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 🛠️ Getting Started
|
|
68
|
+
|
|
69
|
+
**1. Install**
|
|
70
|
+
```bash
|
|
71
|
+
pip install .
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**2. Local LLM Setup**
|
|
75
|
+
Codebase-X is designed to work with **LM Studio**, **Ollama**, or any OpenAI-compatible local server. Ensure your server is running.
|
|
76
|
+
|
|
77
|
+
**3. Initial Analysis**
|
|
78
|
+
Scan your repository to build the Knowledge Graph:
|
|
79
|
+
```bash
|
|
80
|
+
codebookx analyze
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 🔒 Privacy & Performance
|
|
86
|
+
* **100% Offline:** Your code never leaves your machine. No cloud APIs, no subscriptions.
|
|
87
|
+
* **Persistent Indexing:** Uses a lightning-fast SQLite-backed Knowledge Graph with hash-based caching.
|
|
88
|
+
* **Multi-Language:** Deep support for Python, TypeScript, JavaScript, and more.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 📄 License
|
|
93
|
+
Codebase-X is released under the MIT License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "3.0.0"
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import sys
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from .core import run_generate, run_analyze, run_decompose, run_enhance, run_ask, run_ask_chat
|
|
5
|
+
from .webapp.app import run_server
|
|
6
|
+
|
|
7
|
+
def main():
|
|
8
|
+
parser = argparse.ArgumentParser(
|
|
9
|
+
prog="codebookx",
|
|
10
|
+
description="Codebase-X: Evolution of Codebook for offline code comprehension."
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
subparsers = parser.add_subparsers(dest="command", help="Available commands")
|
|
14
|
+
|
|
15
|
+
# Generate (Classic Codebook)
|
|
16
|
+
gen_parser = subparsers.add_parser("generate", help="Generate classic CODEBASE_BOOK.md")
|
|
17
|
+
gen_parser.add_argument("target_dir", nargs="?", default=".", help="Directory to scan")
|
|
18
|
+
gen_parser.add_argument("--url", help="LM Studio base URL")
|
|
19
|
+
gen_parser.add_argument("--model", help="Model name")
|
|
20
|
+
gen_parser.add_argument("--output", help="Output file path")
|
|
21
|
+
gen_parser.add_argument("--prompt-lang", help="Language for explanations")
|
|
22
|
+
gen_parser.add_argument("--file", help="Annotate single file only")
|
|
23
|
+
|
|
24
|
+
# Analyze (PCTF)
|
|
25
|
+
analyze_parser = subparsers.add_parser("analyze", help="Run PCTF Codebase Teardown")
|
|
26
|
+
analyze_parser.add_argument("target_dir", nargs="?", default=".", help="Directory to scan")
|
|
27
|
+
analyze_parser.add_argument("--force", action="store_true", help="Force re-analysis")
|
|
28
|
+
|
|
29
|
+
# Decompose (AATD)
|
|
30
|
+
decompose_parser = subparsers.add_parser("decompose", help="Run AATD Feature Decomposition")
|
|
31
|
+
decompose_parser.add_argument("feature", help="Feature description to decompose")
|
|
32
|
+
decompose_parser.add_argument("target_dir", nargs="?", default=".", help="Directory to scan")
|
|
33
|
+
decompose_parser.add_argument("--deep", action="store_true", help="Use deep context (repomix)")
|
|
34
|
+
|
|
35
|
+
# Enhance (New: Prompt Enhancement)
|
|
36
|
+
enhance_parser = subparsers.add_parser("enhance", help="Enhance a prompt with codebase context (requires: codebook analyze first)")
|
|
37
|
+
enhance_parser.add_argument("feature", help="Feature description to enhance")
|
|
38
|
+
enhance_parser.add_argument("target_dir", nargs="?", default=".", help="Directory to scan")
|
|
39
|
+
|
|
40
|
+
# Ask
|
|
41
|
+
ask_parser = subparsers.add_parser("ask", help="Ask a question about the codebase (requires: codebook analyze first)")
|
|
42
|
+
ask_parser.add_argument("question", help="The question to ask about your codebase")
|
|
43
|
+
ask_parser.add_argument("target_dir", nargs="?", default=".", help="Directory to scan")
|
|
44
|
+
ask_parser.add_argument("--dir", default=None,
|
|
45
|
+
help="Directory to save Q&A log (default: $CODEBOOK_ASK_DIR or ./ask_history)")
|
|
46
|
+
ask_parser.add_argument("-c", "--chat", action="store_true",
|
|
47
|
+
help="Interactive chat mode (multi-turn, context carry-over) (requires: codebook analyze first)")
|
|
48
|
+
|
|
49
|
+
# View
|
|
50
|
+
view_parser = subparsers.add_parser("view", help="Launch local Knowledge Graph web UI")
|
|
51
|
+
view_parser.add_argument("target_dir", nargs="?", default=".", help="Directory to scan")
|
|
52
|
+
view_parser.add_argument("--port", type=int, default=8050, help="Port to run the UI on")
|
|
53
|
+
|
|
54
|
+
# Backward compatibility: Intercept sys.argv
|
|
55
|
+
if len(sys.argv) > 1 and not sys.argv[1].startswith("-") and sys.argv[1] not in ["generate", "analyze", "decompose", "ask", "enhance", "view", "-h", "--help"]:
|
|
56
|
+
sys.argv.insert(1, "generate")
|
|
57
|
+
elif len(sys.argv) == 1:
|
|
58
|
+
sys.argv.append("generate")
|
|
59
|
+
|
|
60
|
+
args = parser.parse_args()
|
|
61
|
+
|
|
62
|
+
if args.command == "generate":
|
|
63
|
+
run_generate(args)
|
|
64
|
+
elif args.command == "analyze":
|
|
65
|
+
run_analyze(args)
|
|
66
|
+
elif args.command == "decompose":
|
|
67
|
+
run_decompose(args)
|
|
68
|
+
elif args.command == "enhance":
|
|
69
|
+
run_enhance(args)
|
|
70
|
+
elif args.command == "ask":
|
|
71
|
+
if getattr(args, "chat", False):
|
|
72
|
+
run_ask_chat(args)
|
|
73
|
+
else:
|
|
74
|
+
run_ask(args)
|
|
75
|
+
elif args.command == "view":
|
|
76
|
+
root = Path(args.target_dir or ".").resolve()
|
|
77
|
+
db_path = root / ".codebook_cache.db"
|
|
78
|
+
print(f"Starting local UI on http://localhost:{args.port}...")
|
|
79
|
+
print(f"Using database: {db_path}")
|
|
80
|
+
run_server(port=args.port, db_path=str(db_path))
|
|
81
|
+
else:
|
|
82
|
+
parser.print_help()
|
|
83
|
+
|
|
84
|
+
if __name__ == "__main__":
|
|
85
|
+
main()
|