@cavelon/cli 0.1.15 → 0.1.17
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 +44 -1
- package/dist/agent-env.js +3 -0
- package/dist/agents.js +16 -7
- package/dist/approval-policy.js +1 -0
- package/dist/commands/db.js +6 -2
- package/dist/commands/init.js +46 -10
- package/dist/commands/limits-set.js +11 -1
- package/dist/commands/limits.js +7 -1
- package/dist/commands/session.js +3 -0
- package/dist/commands/setup.js +18 -5
- package/dist/confirm-token.js +2 -1
- package/dist/database-limits.js +46 -0
- 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/kilo-server.js +33 -0
- package/dist/native-approval/kilo-tui.js +13 -0
- package/dist/native-approval/omp-extension.js +8 -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 +86 -0
- package/dist/native-approval/preview-pages.js +18 -0
- package/dist/native-approval/profile.js +120 -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 +386 -0
- package/dist/native-assets/TYPEBOX-LICENSE +23 -0
- package/dist/native-assets/ZOD-LICENSE +21 -0
- package/dist/native-assets/kilo-server.mjs +39719 -0
- package/dist/native-assets/kilo-tui.mjs +26477 -0
- package/dist/native-assets/manifest.json +82 -0
- package/dist/native-assets/omp-extension.mjs +30729 -0
- package/dist/native-assets/opencode-server.mjs +39692 -0
- package/dist/native-assets/opencode-tui.mjs +26474 -0
- package/dist/native-assets/pi-extension.mjs +30726 -0
- package/dist/native-assets.js +44 -0
- package/dist/native-clients.js +397 -0
- package/dist/native-install.js +390 -0
- package/dist/omp-config.js +85 -0
- package/dist/printed.js +17 -5
- package/dist/setup-agents.js +82 -8
- package/dist/skills/cavelon-loop/SKILL.md +7 -0
- package/dist/yaml-config.js +215 -0
- package/package.json +7 -3
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { promises as fs } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { embeddedContent } from "./embedded.js";
|
|
6
|
+
import { KIT_VERSION } from "./version.js";
|
|
7
|
+
async function readAssets() {
|
|
8
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
for (const directory of [path.join(here, "native-assets"), path.resolve(here, "..", "dist", "native-assets")]) {
|
|
10
|
+
let names;
|
|
11
|
+
try {
|
|
12
|
+
names = await fs.readdir(directory);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (error.code === "ENOENT")
|
|
16
|
+
continue;
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
return Promise.all(names.map(async (name) => ({ path: name, content: await fs.readFile(path.join(directory, name), "utf8") })));
|
|
20
|
+
}
|
|
21
|
+
throw new Error("Missing native assets; build or reinstall Cavelon.");
|
|
22
|
+
}
|
|
23
|
+
export async function bundledNativeAssets() {
|
|
24
|
+
const assets = embeddedContent()?.nativeAssets ?? await readAssets();
|
|
25
|
+
const raw = assets.find(asset => asset.path === "manifest.json");
|
|
26
|
+
if (!raw)
|
|
27
|
+
throw new Error("Missing native asset manifest; reinstall Cavelon.");
|
|
28
|
+
const manifest = JSON.parse(raw.content);
|
|
29
|
+
if (manifest.format !== 1 || manifest.version !== KIT_VERSION || !Array.isArray(manifest.files)
|
|
30
|
+
|| assets.length !== manifest.files.length + 1)
|
|
31
|
+
throw new Error("Invalid native asset manifest; reinstall Cavelon.");
|
|
32
|
+
const seen = new Set();
|
|
33
|
+
for (const listed of manifest.files) {
|
|
34
|
+
if (typeof listed.path !== "string" || !/^[a-zA-Z0-9_.-]+$/.test(listed.path) || seen.has(listed.path) || listed.path === "manifest.json") {
|
|
35
|
+
throw new Error("Invalid native asset path.");
|
|
36
|
+
}
|
|
37
|
+
seen.add(listed.path);
|
|
38
|
+
const asset = assets.find(asset => asset.path === listed.path);
|
|
39
|
+
if (!asset || Buffer.byteLength(asset.content) !== listed.size
|
|
40
|
+
|| createHash("sha256").update(asset.content).digest("hex") !== listed.sha256)
|
|
41
|
+
throw new Error("Native asset checksum mismatch; reinstall Cavelon.");
|
|
42
|
+
}
|
|
43
|
+
return assets.toSorted((a, b) => a.path.localeCompare(b.path, "en"));
|
|
44
|
+
}
|
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import { ompConfig, ompDirectory, ompPolicy } from "./omp-config.js";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import { promises as fs } from "node:fs";
|
|
5
|
+
import { parseTree } from "jsonc-parser";
|
|
6
|
+
import { readTextFile } from "./fsutil.js";
|
|
7
|
+
import { readJsoncEntry } from "./jsonc-config.js";
|
|
8
|
+
import { readYamlEntry } from "./yaml-config.js";
|
|
9
|
+
import { isKitMcpEntry } from "./mcp-entry.js";
|
|
10
|
+
import { homeDir } from "./paths.js";
|
|
11
|
+
const openCodeConfig = (file, files, blocked) => ({
|
|
12
|
+
client: "opencode", format: "native", file, files, syntax: "jsonc", keys: ["mcp", "cavelon"], entryFormat: "command-array", extra: { type: "local" },
|
|
13
|
+
...(blocked ? { blocked } : {}),
|
|
14
|
+
});
|
|
15
|
+
const piConfig = (file) => ({
|
|
16
|
+
client: "pi", format: "native", file, files: [file], syntax: "json", keys: ["mcpServers", "cavelon"], entryFormat: "command-args", extra: {},
|
|
17
|
+
});
|
|
18
|
+
const piDir = (env) => env.PI_CODING_AGENT_DIR || path.join(homeDir(env), ".pi", "agent");
|
|
19
|
+
function gooseConfigDir(env, platform) {
|
|
20
|
+
if (env.GOOSE_PATH_ROOT && path.isAbsolute(env.GOOSE_PATH_ROOT))
|
|
21
|
+
return path.join(env.GOOSE_PATH_ROOT, "config");
|
|
22
|
+
const home = homeDir(env);
|
|
23
|
+
if (platform === "win32")
|
|
24
|
+
return path.join(env.APPDATA || path.join(home, "AppData", "Roaming"), "Block", "goose", "config");
|
|
25
|
+
const xdg = env.XDG_CONFIG_HOME;
|
|
26
|
+
return path.join(xdg && path.isAbsolute(xdg) ? xdg : path.join(home, ".config"), "goose");
|
|
27
|
+
}
|
|
28
|
+
function gooseAdditionalPaths(value, platform) {
|
|
29
|
+
if (value === undefined)
|
|
30
|
+
return [];
|
|
31
|
+
const paths = [];
|
|
32
|
+
let segment = "";
|
|
33
|
+
let quoted = false;
|
|
34
|
+
const separator = platform === "win32" ? ";" : ":";
|
|
35
|
+
for (const char of value) {
|
|
36
|
+
if (platform === "win32" && char === '"')
|
|
37
|
+
quoted = !quoted;
|
|
38
|
+
else if (char === separator && !quoted) {
|
|
39
|
+
paths.push(segment);
|
|
40
|
+
segment = "";
|
|
41
|
+
}
|
|
42
|
+
else
|
|
43
|
+
segment += char;
|
|
44
|
+
}
|
|
45
|
+
paths.push(segment);
|
|
46
|
+
return paths;
|
|
47
|
+
}
|
|
48
|
+
function gooseUser(env, platform = process.platform) {
|
|
49
|
+
const dir = gooseConfigDir(env, platform);
|
|
50
|
+
const system = platform === "win32" ? path.join(env.PROGRAMDATA || String.raw `C:\ProgramData`, "goose", "config.yaml") : "/etc/goose/config.yaml";
|
|
51
|
+
const additional = gooseAdditionalPaths(env.GOOSE_ADDITIONAL_CONFIG_FILES, platform);
|
|
52
|
+
const file = path.join(dir, "config.yaml");
|
|
53
|
+
let blocked;
|
|
54
|
+
if (additional.some(file => !file))
|
|
55
|
+
blocked = "GOOSE_ADDITIONAL_CONFIG_FILES contains an empty path; review it before setup";
|
|
56
|
+
else if (env.GOOSE_ALLOWLIST)
|
|
57
|
+
blocked = "Goose's extension allowlist is active; ask the operator to review Cavelon's binding in that policy";
|
|
58
|
+
return {
|
|
59
|
+
mcp: { client: "goose", format: "native", file, files: [file], syntax: "yaml", keys: ["extensions", "cavelon"], entryFormat: "goose-stdio",
|
|
60
|
+
extra: { type: "stdio", name: "cavelon", enabled: true }, managedFiles: [...new Set([system, ...additional])], ...(blocked ? { blocked } : {}) },
|
|
61
|
+
skills: path.join(dir, "skills"), folders: [dir],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function clineUser(env) {
|
|
65
|
+
const candidate = env.HOME?.trim();
|
|
66
|
+
const profile = env.USERPROFILE?.trim() || (env.HOMEDRIVE?.trim() && env.HOMEPATH?.trim() ? `${env.HOMEDRIVE.trim()}${env.HOMEPATH.trim()}` : undefined);
|
|
67
|
+
const home = homeDir({ HOME: candidate && candidate !== "~" ? candidate : undefined, USERPROFILE: profile });
|
|
68
|
+
const dir = env.CLINE_DIR?.trim() || path.join(home, ".cline");
|
|
69
|
+
const data = env.CLINE_DATA_DIR?.trim() || path.join(dir, "data");
|
|
70
|
+
const file = env.CLINE_MCP_SETTINGS_PATH?.trim() || path.join(data, "settings", "cline_mcp_settings.json");
|
|
71
|
+
return {
|
|
72
|
+
mcp: { client: "cline", format: "native", file, files: [file], syntax: "json", keys: ["mcpServers", "cavelon"], entryFormat: "command-args", extra: { type: "stdio" } },
|
|
73
|
+
skills: path.join(dir, "skills"), folders: [...new Set([dir, data])],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function qwenDir(env) {
|
|
77
|
+
const raw = env.QWEN_HOME;
|
|
78
|
+
if (!raw)
|
|
79
|
+
return path.join(homeDir(env), ".qwen");
|
|
80
|
+
const expanded = raw === "~" ? homeDir(env) : raw.startsWith("~/") || raw.startsWith("~\\")
|
|
81
|
+
? path.join(homeDir(env), ...raw.slice(2).split(/[/\\]+/)) : raw;
|
|
82
|
+
return path.resolve(expanded);
|
|
83
|
+
}
|
|
84
|
+
function qwenManagedFiles(env, platform) {
|
|
85
|
+
const system = env.QWEN_CODE_SYSTEM_SETTINGS_PATH || (platform === "darwin" ? "/Library/Application Support/QwenCode/settings.json"
|
|
86
|
+
: platform === "win32" ? "C:\\ProgramData\\qwen-code\\settings.json" : "/etc/qwen-code/settings.json");
|
|
87
|
+
return [env.QWEN_CODE_SYSTEM_DEFAULTS_PATH || path.join(path.dirname(system), "system-defaults.json"), system];
|
|
88
|
+
}
|
|
89
|
+
const qwenConfig = (file, env, platform = process.platform) => ({
|
|
90
|
+
client: "qwen", format: "native", file, files: [file], syntax: "json-comments", keys: ["mcpServers", "cavelon"],
|
|
91
|
+
entryFormat: "command-args", extra: {}, managedFiles: qwenManagedFiles(env, platform),
|
|
92
|
+
});
|
|
93
|
+
export function hasNativeApprovalAdapter(config) {
|
|
94
|
+
return config.client === "opencode" || config.client === "pi" || config.client === "kilo" || config.client === "omp";
|
|
95
|
+
}
|
|
96
|
+
const kiloNames = ["kilo.json", "kilo.jsonc", "opencode.json", "opencode.jsonc"];
|
|
97
|
+
const kiloFiles = (dir) => kiloNames.map(name => path.join(dir, name));
|
|
98
|
+
const kiloCompatibility = (files) => files.filter(file => ["opencode.json", "opencode.jsonc"].includes(path.basename(file)));
|
|
99
|
+
async function kiloAncestorFiles(root) {
|
|
100
|
+
const files = [];
|
|
101
|
+
let dir = path.resolve(root);
|
|
102
|
+
while (path.dirname(dir) !== dir && !await fs.stat(path.join(dir, ".git")).then(() => true, () => false)) {
|
|
103
|
+
dir = path.dirname(dir);
|
|
104
|
+
files.push(...kiloFiles(dir), ...kiloFiles(path.join(dir, ".kilocode")), ...kiloFiles(path.join(dir, ".kilo")));
|
|
105
|
+
}
|
|
106
|
+
return files;
|
|
107
|
+
}
|
|
108
|
+
function kiloUser(env) {
|
|
109
|
+
const home = (env.KILO_TEST_HOME ?? homeDir(env)).trim();
|
|
110
|
+
const xdg = env.XDG_CONFIG_HOME && path.isAbsolute(env.XDG_CONFIG_HOME) ? env.XDG_CONFIG_HOME : path.join(homeDir(env), ".config");
|
|
111
|
+
const global = path.join(xdg.replace(/[\r\n]/g, ""), "kilo");
|
|
112
|
+
const dir = env.KILO_CONFIG_DIR || global;
|
|
113
|
+
const files = [...new Set([path.join(global, "config.json"), ...kiloFiles(global), ...(env.KILO_CONFIG ? [env.KILO_CONFIG] : []),
|
|
114
|
+
...kiloFiles(path.join(home, ".kilocode")), ...kiloFiles(path.join(home, ".kilo")), ...(dir !== global ? kiloFiles(dir) : [])])];
|
|
115
|
+
return { dir, global, files, compatibilityFiles: kiloCompatibility(files) };
|
|
116
|
+
}
|
|
117
|
+
function kiloConfig(file, files, env, platform, blocked) {
|
|
118
|
+
const managed = env.KILO_TEST_MANAGED_CONFIG_DIR || (platform === "darwin" ? "/Library/Application Support/kilo"
|
|
119
|
+
: platform === "win32" ? path.join(env.ProgramData || "C:\\ProgramData", "kilo") : "/etc/kilo");
|
|
120
|
+
return {
|
|
121
|
+
client: "kilo", format: "native", file, files, syntax: "jsonc", keys: ["mcp", "cavelon"], entryFormat: "command-array", extra: { type: "local" },
|
|
122
|
+
compatibilityFiles: kiloCompatibility(files), managedFiles: kiloFiles(managed),
|
|
123
|
+
managedOpaqueFiles: platform === "darwin" ? [path.join("/Library/Managed Preferences", os.userInfo().username, "ai.opencode.managed.plist"),
|
|
124
|
+
"/Library/Managed Preferences/ai.opencode.managed.plist"] : [],
|
|
125
|
+
...(blocked ? { blocked } : env.KILO_CONFIG_CONTENT ? { blocked: "KILO_CONFIG_CONTENT overrides file settings; configure Cavelon in that managed configuration" } : {}),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function openCodeUserFiles(env) {
|
|
129
|
+
const dir = path.join(env.XDG_CONFIG_HOME || path.join(homeDir(env), ".config"), "opencode");
|
|
130
|
+
return [path.join(dir, "config.json"), path.join(dir, "opencode.json"), path.join(dir, "opencode.jsonc"), ...(env.OPENCODE_CONFIG ? [env.OPENCODE_CONFIG] : [])];
|
|
131
|
+
}
|
|
132
|
+
export const NATIVE_CLIENTS = [
|
|
133
|
+
{
|
|
134
|
+
name: "omp", label: "OMP (Oh My Pi)", aliases: ["oh-my-pi", "ohmypi"], commands: ["omp"], projectSkills: [".omp/skills"],
|
|
135
|
+
project: (env = {}) => ompConfig(env, true),
|
|
136
|
+
user: env => {
|
|
137
|
+
const { directory } = ompDirectory(env);
|
|
138
|
+
return { mcp: ompConfig(env), skills: path.join(directory, "skills"), folders: [directory] };
|
|
139
|
+
},
|
|
140
|
+
notes: [
|
|
141
|
+
"OMP is a separate client from Pi. Setup follows OMP_PROFILE / PI_PROFILE, PI_CONFIG_DIR and its default PI_CODING_AGENT_DIR override; use the same profile environment when launching OMP.",
|
|
142
|
+
"Setup installs an owned native autoload extension without rewriting YAML or legacy settings. It disables only the duplicate Cavelon MCP entry and preserves compatible client bindings and deny/force-enable policies.",
|
|
143
|
+
"The native TUI asks the person afresh for each guarded change. Print/RPC modes return an exact command for the person's own terminal. Launch OMP with CAVELON_AGENT=1; file checks cannot qualify actual UI loading or custom extension policies.",
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "goose", label: "Goose", aliases: ["goose-cli"], commands: ["goose"], projectSkills: [],
|
|
148
|
+
project: () => undefined, user: gooseUser,
|
|
149
|
+
notes: [
|
|
150
|
+
"Goose uses user YAML extension settings and native skills; project init copies .agents/skills only. Run cavelon setup --agents goose for the MCP entry. System and additional config layers are inspected without overriding their Cavelon binding. Keep GOOSE_PATH_ROOT, XDG_CONFIG_HOME and GOOSE_ADDITIONAL_CONFIG_FILES the same for setup and the client.",
|
|
151
|
+
"Goose CLI's interactive MCP form can ask the person for the exact change; headless clients must refuse or return the person's terminal route. Automatic tool permissions cannot answer that form. Launch Goose with CAVELON_AGENT=1 to guard shells in modes that do not set a session marker. Actual UI qualification is separate from setup checks.",
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "kilo", label: "Kilo CLI / current VS Code extension", aliases: ["kilocode", "kilo-code"], commands: ["kilo", "kilocode"], projectSkills: [".kilo/skills"],
|
|
156
|
+
project: (env = {}) => ({ ...kiloConfig("kilo.json", [...kiloFiles("."), ...kiloFiles(".kilocode"), ...kiloFiles(".kilo")], env, process.platform, env.KILO_DISABLE_PROJECT_CONFIG === "true" || env.KILO_DISABLE_PROJECT_CONFIG === "1" ? "Kilo project configuration is disabled" :
|
|
157
|
+
env.KILO_CONFIG_DIR ? "KILO_CONFIG_DIR may override project settings; use user setup for that directory" : undefined), shadowFiles: kiloUser(env).files }),
|
|
158
|
+
user: (env, platform = process.platform) => {
|
|
159
|
+
const { dir, global, files } = kiloUser(env);
|
|
160
|
+
return { mcp: kiloConfig(env.KILO_CONFIG || path.join(dir, "kilo.json"), files, env, platform), skills: path.join(dir, "skills"), folders: [...new Set([global, dir])] };
|
|
161
|
+
},
|
|
162
|
+
notes: [
|
|
163
|
+
"Kilo CLI and current VS Code extension 7.8.8 use Kilo's own MCP settings and skills. Compatible OpenCode files are inspected and preserved; setup does not migrate another client's binding.",
|
|
164
|
+
"Setup installs separate Kilo server/TUI plugins and disables only the duplicate Cavelon MCP entry. CLI TUI approval requires a fresh person dialog; the editor and headless modes return a command for the person's own terminal.",
|
|
165
|
+
"Start Kilo with CAVELON_AGENT=1 scoped to its process, including a fresh VS Code process for the editor. A separate person's terminal must not inherit that marker. Check effective cloud/organization policies in Kilo; file checks cannot certify remote settings or actual UI loading.",
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "opencode", label: "OpenCode", aliases: ["opencode-ai"], commands: ["opencode"], projectSkills: [],
|
|
170
|
+
project: (env = {}) => ({ ...openCodeConfig("opencode.json", ["opencode.json", "opencode.jsonc", ".opencode/opencode.json", ".opencode/opencode.jsonc"], env.OPENCODE_CONFIG_CONTENT ? "OPENCODE_CONFIG_CONTENT overrides file settings; configure Cavelon in that managed configuration" :
|
|
171
|
+
env.OPENCODE_DISABLE_PROJECT_CONFIG === "true" || env.OPENCODE_DISABLE_PROJECT_CONFIG === "1" ? "OpenCode project configuration is disabled" :
|
|
172
|
+
env.OPENCODE_CONFIG_DIR ? "OPENCODE_CONFIG_DIR may override project settings; configure Cavelon in that directory" : undefined), shadowFiles: openCodeUserFiles(env) }),
|
|
173
|
+
user: env => {
|
|
174
|
+
const global = path.join(env.XDG_CONFIG_HOME || path.join(homeDir(env), ".config"), "opencode");
|
|
175
|
+
const dir = env.OPENCODE_CONFIG_DIR || global;
|
|
176
|
+
const files = openCodeUserFiles(env);
|
|
177
|
+
if (dir !== global)
|
|
178
|
+
files.push(path.join(dir, "opencode.json"), path.join(dir, "opencode.jsonc"));
|
|
179
|
+
return {
|
|
180
|
+
mcp: openCodeConfig(env.OPENCODE_CONFIG || path.join(dir, "opencode.json"), [...new Set(files)], env.OPENCODE_CONFIG_CONTENT ? "OPENCODE_CONFIG_CONTENT overrides file settings; configure Cavelon in that managed configuration" : undefined),
|
|
181
|
+
skills: path.join(dir, "skills"), folders: [...new Set([global, dir])],
|
|
182
|
+
};
|
|
183
|
+
},
|
|
184
|
+
notes: ["Setup installs separate native OpenCode server/TUI plugins and disables only its duplicate Cavelon MCP entry. Guarded changes require a fresh person dialog; missing UI returns a command for the person's own terminal. File checks do not certify actual UI loading."],
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: "pi", label: "Pi", aliases: ["pi-coding-agent"], commands: ["pi"], projectSkills: [".pi/skills"],
|
|
188
|
+
project: (env = {}) => ({ ...piConfig(".pi/mcp.json"), shadowFiles: [path.join(piDir(env), "mcp.json")] }),
|
|
189
|
+
user: env => {
|
|
190
|
+
const dir = piDir(env);
|
|
191
|
+
return { mcp: piConfig(path.join(dir, "mcp.json")), skills: path.join(dir, "skills"), folders: [dir] };
|
|
192
|
+
},
|
|
193
|
+
notes: [
|
|
194
|
+
"Pi reads project MCP only after the person grants project trust. A project entry overrides a user entry with the same name.",
|
|
195
|
+
"Replacement /mcp extensions can override Pi's built-in MCP; inspect them in Pi before using these settings. Setup does not install or disable another MCP extension.",
|
|
196
|
+
"Setup installs the native Cavelon extension and disables only its duplicate built-in MCP entry. Guarded changes require a fresh person dialog; missing UI returns a command for the person's own terminal. File checks do not certify actual UI loading.",
|
|
197
|
+
],
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: "qwen", label: "Qwen Code CLI", aliases: ["qwen-code", "qwen-cli"], commands: ["qwen"], projectSkills: [".qwen/skills"],
|
|
201
|
+
project: (env = {}) => ({ ...qwenConfig(".qwen/settings.json", env), shadowFiles: [path.join(qwenDir(env), "settings.json")] }),
|
|
202
|
+
user: (env, platform = process.platform) => {
|
|
203
|
+
const dir = qwenDir(env);
|
|
204
|
+
return { mcp: qwenConfig(path.join(dir, "settings.json"), env, platform), skills: path.join(dir, "skills"), folders: [dir] };
|
|
205
|
+
},
|
|
206
|
+
notes: [
|
|
207
|
+
"Qwen Code CLI 0.25.0 reads native Cavelon skills and MCP settings; project settings depend on project trust. System MCP policies and personal servers are preserved.",
|
|
208
|
+
"This client does not advertise MCP form elicitation. Guarded changes return a preview and a command for the person's own terminal; tool permission approval and automatic modes cannot confirm the Cavelon change.",
|
|
209
|
+
],
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
name: "cline", label: "Cline CLI / current VS Code extension", aliases: ["cline-cli", "cline-vscode"], commands: ["cline"], projectSkills: [".cline/skills"],
|
|
213
|
+
project: () => undefined,
|
|
214
|
+
user: clineUser,
|
|
215
|
+
notes: [
|
|
216
|
+
"Cline CLI 3.0.70 and VS Code extension 4.1.23 use shared user MCP settings; project init copies native skills only. Run cavelon setup --agents cline for the MCP entry. Older editor profiles and other surfaces require separate verification.",
|
|
217
|
+
"Set the same absolute CLINE_DIR, CLINE_DATA_DIR and CLINE_MCP_SETTINGS_PATH overrides for setup and the CLI. Mirror CLI --config / --data-dir in setup's environment. The editor's compatibility UI retains legacy path handling: use default shared paths and check its settings and skills independently. Setup does not migrate older editor profiles.",
|
|
218
|
+
"This client's MCP transport does not advertise form elicitation. Guarded changes return an exact command for the person's own terminal; automatic tool approval cannot confirm the change. Launch the coding client with CAVELON_AGENT=1 so its shell commands keep the kit's person-only guards.",
|
|
219
|
+
],
|
|
220
|
+
},
|
|
221
|
+
];
|
|
222
|
+
export const nativeClient = (name) => NATIVE_CLIENTS.find(client => client.name === name || client.aliases.includes(name));
|
|
223
|
+
export function readNativeMcp(text, config) {
|
|
224
|
+
if (config.syntax === "yaml")
|
|
225
|
+
return readYamlEntry(text, config.keys);
|
|
226
|
+
if (text !== undefined && config.syntax === "json") {
|
|
227
|
+
try {
|
|
228
|
+
JSON.parse(text);
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
return { error: "this client requires plain JSON; correct the file before setup" };
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (text !== undefined && config.syntax === "json-comments") {
|
|
235
|
+
const errors = [];
|
|
236
|
+
parseTree(text, errors, { allowTrailingComma: false });
|
|
237
|
+
if (errors.length)
|
|
238
|
+
return { error: "this client accepts JSON comments but not trailing commas; correct the file before setup" };
|
|
239
|
+
}
|
|
240
|
+
return readJsoncEntry(text, config.keys);
|
|
241
|
+
}
|
|
242
|
+
function serverMatches(pattern) {
|
|
243
|
+
let positions = new Set([0]);
|
|
244
|
+
for (const char of pattern) {
|
|
245
|
+
const next = new Set();
|
|
246
|
+
for (const at of positions) {
|
|
247
|
+
if (char === "*")
|
|
248
|
+
for (let end = at; end <= "cavelon".length; end++)
|
|
249
|
+
next.add(end);
|
|
250
|
+
else if (at < "cavelon".length && (char === "?" || char === "cavelon"[at]))
|
|
251
|
+
next.add(at + 1);
|
|
252
|
+
}
|
|
253
|
+
positions = next;
|
|
254
|
+
}
|
|
255
|
+
return positions.has("cavelon".length);
|
|
256
|
+
}
|
|
257
|
+
async function qwenPolicy(config, full) {
|
|
258
|
+
for (const file of new Set([...(config.managedFiles ?? []), ...(config.shadowFiles ?? []), ...config.files.map(full)])) {
|
|
259
|
+
const text = await readTextFile(file);
|
|
260
|
+
if (text === undefined)
|
|
261
|
+
continue;
|
|
262
|
+
const parsed = readNativeMcp(text, config);
|
|
263
|
+
if ("error" in parsed)
|
|
264
|
+
return `${file}: ${parsed.error}`;
|
|
265
|
+
if (config.managedFiles?.includes(file) && parsed.value !== undefined)
|
|
266
|
+
return `managed settings in ${file} define Cavelon; review that binding with the operator instead of writing another entry`;
|
|
267
|
+
const policy = readJsoncEntry(text, ["mcp"]);
|
|
268
|
+
if ("error" in policy)
|
|
269
|
+
return `${file}: ${policy.error}`;
|
|
270
|
+
if (policy.value === undefined)
|
|
271
|
+
continue;
|
|
272
|
+
if (!policy.value || typeof policy.value !== "object" || Array.isArray(policy.value))
|
|
273
|
+
return `the MCP policy in ${file} is invalid; review it manually`;
|
|
274
|
+
const settings = policy.value;
|
|
275
|
+
for (const key of ["allowed", "excluded"]) {
|
|
276
|
+
const patterns = settings[key];
|
|
277
|
+
if (patterns === undefined)
|
|
278
|
+
continue;
|
|
279
|
+
if (!Array.isArray(patterns) || !patterns.every(pattern => typeof pattern === "string"))
|
|
280
|
+
return `the MCP ${key} policy in ${file} is invalid; review it manually`;
|
|
281
|
+
const matches = patterns.some(serverMatches);
|
|
282
|
+
if (key === "allowed" ? !matches : matches)
|
|
283
|
+
return `the MCP ${key} policy in ${file} prevents Cavelon; ask the person or operator to review it`;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return undefined;
|
|
287
|
+
}
|
|
288
|
+
function gooseExtensionName(key, value) {
|
|
289
|
+
const name = value && typeof value === "object" && !Array.isArray(value) ? value.name : undefined;
|
|
290
|
+
const equivalent = (name) => name.replace(/\s/g, "").toLowerCase() === "cavelon";
|
|
291
|
+
const cavelon = equivalent(key) || (typeof name === "string" && equivalent(name));
|
|
292
|
+
return { cavelon, conflicting: key !== "cavelon" || (name !== undefined && name !== "cavelon") };
|
|
293
|
+
}
|
|
294
|
+
function gooseExtensionsPolicy(value, managed, file) {
|
|
295
|
+
if (value === undefined)
|
|
296
|
+
return undefined;
|
|
297
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
298
|
+
return `the extensions in ${file} are not a mapping; review them manually`;
|
|
299
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
300
|
+
const name = gooseExtensionName(key, entry);
|
|
301
|
+
if (!name.cavelon)
|
|
302
|
+
continue;
|
|
303
|
+
if (managed)
|
|
304
|
+
return `a system or additional Cavelon extension in ${file} is preserved; review its binding with the operator`;
|
|
305
|
+
if (name.conflicting)
|
|
306
|
+
return `another Cavelon extension name in ${file} would conflict; review that binding manually`;
|
|
307
|
+
}
|
|
308
|
+
return undefined;
|
|
309
|
+
}
|
|
310
|
+
async function goosePolicy(config, full) {
|
|
311
|
+
for (const candidate of new Set([...(config.managedFiles ?? []), ...config.files])) {
|
|
312
|
+
const file = full(candidate);
|
|
313
|
+
const text = await readTextFile(file);
|
|
314
|
+
if (text === undefined)
|
|
315
|
+
continue;
|
|
316
|
+
const extensions = readYamlEntry(text, ["extensions"]);
|
|
317
|
+
if ("error" in extensions)
|
|
318
|
+
return `${file}: ${extensions.error}`;
|
|
319
|
+
const error = gooseExtensionsPolicy(extensions.value, config.managedFiles?.includes(candidate) ?? false, file);
|
|
320
|
+
if (error)
|
|
321
|
+
return error;
|
|
322
|
+
const allowlist = readYamlEntry(text, ["GOOSE_ALLOWLIST"]);
|
|
323
|
+
if ("error" in allowlist)
|
|
324
|
+
return `${file}: ${allowlist.error}`;
|
|
325
|
+
if (allowlist.value)
|
|
326
|
+
return `Goose's extension allowlist in ${file} requires operator review before Cavelon setup`;
|
|
327
|
+
}
|
|
328
|
+
return undefined;
|
|
329
|
+
}
|
|
330
|
+
export async function resolveNativeMcp(config, root) {
|
|
331
|
+
const full = (file) => root ? path.resolve(root, file) : path.resolve(file);
|
|
332
|
+
if (config.blocked)
|
|
333
|
+
return { file: full(config.file), error: config.blocked };
|
|
334
|
+
if (config.client === "omp") {
|
|
335
|
+
const error = await ompPolicy(config, full);
|
|
336
|
+
if (error)
|
|
337
|
+
return { file: full(config.file), error };
|
|
338
|
+
}
|
|
339
|
+
if (config.client === "goose") {
|
|
340
|
+
const error = await goosePolicy(config, full);
|
|
341
|
+
if (error)
|
|
342
|
+
return { file: full(config.file), error };
|
|
343
|
+
}
|
|
344
|
+
if (config.client === "kilo") {
|
|
345
|
+
for (const file of config.managedOpaqueFiles ?? []) {
|
|
346
|
+
if (await readTextFile(file) !== undefined)
|
|
347
|
+
return { file: full(config.file), error: `managed preferences in ${file} may override Cavelon; review the binding with the operator` };
|
|
348
|
+
}
|
|
349
|
+
for (const candidate of [...(config.managedFiles ?? []), ...(config.compatibilityFiles ?? [])]) {
|
|
350
|
+
const file = full(candidate);
|
|
351
|
+
const selected = readNativeMcp(await readTextFile(file), config);
|
|
352
|
+
if ("error" in selected)
|
|
353
|
+
return { file, error: selected.error };
|
|
354
|
+
if (selected.value !== undefined)
|
|
355
|
+
return { file, error: `a managed or OpenCode-compatible Cavelon server in ${file} is preserved; review its binding before Kilo setup` };
|
|
356
|
+
}
|
|
357
|
+
if (root)
|
|
358
|
+
for (const file of await kiloAncestorFiles(root)) {
|
|
359
|
+
const selected = readNativeMcp(await readTextFile(file), config);
|
|
360
|
+
if ("error" in selected)
|
|
361
|
+
return { file, error: selected.error };
|
|
362
|
+
if (selected.value !== undefined)
|
|
363
|
+
return { file, error: `an inherited Cavelon server in ${file} would be shadowed; review its binding before project setup` };
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
if (config.client === "qwen") {
|
|
367
|
+
const error = await qwenPolicy(config, full);
|
|
368
|
+
if (error)
|
|
369
|
+
return { file: full(config.file), error };
|
|
370
|
+
}
|
|
371
|
+
for (const file of config.shadowFiles ?? []) {
|
|
372
|
+
const entry = readNativeMcp(await readTextFile(file), config);
|
|
373
|
+
if ("error" in entry)
|
|
374
|
+
return { file: full(config.file), error: `${file}: ${entry.error}; review user/project precedence manually` };
|
|
375
|
+
if (entry.value !== undefined && !isKitMcpEntry(entry.value, config.entryFormat, config.extra)) {
|
|
376
|
+
return { file: full(config.file), error: `a personal Cavelon server in ${file} would be shadowed; review user/project precedence manually` };
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
const found = [];
|
|
380
|
+
for (const candidate of config.files) {
|
|
381
|
+
if (config.compatibilityFiles?.includes(candidate))
|
|
382
|
+
continue;
|
|
383
|
+
const file = full(candidate);
|
|
384
|
+
const text = await readTextFile(file);
|
|
385
|
+
if (text === undefined)
|
|
386
|
+
continue;
|
|
387
|
+
const entry = readNativeMcp(text, config);
|
|
388
|
+
if ("error" in entry)
|
|
389
|
+
return { file, error: entry.error };
|
|
390
|
+
found.push({ file, text, current: entry.value, kept: Math.min(entry.kept, config.keys.length - 1) });
|
|
391
|
+
}
|
|
392
|
+
const owners = found.filter(candidate => candidate.current !== undefined);
|
|
393
|
+
if (owners.length > 1)
|
|
394
|
+
return { file: owners.at(-1).file, error: `multiple configuration files define ${config.keys.join(".")}; resolve their precedence manually` };
|
|
395
|
+
const selected = owners[0] ?? found.at(-1);
|
|
396
|
+
return selected ?? { file: full(config.file), text: undefined, current: undefined, kept: 0 };
|
|
397
|
+
}
|