@yasaswy.nagavolu/agents 0.11.0 → 0.13.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 +13 -4
- package/lib/install-state.js +92 -0
- package/lib/install.js +9 -0
- package/lib/ledger.js +3 -1
- package/lib/tty-menu.js +14 -1
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -14,6 +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, chipIsChange } = require('../lib/install-state');
|
|
17
18
|
const { ledgerPath } = require('../lib/ledger');
|
|
18
19
|
const { WiringError } = require('../lib/wiring');
|
|
19
20
|
const {
|
|
@@ -352,10 +353,9 @@ function printFinalSummary({ installed, skipped, targetBase }) {
|
|
|
352
353
|
* file. A ledger problem must not be able to stop the installer from rendering its
|
|
353
354
|
* menu -- the install path itself will surface that error properly.
|
|
354
355
|
*/
|
|
355
|
-
function
|
|
356
|
+
function readLedgerSafely(targetDir) {
|
|
356
357
|
try {
|
|
357
|
-
|
|
358
|
-
return JSON.parse(raw).cliVersion || null;
|
|
358
|
+
return JSON.parse(readFileSync(ledgerPath(targetDir), 'utf8'));
|
|
359
359
|
} catch {
|
|
360
360
|
return null;
|
|
361
361
|
}
|
|
@@ -403,11 +403,20 @@ async function runInteractiveMenu({ advanced, targetDir, targetConfig, noSecrets
|
|
|
403
403
|
const rows = candidateBundles.map((b) => describeBundleRow(b, manifest));
|
|
404
404
|
const details = new Map(candidateBundles.map((b) => [b.key, deriveBundleDetails(b, manifest, { repoRoot })]));
|
|
405
405
|
const header = `${pkg.name} v${pkg.version}`;
|
|
406
|
+
const ledger = readLedgerSafely(targetDir || defaultTargetBase());
|
|
406
407
|
const subheader = formatVersionBanner({
|
|
407
408
|
running: pkg.version,
|
|
408
|
-
installed:
|
|
409
|
+
installed: (ledger && ledger.cliVersion) || null,
|
|
409
410
|
latest: await fetchLatestVersion(pkg.name),
|
|
410
411
|
});
|
|
412
|
+
// Per-row install state, so the list itself answers "which of these do I already
|
|
413
|
+
// have, and what will confirming do to them?"
|
|
414
|
+
for (const row of rows) {
|
|
415
|
+
const state = bundleInstallState(ledger, row.key);
|
|
416
|
+
row.installChip = installChip(state, pkg.version);
|
|
417
|
+
row.installDetail = installDetailLine(state);
|
|
418
|
+
row.installChipIsChange = chipIsChange(state, pkg.version);
|
|
419
|
+
}
|
|
411
420
|
const selectedKeys = await pickBundles(rows, { details, header, subheader });
|
|
412
421
|
if (selectedKeys === null) {
|
|
413
422
|
console.log('Cancelled — nothing installed.');
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Per-bundle install state for the interactive menu.
|
|
4
|
+
//
|
|
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.
|
|
12
|
+
//
|
|
13
|
+
// Pure and ledger-shaped-input only, so it is testable without a TTY or a real install.
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {object|null} ledger parsed agents-ledger.json (or null when absent)
|
|
17
|
+
* @param {string} bundleKey
|
|
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.
|
|
23
|
+
*/
|
|
24
|
+
function bundleInstallState(ledger, bundleKey) {
|
|
25
|
+
const entries = (ledger && ledger.entries) || {};
|
|
26
|
+
let fileCount = 0;
|
|
27
|
+
let newestAt = null;
|
|
28
|
+
const versions = new Set();
|
|
29
|
+
for (const value of Object.values(entries)) {
|
|
30
|
+
if (!value || value.bundle !== bundleKey) continue;
|
|
31
|
+
fileCount += 1;
|
|
32
|
+
const at = value.installedAt;
|
|
33
|
+
if (at && (newestAt === null || at > newestAt)) newestAt = at;
|
|
34
|
+
versions.add(value.cliVersion || null);
|
|
35
|
+
}
|
|
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;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
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"
|
|
67
|
+
*
|
|
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.
|
|
71
|
+
*/
|
|
72
|
+
function installChip(state, 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;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** "installed 2026-07-31 · 6 files" for the detail pane, or null when not installed. */
|
|
85
|
+
function installDetailLine(state) {
|
|
86
|
+
if (!state.installed) return null;
|
|
87
|
+
const day = state.installedAt ? String(state.installedAt).slice(0, 10) : 'unknown date';
|
|
88
|
+
const mixed = state.mixed ? ' · mixed versions on disk' : '';
|
|
89
|
+
return `installed ${day} · ${state.fileCount} file${state.fileCount === 1 ? '' : 's'} on disk${mixed}`;
|
|
90
|
+
}
|
|
91
|
+
|
|
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
|
-
|
|
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
|
@@ -111,7 +111,16 @@ function buildRowLines(row, ansi, { isSelected, isCursor }) {
|
|
|
111
111
|
const pointer = isCursor ? ansi.cyan('❯') : ' ';
|
|
112
112
|
const title = ansi.bold(ansi.white(row.title));
|
|
113
113
|
const summary = ansi.dim(row.summary);
|
|
114
|
-
|
|
114
|
+
// Install chip: "installed -> v0.11.0" or "new". Placed on the main line so the list
|
|
115
|
+
// itself answers "which of these do I already have?" without moving the cursor over
|
|
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.
|
|
120
|
+
const chip = row.installChip
|
|
121
|
+
? ` ${row.installChipIsChange === false ? ansi.dim(`[${row.installChip}]`) : ansi.yellow(`[${row.installChip}]`)}`
|
|
122
|
+
: '';
|
|
123
|
+
const mainLine = `${pointer} ${box} ${title} — ${summary}${chip}`;
|
|
115
124
|
const lines = [isCursor ? ansi.inverse(mainLine) : mainLine];
|
|
116
125
|
const hintLine = buildHintLine(hintsFromRow(row), ansi);
|
|
117
126
|
if (hintLine) lines.push(`${HINT_INDENT}${hintLine}`);
|
|
@@ -147,6 +156,10 @@ function buildDetailLines(row, detail, ansi, { isSelected }) {
|
|
|
147
156
|
} else {
|
|
148
157
|
const stateLabel = isSelected ? ansi.green('selected') : ansi.dim('not selected');
|
|
149
158
|
lines.push(`${ansi.bold(detail.title)} ${ansi.dim('—')} ${stateLabel}`);
|
|
159
|
+
// Exact install facts for the highlighted bundle (date + files actually on disk).
|
|
160
|
+
// The ledger has no per-bundle version, so none is claimed here — see
|
|
161
|
+
// lib/install-state.js.
|
|
162
|
+
if (row && row.installDetail) lines.push(ansi.yellow(row.installDetail));
|
|
150
163
|
|
|
151
164
|
const kindParts = Object.entries(detail.kindCounts || {}).map(
|
|
152
165
|
([kind, count]) => `${count} ${kind}${count === 1 ? '' : 's'}`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yasaswy.nagavolu/agents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.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",
|