@muthuishere/ctx-optimize 0.3.11 → 0.4.1
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.
- package/README.md +129 -36
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# ctx-optimize
|
|
2
2
|
|
|
3
3
|
[](https://github.com/muthuishere/ctx-optimize/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pkg.go.dev/github.com/muthuishere/ctx-optimize)
|
|
4
5
|
[](https://www.npmjs.com/package/@muthuishere/ctx-optimize)
|
|
5
6
|
[](https://muthuishere.github.io/ctx-optimize-site/proof/agent/)
|
|
6
7
|
[](https://www.npmjs.com/package/@muthuishere/ctx-optimize)
|
|
@@ -13,11 +14,13 @@ question it greps, opens files, chases callers, re-reads. ctx-optimize turns a
|
|
|
13
14
|
repo — plus, via adapters, database schemas, messaging topics, log shapes,
|
|
14
15
|
documents — into a queryable graph stored as plain files in a central
|
|
15
16
|
per-module store, and your agent (Claude Code, Codex, Devin — any skill-capable
|
|
16
|
-
harness) answers *from the store* in a single call. The binary
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
harness) answers *from the store* in a single call. The binary is
|
|
18
|
+
deterministic — no LLM, no DB, and network only when you ask: `update`
|
|
19
|
+
(releases), `grammar build` (zig, downloaded once), and whatever your own
|
|
20
|
+
remote scripts do. The only intelligence in the system is the agent you
|
|
21
|
+
already run.
|
|
19
22
|
|
|
20
|
-
> **Status: v0.
|
|
23
|
+
> **Status: v0.4.** On npm (`@muthuishere/ctx-optimize`) with
|
|
21
24
|
> prebuilt binaries for macOS / Linux / Windows; CI green; benchmarks
|
|
22
25
|
> reproducible (see [Proof](#proof--reproducible-not-our-word)). Working
|
|
23
26
|
> today: code extraction for **12 embedded languages** (Go, Python, JS,
|
|
@@ -25,12 +28,22 @@ intelligence in the system is the agent you already run.
|
|
|
25
28
|
> zero setup) plus **drop-in grammar packs** for any other language
|
|
26
29
|
> (kotlin/swift/dart ship in `grammars/`), markdown docs, the universal
|
|
27
30
|
> adapter door, `query`/`path`/`explain`/`affected`/`hubs`, **symbol cards**
|
|
28
|
-
> (`card X`: signature + doc + callers/callees, no file read),
|
|
31
|
+
> (`card X`: signature + doc + callers/callees, no file read),
|
|
32
|
+
> **`change-plan`** (one composed answer for "I'm about to change X":
|
|
33
|
+
> signature + callers + blast radius + which tests to run), the
|
|
29
34
|
> **deterministic wiki** (regenerated on every add) with a
|
|
30
35
|
> **community-detected "Subsystems" map**, the save-result/reflect
|
|
31
|
-
> learning loop, merge/export (json/dot/graphml/csv/obsidian),
|
|
32
|
-
>
|
|
36
|
+
> learning loop, merge/export (json/dot/graphml/csv/obsidian), **scripted
|
|
37
|
+
> remote push/pull**, and **multi-module monorepo support** (`scan` /
|
|
33
38
|
> `init --scan` / parallel fan-out `add` / navigator + federated queries).
|
|
39
|
+
> New in v0.4 (**breaking**): **the remote is your script** — the binary
|
|
40
|
+
> ships no transport of its own; `remote push`/`pull` run the commands you
|
|
41
|
+
> declare in the committed config (`remote init` and the built-in
|
|
42
|
+
> `file://`/`s3://` lanes are gone — see [Sharing](#sharing--the-remote-is-your-script)),
|
|
43
|
+
> **`up`** (the one onboarding verb: pull, gather, or refresh — whatever the
|
|
44
|
+
> state needs), **`sync`** + **`adapters run`** (fast lane / slow lane around
|
|
45
|
+
> adapter scripts), and **`update`** (self-updates the binary and every
|
|
46
|
+
> installed surface — sha256-verified, user-invoked only).
|
|
34
47
|
> New in v0.3: **framework routes** (FastAPI/Flask/Express/NestJS/Angular/
|
|
35
48
|
> React Router/Vue + OpenAPI/Drupal/Ingress YAML — route nodes linked to
|
|
36
49
|
> their handlers, so `affected <handler>` surfaces the URL that binds it),
|
|
@@ -62,25 +75,65 @@ Go:
|
|
|
62
75
|
go install github.com/muthuishere/ctx-optimize/cmd/ctx-optimize@latest
|
|
63
76
|
```
|
|
64
77
|
|
|
65
|
-
Then install the agent
|
|
66
|
-
|
|
78
|
+
Then install the agent surface — skills + hooks for every agent CLI it
|
|
79
|
+
detects (Claude Code, Codex, Copilot, Devin):
|
|
67
80
|
|
|
68
81
|
```sh
|
|
69
|
-
ctx-optimize install
|
|
82
|
+
ctx-optimize install
|
|
70
83
|
```
|
|
71
84
|
|
|
85
|
+
Later, one command updates the whole tool:
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
ctx-optimize update # the binary itself (npm installs via npm; standalone
|
|
89
|
+
# binaries from GitHub Releases, sha256-verified
|
|
90
|
+
# against checksums.txt, swapped atomically; dev
|
|
91
|
+
# builds left alone), then skills + hooks + the
|
|
92
|
+
# global rule from the new binary — an exact replace
|
|
93
|
+
ctx-optimize update --check # report only, touch nothing
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The network call happens only when YOU run it — the binary never checks for
|
|
97
|
+
updates in the background. `ctx-optimize uninstall` removes everything
|
|
98
|
+
`install` wrote; stores and committed repo pointers stay.
|
|
99
|
+
|
|
72
100
|
## Usage
|
|
73
101
|
|
|
102
|
+
One verb is the whole getting-started story — bare repo, fresh clone,
|
|
103
|
+
teammate machine, CI, stale store, doesn't matter:
|
|
104
|
+
|
|
74
105
|
```sh
|
|
75
|
-
|
|
106
|
+
ctx-optimize up
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`up` looks at the state and does the right thing: no config → bootstraps it
|
|
110
|
+
(monorepos via scan; curate `.ctxoptimize/config.json` after) and gathers;
|
|
111
|
+
committed config with a `remote.pull` and no local store → pulls the team's
|
|
112
|
+
prebuilt graph (falls back to gathering, loudly); no remote → gathers;
|
|
113
|
+
stale vs git HEAD → fast re-gather; fresh → no-op. Idempotent — run it
|
|
114
|
+
whenever.
|
|
115
|
+
|
|
116
|
+
```sh
|
|
117
|
+
# author-side, when you want control instead of `up`'s defaults:
|
|
118
|
+
# scaffold .ctxoptimize/ (config, adapter + transport samples,
|
|
119
|
+
# remote.example.md), review monorepo module lists, pick pointer targets
|
|
76
120
|
ctx-optimize init
|
|
77
121
|
|
|
78
|
-
# gather
|
|
122
|
+
# gather / refresh explicitly (up calls these lanes for you)
|
|
79
123
|
ctx-optimize add .
|
|
80
124
|
|
|
81
125
|
# ask the store — complete, citable hits under a token budget
|
|
82
126
|
ctx-optimize query "where is the refund flow" --json
|
|
83
127
|
|
|
128
|
+
# about to change something? ONE composed call: signature + callers +
|
|
129
|
+
# blast radius + WHICH TESTS TO RUN + co-change history
|
|
130
|
+
ctx-optimize change-plan "RefundService"
|
|
131
|
+
|
|
132
|
+
# fast lane / slow lane: re-gather code without running adapter scripts;
|
|
133
|
+
# run adapters (DB dumps, doc converters) on demand — all, or one by name
|
|
134
|
+
ctx-optimize sync
|
|
135
|
+
ctx-optimize adapters run
|
|
136
|
+
|
|
84
137
|
# feed ANY system through the universal adapter door (strictly validated)
|
|
85
138
|
./my-postgres-adapter | ctx-optimize add --json -
|
|
86
139
|
|
|
@@ -91,19 +144,59 @@ ctx-optimize export --format dot --out graph.dot
|
|
|
91
144
|
# see it: local dashboard (embedded single file, zero external requests)
|
|
92
145
|
ctx-optimize serve # → http://127.0.0.1:4747 — graph, search, details
|
|
93
146
|
|
|
94
|
-
# share the store: sync-only remotes (S3-compatible or any folder)
|
|
95
|
-
ctx-optimize remote init s3://team-bucket/ctx/myrepo # writes .ctxoptimize/config.json — commit it
|
|
96
|
-
ctx-optimize remote push # incremental — only changed artifacts move
|
|
97
|
-
ctx-optimize remote pull # a teammate who cloned the repo: this is ALL they run
|
|
98
|
-
|
|
99
147
|
ctx-optimize status --json
|
|
100
148
|
```
|
|
101
149
|
|
|
102
150
|
- The store is **plain files** (ndjson/json/md) — diffable, portable, at
|
|
103
151
|
`~/ctxoptimize/<repo-name>/`. The only thing in your repo is the
|
|
104
152
|
committable `.ctxoptimize/` directory.
|
|
105
|
-
- **
|
|
106
|
-
|
|
153
|
+
- **Sharing is your script.** `remote push` / `remote pull` run the commands
|
|
154
|
+
declared in the committed config — the binary ships no transport of its
|
|
155
|
+
own. Queries always run on the local folder. See
|
|
156
|
+
[Sharing](#sharing--the-remote-is-your-script).
|
|
157
|
+
|
|
158
|
+
## Sharing — the remote is your script
|
|
159
|
+
|
|
160
|
+
The binary never moves bytes to a host it chose. `remote push` / `remote pull`
|
|
161
|
+
run the commands you declare in `.ctxoptimize/config.json` — any shell line
|
|
162
|
+
(js, py, sh, or inline):
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"remote": {
|
|
167
|
+
"push": "node .ctxoptimize/push.js",
|
|
168
|
+
"pull": "node .ctxoptimize/pull.js"
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Your command gets the store context in env — `CTX_STORE_DIR` (the local store
|
|
174
|
+
tree; pull pre-creates it), `CTX_STORE_KEY`, `CTX_SCOPE_PREFIX` (module scope),
|
|
175
|
+
`CTX_DIRECTION` (`push`/`pull` — one script can serve both) — and a non-zero
|
|
176
|
+
exit fails the verb. Same trust model as adapters and npm scripts.
|
|
177
|
+
|
|
178
|
+
`init` scaffolds a complete zero-dependency **git lane** as inert samples: a
|
|
179
|
+
private git repo hosts every store (artifacts are sorted ndjson, so git diffs
|
|
180
|
+
and merges them cleanly). Arming it:
|
|
181
|
+
|
|
182
|
+
```sh
|
|
183
|
+
gh repo create your-org/ctx-stores --private # once per team
|
|
184
|
+
mv .ctxoptimize/push.js.sample .ctxoptimize/push.js
|
|
185
|
+
mv .ctxoptimize/pull.js.sample .ctxoptimize/pull.js
|
|
186
|
+
# set STORE_REPO_URL in both, add the "remote" block to config.json, commit
|
|
187
|
+
ctx-optimize remote push
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
A teammate who clones the repo runs `ctx-optimize up` — done. S3/R2/MinIO is
|
|
191
|
+
a small aws-CLI script over the same env contract; GCS, artifactory,
|
|
192
|
+
rsync-over-ssh, anything: write the script that copies `CTX_STORE_DIR` to and
|
|
193
|
+
from your host and declare it. Recipes live in the scaffolded
|
|
194
|
+
`.ctxoptimize/remote.example.md`. Secrets stay env-var NAMES that the shell
|
|
195
|
+
expands at run time — never in config or scripts, never printed.
|
|
196
|
+
|
|
197
|
+
Upgrading from v0.3: `remote init` and the built-in `file://`/`s3://`
|
|
198
|
+
transports are gone. A legacy URL-shaped config still loads but is inert —
|
|
199
|
+
`push`/`pull` print the migration pointer.
|
|
107
200
|
|
|
108
201
|
## Multi-module — monorepos get one graph per module, plus a navigator
|
|
109
202
|
|
|
@@ -192,8 +285,10 @@ Harness + full write-up: https://muthuishere.github.io/ctx-optimize-site/proof/a
|
|
|
192
285
|
|
|
193
286
|
```
|
|
194
287
|
.ctxoptimize/
|
|
195
|
-
config.json
|
|
196
|
-
adapters/
|
|
288
|
+
config.json name + remote commands (+ modules[] in a monorepo)
|
|
289
|
+
adapters/ drop scripts here — every .js/.py/.sh runs on `add`
|
|
290
|
+
push.js / pull.js your transport scripts (init writes an inert *.sample pair)
|
|
291
|
+
remote.example.md transport recipes: git lane, s3 lane, custom
|
|
197
292
|
```
|
|
198
293
|
|
|
199
294
|
`config.json`:
|
|
@@ -202,14 +297,8 @@ Harness + full write-up: https://muthuishere.github.io/ctx-optimize-site/proof/a
|
|
|
202
297
|
{
|
|
203
298
|
"name": "my-module",
|
|
204
299
|
"remote": {
|
|
205
|
-
"
|
|
206
|
-
"
|
|
207
|
-
"credentials": {
|
|
208
|
-
"access_key_id": "${TEAM_R2_KEY_ID}",
|
|
209
|
-
"secret_access_key": "${TEAM_R2_SECRET}",
|
|
210
|
-
"region": "auto",
|
|
211
|
-
"endpoint": "${R2_ENDPOINT}"
|
|
212
|
-
}
|
|
300
|
+
"push": "node .ctxoptimize/push.js",
|
|
301
|
+
"pull": "node .ctxoptimize/pull.js"
|
|
213
302
|
}
|
|
214
303
|
}
|
|
215
304
|
```
|
|
@@ -217,17 +306,21 @@ Harness + full write-up: https://muthuishere.github.io/ctx-optimize-site/proof/a
|
|
|
217
306
|
Commit the directory — it is safe by construction:
|
|
218
307
|
|
|
219
308
|
- `name` picks the store folder under `~/ctxoptimize/` (default: repo basename).
|
|
220
|
-
- `remote`
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
written or printed.
|
|
224
|
-
env vars (endpoint override covers R2/Hetzner/MinIO).
|
|
309
|
+
- `remote` declares the push/pull commands — plain shell lines the binary
|
|
310
|
+
runs as-is (cwd = repo root). Secrets stay env-var NAMES in scripts and
|
|
311
|
+
config alike; the shell expands them at run time — values are never
|
|
312
|
+
written or printed.
|
|
225
313
|
- **Adapters are files**: dropping `kafka.js` into `.ctxoptimize/adapters/`
|
|
226
314
|
is the whole registration (`.js`/`.mjs` → node, `.py` → python3, `.sh` →
|
|
227
315
|
sh; other extensions inert — `init` seeds an `example.js.sample` template).
|
|
228
316
|
Each script prints batch JSON to stdout; `ctx-optimize add` runs the
|
|
229
|
-
built-in extractors **and** every adapter through the fail-closed door.
|
|
230
|
-
|
|
317
|
+
built-in extractors **and** every adapter through the fail-closed door.
|
|
318
|
+
Adapters can be arbitrarily slow (DB dumps, doc converters), so they get
|
|
319
|
+
their own lanes: `sync` re-gathers the repo you're in and **skips** them
|
|
320
|
+
(safe — replace is producer-scoped, adapter nodes stay put), `adapters
|
|
321
|
+
run [name]` re-runs all or one on demand, `add --no-adapters` is the fast
|
|
322
|
+
lane spelled long. One `add` refreshes the whole world; a fresh clone
|
|
323
|
+
needs zero setup — `ctx-optimize up`.
|
|
231
324
|
|
|
232
325
|
## Grammar packs — add any language without recompiling
|
|
233
326
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@muthuishere/ctx-optimize",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Gather a codebase (and its world) into one local knowledge store an AI agent answers from — deterministic, no LLM API, no DB.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"ctx-optimize": "bin/ctx-optimize.js"
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"url": "git+https://github.com/muthuishere/ctx-optimize.git"
|
|
16
16
|
},
|
|
17
17
|
"optionalDependencies": {
|
|
18
|
-
"@muthuishere/ctx-optimize-darwin-arm64": "0.
|
|
19
|
-
"@muthuishere/ctx-optimize-darwin-x64": "0.
|
|
20
|
-
"@muthuishere/ctx-optimize-linux-arm64": "0.
|
|
21
|
-
"@muthuishere/ctx-optimize-linux-x64": "0.
|
|
22
|
-
"@muthuishere/ctx-optimize-windows-x64": "0.
|
|
18
|
+
"@muthuishere/ctx-optimize-darwin-arm64": "0.4.1",
|
|
19
|
+
"@muthuishere/ctx-optimize-darwin-x64": "0.4.1",
|
|
20
|
+
"@muthuishere/ctx-optimize-linux-arm64": "0.4.1",
|
|
21
|
+
"@muthuishere/ctx-optimize-linux-x64": "0.4.1",
|
|
22
|
+
"@muthuishere/ctx-optimize-windows-x64": "0.4.1"
|
|
23
23
|
}
|
|
24
24
|
}
|