@yasaswy.nagavolu/agents 0.13.0 → 0.15.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
@@ -985,6 +985,32 @@ async function main(argv) {
985
985
  return 1;
986
986
  }
987
987
 
988
+ /**
989
+ * Return stdin to an idle state so the process can actually exit.
990
+ *
991
+ * A resumed stdin is an active libuv handle: the event loop never drains and node hangs
992
+ * with no shell prompt, even though all work is done and the exit code is set. The
993
+ * interactive readers all resume it -- the raw-mode picker (which pauses on its own way
994
+ * out) and, crucially, the secrets prompts, whose ensureFlowing() resumes stdin and
995
+ * never pauses it again. Observed 2026-08-02: a full interactive install printed its
996
+ * summary and then sat there forever.
997
+ *
998
+ * Done once here, at the single exit point, rather than in each reader: any future
999
+ * prompt that resumes stdin is covered automatically, which a per-reader fix would not
1000
+ * be. Best-effort and never throws -- failing to tidy stdin must not change the exit
1001
+ * code of an otherwise successful run.
1002
+ */
1003
+ function releaseStdin() {
1004
+ try {
1005
+ if (process.stdin.isTTY && typeof process.stdin.setRawMode === 'function') {
1006
+ process.stdin.setRawMode(false);
1007
+ }
1008
+ } catch { /* platform refused — nothing further to do */ }
1009
+ try {
1010
+ process.stdin.pause();
1011
+ } catch { /* ditto */ }
1012
+ }
1013
+
988
1014
  main(process.argv.slice(2))
989
1015
  .then((code) => {
990
1016
  process.exitCode = code;
@@ -992,4 +1018,5 @@ main(process.argv.slice(2))
992
1018
  .catch((err) => {
993
1019
  console.error(err.stack || err.message);
994
1020
  process.exitCode = 1;
995
- });
1021
+ })
1022
+ .finally(releaseStdin);
@@ -84,6 +84,20 @@ function maskValue(value) {
84
84
  return '*'.repeat(str.length - 4) + str.slice(-4);
85
85
  }
86
86
 
87
+ /**
88
+ * Fixed-width mask for DISPLAY: four stars plus the last four characters, and the real
89
+ * length alongside. maskValue() mirrors the value's length, which for a 164-character
90
+ * OpenAI key prints 160 asterisks — a wall of noise that hides the only part a human
91
+ * can actually recognise. The length is kept because it is the other thing worth
92
+ * eyeballing (a truncated paste shows up as a wrong count).
93
+ */
94
+ function maskCompact(value) {
95
+ const str = String(value == null ? '' : value);
96
+ if (!str) return '(empty)';
97
+ if (str.length < 8) return `${'*'.repeat(str.length)} (${str.length} chars)`;
98
+ return `****${str.slice(-4)} (${str.length} chars)`;
99
+ }
100
+
87
101
  /**
88
102
  * Ensure `input` is actively flowing before reading from it. A stream left
89
103
  * paused by a prior consumer (notably lib/tty-menu.js's raw-mode bundle
@@ -258,15 +272,17 @@ const DEFAULT_VALIDATORS = { GITLAB_TOKEN: validateGitlabToken };
258
272
  * `'kept'`) rather than "skip" (status `'skipped'`), and the prompt text is
259
273
  * worded to match.
260
274
  */
