agentpacks 1.7.6 → 1.7.8
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
|
@@ -5,13 +5,13 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
5
5
|
import {
|
|
6
6
|
existsSync,
|
|
7
7
|
mkdirSync,
|
|
8
|
-
readFileSync,
|
|
9
|
-
writeFileSync,
|
|
10
8
|
readdirSync,
|
|
9
|
+
readFileSync,
|
|
11
10
|
rmSync,
|
|
12
|
-
statSync
|
|
11
|
+
statSync,
|
|
12
|
+
writeFileSync
|
|
13
13
|
} from "fs";
|
|
14
|
-
import { dirname,
|
|
14
|
+
import { dirname, join, relative } from "path";
|
|
15
15
|
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
16
16
|
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
17
17
|
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
@@ -130,7 +130,7 @@ function serializeFrontmatter(data, content) {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
// src/features/skills.ts
|
|
133
|
-
import {
|
|
133
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
134
134
|
import { basename, join as join2 } from "path";
|
|
135
135
|
var SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
136
136
|
var SKILL_NAME_MAX_LENGTH = 64;
|
|
@@ -219,152 +219,90 @@ function skillMatchesTarget(skill, targetId) {
|
|
|
219
219
|
return Array.isArray(targets) && targets.includes(targetId);
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
// src/importers/
|
|
223
|
-
import { existsSync as existsSync3, readFileSync as readFileSync3,
|
|
224
|
-
import {
|
|
225
|
-
|
|
226
|
-
function importFromRulesync(projectRoot, outputPackDir) {
|
|
227
|
-
const rulesyncDir = resolve(projectRoot, ".rulesync");
|
|
222
|
+
// src/importers/claude-code.ts
|
|
223
|
+
import { copyFileSync, existsSync as existsSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
224
|
+
import { basename as basename2, join as join3, resolve } from "path";
|
|
225
|
+
function importFromClaudeCode(projectRoot, outputPackDir) {
|
|
228
226
|
const warnings = [];
|
|
229
227
|
const filesImported = [];
|
|
230
|
-
|
|
228
|
+
const claudeDir = resolve(projectRoot, ".claude");
|
|
229
|
+
const hasClaudeMd = existsSync3(resolve(projectRoot, "CLAUDE.md"));
|
|
230
|
+
const hasClaudeDir = existsSync3(claudeDir);
|
|
231
|
+
if (!hasClaudeMd && !hasClaudeDir) {
|
|
231
232
|
return {
|
|
232
233
|
packDir: "",
|
|
233
234
|
filesImported: [],
|
|
234
|
-
warnings: ["No .
|
|
235
|
+
warnings: ["No CLAUDE.md or .claude/ directory found."],
|
|
235
236
|
configGenerated: false
|
|
236
237
|
};
|
|
237
238
|
}
|
|
238
|
-
const packDir = outputPackDir ?? resolve(projectRoot, "packs", "
|
|
239
|
+
const packDir = outputPackDir ?? resolve(projectRoot, "packs", "claude-import");
|
|
239
240
|
ensureDir(packDir);
|
|
240
|
-
const rulesDir = resolve(
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
for (const file of files) {
|
|
257
|
-
const dest = join3(outCommandsDir, basename2(file));
|
|
258
|
-
copyFileSync(file, dest);
|
|
259
|
-
filesImported.push(dest);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
const subagentsDir = resolve(rulesyncDir, "subagents");
|
|
263
|
-
if (existsSync3(subagentsDir)) {
|
|
264
|
-
const outAgentsDir = resolve(packDir, "agents");
|
|
265
|
-
ensureDir(outAgentsDir);
|
|
266
|
-
const files = listFiles(subagentsDir, { extension: ".md" });
|
|
267
|
-
for (const file of files) {
|
|
268
|
-
const dest = join3(outAgentsDir, basename2(file));
|
|
269
|
-
copyFileSync(file, dest);
|
|
270
|
-
filesImported.push(dest);
|
|
271
|
-
}
|
|
241
|
+
const rulesDir = resolve(packDir, "rules");
|
|
242
|
+
ensureDir(rulesDir);
|
|
243
|
+
if (hasClaudeMd) {
|
|
244
|
+
const raw = readFileSync3(resolve(projectRoot, "CLAUDE.md"), "utf-8");
|
|
245
|
+
const ruleContent = [
|
|
246
|
+
"---",
|
|
247
|
+
"root: true",
|
|
248
|
+
'description: "Root Claude Code rules"',
|
|
249
|
+
"---",
|
|
250
|
+
"",
|
|
251
|
+
raw
|
|
252
|
+
].join(`
|
|
253
|
+
`);
|
|
254
|
+
const dest = join3(rulesDir, "claude-root.md");
|
|
255
|
+
writeFileSync2(dest, ruleContent);
|
|
256
|
+
filesImported.push(dest);
|
|
272
257
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
if (skillName.startsWith("."))
|
|
281
|
-
continue;
|
|
282
|
-
const skillMd = join3(skillDir, "SKILL.md");
|
|
283
|
-
if (existsSync3(skillMd)) {
|
|
284
|
-
const outSkillDir = join3(outSkillsDir, skillName);
|
|
285
|
-
ensureDir(outSkillDir);
|
|
286
|
-
const rawSkill = readFileSync3(skillMd, "utf-8");
|
|
287
|
-
const normalized = normalizeImportedSkillMarkdown(rawSkill, skillName);
|
|
288
|
-
const dest = join3(outSkillDir, "SKILL.md");
|
|
289
|
-
writeFileSync2(dest, normalized.content);
|
|
258
|
+
if (hasClaudeDir) {
|
|
259
|
+
const claudeRulesDir = resolve(claudeDir, "rules");
|
|
260
|
+
if (existsSync3(claudeRulesDir)) {
|
|
261
|
+
const files = listFiles(claudeRulesDir, { extension: ".md" });
|
|
262
|
+
for (const file of files) {
|
|
263
|
+
const dest = join3(rulesDir, basename2(file));
|
|
264
|
+
copyFileSync(file, dest);
|
|
290
265
|
filesImported.push(dest);
|
|
291
|
-
|
|
292
|
-
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
const settingsPath = resolve(claudeDir, "settings.json");
|
|
269
|
+
if (existsSync3(settingsPath)) {
|
|
270
|
+
try {
|
|
271
|
+
const raw = readFileSync3(settingsPath, "utf-8");
|
|
272
|
+
const settings = JSON.parse(raw);
|
|
273
|
+
const mcpServers = settings.mcpServers ?? settings.mcp_servers;
|
|
274
|
+
if (mcpServers && typeof mcpServers === "object") {
|
|
275
|
+
const mcpConfig = { servers: mcpServers };
|
|
276
|
+
const dest = join3(packDir, "mcp.json");
|
|
277
|
+
writeFileSync2(dest, JSON.stringify(mcpConfig, null, 2) + `
|
|
278
|
+
`);
|
|
279
|
+
filesImported.push(dest);
|
|
293
280
|
}
|
|
281
|
+
} catch {
|
|
282
|
+
warnings.push("Failed to parse .claude/settings.json");
|
|
294
283
|
}
|
|
295
284
|
}
|
|
296
285
|
}
|
|
297
|
-
const hooksJson = resolve(rulesyncDir, "hooks.json");
|
|
298
|
-
if (existsSync3(hooksJson)) {
|
|
299
|
-
const outHooksDir = resolve(packDir, "hooks");
|
|
300
|
-
ensureDir(outHooksDir);
|
|
301
|
-
copyFileSync(hooksJson, join3(outHooksDir, "hooks.json"));
|
|
302
|
-
filesImported.push(join3(outHooksDir, "hooks.json"));
|
|
303
|
-
}
|
|
304
|
-
const mcpJson = resolve(rulesyncDir, "mcp.json");
|
|
305
|
-
if (existsSync3(mcpJson)) {
|
|
306
|
-
copyFileSync(mcpJson, join3(packDir, "mcp.json"));
|
|
307
|
-
filesImported.push(join3(packDir, "mcp.json"));
|
|
308
|
-
}
|
|
309
|
-
const aiIgnore = resolve(rulesyncDir, ".aiignore");
|
|
310
|
-
const rulesyncIgnore = resolve(projectRoot, ".rulesyncignore");
|
|
311
|
-
if (existsSync3(aiIgnore)) {
|
|
312
|
-
copyFileSync(aiIgnore, join3(packDir, "ignore"));
|
|
313
|
-
filesImported.push(join3(packDir, "ignore"));
|
|
314
|
-
} else if (existsSync3(rulesyncIgnore)) {
|
|
315
|
-
copyFileSync(rulesyncIgnore, join3(packDir, "ignore"));
|
|
316
|
-
filesImported.push(join3(packDir, "ignore"));
|
|
317
|
-
}
|
|
318
286
|
const packJson = {
|
|
319
|
-
name: "
|
|
287
|
+
name: "claude-import",
|
|
320
288
|
version: "1.0.0",
|
|
321
|
-
description: "Imported from
|
|
322
|
-
tags: ["imported", "
|
|
289
|
+
description: "Imported from Claude Code",
|
|
290
|
+
tags: ["imported", "claude-code"],
|
|
323
291
|
dependencies: [],
|
|
324
292
|
conflicts: [],
|
|
325
293
|
targets: "*",
|
|
326
294
|
features: "*"
|
|
327
295
|
};
|
|
328
|
-
|
|
296
|
+
const packJsonPath = join3(packDir, "pack.json");
|
|
297
|
+
writeFileSync2(packJsonPath, JSON.stringify(packJson, null, 2) + `
|
|
329
298
|
`);
|
|
330
|
-
filesImported.push(
|
|
331
|
-
|
|
332
|
-
const rulesyncConfig = resolve(projectRoot, "rulesync.jsonc");
|
|
333
|
-
if (existsSync3(rulesyncConfig)) {
|
|
334
|
-
const agentpacksConfig = convertRulesyncConfig(rulesyncConfig, packDir);
|
|
335
|
-
const configPath = resolve(projectRoot, "agentpacks.jsonc");
|
|
336
|
-
writeFileSync2(configPath, agentpacksConfig);
|
|
337
|
-
configGenerated = true;
|
|
338
|
-
}
|
|
339
|
-
return { packDir, filesImported, warnings, configGenerated };
|
|
340
|
-
}
|
|
341
|
-
function convertRulesyncConfig(rulesyncPath, _packDir) {
|
|
342
|
-
const raw = readFileSync3(rulesyncPath, "utf-8");
|
|
343
|
-
const parsed = parseJsonc(raw);
|
|
344
|
-
const targets = parsed.targets ?? ["opencode", "cursor", "claudecode"];
|
|
345
|
-
const features = parsed.features ?? ["*"];
|
|
346
|
-
const baseDirs = parsed.baseDirs ?? ["."];
|
|
347
|
-
const global = parsed.global ?? false;
|
|
348
|
-
const deleteVal = parsed.delete ?? true;
|
|
349
|
-
const relPackDir = "./" + join3("packs", "default");
|
|
350
|
-
const config = {
|
|
351
|
-
$schema: "https://unpkg.com/agentpacks/schema.json",
|
|
352
|
-
packs: [relPackDir],
|
|
353
|
-
disabled: [],
|
|
354
|
-
targets,
|
|
355
|
-
features,
|
|
356
|
-
mode: baseDirs.length > 1 ? "monorepo" : "repo",
|
|
357
|
-
baseDirs,
|
|
358
|
-
global,
|
|
359
|
-
delete: deleteVal
|
|
360
|
-
};
|
|
361
|
-
return JSON.stringify(config, null, 2) + `
|
|
362
|
-
`;
|
|
299
|
+
filesImported.push(packJsonPath);
|
|
300
|
+
return { packDir, filesImported, warnings, configGenerated: false };
|
|
363
301
|
}
|
|
364
302
|
|
|
365
303
|
// src/importers/cursor.ts
|
|
366
|
-
import { existsSync as existsSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync3
|
|
367
|
-
import {
|
|
304
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "fs";
|
|
305
|
+
import { basename as basename3, join as join4, resolve as resolve2 } from "path";
|
|
368
306
|
function importFromCursor(projectRoot, outputPackDir) {
|
|
369
307
|
const cursorDir = resolve2(projectRoot, ".cursor");
|
|
370
308
|
const warnings = [];
|
|
@@ -495,95 +433,14 @@ function writePackJson(packDir, name, filesImported) {
|
|
|
495
433
|
filesImported.push(dest);
|
|
496
434
|
}
|
|
497
435
|
|
|
498
|
-
// src/importers/claude-code.ts
|
|
499
|
-
import { existsSync as existsSync5, readFileSync as readFileSync5, writeFileSync as writeFileSync4, copyFileSync as copyFileSync3 } from "fs";
|
|
500
|
-
import { resolve as resolve3, join as join5, basename as basename4 } from "path";
|
|
501
|
-
function importFromClaudeCode(projectRoot, outputPackDir) {
|
|
502
|
-
const warnings = [];
|
|
503
|
-
const filesImported = [];
|
|
504
|
-
const claudeDir = resolve3(projectRoot, ".claude");
|
|
505
|
-
const hasClaudeMd = existsSync5(resolve3(projectRoot, "CLAUDE.md"));
|
|
506
|
-
const hasClaudeDir = existsSync5(claudeDir);
|
|
507
|
-
if (!hasClaudeMd && !hasClaudeDir) {
|
|
508
|
-
return {
|
|
509
|
-
packDir: "",
|
|
510
|
-
filesImported: [],
|
|
511
|
-
warnings: ["No CLAUDE.md or .claude/ directory found."],
|
|
512
|
-
configGenerated: false
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
const packDir = outputPackDir ?? resolve3(projectRoot, "packs", "claude-import");
|
|
516
|
-
ensureDir(packDir);
|
|
517
|
-
const rulesDir = resolve3(packDir, "rules");
|
|
518
|
-
ensureDir(rulesDir);
|
|
519
|
-
if (hasClaudeMd) {
|
|
520
|
-
const raw = readFileSync5(resolve3(projectRoot, "CLAUDE.md"), "utf-8");
|
|
521
|
-
const ruleContent = [
|
|
522
|
-
"---",
|
|
523
|
-
"root: true",
|
|
524
|
-
'description: "Root Claude Code rules"',
|
|
525
|
-
"---",
|
|
526
|
-
"",
|
|
527
|
-
raw
|
|
528
|
-
].join(`
|
|
529
|
-
`);
|
|
530
|
-
const dest = join5(rulesDir, "claude-root.md");
|
|
531
|
-
writeFileSync4(dest, ruleContent);
|
|
532
|
-
filesImported.push(dest);
|
|
533
|
-
}
|
|
534
|
-
if (hasClaudeDir) {
|
|
535
|
-
const claudeRulesDir = resolve3(claudeDir, "rules");
|
|
536
|
-
if (existsSync5(claudeRulesDir)) {
|
|
537
|
-
const files = listFiles(claudeRulesDir, { extension: ".md" });
|
|
538
|
-
for (const file of files) {
|
|
539
|
-
const dest = join5(rulesDir, basename4(file));
|
|
540
|
-
copyFileSync3(file, dest);
|
|
541
|
-
filesImported.push(dest);
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
const settingsPath = resolve3(claudeDir, "settings.json");
|
|
545
|
-
if (existsSync5(settingsPath)) {
|
|
546
|
-
try {
|
|
547
|
-
const raw = readFileSync5(settingsPath, "utf-8");
|
|
548
|
-
const settings = JSON.parse(raw);
|
|
549
|
-
const mcpServers = settings.mcpServers ?? settings.mcp_servers;
|
|
550
|
-
if (mcpServers && typeof mcpServers === "object") {
|
|
551
|
-
const mcpConfig = { servers: mcpServers };
|
|
552
|
-
const dest = join5(packDir, "mcp.json");
|
|
553
|
-
writeFileSync4(dest, JSON.stringify(mcpConfig, null, 2) + `
|
|
554
|
-
`);
|
|
555
|
-
filesImported.push(dest);
|
|
556
|
-
}
|
|
557
|
-
} catch {
|
|
558
|
-
warnings.push("Failed to parse .claude/settings.json");
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
const packJson = {
|
|
563
|
-
name: "claude-import",
|
|
564
|
-
version: "1.0.0",
|
|
565
|
-
description: "Imported from Claude Code",
|
|
566
|
-
tags: ["imported", "claude-code"],
|
|
567
|
-
dependencies: [],
|
|
568
|
-
conflicts: [],
|
|
569
|
-
targets: "*",
|
|
570
|
-
features: "*"
|
|
571
|
-
};
|
|
572
|
-
const packJsonPath = join5(packDir, "pack.json");
|
|
573
|
-
writeFileSync4(packJsonPath, JSON.stringify(packJson, null, 2) + `
|
|
574
|
-
`);
|
|
575
|
-
filesImported.push(packJsonPath);
|
|
576
|
-
return { packDir, filesImported, warnings, configGenerated: false };
|
|
577
|
-
}
|
|
578
|
-
|
|
579
436
|
// src/importers/opencode.ts
|
|
580
|
-
import {
|
|
581
|
-
import {
|
|
437
|
+
import { copyFileSync as copyFileSync3, existsSync as existsSync5, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "fs";
|
|
438
|
+
import { basename as basename4, join as join5, resolve as resolve3 } from "path";
|
|
582
439
|
function importFromOpenCode(projectRoot, outputPackDir) {
|
|
583
440
|
const warnings = [];
|
|
584
441
|
const filesImported = [];
|
|
585
|
-
const ocDir =
|
|
586
|
-
if (!
|
|
442
|
+
const ocDir = resolve3(projectRoot, ".opencode");
|
|
443
|
+
if (!existsSync5(ocDir)) {
|
|
587
444
|
return {
|
|
588
445
|
packDir: "",
|
|
589
446
|
filesImported: [],
|
|
@@ -591,28 +448,28 @@ function importFromOpenCode(projectRoot, outputPackDir) {
|
|
|
591
448
|
configGenerated: false
|
|
592
449
|
};
|
|
593
450
|
}
|
|
594
|
-
const packDir = outputPackDir ??
|
|
451
|
+
const packDir = outputPackDir ?? resolve3(projectRoot, "packs", "opencode-import");
|
|
595
452
|
ensureDir(packDir);
|
|
596
|
-
importDirMd(
|
|
597
|
-
importDirMd(
|
|
598
|
-
importDirMd(
|
|
599
|
-
const skillDir =
|
|
600
|
-
if (
|
|
601
|
-
const outSkillDir =
|
|
453
|
+
importDirMd(resolve3(ocDir, "rules"), resolve3(packDir, "rules"), filesImported);
|
|
454
|
+
importDirMd(resolve3(ocDir, "commands"), resolve3(packDir, "commands"), filesImported);
|
|
455
|
+
importDirMd(resolve3(ocDir, "agents"), resolve3(packDir, "agents"), filesImported);
|
|
456
|
+
const skillDir = resolve3(ocDir, "skill");
|
|
457
|
+
if (existsSync5(skillDir)) {
|
|
458
|
+
const outSkillDir = resolve3(packDir, "skills");
|
|
602
459
|
ensureDir(outSkillDir);
|
|
603
460
|
const dirs = listDirs(skillDir);
|
|
604
461
|
for (const dir of dirs) {
|
|
605
|
-
const name =
|
|
462
|
+
const name = basename4(dir);
|
|
606
463
|
if (name.startsWith("."))
|
|
607
464
|
continue;
|
|
608
|
-
const skillMd =
|
|
609
|
-
if (
|
|
610
|
-
const outDir =
|
|
465
|
+
const skillMd = join5(dir, "SKILL.md");
|
|
466
|
+
if (existsSync5(skillMd)) {
|
|
467
|
+
const outDir = join5(outSkillDir, name);
|
|
611
468
|
ensureDir(outDir);
|
|
612
|
-
const rawSkill =
|
|
469
|
+
const rawSkill = readFileSync5(skillMd, "utf-8");
|
|
613
470
|
const normalized = normalizeImportedSkillMarkdown(rawSkill, name);
|
|
614
|
-
const dest2 =
|
|
615
|
-
|
|
471
|
+
const dest2 = join5(outDir, "SKILL.md");
|
|
472
|
+
writeFileSync4(dest2, normalized.content);
|
|
616
473
|
filesImported.push(dest2);
|
|
617
474
|
if (normalized.addedDescription) {
|
|
618
475
|
warnings.push(`skills/${name}/SKILL.md missing description; added import placeholder.`);
|
|
@@ -620,24 +477,24 @@ function importFromOpenCode(projectRoot, outputPackDir) {
|
|
|
620
477
|
}
|
|
621
478
|
}
|
|
622
479
|
}
|
|
623
|
-
const pluginsDir =
|
|
624
|
-
if (
|
|
625
|
-
const outPluginsDir =
|
|
480
|
+
const pluginsDir = resolve3(ocDir, "plugins");
|
|
481
|
+
if (existsSync5(pluginsDir)) {
|
|
482
|
+
const outPluginsDir = resolve3(packDir, "plugins");
|
|
626
483
|
ensureDir(outPluginsDir);
|
|
627
484
|
const files = listFiles(pluginsDir);
|
|
628
485
|
for (const file of files) {
|
|
629
486
|
if (file.endsWith(".ts") || file.endsWith(".js")) {
|
|
630
|
-
const dest2 =
|
|
631
|
-
|
|
487
|
+
const dest2 = join5(outPluginsDir, basename4(file));
|
|
488
|
+
copyFileSync3(file, dest2);
|
|
632
489
|
filesImported.push(dest2);
|
|
633
490
|
}
|
|
634
491
|
}
|
|
635
492
|
}
|
|
636
|
-
const agentsMd =
|
|
637
|
-
if (
|
|
638
|
-
const outRulesDir =
|
|
493
|
+
const agentsMd = resolve3(projectRoot, "AGENTS.md");
|
|
494
|
+
if (existsSync5(agentsMd)) {
|
|
495
|
+
const outRulesDir = resolve3(packDir, "rules");
|
|
639
496
|
ensureDir(outRulesDir);
|
|
640
|
-
const raw =
|
|
497
|
+
const raw = readFileSync5(agentsMd, "utf-8");
|
|
641
498
|
const ruleContent = [
|
|
642
499
|
"---",
|
|
643
500
|
"root: true",
|
|
@@ -647,19 +504,19 @@ function importFromOpenCode(projectRoot, outputPackDir) {
|
|
|
647
504
|
raw
|
|
648
505
|
].join(`
|
|
649
506
|
`);
|
|
650
|
-
const dest2 =
|
|
651
|
-
|
|
507
|
+
const dest2 = join5(outRulesDir, "agents-md-root.md");
|
|
508
|
+
writeFileSync4(dest2, ruleContent);
|
|
652
509
|
filesImported.push(dest2);
|
|
653
510
|
}
|
|
654
|
-
const ocJson =
|
|
655
|
-
if (
|
|
511
|
+
const ocJson = resolve3(projectRoot, "opencode.json");
|
|
512
|
+
if (existsSync5(ocJson)) {
|
|
656
513
|
try {
|
|
657
|
-
const raw =
|
|
514
|
+
const raw = readFileSync5(ocJson, "utf-8");
|
|
658
515
|
const config = JSON.parse(raw);
|
|
659
516
|
const mcpObj = config.mcp;
|
|
660
517
|
if (mcpObj) {
|
|
661
|
-
const dest2 =
|
|
662
|
-
|
|
518
|
+
const dest2 = join5(packDir, "mcp.json");
|
|
519
|
+
writeFileSync4(dest2, JSON.stringify({ servers: mcpObj }, null, 2) + `
|
|
663
520
|
`);
|
|
664
521
|
filesImported.push(dest2);
|
|
665
522
|
}
|
|
@@ -667,10 +524,10 @@ function importFromOpenCode(projectRoot, outputPackDir) {
|
|
|
667
524
|
warnings.push("Failed to parse opencode.json");
|
|
668
525
|
}
|
|
669
526
|
}
|
|
670
|
-
const ocIgnore =
|
|
671
|
-
if (
|
|
672
|
-
|
|
673
|
-
filesImported.push(
|
|
527
|
+
const ocIgnore = resolve3(projectRoot, ".opencodeignore");
|
|
528
|
+
if (existsSync5(ocIgnore)) {
|
|
529
|
+
copyFileSync3(ocIgnore, join5(packDir, "ignore"));
|
|
530
|
+
filesImported.push(join5(packDir, "ignore"));
|
|
674
531
|
}
|
|
675
532
|
const packJson = {
|
|
676
533
|
name: "opencode-import",
|
|
@@ -682,24 +539,167 @@ function importFromOpenCode(projectRoot, outputPackDir) {
|
|
|
682
539
|
targets: "*",
|
|
683
540
|
features: "*"
|
|
684
541
|
};
|
|
685
|
-
const dest =
|
|
686
|
-
|
|
542
|
+
const dest = join5(packDir, "pack.json");
|
|
543
|
+
writeFileSync4(dest, JSON.stringify(packJson, null, 2) + `
|
|
687
544
|
`);
|
|
688
545
|
filesImported.push(dest);
|
|
689
546
|
return { packDir, filesImported, warnings, configGenerated: false };
|
|
690
547
|
}
|
|
691
548
|
function importDirMd(srcDir, outDir, filesImported) {
|
|
692
|
-
if (!
|
|
549
|
+
if (!existsSync5(srcDir))
|
|
693
550
|
return;
|
|
694
551
|
ensureDir(outDir);
|
|
695
552
|
const files = listFiles(srcDir, { extension: ".md" });
|
|
696
553
|
for (const file of files) {
|
|
697
|
-
const dest =
|
|
698
|
-
|
|
554
|
+
const dest = join5(outDir, basename4(file));
|
|
555
|
+
copyFileSync3(file, dest);
|
|
699
556
|
filesImported.push(dest);
|
|
700
557
|
}
|
|
701
558
|
}
|
|
702
559
|
|
|
560
|
+
// src/importers/rulesync.ts
|
|
561
|
+
import { copyFileSync as copyFileSync4, existsSync as existsSync6, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
|
|
562
|
+
import { parse as parseJsonc } from "jsonc-parser";
|
|
563
|
+
import { basename as basename5, join as join6, resolve as resolve4 } from "path";
|
|
564
|
+
function importFromRulesync(projectRoot, outputPackDir) {
|
|
565
|
+
const rulesyncDir = resolve4(projectRoot, ".rulesync");
|
|
566
|
+
const warnings = [];
|
|
567
|
+
const filesImported = [];
|
|
568
|
+
if (!existsSync6(rulesyncDir)) {
|
|
569
|
+
return {
|
|
570
|
+
packDir: "",
|
|
571
|
+
filesImported: [],
|
|
572
|
+
warnings: ["No .rulesync/ directory found."],
|
|
573
|
+
configGenerated: false
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
const packDir = outputPackDir ?? resolve4(projectRoot, "packs", "default");
|
|
577
|
+
ensureDir(packDir);
|
|
578
|
+
const rulesDir = resolve4(rulesyncDir, "rules");
|
|
579
|
+
if (existsSync6(rulesDir)) {
|
|
580
|
+
const outRulesDir = resolve4(packDir, "rules");
|
|
581
|
+
ensureDir(outRulesDir);
|
|
582
|
+
const files = listFiles(rulesDir, { extension: ".md" });
|
|
583
|
+
for (const file of files) {
|
|
584
|
+
const dest = join6(outRulesDir, basename5(file));
|
|
585
|
+
copyFileSync4(file, dest);
|
|
586
|
+
filesImported.push(dest);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
const commandsDir = resolve4(rulesyncDir, "commands");
|
|
590
|
+
if (existsSync6(commandsDir)) {
|
|
591
|
+
const outCommandsDir = resolve4(packDir, "commands");
|
|
592
|
+
ensureDir(outCommandsDir);
|
|
593
|
+
const files = listFiles(commandsDir, { extension: ".md" });
|
|
594
|
+
for (const file of files) {
|
|
595
|
+
const dest = join6(outCommandsDir, basename5(file));
|
|
596
|
+
copyFileSync4(file, dest);
|
|
597
|
+
filesImported.push(dest);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
const subagentsDir = resolve4(rulesyncDir, "subagents");
|
|
601
|
+
if (existsSync6(subagentsDir)) {
|
|
602
|
+
const outAgentsDir = resolve4(packDir, "agents");
|
|
603
|
+
ensureDir(outAgentsDir);
|
|
604
|
+
const files = listFiles(subagentsDir, { extension: ".md" });
|
|
605
|
+
for (const file of files) {
|
|
606
|
+
const dest = join6(outAgentsDir, basename5(file));
|
|
607
|
+
copyFileSync4(file, dest);
|
|
608
|
+
filesImported.push(dest);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
const skillsDir = resolve4(rulesyncDir, "skills");
|
|
612
|
+
if (existsSync6(skillsDir)) {
|
|
613
|
+
const outSkillsDir = resolve4(packDir, "skills");
|
|
614
|
+
ensureDir(outSkillsDir);
|
|
615
|
+
const skillDirs = listDirs(skillsDir);
|
|
616
|
+
for (const skillDir of skillDirs) {
|
|
617
|
+
const skillName = basename5(skillDir);
|
|
618
|
+
if (skillName.startsWith("."))
|
|
619
|
+
continue;
|
|
620
|
+
const skillMd = join6(skillDir, "SKILL.md");
|
|
621
|
+
if (existsSync6(skillMd)) {
|
|
622
|
+
const outSkillDir = join6(outSkillsDir, skillName);
|
|
623
|
+
ensureDir(outSkillDir);
|
|
624
|
+
const rawSkill = readFileSync6(skillMd, "utf-8");
|
|
625
|
+
const normalized = normalizeImportedSkillMarkdown(rawSkill, skillName);
|
|
626
|
+
const dest = join6(outSkillDir, "SKILL.md");
|
|
627
|
+
writeFileSync5(dest, normalized.content);
|
|
628
|
+
filesImported.push(dest);
|
|
629
|
+
if (normalized.addedDescription) {
|
|
630
|
+
warnings.push(`skills/${skillName}/SKILL.md missing description; added import placeholder.`);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
const hooksJson = resolve4(rulesyncDir, "hooks.json");
|
|
636
|
+
if (existsSync6(hooksJson)) {
|
|
637
|
+
const outHooksDir = resolve4(packDir, "hooks");
|
|
638
|
+
ensureDir(outHooksDir);
|
|
639
|
+
copyFileSync4(hooksJson, join6(outHooksDir, "hooks.json"));
|
|
640
|
+
filesImported.push(join6(outHooksDir, "hooks.json"));
|
|
641
|
+
}
|
|
642
|
+
const mcpJson = resolve4(rulesyncDir, "mcp.json");
|
|
643
|
+
if (existsSync6(mcpJson)) {
|
|
644
|
+
copyFileSync4(mcpJson, join6(packDir, "mcp.json"));
|
|
645
|
+
filesImported.push(join6(packDir, "mcp.json"));
|
|
646
|
+
}
|
|
647
|
+
const aiIgnore = resolve4(rulesyncDir, ".aiignore");
|
|
648
|
+
const rulesyncIgnore = resolve4(projectRoot, ".rulesyncignore");
|
|
649
|
+
if (existsSync6(aiIgnore)) {
|
|
650
|
+
copyFileSync4(aiIgnore, join6(packDir, "ignore"));
|
|
651
|
+
filesImported.push(join6(packDir, "ignore"));
|
|
652
|
+
} else if (existsSync6(rulesyncIgnore)) {
|
|
653
|
+
copyFileSync4(rulesyncIgnore, join6(packDir, "ignore"));
|
|
654
|
+
filesImported.push(join6(packDir, "ignore"));
|
|
655
|
+
}
|
|
656
|
+
const packJson = {
|
|
657
|
+
name: "default",
|
|
658
|
+
version: "1.0.0",
|
|
659
|
+
description: "Imported from rulesync",
|
|
660
|
+
tags: ["imported", "rulesync"],
|
|
661
|
+
dependencies: [],
|
|
662
|
+
conflicts: [],
|
|
663
|
+
targets: "*",
|
|
664
|
+
features: "*"
|
|
665
|
+
};
|
|
666
|
+
writeFileSync5(join6(packDir, "pack.json"), JSON.stringify(packJson, null, 2) + `
|
|
667
|
+
`);
|
|
668
|
+
filesImported.push(join6(packDir, "pack.json"));
|
|
669
|
+
let configGenerated = false;
|
|
670
|
+
const rulesyncConfig = resolve4(projectRoot, "rulesync.jsonc");
|
|
671
|
+
if (existsSync6(rulesyncConfig)) {
|
|
672
|
+
const agentpacksConfig = convertRulesyncConfig(rulesyncConfig, packDir);
|
|
673
|
+
const configPath = resolve4(projectRoot, "agentpacks.jsonc");
|
|
674
|
+
writeFileSync5(configPath, agentpacksConfig);
|
|
675
|
+
configGenerated = true;
|
|
676
|
+
}
|
|
677
|
+
return { packDir, filesImported, warnings, configGenerated };
|
|
678
|
+
}
|
|
679
|
+
function convertRulesyncConfig(rulesyncPath, _packDir) {
|
|
680
|
+
const raw = readFileSync6(rulesyncPath, "utf-8");
|
|
681
|
+
const parsed = parseJsonc(raw);
|
|
682
|
+
const targets = parsed.targets ?? ["opencode", "cursor", "claudecode"];
|
|
683
|
+
const features = parsed.features ?? ["*"];
|
|
684
|
+
const baseDirs = parsed.baseDirs ?? ["."];
|
|
685
|
+
const global = parsed.global ?? false;
|
|
686
|
+
const deleteVal = parsed.delete ?? true;
|
|
687
|
+
const relPackDir = "./" + join6("packs", "default");
|
|
688
|
+
const config = {
|
|
689
|
+
$schema: "https://unpkg.com/agentpacks/schema.json",
|
|
690
|
+
packs: [relPackDir],
|
|
691
|
+
disabled: [],
|
|
692
|
+
targets,
|
|
693
|
+
features,
|
|
694
|
+
mode: baseDirs.length > 1 ? "monorepo" : "repo",
|
|
695
|
+
baseDirs,
|
|
696
|
+
global,
|
|
697
|
+
delete: deleteVal
|
|
698
|
+
};
|
|
699
|
+
return JSON.stringify(config, null, 2) + `
|
|
700
|
+
`;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
703
|
// src/cli/import-cmd.ts
|
|
704
704
|
import chalk from "chalk";
|
|
705
705
|
function runImport(projectRoot, options) {
|