@yasaswy.nagavolu/agents 0.8.2 → 0.9.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 +79 -5
- package/bin/cli.js +96 -19
- package/content/proxy/managed_files_guard.py +1 -1
- package/lib/ansi.js +105 -0
- package/lib/install.js +42 -1
- package/lib/menu.js +105 -1
- package/lib/tty-menu.js +106 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,6 +19,13 @@ any repo file is left unclaimed by a bundle or `internal[]`.
|
|
|
19
19
|
npx @yasaswy.nagavolu/agents install
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
In PowerShell, quote the package name (`@` collides with the splatting
|
|
23
|
+
operator — harmless elsewhere, required here):
|
|
24
|
+
|
|
25
|
+
```powershell
|
|
26
|
+
npx '@yasaswy.nagavolu/agents' install
|
|
27
|
+
```
|
|
28
|
+
|
|
22
29
|
or install the CLI globally:
|
|
23
30
|
|
|
24
31
|
```bash
|
|
@@ -30,11 +37,18 @@ agents-cli install
|
|
|
30
37
|
|
|
31
38
|
- `agents-cli --version` — print the installed CLI version
|
|
32
39
|
- `agents-cli install` — in a terminal (TTY), opens the interactive bundle
|
|
33
|
-
menu:
|
|
34
|
-
`q`/`Ctrl-C` cancels.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
menu: `↑`/`↓`/`j`/`k` move, `PgUp`/`PgDn` jump 5 rows, `space` toggles, `a`
|
|
41
|
+
selects all, `enter` confirms, `q`/`Ctrl-C` cancels. A live detail pane
|
|
42
|
+
below the list always shows what the highlighted bundle installs — item
|
|
43
|
+
counts by kind, real destination paths, MCP servers it registers,
|
|
44
|
+
component deps, secrets it will prompt for, and an approximate file
|
|
45
|
+
count/size. If raw-mode keypress handling isn't available, it falls back
|
|
46
|
+
to a numbered prompt (`1,3,5` / `a` / blank to quit) — same underlying
|
|
47
|
+
selection logic either way. Piped/non-interactive (CI) input instead
|
|
48
|
+
prints the bundle list and instructs `--bundle` usage; exits 0. Colors and
|
|
49
|
+
the fancy layout are on for a real TTY and off (plain text) when
|
|
50
|
+
`NO_COLOR` is set — see [The interactive menu](#the-interactive-menu)
|
|
51
|
+
below for what it looks like.
|
|
38
52
|
- `agents-cli install --advanced` — interactive menu over **every** bundle
|
|
39
53
|
(not just the public/non-advanced basic set), and for each bundle you pick,
|
|
40
54
|
a second checkbox lets you deselect individual items within it (including
|
|
@@ -61,6 +75,59 @@ agents-cli install
|
|
|
61
75
|
[Updating](#updating) below.
|
|
62
76
|
- `agents-cli --help` — show usage
|
|
63
77
|
|
|
78
|
+
### The interactive menu
|
|
79
|
+
|
|
80
|
+
In a color-capable terminal, `agents-cli install` looks roughly like this
|
|
81
|
+
(`✓`/colors omitted from this plain-text README, but selected rows get a
|
|
82
|
+
green check, the cursor row is highlighted, `(needs: ...)` is yellow,
|
|
83
|
+
`(asks: ...)` is cyan, and `[passthrough]` is magenta in the real thing):
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
@yasaswy.nagavolu/agents v0.9.0
|
|
87
|
+
Select bundles to install
|
|
88
|
+
|
|
89
|
+
[ ] Session Tools — Resume past Claude Code sessions by name and archive session transcripts to markdown
|
|
90
|
+
[ ] Shipping — Ship code changes end-to-end: sync, test, commit, push, and file the GitLab issue update in one skill (asks: GITLAB_TOKEN)
|
|
91
|
+
❯ [✓] Reddit Reader — Read Reddit posts/threads into Claude Code from a URL, with a deterministic prompt-intent nudge (asks: REDDIT_CLIENT_ID, REDDIT_CLIENT_SECRET, REDDIT_USER_AGENT)
|
|
92
|
+
[ ] Skill Authoring — code-is-law: turn skill/agent-file prose rules into an enforced PostToolUse lint
|
|
93
|
+
|
|
94
|
+
────────────────────────────────────────────────────────────────
|
|
95
|
+
Reddit Reader — selected
|
|
96
|
+
1 skill, 2 hooks (8 files, 201.5 KB)
|
|
97
|
+
→ ~/.claude/skills/read-reddit-post
|
|
98
|
+
→ ~/.claude/proxy/reddit_intent_hook.py
|
|
99
|
+
Asks: REDDIT_CLIENT_ID (optional), REDDIT_CLIENT_SECRET (optional), REDDIT_USER_AGENT (optional)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
────────────────────────────────────────────────────────────────
|
|
103
|
+
↑/↓/j/k move PgUp/PgDn jump space toggle a all enter confirm q quit
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Once you confirm a selection, each bundle installs with a determinate
|
|
107
|
+
progress bar (file counts are known up front from the manifest), then a
|
|
108
|
+
one-line summary:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
Installing Visual Review ━━━━━━━━━━━━━━━━╸─────── 42/61 files
|
|
112
|
+
✓ visual-review — 61 file(s) written, 0 unchanged, 1.2 MB, installed to C:/Users/you/.claude
|
|
113
|
+
✓ wired 3 hook(s) into C:/Users/you/.claude/settings.json
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
After every requested bundle finishes, a final summary recaps what landed
|
|
117
|
+
where and what's next:
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
Summary
|
|
121
|
+
✓ Reddit Reader — 8 file(s), 201.5 KB, 1 hook(s) wired
|
|
122
|
+
|
|
123
|
+
Installed to C:/Users/you/.claude. Next: agents-cli secrets to fill in any skipped secrets, agents-cli update --yes to refresh later.
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`NO_COLOR=1` (or a non-TTY stdout) strips all color from every line above
|
|
127
|
+
but keeps the same layout and information; a terminal that can't do raw-mode
|
|
128
|
+
keypress handling at all falls back further, to the plain numbered prompt
|
|
129
|
+
described above.
|
|
130
|
+
|
|
64
131
|
### Bundle dispositions in the menu
|
|
65
132
|
|
|
66
133
|
- **installable** — installs immediately, whether or not the bundle declares
|
|
@@ -257,6 +324,13 @@ is:
|
|
|
257
324
|
npx @yasaswy.nagavolu/agents@latest update
|
|
258
325
|
```
|
|
259
326
|
|
|
327
|
+
In PowerShell, quote the package name (`@` collides with the splatting
|
|
328
|
+
operator — harmless elsewhere, required here):
|
|
329
|
+
|
|
330
|
+
```powershell
|
|
331
|
+
npx '@yasaswy.nagavolu/agents@latest' update
|
|
332
|
+
```
|
|
333
|
+
|
|
260
334
|
Every installed file is compared three ways — its hash in the shipped
|
|
261
335
|
source, its hash in `<target-dir>/agents-ledger.json` (what was last
|
|
262
336
|
installed), and its actual on-disk hash:
|
package/bin/cli.js
CHANGED
|
@@ -20,12 +20,27 @@ const {
|
|
|
20
20
|
describeBundleRow,
|
|
21
21
|
describeBundleItems,
|
|
22
22
|
planSelection,
|
|
23
|
+
deriveBundleDetails,
|
|
23
24
|
} = require('../lib/menu');
|
|
24
25
|
const { pickBundles } = require('../lib/tty-menu');
|
|
26
|
+
const { supportsColor, createStyler, renderBar, formatBytes } = require('../lib/ansi');
|
|
25
27
|
const { collectBundleSecrets, collectComponentSecrets, isResolved, promptForMissingSecrets } = require('../lib/secretsPrompt');
|
|
26
28
|
const { runSelfProfilePostInstall } = require('../lib/selfProfile');
|
|
27
29
|
|
|
28
30
|
const PACKAGE_ROOT = path.join(__dirname, '..');
|
|
31
|
+
// One styler for the whole process: colors on only for a real TTY stdout
|
|
32
|
+
// with no NO_COLOR set (see lib/ansi.js). Every console.log below that
|
|
33
|
+
// wants color routes through this — it's a plain passthrough (no codes)
|
|
34
|
+
// otherwise, so nothing needs its own TTY check.
|
|
35
|
+
const ansi = createStyler(supportsColor());
|
|
36
|
+
|
|
37
|
+
/** A short pip-style status marker: colored ✓/… when ansi is enabled, plain-ASCII when not (NO_COLOR/non-TTY). */
|
|
38
|
+
function mark(kind) {
|
|
39
|
+
if (kind === 'ok') return ansi.enabled ? ansi.green('✓') : 'OK:';
|
|
40
|
+
if (kind === 'skip') return ansi.enabled ? ansi.yellow('•') : '-';
|
|
41
|
+
if (kind === 'fail') return ansi.enabled ? ansi.red('✗') : 'FAILED:';
|
|
42
|
+
return ansi.enabled ? ansi.dim('·') : '-';
|
|
43
|
+
}
|
|
29
44
|
|
|
30
45
|
function printHelp() {
|
|
31
46
|
console.log(`${pkg.name} v${pkg.version}
|
|
@@ -212,7 +227,30 @@ function runSelfProfileStepsIfNeeded({ profile, targetDir }) {
|
|
|
212
227
|
return result;
|
|
213
228
|
}
|
|
214
229
|
|
|
215
|
-
|
|
230
|
+
/**
|
|
231
|
+
* Builds an install.js progress callback that renders a live, in-place
|
|
232
|
+
* (\r-redrawn) pip-style bar while files are copied — but only when stdout
|
|
233
|
+
* is a real TTY. On a non-TTY stdout (piped/CI/logged) this is a no-op:
|
|
234
|
+
* install.js's per-file events simply go nowhere, and the plain one-line
|
|
235
|
+
* summary printed after installOneBundle's installBundle() call is the only
|
|
236
|
+
* output, matching pre-progress-bar behavior exactly. Colors within the bar
|
|
237
|
+
* itself further degrade under NO_COLOR (module-level `ansi`), independent
|
|
238
|
+
* of whether the bar renders at all.
|
|
239
|
+
*/
|
|
240
|
+
function createProgressRenderer(title) {
|
|
241
|
+
const showProgress = !!process.stdout.isTTY;
|
|
242
|
+
return (event) => {
|
|
243
|
+
if (!showProgress || event.type !== 'file' || event.total === 0) return;
|
|
244
|
+
const bar = renderBar(event.index, event.total, { width: 24 });
|
|
245
|
+
const done = event.index >= event.total;
|
|
246
|
+
const coloredBar = ansi.enabled ? (done ? ansi.green(bar) : ansi.cyan(bar)) : bar;
|
|
247
|
+
const line = `Installing ${ansi.bold(title)} ${coloredBar} ${event.index}/${event.total} files`;
|
|
248
|
+
process.stdout.write(`\r${ansi.clearLine()}${line}`);
|
|
249
|
+
if (done) process.stdout.write('\n');
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function installOneBundle({ bundleKey, bundleTitle, targetDir, targetConfig, itemPaths }) {
|
|
216
254
|
const result = installBundle({
|
|
217
255
|
packageRoot: PACKAGE_ROOT,
|
|
218
256
|
bundleKey,
|
|
@@ -220,53 +258,56 @@ function installOneBundle({ bundleKey, targetDir, targetConfig, itemPaths }) {
|
|
|
220
258
|
cliVersion: pkg.version,
|
|
221
259
|
itemPaths,
|
|
222
260
|
mcpConfigPath: targetConfig,
|
|
261
|
+
progress: createProgressRenderer(bundleTitle || bundleKey),
|
|
223
262
|
});
|
|
263
|
+
const sizeSuffix = result.bytesWritten ? `, ${formatBytes(result.bytesWritten)}` : '';
|
|
224
264
|
if (result.unchanged) {
|
|
225
|
-
console.log(
|
|
265
|
+
console.log(`${mark('skip')} "${result.bundle}" already up to date at ${result.targetBase} (no changes).`);
|
|
226
266
|
} else {
|
|
227
267
|
console.log(
|
|
228
|
-
|
|
229
|
-
`${result.
|
|
268
|
+
`${mark('ok')} ${ansi.bold(result.bundle)} — ${result.filesWritten} file(s) written, ` +
|
|
269
|
+
`${result.filesUnchanged} unchanged${sizeSuffix}, installed to ${result.targetBase}`
|
|
230
270
|
);
|
|
231
271
|
}
|
|
232
272
|
if (result.hooksWired.length > 0) {
|
|
233
|
-
console.log(`
|
|
273
|
+
console.log(` ${mark('ok')} wired ${result.hooksWired.length} hook(s) into ${result.targetBase}/settings.json`);
|
|
234
274
|
}
|
|
235
275
|
if (result.settingsBackupFile) {
|
|
236
|
-
console.log(`
|
|
276
|
+
console.log(` ${mark()} backed up existing settings.json to ${result.settingsBackupFile} before this CLI's first write`);
|
|
237
277
|
}
|
|
238
278
|
if (result.hooksSkippedNoPython.length > 0) {
|
|
239
279
|
const names = result.hooksSkippedNoPython.map((h) => h.path).join(', ');
|
|
240
280
|
console.log(
|
|
241
|
-
`
|
|
281
|
+
` ${mark('skip')} skipped wiring ${result.hooksSkippedNoPython.length} Python hook(s) (${names}): no python3/python found on PATH. ` +
|
|
242
282
|
`Install Python, then re-run: agents-cli install --bundle ${result.bundle} --yes`
|
|
243
283
|
);
|
|
244
284
|
}
|
|
245
285
|
if (result.mcpWired.length > 0) {
|
|
246
286
|
const names = result.mcpWired.map((m) => m.name).join(', ');
|
|
247
|
-
console.log(`
|
|
287
|
+
console.log(` ${mark('ok')} wired ${result.mcpWired.length} MCP server(s) (${names}) into ${result.mcpConfigPath}`);
|
|
248
288
|
}
|
|
249
289
|
if (result.mcpBackupFile) {
|
|
250
|
-
console.log(`
|
|
290
|
+
console.log(` ${mark()} backed up existing MCP config to ${result.mcpBackupFile} before this CLI's first write`);
|
|
251
291
|
}
|
|
252
292
|
if (result.mcpSkippedNoSecret.length > 0) {
|
|
253
293
|
const names = result.mcpSkippedNoSecret.map((m) => m.name).join(', ');
|
|
254
|
-
console.log(`
|
|
294
|
+
console.log(` ${mark('skip')} skipped wiring ${result.mcpSkippedNoSecret.length} MCP server(s) (${names}): required secret not set`);
|
|
255
295
|
}
|
|
256
296
|
for (const component of result.components || []) {
|
|
257
297
|
if (component.status === 'present') {
|
|
258
|
-
console.log(`
|
|
298
|
+
console.log(` ${mark('ok')} component "${component.key}": already on PATH`);
|
|
259
299
|
} else if (component.status === 'installed') {
|
|
260
|
-
console.log(`
|
|
300
|
+
console.log(` ${mark('ok')} component "${component.key}": installed via ${component.tool}`);
|
|
261
301
|
} else if (component.status === 'failed') {
|
|
262
|
-
console.log(`
|
|
302
|
+
console.log(` ${mark('fail')} component "${component.key}": ${component.message}`);
|
|
263
303
|
} else if (component.status === 'pending') {
|
|
264
|
-
console.log(`
|
|
304
|
+
console.log(` ${mark('skip')} component "${component.key}": ${component.message}`);
|
|
265
305
|
}
|
|
266
306
|
if (component.filesWritten && component.filesWritten.length > 0) {
|
|
267
|
-
console.log(`
|
|
307
|
+
console.log(` ${mark('ok')} component "${component.key}": wrote ${component.filesWritten.join(', ')} to ${result.targetBase}`);
|
|
268
308
|
}
|
|
269
309
|
}
|
|
310
|
+
return result;
|
|
270
311
|
}
|
|
271
312
|
|
|
272
313
|
/**
|
|
@@ -275,8 +316,30 @@ function installOneBundle({ bundleKey, targetDir, targetConfig, itemPaths }) {
|
|
|
275
316
|
* the only piece of the menu flow that isn't unit-testable without a TTY —
|
|
276
317
|
* everything it calls (planSelection, installBundle) is.
|
|
277
318
|
*/
|
|
319
|
+
/** "what landed where, what was skipped, next steps" — printed once after every
|
|
320
|
+
* requested bundle has been installed (or skipped/failed). */
|
|
321
|
+
function printFinalSummary({ installed, skipped, targetBase }) {
|
|
322
|
+
if (installed.length === 0 && skipped.length === 0) return;
|
|
323
|
+
console.log(`\n${ansi.bold('Summary')}`);
|
|
324
|
+
for (const { bundle, result } of installed) {
|
|
325
|
+
const totalFiles = result.filesWritten + result.filesUnchanged;
|
|
326
|
+
const sizeSuffix = result.bytesWritten ? `, ${formatBytes(result.bytesWritten)}` : '';
|
|
327
|
+
const hooksSuffix = result.hooksWired.length > 0 ? `, ${result.hooksWired.length} hook(s) wired` : '';
|
|
328
|
+
const mcpSuffix = result.mcpWired.length > 0 ? `, ${result.mcpWired.length} MCP server(s) wired` : '';
|
|
329
|
+
console.log(` ${mark('ok')} ${ansi.bold(bundle.title)} — ${totalFiles} file(s)${sizeSuffix}${hooksSuffix}${mcpSuffix}`);
|
|
330
|
+
}
|
|
331
|
+
for (const label of skipped) {
|
|
332
|
+
console.log(` ${mark('skip')} ${label}`);
|
|
333
|
+
}
|
|
334
|
+
console.log(
|
|
335
|
+
`\nInstalled to ${ansi.bold(targetBase)}. Next: ${ansi.dim('agents-cli secrets')} to fill in any skipped ` +
|
|
336
|
+
`secrets, ${ansi.dim('agents-cli update --yes')} to refresh later.`
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
|
|
278
340
|
async function runInteractiveMenu({ advanced, targetDir, targetConfig, noSecrets, profile }) {
|
|
279
|
-
const { manifest } = loadManifest(PACKAGE_ROOT);
|
|
341
|
+
const { manifest, manifestPath } = loadManifest(PACKAGE_ROOT);
|
|
342
|
+
const repoRoot = path.dirname(manifestPath);
|
|
280
343
|
const candidateBundles = advanced ? advancedMenuBundles(manifest, profile) : basicMenuBundles(manifest, profile);
|
|
281
344
|
if (!candidateBundles.length) {
|
|
282
345
|
console.log('No bundles are defined yet.');
|
|
@@ -284,7 +347,9 @@ async function runInteractiveMenu({ advanced, targetDir, targetConfig, noSecrets
|
|
|
284
347
|
}
|
|
285
348
|
|
|
286
349
|
const rows = candidateBundles.map(describeBundleRow);
|
|
287
|
-
const
|
|
350
|
+
const details = new Map(candidateBundles.map((b) => [b.key, deriveBundleDetails(b, manifest, { repoRoot })]));
|
|
351
|
+
const header = `${pkg.name} v${pkg.version}`;
|
|
352
|
+
const selectedKeys = await pickBundles(rows, { details, header });
|
|
288
353
|
if (selectedKeys === null) {
|
|
289
354
|
console.log('Cancelled — nothing installed.');
|
|
290
355
|
return 0;
|
|
@@ -304,6 +369,8 @@ async function runInteractiveMenu({ advanced, targetDir, targetConfig, noSecrets
|
|
|
304
369
|
}
|
|
305
370
|
|
|
306
371
|
const installedBundles = [];
|
|
372
|
+
const installedResults = [];
|
|
373
|
+
const skipped = [];
|
|
307
374
|
for (const bundle of plan.toInstall) {
|
|
308
375
|
let itemPaths;
|
|
309
376
|
if (advanced) {
|
|
@@ -318,16 +385,19 @@ async function runInteractiveMenu({ advanced, targetDir, targetConfig, noSecrets
|
|
|
318
385
|
const selectedItemPaths = await pickBundles(itemRows);
|
|
319
386
|
if (selectedItemPaths === null || selectedItemPaths.length === 0) {
|
|
320
387
|
console.log(`Skipping "${bundle.title}" — no items selected.`);
|
|
388
|
+
skipped.push(`${bundle.title} — no items selected`);
|
|
321
389
|
continue;
|
|
322
390
|
}
|
|
323
391
|
itemPaths = selectedItemPaths;
|
|
324
392
|
}
|
|
325
393
|
try {
|
|
326
|
-
installOneBundle({ bundleKey: bundle.key, targetDir, targetConfig, itemPaths });
|
|
394
|
+
const result = installOneBundle({ bundleKey: bundle.key, bundleTitle: bundle.title, targetDir, targetConfig, itemPaths });
|
|
327
395
|
installedBundles.push(bundle);
|
|
396
|
+
installedResults.push({ bundle, result });
|
|
328
397
|
} catch (err) {
|
|
329
398
|
if (err instanceof InstallError || err instanceof ManifestError || err instanceof LedgerError || err instanceof WiringError) {
|
|
330
399
|
console.error(err.message);
|
|
400
|
+
skipped.push(`${bundle.title} — failed: ${err.message}`);
|
|
331
401
|
} else {
|
|
332
402
|
throw err;
|
|
333
403
|
}
|
|
@@ -345,6 +415,8 @@ async function runInteractiveMenu({ advanced, targetDir, targetConfig, noSecrets
|
|
|
345
415
|
runSelfProfileStepsIfNeeded({ profile, targetDir });
|
|
346
416
|
}
|
|
347
417
|
|
|
418
|
+
printFinalSummary({ installed: installedResults, skipped, targetBase: targetDir || defaultTargetBase() });
|
|
419
|
+
|
|
348
420
|
return 0;
|
|
349
421
|
}
|
|
350
422
|
|
|
@@ -377,9 +449,14 @@ async function runInstall(argv) {
|
|
|
377
449
|
}
|
|
378
450
|
|
|
379
451
|
try {
|
|
380
|
-
installOneBundle({ bundleKey: args.bundle, targetDir: args.targetDir, targetConfig: args.targetConfig });
|
|
381
452
|
const { manifest } = loadManifest(PACKAGE_ROOT);
|
|
382
453
|
const bundle = findBundle(manifest, args.bundle);
|
|
454
|
+
installOneBundle({
|
|
455
|
+
bundleKey: args.bundle,
|
|
456
|
+
bundleTitle: bundle ? bundle.title : args.bundle,
|
|
457
|
+
targetDir: args.targetDir,
|
|
458
|
+
targetConfig: args.targetConfig,
|
|
459
|
+
});
|
|
383
460
|
await promptForMissingSecrets({
|
|
384
461
|
bundles: bundle ? [bundle] : [],
|
|
385
462
|
targetBase: args.targetDir || defaultTargetBase(),
|
|
@@ -108,7 +108,7 @@ def check(edited_path: str, target_base: Path) -> str | None:
|
|
|
108
108
|
|
|
109
109
|
return (
|
|
110
110
|
f'managed by @yasaswy.nagavolu/agents (bundle "{bundle}") — edit {source_display} '
|
|
111
|
-
f"and run: npx @yasaswy.nagavolu/agents update"
|
|
111
|
+
f"and run: npx '@yasaswy.nagavolu/agents' update"
|
|
112
112
|
)
|
|
113
113
|
|
|
114
114
|
|
package/lib/ansi.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Tiny zero-dependency ANSI helper: color/style wrapping, a determinate
|
|
5
|
+
* progress-bar renderer, and byte formatting. No npm packages — the CLI's
|
|
6
|
+
* zero-runtime-dependency constraint is non-negotiable.
|
|
7
|
+
*
|
|
8
|
+
* Nesting-safe: each style wrapper re-asserts its own open code after any
|
|
9
|
+
* embedded reset it finds in the text, so `bold(dim(x))`-style composition
|
|
10
|
+
* doesn't have the inner reset silently cancel the outer style early.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const CODES = {
|
|
14
|
+
reset: '\x1b[0m',
|
|
15
|
+
bold: '\x1b[1m',
|
|
16
|
+
dim: '\x1b[2m',
|
|
17
|
+
italic: '\x1b[3m',
|
|
18
|
+
inverse: '\x1b[7m',
|
|
19
|
+
black: '\x1b[30m',
|
|
20
|
+
red: '\x1b[31m',
|
|
21
|
+
green: '\x1b[32m',
|
|
22
|
+
yellow: '\x1b[33m',
|
|
23
|
+
blue: '\x1b[34m',
|
|
24
|
+
magenta: '\x1b[35m',
|
|
25
|
+
cyan: '\x1b[36m',
|
|
26
|
+
white: '\x1b[37m',
|
|
27
|
+
gray: '\x1b[90m',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const STYLE_NAMES = Object.keys(CODES).filter((name) => name !== 'reset');
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Colors are on only when stdout is a real TTY and NO_COLOR isn't set (any
|
|
34
|
+
* value, including empty string, per the NO_COLOR spec at no-color.org).
|
|
35
|
+
*/
|
|
36
|
+
function supportsColor({ stream = process.stdout, env = process.env } = {}) {
|
|
37
|
+
if (env && Object.prototype.hasOwnProperty.call(env, 'NO_COLOR')) return false;
|
|
38
|
+
return !!(stream && stream.isTTY);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function createStyler(enabled) {
|
|
42
|
+
const styler = { enabled: !!enabled };
|
|
43
|
+
for (const name of STYLE_NAMES) {
|
|
44
|
+
styler[name] = (text) => {
|
|
45
|
+
const str = text === undefined || text === null ? '' : String(text);
|
|
46
|
+
if (!styler.enabled || str === '') return str;
|
|
47
|
+
const open = CODES[name];
|
|
48
|
+
const close = CODES.reset;
|
|
49
|
+
// Re-open after any embedded reset so nested styles don't clip early.
|
|
50
|
+
return open + str.split(close).join(close + open) + close;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
styler.clearScreen = () => (styler.enabled ? '\x1Bc' : '');
|
|
54
|
+
styler.hideCursor = () => (styler.enabled ? '\x1b[?25l' : '');
|
|
55
|
+
styler.showCursor = () => (styler.enabled ? '\x1b[?25h' : '');
|
|
56
|
+
// Clear from cursor to end of line, then return to column 0 — used for
|
|
57
|
+
// in-place progress-bar redraws (\r + this) so a shorter next frame
|
|
58
|
+
// doesn't leave stray characters from a longer previous frame.
|
|
59
|
+
styler.clearLine = () => (styler.enabled ? '\x1b[K' : '');
|
|
60
|
+
return styler;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function clamp(n, lo, hi) {
|
|
64
|
+
return Math.max(lo, Math.min(hi, n));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Render a pip-style determinate bar: full cells '━', one partial cap '╸' at
|
|
69
|
+
* the boundary, remaining cells '─'. current/total can be any non-negative
|
|
70
|
+
* numbers; total<=0 or current>=total renders a full bar (nothing left to
|
|
71
|
+
* show as pending), current<=0 renders empty.
|
|
72
|
+
*/
|
|
73
|
+
function renderBar(current, total, { width = 24 } = {}) {
|
|
74
|
+
const safeWidth = Math.max(1, Math.floor(width));
|
|
75
|
+
const safeTotal = Math.max(0, total || 0);
|
|
76
|
+
const safeCurrent = Math.max(0, current || 0);
|
|
77
|
+
const ratio = safeTotal === 0 ? 1 : clamp(safeCurrent / safeTotal, 0, 1);
|
|
78
|
+
const filledCells = Math.round(ratio * safeWidth);
|
|
79
|
+
if (filledCells <= 0) return '─'.repeat(safeWidth);
|
|
80
|
+
if (filledCells >= safeWidth) return '━'.repeat(safeWidth);
|
|
81
|
+
return '━'.repeat(filledCells - 1) + '╸' + '─'.repeat(safeWidth - filledCells);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function formatBytes(bytes) {
|
|
85
|
+
const value = Math.max(0, bytes || 0);
|
|
86
|
+
if (value === 0) return '0 B';
|
|
87
|
+
const units = ['B', 'KB', 'MB', 'GB'];
|
|
88
|
+
let n = value;
|
|
89
|
+
let unitIndex = 0;
|
|
90
|
+
while (n >= 1024 && unitIndex < units.length - 1) {
|
|
91
|
+
n /= 1024;
|
|
92
|
+
unitIndex += 1;
|
|
93
|
+
}
|
|
94
|
+
const precision = unitIndex === 0 ? 0 : 1;
|
|
95
|
+
return `${n.toFixed(precision)} ${units[unitIndex]}`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
module.exports = {
|
|
99
|
+
CODES,
|
|
100
|
+
supportsColor,
|
|
101
|
+
createStyler,
|
|
102
|
+
renderBar,
|
|
103
|
+
formatBytes,
|
|
104
|
+
clamp,
|
|
105
|
+
};
|
package/lib/install.js
CHANGED
|
@@ -36,6 +36,15 @@ function defaultTargetBase() {
|
|
|
36
36
|
* `componentRunner` (optional, test seam): overrides components.js's
|
|
37
37
|
* spawnSync-based detection/install runner for any component this bundle
|
|
38
38
|
* declares in `deps` (e.g. litellm) — see components.js's defaultRunner doc.
|
|
39
|
+
*
|
|
40
|
+
* `progress` (optional): a `(event) => void` callback fired as files are
|
|
41
|
+
* copied — `{type:'begin', bundle, totalFiles}` once, then one
|
|
42
|
+
* `{type:'file', bundle, file, index, total, written}` per file (both newly
|
|
43
|
+
* written and already-unchanged files count, so a determinate progress bar
|
|
44
|
+
* can track every file the bundle will touch), then one
|
|
45
|
+
* `{type:'done', bundle, ...<the return value below>}`. This function stays
|
|
46
|
+
* UI-free — no color/TTY decisions here; the caller (bin/cli.js) decides
|
|
47
|
+
* what a fancy vs. plain progress callback looks like and injects it.
|
|
39
48
|
*/
|
|
40
49
|
function installBundle({
|
|
41
50
|
packageRoot,
|
|
@@ -47,7 +56,9 @@ function installBundle({
|
|
|
47
56
|
pythonChecker,
|
|
48
57
|
mcpConfigPath,
|
|
49
58
|
componentRunner,
|
|
59
|
+
progress,
|
|
50
60
|
}) {
|
|
61
|
+
const emit = typeof progress === 'function' ? progress : () => {};
|
|
51
62
|
const { manifest, manifestPath } = loadManifest(packageRoot);
|
|
52
63
|
const repoRoot = path.dirname(manifestPath);
|
|
53
64
|
|
|
@@ -71,8 +82,28 @@ function installBundle({
|
|
|
71
82
|
const ledger = loadLedger(resolvedTargetBase, cliVersion);
|
|
72
83
|
const timestamp = now || new Date().toISOString();
|
|
73
84
|
|
|
85
|
+
// Pass 1: count every file the bundle will touch, so `begin` can report a
|
|
86
|
+
// total up front and the progress bar is determinate from the first frame.
|
|
87
|
+
let totalFiles = 0;
|
|
88
|
+
for (const item of items) {
|
|
89
|
+
if (item.kind === 'mcp') continue;
|
|
90
|
+
const srcRoot = path.join(repoRoot, ...item.path.split('/'));
|
|
91
|
+
if (!fs.existsSync(srcRoot)) continue; // pass 2 raises the real error for this
|
|
92
|
+
const excluded = new Set(item.exclude || []);
|
|
93
|
+
if (fs.statSync(srcRoot).isFile()) {
|
|
94
|
+
totalFiles += 1;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
for (const relFile of walk(srcRoot)) {
|
|
98
|
+
if (!excluded.has(relFile)) totalFiles += 1;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
emit({ type: 'begin', bundle: bundle.key, totalFiles });
|
|
102
|
+
|
|
74
103
|
let filesWritten = 0;
|
|
75
104
|
let filesUnchanged = 0;
|
|
105
|
+
let bytesWritten = 0;
|
|
106
|
+
let processedFiles = 0;
|
|
76
107
|
|
|
77
108
|
for (const item of items) {
|
|
78
109
|
// mcp-kind items carry declarative wiring data only (see manifest.schema.json
|
|
@@ -120,6 +151,8 @@ function installBundle({
|
|
|
120
151
|
|
|
121
152
|
if (existingEntry && existingEntry.sha256 === sourceHash && destHash === sourceHash) {
|
|
122
153
|
filesUnchanged += 1;
|
|
154
|
+
processedFiles += 1;
|
|
155
|
+
emit({ type: 'file', bundle: bundle.key, file: relTarget, index: processedFiles, total: totalFiles, written: false });
|
|
123
156
|
continue;
|
|
124
157
|
}
|
|
125
158
|
|
|
@@ -131,6 +164,9 @@ function installBundle({
|
|
|
131
164
|
sourcePath,
|
|
132
165
|
};
|
|
133
166
|
filesWritten += 1;
|
|
167
|
+
bytesWritten += fs.statSync(srcFile).size;
|
|
168
|
+
processedFiles += 1;
|
|
169
|
+
emit({ type: 'file', bundle: bundle.key, file: relTarget, index: processedFiles, total: totalFiles, written: true });
|
|
134
170
|
}
|
|
135
171
|
}
|
|
136
172
|
|
|
@@ -162,11 +198,12 @@ function installBundle({
|
|
|
162
198
|
ledger.cliVersion = cliVersion;
|
|
163
199
|
saveLedger(resolvedTargetBase, ledger);
|
|
164
200
|
|
|
165
|
-
|
|
201
|
+
const result = {
|
|
166
202
|
bundle: bundle.key,
|
|
167
203
|
targetBase: resolvedTargetBase,
|
|
168
204
|
filesWritten,
|
|
169
205
|
filesUnchanged,
|
|
206
|
+
bytesWritten,
|
|
170
207
|
unchanged:
|
|
171
208
|
filesWritten === 0 &&
|
|
172
209
|
wiring.wired.length === 0 &&
|
|
@@ -183,6 +220,10 @@ function installBundle({
|
|
|
183
220
|
mcpBackupFile: mcpWiring.backupFile,
|
|
184
221
|
components,
|
|
185
222
|
};
|
|
223
|
+
|
|
224
|
+
emit({ type: 'done', bundle: bundle.key, ...result });
|
|
225
|
+
|
|
226
|
+
return result;
|
|
186
227
|
}
|
|
187
228
|
|
|
188
229
|
module.exports = { installBundle, defaultTargetBase, InstallError };
|
package/lib/menu.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const { walk } = require('./fsutil');
|
|
6
|
+
|
|
3
7
|
/**
|
|
4
8
|
* Pure classification/selection logic for the bundle picker. Deliberately
|
|
5
9
|
* decoupled from any TTY/readline code so it's testable without a real
|
|
6
10
|
* terminal — the interactive renderer in tty-menu.js is the only piece that
|
|
7
|
-
* touches process.stdin/stdout directly.
|
|
11
|
+
* touches process.stdin/stdout directly. deriveBundleDetails() below does
|
|
12
|
+
* stat the filesystem (for file-count/size), but that's a data lookup, not
|
|
13
|
+
* a TTY interaction — still fully testable without a terminal.
|
|
8
14
|
*/
|
|
9
15
|
|
|
10
16
|
/**
|
|
@@ -125,6 +131,103 @@ function describeBundleItems(bundle) {
|
|
|
125
131
|
}));
|
|
126
132
|
}
|
|
127
133
|
|
|
134
|
+
/**
|
|
135
|
+
* File count + total byte size of one non-mcp item's source files, mirroring
|
|
136
|
+
* install.js's own srcIsFile/exclude handling so the numbers the detail pane
|
|
137
|
+
* shows match what an install actually copies. Missing source (shouldn't
|
|
138
|
+
* happen for a real manifest, but the detail pane must never throw over it)
|
|
139
|
+
* counts as zero.
|
|
140
|
+
*/
|
|
141
|
+
function statItemFiles(repoRoot, item) {
|
|
142
|
+
const srcRoot = path.join(repoRoot, ...item.path.split('/'));
|
|
143
|
+
if (!fs.existsSync(srcRoot)) {
|
|
144
|
+
return { fileCount: 0, totalBytes: 0 };
|
|
145
|
+
}
|
|
146
|
+
const excluded = new Set(item.exclude || []);
|
|
147
|
+
const srcIsFile = fs.statSync(srcRoot).isFile();
|
|
148
|
+
if (srcIsFile) {
|
|
149
|
+
return { fileCount: 1, totalBytes: fs.statSync(srcRoot).size };
|
|
150
|
+
}
|
|
151
|
+
let fileCount = 0;
|
|
152
|
+
let totalBytes = 0;
|
|
153
|
+
for (const relFile of walk(srcRoot)) {
|
|
154
|
+
if (excluded.has(relFile)) continue;
|
|
155
|
+
fileCount += 1;
|
|
156
|
+
totalBytes += fs.statSync(path.join(srcRoot, ...relFile.split('/'))).size;
|
|
157
|
+
}
|
|
158
|
+
return { fileCount, totalBytes };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Is a secret optional? The manifest has no explicit required/optional
|
|
163
|
+
* field — by convention (see e.g. CONTEXT7_API_KEY, REDDIT_CLIENT_ID) an
|
|
164
|
+
* optional secret says so in its validationHint. Absent that marker, a
|
|
165
|
+
* declared secret is treated as required.
|
|
166
|
+
*/
|
|
167
|
+
function isSecretOptional(secret) {
|
|
168
|
+
return /\boptional\b/i.test(secret.validationHint || '');
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Build the data a detail pane (or any richer renderer) needs to describe
|
|
173
|
+
* one bundle: item counts by kind, install destinations, MCP servers it
|
|
174
|
+
* registers, component deps, secrets it will prompt for, and an approximate
|
|
175
|
+
* file count/size computed by statting the real source tree once. Returns a
|
|
176
|
+
* plain object — no formatting/color decisions, those belong to the
|
|
177
|
+
* renderer. `repoRoot` is optional; omit it (e.g. a test with no real repo
|
|
178
|
+
* checkout) to skip the file-count/size stat and get zeros back.
|
|
179
|
+
*/
|
|
180
|
+
function deriveBundleDetails(bundle, manifest, { repoRoot } = {}) {
|
|
181
|
+
const kindCounts = {};
|
|
182
|
+
const destinations = [];
|
|
183
|
+
const mcpServers = [];
|
|
184
|
+
let fileCount = 0;
|
|
185
|
+
let totalBytes = 0;
|
|
186
|
+
let wiredHookCount = 0;
|
|
187
|
+
|
|
188
|
+
for (const item of bundle.items) {
|
|
189
|
+
kindCounts[item.kind] = (kindCounts[item.kind] || 0) + 1;
|
|
190
|
+
|
|
191
|
+
if (item.kind === 'mcp') {
|
|
192
|
+
if (item.wiring && item.wiring.name) mcpServers.push(item.wiring.name);
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const dest = item.targetPath || item.path;
|
|
197
|
+
if (!destinations.includes(dest)) destinations.push(dest);
|
|
198
|
+
|
|
199
|
+
if (item.kind === 'hook' && item.wiring) wiredHookCount += 1;
|
|
200
|
+
|
|
201
|
+
if (repoRoot) {
|
|
202
|
+
const stats = statItemFiles(repoRoot, item);
|
|
203
|
+
fileCount += stats.fileCount;
|
|
204
|
+
totalBytes += stats.totalBytes;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return {
|
|
209
|
+
key: bundle.key,
|
|
210
|
+
title: bundle.title,
|
|
211
|
+
summary: bundle.summary,
|
|
212
|
+
status: classifyBundle(bundle),
|
|
213
|
+
passthroughCommand: bundle.passthrough ? bundle.passthrough.command : null,
|
|
214
|
+
passthroughNote: bundle.passthrough ? bundle.passthrough.note || null : null,
|
|
215
|
+
kindCounts,
|
|
216
|
+
totalItems: bundle.items.length,
|
|
217
|
+
destinations,
|
|
218
|
+
mcpServers,
|
|
219
|
+
deps: bundle.deps || [],
|
|
220
|
+
secrets: (bundle.secrets || []).map((s) => ({
|
|
221
|
+
name: s.name,
|
|
222
|
+
prompt: s.prompt || null,
|
|
223
|
+
optional: isSecretOptional(s),
|
|
224
|
+
})),
|
|
225
|
+
wiredHookCount,
|
|
226
|
+
fileCount,
|
|
227
|
+
totalBytes,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
128
231
|
module.exports = {
|
|
129
232
|
classifyBundle,
|
|
130
233
|
secretsHint,
|
|
@@ -135,4 +238,5 @@ module.exports = {
|
|
|
135
238
|
describeBundleRow,
|
|
136
239
|
planSelection,
|
|
137
240
|
describeBundleItems,
|
|
241
|
+
deriveBundleDetails,
|
|
138
242
|
};
|
package/lib/tty-menu.js
CHANGED
|
@@ -1,21 +1,38 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const readline = require('node:readline');
|
|
4
|
+
const { supportsColor, createStyler, formatBytes } = require('./ansi');
|
|
5
|
+
|
|
6
|
+
// Fixed line count for the detail pane so the layout never jumps as the
|
|
7
|
+
// cursor moves between bundles with different amounts of detail to show.
|
|
8
|
+
const DETAIL_HEIGHT = 7;
|
|
9
|
+
const RULE_WIDTH = 64;
|
|
4
10
|
|
|
5
11
|
/**
|
|
6
12
|
* Interactive checkbox picker over `rows` (from menu.describeBundleRow).
|
|
7
|
-
* Renders with raw-mode keypress handling when available (up/down/
|
|
8
|
-
* a=all
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
13
|
+
* Renders with raw-mode keypress handling when available (up/down/j/k=move,
|
|
14
|
+
* PgUp/PgDn=jump, space=toggle, a=all, enter=confirm, q=quit) — colored and
|
|
15
|
+
* with a live detail pane when the terminal supports it (isTTY && no
|
|
16
|
+
* NO_COLOR); degrades to a numbered comma-list prompt (readline.question)
|
|
17
|
+
* when raw mode isn't available at all (e.g. some CI shells, piped stdin
|
|
18
|
+
* that still reports isTTY oddly, or a stdin that doesn't support
|
|
19
|
+
* setRawMode). Non-TTY behavior is untouched by this module either way —
|
|
20
|
+
* bin/cli.js never calls into here for a non-TTY install.
|
|
21
|
+
*
|
|
22
|
+
* `details` (optional): a Map or plain object keyed by row.key, holding the
|
|
23
|
+
* plain data menu.deriveBundleDetails() returns for that bundle — powers
|
|
24
|
+
* the detail pane. Rows with no matching entry (e.g. the --advanced
|
|
25
|
+
* per-item picker, which has no bundle-shaped detail data) fall back to
|
|
26
|
+
* showing just the row's own summary line.
|
|
27
|
+
* `header` (optional): a single line printed above the list, e.g. the
|
|
28
|
+
* package name + version.
|
|
12
29
|
*
|
|
13
30
|
* Resolves to an array of selected bundle keys, or null if the user quit.
|
|
14
31
|
*/
|
|
15
|
-
function pickBundles(rows, { stdin = process.stdin, stdout = process.stdout } = {}) {
|
|
32
|
+
function pickBundles(rows, { stdin = process.stdin, stdout = process.stdout, details = null, header = null } = {}) {
|
|
16
33
|
const canRawMode = !!(stdin.isTTY && typeof stdin.setRawMode === 'function');
|
|
17
34
|
if (canRawMode) {
|
|
18
|
-
return pickWithRawMode(rows, stdin, stdout);
|
|
35
|
+
return pickWithRawMode(rows, stdin, stdout, { details, header });
|
|
19
36
|
}
|
|
20
37
|
return pickWithNumberedPrompt(rows, stdin, stdout);
|
|
21
38
|
}
|
|
@@ -25,17 +42,67 @@ function statusLabel(row) {
|
|
|
25
42
|
return '';
|
|
26
43
|
}
|
|
27
44
|
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const secretsPart = row.secretsHint ? ` (asks: ${row.secretsHint})` : '';
|
|
33
|
-
const label = statusLabel(row);
|
|
34
|
-
return `${pointer} ${box} ${row.title} — ${row.summary}${depsPart}${secretsPart} ${label}`.trimEnd();
|
|
45
|
+
function detailFor(details, row) {
|
|
46
|
+
if (!details || !row) return null;
|
|
47
|
+
if (typeof details.get === 'function') return details.get(row.key) || null;
|
|
48
|
+
return details[row.key] || null;
|
|
35
49
|
}
|
|
36
50
|
|
|
37
|
-
function
|
|
51
|
+
function renderRowColored(row, ansi, { isSelected, isCursor }) {
|
|
52
|
+
const box = isSelected ? ansi.green('[✓]') : '[ ]';
|
|
53
|
+
const pointer = isCursor ? ansi.cyan('❯') : ' ';
|
|
54
|
+
const title = ansi.bold(ansi.white(row.title));
|
|
55
|
+
const summary = ansi.dim(row.summary);
|
|
56
|
+
const depsPart = row.depsHint ? ` ${ansi.yellow(`(needs: ${row.depsHint})`)}` : '';
|
|
57
|
+
const secretsPart = row.secretsHint ? ` ${ansi.cyan(`(asks: ${row.secretsHint})`)}` : '';
|
|
58
|
+
const label = row.status === 'passthrough' ? ` ${ansi.magenta(ansi.italic('[passthrough]'))}` : '';
|
|
59
|
+
const line = `${pointer} ${box} ${title} — ${summary}${depsPart}${secretsPart}${label}`;
|
|
60
|
+
return isCursor ? ansi.inverse(line) : line;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Builds exactly DETAIL_HEIGHT lines (padded/truncated) describing the
|
|
64
|
+
* highlighted row's detail data, or its plain summary if no detail data was
|
|
65
|
+
* supplied for it (e.g. the per-item advanced picker). */
|
|
66
|
+
function buildDetailLines(row, detail, ansi, { isSelected }) {
|
|
67
|
+
const lines = [];
|
|
68
|
+
if (!detail) {
|
|
69
|
+
if (row && row.summary) lines.push(ansi.dim(row.summary));
|
|
70
|
+
} else {
|
|
71
|
+
const stateLabel = isSelected ? ansi.green('selected') : ansi.dim('not selected');
|
|
72
|
+
lines.push(`${ansi.bold(detail.title)} ${ansi.dim('—')} ${stateLabel}`);
|
|
73
|
+
|
|
74
|
+
const kindParts = Object.entries(detail.kindCounts || {}).map(
|
|
75
|
+
([kind, count]) => `${count} ${kind}${count === 1 ? '' : 's'}`
|
|
76
|
+
);
|
|
77
|
+
const sizeSuffix = detail.fileCount
|
|
78
|
+
? ` (${detail.fileCount} file${detail.fileCount === 1 ? '' : 's'}, ${formatBytes(detail.totalBytes)})`
|
|
79
|
+
: '';
|
|
80
|
+
lines.push(kindParts.length ? `${kindParts.join(', ')}${sizeSuffix}` : ansi.dim('(no items)'));
|
|
81
|
+
|
|
82
|
+
for (const dest of (detail.destinations || []).slice(0, 2)) {
|
|
83
|
+
lines.push(`${ansi.dim('→')} ~/.claude/${dest}`);
|
|
84
|
+
}
|
|
85
|
+
for (const mcp of detail.mcpServers || []) {
|
|
86
|
+
lines.push(`${ansi.dim('→')} registers MCP server "${ansi.cyan(mcp)}"`);
|
|
87
|
+
}
|
|
88
|
+
if (detail.deps && detail.deps.length) {
|
|
89
|
+
lines.push(ansi.yellow(`Needs: ${detail.deps.join(', ')}`));
|
|
90
|
+
}
|
|
91
|
+
if (detail.secrets && detail.secrets.length) {
|
|
92
|
+
const names = detail.secrets.map((s) => (s.optional ? `${s.name} (optional)` : s.name)).join(', ');
|
|
93
|
+
lines.push(ansi.cyan(`Asks: ${names}`));
|
|
94
|
+
}
|
|
95
|
+
if (detail.passthroughCommand) {
|
|
96
|
+
lines.push(ansi.magenta(`Run instead: ${detail.passthroughCommand}`));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
while (lines.length < DETAIL_HEIGHT) lines.push('');
|
|
100
|
+
return lines.slice(0, DETAIL_HEIGHT);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function pickWithRawMode(rows, stdin, stdout, { details, header } = {}) {
|
|
38
104
|
return new Promise((resolve) => {
|
|
105
|
+
const ansi = createStyler(supportsColor({ stream: stdout }));
|
|
39
106
|
readline.emitKeypressEvents(stdin);
|
|
40
107
|
stdin.setRawMode(true);
|
|
41
108
|
stdin.resume();
|
|
@@ -44,17 +111,26 @@ function pickWithRawMode(rows, stdin, stdout) {
|
|
|
44
111
|
const selected = new Set();
|
|
45
112
|
|
|
46
113
|
function draw() {
|
|
47
|
-
|
|
48
|
-
|
|
114
|
+
const out = [ansi.clearScreen()];
|
|
115
|
+
if (header) out.push(ansi.bold(header));
|
|
116
|
+
out.push(ansi.dim('Select bundles to install'));
|
|
117
|
+
out.push('');
|
|
49
118
|
rows.forEach((row, i) => {
|
|
50
|
-
|
|
119
|
+
out.push(renderRowColored(row, ansi, { isSelected: selected.has(i), isCursor: cursor === i }));
|
|
51
120
|
});
|
|
121
|
+
out.push('');
|
|
122
|
+
out.push(ansi.dim('─'.repeat(RULE_WIDTH)));
|
|
123
|
+
out.push(...buildDetailLines(rows[cursor], detailFor(details, rows[cursor]), ansi, { isSelected: selected.has(cursor) }));
|
|
124
|
+
out.push(ansi.dim('─'.repeat(RULE_WIDTH)));
|
|
125
|
+
out.push(ansi.dim('↑/↓/j/k move PgUp/PgDn jump space toggle a all enter confirm q quit'));
|
|
126
|
+
stdout.write(`${out.join('\n')}\n`);
|
|
52
127
|
}
|
|
53
128
|
|
|
54
129
|
function cleanup() {
|
|
55
130
|
stdin.setRawMode(false);
|
|
56
131
|
stdin.pause();
|
|
57
132
|
stdin.removeListener('keypress', onKeypress);
|
|
133
|
+
stdout.write(ansi.showCursor());
|
|
58
134
|
}
|
|
59
135
|
|
|
60
136
|
function toggle(i) {
|
|
@@ -62,6 +138,10 @@ function pickWithRawMode(rows, stdin, stdout) {
|
|
|
62
138
|
else selected.add(i);
|
|
63
139
|
}
|
|
64
140
|
|
|
141
|
+
function moveCursor(delta) {
|
|
142
|
+
cursor = Math.min(rows.length - 1, Math.max(0, cursor + delta));
|
|
143
|
+
}
|
|
144
|
+
|
|
65
145
|
function onKeypress(str, key) {
|
|
66
146
|
if (key && key.ctrl && key.name === 'c') {
|
|
67
147
|
cleanup();
|
|
@@ -73,10 +153,14 @@ function pickWithRawMode(rows, stdin, stdout) {
|
|
|
73
153
|
resolve(null);
|
|
74
154
|
return;
|
|
75
155
|
}
|
|
76
|
-
if (key && key.name === 'up') {
|
|
156
|
+
if (key && (key.name === 'up' || key.name === 'k')) {
|
|
77
157
|
cursor = (cursor - 1 + rows.length) % rows.length;
|
|
78
|
-
} else if (key && key.name === 'down') {
|
|
158
|
+
} else if (key && (key.name === 'down' || key.name === 'j')) {
|
|
79
159
|
cursor = (cursor + 1) % rows.length;
|
|
160
|
+
} else if (key && key.name === 'pageup') {
|
|
161
|
+
moveCursor(-5);
|
|
162
|
+
} else if (key && key.name === 'pagedown') {
|
|
163
|
+
moveCursor(5);
|
|
80
164
|
} else if (key && key.name === 'space') {
|
|
81
165
|
toggle(cursor);
|
|
82
166
|
} else if (str === 'a') {
|
|
@@ -90,6 +174,7 @@ function pickWithRawMode(rows, stdin, stdout) {
|
|
|
90
174
|
}
|
|
91
175
|
|
|
92
176
|
stdin.on('keypress', onKeypress);
|
|
177
|
+
stdout.write(ansi.hideCursor());
|
|
93
178
|
draw();
|
|
94
179
|
});
|
|
95
180
|
}
|
|
@@ -129,4 +214,4 @@ function pickWithNumberedPrompt(rows, stdin, stdout) {
|
|
|
129
214
|
});
|
|
130
215
|
}
|
|
131
216
|
|
|
132
|
-
module.exports = { pickBundles };
|
|
217
|
+
module.exports = { pickBundles, buildDetailLines, DETAIL_HEIGHT };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yasaswy.nagavolu/agents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "CLI for installing the yasaswy.nagavolu agent/skill/hook bundle. `install` opens an interactive bundle menu in a TTY (or `--bundle <key> --yes` for non-interactive installs), with hash-tracked idempotent deploys, automatic hook wiring into settings.json, and masked secret prompting. `update` reconciles installed bundles against the current source (hash-tracked: silent overwrite, conflict diff+prompt, or --theirs/--keep-mine). `uninstall` removes a bundle's files and wiring. `secrets` re-runs secret prompting for already-installed bundles.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|