261
- async function promptOneSecret({ secret, io, validator, alreadySet = false }) {
275
+ async function promptOneSecret({ secret, io, validator, alreadySet = false, replacing = false }) {
262
276
  for (;;) {
263
277
  // eslint-disable-next-line no-await-in-loop
264
278
  const value = await readMaskedSecret({
265
279
  input: io.input,
266
280
  output: io.output,
267
- promptText: alreadySet
268
- ? `Enter ${secret.name} (Enter to keep current value): `
269
- : `Enter ${secret.name} (Enter to skip): `,
281
+ promptText: replacing
282
+ ? ` Enter NEW ${secret.name} (Enter to cancel and keep current): `
283
+ : alreadySet
284
+ ? `Enter ${secret.name} (Enter to keep current value): `
285
+ : `Enter ${secret.name} (Enter to skip): `,
270
286
  });
271
287
  if (!value) {
272
288
  return { status: alreadySet ? 'kept' : 'skipped' };
@@ -371,14 +387,34 @@ async function promptForMissingSecrets({ bundles, targetBase, io, validators, no
371
387
  if (secret.validationHint) {
372
388
  log(` (${secret.validationHint})`);
373
389
  }
390
+ let replacing = false;
374
391
  if (resolution.resolved) {
375
- log(` already set (${maskValue(resolution.value)}, from ${resolution.source}) — Enter keeps, type to replace`);
392
+ // Show what is there, then ask a single explicit question. The old flow printed
393
+ // "Enter keeps, type to replace" and dropped straight into a masked field, so
394
+ // replacing meant blind-typing a long secret with no confirmation step, and there
395
+ // was no way to see what you already had beyond a row of asterisks.
396
+ log(` current: ${maskCompact(resolution.value)} — from ${resolution.source}`);
397
+ // eslint-disable-next-line no-await-in-loop
398
+ const choice = await askChoice({
399
+ input: resolvedIo.input,
400
+ output: resolvedIo.output,
401
+ promptText: ` [K] keep [R] replace (Enter = keep): `,
402
+ choices: ['k', 'r'],
403
+ defaultChoice: 'k',
404
+ });
405
+ if (choice !== 'r') {
406
+ log(` Kept existing ${secret.name}.`);
407
+ result.alreadySet.push(secret.name);
408
+ continue;
409
+ }
410
+ replacing = true;
376
411
  }
377
412
  const outcome = await promptOneSecret({ // eslint-disable-line no-await-in-loop
378
413
  secret,
379
414
  io: resolvedIo,
380
415
  validator: activeValidators[secret.name],
381
416
  alreadySet: resolution.resolved,
417
+ replacing,
382
418
  });
383
419
  if (outcome.status === 'kept') {
384
420
  log(` Kept existing ${secret.name}.`);
@@ -409,6 +445,7 @@ module.exports = {
409
445
  resolveSecretSource,
410
446
  isResolved,
411
447
  maskValue,
448
+ maskCompact,
412
449
  readMaskedSecret,
413
450
  readPlainLine,
414
451
  askChoice,
package/lib/tty-menu.js CHANGED
@@ -190,6 +190,32 @@ function buildDetailLines(row, detail, ansi, { isSelected }) {
190
190
  return lines.slice(0, DETAIL_HEIGHT);
191
191
  }
192
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
+
193
219
  function pickWithRawMode(rows, stdin, stdout, { details, header, subheader } = {}) {
194
220
  return new Promise((resolve) => {
195
221
  const ansi = createStyler(supportsColor({ stream: stdout }));
@@ -209,10 +235,26 @@ function pickWithRawMode(rows, stdin, stdout, { details, header, subheader } = {
209
235
  if (subheader) out.push(ansi.dim(subheader));
210
236
  out.push(ansi.dim('Select bundles to install'));
211
237
  out.push('');
212
- 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);
213
241
  out.push('');
214
242
  out.push(ansi.dim('─'.repeat(RULE_WIDTH)));
215
- 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
+ }
216
258
  out.push(ansi.dim('─'.repeat(RULE_WIDTH)));
217
259
  out.push(ansi.dim('↑/↓/j/k move PgUp/PgDn jump space toggle a all/none enter confirm q quit'));
218
260
  stdout.write(`${out.join('\n')}\n`);
@@ -230,8 +272,17 @@ function pickWithRawMode(rows, stdin, stdout, { details, header, subheader } = {
230
272
  else selected.add(i);
231
273
  }
232
274
 
275
+ // Total navigable positions include the synthetic All row at index 0.
276
+ function positionCount() {
277
+ return rows.length + 1;
278
+ }
279
+
233
280
  function moveCursor(delta) {
234
- 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));
235
286
  }
236
287
 
237
288
  function onKeypress(str, key) {
@@ -246,20 +297,18 @@ function pickWithRawMode(rows, stdin, stdout, { details, header, subheader } = {
246
297
  return;
247
298
  }
248
299
  if (key && (key.name === 'up' || key.name === 'k')) {
249
- cursor = (cursor - 1 + rows.length) % rows.length;
300
+ cursor = (cursor - 1 + positionCount()) % positionCount();
250
301
  } else if (key && (key.name === 'down' || key.name === 'j')) {
251
- cursor = (cursor + 1) % rows.length;
302
+ cursor = (cursor + 1) % positionCount();
252
303
  } else if (key && key.name === 'pageup') {
253
304
  moveCursor(-5);
254
305
  } else if (key && key.name === 'pagedown') {
255
306
  moveCursor(5);
256
307
  } else if (key && key.name === 'space') {
257
- toggle(cursor);
308
+ if (cursor === 0) toggleAllRows();
309
+ else toggle(cursor - 1);
258
310
  } else if (str === 'a') {
259
- selected = toggleAll(
260
- selected,
261
- rows.map((_, i) => i)
262
- );
311
+ toggleAllRows();
263
312
  } else if (key && key.name === 'return') {
264
313
  cleanup();
265
314
  resolve(rows.filter((_, i) => selected.has(i)).map((r) => r.key));
@@ -318,4 +367,6 @@ module.exports = {
318
367
  hintsFromRow,
319
368
  layoutRows,
320
369
  HINT_INDENT,
370
+ allRowState,
371
+ buildAllRowLine,
321
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.13.0",
3
+ "version": "0.15.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",