ctxloop 0.3.1__tar.gz → 0.3.3__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 (56) hide show
  1. ctxloop-0.3.3/NOTICE +7 -0
  2. {ctxloop-0.3.1/src/ctxloop.egg-info → ctxloop-0.3.3}/PKG-INFO +131 -121
  3. {ctxloop-0.3.1 → ctxloop-0.3.3}/README.md +130 -120
  4. {ctxloop-0.3.1 → ctxloop-0.3.3}/pyproject.toml +2 -3
  5. ctxloop-0.3.3/src/ctxloop/__init__.py +8 -0
  6. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/ab.py +18 -18
  7. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/baseline.py +3 -3
  8. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/bench.py +28 -28
  9. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/cli.py +223 -79
  10. ctxloop-0.3.3/src/ctxloop/contract.py +95 -0
  11. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/dashboard.py +180 -97
  12. ctxloop-0.3.3/src/ctxloop/dashboard_server.py +149 -0
  13. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/engine.py +27 -20
  14. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/hooks.py +12 -12
  15. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/installer.py +129 -92
  16. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/ledger.py +2 -2
  17. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/mcp_server.py +84 -52
  18. ctxloop-0.3.3/src/ctxloop/migration.py +318 -0
  19. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/probe.py +1 -1
  20. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/project.py +25 -20
  21. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/retrieval.py +13 -13
  22. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/router.py +5 -5
  23. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/semantic.py +12 -12
  24. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/shellfilter.py +8 -8
  25. {ctxloop-0.3.1 → ctxloop-0.3.3/src/ctxloop.egg-info}/PKG-INFO +131 -121
  26. ctxloop-0.3.3/src/ctxloop.egg-info/SOURCES.txt +48 -0
  27. {ctxloop-0.3.1 → ctxloop-0.3.3}/src/ctxloop.egg-info/entry_points.txt +0 -1
  28. ctxloop-0.3.3/src/ctxloop.egg-info/top_level.txt +1 -0
  29. ctxloop-0.3.3/tests/test_contract.py +113 -0
  30. {ctxloop-0.3.1 → ctxloop-0.3.3}/tests/test_core.py +10 -10
  31. ctxloop-0.3.3/tests/test_dashboard_server.py +253 -0
  32. {ctxloop-0.3.1 → ctxloop-0.3.3}/tests/test_integrations.py +109 -89
  33. {ctxloop-0.3.1 → ctxloop-0.3.3}/tests/test_memory_client.py +1 -1
  34. {ctxloop-0.3.1 → ctxloop-0.3.3}/tests/test_memory_cross_runtime.py +43 -6
  35. {ctxloop-0.3.1 → ctxloop-0.3.3}/tests/test_memory_eval.py +1 -1
  36. {ctxloop-0.3.1 → ctxloop-0.3.3}/tests/test_memory_integration.py +5 -5
  37. ctxloop-0.3.3/tests/test_migration.py +195 -0
  38. {ctxloop-0.3.1 → ctxloop-0.3.3}/tests/test_refresh.py +7 -6
  39. {ctxloop-0.3.1 → ctxloop-0.3.3}/tests/test_semantic.py +9 -9
  40. ctxloop-0.3.1/NOTICE +0 -7
  41. ctxloop-0.3.1/src/ctxloop/__init__.py +0 -7
  42. ctxloop-0.3.1/src/ctxloop.egg-info/SOURCES.txt +0 -44
  43. ctxloop-0.3.1/src/ctxloop.egg-info/top_level.txt +0 -2
  44. ctxloop-0.3.1/src/graphsnip/__init__.py +0 -3
  45. ctxloop-0.3.1/src/graphsnip/__main__.py +0 -4
  46. {ctxloop-0.3.1 → ctxloop-0.3.3}/LICENSE +0 -0
  47. {ctxloop-0.3.1 → ctxloop-0.3.3}/setup.cfg +0 -0
  48. {ctxloop-0.3.1 → ctxloop-0.3.3}/src/ctxloop/__main__.py +0 -0
  49. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/memory_client.py +0 -0
  50. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/memory_eval.py +0 -0
  51. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/py.typed +0 -0
  52. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/slicer.py +0 -0
  53. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/tokens.py +0 -0
  54. {ctxloop-0.3.1/src/graphsnip → ctxloop-0.3.3/src/ctxloop}/usage.py +0 -0
  55. {ctxloop-0.3.1 → ctxloop-0.3.3}/src/ctxloop.egg-info/dependency_links.txt +0 -0
  56. {ctxloop-0.3.1 → ctxloop-0.3.3}/src/ctxloop.egg-info/requires.txt +0 -0
