@cleocode/caamp 1.8.1 → 1.9.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/dist/chunk-ER3FIOTM.js +244 -0
- package/dist/chunk-ER3FIOTM.js.map +1 -0
- package/dist/{chunk-CPHF5IM4.js → chunk-MFWBR2NY.js} +20 -290
- package/dist/chunk-MFWBR2NY.js.map +1 -0
- package/dist/{chunk-LDTYDQGR.js → chunk-OLJZ23W3.js} +7 -5
- package/dist/{chunk-LDTYDQGR.js.map → chunk-OLJZ23W3.js.map} +1 -1
- package/dist/chunk-TRIXT4T7.js +276 -0
- package/dist/chunk-TRIXT4T7.js.map +1 -0
- package/dist/cli.js +199 -87
- package/dist/cli.js.map +1 -1
- package/dist/hooks-LV6VU7QJ.js +56 -0
- package/dist/index.d.ts +207 -2
- package/dist/index.js +71 -19
- package/dist/index.js.map +1 -1
- package/dist/{injector-TIUEM4X2.js → injector-P2OL6RK3.js} +3 -2
- package/dist/injector-P2OL6RK3.js.map +1 -0
- package/package.json +1 -1
- package/providers/hook-mappings.json +302 -0
- package/providers/registry.json +599 -156
- package/dist/chunk-CPHF5IM4.js.map +0 -1
- /package/dist/{injector-TIUEM4X2.js.map → hooks-LV6VU7QJ.js.map} +0 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/core/platform-paths.ts
|
|
8
|
+
import envPaths from "env-paths";
|
|
9
|
+
import { arch, homedir, hostname, platform, release } from "os";
|
|
10
|
+
import { isAbsolute, join, resolve } from "path";
|
|
11
|
+
var APP_NAME = "agents";
|
|
12
|
+
function resolveAgentsHomeOverride(value) {
|
|
13
|
+
if (value === void 0) return void 0;
|
|
14
|
+
const trimmed = value.trim();
|
|
15
|
+
if (trimmed.length === 0) return void 0;
|
|
16
|
+
if (trimmed === "~") return homedir();
|
|
17
|
+
if (trimmed.startsWith("~/")) return join(homedir(), trimmed.slice(2));
|
|
18
|
+
if (isAbsolute(trimmed)) return resolve(trimmed);
|
|
19
|
+
return resolve(homedir(), trimmed);
|
|
20
|
+
}
|
|
21
|
+
var _paths = null;
|
|
22
|
+
var _sysInfo = null;
|
|
23
|
+
var _lastAgentsHome = void 0;
|
|
24
|
+
function getPlatformPaths() {
|
|
25
|
+
const currentAgentsHome = process.env["AGENTS_HOME"];
|
|
26
|
+
if (_paths && currentAgentsHome !== _lastAgentsHome) {
|
|
27
|
+
_paths = null;
|
|
28
|
+
_sysInfo = null;
|
|
29
|
+
}
|
|
30
|
+
if (_paths) return _paths;
|
|
31
|
+
const ep = envPaths(APP_NAME, { suffix: "" });
|
|
32
|
+
_lastAgentsHome = currentAgentsHome;
|
|
33
|
+
_paths = {
|
|
34
|
+
data: resolveAgentsHomeOverride(currentAgentsHome) ?? ep.data,
|
|
35
|
+
config: ep.config,
|
|
36
|
+
cache: ep.cache,
|
|
37
|
+
log: ep.log,
|
|
38
|
+
temp: ep.temp
|
|
39
|
+
};
|
|
40
|
+
return _paths;
|
|
41
|
+
}
|
|
42
|
+
function getSystemInfo() {
|
|
43
|
+
if (_sysInfo) return _sysInfo;
|
|
44
|
+
const paths = getPlatformPaths();
|
|
45
|
+
_sysInfo = {
|
|
46
|
+
platform: platform(),
|
|
47
|
+
arch: arch(),
|
|
48
|
+
release: release(),
|
|
49
|
+
hostname: hostname(),
|
|
50
|
+
nodeVersion: process.version,
|
|
51
|
+
paths
|
|
52
|
+
};
|
|
53
|
+
return _sysInfo;
|
|
54
|
+
}
|
|
55
|
+
function _resetPlatformPathsCache() {
|
|
56
|
+
_paths = null;
|
|
57
|
+
_sysInfo = null;
|
|
58
|
+
_lastAgentsHome = void 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// src/core/paths/standard.ts
|
|
62
|
+
import { existsSync } from "fs";
|
|
63
|
+
import { homedir as homedir2 } from "os";
|
|
64
|
+
import { dirname, join as join2 } from "path";
|
|
65
|
+
function getPlatformLocations() {
|
|
66
|
+
const home = homedir2();
|
|
67
|
+
const platform2 = process.platform;
|
|
68
|
+
if (platform2 === "win32") {
|
|
69
|
+
const appData = process.env["APPDATA"] ?? join2(home, "AppData", "Roaming");
|
|
70
|
+
return {
|
|
71
|
+
home,
|
|
72
|
+
config: appData,
|
|
73
|
+
vscodeConfig: join2(appData, "Code", "User"),
|
|
74
|
+
zedConfig: join2(appData, "Zed"),
|
|
75
|
+
claudeDesktopConfig: join2(appData, "Claude"),
|
|
76
|
+
applications: []
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (platform2 === "darwin") {
|
|
80
|
+
const config2 = process.env["XDG_CONFIG_HOME"] ?? join2(home, ".config");
|
|
81
|
+
return {
|
|
82
|
+
home,
|
|
83
|
+
config: config2,
|
|
84
|
+
vscodeConfig: join2(home, "Library", "Application Support", "Code", "User"),
|
|
85
|
+
zedConfig: join2(home, "Library", "Application Support", "Zed"),
|
|
86
|
+
claudeDesktopConfig: join2(home, "Library", "Application Support", "Claude"),
|
|
87
|
+
applications: ["/Applications", join2(home, "Applications")]
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const config = process.env["XDG_CONFIG_HOME"] ?? join2(home, ".config");
|
|
91
|
+
return {
|
|
92
|
+
home,
|
|
93
|
+
config,
|
|
94
|
+
vscodeConfig: join2(config, "Code", "User"),
|
|
95
|
+
zedConfig: join2(config, "zed"),
|
|
96
|
+
claudeDesktopConfig: join2(config, "Claude"),
|
|
97
|
+
applications: []
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function getAgentsHome() {
|
|
101
|
+
return getPlatformPaths().data;
|
|
102
|
+
}
|
|
103
|
+
function getProjectAgentsDir(projectRoot = process.cwd()) {
|
|
104
|
+
return join2(projectRoot, ".agents");
|
|
105
|
+
}
|
|
106
|
+
function resolveProjectPath(relativePath, projectDir = process.cwd()) {
|
|
107
|
+
return join2(projectDir, relativePath);
|
|
108
|
+
}
|
|
109
|
+
function getCanonicalSkillsDir() {
|
|
110
|
+
return join2(getAgentsHome(), "skills");
|
|
111
|
+
}
|
|
112
|
+
function getLockFilePath() {
|
|
113
|
+
return join2(getAgentsHome(), ".caamp-lock.json");
|
|
114
|
+
}
|
|
115
|
+
function getAgentsMcpDir(scope = "global", projectDir) {
|
|
116
|
+
if (scope === "global") return join2(getAgentsHome(), "mcp");
|
|
117
|
+
return join2(projectDir ?? process.cwd(), ".agents", "mcp");
|
|
118
|
+
}
|
|
119
|
+
function getAgentsMcpServersPath(scope = "global", projectDir) {
|
|
120
|
+
return join2(getAgentsMcpDir(scope, projectDir), "servers.json");
|
|
121
|
+
}
|
|
122
|
+
function getAgentsInstructFile(scope = "global", projectDir) {
|
|
123
|
+
if (scope === "global") return join2(getAgentsHome(), "AGENTS.md");
|
|
124
|
+
return join2(projectDir ?? process.cwd(), ".agents", "AGENTS.md");
|
|
125
|
+
}
|
|
126
|
+
function getAgentsConfigPath(scope = "global", projectDir) {
|
|
127
|
+
if (scope === "global") return join2(getAgentsHome(), "config.toml");
|
|
128
|
+
return join2(projectDir ?? process.cwd(), ".agents", "config.toml");
|
|
129
|
+
}
|
|
130
|
+
function getAgentsWikiDir(scope = "global", projectDir) {
|
|
131
|
+
if (scope === "global") return join2(getAgentsHome(), "wiki");
|
|
132
|
+
return join2(projectDir ?? process.cwd(), ".agents", "wiki");
|
|
133
|
+
}
|
|
134
|
+
function getAgentsSpecDir(scope = "global", projectDir) {
|
|
135
|
+
if (scope === "global") return join2(getAgentsHome(), "spec");
|
|
136
|
+
return join2(projectDir ?? process.cwd(), ".agents", "spec");
|
|
137
|
+
}
|
|
138
|
+
function getAgentsLinksDir(scope = "global", projectDir) {
|
|
139
|
+
if (scope === "global") return join2(getAgentsHome(), "links");
|
|
140
|
+
return join2(projectDir ?? process.cwd(), ".agents", "links");
|
|
141
|
+
}
|
|
142
|
+
function resolveRegistryTemplatePath(template) {
|
|
143
|
+
const locations = getPlatformLocations();
|
|
144
|
+
return template.replace(/\$HOME/g, locations.home).replace(/\$CONFIG/g, locations.config).replace(/\$VSCODE_CONFIG/g, locations.vscodeConfig).replace(/\$ZED_CONFIG/g, locations.zedConfig).replace(/\$CLAUDE_DESKTOP_CONFIG/g, locations.claudeDesktopConfig).replace(/\$AGENTS_HOME/g, getAgentsHome());
|
|
145
|
+
}
|
|
146
|
+
function resolveProviderConfigPath(provider, scope, projectDir = process.cwd()) {
|
|
147
|
+
if (scope === "global") {
|
|
148
|
+
return provider.configPathGlobal;
|
|
149
|
+
}
|
|
150
|
+
if (!provider.configPathProject) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
return resolveProjectPath(provider.configPathProject, projectDir);
|
|
154
|
+
}
|
|
155
|
+
function resolvePreferredConfigScope(provider, useGlobalFlag) {
|
|
156
|
+
if (useGlobalFlag) {
|
|
157
|
+
return "global";
|
|
158
|
+
}
|
|
159
|
+
return provider.configPathProject ? "project" : "global";
|
|
160
|
+
}
|
|
161
|
+
function resolveProviderSkillsDir(provider, scope, projectDir = process.cwd()) {
|
|
162
|
+
if (scope === "global") {
|
|
163
|
+
return provider.pathSkills;
|
|
164
|
+
}
|
|
165
|
+
return resolveProjectPath(provider.pathProjectSkills, projectDir);
|
|
166
|
+
}
|
|
167
|
+
function resolveProviderSkillsDirs(provider, scope, projectDir = process.cwd()) {
|
|
168
|
+
const vendorPath = resolveProviderSkillsDir(provider, scope, projectDir);
|
|
169
|
+
const precedence = provider.capabilities?.skills?.precedence ?? "vendor-only";
|
|
170
|
+
const resolveAgentsPath = () => {
|
|
171
|
+
if (scope === "global") {
|
|
172
|
+
return provider.capabilities?.skills?.agentsGlobalPath ?? null;
|
|
173
|
+
}
|
|
174
|
+
const projectRelative = provider.capabilities?.skills?.agentsProjectPath ?? null;
|
|
175
|
+
return projectRelative ? join2(projectDir, projectRelative) : null;
|
|
176
|
+
};
|
|
177
|
+
switch (precedence) {
|
|
178
|
+
case "vendor-only":
|
|
179
|
+
return [vendorPath];
|
|
180
|
+
case "agents-canonical": {
|
|
181
|
+
const agentsPath = resolveAgentsPath();
|
|
182
|
+
return agentsPath ? [agentsPath] : [vendorPath];
|
|
183
|
+
}
|
|
184
|
+
case "agents-first": {
|
|
185
|
+
const agentsPath = resolveAgentsPath();
|
|
186
|
+
return agentsPath ? [agentsPath, vendorPath] : [vendorPath];
|
|
187
|
+
}
|
|
188
|
+
case "agents-supported": {
|
|
189
|
+
const agentsPath = resolveAgentsPath();
|
|
190
|
+
return agentsPath ? [vendorPath, agentsPath] : [vendorPath];
|
|
191
|
+
}
|
|
192
|
+
case "vendor-global-agents-project": {
|
|
193
|
+
if (scope === "global") {
|
|
194
|
+
return [vendorPath];
|
|
195
|
+
}
|
|
196
|
+
const agentsPath = resolveAgentsPath();
|
|
197
|
+
return agentsPath ? [agentsPath, vendorPath] : [vendorPath];
|
|
198
|
+
}
|
|
199
|
+
default:
|
|
200
|
+
return [vendorPath];
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function resolveProviderProjectPath(provider, projectDir = process.cwd()) {
|
|
204
|
+
return resolveProjectPath(provider.pathProject, projectDir);
|
|
205
|
+
}
|
|
206
|
+
function resolveProvidersRegistryPath(startDir) {
|
|
207
|
+
const candidates = [
|
|
208
|
+
join2(startDir, "..", "..", "..", "providers", "registry.json"),
|
|
209
|
+
join2(startDir, "..", "providers", "registry.json")
|
|
210
|
+
];
|
|
211
|
+
for (const candidate of candidates) {
|
|
212
|
+
if (existsSync(candidate)) {
|
|
213
|
+
return candidate;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
let current = startDir;
|
|
217
|
+
for (let i = 0; i < 8; i += 1) {
|
|
218
|
+
const candidate = join2(current, "providers", "registry.json");
|
|
219
|
+
if (existsSync(candidate)) {
|
|
220
|
+
return candidate;
|
|
221
|
+
}
|
|
222
|
+
current = dirname(current);
|
|
223
|
+
}
|
|
224
|
+
throw new Error(`Cannot find providers/registry.json (searched from ${startDir})`);
|
|
225
|
+
}
|
|
226
|
+
function normalizeSkillSubPath(path) {
|
|
227
|
+
if (!path) return void 0;
|
|
228
|
+
const normalized = path.replace(/\\/g, "/").replace(/^\/+/, "").replace(/\/SKILL\.md$/i, "").trim();
|
|
229
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
230
|
+
}
|
|
231
|
+
function buildSkillSubPathCandidates(marketplacePath, parsedPath) {
|
|
232
|
+
const candidates = [];
|
|
233
|
+
const base = normalizeSkillSubPath(marketplacePath);
|
|
234
|
+
const parsed = normalizeSkillSubPath(parsedPath);
|
|
235
|
+
if (base) candidates.push(base);
|
|
236
|
+
if (parsed) candidates.push(parsed);
|
|
237
|
+
const knownPrefixes = [".agents", ".claude"];
|
|
238
|
+
for (const value of [base, parsed]) {
|
|
239
|
+
if (!value || !value.startsWith("skills/")) continue;
|
|
240
|
+
for (const prefix of knownPrefixes) {
|
|
241
|
+
candidates.push(`${prefix}/${value}`);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (candidates.length === 0) {
|
|
245
|
+
candidates.push(void 0);
|
|
246
|
+
}
|
|
247
|
+
return Array.from(new Set(candidates));
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export {
|
|
251
|
+
__export,
|
|
252
|
+
getPlatformPaths,
|
|
253
|
+
getSystemInfo,
|
|
254
|
+
_resetPlatformPathsCache,
|
|
255
|
+
getPlatformLocations,
|
|
256
|
+
getAgentsHome,
|
|
257
|
+
getProjectAgentsDir,
|
|
258
|
+
getCanonicalSkillsDir,
|
|
259
|
+
getLockFilePath,
|
|
260
|
+
getAgentsMcpDir,
|
|
261
|
+
getAgentsMcpServersPath,
|
|
262
|
+
getAgentsInstructFile,
|
|
263
|
+
getAgentsConfigPath,
|
|
264
|
+
getAgentsWikiDir,
|
|
265
|
+
getAgentsSpecDir,
|
|
266
|
+
getAgentsLinksDir,
|
|
267
|
+
resolveRegistryTemplatePath,
|
|
268
|
+
resolveProviderConfigPath,
|
|
269
|
+
resolvePreferredConfigScope,
|
|
270
|
+
resolveProviderSkillsDir,
|
|
271
|
+
resolveProviderSkillsDirs,
|
|
272
|
+
resolveProviderProjectPath,
|
|
273
|
+
resolveProvidersRegistryPath,
|
|
274
|
+
buildSkillSubPathCandidates
|
|
275
|
+
};
|
|
276
|
+
//# sourceMappingURL=chunk-TRIXT4T7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/platform-paths.ts","../src/core/paths/standard.ts"],"sourcesContent":["/**\n * Central OS platform path resolution using env-paths.\n *\n * Provides OS-appropriate paths for CAAMP's global directories using\n * XDG conventions on Linux, standard conventions on macOS/Windows.\n * Results are cached for the process lifetime. Env vars take precedence.\n *\n * Platform path defaults:\n * data: ~/.local/share/agents | ~/Library/Application Support/agents | %LOCALAPPDATA%\\agents\\Data\n * config: ~/.config/agents | ~/Library/Preferences/agents | %APPDATA%\\agents\\Config\n * cache: ~/.cache/agents | ~/Library/Caches/agents | %LOCALAPPDATA%\\agents\\Cache\n * log: ~/.local/state/agents | ~/Library/Logs/agents | %LOCALAPPDATA%\\agents\\Log\n * temp: /tmp/<user>/agents | /var/folders/.../agents | %TEMP%\\agents\n *\n * AGENTS_HOME env var overrides the data path for backward compatibility\n * with existing ~/.agents installations.\n */\n\nimport envPaths from 'env-paths';\nimport { arch, homedir, hostname, platform, release } from 'node:os';\nimport { isAbsolute, join, resolve } from 'node:path';\n\nconst APP_NAME = 'agents';\n\n/**\n * Normalize an AGENTS_HOME env var value to an absolute path.\n * Returns undefined when the value is absent, empty, or whitespace-only\n * (callers should fall back to the OS default in that case).\n */\nfunction resolveAgentsHomeOverride(value: string | undefined): string | undefined {\n if (value === undefined) return undefined;\n const trimmed = value.trim();\n if (trimmed.length === 0) return undefined;\n if (trimmed === '~') return homedir();\n if (trimmed.startsWith('~/')) return join(homedir(), trimmed.slice(2));\n if (isAbsolute(trimmed)) return resolve(trimmed);\n return resolve(homedir(), trimmed);\n}\n\nexport interface PlatformPaths {\n /** User data dir. Override with AGENTS_HOME env var. */\n data: string;\n /** OS config dir (XDG_CONFIG_HOME / Library/Preferences / %APPDATA%). */\n config: string;\n /** OS cache dir. */\n cache: string;\n /** OS log dir. */\n log: string;\n /** OS temp dir. */\n temp: string;\n}\n\nexport interface SystemInfo {\n platform: NodeJS.Platform;\n arch: string;\n release: string;\n hostname: string;\n nodeVersion: string;\n paths: PlatformPaths;\n}\n\nlet _paths: PlatformPaths | null = null;\nlet _sysInfo: SystemInfo | null = null;\nlet _lastAgentsHome: string | undefined = undefined;\n\n/**\n * Get OS-appropriate paths for CAAMP's global directories.\n * Cached after first call. AGENTS_HOME env var overrides the data path.\n * Cache auto-invalidates when AGENTS_HOME changes (supports test isolation).\n */\nexport function getPlatformPaths(): PlatformPaths {\n const currentAgentsHome = process.env['AGENTS_HOME'];\n\n // Invalidate if AGENTS_HOME changed since last cache build\n if (_paths && currentAgentsHome !== _lastAgentsHome) {\n _paths = null;\n _sysInfo = null;\n }\n\n if (_paths) return _paths;\n\n const ep = envPaths(APP_NAME, { suffix: '' });\n _lastAgentsHome = currentAgentsHome;\n\n _paths = {\n data: resolveAgentsHomeOverride(currentAgentsHome) ?? ep.data,\n config: ep.config,\n cache: ep.cache,\n log: ep.log,\n temp: ep.temp,\n };\n\n return _paths;\n}\n\n/**\n * Get a cached system information snapshot.\n * Captured once and reused for the process lifetime.\n */\nexport function getSystemInfo(): SystemInfo {\n if (_sysInfo) return _sysInfo;\n\n const paths = getPlatformPaths();\n\n _sysInfo = {\n platform: platform(),\n arch: arch(),\n release: release(),\n hostname: hostname(),\n nodeVersion: process.version,\n paths,\n };\n\n return _sysInfo;\n}\n\n/**\n * Invalidate the path and system info caches.\n * Use in tests after mutating AGENTS_HOME env var.\n * @internal\n */\nexport function _resetPlatformPathsCache(): void {\n _paths = null;\n _sysInfo = null;\n _lastAgentsHome = undefined;\n}\n","import { existsSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport type { Provider } from \"../../types.js\";\nimport { getPlatformPaths } from \"../platform-paths.js\";\n\nexport type PathScope = \"project\" | \"global\";\n\nexport interface PlatformLocations {\n home: string;\n config: string;\n vscodeConfig: string;\n zedConfig: string;\n claudeDesktopConfig: string;\n applications: string[];\n}\n\nexport function getPlatformLocations(): PlatformLocations {\n const home = homedir();\n const platform = process.platform;\n\n if (platform === \"win32\") {\n const appData = process.env[\"APPDATA\"] ?? join(home, \"AppData\", \"Roaming\");\n return {\n home,\n config: appData,\n vscodeConfig: join(appData, \"Code\", \"User\"),\n zedConfig: join(appData, \"Zed\"),\n claudeDesktopConfig: join(appData, \"Claude\"),\n applications: [],\n };\n }\n\n if (platform === \"darwin\") {\n const config = process.env[\"XDG_CONFIG_HOME\"] ?? join(home, \".config\");\n return {\n home,\n config,\n vscodeConfig: join(home, \"Library\", \"Application Support\", \"Code\", \"User\"),\n zedConfig: join(home, \"Library\", \"Application Support\", \"Zed\"),\n claudeDesktopConfig: join(home, \"Library\", \"Application Support\", \"Claude\"),\n applications: [\"/Applications\", join(home, \"Applications\")],\n };\n }\n\n const config = process.env[\"XDG_CONFIG_HOME\"] ?? join(home, \".config\");\n return {\n home,\n config,\n vscodeConfig: join(config, \"Code\", \"User\"),\n zedConfig: join(config, \"zed\"),\n claudeDesktopConfig: join(config, \"Claude\"),\n applications: [],\n };\n}\n\nexport function getAgentsHome(): string {\n return getPlatformPaths().data;\n}\n\nexport function getProjectAgentsDir(projectRoot = process.cwd()): string {\n return join(projectRoot, \".agents\");\n}\n\nexport function resolveProjectPath(relativePath: string, projectDir = process.cwd()): string {\n return join(projectDir, relativePath);\n}\n\nexport function getCanonicalSkillsDir(): string {\n return join(getAgentsHome(), \"skills\");\n}\n\nexport function getLockFilePath(): string {\n return join(getAgentsHome(), \".caamp-lock.json\");\n}\n\n// ── .agents/ Standard Directory Structure ────────────────────────────\n\n/**\n * Get the MCP directory within `.agents/`.\n *\n * @param scope - `\"global\"` for `~/.agents/mcp/`, `\"project\"` for `<project>/.agents/mcp/`\n * @param projectDir - Project root (defaults to `process.cwd()`)\n */\nexport function getAgentsMcpDir(scope: PathScope = \"global\", projectDir?: string): string {\n if (scope === \"global\") return join(getAgentsHome(), \"mcp\");\n return join(projectDir ?? process.cwd(), \".agents\", \"mcp\");\n}\n\n/**\n * Get the MCP servers.json path within `.agents/`.\n *\n * Per the `.agents/` standard (Section 9), this is the canonical MCP\n * server registry that should be checked before legacy per-provider configs.\n *\n * @param scope - `\"global\"` for `~/.agents/mcp/servers.json`, `\"project\"` for `<project>/.agents/mcp/servers.json`\n * @param projectDir - Project root (defaults to `process.cwd()`)\n */\nexport function getAgentsMcpServersPath(scope: PathScope = \"global\", projectDir?: string): string {\n return join(getAgentsMcpDir(scope, projectDir), \"servers.json\");\n}\n\n/**\n * Get the primary AGENTS.md instruction file path within `.agents/`.\n *\n * @param scope - `\"global\"` for `~/.agents/AGENTS.md`, `\"project\"` for `<project>/.agents/AGENTS.md`\n * @param projectDir - Project root (defaults to `process.cwd()`)\n */\nexport function getAgentsInstructFile(scope: PathScope = \"global\", projectDir?: string): string {\n if (scope === \"global\") return join(getAgentsHome(), \"AGENTS.md\");\n return join(projectDir ?? process.cwd(), \".agents\", \"AGENTS.md\");\n}\n\n/**\n * Get the config.toml path within `.agents/`.\n *\n * @param scope - `\"global\"` for `~/.agents/config.toml`, `\"project\"` for `<project>/.agents/config.toml`\n * @param projectDir - Project root (defaults to `process.cwd()`)\n */\nexport function getAgentsConfigPath(scope: PathScope = \"global\", projectDir?: string): string {\n if (scope === \"global\") return join(getAgentsHome(), \"config.toml\");\n return join(projectDir ?? process.cwd(), \".agents\", \"config.toml\");\n}\n\n/**\n * Get the wiki directory within `.agents/`.\n *\n * @param scope - `\"global\"` or `\"project\"`\n * @param projectDir - Project root (defaults to `process.cwd()`)\n */\nexport function getAgentsWikiDir(scope: PathScope = \"global\", projectDir?: string): string {\n if (scope === \"global\") return join(getAgentsHome(), \"wiki\");\n return join(projectDir ?? process.cwd(), \".agents\", \"wiki\");\n}\n\n/**\n * Get the spec directory within `.agents/`.\n *\n * @param scope - `\"global\"` or `\"project\"`\n * @param projectDir - Project root (defaults to `process.cwd()`)\n */\nexport function getAgentsSpecDir(scope: PathScope = \"global\", projectDir?: string): string {\n if (scope === \"global\") return join(getAgentsHome(), \"spec\");\n return join(projectDir ?? process.cwd(), \".agents\", \"spec\");\n}\n\n/**\n * Get the links directory within `.agents/`.\n *\n * @param scope - `\"global\"` or `\"project\"`\n * @param projectDir - Project root (defaults to `process.cwd()`)\n */\nexport function getAgentsLinksDir(scope: PathScope = \"global\", projectDir?: string): string {\n if (scope === \"global\") return join(getAgentsHome(), \"links\");\n return join(projectDir ?? process.cwd(), \".agents\", \"links\");\n}\n\nexport function resolveRegistryTemplatePath(template: string): string {\n const locations = getPlatformLocations();\n return template\n .replace(/\\$HOME/g, locations.home)\n .replace(/\\$CONFIG/g, locations.config)\n .replace(/\\$VSCODE_CONFIG/g, locations.vscodeConfig)\n .replace(/\\$ZED_CONFIG/g, locations.zedConfig)\n .replace(/\\$CLAUDE_DESKTOP_CONFIG/g, locations.claudeDesktopConfig)\n .replace(/\\$AGENTS_HOME/g, getAgentsHome());\n}\n\nexport function resolveProviderConfigPath(\n provider: Provider,\n scope: PathScope,\n projectDir = process.cwd(),\n): string | null {\n if (scope === \"global\") {\n return provider.configPathGlobal;\n }\n if (!provider.configPathProject) {\n return null;\n }\n return resolveProjectPath(provider.configPathProject, projectDir);\n}\n\nexport function resolvePreferredConfigScope(provider: Provider, useGlobalFlag?: boolean): PathScope {\n if (useGlobalFlag) {\n return \"global\";\n }\n return provider.configPathProject ? \"project\" : \"global\";\n}\n\nexport function resolveProviderSkillsDir(\n provider: Provider,\n scope: PathScope,\n projectDir = process.cwd(),\n): string {\n if (scope === \"global\") {\n return provider.pathSkills;\n }\n return resolveProjectPath(provider.pathProjectSkills, projectDir);\n}\n\n/**\n * Get ALL target directories for skill installation based on the provider's\n * skills precedence setting.\n *\n * @param provider - Provider to resolve paths for\n * @param scope - Whether to resolve global or project paths\n * @param projectDir - Project directory for project-scope resolution\n * @returns Array of target directories for symlink creation\n */\nexport function resolveProviderSkillsDirs(\n provider: Provider,\n scope: PathScope,\n projectDir = process.cwd(),\n): string[] {\n const vendorPath = resolveProviderSkillsDir(provider, scope, projectDir);\n const precedence = provider.capabilities?.skills?.precedence ?? \"vendor-only\";\n\n const resolveAgentsPath = (): string | null => {\n if (scope === \"global\") {\n return provider.capabilities?.skills?.agentsGlobalPath ?? null;\n }\n const projectRelative = provider.capabilities?.skills?.agentsProjectPath ?? null;\n return projectRelative ? join(projectDir, projectRelative) : null;\n };\n\n switch (precedence) {\n case \"vendor-only\":\n return [vendorPath];\n\n case \"agents-canonical\": {\n const agentsPath = resolveAgentsPath();\n return agentsPath ? [agentsPath] : [vendorPath];\n }\n\n case \"agents-first\": {\n const agentsPath = resolveAgentsPath();\n return agentsPath ? [agentsPath, vendorPath] : [vendorPath];\n }\n\n case \"agents-supported\": {\n const agentsPath = resolveAgentsPath();\n return agentsPath ? [vendorPath, agentsPath] : [vendorPath];\n }\n\n case \"vendor-global-agents-project\": {\n if (scope === \"global\") {\n return [vendorPath];\n }\n const agentsPath = resolveAgentsPath();\n return agentsPath ? [agentsPath, vendorPath] : [vendorPath];\n }\n\n default:\n return [vendorPath];\n }\n}\n\nexport function resolveProviderProjectPath(provider: Provider, projectDir = process.cwd()): string {\n return resolveProjectPath(provider.pathProject, projectDir);\n}\n\nexport function resolveProvidersRegistryPath(startDir: string): string {\n const candidates = [\n join(startDir, \"..\", \"..\", \"..\", \"providers\", \"registry.json\"),\n join(startDir, \"..\", \"providers\", \"registry.json\"),\n ];\n\n for (const candidate of candidates) {\n if (existsSync(candidate)) {\n return candidate;\n }\n }\n\n let current = startDir;\n for (let i = 0; i < 8; i += 1) {\n const candidate = join(current, \"providers\", \"registry.json\");\n if (existsSync(candidate)) {\n return candidate;\n }\n current = dirname(current);\n }\n\n throw new Error(`Cannot find providers/registry.json (searched from ${startDir})`);\n}\n\nexport function normalizeSkillSubPath(path: string | undefined): string | undefined {\n if (!path) return undefined;\n const normalized = path.replace(/\\\\/g, \"/\").replace(/^\\/+/, \"\").replace(/\\/SKILL\\.md$/i, \"\").trim();\n return normalized.length > 0 ? normalized : undefined;\n}\n\nexport function buildSkillSubPathCandidates(\n marketplacePath: string | undefined,\n parsedPath: string | undefined,\n): (string | undefined)[] {\n const candidates: (string | undefined)[] = [];\n const base = normalizeSkillSubPath(marketplacePath);\n const parsed = normalizeSkillSubPath(parsedPath);\n\n if (base) candidates.push(base);\n if (parsed) candidates.push(parsed);\n\n const knownPrefixes = [\".agents\", \".claude\"];\n for (const value of [base, parsed]) {\n if (!value || !value.startsWith(\"skills/\")) continue;\n for (const prefix of knownPrefixes) {\n candidates.push(`${prefix}/${value}`);\n }\n }\n\n if (candidates.length === 0) {\n candidates.push(undefined);\n }\n\n return Array.from(new Set(candidates));\n}\n"],"mappings":";;;;;;;AAkBA,OAAO,cAAc;AACrB,SAAS,MAAM,SAAS,UAAU,UAAU,eAAe;AAC3D,SAAS,YAAY,MAAM,eAAe;AAE1C,IAAM,WAAW;AAOjB,SAAS,0BAA0B,OAA+C;AAChF,MAAI,UAAU,OAAW,QAAO;AAChC,QAAM,UAAU,MAAM,KAAK;AAC3B,MAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,MAAI,YAAY,IAAK,QAAO,QAAQ;AACpC,MAAI,QAAQ,WAAW,IAAI,EAAG,QAAO,KAAK,QAAQ,GAAG,QAAQ,MAAM,CAAC,CAAC;AACrE,MAAI,WAAW,OAAO,EAAG,QAAO,QAAQ,OAAO;AAC/C,SAAO,QAAQ,QAAQ,GAAG,OAAO;AACnC;AAwBA,IAAI,SAA+B;AACnC,IAAI,WAA8B;AAClC,IAAI,kBAAsC;AAOnC,SAAS,mBAAkC;AAChD,QAAM,oBAAoB,QAAQ,IAAI,a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A,IACtC;AAAA,EACF;AAEA,MAAI,WAAW,WAAW,GAAG;AAC3B,eAAW,KAAK,MAAS;AAAA,EAC3B;AAEA,SAAO,MAAM,KAAK,IAAI,IAAI,UAAU,CAAC;AACvC;","names":["homedir","join","homedir","platform","join","config"]}
|
package/dist/cli.js
CHANGED
|
@@ -61,26 +61,35 @@ import {
|
|
|
61
61
|
tokenizeCriteriaValue,
|
|
62
62
|
updateInstructionsSingleOperation,
|
|
63
63
|
validateSkill
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-OLJZ23W3.js";
|
|
65
65
|
import {
|
|
66
|
-
buildSkillSubPathCandidates,
|
|
67
66
|
buildSkillsMap,
|
|
68
67
|
checkAllInjections,
|
|
69
68
|
generateInjectionContent,
|
|
70
69
|
getAllProviders,
|
|
71
|
-
getCommonHookEvents,
|
|
72
70
|
getProvider,
|
|
73
71
|
getProviderCount,
|
|
74
|
-
getProvidersByHookEvent,
|
|
75
72
|
getProvidersByPriority,
|
|
76
73
|
getRegistryVersion,
|
|
77
74
|
groupByInstructFile,
|
|
78
75
|
injectAll,
|
|
79
|
-
providerSupports
|
|
76
|
+
providerSupports
|
|
77
|
+
} from "./chunk-MFWBR2NY.js";
|
|
78
|
+
import {
|
|
79
|
+
CANONICAL_HOOK_EVENTS,
|
|
80
|
+
buildHookMatrix,
|
|
81
|
+
getCommonEvents,
|
|
82
|
+
getHookMappingsVersion,
|
|
83
|
+
getHookSupport,
|
|
84
|
+
getProviderSummary,
|
|
85
|
+
translateToAll
|
|
86
|
+
} from "./chunk-ER3FIOTM.js";
|
|
87
|
+
import {
|
|
88
|
+
buildSkillSubPathCandidates,
|
|
80
89
|
resolvePreferredConfigScope,
|
|
81
90
|
resolveProviderConfigPath,
|
|
82
91
|
resolveProviderSkillsDir
|
|
83
|
-
} from "./chunk-
|
|
92
|
+
} from "./chunk-TRIXT4T7.js";
|
|
84
93
|
|
|
85
94
|
// src/cli.ts
|
|
86
95
|
import { Command } from "commander";
|
|
@@ -2936,8 +2945,69 @@ ${provider.toolName}`));
|
|
|
2936
2945
|
${map.length} providers shown`));
|
|
2937
2946
|
console.log();
|
|
2938
2947
|
});
|
|
2939
|
-
providers.command("hooks").description("Show provider hook event support")
|
|
2940
|
-
|
|
2948
|
+
const hooks = providers.command("hooks").description("Show provider hook event support");
|
|
2949
|
+
hooks.command("list", { isDefault: true }).description("Show all providers with their hook support summary").option("--json", "Output as JSON (default)").option("--human", "Output in human-readable format").action(async (opts) => {
|
|
2950
|
+
const operation = "providers.hooks.list";
|
|
2951
|
+
const mvi = "standard";
|
|
2952
|
+
let format;
|
|
2953
|
+
try {
|
|
2954
|
+
format = resolveOutputFormat2({
|
|
2955
|
+
jsonFlag: opts.json ?? false,
|
|
2956
|
+
humanFlag: (opts.human ?? false) || isHuman(),
|
|
2957
|
+
projectDefault: "json"
|
|
2958
|
+
}).format;
|
|
2959
|
+
} catch (error) {
|
|
2960
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2961
|
+
emitJsonError2(operation, mvi, "E_FORMAT_CONFLICT", message, "VALIDATION");
|
|
2962
|
+
process.exit(1);
|
|
2963
|
+
}
|
|
2964
|
+
const all = getAllProviders();
|
|
2965
|
+
const summaries = all.map((p) => getProviderSummary(p.id)).filter((s) => s !== void 0);
|
|
2966
|
+
if (format === "json") {
|
|
2967
|
+
const envelope = buildEnvelope4(
|
|
2968
|
+
operation,
|
|
2969
|
+
mvi,
|
|
2970
|
+
{
|
|
2971
|
+
mappingsVersion: getHookMappingsVersion(),
|
|
2972
|
+
canonicalEventCount: CANONICAL_HOOK_EVENTS.length,
|
|
2973
|
+
providers: summaries
|
|
2974
|
+
},
|
|
2975
|
+
null
|
|
2976
|
+
);
|
|
2977
|
+
console.log(JSON.stringify(envelope, null, 2));
|
|
2978
|
+
return;
|
|
2979
|
+
}
|
|
2980
|
+
console.log(pc11.bold(`
|
|
2981
|
+
CAMP Hook Support (mappings v${getHookMappingsVersion()})
|
|
2982
|
+
`));
|
|
2983
|
+
console.log(pc11.dim(` ${CANONICAL_HOOK_EVENTS.length} canonical events defined
|
|
2984
|
+
`));
|
|
2985
|
+
console.log(
|
|
2986
|
+
` ${pc11.bold("Provider".padEnd(22))} ${pc11.bold("System".padEnd(10))} ${pc11.bold("Coverage".padEnd(12))} ${pc11.bold("Supported".padEnd(12))} ${pc11.bold("Provider-Only")}`
|
|
2987
|
+
);
|
|
2988
|
+
console.log(` ${"\u2500".repeat(22)} ${"\u2500".repeat(10)} ${"\u2500".repeat(12)} ${"\u2500".repeat(12)} ${"\u2500".repeat(20)}`);
|
|
2989
|
+
for (const s of summaries) {
|
|
2990
|
+
if (!s) continue;
|
|
2991
|
+
const system = s.hookSystem === "none" ? pc11.dim("none") : s.experimental ? pc11.yellow(s.hookSystem + "*") : pc11.green(s.hookSystem);
|
|
2992
|
+
const coverage = s.coverage > 0 ? (s.coverage >= 75 ? pc11.green : s.coverage >= 40 ? pc11.yellow : pc11.dim)(`${s.coverage}%`) : pc11.dim("0%");
|
|
2993
|
+
const supported = s.supportedCount > 0 ? `${s.supportedCount}/${s.totalCanonical}` : pc11.dim("0");
|
|
2994
|
+
const provOnly = s.providerOnly.length > 0 ? String(s.providerOnly.length) : pc11.dim("-");
|
|
2995
|
+
const provider = getProvider(s.providerId);
|
|
2996
|
+
const name = provider?.toolName ?? s.providerId;
|
|
2997
|
+
console.log(
|
|
2998
|
+
` ${name.padEnd(22)} ${system.padEnd(20)} ${coverage.padEnd(22)} ${supported.padEnd(22)} ${provOnly}`
|
|
2999
|
+
);
|
|
3000
|
+
}
|
|
3001
|
+
const withHooks = summaries.filter((s) => s && s.supportedCount > 0);
|
|
3002
|
+
console.log(pc11.dim(`
|
|
3003
|
+
${withHooks.length} providers with hook support, ${summaries.length - withHooks.length} without`));
|
|
3004
|
+
if (summaries.some((s) => s?.experimental)) {
|
|
3005
|
+
console.log(pc11.dim(" * = experimental hook system"));
|
|
3006
|
+
}
|
|
3007
|
+
console.log();
|
|
3008
|
+
});
|
|
3009
|
+
hooks.command("matrix").description("Show cross-provider hook support matrix").option("--json", "Output as JSON (default)").option("--human", "Output in human-readable format").option("--provider <ids>", "Comma-separated provider IDs to compare").action(async (opts) => {
|
|
3010
|
+
const operation = "providers.hooks.matrix";
|
|
2941
3011
|
const mvi = "standard";
|
|
2942
3012
|
let format;
|
|
2943
3013
|
try {
|
|
@@ -2951,102 +3021,144 @@ ${provider.toolName}`));
|
|
|
2951
3021
|
emitJsonError2(operation, mvi, "E_FORMAT_CONFLICT", message, "VALIDATION");
|
|
2952
3022
|
process.exit(1);
|
|
2953
3023
|
}
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
3024
|
+
const ids = opts.provider?.split(",").map((s) => s.trim());
|
|
3025
|
+
const matrix = buildHookMatrix(ids);
|
|
3026
|
+
if (format === "json") {
|
|
3027
|
+
const envelope = buildEnvelope4(operation, mvi, { matrix }, null);
|
|
3028
|
+
console.log(JSON.stringify(envelope, null, 2));
|
|
3029
|
+
return;
|
|
3030
|
+
}
|
|
3031
|
+
const providerNames = matrix.providers.map((id) => {
|
|
3032
|
+
const p = getProvider(id);
|
|
3033
|
+
return (p?.toolName ?? id).slice(0, 14);
|
|
3034
|
+
});
|
|
3035
|
+
console.log(pc11.bold("\nHook Support Matrix\n"));
|
|
3036
|
+
const eventCol = "CAAMP Event".padEnd(22);
|
|
3037
|
+
const provCols = providerNames.map((n) => pc11.bold(n.padEnd(16))).join("");
|
|
3038
|
+
console.log(` ${pc11.bold(eventCol)} ${provCols}`);
|
|
3039
|
+
console.log(` ${"\u2500".repeat(22)} ${providerNames.map(() => "\u2500".repeat(16)).join("")}`);
|
|
3040
|
+
for (const event of matrix.events) {
|
|
3041
|
+
const cells = matrix.providers.map((id) => {
|
|
3042
|
+
const m = matrix.matrix[event][id];
|
|
3043
|
+
if (!m?.supported) return pc11.dim("\xB7".padEnd(16));
|
|
3044
|
+
return pc11.green((m.nativeName ?? "?").slice(0, 14).padEnd(16));
|
|
3045
|
+
}).join("");
|
|
3046
|
+
console.log(` ${event.padEnd(22)} ${cells}`);
|
|
3047
|
+
}
|
|
3048
|
+
const commonEvents = getCommonEvents(matrix.providers);
|
|
3049
|
+
console.log(pc11.dim(`
|
|
3050
|
+
Common events: ${commonEvents.length > 0 ? commonEvents.join(", ") : "none"}`));
|
|
3051
|
+
console.log();
|
|
3052
|
+
});
|
|
3053
|
+
hooks.command("translate").description("Translate a hook event name between CAAMP canonical and provider-native").argument("<event>", "Hook event name (canonical or native)").option("--to <provider>", "Target provider ID for canonical\u2192native translation").option("--from <provider>", "Source provider ID for native\u2192canonical translation").option("--json", "Output as JSON (default)").option("--human", "Output in human-readable format").action(async (event, opts) => {
|
|
3054
|
+
const operation = "providers.hooks.translate";
|
|
3055
|
+
const mvi = "standard";
|
|
3056
|
+
let format;
|
|
3057
|
+
try {
|
|
3058
|
+
format = resolveOutputFormat2({
|
|
3059
|
+
jsonFlag: opts.json ?? false,
|
|
3060
|
+
humanFlag: (opts.human ?? false) || isHuman(),
|
|
3061
|
+
projectDefault: "json"
|
|
3062
|
+
}).format;
|
|
3063
|
+
} catch (error) {
|
|
3064
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
3065
|
+
emitJsonError2(operation, mvi, "E_FORMAT_CONFLICT", message, "VALIDATION");
|
|
3066
|
+
process.exit(1);
|
|
3067
|
+
}
|
|
3068
|
+
if (opts.to) {
|
|
3069
|
+
const canonical2 = event;
|
|
3070
|
+
if (!CANONICAL_HOOK_EVENTS.includes(canonical2)) {
|
|
3071
|
+
const msg = `Unknown canonical event: ${event}. Valid: ${CANONICAL_HOOK_EVENTS.join(", ")}`;
|
|
3072
|
+
if (format === "json") {
|
|
3073
|
+
emitJsonError2(operation, mvi, "E_UNKNOWN_EVENT", msg, "VALIDATION");
|
|
3074
|
+
} else {
|
|
3075
|
+
console.error(pc11.red(msg));
|
|
3076
|
+
}
|
|
3077
|
+
process.exit(1);
|
|
3078
|
+
}
|
|
3079
|
+
const result = getHookSupport(canonical2, opts.to);
|
|
2957
3080
|
if (format === "json") {
|
|
2958
|
-
const envelope = buildEnvelope4(
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
providers: matching.map((p) => ({
|
|
2964
|
-
id: p.id,
|
|
2965
|
-
toolName: p.toolName,
|
|
2966
|
-
supportedEvents: p.capabilities.hooks.supported
|
|
2967
|
-
})),
|
|
2968
|
-
count: matching.length
|
|
2969
|
-
},
|
|
2970
|
-
null
|
|
2971
|
-
);
|
|
3081
|
+
const envelope = buildEnvelope4(operation, mvi, {
|
|
3082
|
+
direction: "canonical-to-native",
|
|
3083
|
+
providerId: opts.to,
|
|
3084
|
+
...result
|
|
3085
|
+
}, null);
|
|
2972
3086
|
console.log(JSON.stringify(envelope, null, 2));
|
|
2973
|
-
return;
|
|
2974
|
-
}
|
|
2975
|
-
console.log(pc11.bold(`
|
|
2976
|
-
Providers supporting ${pc11.green(event)}:
|
|
2977
|
-
`));
|
|
2978
|
-
if (matching.length === 0) {
|
|
2979
|
-
console.log(pc11.dim(" No providers support this event."));
|
|
2980
3087
|
} else {
|
|
2981
|
-
|
|
2982
|
-
console.log(`
|
|
3088
|
+
if (result.supported) {
|
|
3089
|
+
console.log(`
|
|
3090
|
+
${pc11.green(event)} \u2192 ${pc11.bold(result.native)} (${opts.to})`);
|
|
3091
|
+
if (result.notes) console.log(pc11.dim(` Note: ${result.notes}`));
|
|
3092
|
+
} else {
|
|
3093
|
+
console.log(`
|
|
3094
|
+
${pc11.red(event)} \u2192 ${pc11.dim("not supported")} (${opts.to})`);
|
|
2983
3095
|
}
|
|
3096
|
+
console.log();
|
|
2984
3097
|
}
|
|
2985
|
-
console.log();
|
|
2986
3098
|
return;
|
|
2987
3099
|
}
|
|
2988
|
-
if (opts.
|
|
2989
|
-
const
|
|
3100
|
+
if (opts.from) {
|
|
3101
|
+
const { toCanonical } = await import("./hooks-LV6VU7QJ.js");
|
|
3102
|
+
const canonical2 = toCanonical(event, opts.from);
|
|
2990
3103
|
if (format === "json") {
|
|
2991
|
-
const envelope = buildEnvelope4(
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
null
|
|
2999
|
-
);
|
|
3104
|
+
const envelope = buildEnvelope4(operation, mvi, {
|
|
3105
|
+
direction: "native-to-canonical",
|
|
3106
|
+
native: event,
|
|
3107
|
+
providerId: opts.from,
|
|
3108
|
+
canonical: canonical2,
|
|
3109
|
+
supported: canonical2 !== null
|
|
3110
|
+
}, null);
|
|
3000
3111
|
console.log(JSON.stringify(envelope, null, 2));
|
|
3001
|
-
return;
|
|
3002
|
-
}
|
|
3003
|
-
console.log(pc11.bold("\nHook events common to all providers:\n"));
|
|
3004
|
-
if (common.length === 0) {
|
|
3005
|
-
console.log(pc11.dim(" No events are common to all providers."));
|
|
3006
3112
|
} else {
|
|
3007
|
-
|
|
3008
|
-
console.log(`
|
|
3113
|
+
if (canonical2) {
|
|
3114
|
+
console.log(`
|
|
3115
|
+
${pc11.bold(event)} (${opts.from}) \u2192 ${pc11.green(canonical2)}`);
|
|
3116
|
+
} else {
|
|
3117
|
+
console.log(`
|
|
3118
|
+
${pc11.bold(event)} (${opts.from}) \u2192 ${pc11.dim("no canonical mapping (provider-only event)")}`);
|
|
3009
3119
|
}
|
|
3120
|
+
console.log();
|
|
3010
3121
|
}
|
|
3011
|
-
console.log();
|
|
3012
3122
|
return;
|
|
3013
3123
|
}
|
|
3014
|
-
const
|
|
3015
|
-
|
|
3124
|
+
const canonical = event;
|
|
3125
|
+
if (!CANONICAL_HOOK_EVENTS.includes(canonical)) {
|
|
3126
|
+
const msg = `Unknown canonical event: ${event}. Use --from <provider> for native names, or valid canonical: ${CANONICAL_HOOK_EVENTS.join(", ")}`;
|
|
3127
|
+
if (format === "json") {
|
|
3128
|
+
emitJsonError2(operation, mvi, "E_UNKNOWN_EVENT", msg, "VALIDATION");
|
|
3129
|
+
} else {
|
|
3130
|
+
console.error(pc11.red(msg));
|
|
3131
|
+
}
|
|
3132
|
+
process.exit(1);
|
|
3133
|
+
}
|
|
3134
|
+
const { getMappedProviderIds } = await import("./hooks-LV6VU7QJ.js");
|
|
3135
|
+
const allIds = getMappedProviderIds();
|
|
3136
|
+
const translations = translateToAll(canonical, allIds);
|
|
3016
3137
|
if (format === "json") {
|
|
3017
|
-
const envelope = buildEnvelope4(
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
supportedEvents: p.capabilities.hooks.supported
|
|
3025
|
-
})),
|
|
3026
|
-
withHooksCount: withHooks.length,
|
|
3027
|
-
totalCount: all.length
|
|
3028
|
-
},
|
|
3029
|
-
null
|
|
3030
|
-
);
|
|
3138
|
+
const envelope = buildEnvelope4(operation, mvi, {
|
|
3139
|
+
direction: "canonical-to-all",
|
|
3140
|
+
canonical: event,
|
|
3141
|
+
translations,
|
|
3142
|
+
supportedCount: Object.keys(translations).length,
|
|
3143
|
+
totalProviders: allIds.length
|
|
3144
|
+
}, null);
|
|
3031
3145
|
console.log(JSON.stringify(envelope, null, 2));
|
|
3032
|
-
return;
|
|
3033
|
-
}
|
|
3034
|
-
console.log(pc11.bold(`
|
|
3035
|
-
Provider Hook Support
|
|
3036
|
-
`));
|
|
3037
|
-
if (withHooks.length === 0) {
|
|
3038
|
-
console.log(pc11.dim(" No providers have hook support."));
|
|
3039
3146
|
} else {
|
|
3040
|
-
|
|
3041
|
-
|
|
3147
|
+
console.log(pc11.bold(`
|
|
3148
|
+
${event} across providers:
|
|
3149
|
+
`));
|
|
3150
|
+
for (const id of allIds) {
|
|
3151
|
+
const native = translations[id];
|
|
3152
|
+
const provider = getProvider(id);
|
|
3153
|
+
const name = (provider?.toolName ?? id).padEnd(22);
|
|
3154
|
+
if (native) {
|
|
3155
|
+
console.log(` ${pc11.green("\u2713")} ${name} ${pc11.bold(native)}`);
|
|
3156
|
+
} else {
|
|
3157
|
+
console.log(` ${pc11.dim("\xB7")} ${name} ${pc11.dim("not supported")}`);
|
|
3158
|
+
}
|
|
3042
3159
|
}
|
|
3160
|
+
console.log();
|
|
3043
3161
|
}
|
|
3044
|
-
const withoutHooks = all.length - withHooks.length;
|
|
3045
|
-
if (withoutHooks > 0) {
|
|
3046
|
-
console.log(pc11.dim(`
|
|
3047
|
-
${withoutHooks} providers without hook support`));
|
|
3048
|
-
}
|
|
3049
|
-
console.log();
|
|
3050
3162
|
});
|
|
3051
3163
|
providers.command("capabilities").description("Show provider capability matrix").option("--json", "Output as JSON (default)").option("--human", "Output in human-readable format").option("--filter <path>", "Filter to providers supporting a capability dot-path (e.g. spawn.supportsSubagents)").action(async (opts) => {
|
|
3052
3164
|
const operation = "providers.capabilities";
|
|
@@ -3104,10 +3216,10 @@ Provider Hook Support
|
|
|
3104
3216
|
);
|
|
3105
3217
|
console.log(` ${"\u2500".repeat(22)} ${"\u2500".repeat(20)} ${"\u2500".repeat(8)} ${"\u2500".repeat(20)}`);
|
|
3106
3218
|
for (const row of matrix) {
|
|
3107
|
-
const
|
|
3219
|
+
const hooks2 = row.hooksCount > 0 ? String(row.hooksCount) : "-";
|
|
3108
3220
|
const spawn = row.spawnMechanism ?? "-";
|
|
3109
3221
|
console.log(
|
|
3110
|
-
` ${row.toolName.padEnd(22)} ${row.skillsPrecedence.padEnd(20)} ${
|
|
3222
|
+
` ${row.toolName.padEnd(22)} ${row.skillsPrecedence.padEnd(20)} ${hooks2.padEnd(8)} ${spawn}`
|
|
3111
3223
|
);
|
|
3112
3224
|
}
|
|
3113
3225
|
console.log(pc11.dim(`
|