@yasaswy.nagavolu/agents 0.8.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.
package/README.md ADDED
@@ -0,0 +1,349 @@
1
+ # @yasaswy.nagavolu/agents
2
+
3
+ CLI for installing the yasaswy.nagavolu agent/skill/hook bundle (Claude
4
+ agents, skills, hooks, and supporting tooling).
5
+
6
+ `install` opens an interactive checkbox menu of purpose-based bundles when
7
+ run in a terminal, or installs one bundle non-interactively via
8
+ `--bundle <key> --yes`. Every installed file's hash is recorded in a ledger
9
+ for idempotent re-runs. Bundles are declared in the repo-root `manifest.json`,
10
+ validated against `manifest.schema.json`
11
+ ([schema decision: #36](https://gitlab.com/yasaswy22/my-agents/-/issues/36),
12
+ [versioning decision: #37](https://gitlab.com/yasaswy22/my-agents/-/issues/37)),
13
+ and CI's `manifest-lint` job (`tools/manifest_lint.py`) fails the pipeline if
14
+ any repo file is left unclaimed by a bundle or `internal[]`.
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ npx @yasaswy.nagavolu/agents install
20
+ ```
21
+
22
+ or install the CLI globally:
23
+
24
+ ```bash
25
+ npm install -g @yasaswy.nagavolu/agents
26
+ agents-cli install
27
+ ```
28
+
29
+ ## Commands
30
+
31
+ - `agents-cli --version` — print the installed CLI version
32
+ - `agents-cli install` — in a terminal (TTY), opens the interactive bundle
33
+ menu: `↑`/`↓` move, `space` toggles, `a` selects all, `enter` confirms,
34
+ `q`/`Ctrl-C` cancels. If raw-mode keypress handling isn't available, it
35
+ falls back to a numbered prompt (`1,3,5` / `a` / blank to quit) — same
36
+ underlying selection logic either way. Piped/non-interactive (CI) input
37
+ instead prints the bundle list and instructs `--bundle` usage; exits 0.
38
+ - `agents-cli install --advanced` — interactive menu over **every** bundle
39
+ (not just the public/non-advanced basic set), and for each bundle you pick,
40
+ a second checkbox lets you deselect individual items within it (including
41
+ `advancedOnly` items like the farm-style-project routing hooks in
42
+ `agent-orchestration`) before installing.
43
+ - `agents-cli install --bundle <key> --yes` — install one bundle
44
+ non-interactively (`--yes` required to confirm). A bundle that declares
45
+ `deps` (e.g. `litellm`) also runs that dependency's component flow —
46
+ see [Components (LiteLLM-backed bundles)](#components-litellm-backed-bundles)
47
+ below. After files are installed, hooks wired, and any component set up,
48
+ the CLI prompts (in a TTY) for any secret the bundle (or its component)
49
+ declares that isn't already set — see [Secrets](#secrets) below. `--yes`
50
+ alone does **not** skip that prompting; pass `--no-secrets` explicitly if
51
+ you want to.
52
+ - `agents-cli install --bundle <key> --yes --target-dir <path>` — install into
53
+ `<path>` instead of the default `~/.claude` (mainly for testing — don't
54
+ point this at a real `~/.claude` you care about without reviewing the diff)
55
+ - `agents-cli install --bundle <key> --yes --target-config <path>` — wire any
56
+ `mcp`-kind items into `<path>` instead of the default sibling `.claude.json`
57
+ next to `--target-dir` (mainly for testing — see [MCP servers](#mcp-servers))
58
+ - `agents-cli secrets` / `agents-cli secrets --bundle <key>` / `agents-cli
59
+ secrets --list` — see [Secrets](#secrets) below.
60
+ - `agents-cli update --yes` / `agents-cli update --bundle <key> --yes` — see
61
+ [Updating](#updating) below.
62
+ - `agents-cli --help` — show usage
63
+
64
+ ### Bundle dispositions in the menu
65
+
66
+ - **installable** — installs immediately, whether or not the bundle declares
67
+ `deps`. A bundle with `deps` (LiteLLM-backed: Councils, Review Council,
68
+ Agent Orchestration, Web Search, Model Routing) is shown with a
69
+ `(needs: litellm)` hint and, on selection, also runs that component's
70
+ install flow — see [Components](#components-litellm-backed-bundles) below.
71
+ - **passthrough** — `planning-ideation` only: not shipped by this package at
72
+ all. Selecting it prints `npx skills add mattpocock/skills` instead of
73
+ installing anything.
74
+
75
+ Every installed file's hash is recorded in `<target-dir>/agents-ledger.json`.
76
+ Re-running `install` with unchanged source files is a no-op; changed or
77
+ missing files are re-copied and the ledger updated.
78
+
79
+ ## Hook wiring
80
+
81
+ Hook items that carry `wiring` data in `manifest.json` (event, matcher, type,
82
+ command — see `proxy/README.md` for what each hook does) are automatically
83
+ merged into `<target-dir>/settings.json`'s `hooks` section right after their
84
+ files are installed — no manual settings.json editing required for a public
85
+ install.
86
+
87
+ - **Idempotent.** Re-running `install` never produces duplicate hook entries
88
+ — the dedupe key is (event, matcher, `if`, resolved command path).
89
+ - **Non-destructive.** The whole settings.json is round-tripped through
90
+ `JSON.parse`/`JSON.stringify` and only the specific hook blocks we own are
91
+ touched — every unrelated key and hook entry you already have is preserved
92
+ verbatim, in place.
93
+ - **Atomic.** Writes go through a temp-file-then-rename, same as the ledger.
94
+ - **One-time backup.** Before the very first write this CLI ever makes to
95
+ your settings.json, it's copied to `settings.json.bak-<timestamp>` — a
96
+ marker on the ledger means this only ever happens once, not on every
97
+ install.
98
+ - **Multi-registration hooks.** An item's `wiring` field can be a single
99
+ object or an array of objects, for a hook that needs registering under more
100
+ than one tool matcher (e.g. `html_mocker_subagent_guard.py` under both
101
+ `Bash` and `Monitor`).
102
+ - **Python required.** Every hook shipped today is a Python script. Before
103
+ wiring a Python-backed hook, the CLI checks `python3`/`python` on `PATH`.
104
+ If neither is found, that hook's files still install but it is **not**
105
+ wired — you'll see a message telling you to install Python and re-run
106
+ `agents-cli install --bundle <key> --yes`, which re-attempts wiring only
107
+ (already-installed files are a no-op; the ledger is untouched for them).
108
+ - **Out of scope this slice.** `statusline` kind items carry wiring data too,
109
+ but their execution (writing the top-level `statusLine` key) is deferred to
110
+ a later slice.
111
+
112
+ ## MCP servers
113
+
114
+ `mcp`-kind items (e.g. `docs-lookup`'s Context7 server) carry a `wiring`
115
+ object shaped `{name, ...serverDef}` — `name` is the key to write under
116
+ `mcpServers`, and the rest (`type`/`url`/`headers`, or `type`/`command`/
117
+ `args`/`env` for stdio transports) is the entry itself. `install` merges it
118
+ into the real user-scope MCP config file Claude Code reads (`~/.claude.json`
119
+ by default — a sibling of `~/.claude`, overridable with `--target-config` for
120
+ testing) right after files are installed:
121
+
122
+ - **Idempotent.** Re-running `install` writes the same entry again only if it
123
+ changed; an unchanged entry is reported as already-wired, not re-written.
124
+ - **Non-destructive.** The whole config file is round-tripped through
125
+ `JSON.parse`/`JSON.stringify` — only the `mcpServers` entries this bundle
126
+ owns are touched; every other server entry and top-level key is preserved
127
+ verbatim.
128
+ - **Atomic + one-time backup.** Same guarantees as hook wiring: an
129
+ atomic temp-file-then-rename write, and a `.claude.json.bak-<timestamp>`
130
+ backup taken once, before this CLI's first-ever write to that file.
131
+ - **Secret placeholders.** A string value of the form `"${SECRET_NAME}"`
132
+ anywhere in the entry (e.g. an auth header) is resolved at wire time via
133
+ the same secrets contract described in [Secrets](#secrets) below. An
134
+ *unresolved* placeholder is dropped rather than written literally — e.g.
135
+ Context7's HTTP MCP works keylessly (rate-limited), so installing without
136
+ `CONTEXT7_API_KEY` set writes a `context7` entry with no `headers` key at
137
+ all, instead of blocking the install or writing a broken template string.
138
+ - **Uninstall.** `agents-cli uninstall` removes exactly the `mcpServers`
139
+ entries this bundle wired (tracked per-bundle on the ledger). An entry
140
+ hand-edited since install (its current value no longer matches what was
141
+ last written) is left in place, same protection as file uninstall gives
142
+ hash-mismatched files.
143
+
144
+ ## Components (LiteLLM-backed bundles)
145
+
146
+ Five bundles — Councils, Review Council, Agent Orchestration, Web Search,
147
+ Model Routing — declare `deps: ["litellm"]`. Installing any one of them also
148
+ runs the `litellm` component's install flow, defined once in
149
+ `manifest.json`'s top-level `components.litellm` (not duplicated per bundle):
150
+
151
+ 1. **Detect.** `litellm --version` on PATH? Already set up — nothing to
152
+ install.
153
+ 2. **Install.** Not found: `uv tool install "litellm[proxy]"` if `uv` is on
154
+ PATH ([install uv](https://docs.astral.sh/uv/)); otherwise
155
+ `pipx install "litellm[proxy]"` if `pipx` is on PATH. Neither installer
156
+ found: the bundle's own files still install, but LiteLLM itself is left
157
+ **pending** — an actionable message tells you what to run, and re-running
158
+ `agents-cli install --bundle <key> --yes` once `uv`/`pipx` is on PATH
159
+ finishes the setup.
160
+ 3. **Config + start scripts.** `<target-dir>/litellm/config.yaml` (a public,
161
+ env-parameterized template — every provider key is read via LiteLLM's
162
+ `os.environ/VAR_NAME` syntax, nothing in the file is a real secret) plus
163
+ `<target-dir>/litellm/start-litellm.ps1` and `.sh`. Both, like every other
164
+ installed file, are hash-ledger tracked and idempotent.
165
+
166
+ **Starting the proxy** is a separate, manual step (no service supervision in
167
+ this release):
168
+
169
+ ```bash
170
+ # Windows
171
+ powershell -ExecutionPolicy Bypass -File ~/.claude/litellm/start-litellm.ps1
172
+
173
+ # macOS/Linux
174
+ ~/.claude/litellm/start-litellm.sh
175
+ ```
176
+
177
+ Either script loads `<target-dir>/agents.env` into the process environment
178
+ first (a real exported env var of the same name always wins), then runs
179
+ `litellm --config config.yaml --port 4000` in the foreground — Ctrl-C or
180
+ closing the window stops it; re-run the script to start it again.
181
+
182
+ **Secrets.** `manifest.json`'s `components.litellm.secrets` declares
183
+ `LITELLM_MASTER_KEY` (required for any LiteLLM-backed bundle to work — pick
184
+ any random string) plus one optional provider key per model alias the
185
+ shipped config registers (`GAISTUDIO_API_KEY` for Gemini, `DEEPSEEK_API_KEY`,
186
+ `ZAI_API_KEY` for GLM, `TOGETHERAI_API_KEY` for Qwen, `PERPLEXITY_API_KEY`,
187
+ and `OPENAI_API_KEY` for a bonus generic alias no bundle calls yet). These are
188
+ prompted **once**, deduped by name, the same way a secret shared by two
189
+ bundles is — selecting both Councils and Web Search in one `install` run
190
+ doesn't ask for `LITELLM_MASTER_KEY` twice. Missing a provider key doesn't
191
+ break the proxy or the other models; only that one model 401s when called —
192
+ delete its block from `config.yaml` if you don't want it registered at all.
193
+
194
+ **Uninstall.** Uninstalling the *last* remaining bundle that depends on
195
+ `litellm` removes `<target-dir>/litellm/config.yaml` and the start scripts
196
+ (if untouched since install — an edited file is left in place, same
197
+ protection every other uninstall gives you). The actual `litellm` binary
198
+ (installed via `uv`/`pipx`) is **left installed** — uninstalling a shared
199
+ tool you may use elsewhere isn't this CLI's call to make; the uninstall
200
+ output tells you the exact command to remove it yourself if you want to.
201
+ Uninstalling one of *several* dep-bundles while another is still installed
202
+ leaves the component alone entirely.
203
+
204
+ ## Secrets
205
+
206
+ Some bundles declare `secrets` in `manifest.json` (e.g. `GITLAB_TOKEN` for
207
+ `shipping`/`agent-orchestration`,
208
+ `REDDIT_CLIENT_ID`/`REDDIT_CLIENT_SECRET`/`REDDIT_USER_AGENT` for
209
+ `reddit-reader`), and components declare secrets of their own (e.g.
210
+ `LITELLM_MASTER_KEY` and the provider keys for `litellm` — see
211
+ [Components](#components-litellm-backed-bundles) above). For each secret a
212
+ selected bundle (or a component it depends on) declares that isn't
213
+ already resolvable, `install` prompts for it right after files are copied and
214
+ hooks wired:
215
+
216
+ - **Masked input.** Characters are echoed as `*`, not shown in the clear.
217
+ - **Every prompt is skippable.** Press Enter on an empty line to skip — the
218
+ CLI records nothing for a skipped secret and moves on; nothing forces you
219
+ to fill in a value you don't have yet.
220
+ - **Live-validated where feasible.** `GITLAB_TOKEN` is checked against
221
+ `GET https://gitlab.com/api/v4/user` (5s timeout). A rejected token offers
222
+ retry / skip / keep-anyway; a network error just warns and accepts the
223
+ value as entered. Every other secret is hint-only (no live check).
224
+ - **Re-run any time.** `agents-cli secrets` re-prompts for whatever's still
225
+ missing across every installed bundle (or `agents-cli secrets --bundle
226
+ <key>` for one bundle). `agents-cli secrets --list` shows which secret
227
+ *names* are set vs. missing — it never prints a value.
228
+
229
+ **Where secrets live: `<target-dir>/agents.env` (default
230
+ `~/.claude/agents.env`) — never `settings.json`, and never committed or
231
+ transmitted anywhere. They never leave this machine.** The file gets
232
+ user-only permissions right after every write (`icacls ... /grant:r
233
+ "%USERNAME%":F` on Windows, `chmod 600` on POSIX) — a permissions failure is
234
+ reported as a warning, never silently swallowed and never fatal to the write
235
+ itself.
236
+
237
+ **How hooks read them back.** A hook that needs a secret calls
238
+ `get_secret(name)` from `proxy/agents_env.py` (a small stdlib-only module
239
+ shipped alongside any bundle whose hooks need it). The Node CLI has the same
240
+ contract in `packages/cli/lib/agentsEnv.js`. Both resolve, in order: (1) a
241
+ real environment variable of that name, (2) `<base>/agents.env`, where `base`
242
+ is the `AGENTS_ENV_DIR` environment variable if set, else `~/.claude`. A real
243
+ environment variable always wins, so exporting a secret in your shell (or CI)
244
+ works with no `agents.env` file at all.
245
+
246
+ ## Updating
247
+
248
+ ```bash
249
+ agents-cli update --yes # every bundle recorded in the ledger
250
+ agents-cli update --bundle <key> --yes # one bundle
251
+ ```
252
+
253
+ Once this package is published, the real npx flow (nothing to install first)
254
+ is:
255
+
256
+ ```bash
257
+ npx @yasaswy.nagavolu/agents@latest update
258
+ ```
259
+
260
+ Every installed file is compared three ways — its hash in the shipped
261
+ source, its hash in `<target-dir>/agents-ledger.json` (what was last
262
+ installed), and its actual on-disk hash:
263
+
264
+ - **Untouched, source changed** — silently overwritten; the ledger hash is
265
+ updated. This is the common case and produces no prompt.
266
+ - **Edited by you, source unchanged** — left alone; noted in the summary.
267
+ - **Missing on disk** (e.g. a file added to the bundle since you installed)
268
+ — reinstalled.
269
+ - **Edited by you AND changed upstream** — a genuine conflict. In a
270
+ terminal you get a unified diff (capped at ~200 lines) and a per-file
271
+ `keep / overwrite / backup` prompt (`backup` writes
272
+ `<file>.bak-<cliVersion>` next to it, then overwrites). Piped/non-TTY
273
+ input with neither `--theirs` nor `--keep-mine` resolves nothing for
274
+ conflicts — they're listed, the command exits **2**, and every other
275
+ (non-conflicting) change in the run still applies. Plain `--yes` does
276
+ **not** by itself resolve a conflict.
277
+ - `--theirs` — non-interactively take the new source for every conflict.
278
+ - `--keep-mine` — non-interactively keep your on-disk version for every
279
+ conflict (its ledger hash is deliberately left as-is, so the same
280
+ conflict is reported again on the next `update` until you reconcile it
281
+ — `update` never silently treats a kept edit as the new baseline).
282
+ - **No longer shipped by the bundle** — removed if untouched since install,
283
+ or kept in place with a warning (and dropped from the ledger, untracked)
284
+ if you'd edited it.
285
+
286
+ Hook and MCP wiring are refreshed on every `update` to match the current
287
+ manifest: a wiring entry the manifest still declares is left as-is (or
288
+ re-wired if missing); one the manifest no longer declares is unwired the
289
+ same way `uninstall` would, and dropped from the ledger.
290
+
291
+ - `--target-dir <path>` / `--target-config <path>` work the same as for
292
+ `install`/`uninstall`.
293
+ - `--json` prints a machine-readable summary (`{ targetBase, bundles, unresolvedConflicts, exitCode }`) instead of prose.
294
+
295
+ ## Uninstall
296
+
297
+ ```bash
298
+ agents-cli uninstall --bundle <key> --yes
299
+ ```
300
+
301
+ Removes everything `install` put down for that bundle:
302
+
303
+ - Every installed file **whose on-disk hash still matches the ledger** is
304
+ deleted (and now-empty parent directories are cleaned up). A file you
305
+ edited since install is **left in place** with a warning — uninstall never
306
+ discards your changes — but its ledger entry is still dropped, since the
307
+ bundle is no longer tracked.
308
+ - Exactly the settings.json hook entries this bundle wired (tracked
309
+ per-bundle on the ledger) are removed — nothing belonging to any other
310
+ bundle is touched. Now-empty hook blocks/events are pruned.
311
+ - Exactly the MCP config entries this bundle wired (tracked per-bundle on the
312
+ ledger) are removed the same way — see [MCP servers](#mcp-servers).
313
+ - An unknown `--bundle` key fails with an error listing every bundle key the
314
+ manifest declares. A valid bundle key that was never installed at the
315
+ target is a no-op (prints a message, exits 0) rather than an error.
316
+ - `--target-dir <path>` / `--target-config <path>` work the same as for
317
+ `install`.
318
+
319
+ ## Development
320
+
321
+ ```bash
322
+ cd packages/cli
323
+ npm test
324
+ ```
325
+
326
+ Tests run against scratch directories (via `--target-dir`) — they never
327
+ touch a real `~/.claude`. Raw-mode TTY interaction (`tty-menu.js`) is
328
+ deliberately not exercised in automated tests — its selection logic is
329
+ factored into `lib/menu.js` (pure functions, tested directly); only the
330
+ keypress/redraw plumbing is untested here.
331
+
332
+ The manifest orphan-lint (`tools/manifest_lint.py`) has its own pytest suite:
333
+
334
+ ```bash
335
+ python -m pytest tools/tests/test_manifest_lint.py -q
336
+ ```
337
+
338
+ `proxy/agents_env.py` (the Python half of the secrets-resolution contract,
339
+ consumed by hooks) has its own pytest suite, isolated from any real ambient
340
+ secret via a nonce env-var name and `monkeypatch`/`tmp_path`:
341
+
342
+ ```bash
343
+ python -m pytest proxy/tests/test_agents_env.py -q
344
+ ```
345
+
346
+ ## Source
347
+
348
+ [gitlab.com/yasaswy22/my-agents](https://gitlab.com/yasaswy22/my-agents)
349
+ (private repo; package published publicly to npm).