@cleocode/caamp 1.8.0 → 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-ZVRDBY6L.js → chunk-MFWBR2NY.js} +110 -370
- package/dist/chunk-MFWBR2NY.js.map +1 -0
- package/dist/{chunk-YWO4I7LI.js → chunk-OLJZ23W3.js} +7 -5
- package/dist/chunk-OLJZ23W3.js.map +1 -0
- 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 +217 -11
- package/dist/index.js +71 -19
- package/dist/index.js.map +1 -1
- package/dist/{injector-XGI7NNZA.js → injector-P2OL6RK3.js} +3 -2
- package/dist/injector-P2OL6RK3.js.map +1 -0
- package/package.json +7 -7
- package/providers/hook-mappings.json +302 -0
- package/providers/registry.json +599 -156
- package/dist/chunk-YWO4I7LI.js.map +0 -1
- package/dist/chunk-ZVRDBY6L.js.map +0 -1
- /package/dist/{injector-XGI7NNZA.js.map → hooks-LV6VU7QJ.js.map} +0 -0
|
@@ -1,334 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
resolveProviderSkillsDir,
|
|
3
|
+
resolveProvidersRegistryPath,
|
|
4
|
+
resolveRegistryTemplatePath
|
|
5
|
+
} from "./chunk-TRIXT4T7.js";
|
|
6
6
|
|
|
7
7
|
// src/core/instructions/injector.ts
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { mkdir } from "fs/promises";
|
|
12
|
-
|
|
13
|
-
// src/core/instructions/templates.ts
|
|
14
|
-
function buildInjectionContent(template) {
|
|
15
|
-
const lines = [];
|
|
16
|
-
for (const ref of template.references) {
|
|
17
|
-
lines.push(ref);
|
|
18
|
-
}
|
|
19
|
-
if (template.content && template.content.length > 0) {
|
|
20
|
-
if (lines.length > 0) {
|
|
21
|
-
lines.push("");
|
|
22
|
-
}
|
|
23
|
-
lines.push(...template.content);
|
|
24
|
-
}
|
|
25
|
-
return lines.join("\n");
|
|
26
|
-
}
|
|
27
|
-
function parseInjectionContent(content) {
|
|
28
|
-
const references = [];
|
|
29
|
-
const contentLines = [];
|
|
30
|
-
for (const line of content.split("\n")) {
|
|
31
|
-
const trimmed = line.trim();
|
|
32
|
-
if (!trimmed) continue;
|
|
33
|
-
if (trimmed.startsWith("@")) {
|
|
34
|
-
references.push(trimmed);
|
|
35
|
-
} else {
|
|
36
|
-
contentLines.push(line);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
references,
|
|
41
|
-
content: contentLines.length > 0 ? contentLines : void 0
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function generateInjectionContent(options) {
|
|
45
|
-
const lines = [];
|
|
46
|
-
lines.push("## CAAMP Managed Configuration");
|
|
47
|
-
lines.push("");
|
|
48
|
-
lines.push("This section is managed by [CAAMP](https://github.com/caamp/caamp).");
|
|
49
|
-
lines.push("Do not edit between the CAAMP markers manually.");
|
|
50
|
-
if (options?.mcpServerName) {
|
|
51
|
-
lines.push("");
|
|
52
|
-
lines.push(`### MCP Server: ${options.mcpServerName}`);
|
|
53
|
-
lines.push(`Configured via \`caamp mcp install\`.`);
|
|
54
|
-
}
|
|
55
|
-
if (options?.customContent) {
|
|
56
|
-
lines.push("");
|
|
57
|
-
lines.push(options.customContent);
|
|
58
|
-
}
|
|
59
|
-
return lines.join("\n");
|
|
60
|
-
}
|
|
61
|
-
function generateSkillsSection(skillNames) {
|
|
62
|
-
if (skillNames.length === 0) return "";
|
|
63
|
-
const lines = [];
|
|
64
|
-
lines.push("### Installed Skills");
|
|
65
|
-
lines.push("");
|
|
66
|
-
for (const name of skillNames) {
|
|
67
|
-
lines.push(`- \`${name}\` - Available via SKILL.md`);
|
|
68
|
-
}
|
|
69
|
-
return lines.join("\n");
|
|
70
|
-
}
|
|
71
|
-
function groupByInstructFile(providers) {
|
|
72
|
-
const groups = /* @__PURE__ */ new Map();
|
|
73
|
-
for (const provider of providers) {
|
|
74
|
-
const existing = groups.get(provider.instructFile) ?? [];
|
|
75
|
-
existing.push(provider);
|
|
76
|
-
groups.set(provider.instructFile, existing);
|
|
77
|
-
}
|
|
78
|
-
return groups;
|
|
79
|
-
}
|
|
8
|
+
import { existsSync } from "fs";
|
|
9
|
+
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
10
|
+
import { dirname as dirname2, join as join2 } from "path";
|
|
80
11
|
|
|
81
12
|
// src/core/registry/providers.ts
|
|
82
13
|
import { readFileSync } from "fs";
|
|
83
|
-
import { dirname
|
|
14
|
+
import { dirname, join } from "path";
|
|
84
15
|
import { fileURLToPath } from "url";
|
|
85
|
-
|
|
86
|
-
// src/core/paths/standard.ts
|
|
87
|
-
import { existsSync } from "fs";
|
|
88
|
-
import { homedir as homedir2 } from "os";
|
|
89
|
-
import { dirname, join as join2 } from "path";
|
|
90
|
-
|
|
91
|
-
// src/core/platform-paths.ts
|
|
92
|
-
import envPaths from "env-paths";
|
|
93
|
-
import { arch, homedir, hostname, platform, release } from "os";
|
|
94
|
-
import { isAbsolute, join, resolve } from "path";
|
|
95
|
-
var APP_NAME = "agents";
|
|
96
|
-
function resolveAgentsHomeOverride(value) {
|
|
97
|
-
if (value === void 0) return void 0;
|
|
98
|
-
const trimmed = value.trim();
|
|
99
|
-
if (trimmed.length === 0) return void 0;
|
|
100
|
-
if (trimmed === "~") return homedir();
|
|
101
|
-
if (trimmed.startsWith("~/")) return join(homedir(), trimmed.slice(2));
|
|
102
|
-
if (isAbsolute(trimmed)) return resolve(trimmed);
|
|
103
|
-
return resolve(homedir(), trimmed);
|
|
104
|
-
}
|
|
105
|
-
var _paths = null;
|
|
106
|
-
var _sysInfo = null;
|
|
107
|
-
var _lastAgentsHome = void 0;
|
|
108
|
-
function getPlatformPaths() {
|
|
109
|
-
const currentAgentsHome = process.env["AGENTS_HOME"];
|
|
110
|
-
if (_paths && currentAgentsHome !== _lastAgentsHome) {
|
|
111
|
-
_paths = null;
|
|
112
|
-
_sysInfo = null;
|
|
113
|
-
}
|
|
114
|
-
if (_paths) return _paths;
|
|
115
|
-
const ep = envPaths(APP_NAME, { suffix: "" });
|
|
116
|
-
_lastAgentsHome = currentAgentsHome;
|
|
117
|
-
_paths = {
|
|
118
|
-
data: resolveAgentsHomeOverride(currentAgentsHome) ?? ep.data,
|
|
119
|
-
config: ep.config,
|
|
120
|
-
cache: ep.cache,
|
|
121
|
-
log: ep.log,
|
|
122
|
-
temp: ep.temp
|
|
123
|
-
};
|
|
124
|
-
return _paths;
|
|
125
|
-
}
|
|
126
|
-
function getSystemInfo() {
|
|
127
|
-
if (_sysInfo) return _sysInfo;
|
|
128
|
-
const paths = getPlatformPaths();
|
|
129
|
-
_sysInfo = {
|
|
130
|
-
platform: platform(),
|
|
131
|
-
arch: arch(),
|
|
132
|
-
release: release(),
|
|
133
|
-
hostname: hostname(),
|
|
134
|
-
nodeVersion: process.version,
|
|
135
|
-
paths
|
|
136
|
-
};
|
|
137
|
-
return _sysInfo;
|
|
138
|
-
}
|
|
139
|
-
function _resetPlatformPathsCache() {
|
|
140
|
-
_paths = null;
|
|
141
|
-
_sysInfo = null;
|
|
142
|
-
_lastAgentsHome = void 0;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// src/core/paths/standard.ts
|
|
146
|
-
function getPlatformLocations() {
|
|
147
|
-
const home = homedir2();
|
|
148
|
-
const platform2 = process.platform;
|
|
149
|
-
if (platform2 === "win32") {
|
|
150
|
-
const appData = process.env["APPDATA"] ?? join2(home, "AppData", "Roaming");
|
|
151
|
-
return {
|
|
152
|
-
home,
|
|
153
|
-
config: appData,
|
|
154
|
-
vscodeConfig: join2(appData, "Code", "User"),
|
|
155
|
-
zedConfig: join2(appData, "Zed"),
|
|
156
|
-
claudeDesktopConfig: join2(appData, "Claude"),
|
|
157
|
-
applications: []
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
if (platform2 === "darwin") {
|
|
161
|
-
const config2 = process.env["XDG_CONFIG_HOME"] ?? join2(home, ".config");
|
|
162
|
-
return {
|
|
163
|
-
home,
|
|
164
|
-
config: config2,
|
|
165
|
-
vscodeConfig: join2(home, "Library", "Application Support", "Code", "User"),
|
|
166
|
-
zedConfig: join2(home, "Library", "Application Support", "Zed"),
|
|
167
|
-
claudeDesktopConfig: join2(home, "Library", "Application Support", "Claude"),
|
|
168
|
-
applications: ["/Applications", join2(home, "Applications")]
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
const config = process.env["XDG_CONFIG_HOME"] ?? join2(home, ".config");
|
|
172
|
-
return {
|
|
173
|
-
home,
|
|
174
|
-
config,
|
|
175
|
-
vscodeConfig: join2(config, "Code", "User"),
|
|
176
|
-
zedConfig: join2(config, "zed"),
|
|
177
|
-
claudeDesktopConfig: join2(config, "Claude"),
|
|
178
|
-
applications: []
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
function getAgentsHome() {
|
|
182
|
-
return getPlatformPaths().data;
|
|
183
|
-
}
|
|
184
|
-
function getProjectAgentsDir(projectRoot = process.cwd()) {
|
|
185
|
-
return join2(projectRoot, ".agents");
|
|
186
|
-
}
|
|
187
|
-
function resolveProjectPath(relativePath, projectDir = process.cwd()) {
|
|
188
|
-
return join2(projectDir, relativePath);
|
|
189
|
-
}
|
|
190
|
-
function getCanonicalSkillsDir() {
|
|
191
|
-
return join2(getAgentsHome(), "skills");
|
|
192
|
-
}
|
|
193
|
-
function getLockFilePath() {
|
|
194
|
-
return join2(getAgentsHome(), ".caamp-lock.json");
|
|
195
|
-
}
|
|
196
|
-
function getAgentsMcpDir(scope = "global", projectDir) {
|
|
197
|
-
if (scope === "global") return join2(getAgentsHome(), "mcp");
|
|
198
|
-
return join2(projectDir ?? process.cwd(), ".agents", "mcp");
|
|
199
|
-
}
|
|
200
|
-
function getAgentsMcpServersPath(scope = "global", projectDir) {
|
|
201
|
-
return join2(getAgentsMcpDir(scope, projectDir), "servers.json");
|
|
202
|
-
}
|
|
203
|
-
function getAgentsInstructFile(scope = "global", projectDir) {
|
|
204
|
-
if (scope === "global") return join2(getAgentsHome(), "AGENTS.md");
|
|
205
|
-
return join2(projectDir ?? process.cwd(), ".agents", "AGENTS.md");
|
|
206
|
-
}
|
|
207
|
-
function getAgentsConfigPath(scope = "global", projectDir) {
|
|
208
|
-
if (scope === "global") return join2(getAgentsHome(), "config.toml");
|
|
209
|
-
return join2(projectDir ?? process.cwd(), ".agents", "config.toml");
|
|
210
|
-
}
|
|
211
|
-
function getAgentsWikiDir(scope = "global", projectDir) {
|
|
212
|
-
if (scope === "global") return join2(getAgentsHome(), "wiki");
|
|
213
|
-
return join2(projectDir ?? process.cwd(), ".agents", "wiki");
|
|
214
|
-
}
|
|
215
|
-
function getAgentsSpecDir(scope = "global", projectDir) {
|
|
216
|
-
if (scope === "global") return join2(getAgentsHome(), "spec");
|
|
217
|
-
return join2(projectDir ?? process.cwd(), ".agents", "spec");
|
|
218
|
-
}
|
|
219
|
-
function getAgentsLinksDir(scope = "global", projectDir) {
|
|
220
|
-
if (scope === "global") return join2(getAgentsHome(), "links");
|
|
221
|
-
return join2(projectDir ?? process.cwd(), ".agents", "links");
|
|
222
|
-
}
|
|
223
|
-
function resolveRegistryTemplatePath(template) {
|
|
224
|
-
const locations = getPlatformLocations();
|
|
225
|
-
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());
|
|
226
|
-
}
|
|
227
|
-
function resolveProviderConfigPath(provider, scope, projectDir = process.cwd()) {
|
|
228
|
-
if (scope === "global") {
|
|
229
|
-
return provider.configPathGlobal;
|
|
230
|
-
}
|
|
231
|
-
if (!provider.configPathProject) {
|
|
232
|
-
return null;
|
|
233
|
-
}
|
|
234
|
-
return resolveProjectPath(provider.configPathProject, projectDir);
|
|
235
|
-
}
|
|
236
|
-
function resolvePreferredConfigScope(provider, useGlobalFlag) {
|
|
237
|
-
if (useGlobalFlag) {
|
|
238
|
-
return "global";
|
|
239
|
-
}
|
|
240
|
-
return provider.configPathProject ? "project" : "global";
|
|
241
|
-
}
|
|
242
|
-
function resolveProviderSkillsDir(provider, scope, projectDir = process.cwd()) {
|
|
243
|
-
if (scope === "global") {
|
|
244
|
-
return provider.pathSkills;
|
|
245
|
-
}
|
|
246
|
-
return resolveProjectPath(provider.pathProjectSkills, projectDir);
|
|
247
|
-
}
|
|
248
|
-
function resolveProviderSkillsDirs(provider, scope, projectDir = process.cwd()) {
|
|
249
|
-
const vendorPath = resolveProviderSkillsDir(provider, scope, projectDir);
|
|
250
|
-
const precedence = provider.capabilities?.skills?.precedence ?? "vendor-only";
|
|
251
|
-
const resolveAgentsPath = () => {
|
|
252
|
-
if (scope === "global") {
|
|
253
|
-
return provider.capabilities?.skills?.agentsGlobalPath ?? null;
|
|
254
|
-
}
|
|
255
|
-
const projectRelative = provider.capabilities?.skills?.agentsProjectPath ?? null;
|
|
256
|
-
return projectRelative ? join2(projectDir, projectRelative) : null;
|
|
257
|
-
};
|
|
258
|
-
switch (precedence) {
|
|
259
|
-
case "vendor-only":
|
|
260
|
-
return [vendorPath];
|
|
261
|
-
case "agents-canonical": {
|
|
262
|
-
const agentsPath = resolveAgentsPath();
|
|
263
|
-
return agentsPath ? [agentsPath] : [vendorPath];
|
|
264
|
-
}
|
|
265
|
-
case "agents-first": {
|
|
266
|
-
const agentsPath = resolveAgentsPath();
|
|
267
|
-
return agentsPath ? [agentsPath, vendorPath] : [vendorPath];
|
|
268
|
-
}
|
|
269
|
-
case "agents-supported": {
|
|
270
|
-
const agentsPath = resolveAgentsPath();
|
|
271
|
-
return agentsPath ? [vendorPath, agentsPath] : [vendorPath];
|
|
272
|
-
}
|
|
273
|
-
case "vendor-global-agents-project": {
|
|
274
|
-
if (scope === "global") {
|
|
275
|
-
return [vendorPath];
|
|
276
|
-
}
|
|
277
|
-
const agentsPath = resolveAgentsPath();
|
|
278
|
-
return agentsPath ? [agentsPath, vendorPath] : [vendorPath];
|
|
279
|
-
}
|
|
280
|
-
default:
|
|
281
|
-
return [vendorPath];
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
function resolveProviderProjectPath(provider, projectDir = process.cwd()) {
|
|
285
|
-
return resolveProjectPath(provider.pathProject, projectDir);
|
|
286
|
-
}
|
|
287
|
-
function resolveProvidersRegistryPath(startDir) {
|
|
288
|
-
const candidates = [
|
|
289
|
-
join2(startDir, "..", "..", "..", "providers", "registry.json"),
|
|
290
|
-
join2(startDir, "..", "providers", "registry.json")
|
|
291
|
-
];
|
|
292
|
-
for (const candidate of candidates) {
|
|
293
|
-
if (existsSync(candidate)) {
|
|
294
|
-
return candidate;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
let current = startDir;
|
|
298
|
-
for (let i = 0; i < 8; i += 1) {
|
|
299
|
-
const candidate = join2(current, "providers", "registry.json");
|
|
300
|
-
if (existsSync(candidate)) {
|
|
301
|
-
return candidate;
|
|
302
|
-
}
|
|
303
|
-
current = dirname(current);
|
|
304
|
-
}
|
|
305
|
-
throw new Error(`Cannot find providers/registry.json (searched from ${startDir})`);
|
|
306
|
-
}
|
|
307
|
-
function normalizeSkillSubPath(path) {
|
|
308
|
-
if (!path) return void 0;
|
|
309
|
-
const normalized = path.replace(/\\/g, "/").replace(/^\/+/, "").replace(/\/SKILL\.md$/i, "").trim();
|
|
310
|
-
return normalized.length > 0 ? normalized : void 0;
|
|
311
|
-
}
|
|
312
|
-
function buildSkillSubPathCandidates(marketplacePath, parsedPath) {
|
|
313
|
-
const candidates = [];
|
|
314
|
-
const base = normalizeSkillSubPath(marketplacePath);
|
|
315
|
-
const parsed = normalizeSkillSubPath(parsedPath);
|
|
316
|
-
if (base) candidates.push(base);
|
|
317
|
-
if (parsed) candidates.push(parsed);
|
|
318
|
-
const knownPrefixes = [".agents", ".claude"];
|
|
319
|
-
for (const value of [base, parsed]) {
|
|
320
|
-
if (!value || !value.startsWith("skills/")) continue;
|
|
321
|
-
for (const prefix of knownPrefixes) {
|
|
322
|
-
candidates.push(`${prefix}/${value}`);
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
if (candidates.length === 0) {
|
|
326
|
-
candidates.push(void 0);
|
|
327
|
-
}
|
|
328
|
-
return Array.from(new Set(candidates));
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// src/core/registry/providers.ts
|
|
332
16
|
var DEFAULT_SKILLS_CAPABILITY = {
|
|
333
17
|
agentsGlobalPath: null,
|
|
334
18
|
agentsProjectPath: null,
|
|
@@ -367,7 +51,7 @@ function resolveCapabilities(raw) {
|
|
|
367
51
|
return { skills, hooks, spawn };
|
|
368
52
|
}
|
|
369
53
|
function findRegistryPath() {
|
|
370
|
-
const thisDir =
|
|
54
|
+
const thisDir = dirname(fileURLToPath(import.meta.url));
|
|
371
55
|
return resolveProvidersRegistryPath(thisDir);
|
|
372
56
|
}
|
|
373
57
|
var _registry = null;
|
|
@@ -498,7 +182,7 @@ function getEffectiveSkillsPaths(provider, scope, projectDir) {
|
|
|
498
182
|
const resolveAgentsPath = () => {
|
|
499
183
|
if (scope === "global" && agentsGlobalPath) return agentsGlobalPath;
|
|
500
184
|
if (scope === "project" && agentsProjectPath && projectDir) {
|
|
501
|
-
return
|
|
185
|
+
return join(projectDir, agentsProjectPath);
|
|
502
186
|
}
|
|
503
187
|
return null;
|
|
504
188
|
};
|
|
@@ -555,14 +239,83 @@ function providerSupportsById(idOrAlias, capabilityPath) {
|
|
|
555
239
|
return providerSupports(provider, capabilityPath);
|
|
556
240
|
}
|
|
557
241
|
|
|
242
|
+
// src/core/instructions/templates.ts
|
|
243
|
+
function buildInjectionContent(template) {
|
|
244
|
+
const lines = [];
|
|
245
|
+
for (const ref of template.references) {
|
|
246
|
+
lines.push(ref);
|
|
247
|
+
}
|
|
248
|
+
if (template.content && template.content.length > 0) {
|
|
249
|
+
if (lines.length > 0) {
|
|
250
|
+
lines.push("");
|
|
251
|
+
}
|
|
252
|
+
lines.push(...template.content);
|
|
253
|
+
}
|
|
254
|
+
return lines.join("\n");
|
|
255
|
+
}
|
|
256
|
+
function parseInjectionContent(content) {
|
|
257
|
+
const references = [];
|
|
258
|
+
const contentLines = [];
|
|
259
|
+
for (const line of content.split("\n")) {
|
|
260
|
+
const trimmed = line.trim();
|
|
261
|
+
if (!trimmed) continue;
|
|
262
|
+
if (trimmed.startsWith("@")) {
|
|
263
|
+
references.push(trimmed);
|
|
264
|
+
} else {
|
|
265
|
+
contentLines.push(line);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return {
|
|
269
|
+
references,
|
|
270
|
+
content: contentLines.length > 0 ? contentLines : void 0
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
function generateInjectionContent(options) {
|
|
274
|
+
const lines = [];
|
|
275
|
+
lines.push("## CAAMP Managed Configuration");
|
|
276
|
+
lines.push("");
|
|
277
|
+
lines.push("This section is managed by [CAAMP](https://github.com/caamp/caamp).");
|
|
278
|
+
lines.push("Do not edit between the CAAMP markers manually.");
|
|
279
|
+
if (options?.mcpServerName) {
|
|
280
|
+
lines.push("");
|
|
281
|
+
lines.push(`### MCP Server: ${options.mcpServerName}`);
|
|
282
|
+
lines.push(`Configured via \`caamp mcp install\`.`);
|
|
283
|
+
}
|
|
284
|
+
if (options?.customContent) {
|
|
285
|
+
lines.push("");
|
|
286
|
+
lines.push(options.customContent);
|
|
287
|
+
}
|
|
288
|
+
return lines.join("\n");
|
|
289
|
+
}
|
|
290
|
+
function generateSkillsSection(skillNames) {
|
|
291
|
+
if (skillNames.length === 0) return "";
|
|
292
|
+
const lines = [];
|
|
293
|
+
lines.push("### Installed Skills");
|
|
294
|
+
lines.push("");
|
|
295
|
+
for (const name of skillNames) {
|
|
296
|
+
lines.push(`- \`${name}\` - Available via SKILL.md`);
|
|
297
|
+
}
|
|
298
|
+
return lines.join("\n");
|
|
299
|
+
}
|
|
300
|
+
function groupByInstructFile(providers) {
|
|
301
|
+
const groups = /* @__PURE__ */ new Map();
|
|
302
|
+
for (const provider of providers) {
|
|
303
|
+
const existing = groups.get(provider.instructFile) ?? [];
|
|
304
|
+
existing.push(provider);
|
|
305
|
+
groups.set(provider.instructFile, existing);
|
|
306
|
+
}
|
|
307
|
+
return groups;
|
|
308
|
+
}
|
|
309
|
+
|
|
558
310
|
// src/core/instructions/injector.ts
|
|
559
311
|
var MARKER_START = "<!-- CAAMP:START -->";
|
|
560
312
|
var MARKER_END = "<!-- CAAMP:END -->";
|
|
561
|
-
var MARKER_PATTERN = /<!-- CAAMP:START -->[\s\S]*?<!-- CAAMP:END
|
|
313
|
+
var MARKER_PATTERN = /<!-- CAAMP:START -->[\s\S]*?<!-- CAAMP:END -->/g;
|
|
314
|
+
var MARKER_PATTERN_SINGLE = /<!-- CAAMP:START -->[\s\S]*?<!-- CAAMP:END -->/;
|
|
562
315
|
async function checkInjection(filePath, expectedContent) {
|
|
563
|
-
if (!
|
|
316
|
+
if (!existsSync(filePath)) return "missing";
|
|
564
317
|
const content = await readFile(filePath, "utf-8");
|
|
565
|
-
if (!
|
|
318
|
+
if (!MARKER_PATTERN_SINGLE.test(content)) return "none";
|
|
566
319
|
if (expectedContent) {
|
|
567
320
|
const blockContent = extractBlock(content);
|
|
568
321
|
if (blockContent && blockContent.trim() === expectedContent.trim()) {
|
|
@@ -573,7 +326,7 @@ async function checkInjection(filePath, expectedContent) {
|
|
|
573
326
|
return "current";
|
|
574
327
|
}
|
|
575
328
|
function extractBlock(content) {
|
|
576
|
-
const match = content.match(
|
|
329
|
+
const match = content.match(MARKER_PATTERN_SINGLE);
|
|
577
330
|
if (!match) return null;
|
|
578
331
|
return match[0].replace(MARKER_START, "").replace(MARKER_END, "").trim();
|
|
579
332
|
}
|
|
@@ -584,19 +337,29 @@ ${MARKER_END}`;
|
|
|
584
337
|
}
|
|
585
338
|
async function inject(filePath, content) {
|
|
586
339
|
const block = buildBlock(content);
|
|
587
|
-
await mkdir(
|
|
588
|
-
if (!
|
|
340
|
+
await mkdir(dirname2(filePath), { recursive: true });
|
|
341
|
+
if (!existsSync(filePath)) {
|
|
589
342
|
await writeFile(filePath, `${block}
|
|
590
343
|
`, "utf-8");
|
|
591
344
|
return "created";
|
|
592
345
|
}
|
|
593
346
|
const existing = await readFile(filePath, "utf-8");
|
|
594
|
-
|
|
347
|
+
const matches = existing.match(MARKER_PATTERN);
|
|
348
|
+
if (matches && matches.length > 0) {
|
|
349
|
+
if (matches.length > 1) {
|
|
350
|
+
const updated3 = existing.replace(MARKER_PATTERN, "").replace(/^\n{2,}/, "\n").trim();
|
|
351
|
+
const finalContent = updated3 ? `${block}
|
|
352
|
+
|
|
353
|
+
${updated3}` : `${block}
|
|
354
|
+
`;
|
|
355
|
+
await writeFile(filePath, finalContent, "utf-8");
|
|
356
|
+
return "consolidated";
|
|
357
|
+
}
|
|
595
358
|
const existingBlock = extractBlock(existing);
|
|
596
359
|
if (existingBlock !== null && existingBlock.trim() === content.trim()) {
|
|
597
360
|
return "intact";
|
|
598
361
|
}
|
|
599
|
-
const updated2 = existing.replace(
|
|
362
|
+
const updated2 = existing.replace(MARKER_PATTERN_SINGLE, block);
|
|
600
363
|
await writeFile(filePath, updated2, "utf-8");
|
|
601
364
|
return "updated";
|
|
602
365
|
}
|
|
@@ -607,7 +370,7 @@ ${existing}`;
|
|
|
607
370
|
return "added";
|
|
608
371
|
}
|
|
609
372
|
async function removeInjection(filePath) {
|
|
610
|
-
if (!
|
|
373
|
+
if (!existsSync(filePath)) return false;
|
|
611
374
|
const content = await readFile(filePath, "utf-8");
|
|
612
375
|
if (!MARKER_PATTERN.test(content)) return false;
|
|
613
376
|
const cleaned = content.replace(MARKER_PATTERN, "").replace(/^\n{2,}/, "\n").trim();
|
|
@@ -624,7 +387,7 @@ async function checkAllInjections(providers, projectDir, scope, expectedContent)
|
|
|
624
387
|
const results = [];
|
|
625
388
|
const checked = /* @__PURE__ */ new Set();
|
|
626
389
|
for (const provider of providers) {
|
|
627
|
-
const filePath = scope === "global" ?
|
|
390
|
+
const filePath = scope === "global" ? join2(provider.pathGlobal, provider.instructFile) : join2(projectDir, provider.instructFile);
|
|
628
391
|
if (checked.has(filePath)) continue;
|
|
629
392
|
checked.add(filePath);
|
|
630
393
|
const status = await checkInjection(filePath, expectedContent);
|
|
@@ -632,7 +395,7 @@ async function checkAllInjections(providers, projectDir, scope, expectedContent)
|
|
|
632
395
|
file: filePath,
|
|
633
396
|
provider: provider.id,
|
|
634
397
|
status,
|
|
635
|
-
fileExists:
|
|
398
|
+
fileExists: existsSync(filePath)
|
|
636
399
|
});
|
|
637
400
|
}
|
|
638
401
|
return results;
|
|
@@ -641,7 +404,7 @@ async function injectAll(providers, projectDir, scope, content) {
|
|
|
641
404
|
const results = /* @__PURE__ */ new Map();
|
|
642
405
|
const injected = /* @__PURE__ */ new Set();
|
|
643
406
|
for (const provider of providers) {
|
|
644
|
-
const filePath = scope === "global" ?
|
|
407
|
+
const filePath = scope === "global" ? join2(provider.pathGlobal, provider.instructFile) : join2(projectDir, provider.instructFile);
|
|
645
408
|
if (injected.has(filePath)) continue;
|
|
646
409
|
injected.add(filePath);
|
|
647
410
|
const action = await inject(filePath, content);
|
|
@@ -655,7 +418,7 @@ async function ensureProviderInstructionFile(providerId, projectDir, options) {
|
|
|
655
418
|
throw new Error(`Unknown provider: "${providerId}". Check CAAMP provider registry.`);
|
|
656
419
|
}
|
|
657
420
|
const scope = options.scope ?? "project";
|
|
658
|
-
const filePath = scope === "global" ?
|
|
421
|
+
const filePath = scope === "global" ? join2(provider.pathGlobal, provider.instructFile) : join2(projectDir, provider.instructFile);
|
|
659
422
|
const template = {
|
|
660
423
|
references: options.references,
|
|
661
424
|
content: options.content
|
|
@@ -678,7 +441,7 @@ async function ensureAllProviderInstructionFiles(providerIds, projectDir, option
|
|
|
678
441
|
throw new Error(`Unknown provider: "${providerId}". Check CAAMP provider registry.`);
|
|
679
442
|
}
|
|
680
443
|
const scope = options.scope ?? "project";
|
|
681
|
-
const filePath = scope === "global" ?
|
|
444
|
+
const filePath = scope === "global" ? join2(provider.pathGlobal, provider.instructFile) : join2(projectDir, provider.instructFile);
|
|
682
445
|
if (processed.has(filePath)) continue;
|
|
683
446
|
processed.add(filePath);
|
|
684
447
|
const template = {
|
|
@@ -698,34 +461,6 @@ async function ensureAllProviderInstructionFiles(providerIds, projectDir, option
|
|
|
698
461
|
}
|
|
699
462
|
|
|
700
463
|
export {
|
|
701
|
-
__export,
|
|
702
|
-
buildInjectionContent,
|
|
703
|
-
parseInjectionContent,
|
|
704
|
-
generateInjectionContent,
|
|
705
|
-
generateSkillsSection,
|
|
706
|
-
groupByInstructFile,
|
|
707
|
-
getPlatformPaths,
|
|
708
|
-
getSystemInfo,
|
|
709
|
-
_resetPlatformPathsCache,
|
|
710
|
-
getPlatformLocations,
|
|
711
|
-
getAgentsHome,
|
|
712
|
-
getProjectAgentsDir,
|
|
713
|
-
getCanonicalSkillsDir,
|
|
714
|
-
getLockFilePath,
|
|
715
|
-
getAgentsMcpDir,
|
|
716
|
-
getAgentsMcpServersPath,
|
|
717
|
-
getAgentsInstructFile,
|
|
718
|
-
getAgentsConfigPath,
|
|
719
|
-
getAgentsWikiDir,
|
|
720
|
-
getAgentsSpecDir,
|
|
721
|
-
getAgentsLinksDir,
|
|
722
|
-
resolveRegistryTemplatePath,
|
|
723
|
-
resolveProviderConfigPath,
|
|
724
|
-
resolvePreferredConfigScope,
|
|
725
|
-
resolveProviderSkillsDir,
|
|
726
|
-
resolveProviderSkillsDirs,
|
|
727
|
-
resolveProviderProjectPath,
|
|
728
|
-
buildSkillSubPathCandidates,
|
|
729
464
|
getAllProviders,
|
|
730
465
|
getProvider,
|
|
731
466
|
resolveAlias,
|
|
@@ -745,6 +480,11 @@ export {
|
|
|
745
480
|
buildSkillsMap,
|
|
746
481
|
getProviderCapabilities,
|
|
747
482
|
providerSupportsById,
|
|
483
|
+
buildInjectionContent,
|
|
484
|
+
parseInjectionContent,
|
|
485
|
+
generateInjectionContent,
|
|
486
|
+
generateSkillsSection,
|
|
487
|
+
groupByInstructFile,
|
|
748
488
|
checkInjection,
|
|
749
489
|
inject,
|
|
750
490
|
removeInjection,
|
|
@@ -753,4 +493,4 @@ export {
|
|
|
753
493
|
ensureProviderInstructionFile,
|
|
754
494
|
ensureAllProviderInstructionFiles
|
|
755
495
|
};
|
|
756
|
-
//# sourceMappingURL=chunk-
|
|
496
|
+
//# sourceMappingURL=chunk-MFWBR2NY.js.map
|