ctxloop-0.3.3/NOTICE ADDED
@@ -0,0 +1,7 @@
1
+ ctxloop
2
+ Copyright 2026 Nithin and the ctxloop contributors.
3
+
4
+ ctxloop is a companion layer built on top of Graphify
5
+ (https://github.com/Graphify-Labs/graphify), which is licensed under the
6
+ Apache License 2.0. Graphify is a separate project; ctxloop calls it as a
7
+ library and does not copy its source.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ctxloop
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: Token-saving layer on top of Graphify: symbol-level code slicing, context packs, a savings ledger with an honest baseline, hooks and MCP for Claude Code, Copilot and Codex.
5
5
  License-Expression: Apache-2.0
6
6
  Project-URL: Repository, https://github.com/naubadnithinkumar/ctxloop
@@ -41,9 +41,9 @@ A token-saving layer on top of [Graphify](https://github.com/Graphify-Labs/graph
41
41
 
42
42
  <br>
43
43
 
44
- <img src="https://raw.githubusercontent.com/naubadnithin7/codegraf/main/docs/img/dashboard-overview.png" alt="graphsnip dashboard: tokens saved, reduction, per-call chart" width="900">
44
+ <img src="https://raw.githubusercontent.com/naubadnithin7/codegraf/main/docs/img/dashboard-overview.png" alt="ctxloop dashboard: tokens saved, reduction, per-call chart" width="900">
45
45
 
46
- <sub>The dashboard <code>graphsnip report</code> writes. Real data from the Flask codebase.</sub>
46
+ <sub>The dashboard <code>ctxloop report</code> writes. Real data from the Flask codebase.</sub>
47
47
 
48
48
  </div>
49
49
 
@@ -51,7 +51,7 @@ A token-saving layer on top of [Graphify](https://github.com/Graphify-Labs/graph
51
51
 
52
52
  ## At a glance
53
53
 
54
- | | Without a graph | Graphify alone | **Graphify + graphsnip** |
54
+ | | Without a graph | Graphify alone | **Graphify + ctxloop** |
55
55
  |---|---|---|---|
56
56
  | What the agent receives | whole files from grep | a map, **no source code** | **the exact code**, ranked and budgeted |
57
57
  | Tokens for 8 Flask questions | 366,565 | 13,008 (then it must read files) | **17,869** |
@@ -62,7 +62,7 @@ A token-saving layer on top of [Graphify](https://github.com/Graphify-Labs/graph
62
62
  <img src="https://raw.githubusercontent.com/naubadnithin7/codegraf/main/docs/img/benchmark.svg" alt="Tokens per approach on Flask and Express" width="860">
63
63
  </div>
64
64
 
65
- Graphify is excellent at telling an agent *where* things are. graphsnip adds the step after: *hand over just that code*, stop re-sending code the agent already has, and measure what it saved. Baseline here is deliberately realistic: **grep the question's terms and read the top 8 matching files in full**. It is far less than "read the whole repo".
65
+ Graphify is excellent at telling an agent *where* things are. ctxloop adds the step after: *hand over just that code*, stop re-sending code the agent already has, and measure what it saved. Baseline here is deliberately realistic: **grep the question's terms and read the top 8 matching files in full**. It is far less than "read the whole repo".
66
66
 
67
67
  ## Try it
68
68
 
@@ -84,13 +84,13 @@ ctxloop init # build graph, wire up Claude Code / Copilot /
84
84
  ctxloop report --open # savings dashboard (grows as agents use it)
85
85
  ```
86
86
 
87
- No LLM key needed. Everything runs locally: Graphify parses with tree-sitter, graphsnip slices with tree-sitter.
87
+ No LLM key needed. Everything runs locally: Graphify parses with tree-sitter, ctxloop slices with tree-sitter.
88
88
 
89
- Want a one-command demo on any repo? `graphsnip demo --open` builds the graph, runs a benchmark and opens the dashboard.
89
+ Want a one-command demo on any repo? `ctxloop demo --open` builds the graph, runs a benchmark and opens the dashboard.
90
90
 
91
91
  ## Memory Engine: learn from previous coding tasks (optional)
92
92
 
93
- GraphSnip integrates with the independent, open-source [Memory Engine](https://github.com/naubadnithinkumar/memory-engine). The graph describes the current code; memory captures evidence-backed lessons from previous work; approved skills capture reusable procedures. Memory is local, project-scoped and opt-in. No model API key is needed for this walkthrough.
93
+ CtxLoop integrates with the independent, open-source [Memory Engine](https://github.com/naubadnithinkumar/memory-engine). The graph describes the current code; memory captures evidence-backed lessons from previous work; approved skills capture reusable procedures. Memory is local, project-scoped and opt-in. No model API key is needed for this walkthrough.
94
94
 
95
95
  ```mermaid
96
96
  flowchart LR
@@ -99,7 +99,7 @@ flowchart LR
99
99
  C --> D[Verified memory]
100
100
  D --> E[Corroborated skill proposal]
101
101
  E --> F[Independent approval]
102
- G[Current code graph] --> H[gs_pack]
102
+ G[Current code graph] --> H[ctxloop_pack]
103
103
  D --> H
104
104
  F --> H
105
105
  H --> I[Budgeted agent context]
@@ -108,16 +108,16 @@ flowchart LR
108
108
 
109
109
  ### 1. Install the integration
110
110
 
111
- Use Python 3.10+ and Node.js 22.13+. The following POSIX shell commands install the current GraphSnip source and the exact Memory Engine revision used by the interoperability CI. The new integration is not assumed to be available in an older registry release.
111
+ Use Python 3.10+ and Node.js 22.13+. The following POSIX shell commands install the current CtxLoop source and the exact Memory Engine revision used by the interoperability CI. The new integration is not assumed to be available in an older registry release.
112
112
 
113
113
  ```bash
114
- pipx install 'git+https://github.com/naubadnithinkumar/graphsnip.git'
115
- npm install -g https://github.com/naubadnithinkumar/memory-engine/archive/befb5607a7109d8bcc8160a1947878de09a3d807.tar.gz
116
- command -v graphsnip
114
+ pipx install 'git+https://github.com/naubadnithinkumar/ctxloop.git'
115
+ npm install -g @nithin-naubad/memory-engine@0.1.1
116
+ command -v ctxloop
117
117
  command -v memory-engine
118
118
  ```
119
119
 
120
- If GraphSnip is already installed via pipx, use a separate development environment or explicitly replace that installation. The Memory Engine executable must also be on the PATH of your IDE/MCP server, not just your interactive shell.
120
+ If CtxLoop is already installed via pipx, use a separate development environment or explicitly replace that installation. The Memory Engine executable must also be on the PATH of your IDE/MCP server, not just your interactive shell.
121
121
 
122
122
  ### 2. Create a disposable demonstration project
123
123
 
@@ -205,13 +205,13 @@ mem '{"version":1,"operation":"approvedSkills","params":{"context":"project"}}'
205
205
  ### 5. Compare context with and without memory
206
206
 
207
207
  ```bash
208
- graphsnip build
209
- mkdir -p .graphsnip
210
- printf '%s\n' '{"memory":{"enabled":false}}' > .graphsnip/config.json
211
- graphsnip pack "validate email" --budget 8000
212
- printf '%s\n' '{"memory":{"enabled":true,"context":"project","skills":true}}' > .graphsnip/config.json
213
- graphsnip pack "validate email" --budget 8000
214
- graphsnip report --open
208
+ ctxloop build
209
+ mkdir -p .ctxloop
210
+ printf '%s\n' '{"memory":{"enabled":false}}' > .ctxloop/config.json
211
+ ctxloop pack "validate email" --budget 8000
212
+ printf '%s\n' '{"memory":{"enabled":true,"context":"project","skills":true}}' > .ctxloop/config.json
213
+ ctxloop pack "validate email" --budget 8000
214
+ ctxloop report --open
215
215
  ```
216
216
 
217
217
  These config replacements are for the disposable demo only. In an existing project, merge the memory object into your existing configuration instead.
@@ -233,25 +233,25 @@ The **Memory usage** dashboard card shows retrieval attempts, successful retriev
233
233
  ### 6. Use memory from Claude Code, Copilot or Codex
234
234
 
235
235
  ```bash
236
- graphsnip install --clients claude,copilot,codex
237
- graphsnip doctor
236
+ ctxloop install --clients claude,copilot,codex
237
+ ctxloop doctor
238
238
  ```
239
239
 
240
240
  Restart the client and trust the MCP server. With memory enabled, these tools are available:
241
241
 
242
242
  | Tool | Arguments | Purpose |
243
243
  |---|---|---|
244
- | `gs_memory_record` | type, title, learning, evidence (optional) | Record a candidate |
245
- | `gs_memory_search` | query, limit (optional) | Search historical records, including candidates |
246
- | `gs_memory_stats` | none | Inspect local memory counts |
247
- | `gs_skill_propose` | memoryId | Propose a corroborated skill |
248
- | `gs_skill_list` | none | List proposals |
249
- | `gs_skill_inspect` | id | Inspect a proposal |
250
- | `gs_pack` | task, budget | Retrieve code plus eligible memory and skills |
244
+ | `ctxloop_memory_record` | type, title, learning, evidence (optional) | Record a candidate |
245
+ | `ctxloop_memory_search` | query, limit (optional) | Search historical records, including candidates |
246
+ | `ctxloop_memory_stats` | none | Inspect local memory counts |
247
+ | `ctxloop_skill_propose` | memoryId | Propose a corroborated skill |
248
+ | `ctxloop_skill_list` | none | List proposals |
249
+ | `ctxloop_skill_inspect` | id | Inspect a proposal |
250
+ | `ctxloop_pack` | task, budget | Retrieve code plus eligible memory and skills |
251
251
 
252
- Example agent request: “Use gs_pack to locate email validation. After the change and tests, record any reusable correction as a candidate with gs_memory_record. Do not mark your own work verified.”
252
+ Example agent request: “Use ctxloop_pack to locate email validation. After the change and tests, record any reusable correction as a candidate with ctxloop_memory_record. Do not mark your own work verified.”
253
253
 
254
- Verification and approval are intentionally not exposed as GraphSnip MCP tools. Automatic learning from every execution is not yet an end-to-end feature.
254
+ Verification and approval are intentionally not exposed as CtxLoop MCP tools. Automatic learning from every execution is not yet an end-to-end feature.
255
255
 
256
256
  ### 7. Invalidate stale learning and check isolation
257
257
 
@@ -267,13 +267,13 @@ Storage is under `.memory-engine/memory/memory.db` in the project root. Keep tha
267
267
 
268
268
  ### 8. Run the automated interoperability tests
269
269
 
270
- From a GraphSnip source checkout, with the pinned Memory Engine installed:
270
+ From a CtxLoop source checkout, with the pinned Memory Engine installed:
271
271
 
272
272
  ```bash
273
273
  python3 -m venv .venv
274
274
  source .venv/bin/activate
275
275
  python -m pip install '.[dev]'
276
- GRAPHSNIP_TEST_MEMORY_ENGINE=1 python -m pytest -v \
276
+ CTXLOOP_TEST_MEMORY_ENGINE=1 python -m pytest -v \
277
277
  tests/test_memory_cross_runtime.py tests/test_memory_client.py \
278
278
  tests/test_memory_integration.py tests/test_memory_eval.py
279
279
  ```
@@ -281,10 +281,10 @@ GRAPHSNIP_TEST_MEMORY_ENGINE=1 python -m pytest -v \
281
281
  See [Memory evaluation](docs/memory-evaluation.md) for the four-arm comparison (baseline, graph, memory, combined) and the offline analyzer:
282
282
 
283
283
  ```bash
284
- python -m graphsnip.memory_eval results.jsonl
284
+ python -m ctxloop.memory_eval results.jsonl
285
285
  ```
286
286
 
287
- The analyzer requires actual externally collected trial results; it does not execute model trials. The existing two-arm `graphsnip ab` is not a four-arm memory benchmark. No measured memory-specific effectiveness claim is made here.
287
+ The analyzer requires actual externally collected trial results; it does not execute model trials. The existing two-arm `ctxloop ab` is not a four-arm memory benchmark. No measured memory-specific effectiveness claim is made here.
288
288
 
289
289
 
290
290
  ## What you get
@@ -292,15 +292,15 @@ The analyzer requires actual externally collected trial results; it does not exe
292
292
  | | |
293
293
  |---|---|
294
294
  | **Verified memory and approved skills (optional)** | Reuse evidence-backed lessons in context packs with the standalone Memory Engine. |
295
- | **Exact symbol, not the file** | `gs_symbol` returns one function or class with its callers and callees. Docstrings trimmed, big classes shown as skeletons. |
296
- | **Context packs** | `gs_pack` bundles the ranked code for a whole task under a token budget in one call. |
295
+ | **Exact symbol, not the file** | `ctxloop_symbol` returns one function or class with its callers and callees. Docstrings trimmed, big classes shown as skeletons. |
296
+ | **Context packs** | `ctxloop_pack` bundles the ranked code for a whole task under a token budget in one call. |
297
297
  | **No repeats** | Code the agent already has in this session comes back as a one-line pointer. |
298
- | **Slash commands** | `/graphsnip <question>` in Claude Code and Copilot Chat, `/prompts:graphsnip` in Codex. |
298
+ | **Slash commands** | `/ctxloop <question>` in Claude Code and Copilot Chat, `/prompts:ctxloop` in Codex. |
299
299
  | **Model routing** | Light questions go to a cheaper model, hard ones are handed to a stronger one. Counted only when it really happened. |
300
300
  | **Hooks** | Claude Code is nudged to use the graph instead of broad `Read` / `grep`. Fail-open, off-switch included. |
301
- | **Shell compression** | `graphsnip run -- pytest` squeezes noisy output and keeps the failure lines. Savings are exact. |
301
+ | **Shell compression** | `ctxloop run -- pytest` squeezes noisy output and keeps the failure lines. Savings are exact. |
302
302
  | **Dashboard** | Savings per call, efficiency vs accuracy, routing log, benchmark, and Graphify's interactive graph. |
303
- | **Safe installs** | Idempotent and reversible: `graphsnip install` / `graphsnip uninstall`. Your files are never overwritten. |
303
+ | **Safe installs** | Idempotent and reversible: `ctxloop install` / `ctxloop uninstall`. Your files are never overwritten. |
304
304
 
305
305
  ## How it fits together
306
306
 
@@ -308,17 +308,17 @@ The analyzer requires actual externally collected trial results; it does not exe
308
308
  flowchart TB
309
309
  R[your repo] --> G["Graphify<br/>tree-sitter AST → graph.json<br/>graph.html · communities"]
310
310
  G --> S
311
- subgraph S["graphsnip"]
311
+ subgraph S["ctxloop"]
312
312
  direction LR
313
313
  A["symbol slicer · context packs<br/>session dedupe · budgets"]
314
314
  B["router · hooks · shell compression"]
315
315
  C["savings ledger · dashboard"]
316
316
  end
317
- S --> M["MCP server<br/>gs_pack · gs_find · gs_symbol<br/>gs_impact · gs_outline · gs_route"]
317
+ S --> M["MCP server<br/>ctxloop_pack · ctxloop_find · ctxloop_symbol<br/>ctxloop_impact · ctxloop_outline · ctxloop_route"]
318
318
  M --> CC[Claude Code]
319
319
  M --> CP[Copilot]
320
320
  M --> CX[Codex]
321
- S --> D[".graphsnip/dashboard.html"]
321
+ S --> D[".ctxloop/dashboard.html"]
322
322
  ```
323
323
 
324
324
  ## See it working
@@ -327,7 +327,7 @@ flowchart TB
327
327
  <tr>
328
328
  <td width="50%">
329
329
 
330
- **Every call, grey vs teal.** Each pair is one tool call: what grep + read would have cost against what graphsnip returned (log scale), with the multiplier on top.
330
+ **Every call, grey vs teal.** Each pair is one tool call: what grep + read would have cost against what ctxloop returned (log scale), with the multiplier on top.
331
331
 
332
332
  <img src="https://raw.githubusercontent.com/naubadnithin7/codegraf/main/docs/img/chart-per-call.png" alt="Per-call tokens, log scale">
333
333
 
@@ -350,27 +350,27 @@ flowchart TB
350
350
 
351
351
  ## Slash commands
352
352
 
353
- `graphsnip install` writes these for you:
353
+ `ctxloop install` writes these for you:
354
354
 
355
355
  | Client | Command | File |
356
356
  |---|---|---|
357
- | Claude Code | `/graphsnip <question>` and `/graphsnip-deep` | `.claude/commands/` |
358
- | Copilot (VS Code, Local chat) | `/graphsnip <question>` and `/graphsnip-deep` | `.github/prompts/*.prompt.md` |
359
- | Codex | `/prompts:graphsnip <question>` | `~/.codex/prompts/graphsnip.md` (Codex only reads prompts from your home folder; restart Codex) |
357
+ | Claude Code | `/ctxloop <question>` and `/ctxloop-deep` | `.claude/commands/` |
358
+ | Copilot (VS Code, Local chat) | `/ctxloop <question>` and `/ctxloop-deep` | `.github/prompts/*.prompt.md` |
359
+ | Codex | `/prompts:ctxloop <question>` | `~/.codex/prompts/ctxloop.md` (Codex only reads prompts from your home folder; restart Codex) |
360
360
 
361
361
  ```text
362
- /graphsnip how does request routing work
363
- /graphsnip impact Flask.dispatch_request
364
- /graphsnip savings
362
+ /ctxloop how does request routing work
363
+ /ctxloop impact Flask.dispatch_request
364
+ /ctxloop savings
365
365
  ```
366
366
 
367
367
  ## Model routing
368
368
 
369
- graphsnip cannot switch an agent's model by itself (an MCP server has no such power). What it does is decide, steer, and account for it honestly.
369
+ ctxloop cannot switch an agent's model by itself (an MCP server has no such power). What it does is decide, steer, and account for it honestly.
370
370
 
371
371
  ```mermaid
372
372
  flowchart LR
373
- T["/graphsnip task"] --> R{"gs_route<br/>wording + graph size"}
373
+ T["/ctxloop task"] --> R{"ctxloop_route<br/>wording + graph size"}
374
374
  R -- light --> L["cheap model answers<br/>(Haiku)"]
375
375
  R -- "too hard" --> E["prints: Escalating to Sonnet / Opus…"]
376
376
  E --> H["stronger subagent finishes the job"]
@@ -380,72 +380,72 @@ flowchart LR
380
380
 
381
381
  | Client | How the model is switched | Verified by |
382
382
  |---|---|---|
383
- | **Claude Code** | `/graphsnip` is pinned to the light model; hard tasks hand off to a Sonnet / Opus subagent automatically | session transcripts (`graphsnip usage`) |
384
- | **Codex** | `graphsnip codex "task"` picks the tier and runs `codex exec -m <model>`: a real switch graphsnip performs | the launcher knows the model it passed |
385
- | **Copilot** | `/graphsnip` pinned only if you set `routing.models.copilot.light`; hard tasks need `/graphsnip-deep` | not available |
383
+ | **Claude Code** | `/ctxloop` is pinned to the light model; hard tasks hand off to a Sonnet / Opus subagent automatically | session transcripts (`ctxloop usage`) |
384
+ | **Codex** | `ctxloop codex "task"` picks the tier and runs `codex exec -m <model>`: a real switch ctxloop performs | the launcher knows the model it passed |
385
+ | **Copilot** | `/ctxloop` pinned only if you set `routing.models.copilot.light`; hard tasks need `/ctxloop-deep` | not available |
386
386
 
387
387
  - **Statuses.** `routed` (running tier matched the decision), `escalate`, `session` (ran on your own model on purpose), `overpowered`, `advisory` (nobody verified which model ran). Dollars are credited **only for `routed`**.
388
388
  - **Routing saves dollars per token, not tokens.** The token savings above come from the graph alone, and the dashboard keeps the two apart.
389
- - **Prices are editable placeholders** under `routing.prices` in `.graphsnip/config.json`. Put your real ones in before showing a dollar figure. Codex model names go under `routing.models.codex`.
389
+ - **Prices are editable placeholders** under `routing.prices` in `.ctxloop/config.json`. Put your real ones in before showing a dollar figure. Codex model names go under `routing.models.codex`.
390
390
 
391
391
  <details>
392
392
  <summary><b>Codex setup</b></summary>
393
393
 
394
394
  ```json
395
- // .graphsnip/config.json
395
+ // .ctxloop/config.json
396
396
  { "routing": { "models": { "codex": { "light": "<your light model>", "standard": "<your main model>", "heavy": "<your strongest model>" } } } }
397
397
  ```
398
398
  ```bash
399
- graphsnip codex "where is the auth middleware defined" # routes, then runs codex exec -m <model>
400
- graphsnip codex --dry-run "refactor session handling" # print the command only
399
+ ctxloop codex "where is the auth middleware defined" # routes, then runs codex exec -m <model>
400
+ ctxloop codex --dry-run "refactor session handling" # print the command only
401
401
  ```
402
- `graphsnip install` also writes matching `graphsnip-light|standard|heavy` profiles into the Codex config.
402
+ `ctxloop install` also writes matching `ctxloop-light|standard|heavy` profiles into the Codex config.
403
403
  </details>
404
404
 
405
405
  ## Semantic search (optional)
406
406
 
407
407
  Keyword search finds code that shares words with your question. A vague question such as "who is allowed to login" may share none, so
408
- graphsnip can also match by meaning. Install the extra and build the index once:
408
+ ctxloop can also match by meaning. Install the extra and build the index once:
409
409
 
410
410
  ```bash
411
- pip install 'graphsnip[semantic]'
412
- graphsnip embed # one vector per function/class, stored in .graphsnip/semantic/
413
- graphsnip eval # keyword-only vs hybrid on your own questions
411
+ pip install 'ctxloop[semantic]'
412
+ ctxloop embed # one vector per function/class, stored in .ctxloop/semantic/
413
+ ctxloop eval # keyword-only vs hybrid on your own questions
414
414
  ```
415
415
 
416
416
  - **What is embedded:** each graph symbol's name, file, the names it calls and is called by, and the start of its body. The vectors live in
417
417
  three small derived files (`vectors.npy`, `ids.json`, `meta.json`) next to the ledger. Graphify's `graph.json` is not touched.
418
418
  - **Local only:** a small ONNX model (`BAAI/bge-small-en-v1.5` by default) runs on your machine. Nothing is sent anywhere. No vector database is needed.
419
419
  - **Hybrid ranking:** keyword and semantic hits are merged by reciprocal rank fusion, then expanded through the graph (callers, callees) and
420
- packed within the token budget, as before. `gs_find` and `gs_pack` get better; no new tool is added, so there is no extra tool overhead.
420
+ packed within the token budget, as before. `ctxloop_find` and `ctxloop_pack` get better; no new tool is added, so there is no extra tool overhead.
421
421
  - **Stays current:** after a graph refresh only new or changed symbols are re-embedded, and deleted ones are dropped.
422
422
  - **Falls back:** without the extra or an index, behaviour is exactly the keyword search you had before.
423
423
 
424
- **Proof, not promise.** `graphsnip eval` asks the same questions with and without the index and shows what each found (see
424
+ **Proof, not promise.** `ctxloop eval` asks the same questions with and without the index and shows what each found (see
425
425
  [`docs/semantic-tasks.example.json`](docs/semantic-tasks.example.json) for the format). If hybrid does not beat keyword on your repo,
426
- the dashboard says so. Whether better retrieval also lowers your bill is a separate question that `graphsnip ab` answers.
426
+ the dashboard says so. Whether better retrieval also lowers your bill is a separate question that `ctxloop ab` answers.
427
427
 
428
428
  ### Safer graph refresh
429
429
 
430
430
  The graph now refreshes under a cross-process lock (two editors on one repo no longer rebuild at once). The MCP server refreshes in the
431
431
  background and answers from the previous snapshot meanwhile. Changes are found by content hash, so a `git checkout` that touches files
432
- without changing them does nothing, and deleted files are noticed. `graphsnip status` lists what changed.
432
+ without changing them does nothing, and deleted files are noticed. `ctxloop status` lists what changed.
433
433
 
434
434
  ## Measured A/B: real tokens and real cost
435
435
 
436
- The dashboard's savings are estimates against a hypothetical baseline. To get **measured** numbers, run the same questions through headless Claude Code with and without graphsnip:
436
+ The dashboard's savings are estimates against a hypothetical baseline. To get **measured** numbers, run the same questions through headless Claude Code with and without ctxloop:
437
437
 
438
438
  ```bash
439
- graphsnip ab --dry-run # preview: how many sessions, the exact command
440
- graphsnip ab --yes --repeats 2 # run it (spends real usage; capped at $5 total by default)
441
- graphsnip report --open # "Measured A/B (real runs)" card + headline KPI
439
+ ctxloop ab --dry-run # preview: how many sessions, the exact command
440
+ ctxloop ab --yes --repeats 2 # run it (spends real usage; capped at $5 total by default)
441
+ ctxloop report --open # "Measured A/B (real runs)" card + headline KPI
442
442
  ```
443
443
 
444
- - Two throwaway copies of your repo: one with graphsnip uninstalled, one with it installed. Your repo is never modified.
444
+ - Two throwaway copies of your repo: one with ctxloop uninstalled, one with it installed. Your repo is never modified.
445
445
  - Both arms are read-only, use the same model and prompt, and start a fresh session per run, in shuffled order.
446
446
  - Cost and tokens are what `claude -p --output-format json` reports (`total_cost_usd`, input, cache and output tokens), so caching and every turn are included.
447
447
  - Results are medians over repeats; model runs are noisy, so use `--repeats 3` or more for a number you will quote.
448
- - "Found" only checks that the expected symbols appear. The full answers are saved under `.graphsnip/ab/` so you can judge quality yourself.
448
+ - "Found" only checks that the expected symbols appear. The full answers are saved under `.ctxloop/ab/` so you can judge quality yourself.
449
449
  - Needs the `claude` CLI on your machine. Codex A/B is not implemented yet.
450
450
 
451
451
  ## Commands
@@ -455,25 +455,35 @@ graphsnip report --open # "Measured A/B (real runs)" card + headline
455
455
 
456
456
  | Command | What it does |
457
457
  |---|---|
458
- | `graphsnip init` | build graph, install integrations, benchmark, write dashboard (`--dry-run` previews, writes nothing) |
459
- | `graphsnip demo [--open] [--bundle DIR]` | graph + benchmark + dashboard in one go; `--bundle` makes a shareable folder |
460
- | `graphsnip build [--force]` | build or refresh the Graphify graph (code only, no LLM) |
461
- | `graphsnip embed [--force] [--status]` | build or refresh the optional semantic index (only changed symbols are re-embedded) |
462
- | `graphsnip eval [--tasks FILE]` | keyword-only vs hybrid retrieval on your own questions; feeds the dashboard |
463
- | `graphsnip pack "task"` | token-budgeted bundle of the code relevant to a task |
464
- | `graphsnip find "question"` | budgeted map: where things live, how they connect |
465
- | `graphsnip symbol Name` | one function or class: exact lines, callers, callees |
466
- | `graphsnip impact Name` | what depends on a symbol |
467
- | `graphsnip outline path` | symbols in a file with line numbers |
468
- | `graphsnip route "task"` | which model tier does this need? (logs the decision) |
469
- | `graphsnip codex "task"` | route, then run `codex exec -m <model for the tier>` |
470
- | `graphsnip run -- <cmd>` | run a command, compress its output, keep the exit code |
471
- | `graphsnip stats` / `report` | savings in the terminal / the HTML dashboard |
472
- | `graphsnip usage` | which models actually answered (from Claude Code transcripts) |
473
- | `graphsnip bench` | offline benchmark: grep+read vs Graphify vs graphsnip |
474
- | `graphsnip ab` | **measured** A/B in headless Claude Code: real tokens and cost, with vs without graphsnip |
475
- | `graphsnip install` / `uninstall` | per-client config (`--clients claude,copilot,codex`) |
476
- | `graphsnip doctor` | check Python, Graphify, tree-sitter, graph freshness, client configs |
458
+ | `ctxloop init` | build graph, install integrations, benchmark, write dashboard (`--dry-run` previews, writes nothing) |
459
+ | `ctxloop demo [--open] [--bundle DIR]` | graph + benchmark + dashboard in one go; `--bundle` makes a shareable folder |
460
+ | `ctxloop build [--force]` | build or refresh the Graphify graph (code only, no LLM) |
461
+ | `ctxloop embed [--force] [--status]` | build or refresh the optional semantic index (only changed symbols are re-embedded) |
462
+ | `ctxloop eval [--tasks FILE]` | keyword-only vs hybrid retrieval on your own questions; feeds the dashboard |
463
+ | `ctxloop pack "task"` | token-budgeted bundle of the code relevant to a task |
464
+ | `ctxloop find "question"` | budgeted map: where things live, how they connect |
465
+ | `ctxloop symbol Name` | one function or class: exact lines, callers, callees |
466
+ | `ctxloop impact Name` | what depends on a symbol |
467
+ | `ctxloop outline path` | symbols in a file with line numbers |
468
+ | `ctxloop route "task"` | which model tier does this need? (logs the decision) |
469
+ | `ctxloop codex "task"` | route, then run `codex exec -m <model for the tier>` |
470
+ | `ctxloop run -- <cmd>` | run a command, compress its output, keep the exit code |
471
+ | `ctxloop stats` / `report` | savings in the terminal / the HTML dashboard |
472
+ | `ctxloop usage` | which models actually answered (from Claude Code transcripts) |
473
+ | `ctxloop bench` | offline benchmark: grep+read vs Graphify vs ctxloop |
474
+ | `ctxloop ab` | **measured** A/B in headless Claude Code: real tokens and cost, with vs without ctxloop |
475
+ | `ctxloop install` / `uninstall` | per-client config (`--clients claude,copilot,codex`) |
476
+ | `ctxloop doctor` | check Python, Graphify, tree-sitter, graph freshness, client configs |
477
+ | `ctxloop migrate [--rollback]` | copy existing project state to the new namespace, or archive the migrated copy while retaining the original |
478
+ | `ctxloop migrate --mcp-configs [--rollback]` | migrate generated project MCP registrations and marked guidance for Claude, VS Code, and Codex, with byte-for-byte backups |
479
+ | `ctxloop migrate --prompts [--rollback]` | rename generated project-local Claude and Copilot prompts and Claude agents, with exact backups |
480
+ | `ctxloop migrate --codex-user [--rollback]` | explicitly migrate the generated user-level Codex registration and prompt while preserving the registered project path |
481
+ | `ctxloop contract` | discover contract version 1, local CLI operations, and MCP tool input schemas as JSON |
482
+ | `ctxloop memory-suggestions` | filter and deduplicate execution observations through the local Memory Engine using versioned JSON on stdin |
483
+ | `ctxloop memory-evidence` | submit a reviewed local execution candidate using versioned JSON on stdin |
484
+ | `ctxloop snapshot [--html]` | read bounded graph and report metadata as contract-versioned JSON, or stream an existing offline report |
485
+ | `ctxloop dashboard [--parent-origin URL]` | start a private loopback preview of an existing offline report, print the session URL as JSON, and stop when the parent closes stdin |
486
+ | `ctxloop dashboard --live [--parent-origin URL]` | render project state on demand with section navigation, refresh, graph exploration, and local memory search and skill proposals when enabled |
477
487
 
478
488
  Every query command prints `~N tokens returned vs ~M for grep+read → saved P%` to stderr.
479
489
  </details>
@@ -483,44 +493,44 @@ Every query command prints `~N tokens returned vs ~M for grep+read → saved P%`
483
493
 
484
494
  | Tool | Use it for |
485
495
  |---|---|
486
- | `gs_pack(task, budget)` | first call for "how does X work" or before a change |
487
- | `gs_find(question, budget)` | locate things (map only) |
488
- | `gs_symbol(name, max_lines, docs)` | read one definition instead of the file |
489
- | `gs_impact(name, depth)` | blast radius before changing a signature |
490
- | `gs_outline(path)` | symbols of a big file before opening it |
491
- | `gs_route(task, running_tier)` | which model tier this task needs |
492
- | `gs_savings()` | tokens saved so far |
493
- | `gs_memory_*` / `gs_skill_*` | optional memory and skill tools; see the [Memory Engine walkthrough](#memory-engine-learn-from-previous-coding-tasks-optional) |
494
-
495
- A small dependency-free stdio JSON-RPC server (it does not depend on the MCP SDK's changing API). It refreshes a stale graph and records every call in `.graphsnip/ledger.jsonl`.
496
+ | `ctxloop_pack(task, budget)` | first call for "how does X work" or before a change |
497
+ | `ctxloop_find(question, budget)` | locate things (map only) |
498
+ | `ctxloop_symbol(name, max_lines, docs)` | read one definition instead of the file |
499
+ | `ctxloop_impact(name, depth)` | blast radius before changing a signature |
500
+ | `ctxloop_outline(path)` | symbols of a big file before opening it |
501
+ | `ctxloop_route(task, running_tier)` | which model tier this task needs |
502
+ | `ctxloop_savings()` | tokens saved so far |
503
+ | `ctxloop_memory_*` / `ctxloop_skill_*` | optional memory and skill tools; see the [Memory Engine walkthrough](#memory-engine-learn-from-previous-coding-tasks-optional) |
504
+
505
+ A small dependency-free stdio JSON-RPC server (it does not depend on the MCP SDK's changing API). It refreshes a stale graph and records every call in `.ctxloop/ledger.jsonl`.
496
506
  </details>
497
507
 
498
508
  <details>
499
509
  <summary><b>What <code>install</code> writes</b></summary>
500
510
 
501
- Idempotent (run it twice, nothing changes) and reversible (`graphsnip uninstall`). Existing content is preserved: text files get a marked block, JSON is merged.
511
+ Idempotent (run it twice, nothing changes) and reversible (`ctxloop uninstall`). Existing content is preserved: text files get a marked block, JSON is merged.
502
512
 
503
513
  | Client | Files |
504
514
  |---|---|
505
- | Claude Code | `.mcp.json`, `.claude/settings.json` (PreToolUse hook), `CLAUDE.md` block, `.claude/commands/graphsnip*.md`, `.claude/agents/graphsnip-{explorer,standard,heavy}.md` |
506
- | Copilot (VS Code) | `.vscode/mcp.json`, `.github/copilot-instructions.md` block, `.github/prompts/graphsnip*.prompt.md` |
507
- | Codex | `.codex/config.toml` (or `~/.codex/config.toml` with `--codex-scope user`), `AGENTS.md` block, `~/.codex/prompts/graphsnip.md` |
515
+ | Claude Code | `.mcp.json`, `.claude/settings.json` (PreToolUse hook), `CLAUDE.md` block, `.claude/commands/ctxloop*.md`, `.claude/agents/ctxloop-{explorer,standard,heavy}.md` |
516
+ | Copilot (VS Code) | `.vscode/mcp.json`, `.github/copilot-instructions.md` block, `.github/prompts/ctxloop*.prompt.md` |
517
+ | Codex | `.codex/config.toml` (or `~/.codex/config.toml` with `--codex-scope user`), `AGENTS.md` block, `~/.codex/prompts/ctxloop.md` |
508
518
 
509
- Flags: `--allow-tools` pre-approves the read-only tools in Claude Code, `--portable` writes bare `graphsnip` instead of this machine's absolute path (use it before committing configs), `--strict` sets hook mode to strict.
519
+ Flags: `--allow-tools` pre-approves the read-only tools in Claude Code, `--portable` writes bare `ctxloop` instead of this machine's absolute path (use it before committing configs), `--strict` sets hook mode to strict.
510
520
  </details>
511
521
 
512
522
  <details>
513
523
  <summary><b>Hooks (Claude Code)</b></summary>
514
524
 
515
- Fail-open: any error means "do nothing". Configure in `.graphsnip/config.json` (or `GRAPHSNIP_MODE`).
525
+ Fail-open: any error means "do nothing". Configure in `.ctxloop/config.json` (or `CTXLOOP_MODE`).
516
526
 
517
527
  | Mode | Behaviour |
518
528
  |---|---|
519
- | `nudge` (default) | adds context: the file's outline for big reads, `gs_symbol("X")` when a grep pattern is a known symbol. Blocks nothing |
529
+ | `nudge` (default) | adds context: the file's outline for big reads, `ctxloop_symbol("X")` when a grep pattern is a known symbol. Blocks nothing |
520
530
  | `strict` | denies those same calls with a reason that tells the agent what to call. Literal-string greps and reads with `offset`/`limit` are never blocked |
521
531
  | `off` | nothing |
522
532
 
523
- `shell_filter: true` additionally rewrites noisy test/build commands to run through `graphsnip run`. It is **off by default** because the rewrite returns an `allow` decision, which skips the permission prompt; it is limited to an allow-list and never touches pipelines or chained commands. POSIX shells only.
533
+ `shell_filter: true` additionally rewrites noisy test/build commands to run through `ctxloop run`. It is **off by default** because the rewrite returns an `allow` decision, which skips the permission prompt; it is limited to an allow-list and never touches pipelines or chained commands. POSIX shells only.
524
534
  </details>
525
535
 
526
536
  ## How the numbers are measured (and what they are not)
@@ -528,17 +538,17 @@ Fail-open: any error means "do nothing". Configure in `.graphsnip/config.json` (
528
538
  - **Baseline per call.** `find` / `pack`: grep the question's terms, read the top 8 matching files in full. `symbol`: read the whole file. `impact`: grep the name, read matching files (cap 10).
529
539
  - **Counted once.** In a real session, tokens that stay in context are re-sent every turn, so true savings compound. The dashboard does not claim that (the explorer has an optional slider to show it).
530
540
  - **Quality is checked, not assumed.** A task counts as answered only if the expected symbol appears with its source. That measures whether the right code was delivered, not whether a model's final answer was right.
531
- - **Shell savings are exact** (raw vs compressed output). Token counts elsewhere are `chars / 4` estimates; install `graphsnip[accurate]` for tiktoken.
532
- - **Your repo will differ.** Savings are larger where files are large and lookups are broad. Replace the auto-generated tasks in `.graphsnip/tasks.json` with questions you really ask, then `graphsnip bench`.
533
- - **Dollars** on the main dashboard are `tokens × price per million input tokens`, ignoring output tokens and caching: a list-price estimate. For measured dollars use `graphsnip ab`.
541
+ - **Shell savings are exact** (raw vs compressed output). Token counts elsewhere are `chars / 4` estimates; install `ctxloop[accurate]` for tiktoken.
542
+ - **Your repo will differ.** Savings are larger where files are large and lookups are broad. Replace the auto-generated tasks in `.ctxloop/tasks.json` with questions you really ask, then `ctxloop bench`.
543
+ - **Dollars** on the main dashboard are `tokens × price per million input tokens`, ignoring output tokens and caching: a list-price estimate. For measured dollars use `ctxloop ab`.
534
544
 
535
545
  ## Known limits
536
546
 
537
- - The hooks and the three client configs follow each tool's documented formats; the MCP server was verified against the official MCP Python client. Run `graphsnip doctor` and a short session in each client before relying on them.
547
+ - The hooks and the three client configs follow each tool's documented formats; the MCP server was verified against the official MCP Python client. Run `ctxloop doctor` and a short session in each client before relying on them.
538
548
  - Symbol slicing is exact for the ~25 languages with tree-sitter grammars installed; elsewhere it falls back to indentation or brace matching.
539
- - The graph only covers what Graphify extracts from code. Docs, PDFs and images need Graphify's semantic pass (needs an LLM key) and are not part of graphsnip's tools.
540
- - Graphify's `graph.html` loads vis-network from a CDN; graphsnip caches it locally so the dashboard works offline (needs internet once).
541
- - Model routing: Copilot cannot hand off to another model, Codex prompt files cannot pin one (use `graphsnip codex`), and the "measured" model mix works only for Claude Code.
549
+ - The graph only covers what Graphify extracts from code. Docs, PDFs and images need Graphify's semantic pass (needs an LLM key) and are not part of ctxloop's tools.
550
+ - Graphify's `graph.html` loads vis-network from a CDN; ctxloop caches it locally so the dashboard works offline (needs internet once).
551
+ - Model routing: Copilot cannot hand off to another model, Codex prompt files cannot pin one (use `ctxloop codex`), and the "measured" model mix works only for Claude Code.
542
552
 
543
553
  ## Development
544
554
 
@@ -551,4 +561,4 @@ Publishing: `python -m build && twine upload dist/*` (PyPI), `cd npm && npm publ
551
561
 
552
562
  ## License
553
563
 
554
- Apache-2.0. graphsnip is a separate project that calls Graphify (also Apache-2.0) as a library; see `NOTICE`.
564
+ Apache-2.0. ctxloop is a separate project that calls Graphify (also Apache-2.0) as a library; see `NOTICE`.