@yasaswy.nagavolu/agents 0.12.0 → 0.14.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/bin/cli.js CHANGED
@@ -14,7 +14,7 @@ const { loadManifest, findBundle, ManifestError } = require('../lib/manifest');
14
14
  const { loadLedger, bundleKeysInLedger, LedgerError } = require('../lib/ledger');
15
15
  const { updateBundles, UpdateError } = require('../lib/update');
16
16
  const { formatVersionBanner } = require('../lib/version-banner');
17
- const { bundleInstallState, installChip, installDetailLine } = require('../lib/install-state');
17
+ const { bundleInstallState, installChip, installDetailLine, chipIsChange } = require('../lib/install-state');
18
18
  const { ledgerPath } = require('../lib/ledger');
19
19
  const { WiringError } = require('../lib/wiring');
20
20
  const {
@@ -415,6 +415,7 @@ async function runInteractiveMenu({ advanced, targetDir, targetConfig, noSecrets
415
415
  const state = bundleInstallState(ledger, row.key);
416
416
  row.installChip = installChip(state, pkg.version);
417
417
  row.installDetail = installDetailLine(state);
418
+ row.installChipIsChange = chipIsChange(state, pkg.version);
418
419
  }
419
420
  const selectedKeys = await pickBundles(rows, { details, header, subheader });
420
421
  if (selectedKeys === null) {
@@ -2,50 +2,91 @@
2
2
 
3
3
  // Per-bundle install state for the interactive menu.
4
4
  //
5
- // The ledger records, per installed FILE, which bundle owns it and when it landed —
6
- // but no per-bundle version; `cliVersion` is a single global stamp of whichever run
7
- // last wrote the ledger. So a row must NOT claim "installed v0.10.0" for a bundle that
8
- // may have been installed under an older CLI: that would be a fabricated fact on a
9
- // screen people use to decide what to overwrite. What the ledger can honestly support
10
- // is installed-vs-new, the file count, and when it was installed.
5
+ // The ledger records, per installed FILE, which bundle owns it, when it landed, and
6
+ // (from schema 1.2.0) the CLI version that installed it. The ledger's TOP-LEVEL
7
+ // cliVersion is not usable here: it records only whichever run wrote the file last,
8
+ // which says nothing about a bundle installed under an older CLI. Entries written
9
+ // before 1.2.0 have no version at all and must read as an explicit unknown rather than
10
+ // borrowing that global value — this screen is used to decide what to overwrite, so a
11
+ // guessed version is worse than an admitted gap.
11
12
  //
12
13
  // Pure and ledger-shaped-input only, so it is testable without a TTY or a real install.
13
14
 
14
15
  /**
15
16
  * @param {object|null} ledger parsed agents-ledger.json (or null when absent)
16
17
  * @param {string} bundleKey
17
- * @returns {{installed: boolean, fileCount: number, installedAt: string|null}}
18
+ * @returns {{installed: boolean, fileCount: number, installedAt: string|null,
19
+ * version: string|null, mixed: boolean}}
20
+ * `version` is null when unknown (pre-1.2.0 entries). `mixed` is true when a bundle's
21
+ * files disagree — possible after a partial/interrupted install — in which case
22
+ * `version` holds the OLDEST, since that is what still needs updating.
18
23
  */
19
24
  function bundleInstallState(ledger, bundleKey) {
20
25
  const entries = (ledger && ledger.entries) || {};
21
26
  let fileCount = 0;
22
- let newest = null;
27
+ let newestAt = null;
28
+ const versions = new Set();
23
29
  for (const value of Object.values(entries)) {
24
30
  if (!value || value.bundle !== bundleKey) continue;
25
31
  fileCount += 1;
26
32
  const at = value.installedAt;
27
- if (at && (newest === null || at > newest)) newest = at;
33
+ if (at && (newestAt === null || at > newestAt)) newestAt = at;
34
+ versions.add(value.cliVersion || null);
28
35
  }
29
- return { installed: fileCount > 0, fileCount, installedAt: newest };
36
+ if (fileCount === 0) {
37
+ return { installed: false, fileCount: 0, installedAt: null, version: null, mixed: false };
38
+ }
39
+ const known = [...versions].filter(Boolean).sort(compareSemver);
40
+ const hasUnknown = versions.has(null);
41
+ return {
42
+ installed: true,
43
+ fileCount,
44
+ installedAt: newestAt,
45
+ // Any unknown entry makes the whole bundle unknown: reporting the one version we
46
+ // happen to know would overstate what we actually know about the bundle.
47
+ version: hasUnknown ? null : known[0] || null,
48
+ mixed: known.length > 1 || (hasUnknown && known.length > 0),
49
+ };
50
+ }
51
+
52
+ function compareSemver(a, b) {
53
+ const pa = String(a).split('.').map(Number);
54
+ const pb = String(b).split('.').map(Number);
55
+ for (let i = 0; i < 3; i += 1) {
56
+ if ((pa[i] || 0) !== (pb[i] || 0)) return (pa[i] || 0) - (pb[i] || 0);
57
+ }
58
+ return 0;
30
59
  }
31
60
 
32
61
  /**
33
- * Short right-hand chip for a bundle row.
62
+ * Right-hand chip for a bundle row. Four states:
63
+ * not installed -> "new -> v0.12.0"
64
+ * installed, unknown -> "v? -> v0.12.0" (pre-1.2.0 entry; self-heals on update)
65
+ * installed, current -> "v0.12.0 · current" (no arrow — see below)
66
+ * installed, older -> "v0.9.0 -> v0.12.0"
34
67
  *
35
- * `installed -> v0.11.0` reads as "you have this, and confirming replaces it with the
36
- * running version"; `new` reads as "this is not on the machine". Deliberately no
37
- * per-bundle version number — see the module note above.
68
+ * The current state deliberately drops the arrow: after any update every bundle sits at
69
+ * the same version, and a wall of identical "v0.12.0 -> v0.12.0" rows hides the one row
70
+ * that genuinely differs.
38
71
  */
39
72
  function installChip(state, runningVersion) {
40
- if (!state.installed) return 'new';
41
- return `installed -> v${runningVersion}`;
73
+ if (!state.installed) return `new -> v${runningVersion}`;
74
+ if (!state.version) return `v? -> v${runningVersion}`;
75
+ if (state.version === runningVersion) return `v${runningVersion} · current`;
76
+ return `v${state.version} -> v${runningVersion}`;
77
+ }
78
+
79
+ /** True when the chip represents a change the user is about to make. */
80
+ function chipIsChange(state, runningVersion) {
81
+ return !state.installed || state.version !== runningVersion;
42
82
  }
43
83
 
44
84
  /** "installed 2026-07-31 · 6 files" for the detail pane, or null when not installed. */
45
85
  function installDetailLine(state) {
46
86
  if (!state.installed) return null;
47
87
  const day = state.installedAt ? String(state.installedAt).slice(0, 10) : 'unknown date';
48
- return `installed ${day} · ${state.fileCount} file${state.fileCount === 1 ? '' : 's'} on disk`;
88
+ const mixed = state.mixed ? ' · mixed versions on disk' : '';
89
+ return `installed ${day} · ${state.fileCount} file${state.fileCount === 1 ? '' : 's'} on disk${mixed}`;
49
90
  }
50
91
 
51
- module.exports = { bundleInstallState, installChip, installDetailLine };
92
+ module.exports = { bundleInstallState, installChip, installDetailLine, chipIsChange };
package/lib/install.js CHANGED
@@ -155,6 +155,11 @@ function installBundle({
155
155
  const destHash = fs.existsSync(destFile) ? sha256File(destFile) : null;
156
156
 
157
157
  if (existingEntry && existingEntry.sha256 === sourceHash && destHash === sourceHash) {
158
+ // Byte-identical: nothing to copy, but the entry must still be re-stamped with
159
+ // the CLI version that just verified it. Without this, a bundle whose files
160
+ // happen not to change between releases would keep reporting an old version
161
+ // forever, and the menu's "vX -> vY" row would state something false.
162
+ existingEntry.cliVersion = cliVersion;
158
163
  filesUnchanged += 1;
159
164
  processedFiles += 1;
160
165
  emit({ type: 'file', bundle: bundle.key, file: relTarget, index: processedFiles, total: totalFiles, written: false });
@@ -166,6 +171,10 @@ function installBundle({
166
171
  sha256: sourceHash,
167
172
  bundle: bundle.key,
168
173
  installedAt: timestamp,
174
+ // Per-entry version, so the menu can show a real "installed -> available"
175
+ // delta per bundle. The ledger's top-level cliVersion only records whichever
176
+ // run wrote it LAST, which says nothing about a bundle installed earlier.
177
+ cliVersion,
169
178
  sourcePath,
170
179
  };
171
180
  filesWritten += 1;
package/lib/ledger.js CHANGED
@@ -14,7 +14,9 @@ const CLI_LEDGER_SCHEMA_MAJOR = 1;
14
14
  // item.targetPath override. Additive/backward-compatible: an entry written
15
15
  // by an older CLI simply lacks sourcePath, and every reader (managed_files_
16
16
  // guard.py, update.js) falls back to the ledger key (relTarget) when absent.
17
- const CLI_LEDGER_SCHEMA_VERSION = '1.1.0';
17
+ // 1.2.0 adds an optional per-entry `cliVersion`. Additive and same-major, so no
18
+ // migration is registered: an entry without it simply reads as "version unknown".
19
+ const CLI_LEDGER_SCHEMA_VERSION = '1.2.0';
18
20
  const LEDGER_FILE_NAME = 'agents-ledger.json';
19
21
  // ledger.entries[].bundle tag used for files owned by a shared component
20
22
  // (e.g. the litellm config/start-script templates) rather than any one
package/lib/tty-menu.js CHANGED
@@ -114,8 +114,11 @@ function buildRowLines(row, ansi, { isSelected, isCursor }) {
114
114
  // Install chip: "installed -> v0.11.0" or "new". Placed on the main line so the list
115
115
  // itself answers "which of these do I already have?" without moving the cursor over
116
116
  // every row. Never inside the inverse highlight's colour, so it stays legible.
117
+ // Chips that represent a CHANGE (new / older / unknown) are highlighted; a bundle
118
+ // already at the running version is dimmed, so the rows needing attention are the
119
+ // ones that stand out rather than every row shouting equally.
117
120
  const chip = row.installChip
118
- ? ` ${row.installChip === 'new' ? ansi.dim('[new]') : ansi.yellow(`[${row.installChip}]`)}`
121
+ ? ` ${row.installChipIsChange === false ? ansi.dim(`[${row.installChip}]`) : ansi.yellow(`[${row.installChip}]`)}`
119
122
  : '';
120
123
  const mainLine = `${pointer} ${box} ${title} — ${summary}${chip}`;
121
124
  const lines = [isCursor ? ansi.inverse(mainLine) : mainLine];
@@ -187,6 +190,32 @@ function buildDetailLines(row, detail, ansi, { isSelected }) {
187
190
  return lines.slice(0, DETAIL_HEIGHT);
188
191
  }
189
192
 
193
+ /**
194
+ * Tri-state for the "All" row: every bundle selected, none, or some.
195
+ * `some` renders distinctly so a partial selection can't be mistaken for "all".
196
+ */
197
+ function allRowState(selected, total) {
198
+ if (total === 0) return 'none';
199
+ if (selected.size >= total) return 'all';
200
+ return selected.size === 0 ? 'none' : 'some';
201
+ }
202
+
203
+ /**
204
+ * The "All" row line. Rendered as position 0 of the list — the `a` keystroke already
205
+ * did this, but an invisible keybinding is not discoverable; a row you can arrow onto
206
+ * and press space is.
207
+ */
208
+ function buildAllRowLine(state, total, ansi, { isCursor }) {
209
+ const box = state === 'all' ? ansi.green('[✓]') : state === 'some' ? ansi.yellow('[~]') : '[ ]';
210
+ const pointer = isCursor ? ansi.cyan('❯') : ' ';
211
+ const label = ansi.bold(ansi.white('All'));
212
+ const hint = ansi.dim(
213
+ state === 'all' ? `— deselect all ${total}` : `— select all ${total}`
214
+ );
215
+ const line = `${pointer} ${box} ${label} ${hint}`;
216
+ return isCursor ? ansi.inverse(line) : line;
217
+ }
218
+
190
219
  function pickWithRawMode(rows, stdin, stdout, { details, header, subheader } = {}) {
191
220
  return new Promise((resolve) => {
192
221
  const ansi = createStyler(supportsColor({ stream: stdout }));
@@ -206,10 +235,26 @@ function pickWithRawMode(rows, stdin, stdout, { details, header, subheader } = {
206
235
  if (subheader) out.push(ansi.dim(subheader));
207
236
  out.push(ansi.dim('Select bundles to install'));
208
237
  out.push('');
209
- out.push(...layoutRows(rows, ansi, { selected, cursor }).lines);
238
+ // Position 0 is the synthetic "All" row; positions 1..n map to rows[pos-1].
239
+ out.push(buildAllRowLine(allRowState(selected, rows.length), rows.length, ansi, { isCursor: cursor === 0 }));
240
+ out.push(...layoutRows(rows, ansi, { selected, cursor: cursor - 1 }).lines);
210
241
  out.push('');
211
242
  out.push(ansi.dim('─'.repeat(RULE_WIDTH)));
212
- out.push(...buildDetailLines(rows[cursor], detailFor(details, rows[cursor]), ansi, { isSelected: selected.has(cursor) }));
243
+ if (cursor === 0) {
244
+ const state = allRowState(selected, rows.length);
245
+ const allLines = [
246
+ `${ansi.bold('All bundles')} ${ansi.dim('—')} ${
247
+ state === 'all' ? ansi.green(`all ${rows.length} selected`)
248
+ : state === 'some' ? ansi.yellow(`${selected.size} of ${rows.length} selected`)
249
+ : ansi.dim('none selected')}`,
250
+ ansi.dim('space toggles every bundle in the list at once.'),
251
+ ];
252
+ while (allLines.length < DETAIL_HEIGHT) allLines.push('');
253
+ out.push(...allLines.slice(0, DETAIL_HEIGHT));
254
+ } else {
255
+ const row = rows[cursor - 1];
256
+ out.push(...buildDetailLines(row, detailFor(details, row), ansi, { isSelected: selected.has(cursor - 1) }));
257
+ }
213
258
  out.push(ansi.dim('─'.repeat(RULE_WIDTH)));
214
259
  out.push(ansi.dim('↑/↓/j/k move PgUp/PgDn jump space toggle a all/none enter confirm q quit'));
215
260
  stdout.write(`${out.join('\n')}\n`);
@@ -227,8 +272,17 @@ function pickWithRawMode(rows, stdin, stdout, { details, header, subheader } = {
227
272
  else selected.add(i);
228
273
  }
229
274
 
275
+ // Total navigable positions include the synthetic All row at index 0.
276
+ function positionCount() {
277
+ return rows.length + 1;
278
+ }
279
+
230
280
  function moveCursor(delta) {
231
- cursor = Math.min(rows.length - 1, Math.max(0, cursor + delta));
281
+ cursor = Math.min(positionCount() - 1, Math.max(0, cursor + delta));
282
+ }
283
+
284
+ function toggleAllRows() {
285
+ selected = toggleAll(selected, rows.map((_, i) => i));
232
286
  }
233
287
 
234
288
  function onKeypress(str, key) {
@@ -243,20 +297,18 @@ function pickWithRawMode(rows, stdin, stdout, { details, header, subheader } = {
243
297
  return;
244
298
  }
245
299
  if (key && (key.name === 'up' || key.name === 'k')) {
246
- cursor = (cursor - 1 + rows.length) % rows.length;
300
+ cursor = (cursor - 1 + positionCount()) % positionCount();
247
301
  } else if (key && (key.name === 'down' || key.name === 'j')) {
248
- cursor = (cursor + 1) % rows.length;
302
+ cursor = (cursor + 1) % positionCount();
249
303
  } else if (key && key.name === 'pageup') {
250
304
  moveCursor(-5);
251
305
  } else if (key && key.name === 'pagedown') {
252
306
  moveCursor(5);
253
307
  } else if (key && key.name === 'space') {
254
- toggle(cursor);
308
+ if (cursor === 0) toggleAllRows();
309
+ else toggle(cursor - 1);
255
310
  } else if (str === 'a') {
256
- selected = toggleAll(
257
- selected,
258
- rows.map((_, i) => i)
259
- );
311
+ toggleAllRows();
260
312
  } else if (key && key.name === 'return') {
261
313
  cleanup();
262
314
  resolve(rows.filter((_, i) => selected.has(i)).map((r) => r.key));
@@ -315,4 +367,6 @@ module.exports = {
315
367
  hintsFromRow,
316
368
  layoutRows,
317
369
  HINT_INDENT,
370
+ allRowState,
371
+ buildAllRowLine,
318
372
  };
package/lib/update.js CHANGED
@@ -157,16 +157,36 @@ function planComponentUpdate(componentKey, component, { repoRoot, targetBase, le
157
157
  return planFileUpdates(currentFiles, { targetBase, ledger, bundleTag: componentEntryTag(componentKey) });
158
158
  }
159
159
 
160
- function applyOverwrite(item, ledger, bundleKey, timestamp) {
160
+ function applyOverwrite(item, ledger, bundleKey, timestamp, cliVersion) {
161
161
  copyFileEnsuringDir(item.srcFile, item.destFile);
162
162
  ledger.entries[item.relTarget] = {
163
163
  sha256: item.sourceHash,
164
164
  bundle: bundleKey,
165
165
  installedAt: timestamp,
166
+ // Ledger schema 1.2.0 — drives the menu's per-bundle "vX -> vY" chip. Omitting it
167
+ // here would mean `update` never clears a "v?" row, so a legacy install could only
168
+ // be healed by a full reinstall.
169
+ cliVersion,
166
170
  sourcePath: item.sourcePath,
167
171
  };
168
172
  }
169
173
 
174
+ /**
175
+ * Re-stamp entries the update left on disk as already-correct for this release.
176
+ *
177
+ * `upToDate` (source matches what is installed) and `keepNoSourceChange` (source did not
178
+ * change; the user edited their copy) both mean the bundle IS at this release for that
179
+ * path — no bytes needed writing. Without this they would keep whatever cliVersion they
180
+ * were last written with, so a bundle whose files did not change between releases would
181
+ * show a stale version forever, and pre-1.2.0 entries would show "v?" permanently.
182
+ */
183
+ function restampUnwritten(plan, ledger, cliVersion) {
184
+ for (const item of [...plan.upToDate, ...plan.keepNoSourceChange]) {
185
+ const entry = ledger.entries[item.relTarget];
186
+ if (entry) entry.cliVersion = cliVersion;
187
+ }
188
+ }
189
+
170
190
  /**
171
191
  * Resolve `conflicts` per the binding decision: a bulk `strategy`
172
192
  * ('theirs'/'keep-mine') resolves every conflict without prompting; absent a
@@ -241,19 +261,21 @@ async function applyFilePlan(plan, { ledger, tag, targetBase, timestamp, cliVers
241
261
  unresolvedConflicts: [],
242
262
  };
243
263
 
264
+ restampUnwritten(plan, ledger, cliVersion);
265
+
244
266
  for (const item of plan.overwrite) {
245
- applyOverwrite(item, ledger, tag, timestamp);
267
+ applyOverwrite(item, ledger, tag, timestamp, cliVersion);
246
268
  summary.overwritten.push(item.relTarget);
247
269
  }
248
270
  for (const item of plan.reinstall) {
249
- applyOverwrite(item, ledger, tag, timestamp);
271
+ applyOverwrite(item, ledger, tag, timestamp, cliVersion);
250
272
  summary.reinstalled.push(item.relTarget);
251
273
  }
252
274
 
253
275
  const { resolved, unresolved } = await resolveConflicts(plan.conflicts, { strategy, io, isTTY, log, cliVersion });
254
276
  for (const outcome of resolved) {
255
277
  if (outcome.action === 'overwrite' || outcome.action === 'backup') {
256
- applyOverwrite(outcome.item, ledger, tag, timestamp);
278
+ applyOverwrite(outcome.item, ledger, tag, timestamp, cliVersion);
257
279
  }
258
280
  summary.conflictsResolved.push({
259
281
  relTarget: outcome.item.relTarget,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yasaswy.nagavolu/agents",
3
- "version": "0.12.0",
3
+ "version": "0.14.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",