agentpacks 1.7.6 → 1.7.9
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 +69 -742
- package/dist/api.d.ts +15 -15
- package/dist/api.js +2706 -2706
- package/dist/cli/export-cmd.js +364 -364
- package/dist/cli/generate.js +1409 -1409
- package/dist/cli/import-cmd.js +249 -249
- package/dist/cli/info.js +31 -31
- package/dist/cli/init.js +6 -6
- package/dist/cli/install.js +141 -141
- package/dist/cli/login.js +31 -31
- package/dist/cli/models-explain.js +514 -514
- package/dist/cli/pack/create.js +6 -6
- package/dist/cli/pack/enable.js +2 -2
- package/dist/cli/pack/list.js +362 -362
- package/dist/cli/pack/validate.js +119 -119
- package/dist/cli/publish.js +42 -42
- package/dist/cli/search.js +31 -31
- package/dist/core/config.js +3 -3
- package/dist/core/feature-merger.d.ts +5 -5
- package/dist/core/feature-merger.js +4 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +633 -633
- package/dist/core/lockfile.js +1 -1
- package/dist/core/metarepo.js +3 -3
- package/dist/core/pack-loader.d.ts +6 -6
- package/dist/core/pack-loader.js +362 -362
- package/dist/core/profile-resolver.d.ts +1 -1
- package/dist/exporters/cursor-plugin.d.ts +12 -0
- package/dist/exporters/cursor-plugin.js +46 -46
- package/dist/exporters/index.d.ts +1 -1
- package/dist/exporters/index.js +46 -46
- package/dist/features/agents.js +4 -4
- package/dist/features/commands.js +4 -4
- package/dist/features/hooks.js +4 -4
- package/dist/features/index.d.ts +8 -8
- package/dist/features/index.js +350 -350
- package/dist/features/mcp.js +4 -4
- package/dist/features/models.js +4 -4
- package/dist/features/plugins.js +5 -5
- package/dist/features/rules.js +4 -4
- package/dist/features/skills.js +5 -5
- package/dist/importers/claude-code.js +6 -6
- package/dist/importers/cursor.js +7 -7
- package/dist/importers/opencode.js +7 -7
- package/dist/importers/rulesync.js +7 -7
- package/dist/index.js +2674 -2674
- package/dist/node/api.js +2706 -2706
- package/dist/node/cli/export-cmd.js +364 -364
- package/dist/node/cli/generate.js +1409 -1409
- package/dist/node/cli/import-cmd.js +249 -249
- package/dist/node/cli/info.js +31 -31
- package/dist/node/cli/init.js +6 -6
- package/dist/node/cli/install.js +141 -141
- package/dist/node/cli/login.js +31 -31
- package/dist/node/cli/models-explain.js +514 -514
- package/dist/node/cli/pack/create.js +6 -6
- package/dist/node/cli/pack/enable.js +2 -2
- package/dist/node/cli/pack/list.js +362 -362
- package/dist/node/cli/pack/validate.js +119 -119
- package/dist/node/cli/publish.js +42 -42
- package/dist/node/cli/search.js +31 -31
- package/dist/node/core/config.js +3 -3
- package/dist/node/core/feature-merger.js +4 -4
- package/dist/node/core/index.js +633 -633
- package/dist/node/core/lockfile.js +1 -1
- package/dist/node/core/metarepo.js +3 -3
- package/dist/node/core/pack-loader.js +362 -362
- package/dist/node/exporters/cursor-plugin.js +46 -46
- package/dist/node/exporters/index.js +46 -46
- package/dist/node/features/agents.js +4 -4
- package/dist/node/features/commands.js +4 -4
- package/dist/node/features/hooks.js +4 -4
- package/dist/node/features/index.js +350 -350
- package/dist/node/features/mcp.js +4 -4
- package/dist/node/features/models.js +4 -4
- package/dist/node/features/plugins.js +5 -5
- package/dist/node/features/rules.js +4 -4
- package/dist/node/features/skills.js +5 -5
- package/dist/node/importers/claude-code.js +6 -6
- package/dist/node/importers/cursor.js +7 -7
- package/dist/node/importers/opencode.js +7 -7
- package/dist/node/importers/rulesync.js +7 -7
- package/dist/node/index.js +2674 -2674
- package/dist/node/sources/git.js +2 -2
- package/dist/node/sources/index.js +138 -138
- package/dist/node/sources/local.js +1 -1
- package/dist/node/sources/npm.js +3 -3
- package/dist/node/sources/registry.js +35 -35
- package/dist/node/targets/additional-targets.js +43 -43
- package/dist/node/targets/agents-md.js +4 -4
- package/dist/node/targets/claude-code.js +86 -86
- package/dist/node/targets/codex-cli.js +6 -6
- package/dist/node/targets/copilot.js +46 -46
- package/dist/node/targets/cursor.js +68 -68
- package/dist/node/targets/gemini-cli.js +25 -25
- package/dist/node/targets/generic-md-target.js +43 -43
- package/dist/node/targets/index.js +911 -911
- package/dist/node/targets/mistral-vibe.js +46 -46
- package/dist/node/targets/opencode.js +68 -68
- package/dist/node/targets/registry.js +911 -911
- package/dist/node/utils/credentials.js +2 -2
- package/dist/node/utils/filesystem.js +4 -4
- package/dist/node/utils/global.js +1 -1
- package/dist/node/utils/tarball.js +2 -2
- package/dist/sources/git.js +2 -2
- package/dist/sources/index.d.ts +6 -6
- package/dist/sources/index.js +138 -138
- package/dist/sources/local.js +1 -1
- package/dist/sources/npm.d.ts +3 -0
- package/dist/sources/npm.js +3 -3
- package/dist/sources/registry.js +35 -35
- package/dist/targets/additional-targets.js +43 -43
- package/dist/targets/agents-md.js +4 -4
- package/dist/targets/claude-code.js +86 -86
- package/dist/targets/codex-cli.js +6 -6
- package/dist/targets/copilot.js +46 -46
- package/dist/targets/cursor.js +68 -68
- package/dist/targets/gemini-cli.js +25 -25
- package/dist/targets/generic-md-target.js +43 -43
- package/dist/targets/index.d.ts +6 -6
- package/dist/targets/index.js +911 -911
- package/dist/targets/mistral-vibe.js +46 -46
- package/dist/targets/opencode.js +68 -68
- package/dist/targets/registry.js +911 -911
- package/dist/utils/credentials.js +2 -2
- package/dist/utils/filesystem.js +4 -4
- package/dist/utils/global.d.ts +3 -0
- package/dist/utils/global.js +1 -1
- package/dist/utils/tarball.js +2 -2
- package/package.json +5 -5
- package/templates/pack/models.json +36 -36
- package/templates/pack/pack.json +8 -8
- package/templates/workspace/agentpacks.jsonc +24 -24
package/dist/node/core/index.js
CHANGED
|
@@ -2,10 +2,10 @@ import { createRequire } from "node:module";
|
|
|
2
2
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
3
|
|
|
4
4
|
// src/core/config.ts
|
|
5
|
-
import {
|
|
6
|
-
import { readFileSync, existsSync } from "fs";
|
|
7
|
-
import { resolve } from "path";
|
|
5
|
+
import { existsSync, readFileSync } from "fs";
|
|
8
6
|
import { parse as parseJsonc } from "jsonc-parser";
|
|
7
|
+
import { resolve } from "path";
|
|
8
|
+
import { z } from "zod";
|
|
9
9
|
var TARGET_IDS = [
|
|
10
10
|
"opencode",
|
|
11
11
|
"cursor",
|
|
@@ -134,17 +134,138 @@ function resolveTargets(config) {
|
|
|
134
134
|
return config.targets;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
// src/core/dependency-resolver.ts
|
|
138
|
+
function buildDependencyGraph(manifests) {
|
|
139
|
+
const graph = new Map;
|
|
140
|
+
for (const m of manifests) {
|
|
141
|
+
graph.set(m.name, {
|
|
142
|
+
name: m.name,
|
|
143
|
+
manifest: m,
|
|
144
|
+
dependencies: m.dependencies,
|
|
145
|
+
conflicts: m.conflicts
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return graph;
|
|
149
|
+
}
|
|
150
|
+
function resolveDependencies(manifests) {
|
|
151
|
+
const graph = buildDependencyGraph(manifests);
|
|
152
|
+
const allNames = new Set(graph.keys());
|
|
153
|
+
const missingDeps = [];
|
|
154
|
+
for (const [name, node] of graph) {
|
|
155
|
+
for (const dep of node.dependencies) {
|
|
156
|
+
if (!allNames.has(dep)) {
|
|
157
|
+
missingDeps.push([name, dep]);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const { sorted, cycles } = topologicalSort(graph);
|
|
162
|
+
const conflictPairs = detectConflicts(graph);
|
|
163
|
+
const ok = cycles.length === 0 && conflictPairs.length === 0 && missingDeps.length === 0;
|
|
164
|
+
return { sorted, cycles, conflictPairs, missingDeps, ok };
|
|
165
|
+
}
|
|
166
|
+
function topologicalSort(graph) {
|
|
167
|
+
const inDegree = new Map;
|
|
168
|
+
for (const name of graph.keys()) {
|
|
169
|
+
inDegree.set(name, 0);
|
|
170
|
+
}
|
|
171
|
+
for (const [, node] of graph) {
|
|
172
|
+
for (const dep of node.dependencies) {
|
|
173
|
+
if (graph.has(dep)) {
|
|
174
|
+
inDegree.set(dep, (inDegree.get(dep) ?? 0) + 1);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const queue = [];
|
|
179
|
+
for (const [name, degree] of inDegree) {
|
|
180
|
+
if (degree === 0)
|
|
181
|
+
queue.push(name);
|
|
182
|
+
}
|
|
183
|
+
const sorted = [];
|
|
184
|
+
while (queue.length > 0) {
|
|
185
|
+
const current = queue.shift();
|
|
186
|
+
if (!current)
|
|
187
|
+
continue;
|
|
188
|
+
sorted.push(current);
|
|
189
|
+
const node = graph.get(current);
|
|
190
|
+
if (!node)
|
|
191
|
+
continue;
|
|
192
|
+
for (const dep of node.dependencies) {
|
|
193
|
+
if (!graph.has(dep))
|
|
194
|
+
continue;
|
|
195
|
+
const newDegree = (inDegree.get(dep) ?? 1) - 1;
|
|
196
|
+
inDegree.set(dep, newDegree);
|
|
197
|
+
if (newDegree === 0) {
|
|
198
|
+
queue.push(dep);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
const cycles = [];
|
|
203
|
+
if (sorted.length < graph.size) {
|
|
204
|
+
const remaining = new Set;
|
|
205
|
+
for (const name of graph.keys()) {
|
|
206
|
+
if (!sorted.includes(name))
|
|
207
|
+
remaining.add(name);
|
|
208
|
+
}
|
|
209
|
+
const visited = new Set;
|
|
210
|
+
for (const start of remaining) {
|
|
211
|
+
if (visited.has(start))
|
|
212
|
+
continue;
|
|
213
|
+
const cycle = traceCycle(start, graph, remaining);
|
|
214
|
+
if (cycle.length > 0) {
|
|
215
|
+
cycles.push(cycle);
|
|
216
|
+
for (const n of cycle)
|
|
217
|
+
visited.add(n);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return { sorted: sorted.reverse(), cycles };
|
|
222
|
+
}
|
|
223
|
+
function traceCycle(start, graph, remaining) {
|
|
224
|
+
const path = [];
|
|
225
|
+
const pathSet = new Set;
|
|
226
|
+
let current = start;
|
|
227
|
+
while (current && !pathSet.has(current)) {
|
|
228
|
+
path.push(current);
|
|
229
|
+
pathSet.add(current);
|
|
230
|
+
const node = graph.get(current);
|
|
231
|
+
if (!node)
|
|
232
|
+
break;
|
|
233
|
+
current = node.dependencies.find((d) => remaining.has(d) && graph.has(d));
|
|
234
|
+
}
|
|
235
|
+
if (current && pathSet.has(current)) {
|
|
236
|
+
const cycleStart = path.indexOf(current);
|
|
237
|
+
return path.slice(cycleStart);
|
|
238
|
+
}
|
|
239
|
+
return path;
|
|
240
|
+
}
|
|
241
|
+
function detectConflicts(graph) {
|
|
242
|
+
const conflicts = [];
|
|
243
|
+
const seen = new Set;
|
|
244
|
+
for (const [name, node] of graph) {
|
|
245
|
+
for (const conflict of node.conflicts) {
|
|
246
|
+
if (graph.has(conflict)) {
|
|
247
|
+
const key = [name, conflict].sort().join(":");
|
|
248
|
+
if (!seen.has(key)) {
|
|
249
|
+
seen.add(key);
|
|
250
|
+
conflicts.push([name, conflict]);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return conflicts;
|
|
256
|
+
}
|
|
257
|
+
|
|
137
258
|
// src/utils/filesystem.ts
|
|
138
259
|
import {
|
|
139
260
|
existsSync as existsSync2,
|
|
140
261
|
mkdirSync,
|
|
141
|
-
readFileSync as readFileSync2,
|
|
142
|
-
writeFileSync,
|
|
143
262
|
readdirSync,
|
|
263
|
+
readFileSync as readFileSync2,
|
|
144
264
|
rmSync,
|
|
145
|
-
statSync
|
|
265
|
+
statSync,
|
|
266
|
+
writeFileSync
|
|
146
267
|
} from "fs";
|
|
147
|
-
import { dirname,
|
|
268
|
+
import { dirname, join, relative } from "path";
|
|
148
269
|
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
149
270
|
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
150
271
|
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
@@ -244,398 +365,76 @@ function getHeader(type) {
|
|
|
244
365
|
}
|
|
245
366
|
}
|
|
246
367
|
|
|
247
|
-
// src/
|
|
248
|
-
import
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
368
|
+
// src/features/models.ts
|
|
369
|
+
import { join as join2 } from "path";
|
|
370
|
+
import { z as z2 } from "zod";
|
|
371
|
+
var SECRET_PATTERNS = [
|
|
372
|
+
/["']api[_-]?key["']\s*:/i,
|
|
373
|
+
/["']apiKey["']\s*:/i,
|
|
374
|
+
/["']secret["']\s*:/i,
|
|
375
|
+
/["']password["']\s*:/i,
|
|
376
|
+
/["'](?:auth_token|access_token|bearer_token)["']\s*:/i,
|
|
377
|
+
/["']private[_-]?key["']\s*:/i,
|
|
378
|
+
/-----BEGIN\s+(RSA|EC|DSA|OPENSSH|PGP)\s+PRIVATE\s+KEY-----/,
|
|
379
|
+
/sk-[a-zA-Z0-9]{20,}/,
|
|
380
|
+
/Bearer\s+[a-zA-Z0-9._-]{20,}/
|
|
381
|
+
];
|
|
382
|
+
var AgentModelSchema = z2.object({
|
|
383
|
+
model: z2.string(),
|
|
384
|
+
temperature: z2.number().min(0).max(2).optional(),
|
|
385
|
+
top_p: z2.number().min(0).max(1).optional()
|
|
386
|
+
});
|
|
387
|
+
var ModelProfileSchema = z2.object({
|
|
388
|
+
extends: z2.string().optional(),
|
|
389
|
+
description: z2.string().optional(),
|
|
390
|
+
default: z2.string().optional(),
|
|
391
|
+
small: z2.string().optional(),
|
|
392
|
+
agents: z2.record(z2.string(), AgentModelSchema).optional()
|
|
393
|
+
});
|
|
394
|
+
var RoutingConditionSchema = z2.object({
|
|
395
|
+
complexity: z2.enum(["low", "medium", "high", "critical"]).optional().describe("Task complexity level"),
|
|
396
|
+
urgency: z2.enum(["low", "normal", "high"]).optional().describe("Time sensitivity"),
|
|
397
|
+
budget: z2.enum(["minimal", "standard", "premium"]).optional().describe("Cost/token budget tier"),
|
|
398
|
+
contextWindowNeed: z2.enum(["small", "medium", "large", "max"]).optional().describe("Required context window size"),
|
|
399
|
+
toolUseIntensity: z2.enum(["none", "light", "heavy"]).optional().describe("Expected tool/function calling intensity")
|
|
400
|
+
});
|
|
401
|
+
var RoutingRuleSchema = z2.object({
|
|
402
|
+
when: z2.record(z2.string(), z2.string()),
|
|
403
|
+
use: z2.string(),
|
|
404
|
+
description: z2.string().optional(),
|
|
405
|
+
priority: z2.number().optional()
|
|
406
|
+
});
|
|
407
|
+
var ProviderModelSchema = z2.object({
|
|
408
|
+
options: z2.record(z2.string(), z2.unknown()).optional(),
|
|
409
|
+
variants: z2.record(z2.string(), z2.record(z2.string(), z2.unknown())).optional()
|
|
410
|
+
});
|
|
411
|
+
var ProviderConfigSchema = z2.object({
|
|
412
|
+
options: z2.record(z2.string(), z2.unknown()).optional(),
|
|
413
|
+
models: z2.record(z2.string(), ProviderModelSchema).optional()
|
|
414
|
+
});
|
|
415
|
+
var ModelsSchema = z2.object({
|
|
416
|
+
default: z2.string().optional(),
|
|
417
|
+
small: z2.string().optional(),
|
|
418
|
+
agents: z2.record(z2.string(), AgentModelSchema).optional(),
|
|
419
|
+
profiles: z2.record(z2.string(), ModelProfileSchema).optional(),
|
|
420
|
+
providers: z2.record(z2.string(), ProviderConfigSchema).optional(),
|
|
421
|
+
routing: z2.array(RoutingRuleSchema).optional(),
|
|
422
|
+
overrides: z2.record(z2.string(), z2.object({
|
|
423
|
+
default: z2.string().optional(),
|
|
424
|
+
small: z2.string().optional(),
|
|
425
|
+
agents: z2.record(z2.string(), AgentModelSchema).optional()
|
|
426
|
+
})).optional()
|
|
427
|
+
});
|
|
428
|
+
function parseModels(packDir, packName) {
|
|
429
|
+
const modelsPath = join2(packDir, "models.json");
|
|
430
|
+
const raw = readJsonOrNull(modelsPath);
|
|
431
|
+
if (!raw)
|
|
432
|
+
return null;
|
|
433
|
+
const parsed = ModelsSchema.parse(raw);
|
|
308
434
|
return {
|
|
309
|
-
name: basename2(filepath, ".md"),
|
|
310
|
-
sourcePath: filepath,
|
|
311
435
|
packName,
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
function commandMatchesTarget(cmd, targetId) {
|
|
317
|
-
const { targets } = cmd.meta;
|
|
318
|
-
if (!targets || targets === "*")
|
|
319
|
-
return true;
|
|
320
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
321
|
-
return true;
|
|
322
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
// src/features/agents.ts
|
|
326
|
-
import { readFileSync as readFileSync5 } from "fs";
|
|
327
|
-
import { basename as basename3 } from "path";
|
|
328
|
-
function parseAgents(agentsDir, packName) {
|
|
329
|
-
const files = listFiles(agentsDir, { extension: ".md" });
|
|
330
|
-
return files.map((filepath) => parseAgentFile(filepath, packName));
|
|
331
|
-
}
|
|
332
|
-
function parseAgentFile(filepath, packName) {
|
|
333
|
-
const raw = readFileSync5(filepath, "utf-8");
|
|
334
|
-
const { data, content } = parseFrontmatter(raw);
|
|
335
|
-
return {
|
|
336
|
-
name: data.name ?? basename3(filepath, ".md"),
|
|
337
|
-
sourcePath: filepath,
|
|
338
|
-
packName,
|
|
339
|
-
meta: data,
|
|
340
|
-
content
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
function agentMatchesTarget(agent, targetId) {
|
|
344
|
-
const { targets } = agent.meta;
|
|
345
|
-
if (!targets || targets === "*")
|
|
346
|
-
return true;
|
|
347
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
348
|
-
return true;
|
|
349
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// src/features/skills.ts
|
|
353
|
-
import { readFileSync as readFileSync6, existsSync as existsSync3 } from "fs";
|
|
354
|
-
import { basename as basename4, join as join2 } from "path";
|
|
355
|
-
var SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
356
|
-
var SKILL_NAME_MAX_LENGTH = 64;
|
|
357
|
-
function parseSkills(skillsDir, packName) {
|
|
358
|
-
const dirs = listDirs(skillsDir);
|
|
359
|
-
const skills = [];
|
|
360
|
-
for (const dir of dirs) {
|
|
361
|
-
const skillMd = join2(dir, "SKILL.md");
|
|
362
|
-
if (existsSync3(skillMd)) {
|
|
363
|
-
skills.push(parseSkillFile(skillMd, dir, packName));
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
return skills;
|
|
367
|
-
}
|
|
368
|
-
function parseSkillFile(filepath, skillDir, packName) {
|
|
369
|
-
const raw = readFileSync6(filepath, "utf-8");
|
|
370
|
-
const { data, content } = parseFrontmatter(raw);
|
|
371
|
-
return {
|
|
372
|
-
name: data.name ?? basename4(skillDir),
|
|
373
|
-
sourcePath: filepath,
|
|
374
|
-
sourceDir: skillDir,
|
|
375
|
-
packName,
|
|
376
|
-
meta: data,
|
|
377
|
-
content
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
function buildSkillFrontmatter(skill) {
|
|
381
|
-
return {
|
|
382
|
-
...skill.meta,
|
|
383
|
-
name: skill.name
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
function serializeSkill(skill) {
|
|
387
|
-
return serializeFrontmatter(buildSkillFrontmatter(skill), skill.content);
|
|
388
|
-
}
|
|
389
|
-
function normalizeImportedSkillMarkdown(source, skillName) {
|
|
390
|
-
const { data, content } = parseFrontmatter(source);
|
|
391
|
-
const normalized = {
|
|
392
|
-
...data,
|
|
393
|
-
name: skillName
|
|
394
|
-
};
|
|
395
|
-
let addedDescription = false;
|
|
396
|
-
const description = normalized.description;
|
|
397
|
-
if (typeof description !== "string" || description.trim().length === 0) {
|
|
398
|
-
normalized.description = `Imported skill: ${skillName}`;
|
|
399
|
-
addedDescription = true;
|
|
400
|
-
}
|
|
401
|
-
return {
|
|
402
|
-
content: serializeFrontmatter(normalized, content),
|
|
403
|
-
addedDescription
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
|
-
function validateAgentSkillsFrontmatter(skill) {
|
|
407
|
-
const errors = [];
|
|
408
|
-
const dirName = basename4(skill.sourceDir);
|
|
409
|
-
const declaredName = skill.meta.name;
|
|
410
|
-
if (typeof declaredName !== "string" || declaredName.trim().length === 0) {
|
|
411
|
-
errors.push('Missing required frontmatter field "name".');
|
|
412
|
-
} else {
|
|
413
|
-
if (declaredName.length > SKILL_NAME_MAX_LENGTH) {
|
|
414
|
-
errors.push(`Invalid "name": must be at most ${SKILL_NAME_MAX_LENGTH} characters.`);
|
|
415
|
-
}
|
|
416
|
-
if (!SKILL_NAME_PATTERN.test(declaredName)) {
|
|
417
|
-
errors.push('Invalid "name": use lowercase letters, numbers, and single hyphens only.');
|
|
418
|
-
}
|
|
419
|
-
if (declaredName !== dirName) {
|
|
420
|
-
errors.push(`Invalid "name": must match containing directory "${dirName}".`);
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
const description = skill.meta.description;
|
|
424
|
-
if (typeof description !== "string" || description.trim().length === 0) {
|
|
425
|
-
errors.push('Missing required frontmatter field "description".');
|
|
426
|
-
}
|
|
427
|
-
const allowedTools = skill.meta["allowed-tools"];
|
|
428
|
-
if (allowedTools !== undefined && (!Array.isArray(allowedTools) || allowedTools.some((tool) => typeof tool !== "string" || tool.length === 0))) {
|
|
429
|
-
errors.push('Invalid "allowed-tools": expected an array of non-empty strings.');
|
|
430
|
-
}
|
|
431
|
-
return errors;
|
|
432
|
-
}
|
|
433
|
-
function skillMatchesTarget(skill, targetId) {
|
|
434
|
-
const { targets } = skill.meta;
|
|
435
|
-
if (!targets || targets === "*")
|
|
436
|
-
return true;
|
|
437
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
438
|
-
return true;
|
|
439
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
// src/features/hooks.ts
|
|
443
|
-
import { join as join3 } from "path";
|
|
444
|
-
var TARGET_OVERRIDE_KEYS = ["cursor", "claudecode", "opencode"];
|
|
445
|
-
function parseHooks(packDir, packName) {
|
|
446
|
-
const hooksPath = join3(packDir, "hooks", "hooks.json");
|
|
447
|
-
const raw = readJsonOrNull(hooksPath);
|
|
448
|
-
if (!raw)
|
|
449
|
-
return null;
|
|
450
|
-
const shared = raw.hooks ?? {};
|
|
451
|
-
const targetOverrides = {};
|
|
452
|
-
for (const key of TARGET_OVERRIDE_KEYS) {
|
|
453
|
-
const override = raw[key];
|
|
454
|
-
if (override && typeof override === "object" && "hooks" in override && override.hooks) {
|
|
455
|
-
targetOverrides[key] = override.hooks;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
return {
|
|
459
|
-
packName,
|
|
460
|
-
sourcePath: hooksPath,
|
|
461
|
-
version: raw.version,
|
|
462
|
-
shared,
|
|
463
|
-
targetOverrides
|
|
464
|
-
};
|
|
465
|
-
}
|
|
466
|
-
function resolveHooksForTarget(hooks, targetId) {
|
|
467
|
-
const merged = {};
|
|
468
|
-
for (const [event, entries] of Object.entries(hooks.shared)) {
|
|
469
|
-
merged[event] = [...entries];
|
|
470
|
-
}
|
|
471
|
-
const overrides = hooks.targetOverrides[targetId];
|
|
472
|
-
if (overrides) {
|
|
473
|
-
for (const [event, entries] of Object.entries(overrides)) {
|
|
474
|
-
merged[event] = [...merged[event] ?? [], ...entries];
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
return merged;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
// src/features/plugins.ts
|
|
481
|
-
import { readFileSync as readFileSync7, existsSync as existsSync4 } from "fs";
|
|
482
|
-
import { basename as basename5, join as join4 } from "path";
|
|
483
|
-
function parsePlugins(packDir, packName) {
|
|
484
|
-
const pluginsDir = join4(packDir, "plugins");
|
|
485
|
-
if (!existsSync4(pluginsDir))
|
|
486
|
-
return [];
|
|
487
|
-
const tsFiles = listFiles(pluginsDir, { extension: ".ts" });
|
|
488
|
-
const jsFiles = listFiles(pluginsDir, { extension: ".js" });
|
|
489
|
-
const allFiles = [...tsFiles, ...jsFiles];
|
|
490
|
-
return allFiles.map((filepath) => parsePluginFile(filepath, packName));
|
|
491
|
-
}
|
|
492
|
-
function parsePluginFile(filepath, packName) {
|
|
493
|
-
const content = readFileSync7(filepath, "utf-8");
|
|
494
|
-
const ext = filepath.endsWith(".ts") ? "ts" : "js";
|
|
495
|
-
return {
|
|
496
|
-
name: basename5(filepath, `.${ext}`),
|
|
497
|
-
sourcePath: filepath,
|
|
498
|
-
packName,
|
|
499
|
-
content,
|
|
500
|
-
extension: ext
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
// src/features/mcp.ts
|
|
505
|
-
import { join as join5 } from "path";
|
|
506
|
-
function parseMcp(packDir, packName) {
|
|
507
|
-
const mcpPath = join5(packDir, "mcp.json");
|
|
508
|
-
const raw = readJsonOrNull(mcpPath);
|
|
509
|
-
if (!raw?.mcpServers)
|
|
510
|
-
return null;
|
|
511
|
-
return {
|
|
512
|
-
packName,
|
|
513
|
-
sourcePath: mcpPath,
|
|
514
|
-
servers: raw.mcpServers
|
|
515
|
-
};
|
|
516
|
-
}
|
|
517
|
-
function mergeMcpConfigs(configs) {
|
|
518
|
-
const servers = {};
|
|
519
|
-
const warnings = [];
|
|
520
|
-
for (const config of configs) {
|
|
521
|
-
for (const [name, entry] of Object.entries(config.servers)) {
|
|
522
|
-
if (name in servers) {
|
|
523
|
-
warnings.push(`MCP server "${name}" from pack "${config.packName}" skipped (already defined).`);
|
|
524
|
-
continue;
|
|
525
|
-
}
|
|
526
|
-
servers[name] = entry;
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
return { servers, warnings };
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
// src/features/ignore.ts
|
|
533
|
-
import { existsSync as existsSync5, readFileSync as readFileSync8 } from "fs";
|
|
534
|
-
import { join as join6 } from "path";
|
|
535
|
-
var IGNORE_FILES = ["ignore", ".aiignore"];
|
|
536
|
-
function parseIgnore(packDir, packName) {
|
|
537
|
-
for (const filename of IGNORE_FILES) {
|
|
538
|
-
const filepath = join6(packDir, filename);
|
|
539
|
-
if (existsSync5(filepath)) {
|
|
540
|
-
const raw = readFileSync8(filepath, "utf-8");
|
|
541
|
-
const patterns = parseIgnoreContent(raw);
|
|
542
|
-
return {
|
|
543
|
-
packName,
|
|
544
|
-
sourcePath: filepath,
|
|
545
|
-
patterns
|
|
546
|
-
};
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
return null;
|
|
550
|
-
}
|
|
551
|
-
function parseIgnoreContent(content) {
|
|
552
|
-
return content.split(`
|
|
553
|
-
`).map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#"));
|
|
554
|
-
}
|
|
555
|
-
function mergeIgnorePatterns(configs) {
|
|
556
|
-
const seen = new Set;
|
|
557
|
-
const result = [];
|
|
558
|
-
for (const config of configs) {
|
|
559
|
-
for (const pattern of config.patterns) {
|
|
560
|
-
if (!seen.has(pattern)) {
|
|
561
|
-
seen.add(pattern);
|
|
562
|
-
result.push(pattern);
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
return result;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
// src/features/models.ts
|
|
570
|
-
import { join as join7 } from "path";
|
|
571
|
-
import { z as z2 } from "zod";
|
|
572
|
-
var SECRET_PATTERNS = [
|
|
573
|
-
/["']api[_-]?key["']\s*:/i,
|
|
574
|
-
/["']apiKey["']\s*:/i,
|
|
575
|
-
/["']secret["']\s*:/i,
|
|
576
|
-
/["']password["']\s*:/i,
|
|
577
|
-
/["'](?:auth_token|access_token|bearer_token)["']\s*:/i,
|
|
578
|
-
/["']private[_-]?key["']\s*:/i,
|
|
579
|
-
/-----BEGIN\s+(RSA|EC|DSA|OPENSSH|PGP)\s+PRIVATE\s+KEY-----/,
|
|
580
|
-
/sk-[a-zA-Z0-9]{20,}/,
|
|
581
|
-
/Bearer\s+[a-zA-Z0-9._-]{20,}/
|
|
582
|
-
];
|
|
583
|
-
var AgentModelSchema = z2.object({
|
|
584
|
-
model: z2.string(),
|
|
585
|
-
temperature: z2.number().min(0).max(2).optional(),
|
|
586
|
-
top_p: z2.number().min(0).max(1).optional()
|
|
587
|
-
});
|
|
588
|
-
var ModelProfileSchema = z2.object({
|
|
589
|
-
extends: z2.string().optional(),
|
|
590
|
-
description: z2.string().optional(),
|
|
591
|
-
default: z2.string().optional(),
|
|
592
|
-
small: z2.string().optional(),
|
|
593
|
-
agents: z2.record(z2.string(), AgentModelSchema).optional()
|
|
594
|
-
});
|
|
595
|
-
var RoutingConditionSchema = z2.object({
|
|
596
|
-
complexity: z2.enum(["low", "medium", "high", "critical"]).optional().describe("Task complexity level"),
|
|
597
|
-
urgency: z2.enum(["low", "normal", "high"]).optional().describe("Time sensitivity"),
|
|
598
|
-
budget: z2.enum(["minimal", "standard", "premium"]).optional().describe("Cost/token budget tier"),
|
|
599
|
-
contextWindowNeed: z2.enum(["small", "medium", "large", "max"]).optional().describe("Required context window size"),
|
|
600
|
-
toolUseIntensity: z2.enum(["none", "light", "heavy"]).optional().describe("Expected tool/function calling intensity")
|
|
601
|
-
});
|
|
602
|
-
var RoutingRuleSchema = z2.object({
|
|
603
|
-
when: z2.record(z2.string(), z2.string()),
|
|
604
|
-
use: z2.string(),
|
|
605
|
-
description: z2.string().optional(),
|
|
606
|
-
priority: z2.number().optional()
|
|
607
|
-
});
|
|
608
|
-
var ProviderModelSchema = z2.object({
|
|
609
|
-
options: z2.record(z2.string(), z2.unknown()).optional(),
|
|
610
|
-
variants: z2.record(z2.string(), z2.record(z2.string(), z2.unknown())).optional()
|
|
611
|
-
});
|
|
612
|
-
var ProviderConfigSchema = z2.object({
|
|
613
|
-
options: z2.record(z2.string(), z2.unknown()).optional(),
|
|
614
|
-
models: z2.record(z2.string(), ProviderModelSchema).optional()
|
|
615
|
-
});
|
|
616
|
-
var ModelsSchema = z2.object({
|
|
617
|
-
default: z2.string().optional(),
|
|
618
|
-
small: z2.string().optional(),
|
|
619
|
-
agents: z2.record(z2.string(), AgentModelSchema).optional(),
|
|
620
|
-
profiles: z2.record(z2.string(), ModelProfileSchema).optional(),
|
|
621
|
-
providers: z2.record(z2.string(), ProviderConfigSchema).optional(),
|
|
622
|
-
routing: z2.array(RoutingRuleSchema).optional(),
|
|
623
|
-
overrides: z2.record(z2.string(), z2.object({
|
|
624
|
-
default: z2.string().optional(),
|
|
625
|
-
small: z2.string().optional(),
|
|
626
|
-
agents: z2.record(z2.string(), AgentModelSchema).optional()
|
|
627
|
-
})).optional()
|
|
628
|
-
});
|
|
629
|
-
function parseModels(packDir, packName) {
|
|
630
|
-
const modelsPath = join7(packDir, "models.json");
|
|
631
|
-
const raw = readJsonOrNull(modelsPath);
|
|
632
|
-
if (!raw)
|
|
633
|
-
return null;
|
|
634
|
-
const parsed = ModelsSchema.parse(raw);
|
|
635
|
-
return {
|
|
636
|
-
packName,
|
|
637
|
-
sourcePath: modelsPath,
|
|
638
|
-
config: parsed
|
|
436
|
+
sourcePath: modelsPath,
|
|
437
|
+
config: parsed
|
|
639
438
|
};
|
|
640
439
|
}
|
|
641
440
|
function mergeModelsConfigs(configs) {
|
|
@@ -723,119 +522,16 @@ function mergeModelsConfigs(configs) {
|
|
|
723
522
|
}
|
|
724
523
|
}
|
|
725
524
|
return { config: result, warnings };
|
|
726
|
-
}
|
|
727
|
-
function scanModelsForSecrets(config) {
|
|
728
|
-
const warnings = [];
|
|
729
|
-
const json = JSON.stringify(config);
|
|
730
|
-
for (const pattern of SECRET_PATTERNS) {
|
|
731
|
-
if (pattern.test(json)) {
|
|
732
|
-
warnings.push(`Potential secret detected in models.json matching pattern: ${pattern.source}`);
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
return warnings;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
// src/core/pack-loader.ts
|
|
739
|
-
import { existsSync as existsSync6 } from "fs";
|
|
740
|
-
import { resolve as resolve2, isAbsolute } from "path";
|
|
741
|
-
class PackLoader {
|
|
742
|
-
projectRoot;
|
|
743
|
-
config;
|
|
744
|
-
constructor(projectRoot, config) {
|
|
745
|
-
this.projectRoot = projectRoot;
|
|
746
|
-
this.config = config;
|
|
747
|
-
}
|
|
748
|
-
loadAll() {
|
|
749
|
-
const warnings = [];
|
|
750
|
-
const packs = [];
|
|
751
|
-
const disabledSet = new Set(this.config.disabled);
|
|
752
|
-
for (const packRef of this.config.packs) {
|
|
753
|
-
const packDir = this.resolvePackPath(packRef);
|
|
754
|
-
if (!packDir) {
|
|
755
|
-
warnings.push(`Pack "${packRef}" could not be resolved. Skipping.`);
|
|
756
|
-
continue;
|
|
757
|
-
}
|
|
758
|
-
if (!existsSync6(packDir)) {
|
|
759
|
-
warnings.push(`Pack directory "${packDir}" does not exist. Skipping.`);
|
|
760
|
-
continue;
|
|
761
|
-
}
|
|
762
|
-
const manifest = loadPackManifest(packDir);
|
|
763
|
-
if (disabledSet.has(manifest.name) || disabledSet.has(packRef)) {
|
|
764
|
-
continue;
|
|
765
|
-
}
|
|
766
|
-
const loaded = this.loadPack(packDir, manifest);
|
|
767
|
-
packs.push(loaded);
|
|
768
|
-
}
|
|
769
|
-
return { packs, warnings };
|
|
770
|
-
}
|
|
771
|
-
loadPack(packDir, manifest) {
|
|
772
|
-
const name = manifest.name;
|
|
773
|
-
const rulesDir = resolve2(packDir, "rules");
|
|
774
|
-
const commandsDir = resolve2(packDir, "commands");
|
|
775
|
-
const agentsDir = resolve2(packDir, "agents");
|
|
776
|
-
const skillsDir = resolve2(packDir, "skills");
|
|
777
|
-
return {
|
|
778
|
-
manifest,
|
|
779
|
-
directory: packDir,
|
|
780
|
-
rules: existsSync6(rulesDir) ? parseRules(rulesDir, name) : [],
|
|
781
|
-
commands: existsSync6(commandsDir) ? parseCommands(commandsDir, name) : [],
|
|
782
|
-
agents: existsSync6(agentsDir) ? parseAgents(agentsDir, name) : [],
|
|
783
|
-
skills: existsSync6(skillsDir) ? parseSkills(skillsDir, name) : [],
|
|
784
|
-
hooks: parseHooks(packDir, name),
|
|
785
|
-
plugins: parsePlugins(packDir, name),
|
|
786
|
-
mcp: parseMcp(packDir, name),
|
|
787
|
-
ignore: parseIgnore(packDir, name),
|
|
788
|
-
models: parseModels(packDir, name)
|
|
789
|
-
};
|
|
790
|
-
}
|
|
791
|
-
loadForBaseDir(baseDir) {
|
|
792
|
-
const baseDirRoot = resolve2(this.projectRoot, baseDir);
|
|
793
|
-
const localConfigPath = resolve2(baseDirRoot, "agentpacks.jsonc");
|
|
794
|
-
if (!existsSync6(localConfigPath)) {
|
|
795
|
-
return { packs: [], warnings: [] };
|
|
796
|
-
}
|
|
797
|
-
const localConfig = loadWorkspaceConfig(baseDirRoot);
|
|
798
|
-
const loader = new PackLoader(baseDirRoot, localConfig);
|
|
799
|
-
return loader.loadAll();
|
|
800
|
-
}
|
|
801
|
-
resolveCuratedPack(packRef) {
|
|
802
|
-
const curatedDir = resolve2(this.projectRoot, ".agentpacks", ".curated");
|
|
803
|
-
let packName = packRef;
|
|
804
|
-
if (packName.startsWith("registry:"))
|
|
805
|
-
packName = packName.slice(9);
|
|
806
|
-
if (packName.startsWith("npm:"))
|
|
807
|
-
packName = packName.slice(4);
|
|
808
|
-
if (packName.startsWith("github:"))
|
|
809
|
-
packName = packName.slice(7);
|
|
810
|
-
if (packName.startsWith("@"))
|
|
811
|
-
packName = packName.slice(1);
|
|
812
|
-
if (packName.includes("/")) {
|
|
813
|
-
const parts = packName.split("/");
|
|
814
|
-
packName = packName.includes("@") ? parts.join("-") : parts[parts.length - 1] ?? packName;
|
|
815
|
-
}
|
|
816
|
-
const withoutVersion = packName.split("@")[0] ?? packName;
|
|
817
|
-
packName = withoutVersion.split(":")[0] ?? withoutVersion;
|
|
818
|
-
const resolved = resolve2(curatedDir, packName);
|
|
819
|
-
return existsSync6(resolved) ? resolved : null;
|
|
820
|
-
}
|
|
821
|
-
resolvePackPath(packRef) {
|
|
822
|
-
if (packRef.startsWith("./") || packRef.startsWith("../")) {
|
|
823
|
-
return resolve2(this.projectRoot, packRef);
|
|
824
|
-
}
|
|
825
|
-
if (isAbsolute(packRef)) {
|
|
826
|
-
return packRef;
|
|
827
|
-
}
|
|
828
|
-
if (packRef.startsWith("registry:")) {
|
|
829
|
-
return this.resolveCuratedPack(packRef);
|
|
830
|
-
}
|
|
831
|
-
if (packRef.startsWith("@") || packRef.startsWith("npm:") || !packRef.includes("/")) {
|
|
832
|
-
return this.resolveCuratedPack(packRef);
|
|
833
|
-
}
|
|
834
|
-
if (packRef.startsWith("github:") || packRef.includes("/")) {
|
|
835
|
-
return this.resolveCuratedPack(packRef);
|
|
525
|
+
}
|
|
526
|
+
function scanModelsForSecrets(config) {
|
|
527
|
+
const warnings = [];
|
|
528
|
+
const json = JSON.stringify(config);
|
|
529
|
+
for (const pattern of SECRET_PATTERNS) {
|
|
530
|
+
if (pattern.test(json)) {
|
|
531
|
+
warnings.push(`Potential secret detected in models.json matching pattern: ${pattern.source}`);
|
|
836
532
|
}
|
|
837
|
-
return resolve2(this.projectRoot, packRef);
|
|
838
533
|
}
|
|
534
|
+
return warnings;
|
|
839
535
|
}
|
|
840
536
|
|
|
841
537
|
// src/core/feature-merger.ts
|
|
@@ -954,158 +650,462 @@ class FeatureMerger {
|
|
|
954
650
|
}
|
|
955
651
|
|
|
956
652
|
// src/core/lockfile.ts
|
|
957
|
-
import { existsSync as existsSync7, readFileSync as readFileSync9, writeFileSync as writeFileSync2 } from "fs";
|
|
958
|
-
import { resolve as resolve3 } from "path";
|
|
959
653
|
import { createHash } from "crypto";
|
|
654
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
655
|
+
import { resolve as resolve2 } from "path";
|
|
960
656
|
var LOCKFILE_VERSION = 1;
|
|
961
657
|
var LOCKFILE_NAME = "agentpacks.lock";
|
|
962
658
|
function loadLockfile(projectRoot) {
|
|
963
|
-
const filepath =
|
|
964
|
-
if (!
|
|
659
|
+
const filepath = resolve2(projectRoot, LOCKFILE_NAME);
|
|
660
|
+
if (!existsSync3(filepath)) {
|
|
965
661
|
return { lockfileVersion: LOCKFILE_VERSION, sources: {} };
|
|
966
662
|
}
|
|
967
|
-
const raw =
|
|
968
|
-
return JSON.parse(raw);
|
|
969
|
-
}
|
|
970
|
-
function saveLockfile(projectRoot, lockfile) {
|
|
971
|
-
const filepath =
|
|
972
|
-
writeFileSync2(filepath, JSON.stringify(lockfile, null, 2) + `
|
|
973
|
-
`);
|
|
974
|
-
}
|
|
975
|
-
function getLockedSource(lockfile, sourceKey) {
|
|
976
|
-
return lockfile.sources[sourceKey];
|
|
663
|
+
const raw = readFileSync3(filepath, "utf-8");
|
|
664
|
+
return JSON.parse(raw);
|
|
665
|
+
}
|
|
666
|
+
function saveLockfile(projectRoot, lockfile) {
|
|
667
|
+
const filepath = resolve2(projectRoot, LOCKFILE_NAME);
|
|
668
|
+
writeFileSync2(filepath, JSON.stringify(lockfile, null, 2) + `
|
|
669
|
+
`);
|
|
670
|
+
}
|
|
671
|
+
function getLockedSource(lockfile, sourceKey) {
|
|
672
|
+
return lockfile.sources[sourceKey];
|
|
673
|
+
}
|
|
674
|
+
function setLockedSource(lockfile, sourceKey, entry) {
|
|
675
|
+
lockfile.sources[sourceKey] = entry;
|
|
676
|
+
}
|
|
677
|
+
function computeIntegrity(content) {
|
|
678
|
+
const hash = createHash("sha256").update(content).digest("hex");
|
|
679
|
+
return `sha256-${hash}`;
|
|
680
|
+
}
|
|
681
|
+
function isLockfileFrozenValid(lockfile, sourceKeys) {
|
|
682
|
+
const missing = sourceKeys.filter((key) => !(key in lockfile.sources));
|
|
683
|
+
return { valid: missing.length === 0, missing };
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
// src/utils/frontmatter.ts
|
|
687
|
+
import matter from "gray-matter";
|
|
688
|
+
function parseFrontmatter(source) {
|
|
689
|
+
const { data, content } = matter(source);
|
|
690
|
+
return {
|
|
691
|
+
data,
|
|
692
|
+
content: content.trim(),
|
|
693
|
+
raw: source
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
function serializeFrontmatter(data, content) {
|
|
697
|
+
const filtered = Object.fromEntries(Object.entries(data).filter(([, v]) => v !== undefined));
|
|
698
|
+
if (Object.keys(filtered).length === 0) {
|
|
699
|
+
return content;
|
|
700
|
+
}
|
|
701
|
+
return matter.stringify(content, filtered);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
// src/features/agents.ts
|
|
705
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
706
|
+
import { basename } from "path";
|
|
707
|
+
function parseAgents(agentsDir, packName) {
|
|
708
|
+
const files = listFiles(agentsDir, { extension: ".md" });
|
|
709
|
+
return files.map((filepath) => parseAgentFile(filepath, packName));
|
|
710
|
+
}
|
|
711
|
+
function parseAgentFile(filepath, packName) {
|
|
712
|
+
const raw = readFileSync4(filepath, "utf-8");
|
|
713
|
+
const { data, content } = parseFrontmatter(raw);
|
|
714
|
+
return {
|
|
715
|
+
name: data.name ?? basename(filepath, ".md"),
|
|
716
|
+
sourcePath: filepath,
|
|
717
|
+
packName,
|
|
718
|
+
meta: data,
|
|
719
|
+
content
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
function agentMatchesTarget(agent, targetId) {
|
|
723
|
+
const { targets } = agent.meta;
|
|
724
|
+
if (!targets || targets === "*")
|
|
725
|
+
return true;
|
|
726
|
+
if (Array.isArray(targets) && targets.includes("*"))
|
|
727
|
+
return true;
|
|
728
|
+
return Array.isArray(targets) && targets.includes(targetId);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
// src/features/commands.ts
|
|
732
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
733
|
+
import { basename as basename2 } from "path";
|
|
734
|
+
function parseCommands(commandsDir, packName) {
|
|
735
|
+
const files = listFiles(commandsDir, { extension: ".md" });
|
|
736
|
+
return files.map((filepath) => parseCommandFile(filepath, packName));
|
|
737
|
+
}
|
|
738
|
+
function parseCommandFile(filepath, packName) {
|
|
739
|
+
const raw = readFileSync5(filepath, "utf-8");
|
|
740
|
+
const { data, content } = parseFrontmatter(raw);
|
|
741
|
+
return {
|
|
742
|
+
name: basename2(filepath, ".md"),
|
|
743
|
+
sourcePath: filepath,
|
|
744
|
+
packName,
|
|
745
|
+
meta: data,
|
|
746
|
+
content
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
function commandMatchesTarget(cmd, targetId) {
|
|
750
|
+
const { targets } = cmd.meta;
|
|
751
|
+
if (!targets || targets === "*")
|
|
752
|
+
return true;
|
|
753
|
+
if (Array.isArray(targets) && targets.includes("*"))
|
|
754
|
+
return true;
|
|
755
|
+
return Array.isArray(targets) && targets.includes(targetId);
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
// src/features/hooks.ts
|
|
759
|
+
import { join as join3 } from "path";
|
|
760
|
+
var TARGET_OVERRIDE_KEYS = ["cursor", "claudecode", "opencode"];
|
|
761
|
+
function parseHooks(packDir, packName) {
|
|
762
|
+
const hooksPath = join3(packDir, "hooks", "hooks.json");
|
|
763
|
+
const raw = readJsonOrNull(hooksPath);
|
|
764
|
+
if (!raw)
|
|
765
|
+
return null;
|
|
766
|
+
const shared = raw.hooks ?? {};
|
|
767
|
+
const targetOverrides = {};
|
|
768
|
+
for (const key of TARGET_OVERRIDE_KEYS) {
|
|
769
|
+
const override = raw[key];
|
|
770
|
+
if (override && typeof override === "object" && "hooks" in override && override.hooks) {
|
|
771
|
+
targetOverrides[key] = override.hooks;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
return {
|
|
775
|
+
packName,
|
|
776
|
+
sourcePath: hooksPath,
|
|
777
|
+
version: raw.version,
|
|
778
|
+
shared,
|
|
779
|
+
targetOverrides
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
function resolveHooksForTarget(hooks, targetId) {
|
|
783
|
+
const merged = {};
|
|
784
|
+
for (const [event, entries] of Object.entries(hooks.shared)) {
|
|
785
|
+
merged[event] = [...entries];
|
|
786
|
+
}
|
|
787
|
+
const overrides = hooks.targetOverrides[targetId];
|
|
788
|
+
if (overrides) {
|
|
789
|
+
for (const [event, entries] of Object.entries(overrides)) {
|
|
790
|
+
merged[event] = [...merged[event] ?? [], ...entries];
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
return merged;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
// src/features/ignore.ts
|
|
797
|
+
import { existsSync as existsSync4, readFileSync as readFileSync6 } from "fs";
|
|
798
|
+
import { join as join4 } from "path";
|
|
799
|
+
var IGNORE_FILES = ["ignore", ".aiignore"];
|
|
800
|
+
function parseIgnore(packDir, packName) {
|
|
801
|
+
for (const filename of IGNORE_FILES) {
|
|
802
|
+
const filepath = join4(packDir, filename);
|
|
803
|
+
if (existsSync4(filepath)) {
|
|
804
|
+
const raw = readFileSync6(filepath, "utf-8");
|
|
805
|
+
const patterns = parseIgnoreContent(raw);
|
|
806
|
+
return {
|
|
807
|
+
packName,
|
|
808
|
+
sourcePath: filepath,
|
|
809
|
+
patterns
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
return null;
|
|
814
|
+
}
|
|
815
|
+
function parseIgnoreContent(content) {
|
|
816
|
+
return content.split(`
|
|
817
|
+
`).map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#"));
|
|
818
|
+
}
|
|
819
|
+
function mergeIgnorePatterns(configs) {
|
|
820
|
+
const seen = new Set;
|
|
821
|
+
const result = [];
|
|
822
|
+
for (const config of configs) {
|
|
823
|
+
for (const pattern of config.patterns) {
|
|
824
|
+
if (!seen.has(pattern)) {
|
|
825
|
+
seen.add(pattern);
|
|
826
|
+
result.push(pattern);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
return result;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
// src/features/mcp.ts
|
|
834
|
+
import { join as join5 } from "path";
|
|
835
|
+
function parseMcp(packDir, packName) {
|
|
836
|
+
const mcpPath = join5(packDir, "mcp.json");
|
|
837
|
+
const raw = readJsonOrNull(mcpPath);
|
|
838
|
+
if (!raw?.mcpServers)
|
|
839
|
+
return null;
|
|
840
|
+
return {
|
|
841
|
+
packName,
|
|
842
|
+
sourcePath: mcpPath,
|
|
843
|
+
servers: raw.mcpServers
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
function mergeMcpConfigs(configs) {
|
|
847
|
+
const servers = {};
|
|
848
|
+
const warnings = [];
|
|
849
|
+
for (const config of configs) {
|
|
850
|
+
for (const [name, entry] of Object.entries(config.servers)) {
|
|
851
|
+
if (name in servers) {
|
|
852
|
+
warnings.push(`MCP server "${name}" from pack "${config.packName}" skipped (already defined).`);
|
|
853
|
+
continue;
|
|
854
|
+
}
|
|
855
|
+
servers[name] = entry;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
return { servers, warnings };
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
// src/features/plugins.ts
|
|
862
|
+
import { existsSync as existsSync5, readFileSync as readFileSync7 } from "fs";
|
|
863
|
+
import { basename as basename3, join as join6 } from "path";
|
|
864
|
+
function parsePlugins(packDir, packName) {
|
|
865
|
+
const pluginsDir = join6(packDir, "plugins");
|
|
866
|
+
if (!existsSync5(pluginsDir))
|
|
867
|
+
return [];
|
|
868
|
+
const tsFiles = listFiles(pluginsDir, { extension: ".ts" });
|
|
869
|
+
const jsFiles = listFiles(pluginsDir, { extension: ".js" });
|
|
870
|
+
const allFiles = [...tsFiles, ...jsFiles];
|
|
871
|
+
return allFiles.map((filepath) => parsePluginFile(filepath, packName));
|
|
872
|
+
}
|
|
873
|
+
function parsePluginFile(filepath, packName) {
|
|
874
|
+
const content = readFileSync7(filepath, "utf-8");
|
|
875
|
+
const ext = filepath.endsWith(".ts") ? "ts" : "js";
|
|
876
|
+
return {
|
|
877
|
+
name: basename3(filepath, `.${ext}`),
|
|
878
|
+
sourcePath: filepath,
|
|
879
|
+
packName,
|
|
880
|
+
content,
|
|
881
|
+
extension: ext
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
// src/features/rules.ts
|
|
886
|
+
import { readFileSync as readFileSync8 } from "fs";
|
|
887
|
+
import { basename as basename4 } from "path";
|
|
888
|
+
function parseRules(rulesDir, packName) {
|
|
889
|
+
const files = listFiles(rulesDir, { extension: ".md" });
|
|
890
|
+
return files.map((filepath) => parseRuleFile(filepath, packName));
|
|
891
|
+
}
|
|
892
|
+
function parseRuleFile(filepath, packName) {
|
|
893
|
+
const raw = readFileSync8(filepath, "utf-8");
|
|
894
|
+
const { data, content } = parseFrontmatter(raw);
|
|
895
|
+
return {
|
|
896
|
+
name: basename4(filepath, ".md"),
|
|
897
|
+
sourcePath: filepath,
|
|
898
|
+
packName,
|
|
899
|
+
meta: data,
|
|
900
|
+
content
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
function ruleMatchesTarget(rule, targetId) {
|
|
904
|
+
const { targets } = rule.meta;
|
|
905
|
+
if (!targets || targets === "*")
|
|
906
|
+
return true;
|
|
907
|
+
if (Array.isArray(targets) && targets.includes("*"))
|
|
908
|
+
return true;
|
|
909
|
+
return Array.isArray(targets) && targets.includes(targetId);
|
|
910
|
+
}
|
|
911
|
+
function getRootRules(rules) {
|
|
912
|
+
return rules.filter((r) => r.meta.root === true);
|
|
913
|
+
}
|
|
914
|
+
function getDetailRules(rules) {
|
|
915
|
+
return rules.filter((r) => r.meta.root !== true);
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
// src/features/skills.ts
|
|
919
|
+
import { existsSync as existsSync6, readFileSync as readFileSync9 } from "fs";
|
|
920
|
+
import { basename as basename5, join as join7 } from "path";
|
|
921
|
+
var SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
922
|
+
var SKILL_NAME_MAX_LENGTH = 64;
|
|
923
|
+
function parseSkills(skillsDir, packName) {
|
|
924
|
+
const dirs = listDirs(skillsDir);
|
|
925
|
+
const skills = [];
|
|
926
|
+
for (const dir of dirs) {
|
|
927
|
+
const skillMd = join7(dir, "SKILL.md");
|
|
928
|
+
if (existsSync6(skillMd)) {
|
|
929
|
+
skills.push(parseSkillFile(skillMd, dir, packName));
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
return skills;
|
|
977
933
|
}
|
|
978
|
-
function
|
|
979
|
-
|
|
934
|
+
function parseSkillFile(filepath, skillDir, packName) {
|
|
935
|
+
const raw = readFileSync9(filepath, "utf-8");
|
|
936
|
+
const { data, content } = parseFrontmatter(raw);
|
|
937
|
+
return {
|
|
938
|
+
name: data.name ?? basename5(skillDir),
|
|
939
|
+
sourcePath: filepath,
|
|
940
|
+
sourceDir: skillDir,
|
|
941
|
+
packName,
|
|
942
|
+
meta: data,
|
|
943
|
+
content
|
|
944
|
+
};
|
|
980
945
|
}
|
|
981
|
-
function
|
|
982
|
-
|
|
983
|
-
|
|
946
|
+
function buildSkillFrontmatter(skill) {
|
|
947
|
+
return {
|
|
948
|
+
...skill.meta,
|
|
949
|
+
name: skill.name
|
|
950
|
+
};
|
|
984
951
|
}
|
|
985
|
-
function
|
|
986
|
-
|
|
987
|
-
return { valid: missing.length === 0, missing };
|
|
952
|
+
function serializeSkill(skill) {
|
|
953
|
+
return serializeFrontmatter(buildSkillFrontmatter(skill), skill.content);
|
|
988
954
|
}
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
955
|
+
function normalizeImportedSkillMarkdown(source, skillName) {
|
|
956
|
+
const { data, content } = parseFrontmatter(source);
|
|
957
|
+
const normalized = {
|
|
958
|
+
...data,
|
|
959
|
+
name: skillName
|
|
960
|
+
};
|
|
961
|
+
let addedDescription = false;
|
|
962
|
+
const description = normalized.description;
|
|
963
|
+
if (typeof description !== "string" || description.trim().length === 0) {
|
|
964
|
+
normalized.description = `Imported skill: ${skillName}`;
|
|
965
|
+
addedDescription = true;
|
|
1000
966
|
}
|
|
1001
|
-
return
|
|
967
|
+
return {
|
|
968
|
+
content: serializeFrontmatter(normalized, content),
|
|
969
|
+
addedDescription
|
|
970
|
+
};
|
|
1002
971
|
}
|
|
1003
|
-
function
|
|
1004
|
-
const
|
|
1005
|
-
const
|
|
1006
|
-
const
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
}
|
|
972
|
+
function validateAgentSkillsFrontmatter(skill) {
|
|
973
|
+
const errors = [];
|
|
974
|
+
const dirName = basename5(skill.sourceDir);
|
|
975
|
+
const declaredName = skill.meta.name;
|
|
976
|
+
if (typeof declaredName !== "string" || declaredName.trim().length === 0) {
|
|
977
|
+
errors.push('Missing required frontmatter field "name".');
|
|
978
|
+
} else {
|
|
979
|
+
if (declaredName.length > SKILL_NAME_MAX_LENGTH) {
|
|
980
|
+
errors.push(`Invalid "name": must be at most ${SKILL_NAME_MAX_LENGTH} characters.`);
|
|
981
|
+
}
|
|
982
|
+
if (!SKILL_NAME_PATTERN.test(declaredName)) {
|
|
983
|
+
errors.push('Invalid "name": use lowercase letters, numbers, and single hyphens only.');
|
|
984
|
+
}
|
|
985
|
+
if (declaredName !== dirName) {
|
|
986
|
+
errors.push(`Invalid "name": must match containing directory "${dirName}".`);
|
|
1012
987
|
}
|
|
1013
988
|
}
|
|
1014
|
-
const
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
return { sorted, cycles, conflictPairs, missingDeps, ok };
|
|
1018
|
-
}
|
|
1019
|
-
function topologicalSort(graph) {
|
|
1020
|
-
const inDegree = new Map;
|
|
1021
|
-
for (const name of graph.keys()) {
|
|
1022
|
-
inDegree.set(name, 0);
|
|
989
|
+
const description = skill.meta.description;
|
|
990
|
+
if (typeof description !== "string" || description.trim().length === 0) {
|
|
991
|
+
errors.push('Missing required frontmatter field "description".');
|
|
1023
992
|
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
inDegree.set(dep, (inDegree.get(dep) ?? 0) + 1);
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
993
|
+
const allowedTools = skill.meta["allowed-tools"];
|
|
994
|
+
if (allowedTools !== undefined && (!Array.isArray(allowedTools) || allowedTools.some((tool) => typeof tool !== "string" || tool.length === 0))) {
|
|
995
|
+
errors.push('Invalid "allowed-tools": expected an array of non-empty strings.');
|
|
1030
996
|
}
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
997
|
+
return errors;
|
|
998
|
+
}
|
|
999
|
+
function skillMatchesTarget(skill, targetId) {
|
|
1000
|
+
const { targets } = skill.meta;
|
|
1001
|
+
if (!targets || targets === "*")
|
|
1002
|
+
return true;
|
|
1003
|
+
if (Array.isArray(targets) && targets.includes("*"))
|
|
1004
|
+
return true;
|
|
1005
|
+
return Array.isArray(targets) && targets.includes(targetId);
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
// src/core/pack-loader.ts
|
|
1009
|
+
import { existsSync as existsSync7 } from "fs";
|
|
1010
|
+
import { isAbsolute, resolve as resolve3 } from "path";
|
|
1011
|
+
class PackLoader {
|
|
1012
|
+
projectRoot;
|
|
1013
|
+
config;
|
|
1014
|
+
constructor(projectRoot, config) {
|
|
1015
|
+
this.projectRoot = projectRoot;
|
|
1016
|
+
this.config = config;
|
|
1035
1017
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
const
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
continue;
|
|
1045
|
-
for (const dep of node.dependencies) {
|
|
1046
|
-
if (!graph.has(dep))
|
|
1018
|
+
loadAll() {
|
|
1019
|
+
const warnings = [];
|
|
1020
|
+
const packs = [];
|
|
1021
|
+
const disabledSet = new Set(this.config.disabled);
|
|
1022
|
+
for (const packRef of this.config.packs) {
|
|
1023
|
+
const packDir = this.resolvePackPath(packRef);
|
|
1024
|
+
if (!packDir) {
|
|
1025
|
+
warnings.push(`Pack "${packRef}" could not be resolved. Skipping.`);
|
|
1047
1026
|
continue;
|
|
1048
|
-
const newDegree = (inDegree.get(dep) ?? 1) - 1;
|
|
1049
|
-
inDegree.set(dep, newDegree);
|
|
1050
|
-
if (newDegree === 0) {
|
|
1051
|
-
queue.push(dep);
|
|
1052
1027
|
}
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
if (!sorted.includes(name))
|
|
1060
|
-
remaining.add(name);
|
|
1061
|
-
}
|
|
1062
|
-
const visited = new Set;
|
|
1063
|
-
for (const start of remaining) {
|
|
1064
|
-
if (visited.has(start))
|
|
1028
|
+
if (!existsSync7(packDir)) {
|
|
1029
|
+
warnings.push(`Pack directory "${packDir}" does not exist. Skipping.`);
|
|
1030
|
+
continue;
|
|
1031
|
+
}
|
|
1032
|
+
const manifest = loadPackManifest(packDir);
|
|
1033
|
+
if (disabledSet.has(manifest.name) || disabledSet.has(packRef)) {
|
|
1065
1034
|
continue;
|
|
1066
|
-
const cycle = traceCycle(start, graph, remaining);
|
|
1067
|
-
if (cycle.length > 0) {
|
|
1068
|
-
cycles.push(cycle);
|
|
1069
|
-
for (const n of cycle)
|
|
1070
|
-
visited.add(n);
|
|
1071
1035
|
}
|
|
1036
|
+
const loaded = this.loadPack(packDir, manifest);
|
|
1037
|
+
packs.push(loaded);
|
|
1072
1038
|
}
|
|
1039
|
+
return { packs, warnings };
|
|
1073
1040
|
}
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1041
|
+
loadPack(packDir, manifest) {
|
|
1042
|
+
const name = manifest.name;
|
|
1043
|
+
const rulesDir = resolve3(packDir, "rules");
|
|
1044
|
+
const commandsDir = resolve3(packDir, "commands");
|
|
1045
|
+
const agentsDir = resolve3(packDir, "agents");
|
|
1046
|
+
const skillsDir = resolve3(packDir, "skills");
|
|
1047
|
+
return {
|
|
1048
|
+
manifest,
|
|
1049
|
+
directory: packDir,
|
|
1050
|
+
rules: existsSync7(rulesDir) ? parseRules(rulesDir, name) : [],
|
|
1051
|
+
commands: existsSync7(commandsDir) ? parseCommands(commandsDir, name) : [],
|
|
1052
|
+
agents: existsSync7(agentsDir) ? parseAgents(agentsDir, name) : [],
|
|
1053
|
+
skills: existsSync7(skillsDir) ? parseSkills(skillsDir, name) : [],
|
|
1054
|
+
hooks: parseHooks(packDir, name),
|
|
1055
|
+
plugins: parsePlugins(packDir, name),
|
|
1056
|
+
mcp: parseMcp(packDir, name),
|
|
1057
|
+
ignore: parseIgnore(packDir, name),
|
|
1058
|
+
models: parseModels(packDir, name)
|
|
1059
|
+
};
|
|
1087
1060
|
}
|
|
1088
|
-
|
|
1089
|
-
const
|
|
1090
|
-
|
|
1061
|
+
loadForBaseDir(baseDir) {
|
|
1062
|
+
const baseDirRoot = resolve3(this.projectRoot, baseDir);
|
|
1063
|
+
const localConfigPath = resolve3(baseDirRoot, "agentpacks.jsonc");
|
|
1064
|
+
if (!existsSync7(localConfigPath)) {
|
|
1065
|
+
return { packs: [], warnings: [] };
|
|
1066
|
+
}
|
|
1067
|
+
const localConfig = loadWorkspaceConfig(baseDirRoot);
|
|
1068
|
+
const loader = new PackLoader(baseDirRoot, localConfig);
|
|
1069
|
+
return loader.loadAll();
|
|
1091
1070
|
}
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1071
|
+
resolveCuratedPack(packRef) {
|
|
1072
|
+
const curatedDir = resolve3(this.projectRoot, ".agentpacks", ".curated");
|
|
1073
|
+
let packName = packRef;
|
|
1074
|
+
if (packName.startsWith("registry:"))
|
|
1075
|
+
packName = packName.slice(9);
|
|
1076
|
+
if (packName.startsWith("npm:"))
|
|
1077
|
+
packName = packName.slice(4);
|
|
1078
|
+
if (packName.startsWith("github:"))
|
|
1079
|
+
packName = packName.slice(7);
|
|
1080
|
+
if (packName.startsWith("@"))
|
|
1081
|
+
packName = packName.slice(1);
|
|
1082
|
+
if (packName.includes("/")) {
|
|
1083
|
+
const parts = packName.split("/");
|
|
1084
|
+
packName = packName.includes("@") ? parts.join("-") : parts[parts.length - 1] ?? packName;
|
|
1106
1085
|
}
|
|
1086
|
+
const withoutVersion = packName.split("@")[0] ?? packName;
|
|
1087
|
+
packName = withoutVersion.split(":")[0] ?? withoutVersion;
|
|
1088
|
+
const resolved = resolve3(curatedDir, packName);
|
|
1089
|
+
return existsSync7(resolved) ? resolved : null;
|
|
1090
|
+
}
|
|
1091
|
+
resolvePackPath(packRef) {
|
|
1092
|
+
if (packRef.startsWith("./") || packRef.startsWith("../")) {
|
|
1093
|
+
return resolve3(this.projectRoot, packRef);
|
|
1094
|
+
}
|
|
1095
|
+
if (isAbsolute(packRef)) {
|
|
1096
|
+
return packRef;
|
|
1097
|
+
}
|
|
1098
|
+
if (packRef.startsWith("registry:")) {
|
|
1099
|
+
return this.resolveCuratedPack(packRef);
|
|
1100
|
+
}
|
|
1101
|
+
if (packRef.startsWith("@") || packRef.startsWith("npm:") || !packRef.includes("/")) {
|
|
1102
|
+
return this.resolveCuratedPack(packRef);
|
|
1103
|
+
}
|
|
1104
|
+
if (packRef.startsWith("github:") || packRef.includes("/")) {
|
|
1105
|
+
return this.resolveCuratedPack(packRef);
|
|
1106
|
+
}
|
|
1107
|
+
return resolve3(this.projectRoot, packRef);
|
|
1107
1108
|
}
|
|
1108
|
-
return conflicts;
|
|
1109
1109
|
}
|
|
1110
1110
|
export {
|
|
1111
1111
|
setLockedSource,
|