agentpacks 1.7.13 → 1.8.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/api.js +48 -3658
- package/dist/cli/export-cmd.js +7 -1027
- package/dist/cli/generate.js +39 -2731
- package/dist/cli/import-cmd.js +19 -770
- package/dist/cli/info.js +4 -231
- package/dist/cli/init.js +9 -185
- package/dist/cli/install.js +4 -902
- package/dist/cli/login.js +6 -201
- package/dist/cli/models-explain.js +14 -1266
- package/dist/cli/pack/create.js +4 -146
- package/dist/cli/pack/enable.js +2 -65
- package/dist/cli/pack/list.js +5 -893
- package/dist/cli/pack/validate.js +4 -642
- package/dist/cli/publish.js +8 -679
- package/dist/cli/search.js +4 -209
- package/dist/core/config.d.ts +1 -1
- package/dist/core/config.js +1 -145
- package/dist/core/dependency-resolver.js +1 -126
- package/dist/core/feature-merger.js +3 -398
- package/dist/core/index.js +5 -1129
- package/dist/core/lockfile.js +2 -43
- package/dist/core/metarepo.js +1 -183
- package/dist/core/pack-loader.js +4 -841
- package/dist/core/profile-resolver.js +1 -110
- package/dist/exporters/cursor-plugin.js +6 -404
- package/dist/exporters/index.js +6 -404
- package/dist/features/agents.js +3 -161
- package/dist/features/commands.js +3 -161
- package/dist/features/hooks.js +3 -153
- package/dist/features/ignore.js +2 -43
- package/dist/features/index.js +4 -629
- package/dist/features/mcp.js +3 -143
- package/dist/features/models.js +3 -292
- package/dist/features/plugins.js +3 -139
- package/dist/features/rules.d.ts +0 -1
- package/dist/features/rules.js +3 -169
- package/dist/features/skills.js +3 -228
- package/dist/importers/claude-code.js +6 -195
- package/dist/importers/cursor.js +5 -355
- package/dist/importers/opencode.js +6 -346
- package/dist/importers/rulesync.js +5 -365
- package/dist/index.js +89 -4934
- package/dist/node/api.js +48 -3659
- package/dist/node/cli/export-cmd.js +7 -1028
- package/dist/node/cli/generate.js +39 -2732
- package/dist/node/cli/import-cmd.js +19 -771
- package/dist/node/cli/info.js +4 -232
- package/dist/node/cli/init.js +9 -186
- package/dist/node/cli/install.js +4 -903
- package/dist/node/cli/login.js +6 -202
- package/dist/node/cli/models-explain.js +14 -1267
- package/dist/node/cli/pack/create.js +4 -147
- package/dist/node/cli/pack/enable.js +2 -66
- package/dist/node/cli/pack/list.js +5 -894
- package/dist/node/cli/pack/validate.js +4 -643
- package/dist/node/cli/publish.js +8 -680
- package/dist/node/cli/search.js +4 -210
- package/dist/node/core/config.js +1 -146
- package/dist/node/core/dependency-resolver.js +1 -127
- package/dist/node/core/feature-merger.js +3 -399
- package/dist/node/core/index.js +5 -1130
- package/dist/node/core/lockfile.js +2 -44
- package/dist/node/core/metarepo.js +1 -184
- package/dist/node/core/pack-loader.js +4 -842
- package/dist/node/core/profile-resolver.js +1 -111
- package/dist/node/exporters/cursor-plugin.js +6 -405
- package/dist/node/exporters/index.js +6 -405
- package/dist/node/features/agents.js +3 -162
- package/dist/node/features/commands.js +3 -162
- package/dist/node/features/hooks.js +3 -154
- package/dist/node/features/ignore.js +2 -44
- package/dist/node/features/index.js +4 -630
- package/dist/node/features/mcp.js +3 -144
- package/dist/node/features/models.js +3 -293
- package/dist/node/features/plugins.js +3 -140
- package/dist/node/features/rules.js +3 -170
- package/dist/node/features/skills.js +3 -229
- package/dist/node/importers/claude-code.js +6 -196
- package/dist/node/importers/cursor.js +5 -356
- package/dist/node/importers/opencode.js +6 -347
- package/dist/node/importers/rulesync.js +5 -366
- package/dist/node/index.js +89 -4935
- package/dist/node/sources/git-ref.js +1 -56
- package/dist/node/sources/git.js +2 -222
- package/dist/node/sources/index.js +4 -714
- package/dist/node/sources/local.js +1 -24
- package/dist/node/sources/npm-ref.js +1 -56
- package/dist/node/sources/npm.js +2 -184
- package/dist/node/sources/registry-ref.js +1 -37
- package/dist/node/sources/registry.js +4 -355
- package/dist/node/targets/additional-targets.js +6 -587
- package/dist/node/targets/base-target.js +1 -23
- package/dist/node/targets/claude-code.js +6 -714
- package/dist/node/targets/codex-cli.js +3 -324
- package/dist/node/targets/copilot.js +5 -603
- package/dist/node/targets/cursor.js +6 -700
- package/dist/node/targets/gemini-cli.js +10 -319
- package/dist/node/targets/generic-md-target.js +6 -478
- package/dist/node/targets/index.js +32 -1873
- package/dist/node/targets/mistral-vibe.js +7 -661
- package/dist/node/targets/opencode.js +13 -723
- package/dist/node/targets/registry.js +32 -1864
- package/dist/node/utils/credentials.js +3 -38
- package/dist/node/utils/diff.js +5 -132
- package/dist/node/utils/filesystem.js +3 -124
- package/dist/node/utils/frontmatter.js +1 -24
- package/dist/node/utils/global.js +1 -53
- package/dist/node/utils/markdown.js +3 -30
- package/dist/node/utils/model-allowlist.js +1 -126
- package/dist/node/utils/model-guidance.js +2 -78
- package/dist/node/utils/registry-client.js +1 -142
- package/dist/node/utils/tarball.js +1 -49
- package/dist/sources/git-ref.js +1 -55
- package/dist/sources/git.js +2 -221
- package/dist/sources/index.js +4 -713
- package/dist/sources/local.js +1 -23
- package/dist/sources/npm-ref.js +1 -55
- package/dist/sources/npm.js +2 -183
- package/dist/sources/registry-ref.js +1 -36
- package/dist/sources/registry.js +4 -354
- package/dist/targets/additional-targets.js +6 -586
- package/dist/targets/base-target.js +1 -22
- package/dist/targets/claude-code.js +6 -713
- package/dist/targets/codex-cli.js +3 -323
- package/dist/targets/copilot.js +5 -602
- package/dist/targets/cursor.js +6 -699
- package/dist/targets/gemini-cli.js +10 -318
- package/dist/targets/generic-md-target.js +6 -477
- package/dist/targets/index.d.ts +0 -1
- package/dist/targets/index.js +32 -1872
- package/dist/targets/mistral-vibe.js +7 -660
- package/dist/targets/opencode.js +13 -722
- package/dist/targets/registry.js +32 -1863
- package/dist/utils/credentials.js +3 -37
- package/dist/utils/diff.js +5 -131
- package/dist/utils/filesystem.js +3 -123
- package/dist/utils/frontmatter.js +1 -23
- package/dist/utils/global.js +1 -52
- package/dist/utils/markdown.js +3 -29
- package/dist/utils/model-allowlist.js +1 -125
- package/dist/utils/model-guidance.js +2 -77
- package/dist/utils/registry-client.js +1 -141
- package/dist/utils/tarball.js +1 -48
- package/package.json +4 -16
- package/dist/node/targets/agents-md.js +0 -211
- package/dist/targets/agents-md.d.ts +0 -13
- package/dist/targets/agents-md.js +0 -211
package/dist/features/index.js
CHANGED
|
@@ -1,630 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
existsSync,
|
|
7
|
-
mkdirSync,
|
|
8
|
-
readdirSync,
|
|
9
|
-
readFileSync,
|
|
10
|
-
rmSync,
|
|
11
|
-
statSync,
|
|
12
|
-
writeFileSync
|
|
13
|
-
} from "fs";
|
|
14
|
-
import { dirname, join, relative } from "path";
|
|
15
|
-
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
16
|
-
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
17
|
-
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
18
|
-
function writeGeneratedFile(filepath, content, options = {}) {
|
|
19
|
-
const { header = true, type } = options;
|
|
20
|
-
const ext = type ?? inferFileType(filepath);
|
|
21
|
-
ensureDir(dirname(filepath));
|
|
22
|
-
let output = content;
|
|
23
|
-
if (header) {
|
|
24
|
-
const headerComment = getHeader(ext);
|
|
25
|
-
if (headerComment) {
|
|
26
|
-
output = `${headerComment}
|
|
27
|
-
${content}`;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
writeFileSync(filepath, output, "utf-8");
|
|
31
|
-
}
|
|
32
|
-
function writeGeneratedJson(filepath, data, options = {}) {
|
|
33
|
-
const json = JSON.stringify(data, null, 2);
|
|
34
|
-
writeGeneratedFile(filepath, json + `
|
|
35
|
-
`, { ...options, type: "json" });
|
|
36
|
-
}
|
|
37
|
-
function readFileOrNull(filepath) {
|
|
38
|
-
if (!existsSync(filepath))
|
|
39
|
-
return null;
|
|
40
|
-
return readFileSync(filepath, "utf-8");
|
|
41
|
-
}
|
|
42
|
-
function readJsonOrNull(filepath) {
|
|
43
|
-
const content = readFileOrNull(filepath);
|
|
44
|
-
if (content === null)
|
|
45
|
-
return null;
|
|
46
|
-
return JSON.parse(content);
|
|
47
|
-
}
|
|
48
|
-
function ensureDir(dirPath) {
|
|
49
|
-
if (!existsSync(dirPath)) {
|
|
50
|
-
mkdirSync(dirPath, { recursive: true });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function removeIfExists(targetPath) {
|
|
54
|
-
if (existsSync(targetPath)) {
|
|
55
|
-
rmSync(targetPath, { recursive: true, force: true });
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function listFiles(dirPath, options = {}) {
|
|
59
|
-
const { extension, recursive = false } = options;
|
|
60
|
-
if (!existsSync(dirPath))
|
|
61
|
-
return [];
|
|
62
|
-
const results = [];
|
|
63
|
-
const entries = readdirSync(dirPath);
|
|
64
|
-
for (const entry of entries) {
|
|
65
|
-
const fullPath = join(dirPath, entry);
|
|
66
|
-
const stat = statSync(fullPath);
|
|
67
|
-
if (stat.isDirectory() && recursive) {
|
|
68
|
-
results.push(...listFiles(fullPath, options));
|
|
69
|
-
} else if (stat.isFile()) {
|
|
70
|
-
if (!extension || entry.endsWith(extension)) {
|
|
71
|
-
results.push(fullPath);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return results;
|
|
76
|
-
}
|
|
77
|
-
function listDirs(dirPath) {
|
|
78
|
-
if (!existsSync(dirPath))
|
|
79
|
-
return [];
|
|
80
|
-
return readdirSync(dirPath).map((entry) => join(dirPath, entry)).filter((fullPath) => statSync(fullPath).isDirectory());
|
|
81
|
-
}
|
|
82
|
-
function relPath(projectRoot, filepath) {
|
|
83
|
-
return relative(projectRoot, filepath);
|
|
84
|
-
}
|
|
85
|
-
function isGeneratedFile(filepath) {
|
|
86
|
-
const content = readFileOrNull(filepath);
|
|
87
|
-
if (!content)
|
|
88
|
-
return false;
|
|
89
|
-
return content.startsWith(GENERATED_HEADER_MD) || content.startsWith(GENERATED_HEADER_JSON) || content.startsWith(GENERATED_HEADER_JS);
|
|
90
|
-
}
|
|
91
|
-
function inferFileType(filepath) {
|
|
92
|
-
if (filepath.endsWith(".json") || filepath.endsWith(".jsonc"))
|
|
93
|
-
return "json";
|
|
94
|
-
if (filepath.endsWith(".ts") || filepath.endsWith(".mts"))
|
|
95
|
-
return "ts";
|
|
96
|
-
if (filepath.endsWith(".js") || filepath.endsWith(".mjs"))
|
|
97
|
-
return "js";
|
|
98
|
-
return "md";
|
|
99
|
-
}
|
|
100
|
-
function getHeader(type) {
|
|
101
|
-
switch (type) {
|
|
102
|
-
case "md":
|
|
103
|
-
return GENERATED_HEADER_MD;
|
|
104
|
-
case "json":
|
|
105
|
-
return GENERATED_HEADER_JSON;
|
|
106
|
-
case "js":
|
|
107
|
-
case "ts":
|
|
108
|
-
return GENERATED_HEADER_JS;
|
|
109
|
-
default:
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// src/features/models.ts
|
|
115
|
-
import { join as join2 } from "path";
|
|
116
|
-
import { z } from "zod";
|
|
117
|
-
var SECRET_PATTERNS = [
|
|
118
|
-
/["']api[_-]?key["']\s*:/i,
|
|
119
|
-
/["']apiKey["']\s*:/i,
|
|
120
|
-
/["']secret["']\s*:/i,
|
|
121
|
-
/["']password["']\s*:/i,
|
|
122
|
-
/["'](?:auth_token|access_token|bearer_token)["']\s*:/i,
|
|
123
|
-
/["']private[_-]?key["']\s*:/i,
|
|
124
|
-
/-----BEGIN\s+(RSA|EC|DSA|OPENSSH|PGP)\s+PRIVATE\s+KEY-----/,
|
|
125
|
-
/sk-[a-zA-Z0-9]{20,}/,
|
|
126
|
-
/Bearer\s+[a-zA-Z0-9._-]{20,}/
|
|
127
|
-
];
|
|
128
|
-
var AgentModelSchema = z.object({
|
|
129
|
-
model: z.string(),
|
|
130
|
-
temperature: z.number().min(0).max(2).optional(),
|
|
131
|
-
top_p: z.number().min(0).max(1).optional()
|
|
132
|
-
});
|
|
133
|
-
var ModelProfileSchema = z.object({
|
|
134
|
-
extends: z.string().optional(),
|
|
135
|
-
description: z.string().optional(),
|
|
136
|
-
default: z.string().optional(),
|
|
137
|
-
small: z.string().optional(),
|
|
138
|
-
agents: z.record(z.string(), AgentModelSchema).optional()
|
|
139
|
-
});
|
|
140
|
-
var RoutingConditionSchema = z.object({
|
|
141
|
-
complexity: z.enum(["low", "medium", "high", "critical"]).optional().describe("Task complexity level"),
|
|
142
|
-
urgency: z.enum(["low", "normal", "high"]).optional().describe("Time sensitivity"),
|
|
143
|
-
budget: z.enum(["minimal", "standard", "premium"]).optional().describe("Cost/token budget tier"),
|
|
144
|
-
contextWindowNeed: z.enum(["small", "medium", "large", "max"]).optional().describe("Required context window size"),
|
|
145
|
-
toolUseIntensity: z.enum(["none", "light", "heavy"]).optional().describe("Expected tool/function calling intensity")
|
|
146
|
-
});
|
|
147
|
-
var RoutingRuleSchema = z.object({
|
|
148
|
-
when: z.record(z.string(), z.string()),
|
|
149
|
-
use: z.string(),
|
|
150
|
-
description: z.string().optional(),
|
|
151
|
-
priority: z.number().optional()
|
|
152
|
-
});
|
|
153
|
-
var ProviderModelSchema = z.object({
|
|
154
|
-
options: z.record(z.string(), z.unknown()).optional(),
|
|
155
|
-
variants: z.record(z.string(), z.record(z.string(), z.unknown())).optional()
|
|
156
|
-
});
|
|
157
|
-
var ProviderConfigSchema = z.object({
|
|
158
|
-
options: z.record(z.string(), z.unknown()).optional(),
|
|
159
|
-
models: z.record(z.string(), ProviderModelSchema).optional()
|
|
160
|
-
});
|
|
161
|
-
var ModelsSchema = z.object({
|
|
162
|
-
default: z.string().optional(),
|
|
163
|
-
small: z.string().optional(),
|
|
164
|
-
agents: z.record(z.string(), AgentModelSchema).optional(),
|
|
165
|
-
profiles: z.record(z.string(), ModelProfileSchema).optional(),
|
|
166
|
-
providers: z.record(z.string(), ProviderConfigSchema).optional(),
|
|
167
|
-
routing: z.array(RoutingRuleSchema).optional(),
|
|
168
|
-
overrides: z.record(z.string(), z.object({
|
|
169
|
-
default: z.string().optional(),
|
|
170
|
-
small: z.string().optional(),
|
|
171
|
-
agents: z.record(z.string(), AgentModelSchema).optional()
|
|
172
|
-
})).optional()
|
|
173
|
-
});
|
|
174
|
-
function parseModels(packDir, packName) {
|
|
175
|
-
const modelsPath = join2(packDir, "models.json");
|
|
176
|
-
const raw = readJsonOrNull(modelsPath);
|
|
177
|
-
if (!raw)
|
|
178
|
-
return null;
|
|
179
|
-
const parsed = ModelsSchema.parse(raw);
|
|
180
|
-
return {
|
|
181
|
-
packName,
|
|
182
|
-
sourcePath: modelsPath,
|
|
183
|
-
config: parsed
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
function mergeModelsConfigs(configs) {
|
|
187
|
-
const warnings = [];
|
|
188
|
-
const result = {};
|
|
189
|
-
for (const entry of configs) {
|
|
190
|
-
const { config, packName } = entry;
|
|
191
|
-
if (config.default !== undefined && result.default === undefined) {
|
|
192
|
-
result.default = config.default;
|
|
193
|
-
} else if (config.default !== undefined && result.default !== undefined) {
|
|
194
|
-
warnings.push(`Models "default" from pack "${packName}" skipped (already defined).`);
|
|
195
|
-
}
|
|
196
|
-
if (config.small !== undefined && result.small === undefined) {
|
|
197
|
-
result.small = config.small;
|
|
198
|
-
} else if (config.small !== undefined && result.small !== undefined) {
|
|
199
|
-
warnings.push(`Models "small" from pack "${packName}" skipped (already defined).`);
|
|
200
|
-
}
|
|
201
|
-
if (config.agents) {
|
|
202
|
-
if (!result.agents)
|
|
203
|
-
result.agents = {};
|
|
204
|
-
for (const [name, assignment] of Object.entries(config.agents)) {
|
|
205
|
-
if (name in result.agents) {
|
|
206
|
-
warnings.push(`Models agent "${name}" from pack "${packName}" skipped (already defined).`);
|
|
207
|
-
continue;
|
|
208
|
-
}
|
|
209
|
-
result.agents[name] = assignment;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
if (config.profiles) {
|
|
213
|
-
if (!result.profiles)
|
|
214
|
-
result.profiles = {};
|
|
215
|
-
for (const [name, profile] of Object.entries(config.profiles)) {
|
|
216
|
-
if (name in result.profiles) {
|
|
217
|
-
warnings.push(`Models profile "${name}" from pack "${packName}" skipped (already defined).`);
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
result.profiles[name] = profile;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
if (config.providers) {
|
|
224
|
-
if (!result.providers)
|
|
225
|
-
result.providers = {};
|
|
226
|
-
for (const [providerName, providerConfig] of Object.entries(config.providers)) {
|
|
227
|
-
if (!(providerName in result.providers)) {
|
|
228
|
-
result.providers[providerName] = providerConfig;
|
|
229
|
-
} else {
|
|
230
|
-
const existing = result.providers[providerName];
|
|
231
|
-
if (!existing) {
|
|
232
|
-
result.providers[providerName] = providerConfig;
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
if (providerConfig.options) {
|
|
236
|
-
existing.options = {
|
|
237
|
-
...providerConfig.options,
|
|
238
|
-
...existing.options
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
if (providerConfig.models) {
|
|
242
|
-
if (!existing.models)
|
|
243
|
-
existing.models = {};
|
|
244
|
-
for (const [modelName, modelConfig] of Object.entries(providerConfig.models)) {
|
|
245
|
-
if (!(modelName in existing.models)) {
|
|
246
|
-
existing.models[modelName] = modelConfig;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
if (config.routing) {
|
|
254
|
-
if (!result.routing)
|
|
255
|
-
result.routing = [];
|
|
256
|
-
result.routing.push(...config.routing);
|
|
257
|
-
}
|
|
258
|
-
if (config.overrides) {
|
|
259
|
-
if (!result.overrides)
|
|
260
|
-
result.overrides = {};
|
|
261
|
-
for (const [targetId, override] of Object.entries(config.overrides)) {
|
|
262
|
-
if (targetId in result.overrides) {
|
|
263
|
-
warnings.push(`Models override for target "${targetId}" from pack "${packName}" skipped (already defined).`);
|
|
264
|
-
continue;
|
|
265
|
-
}
|
|
266
|
-
result.overrides[targetId] = override;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
return { config: result, warnings };
|
|
271
|
-
}
|
|
272
|
-
function scanModelsForSecrets(config) {
|
|
273
|
-
const warnings = [];
|
|
274
|
-
const json = JSON.stringify(config);
|
|
275
|
-
for (const pattern of SECRET_PATTERNS) {
|
|
276
|
-
if (pattern.test(json)) {
|
|
277
|
-
warnings.push(`Potential secret detected in models.json matching pattern: ${pattern.source}`);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
return warnings;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// src/utils/frontmatter.ts
|
|
284
|
-
import matter from "gray-matter";
|
|
285
|
-
function parseFrontmatter(source) {
|
|
286
|
-
const { data, content } = matter(source);
|
|
287
|
-
return {
|
|
288
|
-
data,
|
|
289
|
-
content: content.trim(),
|
|
290
|
-
raw: source
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
function serializeFrontmatter(data, content) {
|
|
294
|
-
const filtered = Object.fromEntries(Object.entries(data).filter(([, v]) => v !== undefined));
|
|
295
|
-
if (Object.keys(filtered).length === 0) {
|
|
296
|
-
return content;
|
|
297
|
-
}
|
|
298
|
-
return matter.stringify(content, filtered);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// src/features/agents.ts
|
|
302
|
-
import { readFileSync as readFileSync2 } from "fs";
|
|
303
|
-
import { basename } from "path";
|
|
304
|
-
function parseAgents(agentsDir, packName) {
|
|
305
|
-
const files = listFiles(agentsDir, { extension: ".md" });
|
|
306
|
-
return files.map((filepath) => parseAgentFile(filepath, packName));
|
|
307
|
-
}
|
|
308
|
-
function parseAgentFile(filepath, packName) {
|
|
309
|
-
const raw = readFileSync2(filepath, "utf-8");
|
|
310
|
-
const { data, content } = parseFrontmatter(raw);
|
|
311
|
-
return {
|
|
312
|
-
name: data.name ?? basename(filepath, ".md"),
|
|
313
|
-
sourcePath: filepath,
|
|
314
|
-
packName,
|
|
315
|
-
meta: data,
|
|
316
|
-
content
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
function agentMatchesTarget(agent, targetId) {
|
|
320
|
-
const { targets } = agent.meta;
|
|
321
|
-
if (!targets || targets === "*")
|
|
322
|
-
return true;
|
|
323
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
324
|
-
return true;
|
|
325
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// src/features/commands.ts
|
|
329
|
-
import { readFileSync as readFileSync3 } from "fs";
|
|
330
|
-
import { basename as basename2 } from "path";
|
|
331
|
-
function parseCommands(commandsDir, packName) {
|
|
332
|
-
const files = listFiles(commandsDir, { extension: ".md" });
|
|
333
|
-
return files.map((filepath) => parseCommandFile(filepath, packName));
|
|
334
|
-
}
|
|
335
|
-
function parseCommandFile(filepath, packName) {
|
|
336
|
-
const raw = readFileSync3(filepath, "utf-8");
|
|
337
|
-
const { data, content } = parseFrontmatter(raw);
|
|
338
|
-
return {
|
|
339
|
-
name: basename2(filepath, ".md"),
|
|
340
|
-
sourcePath: filepath,
|
|
341
|
-
packName,
|
|
342
|
-
meta: data,
|
|
343
|
-
content
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
function commandMatchesTarget(cmd, targetId) {
|
|
347
|
-
const { targets } = cmd.meta;
|
|
348
|
-
if (!targets || targets === "*")
|
|
349
|
-
return true;
|
|
350
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
351
|
-
return true;
|
|
352
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// src/features/hooks.ts
|
|
356
|
-
import { join as join3 } from "path";
|
|
357
|
-
var TARGET_OVERRIDE_KEYS = ["cursor", "claudecode", "opencode"];
|
|
358
|
-
function parseHooks(packDir, packName) {
|
|
359
|
-
const hooksPath = join3(packDir, "hooks", "hooks.json");
|
|
360
|
-
const raw = readJsonOrNull(hooksPath);
|
|
361
|
-
if (!raw)
|
|
362
|
-
return null;
|
|
363
|
-
const shared = raw.hooks ?? {};
|
|
364
|
-
const targetOverrides = {};
|
|
365
|
-
for (const key of TARGET_OVERRIDE_KEYS) {
|
|
366
|
-
const override = raw[key];
|
|
367
|
-
if (override && typeof override === "object" && "hooks" in override && override.hooks) {
|
|
368
|
-
targetOverrides[key] = override.hooks;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
return {
|
|
372
|
-
packName,
|
|
373
|
-
sourcePath: hooksPath,
|
|
374
|
-
version: raw.version,
|
|
375
|
-
shared,
|
|
376
|
-
targetOverrides
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
function resolveHooksForTarget(hooks, targetId) {
|
|
380
|
-
const merged = {};
|
|
381
|
-
for (const [event, entries] of Object.entries(hooks.shared)) {
|
|
382
|
-
merged[event] = [...entries];
|
|
383
|
-
}
|
|
384
|
-
const overrides = hooks.targetOverrides[targetId];
|
|
385
|
-
if (overrides) {
|
|
386
|
-
for (const [event, entries] of Object.entries(overrides)) {
|
|
387
|
-
merged[event] = [...merged[event] ?? [], ...entries];
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
return merged;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// src/features/ignore.ts
|
|
394
|
-
import { existsSync as existsSync2, readFileSync as readFileSync4 } from "fs";
|
|
395
|
-
import { join as join4 } from "path";
|
|
396
|
-
var IGNORE_FILES = ["ignore", ".aiignore"];
|
|
397
|
-
function parseIgnore(packDir, packName) {
|
|
398
|
-
for (const filename of IGNORE_FILES) {
|
|
399
|
-
const filepath = join4(packDir, filename);
|
|
400
|
-
if (existsSync2(filepath)) {
|
|
401
|
-
const raw = readFileSync4(filepath, "utf-8");
|
|
402
|
-
const patterns = parseIgnoreContent(raw);
|
|
403
|
-
return {
|
|
404
|
-
packName,
|
|
405
|
-
sourcePath: filepath,
|
|
406
|
-
patterns
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
return null;
|
|
411
|
-
}
|
|
412
|
-
function parseIgnoreContent(content) {
|
|
413
|
-
return content.split(`
|
|
414
|
-
`).map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#"));
|
|
415
|
-
}
|
|
416
|
-
function mergeIgnorePatterns(configs) {
|
|
417
|
-
const seen = new Set;
|
|
418
|
-
const result = [];
|
|
419
|
-
for (const config of configs) {
|
|
420
|
-
for (const pattern of config.patterns) {
|
|
421
|
-
if (!seen.has(pattern)) {
|
|
422
|
-
seen.add(pattern);
|
|
423
|
-
result.push(pattern);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
return result;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
// src/features/mcp.ts
|
|
431
|
-
import { join as join5 } from "path";
|
|
432
|
-
function parseMcp(packDir, packName) {
|
|
433
|
-
const mcpPath = join5(packDir, "mcp.json");
|
|
434
|
-
const raw = readJsonOrNull(mcpPath);
|
|
435
|
-
if (!raw?.mcpServers)
|
|
436
|
-
return null;
|
|
437
|
-
return {
|
|
438
|
-
packName,
|
|
439
|
-
sourcePath: mcpPath,
|
|
440
|
-
servers: raw.mcpServers
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
function mergeMcpConfigs(configs) {
|
|
444
|
-
const servers = {};
|
|
445
|
-
const warnings = [];
|
|
446
|
-
for (const config of configs) {
|
|
447
|
-
for (const [name, entry] of Object.entries(config.servers)) {
|
|
448
|
-
if (name in servers) {
|
|
449
|
-
warnings.push(`MCP server "${name}" from pack "${config.packName}" skipped (already defined).`);
|
|
450
|
-
continue;
|
|
451
|
-
}
|
|
452
|
-
servers[name] = entry;
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
return { servers, warnings };
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
// src/features/plugins.ts
|
|
459
|
-
import { existsSync as existsSync3, readFileSync as readFileSync5 } from "fs";
|
|
460
|
-
import { basename as basename3, join as join6 } from "path";
|
|
461
|
-
function parsePlugins(packDir, packName) {
|
|
462
|
-
const pluginsDir = join6(packDir, "plugins");
|
|
463
|
-
if (!existsSync3(pluginsDir))
|
|
464
|
-
return [];
|
|
465
|
-
const tsFiles = listFiles(pluginsDir, { extension: ".ts" });
|
|
466
|
-
const jsFiles = listFiles(pluginsDir, { extension: ".js" });
|
|
467
|
-
const allFiles = [...tsFiles, ...jsFiles];
|
|
468
|
-
return allFiles.map((filepath) => parsePluginFile(filepath, packName));
|
|
469
|
-
}
|
|
470
|
-
function parsePluginFile(filepath, packName) {
|
|
471
|
-
const content = readFileSync5(filepath, "utf-8");
|
|
472
|
-
const ext = filepath.endsWith(".ts") ? "ts" : "js";
|
|
473
|
-
return {
|
|
474
|
-
name: basename3(filepath, `.${ext}`),
|
|
475
|
-
sourcePath: filepath,
|
|
476
|
-
packName,
|
|
477
|
-
content,
|
|
478
|
-
extension: ext
|
|
479
|
-
};
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
// src/features/rules.ts
|
|
483
|
-
import { readFileSync as readFileSync6 } from "fs";
|
|
484
|
-
import { basename as basename4 } from "path";
|
|
485
|
-
function parseRules(rulesDir, packName) {
|
|
486
|
-
const files = listFiles(rulesDir, { extension: ".md" });
|
|
487
|
-
return files.map((filepath) => parseRuleFile(filepath, packName));
|
|
488
|
-
}
|
|
489
|
-
function parseRuleFile(filepath, packName) {
|
|
490
|
-
const raw = readFileSync6(filepath, "utf-8");
|
|
491
|
-
const { data, content } = parseFrontmatter(raw);
|
|
492
|
-
return {
|
|
493
|
-
name: basename4(filepath, ".md"),
|
|
494
|
-
sourcePath: filepath,
|
|
495
|
-
packName,
|
|
496
|
-
meta: data,
|
|
497
|
-
content
|
|
498
|
-
};
|
|
499
|
-
}
|
|
500
|
-
function ruleMatchesTarget(rule, targetId) {
|
|
501
|
-
const { targets } = rule.meta;
|
|
502
|
-
if (!targets || targets === "*")
|
|
503
|
-
return true;
|
|
504
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
505
|
-
return true;
|
|
506
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
507
|
-
}
|
|
508
|
-
function getRootRules(rules) {
|
|
509
|
-
return rules.filter((r) => r.meta.root === true);
|
|
510
|
-
}
|
|
511
|
-
function getDetailRules(rules) {
|
|
512
|
-
return rules.filter((r) => r.meta.root !== true);
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
// src/features/skills.ts
|
|
516
|
-
import { existsSync as existsSync4, readFileSync as readFileSync7 } from "fs";
|
|
517
|
-
import { basename as basename5, join as join7 } from "path";
|
|
518
|
-
var SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
519
|
-
var SKILL_NAME_MAX_LENGTH = 64;
|
|
520
|
-
function parseSkills(skillsDir, packName) {
|
|
521
|
-
const dirs = listDirs(skillsDir);
|
|
522
|
-
const skills = [];
|
|
523
|
-
for (const dir of dirs) {
|
|
524
|
-
const skillMd = join7(dir, "SKILL.md");
|
|
525
|
-
if (existsSync4(skillMd)) {
|
|
526
|
-
skills.push(parseSkillFile(skillMd, dir, packName));
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
return skills;
|
|
530
|
-
}
|
|
531
|
-
function parseSkillFile(filepath, skillDir, packName) {
|
|
532
|
-
const raw = readFileSync7(filepath, "utf-8");
|
|
533
|
-
const { data, content } = parseFrontmatter(raw);
|
|
534
|
-
return {
|
|
535
|
-
name: data.name ?? basename5(skillDir),
|
|
536
|
-
sourcePath: filepath,
|
|
537
|
-
sourceDir: skillDir,
|
|
538
|
-
packName,
|
|
539
|
-
meta: data,
|
|
540
|
-
content
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
function buildSkillFrontmatter(skill) {
|
|
544
|
-
return {
|
|
545
|
-
...skill.meta,
|
|
546
|
-
name: skill.name
|
|
547
|
-
};
|
|
548
|
-
}
|
|
549
|
-
function serializeSkill(skill) {
|
|
550
|
-
return serializeFrontmatter(buildSkillFrontmatter(skill), skill.content);
|
|
551
|
-
}
|
|
552
|
-
function normalizeImportedSkillMarkdown(source, skillName) {
|
|
553
|
-
const { data, content } = parseFrontmatter(source);
|
|
554
|
-
const normalized = {
|
|
555
|
-
...data,
|
|
556
|
-
name: skillName
|
|
557
|
-
};
|
|
558
|
-
let addedDescription = false;
|
|
559
|
-
const description = normalized.description;
|
|
560
|
-
if (typeof description !== "string" || description.trim().length === 0) {
|
|
561
|
-
normalized.description = `Imported skill: ${skillName}`;
|
|
562
|
-
addedDescription = true;
|
|
563
|
-
}
|
|
564
|
-
return {
|
|
565
|
-
content: serializeFrontmatter(normalized, content),
|
|
566
|
-
addedDescription
|
|
567
|
-
};
|
|
568
|
-
}
|
|
569
|
-
function validateAgentSkillsFrontmatter(skill) {
|
|
570
|
-
const errors = [];
|
|
571
|
-
const dirName = basename5(skill.sourceDir);
|
|
572
|
-
const declaredName = skill.meta.name;
|
|
573
|
-
if (typeof declaredName !== "string" || declaredName.trim().length === 0) {
|
|
574
|
-
errors.push('Missing required frontmatter field "name".');
|
|
575
|
-
} else {
|
|
576
|
-
if (declaredName.length > SKILL_NAME_MAX_LENGTH) {
|
|
577
|
-
errors.push(`Invalid "name": must be at most ${SKILL_NAME_MAX_LENGTH} characters.`);
|
|
578
|
-
}
|
|
579
|
-
if (!SKILL_NAME_PATTERN.test(declaredName)) {
|
|
580
|
-
errors.push('Invalid "name": use lowercase letters, numbers, and single hyphens only.');
|
|
581
|
-
}
|
|
582
|
-
if (declaredName !== dirName) {
|
|
583
|
-
errors.push(`Invalid "name": must match containing directory "${dirName}".`);
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
const description = skill.meta.description;
|
|
587
|
-
if (typeof description !== "string" || description.trim().length === 0) {
|
|
588
|
-
errors.push('Missing required frontmatter field "description".');
|
|
589
|
-
}
|
|
590
|
-
const allowedTools = skill.meta["allowed-tools"];
|
|
591
|
-
if (allowedTools !== undefined && (!Array.isArray(allowedTools) || allowedTools.some((tool) => typeof tool !== "string" || tool.length === 0))) {
|
|
592
|
-
errors.push('Invalid "allowed-tools": expected an array of non-empty strings.');
|
|
593
|
-
}
|
|
594
|
-
return errors;
|
|
595
|
-
}
|
|
596
|
-
function skillMatchesTarget(skill, targetId) {
|
|
597
|
-
const { targets } = skill.meta;
|
|
598
|
-
if (!targets || targets === "*")
|
|
599
|
-
return true;
|
|
600
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
601
|
-
return true;
|
|
602
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
603
|
-
}
|
|
604
|
-
export {
|
|
605
|
-
validateAgentSkillsFrontmatter,
|
|
606
|
-
skillMatchesTarget,
|
|
607
|
-
serializeSkill,
|
|
608
|
-
scanModelsForSecrets,
|
|
609
|
-
ruleMatchesTarget,
|
|
610
|
-
resolveHooksForTarget,
|
|
611
|
-
parseSkills,
|
|
612
|
-
parseRules,
|
|
613
|
-
parsePlugins,
|
|
614
|
-
parseModels,
|
|
615
|
-
parseMcp,
|
|
616
|
-
parseIgnore,
|
|
617
|
-
parseHooks,
|
|
618
|
-
parseCommands,
|
|
619
|
-
parseAgents,
|
|
620
|
-
normalizeImportedSkillMarkdown,
|
|
621
|
-
mergeModelsConfigs,
|
|
622
|
-
mergeMcpConfigs,
|
|
623
|
-
mergeIgnorePatterns,
|
|
624
|
-
getRootRules,
|
|
625
|
-
getDetailRules,
|
|
626
|
-
commandMatchesTarget,
|
|
627
|
-
buildSkillFrontmatter,
|
|
628
|
-
agentMatchesTarget,
|
|
629
|
-
ModelsSchema
|
|
630
|
-
};
|
|
2
|
+
var pq=import.meta.require;import{existsSync as J,mkdirSync as S,readdirSync as C,readFileSync as E,rmSync as D,statSync as G,writeFileSync as z}from"fs";import{dirname as N,join as O,relative as u}from"path";var T="<!-- Generated by agentpacks. DO NOT EDIT. -->",I="// Generated by agentpacks. DO NOT EDIT.",R="// Generated by agentpacks. DO NOT EDIT.";function k(q,Q,B={}){let{header:U=!0,type:W}=B,$=W??m(q);g(N(q));let V=Q;if(U){let Y=h($);if(Y)V=`${Y}
|
|
3
|
+
${Q}`}z(q,V,"utf-8")}function sq(q,Q,B={}){let U=JSON.stringify(Q,null,2);k(q,U+`
|
|
4
|
+
`,{...B,type:"json"})}function A(q){if(!J(q))return null;return E(q,"utf-8")}function K(q){let Q=A(q);if(Q===null)return null;return JSON.parse(Q)}function g(q){if(!J(q))S(q,{recursive:!0})}function lq(q){if(J(q))D(q,{recursive:!0,force:!0})}function X(q,Q={}){let{extension:B,recursive:U=!1}=Q;if(!J(q))return[];let W=[],$=C(q);for(let V of $){let Y=O(q,V),M=G(Y);if(M.isDirectory()&&U)W.push(...X(Y,Q));else if(M.isFile()){if(!B||V.endsWith(B))W.push(Y)}}return W}function y(q){if(!J(q))return[];return C(q).map((Q)=>O(q,Q)).filter((Q)=>G(Q).isDirectory())}function rq(q,Q){return u(q,Q)}function iq(q){let Q=A(q);if(!Q)return!1;return Q.startsWith(T)||Q.startsWith(I)||Q.startsWith(R)}function m(q){if(q.endsWith(".json")||q.endsWith(".jsonc"))return"json";if(q.endsWith(".ts")||q.endsWith(".mts"))return"ts";if(q.endsWith(".js")||q.endsWith(".mjs"))return"js";return"md"}function h(q){switch(q){case"md":return T;case"json":return I;case"js":case"ts":return R;default:return null}}import{join as d}from"path";import{z as Z}from"zod";var f=[/["']api[_-]?key["']\s*:/i,/["']apiKey["']\s*:/i,/["']secret["']\s*:/i,/["']password["']\s*:/i,/["'](?:auth_token|access_token|bearer_token)["']\s*:/i,/["']private[_-]?key["']\s*:/i,/-----BEGIN\s+(RSA|EC|DSA|OPENSSH|PGP)\s+PRIVATE\s+KEY-----/,/sk-[a-zA-Z0-9]{20,}/,/Bearer\s+[a-zA-Z0-9._-]{20,}/],b=Z.object({model:Z.string(),temperature:Z.number().min(0).max(2).optional(),top_p:Z.number().min(0).max(1).optional()}),p=Z.object({extends:Z.string().optional(),description:Z.string().optional(),default:Z.string().optional(),small:Z.string().optional(),agents:Z.record(Z.string(),b).optional()}),BB=Z.object({complexity:Z.enum(["low","medium","high","critical"]).optional().describe("Task complexity level"),urgency:Z.enum(["low","normal","high"]).optional().describe("Time sensitivity"),budget:Z.enum(["minimal","standard","premium"]).optional().describe("Cost/token budget tier"),contextWindowNeed:Z.enum(["small","medium","large","max"]).optional().describe("Required context window size"),toolUseIntensity:Z.enum(["none","light","heavy"]).optional().describe("Expected tool/function calling intensity")}),c=Z.object({when:Z.record(Z.string(),Z.string()),use:Z.string(),description:Z.string().optional(),priority:Z.number().optional()}),o=Z.object({options:Z.record(Z.string(),Z.unknown()).optional(),variants:Z.record(Z.string(),Z.record(Z.string(),Z.unknown())).optional()}),n=Z.object({options:Z.record(Z.string(),Z.unknown()).optional(),models:Z.record(Z.string(),o).optional()}),_=Z.object({default:Z.string().optional(),small:Z.string().optional(),agents:Z.record(Z.string(),b).optional(),profiles:Z.record(Z.string(),p).optional(),providers:Z.record(Z.string(),n).optional(),routing:Z.array(c).optional(),overrides:Z.record(Z.string(),Z.object({default:Z.string().optional(),small:Z.string().optional(),agents:Z.record(Z.string(),b).optional()})).optional()});function s(q,Q){let B=d(q,"models.json"),U=K(B);if(!U)return null;let W=_.parse(U);return{packName:Q,sourcePath:B,config:W}}function l(q){let Q=[],B={};for(let U of q){let{config:W,packName:$}=U;if(W.default!==void 0&&B.default===void 0)B.default=W.default;else if(W.default!==void 0&&B.default!==void 0)Q.push(`Models "default" from pack "${$}" skipped (already defined).`);if(W.small!==void 0&&B.small===void 0)B.small=W.small;else if(W.small!==void 0&&B.small!==void 0)Q.push(`Models "small" from pack "${$}" skipped (already defined).`);if(W.agents){if(!B.agents)B.agents={};for(let[V,Y]of Object.entries(W.agents)){if(V in B.agents){Q.push(`Models agent "${V}" from pack "${$}" skipped (already defined).`);continue}B.agents[V]=Y}}if(W.profiles){if(!B.profiles)B.profiles={};for(let[V,Y]of Object.entries(W.profiles)){if(V in B.profiles){Q.push(`Models profile "${V}" from pack "${$}" skipped (already defined).`);continue}B.profiles[V]=Y}}if(W.providers){if(!B.providers)B.providers={};for(let[V,Y]of Object.entries(W.providers))if(!(V in B.providers))B.providers[V]=Y;else{let M=B.providers[V];if(!M){B.providers[V]=Y;continue}if(Y.options)M.options={...Y.options,...M.options};if(Y.models){if(!M.models)M.models={};for(let[x,v]of Object.entries(Y.models))if(!(x in M.models))M.models[x]=v}}}if(W.routing){if(!B.routing)B.routing=[];B.routing.push(...W.routing)}if(W.overrides){if(!B.overrides)B.overrides={};for(let[V,Y]of Object.entries(W.overrides)){if(V in B.overrides){Q.push(`Models override for target "${V}" from pack "${$}" skipped (already defined).`);continue}B.overrides[V]=Y}}}return{config:B,warnings:Q}}function r(q){let Q=[],B=JSON.stringify(q);for(let U of f)if(U.test(B))Q.push(`Potential secret detected in models.json matching pattern: ${U.source}`);return Q}import j from"gray-matter";function H(q){let{data:Q,content:B}=j(q);return{data:Q,content:B.trim(),raw:q}}function L(q,Q){let B=Object.fromEntries(Object.entries(q).filter(([,U])=>U!==void 0));if(Object.keys(B).length===0)return Q;return j.stringify(Q,B)}import{readFileSync as i}from"fs";import{basename as a}from"path";function t(q,Q){return X(q,{extension:".md"}).map((U)=>e(U,Q))}function e(q,Q){let B=i(q,"utf-8"),{data:U,content:W}=H(B);return{name:U.name??a(q,".md"),sourcePath:q,packName:Q,meta:U,content:W}}function qq(q,Q){let{targets:B}=q.meta;if(!B||B==="*")return!0;if(Array.isArray(B)&&B.includes("*"))return!0;return Array.isArray(B)&&B.includes(Q)}import{readFileSync as Bq}from"fs";import{basename as Qq}from"path";function Uq(q,Q){return X(q,{extension:".md"}).map((U)=>Wq(U,Q))}function Wq(q,Q){let B=Bq(q,"utf-8"),{data:U,content:W}=H(B);return{name:Qq(q,".md"),sourcePath:q,packName:Q,meta:U,content:W}}function Zq(q,Q){let{targets:B}=q.meta;if(!B||B==="*")return!0;if(Array.isArray(B)&&B.includes("*"))return!0;return Array.isArray(B)&&B.includes(Q)}import{join as $q}from"path";var Vq=["cursor","claudecode","codexcli","opencode"];function Yq(q,Q){let B=$q(q,"hooks","hooks.json"),U=K(B);if(!U)return null;let W=U.hooks??{},$={};for(let V of Vq){let Y=U[V];if(Y&&typeof Y==="object"&&"hooks"in Y&&Y.hooks)$[V]=Y.hooks}return{packName:Q,sourcePath:B,version:U.version,shared:W,targetOverrides:$}}function Mq(q,Q){let B={};for(let[W,$]of Object.entries(q.shared))B[W]=[...$];let U=q.targetOverrides[Q];if(U)for(let[W,$]of Object.entries(U))B[W]=[...B[W]??[],...$];return B}import{existsSync as Xq,readFileSync as Hq}from"fs";import{join as Kq}from"path";var Jq=["ignore",".aiignore"];function bq(q,Q){for(let B of Jq){let U=Kq(q,B);if(Xq(U)){let W=Hq(U,"utf-8"),$=Lq(W);return{packName:Q,sourcePath:U,patterns:$}}}return null}function Lq(q){return q.split(`
|
|
5
|
+
`).map((Q)=>Q.trim()).filter((Q)=>Q.length>0&&!Q.startsWith("#"))}function xq(q){let Q=new Set,B=[];for(let U of q)for(let W of U.patterns)if(!Q.has(W))Q.add(W),B.push(W);return B}import{join as Cq}from"path";function Gq(q,Q){let B=Cq(q,"mcp.json"),U=K(B);if(!U?.mcpServers)return null;return{packName:Q,sourcePath:B,servers:U.mcpServers}}function Oq(q){let Q={},B=[];for(let U of q)for(let[W,$]of Object.entries(U.servers)){if(W in Q){B.push(`MCP server "${W}" from pack "${U.packName}" skipped (already defined).`);continue}Q[W]=$}return{servers:Q,warnings:B}}import{existsSync as Tq,readFileSync as Iq}from"fs";import{basename as Rq,join as Aq}from"path";function yq(q,Q){let B=Aq(q,"plugins");if(!Tq(B))return[];let U=X(B,{extension:".ts"}),W=X(B,{extension:".js"});return[...U,...W].map((V)=>_q(V,Q))}function _q(q,Q){let B=Iq(q,"utf-8"),U=q.endsWith(".ts")?"ts":"js";return{name:Rq(q,`.${U}`),sourcePath:q,packName:Q,content:B,extension:U}}import{readFileSync as jq}from"fs";import{basename as Pq}from"path";function Fq(q,Q){return X(q,{extension:".md"}).map((U)=>wq(U,Q))}function wq(q,Q){let B=jq(q,"utf-8"),{data:U,content:W}=H(B);return{name:Pq(q,".md"),sourcePath:q,packName:Q,meta:U,content:W}}function vq(q,Q){let{targets:B}=q.meta;if(!B||B==="*")return!0;if(Array.isArray(B)&&B.includes("*"))return!0;return Array.isArray(B)&&B.includes(Q)}function Sq(q){return q.filter((Q)=>Q.meta.root===!0)}function Eq(q){return q.filter((Q)=>Q.meta.root!==!0)}import{existsSync as Dq,readFileSync as zq}from"fs";import{basename as F,join as Nq}from"path";var uq=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,P=64;function kq(q,Q){let B=y(q),U=[];for(let W of B){let $=Nq(W,"SKILL.md");if(Dq($))U.push(gq($,W,Q))}return U}function gq(q,Q,B){let U=zq(q,"utf-8"),{data:W,content:$}=H(U);return{name:W.name??F(Q),sourcePath:q,sourceDir:Q,packName:B,meta:W,content:$}}function w(q){return{...q.meta,name:q.name}}function mq(q){return L(w(q),q.content)}function hq(q,Q){let{data:B,content:U}=H(q),W={...B,name:Q},$=!1,V=W.description;if(typeof V!=="string"||V.trim().length===0)W.description=`Imported skill: ${Q}`,$=!0;return{content:L(W,U),addedDescription:$}}function dq(q){let Q=[],B=F(q.sourceDir),U=q.meta.name;if(typeof U!=="string"||U.trim().length===0)Q.push('Missing required frontmatter field "name".');else{if(U.length>P)Q.push(`Invalid "name": must be at most ${P} characters.`);if(!uq.test(U))Q.push('Invalid "name": use lowercase letters, numbers, and single hyphens only.');if(U!==B)Q.push(`Invalid "name": must match containing directory "${B}".`)}let W=q.meta.description;if(typeof W!=="string"||W.trim().length===0)Q.push('Missing required frontmatter field "description".');let $=q.meta["allowed-tools"];if($!==void 0&&(!Array.isArray($)||$.some((V)=>typeof V!=="string"||V.length===0)))Q.push('Invalid "allowed-tools": expected an array of non-empty strings.');return Q}function fq(q,Q){let{targets:B}=q.meta;if(!B||B==="*")return!0;if(Array.isArray(B)&&B.includes("*"))return!0;return Array.isArray(B)&&B.includes(Q)}export{dq as validateAgentSkillsFrontmatter,fq as skillMatchesTarget,mq as serializeSkill,r as scanModelsForSecrets,vq as ruleMatchesTarget,Mq as resolveHooksForTarget,kq as parseSkills,Fq as parseRules,yq as parsePlugins,s as parseModels,Gq as parseMcp,bq as parseIgnore,Yq as parseHooks,Uq as parseCommands,t as parseAgents,hq as normalizeImportedSkillMarkdown,l as mergeModelsConfigs,Oq as mergeMcpConfigs,xq as mergeIgnorePatterns,Sq as getRootRules,Eq as getDetailRules,Zq as commandMatchesTarget,w as buildSkillFrontmatter,qq as agentMatchesTarget,_ as ModelsSchema};
|