@muthuishere/ctx-optimize 0.3.11 → 0.4.0

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