ctxgraph 0.2.4__tar.gz → 0.3.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.
Files changed (53) hide show
  1. {ctxgraph-0.2.4/src/ctxgraph.egg-info → ctxgraph-0.3.0}/PKG-INFO +82 -11
  2. ctxgraph-0.2.4/PKG-INFO → ctxgraph-0.3.0/README.md +610 -568
  3. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/pyproject.toml +1 -1
  4. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/capsule/renderer.py +9 -1
  5. ctxgraph-0.3.0/src/ctxgraph/capsule/savings.py +85 -0
  6. ctxgraph-0.3.0/src/ctxgraph/cli/main.py +537 -0
  7. ctxgraph-0.3.0/src/ctxgraph/config/init.py +26 -0
  8. ctxgraph-0.3.0/src/ctxgraph/history.py +69 -0
  9. ctxgraph-0.3.0/src/ctxgraph/skills/__init__.py +38 -0
  10. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/view/visualizer.py +10 -2
  11. ctxgraph-0.2.4/README.md → ctxgraph-0.3.0/src/ctxgraph.egg-info/PKG-INFO +639 -539
  12. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph.egg-info/SOURCES.txt +5 -0
  13. ctxgraph-0.3.0/tests/test_e2e.py +219 -0
  14. ctxgraph-0.2.4/src/ctxgraph/cli/main.py +0 -262
  15. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/setup.cfg +0 -0
  16. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/__init__.py +0 -0
  17. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/analyzers/__init__.py +0 -0
  18. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/analyzers/python/__init__.py +0 -0
  19. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/analyzers/python/importer.py +0 -0
  20. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/analyzers/python/semantic.py +0 -0
  21. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/analyzers/python/symbols.py +0 -0
  22. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/capsule/__init__.py +0 -0
  23. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/cli/__init__.py +0 -0
  24. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/clients/__init__.py +0 -0
  25. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/clients/models.py +0 -0
  26. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/config/__init__.py +0 -0
  27. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/config/providers.py +0 -0
  28. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/config/settings.py +0 -0
  29. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/exclude/__init__.py +0 -0
  30. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/exclude/patterns.py +0 -0
  31. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/graph/__init__.py +0 -0
  32. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/graph/builder.py +0 -0
  33. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/graph/models.py +0 -0
  34. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/graph/query.py +0 -0
  35. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/graph/storage.py +0 -0
  36. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/mcp/__init__.py +0 -0
  37. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/mcp/server.py +0 -0
  38. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/view/__init__.py +0 -0
  39. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/wrapper/__init__.py +0 -0
  40. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph/wrapper/claude.py +0 -0
  41. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph.egg-info/dependency_links.txt +0 -0
  42. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph.egg-info/entry_points.txt +0 -0
  43. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph.egg-info/requires.txt +0 -0
  44. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/src/ctxgraph.egg-info/top_level.txt +0 -0
  45. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/tests/test_analyzers.py +0 -0
  46. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/tests/test_benchmark.py +0 -0
  47. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/tests/test_capsule.py +0 -0
  48. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/tests/test_config.py +0 -0
  49. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/tests/test_integration.py +0 -0
  50. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/tests/test_model_mode.py +0 -0
  51. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/tests/test_models.py +0 -0
  52. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/tests/test_query.py +0 -0
  53. {ctxgraph-0.2.4 → ctxgraph-0.3.0}/tests/test_storage.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ctxgraph
3
- Version: 0.2.4
3
+ Version: 0.3.0
4
4
  Summary: AI context engine for Python — cuts LLM tokens 97% via code knowledge graphs. Build, query, and generate compact context capsules for Claude, OpenAI, Ollama.
5
5
  Author: ctxgraph contributors
6
6
  License: MIT
@@ -86,10 +86,10 @@ Repository (.py files)
86
86
  ### Architecture
87
87
 
