@cavelon/cli 0.1.15 → 0.1.16
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 +12 -0
- package/dist/agent-env.js +2 -0
- package/dist/agents.js +14 -7
- package/dist/approval-policy.js +1 -0
- package/dist/commands/init.js +46 -10
- package/dist/commands/session.js +3 -0
- package/dist/commands/setup.js +17 -4
- package/dist/confirm-token.js +2 -1
- package/dist/fsutil.js +24 -7
- package/dist/jsonc-config.js +223 -0
- package/dist/kit-codes.js +1 -0
- package/dist/mcp-command.js +5 -0
- package/dist/mcp-directory.js +32 -0
- package/dist/mcp-entry.js +21 -0
- package/dist/mcp.js +18 -2
- package/dist/native-approval/client.js +126 -0
- package/dist/native-approval/ipc.js +191 -0
- package/dist/native-approval/opencode-server.js +74 -0
- package/dist/native-approval/opencode-tui.js +143 -0
- package/dist/native-approval/pi-extension.js +84 -0
- package/dist/native-approval/preview-pages.js +18 -0
- package/dist/native-approval/profile.js +113 -0
- package/dist/native-assets/JSONC-LICENSE +21 -0
- package/dist/native-assets/LICENSE +201 -0
- package/dist/native-assets/MCP-SDK-LICENSE +21 -0
- package/dist/native-assets/THIRD-PARTY-NOTICES +368 -0
- package/dist/native-assets/TYPEBOX-LICENSE +23 -0
- package/dist/native-assets/ZOD-LICENSE +21 -0
- package/dist/native-assets/manifest.json +60 -0
- package/dist/native-assets/opencode-server.mjs +32273 -0
- package/dist/native-assets/opencode-tui.mjs +19055 -0
- package/dist/native-assets/pi-extension.mjs +23302 -0
- package/dist/native-assets.js +44 -0
- package/dist/native-clients.js +181 -0
- package/dist/native-install.js +365 -0
- package/dist/printed.js +17 -5
- package/dist/setup-agents.js +73 -8
- package/dist/skills/cavelon-loop/SKILL.md +7 -0
- package/package.json +7 -3
package/dist/setup-agents.js
CHANGED
|
@@ -7,6 +7,10 @@ import { isGenerated, removeBlock, removeJsonEntry, upsertBlock, upsertJsonEntry
|
|
|
7
7
|
import { cacheDir, homeDir } from "./paths.js";
|
|
8
8
|
import { runProgram } from "./run-program.js";
|
|
9
9
|
import { KIT_VERSION } from "./version.js";
|
|
10
|
+
import { NATIVE_CLIENTS, nativeClient, hasNativeApprovalAdapter, readNativeMcp, resolveNativeMcp } from "./native-clients.js";
|
|
11
|
+
import { decodeMcpEntry, encodeMcpEntry, isKitMcpEntry } from "./mcp-entry.js";
|
|
12
|
+
import { removeJsoncEntry, upsertJsoncEntry } from "./jsonc-config.js";
|
|
13
|
+
import { applyNativeInstallation, checkNativeInstallation, planNativeInstallation, removeNativeInstallation } from "./native-install.js";
|
|
10
14
|
export const MARKETPLACE_SOURCE = "goodguys-gmbh/cavelon-dev-kit";
|
|
11
15
|
export const MARKETPLACE = "cavelon-dev-kit";
|
|
12
16
|
export const PLUGIN_ID = "cavelon@cavelon-dev-kit";
|
|
@@ -82,12 +86,13 @@ export function setupAgents(env, platform = process.platform) {
|
|
|
82
86
|
mcp: json(path.join(home, ".kiro", "settings", "mcp.json")),
|
|
83
87
|
skills: path.join(home, ".kiro", "skills"),
|
|
84
88
|
},
|
|
89
|
+
...NATIVE_CLIENTS.map(client => ({ name: client.name, label: client.label, commands: client.commands, ...client.user(env, platform), notes: client.notes })),
|
|
85
90
|
];
|
|
86
91
|
}
|
|
87
92
|
const ALIASES = { "claude-code": "claude", vscode: "copilot", "vs-code": "copilot", "gemini-cli": "gemini", "cursor-agent": "cursor" };
|
|
88
93
|
export function agentByName(agents, raw) {
|
|
89
94
|
const name = raw.trim().toLowerCase();
|
|
90
|
-
return agents.find((a) => a.name === (ALIASES[name] ?? name));
|
|
95
|
+
return agents.find((a) => a.name === (ALIASES[name] ?? nativeClient(name)?.name ?? name));
|
|
91
96
|
}
|
|
92
97
|
const WINDOWS_EXTENSIONS = [".exe", ".cmd", ".bat"];
|
|
93
98
|
export async function findAgent(agent, env, platform = process.platform) {
|
|
@@ -202,7 +207,7 @@ function pluginCommands(kind) {
|
|
|
202
207
|
uninstall: kind === "claude" ? ["plugin", "uninstall", PLUGIN_ID, "--scope", "user"] : ["plugin", "remove", PLUGIN_ID],
|
|
203
208
|
};
|
|
204
209
|
}
|
|
205
|
-
export async function planAgent(agent, found, env, command, skills, platform = process.platform) {
|
|
210
|
+
export async function planAgent(agent, found, env, command, skills, platform = process.platform, record) {
|
|
206
211
|
const usePlugin = Boolean(agent.plugin && found.program);
|
|
207
212
|
const state = usePlugin ? await pluginState(agent.plugin, found.program, env) : undefined;
|
|
208
213
|
const plan = { agent, found, method: usePlugin ? "plugin" : "files", changes: [] };
|
|
@@ -226,7 +231,12 @@ export async function planAgent(agent, found, env, command, skills, platform = p
|
|
|
226
231
|
...(state.installed && !state.enabled ? { reason: `it is installed but turned off; turn it on in ${agent.label}` } : {}),
|
|
227
232
|
});
|
|
228
233
|
}
|
|
229
|
-
if (
|
|
234
|
+
if (agent.mcp.format === "native" && hasNativeApprovalAdapter(agent.mcp)) {
|
|
235
|
+
plan.native = await planNativeInstallation(agent.mcp, command, env, { directory: record?.native?.directory, mcpRecord: record?.mcp });
|
|
236
|
+
plan.changes.push({ kind: "native", summary: "install the Cavelon native tools and person dialogs in", target: plan.native.directory,
|
|
237
|
+
outcome: plan.native.outcome, ...(plan.native.reason ? { reason: plan.native.reason } : {}) });
|
|
238
|
+
}
|
|
239
|
+
else if (!usePlugin || platform === "win32")
|
|
230
240
|
plan.changes.push(await mcpChange(agent.mcp, command, false));
|
|
231
241
|
if (!usePlugin)
|
|
232
242
|
plan.changes.push(await skillsChange(agent.skills, skills, false));
|
|
@@ -234,6 +244,21 @@ export async function planAgent(agent, found, env, command, skills, platform = p
|
|
|
234
244
|
}
|
|
235
245
|
async function mcpChange(mcp, command, apply, state) {
|
|
236
246
|
const summary = 'add the "cavelon" tools server to';
|
|
247
|
+
if (mcp.format === "native") {
|
|
248
|
+
const selected = await resolveNativeMcp(mcp);
|
|
249
|
+
if ("error" in selected)
|
|
250
|
+
return { kind: "mcp", summary, target: selected.file, outcome: "skipped", reason: `${selected.error}; the Cavelon entry is "${mcp.keys.join(".")}": ${JSON.stringify(encodeMcpEntry(command, mcp.entryFormat, mcp.extra))}` };
|
|
251
|
+
const result = upsertJsoncEntry(selected.text, mcp.keys, encodeMcpEntry(command, mcp.entryFormat, mcp.extra), { matches: value => isKitMcpEntry(value, mcp.entryFormat, mcp.extra) });
|
|
252
|
+
if (result.outcome === "skipped" || result.outcome === "unchanged")
|
|
253
|
+
return { kind: "mcp", summary, target: selected.file, outcome: result.outcome, ...(result.reason ? { reason: result.reason } : {}) };
|
|
254
|
+
if (!apply)
|
|
255
|
+
return { kind: "mcp", summary, target: selected.file, outcome: "planned" };
|
|
256
|
+
const createdDir = await topmostMissing(path.dirname(selected.file));
|
|
257
|
+
await writeKeepingMode(selected.file, result.content);
|
|
258
|
+
if (state && !state.mcp)
|
|
259
|
+
state.mcp = { file: selected.file, created: selected.text === undefined, kept: selected.kept, ...(createdDir ? { created_dir: createdDir } : {}) };
|
|
260
|
+
return { kind: "mcp", summary, target: selected.file, outcome: "done" };
|
|
261
|
+
}
|
|
237
262
|
const existing = await readTextFile(mcp.file);
|
|
238
263
|
let result;
|
|
239
264
|
if (mcp.format === "json") {
|
|
@@ -330,6 +355,8 @@ export async function applyPlan(plan, env, command, skills, record) {
|
|
|
330
355
|
const done = [];
|
|
331
356
|
for (const change of plan.changes) {
|
|
332
357
|
if (change.outcome !== "planned") {
|
|
358
|
+
if (change.kind === "native" && change.outcome === "unchanged")
|
|
359
|
+
record.native = { directory: plan.native.directory };
|
|
333
360
|
done.push(change);
|
|
334
361
|
continue;
|
|
335
362
|
}
|
|
@@ -358,6 +385,12 @@ export async function applyPlan(plan, env, command, skills, record) {
|
|
|
358
385
|
if (kind === "gemini" && change.kind === "plugin")
|
|
359
386
|
done.push(...(await removeFiles(plan.agent, record, skills, new Set())));
|
|
360
387
|
}
|
|
388
|
+
else if (change.kind === "native") {
|
|
389
|
+
await applyNativeInstallation(plan.native);
|
|
390
|
+
record.native = { directory: plan.native.directory };
|
|
391
|
+
delete record.mcp;
|
|
392
|
+
done.push({ ...change, outcome: "done" });
|
|
393
|
+
}
|
|
361
394
|
else if (change.kind === "mcp") {
|
|
362
395
|
done.push(await mcpChange(plan.agent.mcp, command, true, record));
|
|
363
396
|
}
|
|
@@ -402,6 +435,15 @@ export async function removeAgent(agent, record, env, skills, sharedSkillDirs) {
|
|
|
402
435
|
}
|
|
403
436
|
async function removeFiles(agent, record, skills, sharedSkillDirs) {
|
|
404
437
|
const changes = [];
|
|
438
|
+
if (record.native) {
|
|
439
|
+
const result = await removeNativeInstallation(record.native.directory);
|
|
440
|
+
changes.push({ kind: "native", summary: "remove the recorded Cavelon native integration from", target: record.native.directory,
|
|
441
|
+
outcome: result.removed ? "removed" : "skipped", ...(result.reason ? { reason: result.reason } : {}) });
|
|
442
|
+
if (result.removed)
|
|
443
|
+
delete record.native;
|
|
444
|
+
else
|
|
445
|
+
return changes;
|
|
446
|
+
}
|
|
405
447
|
if (record.mcp) {
|
|
406
448
|
const change = await removeMcp(agent.mcp, record.mcp);
|
|
407
449
|
if (change.outcome !== "failed" && change.outcome !== "skipped")
|
|
@@ -416,13 +458,16 @@ async function removeFiles(agent, record, skills, sharedSkillDirs) {
|
|
|
416
458
|
return changes;
|
|
417
459
|
}
|
|
418
460
|
async function removeMcp(mcp, record) {
|
|
461
|
+
mcp = { ...mcp, file: record.file };
|
|
419
462
|
const summary = 'remove the "cavelon" tools server from';
|
|
420
463
|
const existing = await readTextFile(mcp.file);
|
|
421
464
|
if (existing === undefined)
|
|
422
465
|
return { kind: "mcp", summary, target: mcp.file, outcome: "unchanged" };
|
|
423
|
-
const result = mcp.format === "
|
|
424
|
-
?
|
|
425
|
-
:
|
|
466
|
+
const result = mcp.format === "native"
|
|
467
|
+
? removeJsoncEntry(existing, mcp.keys, value => isKitMcpEntry(value, mcp.entryFormat, mcp.extra), record.kept ?? mcp.keys.length - 1)
|
|
468
|
+
: mcp.format === "json"
|
|
469
|
+
? removeJsonEntry(existing, mcp.keys, (value) => isOwnJsonEntry(mcp, value), record.kept ?? mcp.keys.length - 1)
|
|
470
|
+
: removeBlock(existing, "hash");
|
|
426
471
|
if (result.outcome === "unchanged")
|
|
427
472
|
return { kind: "mcp", summary, target: mcp.file, outcome: "unchanged" };
|
|
428
473
|
if (result.outcome === "skipped")
|
|
@@ -488,6 +533,7 @@ async function topmostMissing(dir) {
|
|
|
488
533
|
export async function checkAgent(agent, env, record, platform = process.platform) {
|
|
489
534
|
const found = await findAgent(agent, env, platform);
|
|
490
535
|
const check = { name: agent.name, label: agent.label, found: Boolean(found.program || found.folder), method: null, ok: true, details: [], servers: [] };
|
|
536
|
+
check.details.push(...(agent.notes ?? []));
|
|
491
537
|
const state = agent.plugin && found.program ? await pluginState(agent.plugin, found.program, env) : undefined;
|
|
492
538
|
const viaFiles = !state || (agent.plugin === "gemini" && ("error" in state || !state.installed));
|
|
493
539
|
const what = agent.plugin === "gemini" ? "extension" : "plugin";
|
|
@@ -516,9 +562,15 @@ export async function checkAgent(agent, env, record, platform = process.platform
|
|
|
516
562
|
else {
|
|
517
563
|
check.method = "files";
|
|
518
564
|
}
|
|
519
|
-
const
|
|
565
|
+
const nativeDirectory = record?.native?.directory ?? (agent.mcp.format === "native" && hasNativeApprovalAdapter(agent.mcp) ? path.join(path.dirname(agent.skills), "cavelon") : undefined);
|
|
566
|
+
const native = nativeDirectory && (record?.native || await readTextFile(path.join(nativeDirectory, "installation.json"))) ? await checkNativeInstallation(nativeDirectory) : undefined;
|
|
567
|
+
if (record?.native && agent.mcp.format === "native" && record.native.directory !== path.join(path.dirname(agent.skills), "cavelon")) {
|
|
568
|
+
check.ok = false;
|
|
569
|
+
check.details.push("The native config directory override changed; remove the recorded integration before setting up the new location.");
|
|
570
|
+
}
|
|
571
|
+
const entry = native ? { server: native.command, problem: native.reason, file: nativeDirectory } : await readEntry(agent.mcp);
|
|
520
572
|
if (entry.server) {
|
|
521
|
-
check.details.push(`the "cavelon" tools server is in ${agent.mcp.file}`);
|
|
573
|
+
check.details.push(native ? `the Cavelon native tools and person-dialog files are in ${nativeDirectory}; actual UI loading must be checked in the client` : `the "cavelon" tools server is in ${entry.file ?? agent.mcp.file}`);
|
|
522
574
|
check.servers.push(entry.server);
|
|
523
575
|
}
|
|
524
576
|
else {
|
|
@@ -544,6 +596,19 @@ export async function checkAgent(agent, env, record, platform = process.platform
|
|
|
544
596
|
return check;
|
|
545
597
|
}
|
|
546
598
|
async function readEntry(mcp) {
|
|
599
|
+
if (mcp.format === "native") {
|
|
600
|
+
const selected = await resolveNativeMcp(mcp);
|
|
601
|
+
if ("error" in selected)
|
|
602
|
+
return { problem: `${selected.file}: ${selected.error}` };
|
|
603
|
+
const entry = readNativeMcp(selected.text, mcp);
|
|
604
|
+
if ("error" in entry)
|
|
605
|
+
return { problem: `${selected.file}: ${entry.error}` };
|
|
606
|
+
const value = entry.value;
|
|
607
|
+
if (value?.enabled === false || value?.disabled === true)
|
|
608
|
+
return { problem: `the Cavelon server in ${selected.file} is disabled` };
|
|
609
|
+
const server = decodeMcpEntry(value, mcp.entryFormat);
|
|
610
|
+
return server ? { server, file: selected.file } : { problem: `${selected.file} has no readable "cavelon" tools server` };
|
|
611
|
+
}
|
|
547
612
|
const text = await readTextFile(mcp.file);
|
|
548
613
|
if (text === undefined)
|
|
549
614
|
return { problem: `${mcp.file} does not exist` };
|
|
@@ -13,6 +13,13 @@ use it when you parse the result.
|
|
|
13
13
|
|
|
14
14
|
## Before anything
|
|
15
15
|
|
|
16
|
+
- **Select the local solution folder.** In a repository with several solutions,
|
|
17
|
+
pass `solution_dir`, such as `solutions/review`, on MCP calls. It resolves
|
|
18
|
+
inside the server's startup workspace and selects that folder's
|
|
19
|
+
`cavelon.yaml`, `env/`, package, tests and saved previews. Use the same folder
|
|
20
|
+
for preview, confirmation and follow-up calls; `harness` selects the solution
|
|
21
|
+
on the instance and does not locate its files. Without `solution_dir`, tools
|
|
22
|
+
keep using the startup folder. From a shell, run in the solution folder.
|
|
16
23
|
- `cavelon status` says which instance, tenant and solution this folder is
|
|
17
24
|
bound to, the solution's state (draft, active, or inactive after a
|
|
18
25
|
deactivate; whether it is ready to
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cavelon/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "The cavelon binary: CLI and local MCP server for building Cavelon solutions with a coding agent.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/goodguys-gmbh/cavelon-dev-kit",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"node": ">=20.3"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
|
-
"build": "tsc -p tsconfig.build.json && node scripts/copy-skills.mjs",
|
|
25
|
+
"build": "tsc -p tsconfig.build.json && node scripts/copy-skills.mjs && node scripts/build-native-assets.mjs",
|
|
26
26
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
27
27
|
"lint": "eslint .",
|
|
28
28
|
"test": "vitest run",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"@modelcontextprotocol/sdk": "^1.31.0",
|
|
36
36
|
"ajv": "^8.20.0",
|
|
37
37
|
"ajv-formats": "^3.0.1",
|
|
38
|
+
"jsonc-parser": "3.3.1",
|
|
38
39
|
"yaml": "^2.9.1"
|
|
39
40
|
},
|
|
40
41
|
"optionalDependencies": {
|
|
@@ -43,9 +44,12 @@
|
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@eslint/js": "^10.0.1",
|
|
45
46
|
"@types/node": "^20.19.0",
|
|
47
|
+
"esbuild": "0.28.2",
|
|
46
48
|
"eslint": "^10.12.0",
|
|
49
|
+
"typebox": "1.3.27",
|
|
47
50
|
"typescript": "~6.0.3",
|
|
48
51
|
"typescript-eslint": "^8.71.0",
|
|
49
|
-
"vitest": "^4.0.0"
|
|
52
|
+
"vitest": "^4.0.0",
|
|
53
|
+
"zod": "4.6.5"
|
|
50
54
|
}
|
|
51
55
|
}
|