@yasaswy.nagavolu/agents 0.13.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/lib/tty-menu.js +61 -10
- package/lib/update.js +26 -4
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
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(
|
|
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 +
|
|
300
|
+
cursor = (cursor - 1 + positionCount()) % positionCount();
|
|
250
301
|
} else if (key && (key.name === 'down' || key.name === 'j')) {
|
|
251
|
-
cursor = (cursor + 1) %
|
|
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
|
-
|
|
308
|
+
if (cursor === 0) toggleAllRows();
|
|
309
|
+
else toggle(cursor - 1);
|
|
258
310
|
} else if (str === 'a') {
|
|
259
|
-
|
|
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.
|
|
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",
|