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
|
@@ -1,324 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// src/utils/filesystem.ts
|
|
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/utils/frontmatter.ts
|
|
115
|
-
import matter from "gray-matter";
|
|
116
|
-
function parseFrontmatter(source) {
|
|
117
|
-
const { data, content } = matter(source);
|
|
118
|
-
return {
|
|
119
|
-
data,
|
|
120
|
-
content: content.trim(),
|
|
121
|
-
raw: source
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
function serializeFrontmatter(data, content) {
|
|
125
|
-
const filtered = Object.fromEntries(Object.entries(data).filter(([, v]) => v !== undefined));
|
|
126
|
-
if (Object.keys(filtered).length === 0) {
|
|
127
|
-
return content;
|
|
128
|
-
}
|
|
129
|
-
return matter.stringify(content, filtered);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// src/features/rules.ts
|
|
133
|
-
import { readFileSync as readFileSync2 } from "fs";
|
|
134
|
-
import { basename } from "path";
|
|
135
|
-
function parseRules(rulesDir, packName) {
|
|
136
|
-
const files = listFiles(rulesDir, { extension: ".md" });
|
|
137
|
-
return files.map((filepath) => parseRuleFile(filepath, packName));
|
|
138
|
-
}
|
|
139
|
-
function parseRuleFile(filepath, packName) {
|
|
140
|
-
const raw = readFileSync2(filepath, "utf-8");
|
|
141
|
-
const { data, content } = parseFrontmatter(raw);
|
|
142
|
-
return {
|
|
143
|
-
name: basename(filepath, ".md"),
|
|
144
|
-
sourcePath: filepath,
|
|
145
|
-
packName,
|
|
146
|
-
meta: data,
|
|
147
|
-
content
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
function ruleMatchesTarget(rule, targetId) {
|
|
151
|
-
const { targets } = rule.meta;
|
|
152
|
-
if (!targets || targets === "*")
|
|
153
|
-
return true;
|
|
154
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
155
|
-
return true;
|
|
156
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
157
|
-
}
|
|
158
|
-
function getRootRules(rules) {
|
|
159
|
-
return rules.filter((r) => r.meta.root === true);
|
|
160
|
-
}
|
|
161
|
-
function getDetailRules(rules) {
|
|
162
|
-
return rules.filter((r) => r.meta.root !== true);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// src/features/skills.ts
|
|
166
|
-
import { existsSync as existsSync2, readFileSync as readFileSync3 } from "fs";
|
|
167
|
-
import { basename as basename2, join as join2 } from "path";
|
|
168
|
-
var SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
169
|
-
var SKILL_NAME_MAX_LENGTH = 64;
|
|
170
|
-
function parseSkills(skillsDir, packName) {
|
|
171
|
-
const dirs = listDirs(skillsDir);
|
|
172
|
-
const skills = [];
|
|
173
|
-
for (const dir of dirs) {
|
|
174
|
-
const skillMd = join2(dir, "SKILL.md");
|
|
175
|
-
if (existsSync2(skillMd)) {
|
|
176
|
-
skills.push(parseSkillFile(skillMd, dir, packName));
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return skills;
|
|
180
|
-
}
|
|
181
|
-
function parseSkillFile(filepath, skillDir, packName) {
|
|
182
|
-
const raw = readFileSync3(filepath, "utf-8");
|
|
183
|
-
const { data, content } = parseFrontmatter(raw);
|
|
184
|
-
return {
|
|
185
|
-
name: data.name ?? basename2(skillDir),
|
|
186
|
-
sourcePath: filepath,
|
|
187
|
-
sourceDir: skillDir,
|
|
188
|
-
packName,
|
|
189
|
-
meta: data,
|
|
190
|
-
content
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
function buildSkillFrontmatter(skill) {
|
|
194
|
-
return {
|
|
195
|
-
...skill.meta,
|
|
196
|
-
name: skill.name
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
function serializeSkill(skill) {
|
|
200
|
-
return serializeFrontmatter(buildSkillFrontmatter(skill), skill.content);
|
|
201
|
-
}
|
|
202
|
-
function normalizeImportedSkillMarkdown(source, skillName) {
|
|
203
|
-
const { data, content } = parseFrontmatter(source);
|
|
204
|
-
const normalized = {
|
|
205
|
-
...data,
|
|
206
|
-
name: skillName
|
|
207
|
-
};
|
|
208
|
-
let addedDescription = false;
|
|
209
|
-
const description = normalized.description;
|
|
210
|
-
if (typeof description !== "string" || description.trim().length === 0) {
|
|
211
|
-
normalized.description = `Imported skill: ${skillName}`;
|
|
212
|
-
addedDescription = true;
|
|
213
|
-
}
|
|
214
|
-
return {
|
|
215
|
-
content: serializeFrontmatter(normalized, content),
|
|
216
|
-
addedDescription
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
function validateAgentSkillsFrontmatter(skill) {
|
|
220
|
-
const errors = [];
|
|
221
|
-
const dirName = basename2(skill.sourceDir);
|
|
222
|
-
const declaredName = skill.meta.name;
|
|
223
|
-
if (typeof declaredName !== "string" || declaredName.trim().length === 0) {
|
|
224
|
-
errors.push('Missing required frontmatter field "name".');
|
|
225
|
-
} else {
|
|
226
|
-
if (declaredName.length > SKILL_NAME_MAX_LENGTH) {
|
|
227
|
-
errors.push(`Invalid "name": must be at most ${SKILL_NAME_MAX_LENGTH} characters.`);
|
|
228
|
-
}
|
|
229
|
-
if (!SKILL_NAME_PATTERN.test(declaredName)) {
|
|
230
|
-
errors.push('Invalid "name": use lowercase letters, numbers, and single hyphens only.');
|
|
231
|
-
}
|
|
232
|
-
if (declaredName !== dirName) {
|
|
233
|
-
errors.push(`Invalid "name": must match containing directory "${dirName}".`);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
const description = skill.meta.description;
|
|
237
|
-
if (typeof description !== "string" || description.trim().length === 0) {
|
|
238
|
-
errors.push('Missing required frontmatter field "description".');
|
|
239
|
-
}
|
|
240
|
-
const allowedTools = skill.meta["allowed-tools"];
|
|
241
|
-
if (allowedTools !== undefined && (!Array.isArray(allowedTools) || allowedTools.some((tool) => typeof tool !== "string" || tool.length === 0))) {
|
|
242
|
-
errors.push('Invalid "allowed-tools": expected an array of non-empty strings.');
|
|
243
|
-
}
|
|
244
|
-
return errors;
|
|
245
|
-
}
|
|
246
|
-
function skillMatchesTarget(skill, targetId) {
|
|
247
|
-
const { targets } = skill.meta;
|
|
248
|
-
if (!targets || targets === "*")
|
|
249
|
-
return true;
|
|
250
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
251
|
-
return true;
|
|
252
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// src/targets/base-target.ts
|
|
256
|
-
class BaseTarget {
|
|
257
|
-
supportsFeature(feature) {
|
|
258
|
-
return this.supportedFeatures.includes(feature);
|
|
259
|
-
}
|
|
260
|
-
getEffectiveFeatures(enabledFeatures) {
|
|
261
|
-
return enabledFeatures.filter((f) => this.supportsFeature(f));
|
|
262
|
-
}
|
|
263
|
-
createResult(filesWritten = [], filesDeleted = [], warnings = []) {
|
|
264
|
-
return {
|
|
265
|
-
targetId: this.id,
|
|
266
|
-
filesWritten,
|
|
267
|
-
filesDeleted,
|
|
268
|
-
warnings
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// src/targets/codex-cli.ts
|
|
274
|
-
import { join as join3, resolve } from "path";
|
|
275
|
-
var TARGET_ID = "codexcli";
|
|
276
|
-
|
|
277
|
-
class CodexCliTarget extends BaseTarget {
|
|
278
|
-
id = TARGET_ID;
|
|
279
|
-
name = "Codex CLI";
|
|
280
|
-
supportedFeatures = ["rules", "skills", "mcp", "hooks"];
|
|
281
|
-
generate(options) {
|
|
282
|
-
const { projectRoot, baseDir, features, enabledFeatures, deleteExisting } = options;
|
|
283
|
-
const root = resolve(projectRoot, baseDir);
|
|
284
|
-
const effective = this.getEffectiveFeatures(enabledFeatures);
|
|
285
|
-
const filesWritten = [];
|
|
286
|
-
const filesDeleted = [];
|
|
287
|
-
const warnings = [];
|
|
288
|
-
const codexDir = resolve(root, ".codex");
|
|
289
|
-
if (effective.includes("rules")) {
|
|
290
|
-
const memoriesDir = resolve(codexDir, "memories");
|
|
291
|
-
if (deleteExisting) {
|
|
292
|
-
removeIfExists(memoriesDir);
|
|
293
|
-
filesDeleted.push(memoriesDir);
|
|
294
|
-
}
|
|
295
|
-
ensureDir(memoriesDir);
|
|
296
|
-
const rules = features.rules.filter((r) => ruleMatchesTarget(r, TARGET_ID));
|
|
297
|
-
for (const rule of rules) {
|
|
298
|
-
const filepath = join3(memoriesDir, `${rule.name}.md`);
|
|
299
|
-
writeGeneratedFile(filepath, rule.content);
|
|
300
|
-
filesWritten.push(filepath);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
if (effective.includes("skills")) {
|
|
304
|
-
const skillsDir = resolve(codexDir, "skills");
|
|
305
|
-
if (deleteExisting) {
|
|
306
|
-
removeIfExists(skillsDir);
|
|
307
|
-
filesDeleted.push(skillsDir);
|
|
308
|
-
}
|
|
309
|
-
ensureDir(skillsDir);
|
|
310
|
-
const skills = features.skills.filter((s) => skillMatchesTarget(s, TARGET_ID));
|
|
311
|
-
for (const skill of skills) {
|
|
312
|
-
const skillSubDir = join3(skillsDir, skill.name);
|
|
313
|
-
ensureDir(skillSubDir);
|
|
314
|
-
const filepath = join3(skillSubDir, "SKILL.md");
|
|
315
|
-
writeGeneratedFile(filepath, serializeSkill(skill));
|
|
316
|
-
filesWritten.push(filepath);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
return this.createResult(filesWritten, filesDeleted, warnings);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
export {
|
|
323
|
-
CodexCliTarget
|
|
324
|
-
};
|
|
1
|
+
import{createRequire as l}from"node:module";var Oq=l(import.meta.url);import{existsSync as O,mkdirSync as s,readdirSync as P,readFileSync as a,rmSync as i,statSync as S,writeFileSync as r}from"fs";import{dirname as t,join as N,relative as e}from"path";var v="<!-- Generated by agentpacks. DO NOT EDIT. -->",y="// Generated by agentpacks. DO NOT EDIT.",E="// Generated by agentpacks. DO NOT EDIT.";function G(q,Q,U={}){let{header:Z=!0,type:$}=U,B=$??qq(q);M(t(q));let K=Q;if(Z){let X=Qq(B);if(X)K=`${X}
|
|
2
|
+
${Q}`}r(q,K,"utf-8")}function A(q,Q,U={}){let Z=JSON.stringify(Q,null,2);G(q,Z+`
|
|
3
|
+
`,{...U,type:"json"})}function D(q){if(!O(q))return null;return a(q,"utf-8")}function g(q){let Q=D(q);if(Q===null)return null;return JSON.parse(Q)}function M(q){if(!O(q))s(q,{recursive:!0})}function u(q){if(O(q))i(q,{recursive:!0,force:!0})}function w(q,Q={}){let{extension:U,recursive:Z=!1}=Q;if(!O(q))return[];let $=[],B=P(q);for(let K of B){let X=N(q,K),J=S(X);if(J.isDirectory()&&Z)$.push(...w(X,Q));else if(J.isFile()){if(!U||K.endsWith(U))$.push(X)}}return $}function m(q){if(!O(q))return[];return P(q).map((Q)=>N(q,Q)).filter((Q)=>S(Q).isDirectory())}function Hq(q,Q){return e(q,Q)}function xq(q){let Q=D(q);if(!Q)return!1;return Q.startsWith(v)||Q.startsWith(y)||Q.startsWith(E)}function qq(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 Qq(q){switch(q){case"md":return v;case"json":return y;case"js":case"ts":return E;default:return null}}import k from"gray-matter";function b(q){let{data:Q,content:U}=k(q);return{data:Q,content:U.trim(),raw:q}}function _(q,Q){let U=Object.fromEntries(Object.entries(q).filter(([,Z])=>Z!==void 0));if(Object.keys(U).length===0)return Q;return k.stringify(Q,U)}import{join as Uq}from"path";var Zq=["cursor","claudecode","codexcli","opencode"];function Rq(q,Q){let U=Uq(q,"hooks","hooks.json"),Z=g(U);if(!Z)return null;let $=Z.hooks??{},B={};for(let K of Zq){let X=Z[K];if(X&&typeof X==="object"&&"hooks"in X&&X.hooks)B[K]=X.hooks}return{packName:Q,sourcePath:U,version:Z.version,shared:$,targetOverrides:B}}function c(q,Q){let U={};for(let[$,B]of Object.entries(q.shared))U[$]=[...B];let Z=q.targetOverrides[Q];if(Z)for(let[$,B]of Object.entries(Z))U[$]=[...U[$]??[],...B];return U}import{readFileSync as $q}from"fs";import{basename as Bq}from"path";function vq(q,Q){return w(q,{extension:".md"}).map((Z)=>Yq(Z,Q))}function Yq(q,Q){let U=$q(q,"utf-8"),{data:Z,content:$}=b(U);return{name:Bq(q,".md"),sourcePath:q,packName:Q,meta:Z,content:$}}function p(q,Q){let{targets:U}=q.meta;if(!U||U==="*")return!0;if(Array.isArray(U)&&U.includes("*"))return!0;return Array.isArray(U)&&U.includes(Q)}function yq(q){return q.filter((Q)=>Q.meta.root===!0)}function Eq(q){return q.filter((Q)=>Q.meta.root!==!0)}import{existsSync as Vq,readFileSync as Xq}from"fs";import{basename as h,join as Kq}from"path";var Cq=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,f=64;function cq(q,Q){let U=m(q),Z=[];for(let $ of U){let B=Kq($,"SKILL.md");if(Vq(B))Z.push(zq(B,$,Q))}return Z}function zq(q,Q,U){let Z=Xq(q,"utf-8"),{data:$,content:B}=b(Z);return{name:$.name??h(Q),sourcePath:q,sourceDir:Q,packName:U,meta:$,content:B}}function Jq(q){return{...q.meta,name:q.name}}function d(q){return _(Jq(q),q.content)}function pq(q,Q){let{data:U,content:Z}=b(q),$={...U,name:Q},B=!1,K=$.description;if(typeof K!=="string"||K.trim().length===0)$.description=`Imported skill: ${Q}`,B=!0;return{content:_($,Z),addedDescription:B}}function fq(q){let Q=[],U=h(q.sourceDir),Z=q.meta.name;if(typeof Z!=="string"||Z.trim().length===0)Q.push('Missing required frontmatter field "name".');else{if(Z.length>f)Q.push(`Invalid "name": must be at most ${f} characters.`);if(!Cq.test(Z))Q.push('Invalid "name": use lowercase letters, numbers, and single hyphens only.');if(Z!==U)Q.push(`Invalid "name": must match containing directory "${U}".`)}let $=q.meta.description;if(typeof $!=="string"||$.trim().length===0)Q.push('Missing required frontmatter field "description".');let B=q.meta["allowed-tools"];if(B!==void 0&&(!Array.isArray(B)||B.some((K)=>typeof K!=="string"||K.length===0)))Q.push('Invalid "allowed-tools": expected an array of non-empty strings.');return Q}function n(q,Q){let{targets:U}=q.meta;if(!U||U==="*")return!0;if(Array.isArray(U)&&U.includes("*"))return!0;return Array.isArray(U)&&U.includes(Q)}class R{supportsFeature(q){return this.supportedFeatures.includes(q)}getEffectiveFeatures(q){return q.filter((Q)=>this.supportsFeature(Q))}createResult(q=[],Q=[],U=[]){return{targetId:this.id,filesWritten:q,filesDeleted:Q,warnings:U}}}import{join as F,resolve as L}from"path";var j="codexcli";class Wq extends R{id=j;name="Codex CLI";supportedFeatures=["rules","skills","mcp","hooks"];generate(q){let{projectRoot:Q,baseDir:U,features:Z,enabledFeatures:$,deleteExisting:B}=q,K=L(Q,U),X=this.getEffectiveFeatures($),J=[],I=[],H=[],x=L(K,".codex");if(X.includes("rules")){let C=L(x,"memories");if(B)T(C,I,H);M(C);let z=Z.rules.filter((Y)=>p(Y,j));for(let Y of z){let V=F(C,`${Y.name}.md`);G(V,Y.content),J.push(V)}}if(X.includes("skills")){let C=L(x,"skills");if(B)T(C,I,H);M(C);let z=Z.skills.filter((Y)=>n(Y,j));for(let Y of z){let V=F(C,Y.name);M(V);let W=F(V,"SKILL.md");G(W,d(Y)),J.push(W)}}if(X.includes("hooks")){let C=L(x,"hooks.json");if(B)T(C,I,H);let z={};for(let Y of Z.hooks){let V=c(Y,j);for(let[W,o]of Object.entries(V)){if(!z[W])z[W]=[];z[W].push(...o)}}if(Object.keys(z).length>0){let Y=Z.hooks.find((V)=>V.version!==void 0)?.version??1;A(C,{version:Y,hooks:z},{header:!1}),J.push(C)}}if(X.includes("mcp")){let C=Object.entries(Z.mcpServers);if(C.length>0){let z={};for(let[Y,V]of C)if(V.url)z[Y]={url:V.url};else if(V.command)z[Y]={command:V.command,...V.args?{args:V.args}:{},...V.env?{env:V.env}:{}};if(Object.keys(z).length>0){let Y=L(x,"mcp.json");A(Y,{mcpServers:z},{header:!1}),J.push(Y)}}}return this.createResult(J,I,H)}}function T(q,Q,U){try{u(q),Q.push(q)}catch(Z){U.push(`Could not remove ${q}: ${Z instanceof Error?Z.message:String(Z)}`)}}export{Wq as CodexCliTarget};
|