88
88
  ```
89
- ┌─────────┐ ┌──────────────┐ ┌──────────────┐
90
- │ CLI │───▶│ Analyzers │───▶│ SQLite DB │
91
- │ typer │ │ AST-based │ │ .ctxgraph/ │
92
- └────┬────┘ └──────────────┘ └──────┬───────┘
89
+ ┌─────────┐ ┌──────────────┐ ┌──────────────┐ ┌─────────────┐
90
+ │ CLI │───▶│ Analyzers │───▶│ SQLite DB │───▶│ Skills/Hist
91
+ │ typer │ │ AST-based │ │ .ctxgraph/ │ │ .ctxgraph/ │
92
+ └────┬────┘ └──────────────┘ └──────┬───────┘ └─────────────┘
93
93
  │ │
94
94
  ├── ctx build ──────────────────────▶│ Graph build
95
95
  │ │
@@ -97,9 +97,17 @@ Repository (.py files)
97
97
  │ │
98
98
  ├── ctx query ◀─────────────────────│ Keyword search
99
99
  │ │
100
- ├── ctx view ◀──────────────────────│ D3.js viz
101
- │ │
102
- ├── ctx serve ◀─────────────────────│ MCP server
100
+ ├── ctx ask ◀──────────────────────│ LLM query + savings
101
+ │ │
102
+ ├── ctx view ◀──────────────────────│ D3.js viz
103
+ │ │
104
+ ├── ctx serve ◀─────────────────────│ MCP server
105
+ │ │
106
+ ├── ctx init ───────────────────────│ Scaffold project
107
+ │ │
108
+ ├── ctx history ◀───────────────────│ Query log
109
+ │ │
110
+ └── ctx skill ◀─────────────────────│ Skill management
103
111
  │ │
104
112
  └── ccg wrapper ───▶ Claude Code ───┘ AI tool
105
113
  ```
@@ -159,10 +167,36 @@ JSON: 426 tokens DSL: 143 tokens
159
167
 
160
168
  **+16.7pp average coverage improvement** — better answers, concrete file names, real code structure.
161
169
 
170
+ ### Token Savings Display
171
+
172
+ Use `--savings` to see how many tokens each capsule saves:
173
+
174
+ ```bash
175
+ ctx capsule "user authentication" --savings
176
+ # ┌──────────────────────────┬──────────────┐
177
+ # │ Metric │ Value │
178
+ # ├──────────────────────────┼──────────────┤
179
+ # │ Raw Project .py Files │ 10,587 tokens│
180
+ # │ Capsule DSL │ 132 tokens │
181
+ # │ JSON Equivalent │ 490 tokens │
182
+ # │ Savings vs Raw │ 98.8% │
183
+ # │ DSL vs JSON │ 73.1% │
184
+ # └──────────────────────────┴──────────────┘
185
+ ```
186
+
187
+ `ctx ask` shows this automatically on every query.
188
+
162
189
  ---
163
190
 
164
191
  ## Commands
165
192
 
193
+ ### `ctx init` — Scaffold project
194
+ ```bash
195
+ ctx init
196
+ # Creates: .ctxgraph/config.toml, .ctxgraph/skills/, .ctxgraph/history.jsonl
197
+ ```
198
+ Sets up a fresh `.ctxgraph/` directory with default config and built-in skills. Idempotent — safe to run on existing projects.
199
+
166
200
  ### `ctx build` — Build knowledge graph
167
201
  ```bash
168
202
  ctx build # Current directory
@@ -170,12 +204,24 @@ ctx build /path/to/project # Specific repo
170
204
  ctx build --exclude "vendor/*" # Custom exclude patterns
171
205
  ```
172
206
 
207
+ ### `ctx ask <query>` — Ask questions via LLM
208
+ ```bash
209
+ ctx ask "how does JWT auth work" # Uses configured provider
210
+ ctx ask "fix login bug" --provider claude --model claude-sonnet-4-20250514
211
+ ctx ask "refactor payment flow" --skill project-style # Activate a skill
212
+ ctx ask "find auth code" --graph # Show graph search results
213
+ ctx ask "deep dive" --mode deep # Deep graph context
214
+ ```
215
+ Shows token savings automatically. Requires a running Ollama instance (or other configured provider).
216
+
173
217
  ### `ctx capsule <query>` — Generate context
