@dadado/agent-kit-cli 6.23.0 → 6.26.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 +48 -7
- package/dashboard/lib/guards.mjs +1 -0
- package/dashboard/lib/live-refresh.mjs +1 -0
- package/dist/{add-RKZQX6ZK.js → add-G7KEZLWP.js} +17 -8
- package/dist/{chunk-7HDQEK6T.js → chunk-2G4K4ZI5.js} +7 -3
- package/dist/{chunk-5PSV76CQ.js → chunk-2GXN7HVG.js} +26 -7
- package/dist/chunk-2QYWMSI5.js +193 -0
- package/dist/{chunk-B3VR5YBQ.js → chunk-2TW7ENWC.js} +12 -11
- package/dist/{chunk-IESSMKOV.js → chunk-5A72LTR3.js} +7 -7
- package/dist/{chunk-R4DUO5DA.js → chunk-AXQMVQ6O.js} +61 -237
- package/dist/{chunk-6WUKLS4D.js → chunk-BIFTTL2O.js} +1 -1
- package/dist/{chunk-AWQ6KRFV.js → chunk-BVZDPVUL.js} +1 -1
- package/dist/{chunk-QNISTPPZ.js → chunk-ENRXS5O6.js} +19 -12
- package/dist/chunk-FB6G6OD6.js +519 -0
- package/dist/{chunk-MFKHIWEL.js → chunk-FOVHFMSH.js} +1 -1
- package/dist/{chunk-6BEFGKCU.js → chunk-FUSNEYGU.js} +29 -3
- package/dist/chunk-H7KAXI5R.js +357 -0
- package/dist/chunk-HGB4DHXV.js +138 -0
- package/dist/{chunk-W3ZJVBNY.js → chunk-HXV6VQD4.js} +2374 -983
- package/dist/{chunk-BGL5DRK2.js → chunk-I3FGWNU5.js} +4 -4
- package/dist/chunk-IHVJTGYR.js +144 -0
- package/dist/{chunk-5LNHRL5E.js → chunk-IUY24WPE.js} +93 -263
- package/dist/chunk-JG5MKMOM.js +248 -0
- package/dist/{chunk-SGTTC2JP.js → chunk-JWIJHO67.js} +17 -2
- package/dist/chunk-KMK4T4ZM.js +34 -0
- package/dist/{chunk-ZMYV6PRE.js → chunk-LEVNLHH3.js} +2 -1
- package/dist/{chunk-2IP4OO6R.js → chunk-MGVV6YC4.js} +1 -1
- package/dist/{chunk-7TYA3GMI.js → chunk-MWRYQLEG.js} +7 -4
- package/dist/chunk-NHJ4IAVN.js +435 -0
- package/dist/{chunk-C4Q77GGJ.js → chunk-O7VMHCNN.js} +6 -0
- package/dist/{chunk-5EBT3V7G.js → chunk-OVRGTHZD.js} +1 -1
- package/dist/{chunk-F7YAAKYP.js → chunk-PCIYXGB3.js} +7 -5
- package/dist/{chunk-UJCATSYO.js → chunk-PLLXFSN2.js} +46 -17
- package/dist/{chunk-OYFCBYMP.js → chunk-RJP47EGS.js} +18 -1
- package/dist/{chunk-KDJ4ML7I.js → chunk-RRJVC35Y.js} +4 -4
- package/dist/{chunk-DRZFWIBN.js → chunk-SWJJW624.js} +1 -1
- package/dist/{chunk-MJJBIOSY.js → chunk-SYRJ5TTK.js} +34 -12
- package/dist/{chunk-L5V3W3DY.js → chunk-TTUFIE26.js} +60 -14
- package/dist/{chunk-JFS4GKP7.js → chunk-XXPI4H4D.js} +2 -2
- package/dist/{chunk-CVZNSRXV.js → chunk-Y5526WCN.js} +84 -19
- package/dist/{chunk-CQHD6UKB.js → chunk-Y575INEC.js} +2 -1
- package/dist/{chunk-V2H57TFD.js → chunk-ZNZHDPS3.js} +80 -170
- package/dist/{commands-SAQEEE6V.js → commands-K4HSDML5.js} +8 -6
- package/dist/{conflicts-5JOP4GX2.js → conflicts-4SUWIPWP.js} +9 -10
- package/dist/{contribute-BQKRT5GN.js → contribute-HE4WCBRY.js} +7 -5
- package/dist/{countdown-25E5C7AR.js → countdown-TYQHVAIX.js} +305 -32
- package/dist/{dashboard-P65XHYCU.js → dashboard-6V6PCNYF.js} +1 -1
- package/dist/{dashboard-broadcast-GYK34QYL.js → dashboard-broadcast-PMVQ7PXU.js} +1 -1
- package/dist/{diff-6JSXBVSX.js → diff-3XUZM7ZT.js} +15 -6
- package/dist/{doctor-I3MTHS7F.js → doctor-KGUWU5SN.js} +106 -19
- package/dist/{engine-info-BBI5QO5Y.js → engine-info-VM4VPGQM.js} +2 -2
- package/dist/{ground-control-IDCXN5FK.js → ground-control-ZIDHEOPW.js} +7 -4
- package/dist/{guard-RJZEEKSL.js → guard-ZO4Z3LLB.js} +47 -9
- package/dist/{handoff-5AGE2D3T.js → handoff-LLT4CI6H.js} +4 -3
- package/dist/{hook-WNA42CXE.js → hook-UPZ3CPYS.js} +22 -20
- package/dist/index.js +51 -33
- package/dist/{init-FZ2UFPO7.js → init-ZHLVXEVT.js} +25 -18
- package/dist/install-XWOG64W3.js +42 -0
- package/dist/installs-2ROXPO6M.js +223 -0
- package/dist/{mission-control-CRMCRZUU.js → mission-control-IGOI3WHS.js} +2 -2
- package/dist/models-5BDXREWM.js +45 -0
- package/dist/paths-JTPV6SXH.js +107 -0
- package/dist/pi-DCMDOY65.js +248 -0
- package/dist/{plan-index-BNLUU6T5.js → plan-index-5QZJK4AG.js} +2 -3
- package/dist/{queue-JW4VR33H.js → queue-Z5VNNHM6.js} +10 -12
- package/dist/{run-X2WOONTB.js → run-QURAXAR2.js} +27 -33
- package/dist/{run-plan-4MOLLIES.js → run-plan-4MMHVCTS.js} +35 -23
- package/dist/{scan-K3T5RQLC.js → scan-7D3RMO34.js} +2 -1
- package/dist/{session-start-MV7A4263.js → session-start-NC2HE5X5.js} +20 -14
- package/dist/{sessions-UPFDWDMB.js → sessions-WWWLYPW6.js} +4 -4
- package/dist/{setup-global-VNADNTQ2.js → setup-global-WDMARD4Z.js} +12 -10
- package/dist/{status-SXA3OK5E.js → status-2WNJL7PP.js} +17 -13
- package/dist/update-YSVOYYK5.js +32 -0
- package/dist/update-all-5XLTCHPX.js +697 -0
- package/package.json +14 -4
- package/pi/agent-kit.ts +224 -0
- package/dist/chunk-4MR4QXMF.js +0 -52
- package/dist/chunk-7ABY6DYH.js +0 -89
- package/dist/chunk-C4LCOOL4.js +0 -71
- package/dist/chunk-DZCLMIAS.js +0 -391
- package/dist/chunk-HAFRAXGV.js +0 -17
- package/dist/chunk-MUTTNRX4.js +0 -53
- package/dist/install-CTLT3TSI.js +0 -38
- package/dist/update-RMAWXMCV.js +0 -304
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import {
|
|
2
|
+
acquireDirLock
|
|
3
|
+
} from "./chunk-IHVJTGYR.js";
|
|
4
|
+
import {
|
|
5
|
+
MANIFEST_RELATIVE_PATH
|
|
6
|
+
} from "./chunk-KMK4T4ZM.js";
|
|
7
|
+
import {
|
|
8
|
+
KIT_VERSION
|
|
9
|
+
} from "./chunk-2G4K4ZI5.js";
|
|
10
|
+
import {
|
|
11
|
+
fileExists
|
|
12
|
+
} from "./chunk-5B4DVO6C.js";
|
|
13
|
+
|
|
14
|
+
// src/installs/inspect.ts
|
|
15
|
+
import { execFile } from "child_process";
|
|
16
|
+
import { readFile, realpath } from "fs/promises";
|
|
17
|
+
import { homedir, tmpdir } from "os";
|
|
18
|
+
import path from "path";
|
|
19
|
+
import { promisify } from "util";
|
|
20
|
+
var execFileAsync = promisify(execFile);
|
|
21
|
+
var FACTORY_REMOTE_MARKERS = ["agent-kit-dev"];
|
|
22
|
+
var FACTORY_CLI_PACKAGES = /* @__PURE__ */ new Set(["@dadado/agent-kit-cli", "@missionkit/cli"]);
|
|
23
|
+
var FIXTURE_SEGMENTS = /* @__PURE__ */ new Set([
|
|
24
|
+
"fixtures",
|
|
25
|
+
"__fixtures__",
|
|
26
|
+
"test-fixtures",
|
|
27
|
+
"testdata",
|
|
28
|
+
"__tests__"
|
|
29
|
+
]);
|
|
30
|
+
function sanitizeRemote(url) {
|
|
31
|
+
if (!url) return null;
|
|
32
|
+
const trimmed = url.trim();
|
|
33
|
+
if (!trimmed) return null;
|
|
34
|
+
try {
|
|
35
|
+
const parsed = new URL(trimmed);
|
|
36
|
+
if (parsed.username || parsed.password) {
|
|
37
|
+
parsed.username = "";
|
|
38
|
+
parsed.password = "";
|
|
39
|
+
return parsed.toString();
|
|
40
|
+
}
|
|
41
|
+
return trimmed;
|
|
42
|
+
} catch {
|
|
43
|
+
return trimmed;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function isUnder(child, parent) {
|
|
47
|
+
const rel = path.relative(parent, child);
|
|
48
|
+
return rel === "" || !rel.startsWith("..") && !path.isAbsolute(rel);
|
|
49
|
+
}
|
|
50
|
+
function isFactoryInstall(facts) {
|
|
51
|
+
const origin = facts.origin?.toLowerCase() ?? "";
|
|
52
|
+
if (FACTORY_REMOTE_MARKERS.some((m) => origin.includes(m))) return true;
|
|
53
|
+
return facts.cliPackageName !== null && FACTORY_CLI_PACKAGES.has(facts.cliPackageName);
|
|
54
|
+
}
|
|
55
|
+
function classifyInstall(facts) {
|
|
56
|
+
if (facts.path === facts.home) return "home";
|
|
57
|
+
if (facts.tmpRoots.some((root) => isUnder(facts.path, root))) return "fixture";
|
|
58
|
+
const rel = path.relative(facts.home, facts.path);
|
|
59
|
+
const segments = (isUnder(facts.path, facts.home) ? rel : facts.path).split(path.sep);
|
|
60
|
+
if (segments.some((s) => FIXTURE_SEGMENTS.has(s))) return "fixture";
|
|
61
|
+
if (facts.git && facts.git.toplevel !== facts.path) return "fixture";
|
|
62
|
+
if (isFactoryInstall(facts)) return "factory";
|
|
63
|
+
if (facts.git && facts.git.gitDir !== facts.git.commonDir) return "worktree";
|
|
64
|
+
return "repo";
|
|
65
|
+
}
|
|
66
|
+
function gitEnv() {
|
|
67
|
+
const env = { ...process.env };
|
|
68
|
+
for (const key of [
|
|
69
|
+
"GIT_DIR",
|
|
70
|
+
"GIT_WORK_TREE",
|
|
71
|
+
"GIT_COMMON_DIR",
|
|
72
|
+
"GIT_INDEX_FILE",
|
|
73
|
+
"GIT_OBJECT_DIRECTORY",
|
|
74
|
+
"GIT_ALTERNATE_OBJECT_DIRECTORIES",
|
|
75
|
+
"GIT_CEILING_DIRECTORIES"
|
|
76
|
+
]) {
|
|
77
|
+
delete env[key];
|
|
78
|
+
}
|
|
79
|
+
return env;
|
|
80
|
+
}
|
|
81
|
+
async function safeRealpath(p) {
|
|
82
|
+
try {
|
|
83
|
+
return await realpath(p);
|
|
84
|
+
} catch {
|
|
85
|
+
return path.resolve(p);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
async function readGitFacts(dir) {
|
|
89
|
+
try {
|
|
90
|
+
const { stdout } = await execFileAsync(
|
|
91
|
+
"git",
|
|
92
|
+
["rev-parse", "--path-format=absolute", "--show-toplevel", "--git-dir", "--git-common-dir"],
|
|
93
|
+
{ cwd: dir, env: gitEnv(), encoding: "utf8", timeout: 5e3 }
|
|
94
|
+
);
|
|
95
|
+
const [toplevel, gitDir, commonDir] = stdout.trim().split("\n");
|
|
96
|
+
if (!toplevel || !gitDir || !commonDir) return null;
|
|
97
|
+
return {
|
|
98
|
+
toplevel: await safeRealpath(toplevel),
|
|
99
|
+
gitDir: await safeRealpath(gitDir),
|
|
100
|
+
commonDir: await safeRealpath(commonDir)
|
|
101
|
+
};
|
|
102
|
+
} catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async function readOrigin(dir) {
|
|
107
|
+
try {
|
|
108
|
+
const { stdout } = await execFileAsync("git", ["remote", "get-url", "origin"], {
|
|
109
|
+
cwd: dir,
|
|
110
|
+
env: gitEnv(),
|
|
111
|
+
encoding: "utf8",
|
|
112
|
+
timeout: 5e3
|
|
113
|
+
});
|
|
114
|
+
return stdout.trim() || null;
|
|
115
|
+
} catch {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async function readCliPackageName(dir) {
|
|
120
|
+
try {
|
|
121
|
+
const raw = await readFile(path.join(dir, "packages", "cli", "package.json"), "utf8");
|
|
122
|
+
const name = JSON.parse(raw).name;
|
|
123
|
+
return typeof name === "string" ? name : null;
|
|
124
|
+
} catch {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async function readManifestVersion(dir) {
|
|
129
|
+
let raw;
|
|
130
|
+
try {
|
|
131
|
+
raw = await readFile(path.join(dir, MANIFEST_RELATIVE_PATH), "utf8");
|
|
132
|
+
} catch {
|
|
133
|
+
return void 0;
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
const version = JSON.parse(raw).version;
|
|
137
|
+
return typeof version === "string" && version.trim() ? version.trim() : null;
|
|
138
|
+
} catch {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function hasInstallManifest(dir) {
|
|
143
|
+
return fileExists(path.join(dir, MANIFEST_RELATIVE_PATH));
|
|
144
|
+
}
|
|
145
|
+
async function defaultTmpRoots() {
|
|
146
|
+
const roots = /* @__PURE__ */ new Set([await safeRealpath(tmpdir())]);
|
|
147
|
+
if (process.platform !== "win32") roots.add(await safeRealpath("/tmp"));
|
|
148
|
+
return [...roots];
|
|
149
|
+
}
|
|
150
|
+
async function inspectInstall(dir, options = {}) {
|
|
151
|
+
const installPath = await safeRealpath(dir);
|
|
152
|
+
const kitVersion = await readManifestVersion(installPath);
|
|
153
|
+
if (kitVersion === void 0) return null;
|
|
154
|
+
const home = await safeRealpath(options.home ?? homedir());
|
|
155
|
+
const tmpRoots = options.tmpRoots ? await Promise.all(options.tmpRoots.map(safeRealpath)) : await defaultTmpRoots();
|
|
156
|
+
const git = await readGitFacts(installPath);
|
|
157
|
+
const origin = git && git.toplevel === installPath ? await readOrigin(installPath) : null;
|
|
158
|
+
const facts = {
|
|
159
|
+
path: installPath,
|
|
160
|
+
home,
|
|
161
|
+
tmpRoots,
|
|
162
|
+
git,
|
|
163
|
+
origin,
|
|
164
|
+
cliPackageName: await readCliPackageName(installPath)
|
|
165
|
+
};
|
|
166
|
+
return {
|
|
167
|
+
path: installPath,
|
|
168
|
+
remote: sanitizeRemote(origin),
|
|
169
|
+
kitVersion,
|
|
170
|
+
cliVersion: options.cliVersion ?? KIT_VERSION,
|
|
171
|
+
kind: classifyInstall(facts)
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/installs/store.ts
|
|
176
|
+
import { randomUUID } from "crypto";
|
|
177
|
+
import { mkdir, readFile as readFile2, rename, rm, writeFile } from "fs/promises";
|
|
178
|
+
import { homedir as homedir2 } from "os";
|
|
179
|
+
import path2 from "path";
|
|
180
|
+
var INSTALLS_SCHEMA_VERSION = 1;
|
|
181
|
+
var INSTALLS_FILENAME = "installs.json";
|
|
182
|
+
var INSTALLS_FILE_ENV = "AGENT_KIT_INSTALLS_FILE";
|
|
183
|
+
var INSTALL_KINDS = [
|
|
184
|
+
"repo",
|
|
185
|
+
"worktree",
|
|
186
|
+
"fixture",
|
|
187
|
+
"factory",
|
|
188
|
+
"home"
|
|
189
|
+
];
|
|
190
|
+
var InstallsRegistryError = class extends Error {
|
|
191
|
+
constructor(message, file) {
|
|
192
|
+
super(message);
|
|
193
|
+
this.file = file;
|
|
194
|
+
this.name = "InstallsRegistryError";
|
|
195
|
+
}
|
|
196
|
+
file;
|
|
197
|
+
};
|
|
198
|
+
function resolveInstallsFile(env = process.env, home = homedir2()) {
|
|
199
|
+
const override = env[INSTALLS_FILE_ENV]?.trim();
|
|
200
|
+
if (override) return path2.resolve(override);
|
|
201
|
+
const xdg = env.XDG_CONFIG_HOME?.trim();
|
|
202
|
+
const configDir = xdg && path2.isAbsolute(xdg) ? xdg : path2.join(home, ".config");
|
|
203
|
+
return path2.join(configDir, "agent-kit", INSTALLS_FILENAME);
|
|
204
|
+
}
|
|
205
|
+
function isInstallEntry(value) {
|
|
206
|
+
if (!value || typeof value !== "object") return false;
|
|
207
|
+
const e = value;
|
|
208
|
+
return typeof e.path === "string" && path2.isAbsolute(e.path) && (e.remote === null || typeof e.remote === "string") && (e.kitVersion === null || typeof e.kitVersion === "string") && typeof e.cliVersion === "string" && typeof e.lastSeen === "string" && INSTALL_KINDS.includes(e.kind);
|
|
209
|
+
}
|
|
210
|
+
function parseInstallsFile(raw, file) {
|
|
211
|
+
let parsed;
|
|
212
|
+
try {
|
|
213
|
+
parsed = JSON.parse(raw);
|
|
214
|
+
} catch {
|
|
215
|
+
throw new InstallsRegistryError(
|
|
216
|
+
`${file} is not valid JSON; move it aside and run \`agent-kit installs scan\` to rebuild it.`,
|
|
217
|
+
file
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
const body = parsed;
|
|
221
|
+
if (!body || typeof body !== "object" || !Array.isArray(body.installs)) {
|
|
222
|
+
throw new InstallsRegistryError(
|
|
223
|
+
`${file} has no installs list; move it aside and run \`agent-kit installs scan\` to rebuild it.`,
|
|
224
|
+
file
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
if (body.schemaVersion !== INSTALLS_SCHEMA_VERSION) {
|
|
228
|
+
throw new InstallsRegistryError(
|
|
229
|
+
`${file} has schemaVersion ${String(body.schemaVersion)}; this CLI understands ${INSTALLS_SCHEMA_VERSION} (newer CLI?). Left untouched.`,
|
|
230
|
+
file
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
const installs = body.installs.filter(isInstallEntry);
|
|
234
|
+
const unrecognized = body.installs.filter((row) => !isInstallEntry(row));
|
|
235
|
+
return { schemaVersion: INSTALLS_SCHEMA_VERSION, installs, unrecognized };
|
|
236
|
+
}
|
|
237
|
+
async function readInstalls(options = {}) {
|
|
238
|
+
const file = options.file ?? resolveInstallsFile();
|
|
239
|
+
let raw;
|
|
240
|
+
try {
|
|
241
|
+
raw = await readFile2(file, "utf8");
|
|
242
|
+
} catch (err) {
|
|
243
|
+
if (err.code === "ENOENT") {
|
|
244
|
+
return { schemaVersion: INSTALLS_SCHEMA_VERSION, installs: [] };
|
|
245
|
+
}
|
|
246
|
+
throw err;
|
|
247
|
+
}
|
|
248
|
+
return parseInstallsFile(raw, file);
|
|
249
|
+
}
|
|
250
|
+
async function listInstalls(options = {}) {
|
|
251
|
+
const { installs } = await readInstalls(options);
|
|
252
|
+
return [...installs].sort((a, b) => a.path.localeCompare(b.path));
|
|
253
|
+
}
|
|
254
|
+
async function writeInstallsFile(file, body) {
|
|
255
|
+
await mkdir(path2.dirname(file), { recursive: true });
|
|
256
|
+
const tmp = `${file}.${process.pid}.${randomUUID()}.tmp`;
|
|
257
|
+
const known = new Set(body.installs.map((e) => e.path));
|
|
258
|
+
const kept = (body.unrecognized ?? []).filter((row) => {
|
|
259
|
+
const rowPath = row?.path;
|
|
260
|
+
return !(typeof rowPath === "string" && known.has(rowPath));
|
|
261
|
+
});
|
|
262
|
+
const sorted = {
|
|
263
|
+
schemaVersion: INSTALLS_SCHEMA_VERSION,
|
|
264
|
+
installs: [...[...body.installs].sort((a, b) => a.path.localeCompare(b.path)), ...kept]
|
|
265
|
+
};
|
|
266
|
+
try {
|
|
267
|
+
await writeFile(tmp, `${JSON.stringify(sorted, null, 2)}
|
|
268
|
+
`, "utf8");
|
|
269
|
+
await rename(tmp, file);
|
|
270
|
+
} catch (err) {
|
|
271
|
+
await rm(tmp, { force: true }).catch(() => void 0);
|
|
272
|
+
throw err;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
async function mutateInstalls(options, mutate) {
|
|
276
|
+
const file = options.file ?? resolveInstallsFile();
|
|
277
|
+
const unlock = await acquireDirLock(file, {
|
|
278
|
+
timeoutMs: options.lockTimeoutMs,
|
|
279
|
+
timeoutMessage: (target) => `Timed out waiting for the install registry lock on ${target}. Another agent-kit process may be stuck.`
|
|
280
|
+
});
|
|
281
|
+
try {
|
|
282
|
+
const current = await readInstalls({ file });
|
|
283
|
+
const { installs, result, changed } = await mutate(current.installs);
|
|
284
|
+
if (changed) {
|
|
285
|
+
await writeInstallsFile(file, {
|
|
286
|
+
schemaVersion: INSTALLS_SCHEMA_VERSION,
|
|
287
|
+
installs,
|
|
288
|
+
unrecognized: current.unrecognized
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
return result;
|
|
292
|
+
} finally {
|
|
293
|
+
await unlock();
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
async function upsertInstalls(records, options = {}) {
|
|
297
|
+
if (records.length === 0) return [];
|
|
298
|
+
const now = (options.now ?? (() => /* @__PURE__ */ new Date()))().toISOString();
|
|
299
|
+
return mutateInstalls(options, async (current) => {
|
|
300
|
+
const byPath = new Map(current.map((e) => [e.path, e]));
|
|
301
|
+
const written = [];
|
|
302
|
+
for (const record of records) {
|
|
303
|
+
if (options.stillInstalled && !await options.stillInstalled(record.path)) continue;
|
|
304
|
+
const entry = {
|
|
305
|
+
path: record.path,
|
|
306
|
+
remote: record.remote,
|
|
307
|
+
kitVersion: record.kitVersion,
|
|
308
|
+
cliVersion: record.cliVersion,
|
|
309
|
+
lastSeen: record.lastSeen ?? now,
|
|
310
|
+
kind: record.kind
|
|
311
|
+
};
|
|
312
|
+
if (!isInstallEntry(entry)) continue;
|
|
313
|
+
byPath.set(entry.path, entry);
|
|
314
|
+
written.push(entry);
|
|
315
|
+
}
|
|
316
|
+
return { installs: [...byPath.values()], result: written, changed: written.length > 0 };
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
async function pruneInstalls(options) {
|
|
320
|
+
return mutateInstalls(options, async (current) => {
|
|
321
|
+
const kept = [];
|
|
322
|
+
const removed = [];
|
|
323
|
+
for (const entry of current) {
|
|
324
|
+
if (await options.stillInstalled(entry.path)) kept.push(entry);
|
|
325
|
+
else removed.push(entry);
|
|
326
|
+
}
|
|
327
|
+
return { installs: kept, result: removed, changed: removed.length > 0 };
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// src/installs/scan.ts
|
|
332
|
+
import { readdir, realpath as realpath2 } from "fs/promises";
|
|
333
|
+
import path3 from "path";
|
|
334
|
+
var DEFAULT_SCAN_DEPTH = 5;
|
|
335
|
+
var DEFAULT_SCAN_MAX_DIRS = 2e4;
|
|
336
|
+
var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
337
|
+
"node_modules",
|
|
338
|
+
"bower_components",
|
|
339
|
+
"vendor",
|
|
340
|
+
"dist",
|
|
341
|
+
"build",
|
|
342
|
+
"target",
|
|
343
|
+
"out",
|
|
344
|
+
"coverage",
|
|
345
|
+
"__pycache__",
|
|
346
|
+
"venv",
|
|
347
|
+
"Library",
|
|
348
|
+
"Applications",
|
|
349
|
+
"snap",
|
|
350
|
+
"AppData"
|
|
351
|
+
]);
|
|
352
|
+
var HIDDEN_WORKTREE_HOMES = {
|
|
353
|
+
".worktrees": ".worktrees",
|
|
354
|
+
".claude": path3.join(".claude", "worktrees")
|
|
355
|
+
};
|
|
356
|
+
async function scanForInstalls(roots, options = {}) {
|
|
357
|
+
const maxDepth = options.maxDepth ?? DEFAULT_SCAN_DEPTH;
|
|
358
|
+
const maxDirs = options.maxDirs ?? DEFAULT_SCAN_MAX_DIRS;
|
|
359
|
+
const found = /* @__PURE__ */ new Set();
|
|
360
|
+
const seen = /* @__PURE__ */ new Set();
|
|
361
|
+
let visited = 0;
|
|
362
|
+
let truncated = false;
|
|
363
|
+
const queue = [];
|
|
364
|
+
for (const root of roots) {
|
|
365
|
+
try {
|
|
366
|
+
queue.push({ dir: await realpath2(path3.resolve(root)), depth: 0 });
|
|
367
|
+
} catch {
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
while (queue.length > 0) {
|
|
371
|
+
const next = queue.shift();
|
|
372
|
+
if (!next) break;
|
|
373
|
+
const { dir, depth } = next;
|
|
374
|
+
if (seen.has(dir)) continue;
|
|
375
|
+
if (visited >= maxDirs) {
|
|
376
|
+
truncated = true;
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
seen.add(dir);
|
|
380
|
+
visited += 1;
|
|
381
|
+
if (await hasInstallManifest(dir)) found.add(dir);
|
|
382
|
+
if (depth >= maxDepth) continue;
|
|
383
|
+
let entries;
|
|
384
|
+
try {
|
|
385
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
386
|
+
} catch {
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
for (const entry of entries) {
|
|
390
|
+
if (!entry.isDirectory()) continue;
|
|
391
|
+
const name = entry.name;
|
|
392
|
+
if (name.startsWith(".")) {
|
|
393
|
+
const sub = HIDDEN_WORKTREE_HOMES[name];
|
|
394
|
+
if (sub) queue.push({ dir: path3.join(dir, sub), depth: depth + 1 });
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
if (SKIP_DIRS.has(name)) continue;
|
|
398
|
+
queue.push({ dir: path3.join(dir, name), depth: depth + 1 });
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return { found: [...found].sort(), visited, truncated };
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// src/installs/index.ts
|
|
405
|
+
async function recordInstalls(dirs, options = {}) {
|
|
406
|
+
const records = [];
|
|
407
|
+
for (const dir of dirs) {
|
|
408
|
+
const record = await inspectInstall(dir, options);
|
|
409
|
+
if (record) records.push(record);
|
|
410
|
+
}
|
|
411
|
+
return upsertInstalls(records, { ...options, stillInstalled: hasInstallManifest });
|
|
412
|
+
}
|
|
413
|
+
function pruneMissingInstalls(options = {}) {
|
|
414
|
+
return pruneInstalls({ ...options, stillInstalled: hasInstallManifest });
|
|
415
|
+
}
|
|
416
|
+
var FEED_LOCK_TIMEOUT_MS = 3e3;
|
|
417
|
+
async function feedInstallsRegistry(root) {
|
|
418
|
+
try {
|
|
419
|
+
await recordInstalls([root], { lockTimeoutMs: FEED_LOCK_TIMEOUT_MS });
|
|
420
|
+
} catch {
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
export {
|
|
425
|
+
inspectInstall,
|
|
426
|
+
InstallsRegistryError,
|
|
427
|
+
resolveInstallsFile,
|
|
428
|
+
listInstalls,
|
|
429
|
+
DEFAULT_SCAN_DEPTH,
|
|
430
|
+
DEFAULT_SCAN_MAX_DIRS,
|
|
431
|
+
scanForInstalls,
|
|
432
|
+
recordInstalls,
|
|
433
|
+
pruneMissingInstalls,
|
|
434
|
+
feedInstallsRegistry
|
|
435
|
+
};
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
import { mkdir, writeFile } from "fs/promises";
|
|
3
3
|
import path from "path";
|
|
4
4
|
var HANDOFF_REL = ".cursor/HANDOFF.md";
|
|
5
|
+
var SKILL_DIRS_REL = [
|
|
6
|
+
".cursor/skills/core",
|
|
7
|
+
".cursor/skills/domain",
|
|
8
|
+
".cursor/skills/community"
|
|
9
|
+
];
|
|
5
10
|
var STATE_ROOT_ENV = "AGENT_KIT_STATE_ROOT";
|
|
6
11
|
var STATE_ROOT_DIRS = [".cursor", ".agent-kit"];
|
|
7
12
|
function resolveStateDir(env = process.env) {
|
|
@@ -32,6 +37,7 @@ async function ensureLoopLogsDir(paths) {
|
|
|
32
37
|
|
|
33
38
|
export {
|
|
34
39
|
HANDOFF_REL,
|
|
40
|
+
SKILL_DIRS_REL,
|
|
35
41
|
STATE_ROOT_ENV,
|
|
36
42
|
runnerStatePaths,
|
|
37
43
|
ensureLoopLogsDir
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
RESOLVE_AGENT_KIT_REL,
|
|
5
5
|
SESSION_START_HOOK_MARKER,
|
|
6
6
|
mergeAllowRowsWithoutGuard
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-BVZDPVUL.js";
|
|
8
8
|
import {
|
|
9
9
|
CLAUDE_COMMANDS_DIR_REL,
|
|
10
10
|
discoverInstalledCommands
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-FUSNEYGU.js";
|
|
12
12
|
import {
|
|
13
13
|
findOnPath
|
|
14
14
|
} from "./chunk-WGLPZXNU.js";
|
|
@@ -17,11 +17,13 @@ import {
|
|
|
17
17
|
} from "./chunk-PNFF6OU3.js";
|
|
18
18
|
import {
|
|
19
19
|
KIT_OWNED_IGNORE_PATTERNS,
|
|
20
|
-
REPOSITORY_PROFILE_REL,
|
|
21
20
|
REQUIRED_SECRET_PATTERNS,
|
|
22
|
-
detectGitDirty,
|
|
23
21
|
runScanner
|
|
24
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-AXQMVQ6O.js";
|
|
23
|
+
import {
|
|
24
|
+
REPOSITORY_PROFILE_REL,
|
|
25
|
+
detectGitDirty
|
|
26
|
+
} from "./chunk-2QYWMSI5.js";
|
|
25
27
|
import {
|
|
26
28
|
CONTEXT_CONFIG_REL,
|
|
27
29
|
contextConfigPath
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
formatStaleCliRefusal,
|
|
7
7
|
installL0,
|
|
8
8
|
syncFromManifest
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-2GXN7HVG.js";
|
|
10
10
|
import {
|
|
11
11
|
SkippedSymlinkError,
|
|
12
12
|
formatPersonalizationSkippedSymlinks,
|
|
@@ -15,21 +15,25 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
REGISTRY_CLI_ARGS,
|
|
17
17
|
resolveRegistryFromCli
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-SWJJW624.js";
|
|
19
19
|
import {
|
|
20
20
|
assessClaudeCommandAdapters,
|
|
21
21
|
executeSafeReadinessFixes
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-PCIYXGB3.js";
|
|
23
23
|
import {
|
|
24
|
+
cachedCliNpmLatest,
|
|
24
25
|
writeReadinessSnapshot
|
|
25
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-FB6G6OD6.js";
|
|
26
27
|
import {
|
|
27
28
|
writeClaudeSessionStartHook
|
|
28
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-BVZDPVUL.js";
|
|
29
30
|
import {
|
|
30
31
|
CLAUDE_HITL_FALLBACK,
|
|
31
32
|
generateClaudeCommandAdapters
|
|
32
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-FUSNEYGU.js";
|
|
34
|
+
import {
|
|
35
|
+
feedInstallsRegistry
|
|
36
|
+
} from "./chunk-NHJ4IAVN.js";
|
|
33
37
|
import {
|
|
34
38
|
shouldUseWelcomeColor,
|
|
35
39
|
withCliProgress
|
|
@@ -38,13 +42,15 @@ import {
|
|
|
38
42
|
createReadinessReport
|
|
39
43
|
} from "./chunk-PNFF6OU3.js";
|
|
40
44
|
import {
|
|
41
|
-
REPOSITORY_PROFILE_REL,
|
|
42
45
|
detectIde,
|
|
43
46
|
runScanner
|
|
44
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-AXQMVQ6O.js";
|
|
45
48
|
import {
|
|
46
49
|
GIT_PLATFORM_META
|
|
47
50
|
} from "./chunk-F6C3GFKV.js";
|
|
51
|
+
import {
|
|
52
|
+
REPOSITORY_PROFILE_REL
|
|
53
|
+
} from "./chunk-2QYWMSI5.js";
|
|
48
54
|
import {
|
|
49
55
|
logger
|
|
50
56
|
} from "./chunk-ZB43YMHW.js";
|
|
@@ -56,21 +62,24 @@ import {
|
|
|
56
62
|
npxPinned,
|
|
57
63
|
pathCliStatus,
|
|
58
64
|
syncPathCliToRuntime
|
|
59
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-RRJVC35Y.js";
|
|
60
66
|
import {
|
|
61
67
|
assessEnvironment
|
|
62
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-2TW7ENWC.js";
|
|
63
69
|
import {
|
|
64
70
|
warnIfRunningCliBehindNpm
|
|
65
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-Y5526WCN.js";
|
|
66
72
|
import {
|
|
67
|
-
|
|
73
|
+
UnknownPackError,
|
|
68
74
|
allPacks,
|
|
69
75
|
allSkills,
|
|
70
76
|
buildManifest,
|
|
77
|
+
canonicalizePackIds,
|
|
71
78
|
emptyStats,
|
|
79
|
+
formatPackIdRewrite,
|
|
72
80
|
installPack,
|
|
73
81
|
installSkill,
|
|
82
|
+
legacyPackIdTarget,
|
|
74
83
|
loadAgentKitManifest,
|
|
75
84
|
loadPackManifest,
|
|
76
85
|
loadRegistry,
|
|
@@ -79,11 +88,14 @@ import {
|
|
|
79
88
|
resolveProtectedGlobs,
|
|
80
89
|
saveManifest,
|
|
81
90
|
skillTargetDir
|
|
82
|
-
} from "./chunk-
|
|
91
|
+
} from "./chunk-ZNZHDPS3.js";
|
|
92
|
+
import {
|
|
93
|
+
DOMAIN_PACK_IDS
|
|
94
|
+
} from "./chunk-KMK4T4ZM.js";
|
|
83
95
|
import {
|
|
84
96
|
KIT_VERSION,
|
|
85
97
|
pinnedCliSpec
|
|
86
|
-
} from "./chunk-
|
|
98
|
+
} from "./chunk-2G4K4ZI5.js";
|
|
87
99
|
import {
|
|
88
100
|
ensureDir,
|
|
89
101
|
fileExists,
|
|
@@ -799,10 +811,16 @@ async function performInstall(options) {
|
|
|
799
811
|
try {
|
|
800
812
|
const stale = await detectStaleCli(registry.root, { warn: logger.warn });
|
|
801
813
|
if (stale && !options.allowStaleCli) throw new StaleCliError(stale);
|
|
814
|
+
const packIds = await canonicalizePackIds(
|
|
815
|
+
registry.root,
|
|
816
|
+
packs.length > 0 ? packs : existing?.packs
|
|
817
|
+
);
|
|
818
|
+
const unknownFlagPack = packs.find((id) => packIds.unknown.includes(id));
|
|
819
|
+
if (unknownFlagPack) throw new UnknownPackError(unknownFlagPack, packIds.knownIds);
|
|
802
820
|
const draft = buildManifest({
|
|
803
821
|
version: KIT_VERSION,
|
|
804
822
|
profile: options.profile ?? existing?.profile ?? "default",
|
|
805
|
-
packs:
|
|
823
|
+
packs: packIds.packs,
|
|
806
824
|
skills: existing?.skills,
|
|
807
825
|
protected: existing?.protected,
|
|
808
826
|
personalization: existing?.personalization,
|
|
@@ -813,6 +831,7 @@ async function performInstall(options) {
|
|
|
813
831
|
const stats = (draft.packs?.length ?? 0) > 0 || (draft.skills?.length ?? 0) > 0 ? await syncFromManifest(registry.root, projectRoot, draft) : await installL0(registry.root, projectRoot, resolveProtectedGlobs(draft));
|
|
814
832
|
if (stats.skippedSymlink.length > 0) throw new SkippedSymlinkError(stats);
|
|
815
833
|
const manifestPath = await saveManifest(projectRoot, draft);
|
|
834
|
+
for (const rewrite of packIds.rewrites) logger.info(formatPackIdRewrite(rewrite));
|
|
816
835
|
const readinessExecution = await executeSafeReadinessFixes(projectRoot, {
|
|
817
836
|
generatorVersion: KIT_VERSION
|
|
818
837
|
});
|
|
@@ -932,10 +951,14 @@ ${err.recovery}
|
|
|
932
951
|
}
|
|
933
952
|
logger.info(`Installing into: ${projectRoot}`);
|
|
934
953
|
logger.info(`CLI v${KIT_VERSION}`);
|
|
935
|
-
await warnIfRunningCliBehindNpm(projectRoot, {
|
|
954
|
+
await warnIfRunningCliBehindNpm(projectRoot, {
|
|
955
|
+
warn: (message) => logger.warn(message),
|
|
956
|
+
stamp: false,
|
|
957
|
+
fetchLatest: async () => (await cachedCliNpmLatest())?.version ?? null
|
|
958
|
+
});
|
|
936
959
|
const packs = parsePackList(args.pack);
|
|
937
960
|
for (const id of packs) {
|
|
938
|
-
if (!DOMAIN_PACK_IDS.includes(id)) {
|
|
961
|
+
if (!DOMAIN_PACK_IDS.includes(id) && !legacyPackIdTarget(id)) {
|
|
939
962
|
logger.warn(`Pack '${id}' is not in the known L1 list; will still try registry.`);
|
|
940
963
|
}
|
|
941
964
|
}
|
|
@@ -965,6 +988,7 @@ ${result.claudeSessionStartInstructions}
|
|
|
965
988
|
`);
|
|
966
989
|
}
|
|
967
990
|
if (result.claudeAdapterHint) logger.info(result.claudeAdapterHint);
|
|
991
|
+
await feedInstallsRegistry(result.projectRoot);
|
|
968
992
|
} catch (err) {
|
|
969
993
|
if (err instanceof StaleCliError) {
|
|
970
994
|
const profile = typeof args.profile === "string" && args.profile ? `${args.profile} ` : "";
|
|
@@ -978,6 +1002,11 @@ ${result.claudeSessionStartInstructions}
|
|
|
978
1002
|
process.exitCode = 1;
|
|
979
1003
|
return;
|
|
980
1004
|
}
|
|
1005
|
+
if (err instanceof UnknownPackError) {
|
|
1006
|
+
logger.error(err.message);
|
|
1007
|
+
process.exitCode = 1;
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
981
1010
|
if (err instanceof SkippedSymlinkError) {
|
|
982
1011
|
logApplyStats(err.stats);
|
|
983
1012
|
logger.error(err.message);
|
|
@@ -485,7 +485,23 @@ var KNOWN_SHIPPED_OVERLAY_HASHES = /* @__PURE__ */ new Set([
|
|
|
485
485
|
"f7b48efcec313ea4a3962ddb8a0eecf819af9906be79e97692379b0fc701d792",
|
|
486
486
|
"3d29d3d2ac1f38cd69ecf83e4c50de7419b07e853ae865318682a13480542ece",
|
|
487
487
|
"6b48f8ada97dc27288723408d8a9f262ae0d22bba6c2fb08fbd12fa28b22f51a",
|
|
488
|
-
"a137cebc4d7c6a14ed56029c3d11571e73e4eb870984a7f901c0880a0980e70f"
|
|
488
|
+
"a137cebc4d7c6a14ed56029c3d11571e73e4eb870984a7f901c0880a0980e70f",
|
|
489
|
+
"e154da7c04f7e634898a49a1c3b573ad314293ee652a05de6c1d559b1fecde66",
|
|
490
|
+
"9241867256f047eceb37b6f86623feef80ddeba9bf492da4f81a06084bd5bb97",
|
|
491
|
+
"670c05a2d888c9702da525febea29b624af8e0d6f0b0bd0bd7ba947a5fac2c6f",
|
|
492
|
+
"6bbca9f7b50a7e904d523a7e1318ddcc54f02bf811928ecae4e82cb80956be1c",
|
|
493
|
+
"82916f566f132583c9a70f661b9675f6204e4fddd6f624add6e7075d19cbf071",
|
|
494
|
+
"9c5a10086431050bee393060acc94d6383a22af627dec13483abbbffa452736c",
|
|
495
|
+
"dc6156f15b94e0b7dbd6b59e4d16dee932763fbcb5169e3a1119fc1b63cecfbf",
|
|
496
|
+
"ec8b8f4b3a12813a6cba9c5a417f5f1ef8ed34e27ea0c1cdc7d2987ce32e0d00",
|
|
497
|
+
"f0555c4a43c3cfd5e6c9fdc9ce14922aaf927d1251d98465f8bc50e6a992d547",
|
|
498
|
+
"9d419d86204df507806fb96dc9e2ba14335b11a1d1a584fbefb1bd31799f1edb",
|
|
499
|
+
"cb7dc49acdf3d4bcce0fc6df938fe6f7867ee548147049cae840d92759a7e665",
|
|
500
|
+
"3ac7992930166e8ffcfa648f01009e956bc6c6df49083c5f32a32e62186d16b7",
|
|
501
|
+
"5c91baae02679b8339f5347e038a1ee45fd785eec8ed5d1865b8139d88f53e74",
|
|
502
|
+
"5d8f9da50239efb7322d314ea2e6fae90e20942d0d4e325f35b7a59e4b2b8150",
|
|
503
|
+
"885ae1082642136b1324bf2d8b3bb9924eed693f10ec7b08e7a59c636d8d5007",
|
|
504
|
+
"eafbc96739f333138df4fbb2f1be8bd5b67681748ccbf02895f337b5edd29f37"
|
|
489
505
|
]);
|
|
490
506
|
|
|
491
507
|
// src/lifecycle/paths.ts
|
|
@@ -629,6 +645,7 @@ export {
|
|
|
629
645
|
assertRealParentContained,
|
|
630
646
|
isRealWriteTargetContained,
|
|
631
647
|
toPosixRel,
|
|
648
|
+
MANAGED_HASHES_REL,
|
|
632
649
|
isConsumerOverlayPath,
|
|
633
650
|
contentHash,
|
|
634
651
|
loadManagedHashLedger,
|