@dadado/agent-kit-cli 5.15.1 → 5.17.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/dashboard/dashboard-data.mjs +69 -65
- package/dashboard/lib/guards.d.mts +5 -0
- package/dashboard/lib/guards.mjs +31 -0
- package/dashboard/lib/identity-probe.mjs +56 -0
- package/dashboard/lib/pipeline-cache.mjs +58 -0
- package/dashboard/lib/processes.mjs +71 -0
- package/dashboard/serve.mjs +43 -1
- package/dashboard/start-broadcast.mjs +2 -12
- package/dashboard/start.mjs +2 -13
- package/dist/add-HTYIFKMN.js +150 -0
- package/dist/chunk-2IPXQFJE.js +253 -0
- package/dist/chunk-2RDRMGD3.js +82 -0
- package/dist/chunk-2YU2H7I6.js +42 -0
- package/dist/chunk-4IWG5CVE.js +214 -0
- package/dist/chunk-5VCOWTTP.js +6 -0
- package/dist/chunk-77V75A7O.js +39 -0
- package/dist/chunk-7HDQEK6T.js +26 -0
- package/dist/chunk-AW74INUW.js +1456 -0
- package/dist/chunk-B73KQ5KX.js +972 -0
- package/dist/chunk-CBCW5R5J.js +484 -0
- package/dist/chunk-DE3LQFSJ.js +18 -0
- package/dist/chunk-DQA434Y4.js +106 -0
- package/dist/chunk-F4VMYR7U.js +318 -0
- package/dist/chunk-F6C3GFKV.js +57 -0
- package/dist/chunk-HFUH3HVS.js +282 -0
- package/dist/chunk-HS7LVVLO.js +74 -0
- package/dist/chunk-IHROBTNM.js +135 -0
- package/dist/chunk-KD2MYBB6.js +213 -0
- package/dist/chunk-MAPOQEA2.js +43 -0
- package/dist/chunk-N3HTJVBR.js +341 -0
- package/dist/chunk-NQ7IQ5XT.js +26 -0
- package/dist/chunk-OUQZC744.js +1315 -0
- package/dist/chunk-PCCQUWE5.js +817 -0
- package/dist/chunk-PNFF6OU3.js +273 -0
- package/dist/chunk-PNG7LO2F.js +53 -0
- package/dist/chunk-QTON2GQX.js +203 -0
- package/dist/chunk-S6GMFDKV.js +50 -0
- package/dist/chunk-SMGFN3Z4.js +503 -0
- package/dist/chunk-STGFBAYT.js +641 -0
- package/dist/chunk-TFZ2JUXH.js +1081 -0
- package/dist/chunk-VY7MTPJ2.js +205 -0
- package/dist/chunk-W24CMQ32.js +525 -0
- package/dist/chunk-WW3YZKHW.js +165 -0
- package/dist/chunk-ZB43YMHW.js +20 -0
- package/dist/chunk-ZCTSUQRR.js +874 -0
- package/dist/chunk-ZXKZBTXE.js +17 -0
- package/dist/contribute-C6AW2P6J.js +367 -0
- package/dist/cursor-awareness-KTL2RGKD.js +77 -0
- package/dist/dashboard-YSNUGBFY.js +21 -0
- package/dist/dashboard-broadcast-M4CMW7RX.js +119 -0
- package/dist/diff-VHNR62SI.js +74 -0
- package/dist/doctor-PET2HRRJ.js +236 -0
- package/dist/dogfood-KKFVRWT6.js +366 -0
- package/dist/guard-EHXF76ID.js +530 -0
- package/dist/handoff-3UI6VKVG.js +302 -0
- package/dist/hook-DYIMKJYL.js +1074 -0
- package/dist/index.js +62 -14068
- package/dist/init-Q4LBM6KT.js +127 -0
- package/dist/install-RHOS3OYZ.js +34 -0
- package/dist/mission-control-LJACEVVN.js +89 -0
- package/dist/monitors-QV2IS3MP.js +176 -0
- package/dist/plan-index-JMC7Z4DW.js +44 -0
- package/dist/public-inbound-radar-WP3XF7GS.js +68 -0
- package/dist/remote-issues-SZ4HDQL5.js +44 -0
- package/dist/run-I3BFGULT.js +243 -0
- package/dist/run-plan-FO7CL4M3.js +118 -0
- package/dist/scan-NI2SWJ2E.js +33 -0
- package/dist/setup-global-M42GEODI.js +340 -0
- package/dist/status-XPVQVQMX.js +150 -0
- package/dist/update-FJ2EBZVO.js +283 -0
- package/dist/validate-V2CW7J4B.js +201 -0
- package/package.json +3 -3
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import {
|
|
2
|
+
classifyInstallError,
|
|
3
|
+
isNonInteractive,
|
|
4
|
+
pathCliStatus
|
|
5
|
+
} from "./chunk-F4VMYR7U.js";
|
|
6
|
+
import {
|
|
7
|
+
assessEnvironment
|
|
8
|
+
} from "./chunk-4IWG5CVE.js";
|
|
9
|
+
import "./chunk-SMGFN3Z4.js";
|
|
10
|
+
import "./chunk-NQ7IQ5XT.js";
|
|
11
|
+
import "./chunk-2RDRMGD3.js";
|
|
12
|
+
import "./chunk-N3HTJVBR.js";
|
|
13
|
+
import "./chunk-AW74INUW.js";
|
|
14
|
+
import "./chunk-5VCOWTTP.js";
|
|
15
|
+
import {
|
|
16
|
+
KIT_VERSION,
|
|
17
|
+
pinnedCliSpec
|
|
18
|
+
} from "./chunk-7HDQEK6T.js";
|
|
19
|
+
import "./chunk-77V75A7O.js";
|
|
20
|
+
|
|
21
|
+
// src/commands/setup-global.ts
|
|
22
|
+
import { spawn } from "child_process";
|
|
23
|
+
import { appendFile, mkdir, readFile, writeFile } from "fs/promises";
|
|
24
|
+
import { homedir } from "os";
|
|
25
|
+
import path from "path";
|
|
26
|
+
import { confirm, isCancel } from "@clack/prompts";
|
|
27
|
+
import { defineCommand } from "citty";
|
|
28
|
+
import { cyan, green, yellow } from "kolorist";
|
|
29
|
+
var NPM_GLOBAL_DIR_NAME = ".npm-global";
|
|
30
|
+
var SETUP_GLOBAL_MARKER = "# agent-kit setup-global";
|
|
31
|
+
function planSetupGlobalSteps(env, options = {}) {
|
|
32
|
+
const homeDir = options.homeDir ?? homedir();
|
|
33
|
+
const packageSpec = options.packageSpec ?? pinnedCliSpec();
|
|
34
|
+
const npmGlobalDir = path.join(homeDir, NPM_GLOBAL_DIR_NAME);
|
|
35
|
+
const npmGlobalBin = path.join(npmGlobalDir, "bin");
|
|
36
|
+
const npmrcPath = path.join(homeDir, ".npmrc");
|
|
37
|
+
const npmrcPrefixValue = `~/${NPM_GLOBAL_DIR_NAME}`;
|
|
38
|
+
const pathExportLine = `export PATH="${npmGlobalBin}:$PATH"`;
|
|
39
|
+
const shellProfile = env.shellProfile;
|
|
40
|
+
const shellSupported = shellProfile != null;
|
|
41
|
+
const steps = [
|
|
42
|
+
{
|
|
43
|
+
id: "set-prefix",
|
|
44
|
+
title: "Set npm's global install prefix to a folder you own",
|
|
45
|
+
detail: [
|
|
46
|
+
`mkdir -p ${npmGlobalDir}`,
|
|
47
|
+
`npm config set prefix "${npmrcPrefixValue}" (writes "prefix = ${npmrcPrefixValue}" to ${npmrcPath})`
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "append-path",
|
|
52
|
+
title: shellSupported ? `Put ${npmGlobalBin} on PATH via ${shellProfile}` : "Put npm's global bin on PATH (manual \u2014 shell not auto-detected)",
|
|
53
|
+
detail: shellSupported ? [`Append to ${shellProfile}:`, ` ${SETUP_GLOBAL_MARKER}`, ` ${pathExportLine}`] : [
|
|
54
|
+
`Shell could not be auto-detected as zsh or bash (detected: ${env.shell ?? "unknown"}).`,
|
|
55
|
+
"You'll need to add this line to your shell's startup file yourself:",
|
|
56
|
+
` ${pathExportLine}`
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: "npm-install",
|
|
61
|
+
title: `Reinstall ${packageSpec} globally, now into the new prefix`,
|
|
62
|
+
detail: [`npm i -g ${packageSpec}`]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "verify",
|
|
66
|
+
title: "Verify `agent-kit` resolves on PATH",
|
|
67
|
+
detail: [
|
|
68
|
+
"Re-check whether a bare `agent-kit` resolves on PATH.",
|
|
69
|
+
"Needs a new shell session (or `source` the profile) to take effect \u2014 this process's own PATH can't reflect it."
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
return {
|
|
74
|
+
packageSpec,
|
|
75
|
+
homeDir,
|
|
76
|
+
npmGlobalDir,
|
|
77
|
+
npmGlobalBin,
|
|
78
|
+
npmrcPath,
|
|
79
|
+
npmrcPrefixValue,
|
|
80
|
+
pathExportLine,
|
|
81
|
+
markerComment: SETUP_GLOBAL_MARKER,
|
|
82
|
+
shellProfile,
|
|
83
|
+
shellSupported,
|
|
84
|
+
alreadyWritable: env.npmPrefixWritable,
|
|
85
|
+
currentPrefix: env.npmPrefix.prefix,
|
|
86
|
+
steps
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function upsertNpmrcPrefix(content, prefixValue) {
|
|
90
|
+
const line = `prefix = ${prefixValue}`;
|
|
91
|
+
const prefixLineRe = /^\s*prefix\s*=.*$/m;
|
|
92
|
+
if (prefixLineRe.test(content)) {
|
|
93
|
+
return content.replace(prefixLineRe, line);
|
|
94
|
+
}
|
|
95
|
+
const withTrailingNewline = content.length > 0 && !content.endsWith("\n") ? `${content}
|
|
96
|
+
` : content;
|
|
97
|
+
return `${withTrailingNewline}${line}
|
|
98
|
+
`;
|
|
99
|
+
}
|
|
100
|
+
var defaultFsImpl = {
|
|
101
|
+
mkdir: async (dir) => {
|
|
102
|
+
await mkdir(dir, { recursive: true });
|
|
103
|
+
},
|
|
104
|
+
readFile: (filePath) => readFile(filePath, "utf8"),
|
|
105
|
+
writeFile: (filePath, content) => writeFile(filePath, content, "utf8"),
|
|
106
|
+
appendFile: (filePath, content) => appendFile(filePath, content, "utf8")
|
|
107
|
+
};
|
|
108
|
+
async function safeReadFile(fs, filePath) {
|
|
109
|
+
try {
|
|
110
|
+
return await fs.readFile(filePath);
|
|
111
|
+
} catch {
|
|
112
|
+
return "";
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
var defaultNpmInstallImpl = (packageSpec) => new Promise((resolve) => {
|
|
116
|
+
const child = spawn("npm", ["i", "-g", packageSpec], { stdio: "inherit" });
|
|
117
|
+
child.on("error", (error) => resolve({ ok: false, error }));
|
|
118
|
+
child.on("close", (code) => {
|
|
119
|
+
if (code === 0) resolve({ ok: true });
|
|
120
|
+
else resolve({ ok: false, error: new Error(`npm exited with code ${code ?? "unknown"}`) });
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
var defaultConfirmImpl = async (message) => {
|
|
124
|
+
const answer = await confirm({ message, initialValue: true });
|
|
125
|
+
if (isCancel(answer)) return false;
|
|
126
|
+
return Boolean(answer);
|
|
127
|
+
};
|
|
128
|
+
function printHeader(env, print) {
|
|
129
|
+
print(cyan("agent-kit setup-global"));
|
|
130
|
+
print(
|
|
131
|
+
` npm prefix: ${env.npmPrefix.prefix ?? "unknown"} (${env.npmPrefixWritable ? "writable" : "NOT writable"})`
|
|
132
|
+
);
|
|
133
|
+
if (!env.npmPrefixWritable && env.npmPrefix.reason) {
|
|
134
|
+
print(` ${env.npmPrefix.reason}`);
|
|
135
|
+
}
|
|
136
|
+
print(
|
|
137
|
+
` shell: ${env.shell ?? "unknown"}${env.shellProfile ? ` (profile: ${env.shellProfile})` : " (profile not auto-detected: zsh/bash only)"}`
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
function printPlanSteps(plan, print) {
|
|
141
|
+
for (const [index, step] of plan.steps.entries()) {
|
|
142
|
+
print(`${index + 1}. ${step.title}`);
|
|
143
|
+
for (const line of step.detail) print(` ${line}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function printManualInstructions(plan, print) {
|
|
147
|
+
print("No changes made. Same fix, as commands you can run yourself:");
|
|
148
|
+
print(` mkdir -p ${plan.npmGlobalDir}`);
|
|
149
|
+
print(` npm config set prefix "${plan.npmrcPrefixValue}"`);
|
|
150
|
+
if (plan.shellSupported) {
|
|
151
|
+
print(` echo '${plan.markerComment}' >> ${plan.shellProfile}`);
|
|
152
|
+
print(` echo '${plan.pathExportLine}' >> ${plan.shellProfile}`);
|
|
153
|
+
print(` source ${plan.shellProfile}`);
|
|
154
|
+
} else {
|
|
155
|
+
print(` # add this line to your shell's startup file:`);
|
|
156
|
+
print(` ${plan.pathExportLine}`);
|
|
157
|
+
}
|
|
158
|
+
print(` npm i -g ${plan.packageSpec}`);
|
|
159
|
+
print(" agent-kit --version # verify, in a new shell session");
|
|
160
|
+
}
|
|
161
|
+
async function runSetupGlobal(options = {}) {
|
|
162
|
+
const print = options.print ?? ((line) => console.log(line));
|
|
163
|
+
const assessEnvironmentImpl = options.assessEnvironmentImpl ?? assessEnvironment;
|
|
164
|
+
const homeDir = options.homeDir ?? homedir();
|
|
165
|
+
const env = await assessEnvironmentImpl(options);
|
|
166
|
+
const plan = planSetupGlobalSteps(env, { homeDir, packageSpec: options.packageSpec });
|
|
167
|
+
if (plan.alreadyWritable && pathCliStatus(env, KIT_VERSION) === "current") {
|
|
168
|
+
printHeader(env, print);
|
|
169
|
+
print(green("npm's global prefix is writable and PATH `agent-kit` matches this CLI."));
|
|
170
|
+
return { exitCode: 0, mutated: false, outcome: "already-ok", env, plan };
|
|
171
|
+
}
|
|
172
|
+
if (plan.alreadyWritable) {
|
|
173
|
+
printHeader(env, print);
|
|
174
|
+
print(
|
|
175
|
+
`PATH \`agent-kit\` is ${env.binVersion ? `v${env.binVersion}` : "missing or unreadable"}; this CLI is v${KIT_VERSION}.`
|
|
176
|
+
);
|
|
177
|
+
print(`Prefix is writable. Next step is only: npm i -g ${plan.packageSpec}`);
|
|
178
|
+
if (options.dryRun) {
|
|
179
|
+
print("Dry run: no changes.");
|
|
180
|
+
print(` npm i -g ${plan.packageSpec}`);
|
|
181
|
+
return { exitCode: 0, mutated: false, outcome: "dry-run", env, plan };
|
|
182
|
+
}
|
|
183
|
+
const nonInteractiveWritable = options.nonInteractive ?? isNonInteractive();
|
|
184
|
+
if (nonInteractiveWritable) {
|
|
185
|
+
print("No changes made. Run this yourself:");
|
|
186
|
+
print(` npm i -g ${plan.packageSpec}`);
|
|
187
|
+
print(" hash -r");
|
|
188
|
+
print(" agent-kit --version");
|
|
189
|
+
return { exitCode: 0, mutated: false, outcome: "manual-instructions", env, plan };
|
|
190
|
+
}
|
|
191
|
+
const confirmStep2 = options.confirmImpl ?? defaultConfirmImpl;
|
|
192
|
+
const npmInstall2 = options.npmInstallImpl ?? defaultNpmInstallImpl;
|
|
193
|
+
const proceedInstall2 = await confirmStep2(`Run: npm i -g ${plan.packageSpec}?`);
|
|
194
|
+
if (!proceedInstall2) {
|
|
195
|
+
print(yellow("Cancelled: no changes made."));
|
|
196
|
+
return { exitCode: 1, mutated: false, outcome: "cancelled", env, plan };
|
|
197
|
+
}
|
|
198
|
+
const installResult2 = await npmInstall2(plan.packageSpec);
|
|
199
|
+
if (!installResult2.ok) {
|
|
200
|
+
const hint = classifyInstallError(installResult2.error);
|
|
201
|
+
print(` npm install failed: ${hint.message}`);
|
|
202
|
+
print(hint.recovery);
|
|
203
|
+
return { exitCode: 1, mutated: false, outcome: "error", env, plan };
|
|
204
|
+
}
|
|
205
|
+
print(green(` done: ${plan.packageSpec} installed globally.`));
|
|
206
|
+
print(" If this shell still shows the old version: hash -r (or open a new terminal).");
|
|
207
|
+
return { exitCode: 0, mutated: true, outcome: "completed", env, plan };
|
|
208
|
+
}
|
|
209
|
+
if (options.dryRun) {
|
|
210
|
+
printHeader(env, print);
|
|
211
|
+
print("Dry run \u2014 no changes will be made. Steps that would run:");
|
|
212
|
+
printPlanSteps(plan, print);
|
|
213
|
+
return { exitCode: 0, mutated: false, outcome: "dry-run", env, plan };
|
|
214
|
+
}
|
|
215
|
+
const nonInteractive = options.nonInteractive ?? isNonInteractive();
|
|
216
|
+
if (nonInteractive) {
|
|
217
|
+
printHeader(env, print);
|
|
218
|
+
printManualInstructions(plan, print);
|
|
219
|
+
return { exitCode: 0, mutated: false, outcome: "manual-instructions", env, plan };
|
|
220
|
+
}
|
|
221
|
+
printHeader(env, print);
|
|
222
|
+
print("You just hit the classic 'command not found' / EACCES fresh-install blocker.");
|
|
223
|
+
print("The following steps need your confirmation, one at a time:");
|
|
224
|
+
printPlanSteps(plan, print);
|
|
225
|
+
const fs = options.fsImpl ?? defaultFsImpl;
|
|
226
|
+
const confirmStep = options.confirmImpl ?? defaultConfirmImpl;
|
|
227
|
+
const npmInstall = options.npmInstallImpl ?? defaultNpmInstallImpl;
|
|
228
|
+
let mutated = false;
|
|
229
|
+
const setPrefixStep = plan.steps[0];
|
|
230
|
+
print(`
|
|
231
|
+
${setPrefixStep.title}`);
|
|
232
|
+
for (const line of setPrefixStep.detail) print(` ${line}`);
|
|
233
|
+
const proceedPrefix = await confirmStep(`Set npm's global prefix to ${plan.npmGlobalDir}?`);
|
|
234
|
+
if (!proceedPrefix) {
|
|
235
|
+
print(yellow("Cancelled \u2014 no changes made."));
|
|
236
|
+
return { exitCode: 1, mutated, outcome: "cancelled", env, plan };
|
|
237
|
+
}
|
|
238
|
+
await fs.mkdir(plan.npmGlobalDir);
|
|
239
|
+
const npmrcContent = await safeReadFile(fs, plan.npmrcPath);
|
|
240
|
+
await fs.writeFile(plan.npmrcPath, upsertNpmrcPrefix(npmrcContent, plan.npmrcPrefixValue));
|
|
241
|
+
mutated = true;
|
|
242
|
+
print(green(` done: prefix set (${plan.npmrcPath}).`));
|
|
243
|
+
const appendPathStep = plan.steps[1];
|
|
244
|
+
print(`
|
|
245
|
+
${appendPathStep.title}`);
|
|
246
|
+
for (const line of appendPathStep.detail) print(` ${line}`);
|
|
247
|
+
if (!plan.shellSupported) {
|
|
248
|
+
print(yellow(" shell not auto-detected as zsh/bash \u2014 add the line above yourself."));
|
|
249
|
+
} else {
|
|
250
|
+
const profilePath = plan.shellProfile;
|
|
251
|
+
const profileContent = await safeReadFile(fs, profilePath);
|
|
252
|
+
if (profileContent.includes(plan.markerComment)) {
|
|
253
|
+
print(` already present in ${profilePath} (marker found) \u2014 skipping.`);
|
|
254
|
+
} else {
|
|
255
|
+
const proceedPath = await confirmStep(`Append the PATH export to ${profilePath}?`);
|
|
256
|
+
if (!proceedPath) {
|
|
257
|
+
print(yellow("Cancelled \u2014 prefix was set, PATH export was not appended."));
|
|
258
|
+
return { exitCode: 1, mutated, outcome: "cancelled", env, plan };
|
|
259
|
+
}
|
|
260
|
+
await fs.appendFile(profilePath, `
|
|
261
|
+
${plan.markerComment}
|
|
262
|
+
${plan.pathExportLine}
|
|
263
|
+
`);
|
|
264
|
+
mutated = true;
|
|
265
|
+
print(green(` done: PATH export appended to ${profilePath}.`));
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
const installStep = plan.steps[2];
|
|
269
|
+
print(`
|
|
270
|
+
${installStep.title}`);
|
|
271
|
+
for (const line of installStep.detail) print(` ${line}`);
|
|
272
|
+
const proceedInstall = await confirmStep(`Run: npm i -g ${plan.packageSpec}?`);
|
|
273
|
+
if (!proceedInstall) {
|
|
274
|
+
print(yellow("Cancelled \u2014 prefix/PATH changes above are still in place."));
|
|
275
|
+
return { exitCode: 1, mutated, outcome: "cancelled", env, plan };
|
|
276
|
+
}
|
|
277
|
+
const installResult = await npmInstall(plan.packageSpec);
|
|
278
|
+
if (!installResult.ok) {
|
|
279
|
+
const hint = classifyInstallError(installResult.error);
|
|
280
|
+
print(` npm install failed: ${hint.message}`);
|
|
281
|
+
print(hint.recovery);
|
|
282
|
+
return { exitCode: 1, mutated, outcome: "error", env, plan };
|
|
283
|
+
}
|
|
284
|
+
mutated = true;
|
|
285
|
+
print(green(` done: ${plan.packageSpec} installed globally.`));
|
|
286
|
+
const verifyStep = plan.steps[3];
|
|
287
|
+
print(`
|
|
288
|
+
${verifyStep.title}`);
|
|
289
|
+
for (const line of verifyStep.detail) print(` ${line}`);
|
|
290
|
+
const proceedVerify = await confirmStep("Verify now (re-check PATH in this process)?");
|
|
291
|
+
if (proceedVerify) {
|
|
292
|
+
const verifyEnv = await assessEnvironmentImpl(options);
|
|
293
|
+
if (verifyEnv.binOnPath) {
|
|
294
|
+
print(green(" verify: `agent-kit` resolves on PATH."));
|
|
295
|
+
} else {
|
|
296
|
+
print(" verify: `agent-kit` isn't resolvable in THIS process's PATH yet \u2014 that's expected.");
|
|
297
|
+
print(
|
|
298
|
+
` Open a new terminal (or run: source ${plan.shellProfile ?? "<your shell profile>"}) and re-check with: agent-kit --version`
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
} else {
|
|
302
|
+
print(" skipped verification. Open a new terminal and run: agent-kit --version");
|
|
303
|
+
}
|
|
304
|
+
return { exitCode: 0, mutated, outcome: "completed", env, plan };
|
|
305
|
+
}
|
|
306
|
+
var setupGlobalCommand = defineCommand({
|
|
307
|
+
meta: {
|
|
308
|
+
name: "setup-global",
|
|
309
|
+
description: "Self-heal a root-owned npm prefix: relocate to ~/.npm-global, fix PATH, reinstall globally."
|
|
310
|
+
},
|
|
311
|
+
args: {
|
|
312
|
+
"dry-run": {
|
|
313
|
+
type: "boolean",
|
|
314
|
+
description: "Print the resolved plan; mutate nothing.",
|
|
315
|
+
default: false
|
|
316
|
+
},
|
|
317
|
+
yes: {
|
|
318
|
+
type: "boolean",
|
|
319
|
+
alias: "y",
|
|
320
|
+
description: "Treat as non-interactive: print the manual steps instead of prompting (never mutates).",
|
|
321
|
+
default: false
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
async run({ args }) {
|
|
325
|
+
const nonInteractive = args.yes || isNonInteractive();
|
|
326
|
+
const result = await runSetupGlobal({
|
|
327
|
+
dryRun: Boolean(args["dry-run"]),
|
|
328
|
+
nonInteractive
|
|
329
|
+
});
|
|
330
|
+
process.exitCode = result.exitCode;
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
export {
|
|
334
|
+
NPM_GLOBAL_DIR_NAME,
|
|
335
|
+
SETUP_GLOBAL_MARKER,
|
|
336
|
+
planSetupGlobalSteps,
|
|
337
|
+
runSetupGlobal,
|
|
338
|
+
setupGlobalCommand,
|
|
339
|
+
upsertNpmrcPrefix
|
|
340
|
+
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import {
|
|
2
|
+
detectWorkspaceParent,
|
|
3
|
+
workspaceParentAdvisoryLines
|
|
4
|
+
} from "./chunk-S6GMFDKV.js";
|
|
5
|
+
import {
|
|
6
|
+
createReadinessReport
|
|
7
|
+
} from "./chunk-PNFF6OU3.js";
|
|
8
|
+
import {
|
|
9
|
+
runScanner
|
|
10
|
+
} from "./chunk-ZCTSUQRR.js";
|
|
11
|
+
import "./chunk-F6C3GFKV.js";
|
|
12
|
+
import {
|
|
13
|
+
logger
|
|
14
|
+
} from "./chunk-ZB43YMHW.js";
|
|
15
|
+
import {
|
|
16
|
+
npxPinned,
|
|
17
|
+
pathCliStatus
|
|
18
|
+
} from "./chunk-F4VMYR7U.js";
|
|
19
|
+
import {
|
|
20
|
+
assessEnvironment
|
|
21
|
+
} from "./chunk-4IWG5CVE.js";
|
|
22
|
+
import "./chunk-SMGFN3Z4.js";
|
|
23
|
+
import "./chunk-NQ7IQ5XT.js";
|
|
24
|
+
import "./chunk-2RDRMGD3.js";
|
|
25
|
+
import "./chunk-N3HTJVBR.js";
|
|
26
|
+
import {
|
|
27
|
+
MANIFEST_RELATIVE_PATH,
|
|
28
|
+
loadAgentKitManifest,
|
|
29
|
+
resolveProtectedGlobs
|
|
30
|
+
} from "./chunk-AW74INUW.js";
|
|
31
|
+
import "./chunk-5VCOWTTP.js";
|
|
32
|
+
import {
|
|
33
|
+
KIT_VERSION
|
|
34
|
+
} from "./chunk-7HDQEK6T.js";
|
|
35
|
+
import {
|
|
36
|
+
readJson
|
|
37
|
+
} from "./chunk-77V75A7O.js";
|
|
38
|
+
|
|
39
|
+
// src/commands/status.ts
|
|
40
|
+
import path from "path";
|
|
41
|
+
import { defineCommand } from "citty";
|
|
42
|
+
function profileStatus(profile) {
|
|
43
|
+
if (!profile) return { origin: "none", evidence: [], profile: null };
|
|
44
|
+
if ("detection" in profile && profile.detection && typeof profile.detection === "object") {
|
|
45
|
+
const detection = profile.detection;
|
|
46
|
+
return {
|
|
47
|
+
origin: "readiness-scanner",
|
|
48
|
+
evidence: detection.providerEvidence ?? [],
|
|
49
|
+
profile
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return { origin: "legacy-wizard", evidence: [], profile };
|
|
53
|
+
}
|
|
54
|
+
var statusCommand = defineCommand({
|
|
55
|
+
meta: {
|
|
56
|
+
name: "status",
|
|
57
|
+
description: "Show installed kit version, manifest, and optional profile."
|
|
58
|
+
},
|
|
59
|
+
args: {
|
|
60
|
+
cwd: {
|
|
61
|
+
type: "string",
|
|
62
|
+
default: process.cwd()
|
|
63
|
+
},
|
|
64
|
+
json: {
|
|
65
|
+
type: "boolean",
|
|
66
|
+
description: "Print raw JSON for manifest and profile",
|
|
67
|
+
default: false
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
async run({ args }) {
|
|
71
|
+
const rootDir = path.resolve(args.cwd);
|
|
72
|
+
const workspaceParent = await detectWorkspaceParent(rootDir);
|
|
73
|
+
if (workspaceParent && !args.json) {
|
|
74
|
+
for (const line of workspaceParentAdvisoryLines(rootDir, workspaceParent, "status")) {
|
|
75
|
+
console.log(line);
|
|
76
|
+
}
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const [manifest, rawProfile, scan, env] = await Promise.all([
|
|
80
|
+
loadAgentKitManifest(rootDir, args.json ? {} : { onWarning: logger.warn }),
|
|
81
|
+
readJson(
|
|
82
|
+
path.join(rootDir, ".cursor", "agent-kit.config.json")
|
|
83
|
+
),
|
|
84
|
+
runScanner(rootDir),
|
|
85
|
+
assessEnvironment()
|
|
86
|
+
]);
|
|
87
|
+
const readiness = createReadinessReport(scan, { generatorVersion: KIT_VERSION });
|
|
88
|
+
const profile = profileStatus(rawProfile);
|
|
89
|
+
const nextAction = readiness.pendingActions[0];
|
|
90
|
+
if (args.json) {
|
|
91
|
+
console.log(
|
|
92
|
+
JSON.stringify(
|
|
93
|
+
{
|
|
94
|
+
runtimeVersion: KIT_VERSION,
|
|
95
|
+
manifest: manifest ?? null,
|
|
96
|
+
readiness,
|
|
97
|
+
pendingActions: readiness.pendingActions,
|
|
98
|
+
profile,
|
|
99
|
+
...workspaceParent ? { workspaceParent } : {}
|
|
100
|
+
},
|
|
101
|
+
null,
|
|
102
|
+
2
|
|
103
|
+
)
|
|
104
|
+
);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (!manifest) {
|
|
108
|
+
logger.warn(`No ${MANIFEST_RELATIVE_PATH}: run agent-kit install.`);
|
|
109
|
+
} else {
|
|
110
|
+
const protectedGlobs = resolveProtectedGlobs(manifest);
|
|
111
|
+
console.log("Agent Kit status");
|
|
112
|
+
console.log(` runtime: ${KIT_VERSION}`);
|
|
113
|
+
console.log(` installed: ${manifest.version}`);
|
|
114
|
+
console.log(` profile: ${manifest.profile ?? "(none)"}`);
|
|
115
|
+
console.log(` packs: ${(manifest.packs ?? []).join(", ") || "(none)"}`);
|
|
116
|
+
console.log(` skills: ${(manifest.skills ?? []).length} listed`);
|
|
117
|
+
console.log(` protected: ${protectedGlobs.length} glob(s) (L3 safe on update)`);
|
|
118
|
+
console.log(
|
|
119
|
+
` registry: ${manifest.registry?.url ?? "(default)"} @ ${manifest.registry?.ref ?? "(default)"}`
|
|
120
|
+
);
|
|
121
|
+
if (manifest.installedAt) console.log(` installed at: ${manifest.installedAt}`);
|
|
122
|
+
if (manifest.version !== KIT_VERSION) {
|
|
123
|
+
console.log(
|
|
124
|
+
` overlay: this CLI is v${KIT_VERSION}; apply with the same binary, not a stale PATH hit:`
|
|
125
|
+
);
|
|
126
|
+
console.log(` ${npxPinned(KIT_VERSION, "update")}`);
|
|
127
|
+
}
|
|
128
|
+
const pathStatus = pathCliStatus(env, KIT_VERSION);
|
|
129
|
+
if (pathStatus === "behind" || pathStatus === "unknown") {
|
|
130
|
+
console.log(` PATH bin: v${env.binVersion ?? "unknown"} at ${env.binPath}`);
|
|
131
|
+
console.log(" bare `agent-kit update` will re-stamp that older version");
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
console.log("Repository readiness");
|
|
135
|
+
console.log(
|
|
136
|
+
` ready: ${readiness.summary.ready}, choices: ${readiness.summary.needs_choice}, manual: ${readiness.summary.manual}, blocked: ${readiness.summary.blocked}`
|
|
137
|
+
);
|
|
138
|
+
console.log(` pending: ${readiness.pendingActions.length}`);
|
|
139
|
+
console.log(` profile origin: ${profile.origin}`);
|
|
140
|
+
console.log(
|
|
141
|
+
` profile evidence: ${profile.evidence.map((item) => item.value).join(", ") || "(none)"}`
|
|
142
|
+
);
|
|
143
|
+
console.log(
|
|
144
|
+
nextAction ? `Next: ${nextAction.recommendation}` : "Next: repository readiness checks are complete"
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
export {
|
|
149
|
+
statusCommand
|
|
150
|
+
};
|