174
218
  ```bash
175
219
  ctx capsule "fix JWT token validation" # Balanced (default: 20 nodes, depth 2)
176
220
  ctx capsule "fix JWT token validation" --mode fast # Fast (10 nodes, depth 1)
177
221
  ctx capsule "fix JWT token validation" --mode deep # Deep (40 nodes, depth 3)
178
222
  ctx capsule --overview # Project architecture overview
223
+ ctx capsule "fix auth" --savings # Show token savings table
224
+ ctx capsule "fix auth" --skill project-style # Prepends skill context
179
225
  ```
180
226
 
181
227
  | Mode | Max Nodes | BFS Depth | When to Use |
@@ -217,6 +263,22 @@ Claude Desktop config:
217
263
  ```
218
264
  Tools: `search_graph`, `get_context_capsule`, `get_file_dependencies`, `get_project_overview`.
219
265
 
266
+ ### `ctx history` — Query history
267
+ ```bash
268
+ ctx history # Last 10 queries
269
+ ctx history -n 20 # Last 20
270
+ ctx history --filter "auth" # Filter by keyword
271
+ ctx history --stats # Aggregate statistics
272
+ ```
273
+ History stored in JSONL format at `.ctxgraph/history.jsonl`. Auto-prunes to 1000 entries.
274
+
275
+ ### `ctx skill` — Manage skills
276
+ ```bash
277
+ ctx skill list # Show all available skills
278
+ ctx skill show project-style # Display skill contents
279
+ ```
280
+ Skills are TOML files in `.ctxgraph/skills/`. Activate with `ctx ask --skill <name>` or `ctx capsule --skill <name>`.
281
+
220
282
  ### `ctx info` — Graph statistics
221
283
  ```bash
222
284
  ctx info
@@ -531,25 +593,34 @@ python benchmarks/run_ollama_comparison.py # Requires local Ollama
531
593
  ### Project Structure
532
594
  ```
533
595
  src/ctxgraph/
534
- ├── cli/main.py — Typer CLI (6 commands)
596
+ ├── cli/main.py — Typer CLI (9 commands)
535
597
  ├── graph/
536
598
  │ ├── models.py — Node, Edge, Graph dataclasses
537
599
  │ ├── storage.py — SQLite persistence
538
600
  │ ├── builder.py — Graph build orchestrator
539
601
  │ └── query.py — Tokenizer + BFS + relevance scoring
540
- ├── capsule/renderer.py — DSL context generation
602
+ ├── capsule/
603
+ │ ├── renderer.py — DSL context generation
604
+ │ └── savings.py — Token savings computation
541
605
  ├── analyzers/python/
542
606
  │ ├── importer.py — AST import extraction
543
607
  │ ├── symbols.py — AST class/function/method analysis
544
608
  │ └── semantic.py — Docstring summarization
545
609
  ├── config/
610
+ │ ├── __init__.py
611
+ │ ├── init.py — Project scaffold (.ctxgraph dir)
546
612
  │ ├── settings.py — TOML/JSON/env config loading
547
613
  │ └── providers.py — Ollama, Claude, OpenAI clients
548
614
  ├── clients/models.py — Mode enum (fast/balanced/deep)
549
615
  ├── exclude/patterns.py — Exclusion pattern matching
550
616
  ├── view/visualizer.py — D3.js HTML graph generator
551
617
  ├── wrapper/claude.py — ccg Claude wrapper
552
- └── mcp/server.py — MCP protocol server
618
+ ├── mcp/server.py — MCP protocol server
619
+ ├── skills/
620
+ │ ├── __init__.py — Skill discovery + loading
621
+ │ ├── project-style.toml — Default skill: project conventions
622
+ │ └── field-guide.toml — Default skill: field guide
623
+ └── history.py — JSONL history append/query/stats
553
624
  ```
554
625
 
555
626
  ---