@dadado/agent-kit-cli 6.22.1 → 6.25.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 +1 -0
- package/dashboard/dashboard-data.mjs +126 -5
- package/dashboard/dashboard.html +45 -4
- package/dashboard/lib/live-refresh.mjs +1 -0
- package/dist/{add-YVDIFP4N.js → add-OYLOMCM6.js} +14 -6
- package/dist/chunk-2F6NMQOA.js +519 -0
- package/dist/chunk-2QYWMSI5.js +193 -0
- package/dist/{chunk-B3VR5YBQ.js → chunk-2TW7ENWC.js} +12 -11
- package/dist/{chunk-GT5R7W66.js → chunk-2XLI7XEY.js} +1 -1
- package/dist/chunk-6M6UKECW.js +176 -0
- package/dist/{chunk-YRBRYTM5.js → chunk-7Y74KO7U.js} +45 -16
- package/dist/{chunk-DZCLMIAS.js → chunk-AQLBEEPD.js} +236 -2
- package/dist/{chunk-R4DUO5DA.js → chunk-AXQMVQ6O.js} +61 -237
- package/dist/{chunk-4SEQ76BQ.js → chunk-C7SV7UP5.js} +7 -4
- package/dist/{chunk-WS6OX2IG.js → chunk-CGXLR77R.js} +4 -0
- package/dist/{chunk-XZQM55BK.js → chunk-CIV42JGT.js} +7 -5
- package/dist/{chunk-CQHD6UKB.js → chunk-CXE6ASSX.js} +1 -0
- package/dist/{chunk-2FKAKFMH.js → chunk-EO5NGAYV.js} +1 -1
- package/dist/{chunk-GV4VKIPO.js → chunk-G5MQRP6M.js} +32 -14
- package/dist/chunk-GMG7ZH4E.js +357 -0
- package/dist/{chunk-5EBT3V7G.js → chunk-GQSSXDDK.js} +1 -1
- package/dist/{chunk-EYNSSL6B.js → chunk-H7RAFRRZ.js} +47 -251
- package/dist/{chunk-IESSMKOV.js → chunk-HSIHZWFF.js} +4 -4
- package/dist/{chunk-W3ZJVBNY.js → chunk-IFBIO7VT.js} +449 -418
- package/dist/{chunk-QWTBYXHN.js → chunk-JFS4GKP7.js} +1 -1
- package/dist/{chunk-LDZAK5DU.js → chunk-JG3CNGQM.js} +78 -170
- package/dist/{chunk-SDJIMC5S.js → chunk-JGG574RK.js} +3 -3
- package/dist/{chunk-SGTTC2JP.js → chunk-KWYF7QNH.js} +1 -1
- package/dist/{chunk-5HH3HSUR.js → chunk-M4UL422I.js} +80 -15
- package/dist/{chunk-DTSL2RH7.js → chunk-MFKHIWEL.js} +5 -3
- package/dist/{chunk-MGIPA6SD.js → chunk-NJ2SUSWX.js} +1 -1
- package/dist/{chunk-BCU54M2P.js → chunk-PIMGV3E5.js} +1 -1
- package/dist/{chunk-HJWSOZXS.js → chunk-QACMV46U.js} +10 -10
- package/dist/{chunk-WHBGJ7IJ.js → chunk-QLTGHJB3.js} +26 -7
- package/dist/{chunk-ZJDJCMQO.js → chunk-QX55T4UX.js} +23 -1
- package/dist/chunk-SAQ3EE5R.js +138 -0
- package/dist/{chunk-C4LCOOL4.js → chunk-TOSAAQ5A.js} +1 -1
- package/dist/chunk-WKFE3RUC.js +433 -0
- package/dist/{chunk-BGL5DRK2.js → chunk-XGZOU4DS.js} +1 -1
- package/dist/{commands-LEBG6DMD.js → commands-UW2C2ZN4.js} +5 -5
- package/dist/{conflicts-FJD3IVPQ.js → conflicts-RING6AHV.js} +22 -12
- package/dist/{contribute-XPAR2JER.js → contribute-LSY75JZH.js} +6 -5
- package/dist/{countdown-25E5C7AR.js → countdown-SZ2P4XHB.js} +267 -23
- package/dist/{diff-KFID4SX3.js → diff-NZVBVQSK.js} +14 -6
- package/dist/{doctor-J2GJFTSE.js → doctor-TJSXBVGV.js} +104 -18
- package/dist/{ground-control-IDCXN5FK.js → ground-control-ZJXPUIQN.js} +3 -3
- package/dist/{guard-RJZEEKSL.js → guard-ZO4Z3LLB.js} +47 -9
- package/dist/{handoff-5AGE2D3T.js → handoff-2OZSWGTE.js} +2 -0
- package/dist/{hook-HV6U3ANI.js → hook-3VPKNSOO.js} +14 -12
- package/dist/index.js +27 -26
- package/dist/{init-47WA2SCG.js → init-UW2BJBO2.js} +22 -16
- package/dist/install-RQSI4CHG.js +41 -0
- package/dist/installs-7TR4H4QH.js +222 -0
- package/dist/{mission-control-CRMCRZUU.js → mission-control-VSU6NT43.js} +1 -1
- package/dist/{queue-OJHKFKK3.js → queue-JHYILLMX.js} +10 -10
- package/dist/{run-Z2GHNVBO.js → run-CQF5RM5X.js} +29 -29
- package/dist/{run-plan-XA7MYOQ3.js → run-plan-BEOCOJCF.js} +13 -13
- package/dist/{scan-K3T5RQLC.js → scan-7D3RMO34.js} +2 -1
- package/dist/{session-start-PEVTDMOZ.js → session-start-QV7CEFRX.js} +18 -12
- package/dist/{sessions-6IGVH467.js → sessions-AWAAO3DU.js} +3 -3
- package/dist/{setup-global-KBJL7QRD.js → setup-global-ST4TT427.js} +9 -8
- package/dist/{status-3UGVDIO6.js → status-HUBPBGUU.js} +14 -11
- package/dist/update-DD5UZPGG.js +31 -0
- package/dist/update-all-YYUTXHGR.js +695 -0
- package/package.json +1 -1
- package/dist/chunk-HAFRAXGV.js +0 -17
- package/dist/chunk-ZNY32NK2.js +0 -52
- package/dist/install-Y63HEM4G.js +0 -38
- package/dist/update-4UQHGENC.js +0 -283
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
validateHandoffText
|
|
3
|
-
} from "./chunk-2YU2H7I6.js";
|
|
4
1
|
import {
|
|
5
2
|
collectLiveRoster,
|
|
6
3
|
formatRosterLease,
|
|
7
4
|
formatRosterRow
|
|
8
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-JFS4GKP7.js";
|
|
6
|
+
import {
|
|
7
|
+
validateHandoffText
|
|
8
|
+
} from "./chunk-2YU2H7I6.js";
|
|
9
|
+
import {
|
|
10
|
+
formatPlanIndexSection,
|
|
11
|
+
writePlanIndex
|
|
12
|
+
} from "./chunk-L5V3W3DY.js";
|
|
9
13
|
import {
|
|
10
14
|
CHANGELOG_FETCH_TIMEOUT_MS,
|
|
11
15
|
resolveInventoryRoot,
|
|
@@ -16,21 +20,19 @@ import {
|
|
|
16
20
|
stampPublicInboundCheck
|
|
17
21
|
} from "./chunk-4CRBUEJ6.js";
|
|
18
22
|
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
READINESS_SNAPSHOT_RELATIVE_PATH
|
|
24
|
-
} from "./chunk-HAFRAXGV.js";
|
|
23
|
+
READINESS_SNAPSHOT_RELATIVE_PATH,
|
|
24
|
+
UPDATE_NOTICE_SESSION_FETCH_TIMEOUT_MS,
|
|
25
|
+
computeUpdateNotice
|
|
26
|
+
} from "./chunk-2F6NMQOA.js";
|
|
25
27
|
import {
|
|
26
28
|
stampLastCheckedAt
|
|
27
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-M4UL422I.js";
|
|
28
30
|
import {
|
|
29
31
|
loadContextConfig
|
|
30
32
|
} from "./chunk-PFEUZXVT.js";
|
|
31
33
|
import {
|
|
32
34
|
MANIFEST_RELATIVE_PATH
|
|
33
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-6M6UKECW.js";
|
|
34
36
|
import {
|
|
35
37
|
HANDOFF_REL
|
|
36
38
|
} from "./chunk-C4Q77GGJ.js";
|
|
@@ -480,6 +482,18 @@ async function dogfoodInboxSection(root) {
|
|
|
480
482
|
function colonyHostSection(env = process.env) {
|
|
481
483
|
return env.COLONY_HOST_CLI?.trim() ? COLONY_HOST_HINT : null;
|
|
482
484
|
}
|
|
485
|
+
var UPDATE_NOTICE_SECTION_DEADLINE_MS = UPDATE_NOTICE_SESSION_FETCH_TIMEOUT_MS + 1e3;
|
|
486
|
+
async function updateNoticeSection(root, options = {}) {
|
|
487
|
+
const { deadlineMs, ...noticeOptions } = options;
|
|
488
|
+
const summary = await withDeadline(
|
|
489
|
+
computeUpdateNotice(root, {
|
|
490
|
+
timeoutMs: UPDATE_NOTICE_SESSION_FETCH_TIMEOUT_MS,
|
|
491
|
+
...noticeOptions
|
|
492
|
+
}),
|
|
493
|
+
deadlineMs ?? UPDATE_NOTICE_SECTION_DEADLINE_MS
|
|
494
|
+
);
|
|
495
|
+
return summary?.line ?? null;
|
|
496
|
+
}
|
|
483
497
|
async function loadUpdateCheckPrefs(root) {
|
|
484
498
|
const data = await loadContextConfig(root);
|
|
485
499
|
if (!data) return null;
|
|
@@ -962,13 +976,15 @@ async function buildSessionStartAdditionalContext(rootDir, _payload = {}, deps =
|
|
|
962
976
|
const cursorAttempt = newAttempt();
|
|
963
977
|
const inboundAttempt = newAttempt();
|
|
964
978
|
const runSection = (section, attempt) => runSectionWithDeadline(section, root, deps.spawnFn, deadlineMs, attempt);
|
|
965
|
-
const [updateNudge, cursorNudge, inboundNudge] = await Promise.all([
|
|
979
|
+
const [updateNotice, updateNudge, cursorNudge, inboundNudge] = await Promise.all([
|
|
980
|
+
updateNoticeSection(root, deps.updateNotice).catch(() => null),
|
|
966
981
|
runSection(updateCheckSection, updateAttempt),
|
|
967
982
|
runSection(cursorAwarenessSection, cursorAttempt),
|
|
968
983
|
runSection(publicInboundSection, inboundAttempt)
|
|
969
984
|
]);
|
|
970
985
|
await stampSectionAttempts(root, updateAttempt, cursorAttempt, inboundAttempt);
|
|
971
|
-
if (
|
|
986
|
+
if (updateNotice) parts.push(updateNotice);
|
|
987
|
+
else if (updateNudge) parts.push(updateNudge);
|
|
972
988
|
if (cursorNudge) parts.push(cursorNudge);
|
|
973
989
|
if (inboundNudge) parts.push(inboundNudge);
|
|
974
990
|
const liveAgents = await liveAgentsPending.catch(() => null);
|
|
@@ -1048,6 +1064,8 @@ export {
|
|
|
1048
1064
|
CURSOR_AWARENESS_SPAWN_TIMEOUT_MS,
|
|
1049
1065
|
parseUnprocessedDogfoodItems,
|
|
1050
1066
|
colonyHostSection,
|
|
1067
|
+
UPDATE_NOTICE_SECTION_DEADLINE_MS,
|
|
1068
|
+
updateNoticeSection,
|
|
1051
1069
|
SESSION_START_SECTION_DEADLINE_MS,
|
|
1052
1070
|
withDeadline,
|
|
1053
1071
|
runSectionWithDeadline,
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatQueueLeaseRefusal,
|
|
3
|
+
inspectQueueLease
|
|
4
|
+
} from "./chunk-MFKHIWEL.js";
|
|
5
|
+
import {
|
|
6
|
+
NON_INTERACTIVE_ROOT_ARGS,
|
|
7
|
+
detectStaleCli,
|
|
8
|
+
formatRerunFlags,
|
|
9
|
+
formatStaleCliRefusal,
|
|
10
|
+
syncFromManifest
|
|
11
|
+
} from "./chunk-QLTGHJB3.js";
|
|
12
|
+
import {
|
|
13
|
+
formatSkippedSymlinks,
|
|
14
|
+
logApplyStats
|
|
15
|
+
} from "./chunk-HS7LVVLO.js";
|
|
16
|
+
import {
|
|
17
|
+
REGISTRY_CLI_ARGS,
|
|
18
|
+
resolveRegistryFromCli
|
|
19
|
+
} from "./chunk-PIMGV3E5.js";
|
|
20
|
+
import {
|
|
21
|
+
CLAUDE_SETTINGS_REL,
|
|
22
|
+
formatClaudeSettingsDrift,
|
|
23
|
+
formatPermissionsChanged,
|
|
24
|
+
planClaudeSettingsDrift,
|
|
25
|
+
writeClaudeSessionStartHook
|
|
26
|
+
} from "./chunk-NJ2SUSWX.js";
|
|
27
|
+
import {
|
|
28
|
+
generateClaudeCommandAdapters
|
|
29
|
+
} from "./chunk-EO5NGAYV.js";
|
|
30
|
+
import {
|
|
31
|
+
feedInstallsRegistry
|
|
32
|
+
} from "./chunk-WKFE3RUC.js";
|
|
33
|
+
import {
|
|
34
|
+
withCliProgress
|
|
35
|
+
} from "./chunk-QTON2GQX.js";
|
|
36
|
+
import {
|
|
37
|
+
logger
|
|
38
|
+
} from "./chunk-ZB43YMHW.js";
|
|
39
|
+
import {
|
|
40
|
+
RootRefusedError,
|
|
41
|
+
confirmProjectRoot,
|
|
42
|
+
isNonInteractive,
|
|
43
|
+
syncPathCliToRuntime
|
|
44
|
+
} from "./chunk-JGG574RK.js";
|
|
45
|
+
import {
|
|
46
|
+
checkForUpdates
|
|
47
|
+
} from "./chunk-M4UL422I.js";
|
|
48
|
+
import {
|
|
49
|
+
dropRetiredSkillIds,
|
|
50
|
+
formatRetiredSkillDrop
|
|
51
|
+
} from "./chunk-SAQ3EE5R.js";
|
|
52
|
+
import {
|
|
53
|
+
buildManifest,
|
|
54
|
+
canonicalizePackIds,
|
|
55
|
+
formatPackIdRewrite,
|
|
56
|
+
isProtectedPath,
|
|
57
|
+
loadAgentKitManifest,
|
|
58
|
+
resolveProtectedGlobs,
|
|
59
|
+
saveManifest
|
|
60
|
+
} from "./chunk-JG3CNGQM.js";
|
|
61
|
+
import {
|
|
62
|
+
seedManagedHashLedger
|
|
63
|
+
} from "./chunk-QX55T4UX.js";
|
|
64
|
+
import {
|
|
65
|
+
KIT_VERSION
|
|
66
|
+
} from "./chunk-7HDQEK6T.js";
|
|
67
|
+
|
|
68
|
+
// src/commands/update.ts
|
|
69
|
+
import { defineCommand } from "citty";
|
|
70
|
+
var UPDATE_RERUN_FLAGS = [
|
|
71
|
+
"claude",
|
|
72
|
+
"yes",
|
|
73
|
+
"force-root",
|
|
74
|
+
"force",
|
|
75
|
+
"seed-overlay",
|
|
76
|
+
"cwd",
|
|
77
|
+
"registry",
|
|
78
|
+
"url",
|
|
79
|
+
"ref",
|
|
80
|
+
"refresh"
|
|
81
|
+
];
|
|
82
|
+
var updateCommand = defineCommand({
|
|
83
|
+
meta: {
|
|
84
|
+
name: "update",
|
|
85
|
+
description: "Re-apply L0/packs/skills from the registry (never overwrites L3). --check = notify-only."
|
|
86
|
+
},
|
|
87
|
+
args: {
|
|
88
|
+
cwd: {
|
|
89
|
+
type: "string",
|
|
90
|
+
default: process.cwd()
|
|
91
|
+
},
|
|
92
|
+
check: {
|
|
93
|
+
type: "boolean",
|
|
94
|
+
description: "Check-only: compare installed version to the resolved registry (public tags, or --registry local checkout); never apply L0 writes",
|
|
95
|
+
default: false
|
|
96
|
+
},
|
|
97
|
+
json: {
|
|
98
|
+
type: "boolean",
|
|
99
|
+
description: "Print machine-readable JSON (with --check)",
|
|
100
|
+
default: false
|
|
101
|
+
},
|
|
102
|
+
"respect-prefs": {
|
|
103
|
+
type: "boolean",
|
|
104
|
+
description: "Honor updateCheck.enabled and intervalDays from .cursor/context/config.json (hooks)",
|
|
105
|
+
default: false
|
|
106
|
+
},
|
|
107
|
+
stamp: {
|
|
108
|
+
type: "boolean",
|
|
109
|
+
description: "Persist updateCheck.lastCheckedAt after a network check",
|
|
110
|
+
default: false
|
|
111
|
+
},
|
|
112
|
+
"seed-overlay": {
|
|
113
|
+
type: "boolean",
|
|
114
|
+
description: "Seed the managed-hash ledger from current local overlay files before applying (factory/dogfood only; consumers should not use this)",
|
|
115
|
+
default: false
|
|
116
|
+
},
|
|
117
|
+
"allow-stale-cli": {
|
|
118
|
+
type: "boolean",
|
|
119
|
+
description: "Apply even when this CLI is older than the registry it is syncing from; the manifest is then stamped with this CLI's version, not the registry's (factory/dev only)",
|
|
120
|
+
default: false
|
|
121
|
+
},
|
|
122
|
+
force: {
|
|
123
|
+
type: "boolean",
|
|
124
|
+
description: "Apply even while another live writer holds the queue lease (.cursor/context/run-plan-all.lock); an operator choice, never a default",
|
|
125
|
+
default: false
|
|
126
|
+
},
|
|
127
|
+
claude: {
|
|
128
|
+
type: "boolean",
|
|
129
|
+
description: "Also apply the ledger-aware Claude settings merge (.claude/settings.json + ledger) and generate the .claude/commands/* pointer adapters with install --claude authority; operator opt-in, never from hooks or plan-loop",
|
|
130
|
+
default: false
|
|
131
|
+
},
|
|
132
|
+
all: {
|
|
133
|
+
type: "boolean",
|
|
134
|
+
description: "Operator-typed only: update every repo in the machine install registry, one branch chore/kit-X.Y.Z and one PR/MR per repo after one plan table and one confirm; refuses without a TTY or inside an agent session; never merges",
|
|
135
|
+
default: false
|
|
136
|
+
},
|
|
137
|
+
"include-worktrees": {
|
|
138
|
+
type: "boolean",
|
|
139
|
+
description: "With --all: also update linked git worktrees (excluded by default)",
|
|
140
|
+
default: false
|
|
141
|
+
},
|
|
142
|
+
...NON_INTERACTIVE_ROOT_ARGS,
|
|
143
|
+
...REGISTRY_CLI_ARGS
|
|
144
|
+
},
|
|
145
|
+
async run({ args }) {
|
|
146
|
+
if (args.all) {
|
|
147
|
+
if (args.check) {
|
|
148
|
+
logger.error(
|
|
149
|
+
"--all and --check do not combine; use agent-kit installs list to see versions."
|
|
150
|
+
);
|
|
151
|
+
process.exitCode = 1;
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const { runUpdateAll } = await import("./update-all-YYUTXHGR.js");
|
|
155
|
+
const result2 = await runUpdateAll({
|
|
156
|
+
includeWorktrees: args["include-worktrees"],
|
|
157
|
+
applyOptions: {
|
|
158
|
+
registry: args.registry,
|
|
159
|
+
url: args.url,
|
|
160
|
+
ref: args.ref,
|
|
161
|
+
refresh: args.refresh
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
const failed = result2.results.some((r) => r.outcome.status === "error");
|
|
165
|
+
if (result2.status === "refused" || result2.status === "preflight-stop" || failed) {
|
|
166
|
+
process.exitCode = 1;
|
|
167
|
+
}
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (args.check) {
|
|
171
|
+
const result2 = await checkForUpdates(args.cwd, {
|
|
172
|
+
respectPrefs: Boolean(args["respect-prefs"]),
|
|
173
|
+
stamp: Boolean(args.stamp),
|
|
174
|
+
publicRegistryUrl: typeof args.url === "string" && args.url ? args.url : void 0,
|
|
175
|
+
registryPath: typeof args.registry === "string" && args.registry ? args.registry : void 0
|
|
176
|
+
});
|
|
177
|
+
if (args.json) {
|
|
178
|
+
console.log(JSON.stringify(result2, null, 2));
|
|
179
|
+
} else {
|
|
180
|
+
const line = `[${result2.status}] ${result2.message}`;
|
|
181
|
+
if (result2.status === "error") logger.error(line);
|
|
182
|
+
else if (result2.status === "update-available") logger.warn(line);
|
|
183
|
+
else if (result2.status.startsWith("skipped-")) logger.warn(line);
|
|
184
|
+
else logger.info(line);
|
|
185
|
+
}
|
|
186
|
+
if (result2.status === "error") process.exitCode = 2;
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const nonInteractive = args.yes || isNonInteractive();
|
|
190
|
+
let projectRoot;
|
|
191
|
+
try {
|
|
192
|
+
projectRoot = await confirmProjectRoot(args.cwd, {
|
|
193
|
+
nonInteractive,
|
|
194
|
+
command: "update",
|
|
195
|
+
forceRoot: args["force-root"]
|
|
196
|
+
});
|
|
197
|
+
} catch (err) {
|
|
198
|
+
if (err instanceof RootRefusedError) {
|
|
199
|
+
logger.error(err.message);
|
|
200
|
+
if (err.recovery) console.error(`
|
|
201
|
+
${err.recovery}
|
|
202
|
+
`);
|
|
203
|
+
process.exitCode = 1;
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
throw err;
|
|
207
|
+
}
|
|
208
|
+
const result = await applyUpdateAtRoot(projectRoot, {
|
|
209
|
+
registry: args.registry,
|
|
210
|
+
url: args.url,
|
|
211
|
+
ref: args.ref,
|
|
212
|
+
refresh: args.refresh,
|
|
213
|
+
force: args.force,
|
|
214
|
+
allowStaleCli: args["allow-stale-cli"],
|
|
215
|
+
seedOverlay: args["seed-overlay"],
|
|
216
|
+
claude: args.claude,
|
|
217
|
+
rerun: formatRerunFlags(args, UPDATE_RERUN_FLAGS),
|
|
218
|
+
syncPathCli: true
|
|
219
|
+
});
|
|
220
|
+
if (result.status === "refused" || result.status === "failed") process.exitCode = 1;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
async function applyUpdateAtRoot(projectRoot, options = {}) {
|
|
224
|
+
const existing = await loadAgentKitManifest(projectRoot, { onWarning: logger.warn });
|
|
225
|
+
if (!existing) {
|
|
226
|
+
logger.warn("No .cursor/agent-kit.json \u2014 run agent-kit install first.");
|
|
227
|
+
return { status: "no-manifest" };
|
|
228
|
+
}
|
|
229
|
+
const lease = inspectQueueLease(projectRoot);
|
|
230
|
+
if (lease.kind === "held" && !options.force) {
|
|
231
|
+
const reason = formatQueueLeaseRefusal(lease, {
|
|
232
|
+
what: "another live session writes this workspace, so update will not rewrite L0",
|
|
233
|
+
next: "run agent-kit update again (--force applies anyway; operator choice)"
|
|
234
|
+
});
|
|
235
|
+
logger.error(reason);
|
|
236
|
+
return { status: "refused", reason };
|
|
237
|
+
}
|
|
238
|
+
const registry = await resolveRegistryFromCli({
|
|
239
|
+
cwd: projectRoot,
|
|
240
|
+
registry: options.registry,
|
|
241
|
+
url: options.url,
|
|
242
|
+
ref: options.ref,
|
|
243
|
+
refresh: options.refresh,
|
|
244
|
+
manifest: existing
|
|
245
|
+
});
|
|
246
|
+
try {
|
|
247
|
+
logger.info(`Registry: ${registry.root} (${registry.source})`);
|
|
248
|
+
const stale = await detectStaleCli(registry.root, { warn: logger.warn });
|
|
249
|
+
if (stale && !options.allowStaleCli) {
|
|
250
|
+
const refusal = formatStaleCliRefusal({
|
|
251
|
+
command: "update",
|
|
252
|
+
stale,
|
|
253
|
+
rerun: options.rerun ?? ""
|
|
254
|
+
});
|
|
255
|
+
logger.error(refusal.error);
|
|
256
|
+
console.error(refusal.recovery);
|
|
257
|
+
return { status: "refused", reason: refusal.error };
|
|
258
|
+
}
|
|
259
|
+
const packIds = await canonicalizePackIds(registry.root, existing.packs);
|
|
260
|
+
const retiredSkills = dropRetiredSkillIds(existing.skills);
|
|
261
|
+
const next = buildManifest({
|
|
262
|
+
version: KIT_VERSION,
|
|
263
|
+
profile: existing.profile,
|
|
264
|
+
packs: packIds.packs,
|
|
265
|
+
skills: retiredSkills.skills,
|
|
266
|
+
protected: existing.protected,
|
|
267
|
+
// Restamp generatorVersion with the CLI that ran this apply so the two
|
|
268
|
+
// version fields in the manifest stop disagreeing after an update. The
|
|
269
|
+
// personalization result file itself is not regenerated here.
|
|
270
|
+
personalization: existing.personalization ? { ...existing.personalization, generatorVersion: KIT_VERSION } : void 0,
|
|
271
|
+
registryUrl: registry.url ?? existing.registry?.url,
|
|
272
|
+
registryRef: registry.ref ?? existing.registry?.ref
|
|
273
|
+
});
|
|
274
|
+
if (existing.overrides?.length) next.overrides = existing.overrides;
|
|
275
|
+
if (existing.unknownFields) next.unknownFields = existing.unknownFields;
|
|
276
|
+
if (next.version === existing.version && existing.installedAt) {
|
|
277
|
+
next.installedAt = existing.installedAt;
|
|
278
|
+
}
|
|
279
|
+
if (options.seedOverlay) {
|
|
280
|
+
await seedManagedHashLedger(projectRoot);
|
|
281
|
+
logger.info("Seeded managed-hash ledger from current local overlay files.");
|
|
282
|
+
}
|
|
283
|
+
const stats = await withCliProgress(
|
|
284
|
+
"update",
|
|
285
|
+
() => syncFromManifest(registry.root, projectRoot, next)
|
|
286
|
+
);
|
|
287
|
+
if (stats.skippedSymlink.length > 0) {
|
|
288
|
+
logApplyStats(stats);
|
|
289
|
+
const reason = formatSkippedSymlinks(stats.skippedSymlink);
|
|
290
|
+
logger.error(reason);
|
|
291
|
+
return { status: "failed", reason };
|
|
292
|
+
}
|
|
293
|
+
if (options.claude) {
|
|
294
|
+
const claude = await writeClaudeSessionStartHook(projectRoot, { authorized: true });
|
|
295
|
+
if (claude.status === "skipped-symlink") {
|
|
296
|
+
logApplyStats(stats);
|
|
297
|
+
const reason = `Claude settings not written: ${CLAUDE_SETTINGS_REL}, .claude/ or the ledger resolves outside the project (symlink). Nothing was changed there.`;
|
|
298
|
+
logger.error(reason);
|
|
299
|
+
return { status: "failed", reason };
|
|
300
|
+
}
|
|
301
|
+
if (claude.status === "unavailable") {
|
|
302
|
+
logger.warn(claude.instructions ?? `${CLAUDE_SETTINGS_REL} could not be merged.`);
|
|
303
|
+
} else {
|
|
304
|
+
console.log(`Claude settings ${claude.status}: ${claude.relativePath}`);
|
|
305
|
+
const changed = formatPermissionsChanged(claude.permissionChanges ?? [], {
|
|
306
|
+
mergeAllowWithoutGuard: claude.mergeAllowWithoutGuard ?? []
|
|
307
|
+
});
|
|
308
|
+
for (const line of changed) console.log(line);
|
|
309
|
+
}
|
|
310
|
+
const adapters = await generateClaudeCommandAdapters(projectRoot);
|
|
311
|
+
const skipped = adapters.filter((a) => a.status === "skipped-symlink");
|
|
312
|
+
if (skipped.length > 0) {
|
|
313
|
+
logApplyStats(stats);
|
|
314
|
+
const reason = `Claude command adapters not written for: ${skipped.map((a) => a.relativePath).join(", ")} (symlink outside the project). Nothing was changed there.`;
|
|
315
|
+
logger.error(reason);
|
|
316
|
+
return { status: "failed", reason };
|
|
317
|
+
}
|
|
318
|
+
if (adapters.length > 0) console.log(formatClaudeAdapterSummary(adapters));
|
|
319
|
+
} else {
|
|
320
|
+
const drift = await planClaudeSettingsDrift(projectRoot);
|
|
321
|
+
if (drift) {
|
|
322
|
+
const protectedPath = isProtectedPath(CLAUDE_SETTINGS_REL, resolveProtectedGlobs(next));
|
|
323
|
+
for (const line of formatClaudeSettingsDrift(drift, { protectedPath })) console.log(line);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
await saveManifest(projectRoot, next);
|
|
327
|
+
for (const rewrite of packIds.rewrites) logger.info(formatPackIdRewrite(rewrite));
|
|
328
|
+
for (const id of retiredSkills.dropped) logger.info(formatRetiredSkillDrop(id));
|
|
329
|
+
logApplyStats(stats);
|
|
330
|
+
const transition = next.version === existing.version ? `unchanged at v${next.version}` : `v${existing.version} \u2192 v${next.version}`;
|
|
331
|
+
logger.success(`Update complete: ${transition} (L3 protected paths left untouched).`);
|
|
332
|
+
await feedInstallsRegistry(projectRoot);
|
|
333
|
+
if (options.syncPathCli) {
|
|
334
|
+
const sync = await syncPathCliToRuntime({ runtimeVersion: KIT_VERSION });
|
|
335
|
+
for (const line of sync.lines) console.log(line);
|
|
336
|
+
}
|
|
337
|
+
return { status: "applied", fromVersion: existing.version, toVersion: next.version, stats };
|
|
338
|
+
} finally {
|
|
339
|
+
await registry.unlock?.();
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function formatClaudeAdapterSummary(results) {
|
|
343
|
+
const count = (status) => results.filter((r) => r.status === status).length;
|
|
344
|
+
const parts = [
|
|
345
|
+
`${count("applied")} written`,
|
|
346
|
+
`${count("refreshed")} refreshed`,
|
|
347
|
+
`${count("unchanged")} unchanged`
|
|
348
|
+
];
|
|
349
|
+
const customized = count("preserved-customized");
|
|
350
|
+
if (customized > 0) parts.push(`${customized} preserved (customized)`);
|
|
351
|
+
return `Claude command adapters: ${parts.join(", ")} (.claude/commands/)`;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export {
|
|
355
|
+
updateCommand,
|
|
356
|
+
applyUpdateAtRoot
|
|
357
|
+
};
|