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.
Files changed (147) hide show
  1. package/dist/api.js +48 -3658
  2. package/dist/cli/export-cmd.js +7 -1027
  3. package/dist/cli/generate.js +39 -2731
  4. package/dist/cli/import-cmd.js +19 -770
  5. package/dist/cli/info.js +4 -231
  6. package/dist/cli/init.js +9 -185
  7. package/dist/cli/install.js +4 -902
  8. package/dist/cli/login.js +6 -201
  9. package/dist/cli/models-explain.js +14 -1266
  10. package/dist/cli/pack/create.js +4 -146
  11. package/dist/cli/pack/enable.js +2 -65
  12. package/dist/cli/pack/list.js +5 -893
  13. package/dist/cli/pack/validate.js +4 -642
  14. package/dist/cli/publish.js +8 -679
  15. package/dist/cli/search.js +4 -209
  16. package/dist/core/config.d.ts +1 -1
  17. package/dist/core/config.js +1 -145
  18. package/dist/core/dependency-resolver.js +1 -126
  19. package/dist/core/feature-merger.js +3 -398
  20. package/dist/core/index.js +5 -1129
  21. package/dist/core/lockfile.js +2 -43
  22. package/dist/core/metarepo.js +1 -183
  23. package/dist/core/pack-loader.js +4 -841
  24. package/dist/core/profile-resolver.js +1 -110
  25. package/dist/exporters/cursor-plugin.js +6 -404
  26. package/dist/exporters/index.js +6 -404
  27. package/dist/features/agents.js +3 -161
  28. package/dist/features/commands.js +3 -161
  29. package/dist/features/hooks.js +3 -153
  30. package/dist/features/ignore.js +2 -43
  31. package/dist/features/index.js +4 -629
  32. package/dist/features/mcp.js +3 -143
  33. package/dist/features/models.js +3 -292
  34. package/dist/features/plugins.js +3 -139
  35. package/dist/features/rules.d.ts +0 -1
  36. package/dist/features/rules.js +3 -169
  37. package/dist/features/skills.js +3 -228
  38. package/dist/importers/claude-code.js +6 -195
  39. package/dist/importers/cursor.js +5 -355
  40. package/dist/importers/opencode.js +6 -346
  41. package/dist/importers/rulesync.js +5 -365
  42. package/dist/index.js +89 -4934
  43. package/dist/node/api.js +48 -3659
  44. package/dist/node/cli/export-cmd.js +7 -1028
  45. package/dist/node/cli/generate.js +39 -2732
  46. package/dist/node/cli/import-cmd.js +19 -771
  47. package/dist/node/cli/info.js +4 -232
  48. package/dist/node/cli/init.js +9 -186
  49. package/dist/node/cli/install.js +4 -903
  50. package/dist/node/cli/login.js +6 -202
  51. package/dist/node/cli/models-explain.js +14 -1267
  52. package/dist/node/cli/pack/create.js +4 -147
  53. package/dist/node/cli/pack/enable.js +2 -66
  54. package/dist/node/cli/pack/list.js +5 -894
  55. package/dist/node/cli/pack/validate.js +4 -643
  56. package/dist/node/cli/publish.js +8 -680
  57. package/dist/node/cli/search.js +4 -210
  58. package/dist/node/core/config.js +1 -146
  59. package/dist/node/core/dependency-resolver.js +1 -127
  60. package/dist/node/core/feature-merger.js +3 -399
  61. package/dist/node/core/index.js +5 -1130
  62. package/dist/node/core/lockfile.js +2 -44
  63. package/dist/node/core/metarepo.js +1 -184
  64. package/dist/node/core/pack-loader.js +4 -842
  65. package/dist/node/core/profile-resolver.js +1 -111
  66. package/dist/node/exporters/cursor-plugin.js +6 -405
  67. package/dist/node/exporters/index.js +6 -405
  68. package/dist/node/features/agents.js +3 -162
  69. package/dist/node/features/commands.js +3 -162
  70. package/dist/node/features/hooks.js +3 -154
  71. package/dist/node/features/ignore.js +2 -44
  72. package/dist/node/features/index.js +4 -630
  73. package/dist/node/features/mcp.js +3 -144
  74. package/dist/node/features/models.js +3 -293
  75. package/dist/node/features/plugins.js +3 -140
  76. package/dist/node/features/rules.js +3 -170
  77. package/dist/node/features/skills.js +3 -229
  78. package/dist/node/importers/claude-code.js +6 -196
  79. package/dist/node/importers/cursor.js +5 -356
  80. package/dist/node/importers/opencode.js +6 -347
  81. package/dist/node/importers/rulesync.js +5 -366
  82. package/dist/node/index.js +89 -4935
  83. package/dist/node/sources/git-ref.js +1 -56
  84. package/dist/node/sources/git.js +2 -222
  85. package/dist/node/sources/index.js +4 -714
  86. package/dist/node/sources/local.js +1 -24
  87. package/dist/node/sources/npm-ref.js +1 -56
  88. package/dist/node/sources/npm.js +2 -184
  89. package/dist/node/sources/registry-ref.js +1 -37
  90. package/dist/node/sources/registry.js +4 -355
  91. package/dist/node/targets/additional-targets.js +6 -587
  92. package/dist/node/targets/base-target.js +1 -23
  93. package/dist/node/targets/claude-code.js +6 -714
  94. package/dist/node/targets/codex-cli.js +3 -324
  95. package/dist/node/targets/copilot.js +5 -603
  96. package/dist/node/targets/cursor.js +6 -700
  97. package/dist/node/targets/gemini-cli.js +10 -319
  98. package/dist/node/targets/generic-md-target.js +6 -478
  99. package/dist/node/targets/index.js +32 -1873
  100. package/dist/node/targets/mistral-vibe.js +7 -661
  101. package/dist/node/targets/opencode.js +13 -723
  102. package/dist/node/targets/registry.js +32 -1864
  103. package/dist/node/utils/credentials.js +3 -38
  104. package/dist/node/utils/diff.js +5 -132
  105. package/dist/node/utils/filesystem.js +3 -124
  106. package/dist/node/utils/frontmatter.js +1 -24
  107. package/dist/node/utils/global.js +1 -53
  108. package/dist/node/utils/markdown.js +3 -30
  109. package/dist/node/utils/model-allowlist.js +1 -126
  110. package/dist/node/utils/model-guidance.js +2 -78
  111. package/dist/node/utils/registry-client.js +1 -142
  112. package/dist/node/utils/tarball.js +1 -49
  113. package/dist/sources/git-ref.js +1 -55
  114. package/dist/sources/git.js +2 -221
  115. package/dist/sources/index.js +4 -713
  116. package/dist/sources/local.js +1 -23
  117. package/dist/sources/npm-ref.js +1 -55
  118. package/dist/sources/npm.js +2 -183
  119. package/dist/sources/registry-ref.js +1 -36
  120. package/dist/sources/registry.js +4 -354
  121. package/dist/targets/additional-targets.js +6 -586
  122. package/dist/targets/base-target.js +1 -22
  123. package/dist/targets/claude-code.js +6 -713
  124. package/dist/targets/codex-cli.js +3 -323
  125. package/dist/targets/copilot.js +5 -602
  126. package/dist/targets/cursor.js +6 -699
  127. package/dist/targets/gemini-cli.js +10 -318
  128. package/dist/targets/generic-md-target.js +6 -477
  129. package/dist/targets/index.d.ts +0 -1
  130. package/dist/targets/index.js +32 -1872
  131. package/dist/targets/mistral-vibe.js +7 -660
  132. package/dist/targets/opencode.js +13 -722
  133. package/dist/targets/registry.js +32 -1863
  134. package/dist/utils/credentials.js +3 -37
  135. package/dist/utils/diff.js +5 -131
  136. package/dist/utils/filesystem.js +3 -123
  137. package/dist/utils/frontmatter.js +1 -23
  138. package/dist/utils/global.js +1 -52
  139. package/dist/utils/markdown.js +3 -29
  140. package/dist/utils/model-allowlist.js +1 -125
  141. package/dist/utils/model-guidance.js +2 -77
  142. package/dist/utils/registry-client.js +1 -141
  143. package/dist/utils/tarball.js +1 -48
  144. package/package.json +4 -16
  145. package/dist/node/targets/agents-md.js +0 -211
  146. package/dist/targets/agents-md.d.ts +0 -13
  147. package/dist/targets/agents-md.js +0 -211
@@ -1,347 +1,6 @@
1
- import { createRequire } from "node:module";
2
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
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/skills.ts
133
- import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
134
- import { basename, join as join2 } from "path";
135
- var SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
136
- var SKILL_NAME_MAX_LENGTH = 64;
137
- function parseSkills(skillsDir, packName) {
138
- const dirs = listDirs(skillsDir);
139
- const skills = [];
140
- for (const dir of dirs) {
141
- const skillMd = join2(dir, "SKILL.md");
142
- if (existsSync2(skillMd)) {
143
- skills.push(parseSkillFile(skillMd, dir, packName));
144
- }
145
- }
146
- return skills;
147
- }
148
- function parseSkillFile(filepath, skillDir, packName) {
149
- const raw = readFileSync2(filepath, "utf-8");
150
- const { data, content } = parseFrontmatter(raw);
151
- return {
152
- name: data.name ?? basename(skillDir),
153
- sourcePath: filepath,
154
- sourceDir: skillDir,
155
- packName,
156
- meta: data,
157
- content
158
- };
159
- }
160
- function buildSkillFrontmatter(skill) {
161
- return {
162
- ...skill.meta,
163
- name: skill.name
164
- };
165
- }
166
- function serializeSkill(skill) {
167
- return serializeFrontmatter(buildSkillFrontmatter(skill), skill.content);
168
- }
169
- function normalizeImportedSkillMarkdown(source, skillName) {
170
- const { data, content } = parseFrontmatter(source);
171
- const normalized = {
172
- ...data,
173
- name: skillName
174
- };
175
- let addedDescription = false;
176
- const description = normalized.description;
177
- if (typeof description !== "string" || description.trim().length === 0) {
178
- normalized.description = `Imported skill: ${skillName}`;
179
- addedDescription = true;
180
- }
181
- return {
182
- content: serializeFrontmatter(normalized, content),
183
- addedDescription
184
- };
185
- }
186
- function validateAgentSkillsFrontmatter(skill) {
187
- const errors = [];
188
- const dirName = basename(skill.sourceDir);
189
- const declaredName = skill.meta.name;
190
- if (typeof declaredName !== "string" || declaredName.trim().length === 0) {
191
- errors.push('Missing required frontmatter field "name".');
192
- } else {
193
- if (declaredName.length > SKILL_NAME_MAX_LENGTH) {
194
- errors.push(`Invalid "name": must be at most ${SKILL_NAME_MAX_LENGTH} characters.`);
195
- }
196
- if (!SKILL_NAME_PATTERN.test(declaredName)) {
197
- errors.push('Invalid "name": use lowercase letters, numbers, and single hyphens only.');
198
- }
199
- if (declaredName !== dirName) {
200
- errors.push(`Invalid "name": must match containing directory "${dirName}".`);
201
- }
202
- }
203
- const description = skill.meta.description;
204
- if (typeof description !== "string" || description.trim().length === 0) {
205
- errors.push('Missing required frontmatter field "description".');
206
- }
207
- const allowedTools = skill.meta["allowed-tools"];
208
- if (allowedTools !== undefined && (!Array.isArray(allowedTools) || allowedTools.some((tool) => typeof tool !== "string" || tool.length === 0))) {
209
- errors.push('Invalid "allowed-tools": expected an array of non-empty strings.');
210
- }
211
- return errors;
212
- }
213
- function skillMatchesTarget(skill, targetId) {
214
- const { targets } = skill.meta;
215
- if (!targets || targets === "*")
216
- return true;
217
- if (Array.isArray(targets) && targets.includes("*"))
218
- return true;
219
- return Array.isArray(targets) && targets.includes(targetId);
220
- }
221
-
222
- // src/importers/opencode.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 importFromOpenCode(projectRoot, outputPackDir) {
226
- const warnings = [];
227
- const filesImported = [];
228
- const ocDir = resolve(projectRoot, ".opencode");
229
- if (!existsSync3(ocDir)) {
230
- return {
231
- packDir: "",
232
- filesImported: [],
233
- warnings: ["No .opencode/ directory found."],
234
- configGenerated: false
235
- };
236
- }
237
- const packDir = outputPackDir ?? resolve(projectRoot, "packs", "opencode-import");
238
- ensureDir(packDir);
239
- importDirMd(resolve(ocDir, "rules"), resolve(packDir, "rules"), filesImported);
240
- importDirMd(resolve(ocDir, "commands"), resolve(packDir, "commands"), filesImported);
241
- importDirMd(resolve(ocDir, "agents"), resolve(packDir, "agents"), filesImported);
242
- const skillDir = resolve(ocDir, "skill");
243
- if (existsSync3(skillDir)) {
244
- const outSkillDir = resolve(packDir, "skills");
245
- ensureDir(outSkillDir);
246
- const dirs = listDirs(skillDir);
247
- for (const dir of dirs) {
248
- const name = basename2(dir);
249
- if (name.startsWith("."))
250
- continue;
251
- const skillMd = join3(dir, "SKILL.md");
252
- if (existsSync3(skillMd)) {
253
- const outDir = join3(outSkillDir, name);
254
- ensureDir(outDir);
255
- const rawSkill = readFileSync3(skillMd, "utf-8");
256
- const normalized = normalizeImportedSkillMarkdown(rawSkill, name);
257
- const dest2 = join3(outDir, "SKILL.md");
258
- writeFileSync2(dest2, normalized.content);
259
- filesImported.push(dest2);
260
- if (normalized.addedDescription) {
261
- warnings.push(`skills/${name}/SKILL.md missing description; added import placeholder.`);
262
- }
263
- }
264
- }
265
- }
266
- const pluginsDir = resolve(ocDir, "plugins");
267
- if (existsSync3(pluginsDir)) {
268
- const outPluginsDir = resolve(packDir, "plugins");
269
- ensureDir(outPluginsDir);
270
- const files = listFiles(pluginsDir);
271
- for (const file of files) {
272
- if (file.endsWith(".ts") || file.endsWith(".js")) {
273
- const dest2 = join3(outPluginsDir, basename2(file));
274
- copyFileSync(file, dest2);
275
- filesImported.push(dest2);
276
- }
277
- }
278
- }
279
- const agentsMd = resolve(projectRoot, "AGENTS.md");
280
- if (existsSync3(agentsMd)) {
281
- const outRulesDir = resolve(packDir, "rules");
282
- ensureDir(outRulesDir);
283
- const raw = readFileSync3(agentsMd, "utf-8");
284
- const ruleContent = [
285
- "---",
286
- "root: true",
287
- 'description: "AGENTS.md root rules"',
288
- "---",
289
- "",
290
- raw
291
- ].join(`
292
- `);
293
- const dest2 = join3(outRulesDir, "agents-md-root.md");
294
- writeFileSync2(dest2, ruleContent);
295
- filesImported.push(dest2);
296
- }
297
- const ocJson = resolve(projectRoot, "opencode.json");
298
- if (existsSync3(ocJson)) {
299
- try {
300
- const raw = readFileSync3(ocJson, "utf-8");
301
- const config = JSON.parse(raw);
302
- const mcpObj = config.mcp;
303
- if (mcpObj) {
304
- const dest2 = join3(packDir, "mcp.json");
305
- writeFileSync2(dest2, JSON.stringify({ servers: mcpObj }, null, 2) + `
306
- `);
307
- filesImported.push(dest2);
308
- }
309
- } catch {
310
- warnings.push("Failed to parse opencode.json");
311
- }
312
- }
313
- const ocIgnore = resolve(projectRoot, ".opencodeignore");
314
- if (existsSync3(ocIgnore)) {
315
- copyFileSync(ocIgnore, join3(packDir, "ignore"));
316
- filesImported.push(join3(packDir, "ignore"));
317
- }
318
- const packJson = {
319
- name: "opencode-import",
320
- version: "1.0.0",
321
- description: "Imported from OpenCode",
322
- tags: ["imported", "opencode"],
323
- dependencies: [],
324
- conflicts: [],
325
- targets: "*",
326
- features: "*"
327
- };
328
- const dest = join3(packDir, "pack.json");
329
- writeFileSync2(dest, JSON.stringify(packJson, null, 2) + `
330
- `);
331
- filesImported.push(dest);
332
- return { packDir, filesImported, warnings, configGenerated: false };
333
- }
334
- function importDirMd(srcDir, outDir, filesImported) {
335
- if (!existsSync3(srcDir))
336
- return;
337
- ensureDir(outDir);
338
- const files = listFiles(srcDir, { extension: ".md" });
339
- for (const file of files) {
340
- const dest = join3(outDir, basename2(file));
341
- copyFileSync(file, dest);
342
- filesImported.push(dest);
343
- }
344
- }
345
- export {
346
- importFromOpenCode
347
- };
1
+ import{createRequire as o}from"node:module";var Kq=o(import.meta.url);import{existsSync as H,mkdirSync as s,readdirSync as S,readFileSync as l,rmSync as r,statSync as y,writeFileSync as i}from"fs";import{dirname as t,join as u,relative as e}from"path";var h="<!-- Generated by agentpacks. DO NOT EDIT. -->",k="// Generated by agentpacks. DO NOT EDIT.",m="// Generated by agentpacks. DO NOT EDIT.";function qq(q,B,Q={}){let{header:U=!0,type:W}=Q,V=W??Bq(q);J(t(q));let Z=B;if(U){let O=Qq(V);if(O)Z=`${O}
2
+ ${B}`}i(q,Z,"utf-8")}function Lq(q,B,Q={}){let U=JSON.stringify(B,null,2);qq(q,U+`
3
+ `,{...Q,type:"json"})}function D(q){if(!H(q))return null;return l(q,"utf-8")}function zq(q){let B=D(q);if(B===null)return null;return JSON.parse(B)}function J(q){if(!H(q))s(q,{recursive:!0})}function Gq(q){if(H(q))r(q,{recursive:!0,force:!0})}function b(q,B={}){let{extension:Q,recursive:U=!1}=B;if(!H(q))return[];let W=[],V=S(q);for(let Z of V){let O=u(q,Z),z=y(O);if(z.isDirectory()&&U)W.push(...b(O,B));else if(z.isFile()){if(!Q||Z.endsWith(Q))W.push(O)}}return W}function T(q){if(!H(q))return[];return S(q).map((B)=>u(q,B)).filter((B)=>y(B).isDirectory())}function Hq(q,B){return e(q,B)}function bq(q){let B=D(q);if(!B)return!1;return B.startsWith(h)||B.startsWith(k)||B.startsWith(m)}function Bq(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 h;case"json":return k;case"js":case"ts":return m;default:return null}}import f from"gray-matter";function x(q){let{data:B,content:Q}=f(q);return{data:B,content:Q.trim(),raw:q}}function M(q,B){let Q=Object.fromEntries(Object.entries(q).filter(([,U])=>U!==void 0));if(Object.keys(Q).length===0)return B;return f.stringify(B,Q)}import{existsSync as Uq,readFileSync as Vq}from"fs";import{basename as d,join as Wq}from"path";var Yq=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,p=64;function Iq(q,B){let Q=T(q),U=[];for(let W of Q){let V=Wq(W,"SKILL.md");if(Uq(V))U.push(Zq(V,W,B))}return U}function Zq(q,B,Q){let U=Vq(q,"utf-8"),{data:W,content:V}=x(U);return{name:W.name??d(B),sourcePath:q,sourceDir:B,packName:Q,meta:W,content:V}}function $q(q){return{...q.meta,name:q.name}}function Fq(q){return M($q(q),q.content)}function c(q,B){let{data:Q,content:U}=x(q),W={...Q,name:B},V=!1,Z=W.description;if(typeof Z!=="string"||Z.trim().length===0)W.description=`Imported skill: ${B}`,V=!0;return{content:M(W,U),addedDescription:V}}function Rq(q){let B=[],Q=d(q.sourceDir),U=q.meta.name;if(typeof U!=="string"||U.trim().length===0)B.push('Missing required frontmatter field "name".');else{if(U.length>p)B.push(`Invalid "name": must be at most ${p} characters.`);if(!Yq.test(U))B.push('Invalid "name": use lowercase letters, numbers, and single hyphens only.');if(U!==Q)B.push(`Invalid "name": must match containing directory "${Q}".`)}let W=q.meta.description;if(typeof W!=="string"||W.trim().length===0)B.push('Missing required frontmatter field "description".');let V=q.meta["allowed-tools"];if(V!==void 0&&(!Array.isArray(V)||V.some((Z)=>typeof Z!=="string"||Z.length===0)))B.push('Invalid "allowed-tools": expected an array of non-empty strings.');return B}function gq(q,B){let{targets:Q}=q.meta;if(!Q||Q==="*")return!0;if(Array.isArray(Q)&&Q.includes("*"))return!0;return Array.isArray(Q)&&Q.includes(B)}import{copyFileSync as _,existsSync as L,readFileSync as A,writeFileSync as w}from"fs";import{basename as I,join as C,resolve as Y}from"path";function yq(q,B){let Q=[],U=[],W=Y(q,".opencode");if(!L(W))return{packDir:"",filesImported:[],warnings:["No .opencode/ directory found."],configGenerated:!1};let V=B??Y(q,"packs","opencode-import");J(V),v(Y(W,"rules"),Y(V,"rules"),U),v(Y(W,"commands"),Y(V,"commands"),U),v(Y(W,"agents"),Y(V,"agents"),U);let Z=Y(W,"skill");if(L(Z)){let K=Y(V,"skills");J(K);let G=T(Z);for(let X of G){let $=I(X);if($.startsWith("."))continue;let P=C(X,"SKILL.md");if(L(P)){let N=C(K,$);J(N);let a=A(P,"utf-8"),j=c(a,$),E=C(N,"SKILL.md");if(w(E,j.content),U.push(E),j.addedDescription)Q.push(`skills/${$}/SKILL.md missing description; added import placeholder.`)}}}let O=Y(W,"plugins");if(L(O)){let K=Y(V,"plugins");J(K);let G=b(O);for(let X of G)if(X.endsWith(".ts")||X.endsWith(".js")){let $=C(K,I(X));_(X,$),U.push($)}}let z=Y(q,"AGENTS.md");if(L(z)){let K=Y(V,"rules");J(K);let X=["---","root: true",'description: "AGENTS.md root rules"',"---","",A(z,"utf-8")].join(`
4
+ `),$=C(K,"agents-md-root.md");w($,X),U.push($)}let F=Y(q,"opencode.json");if(L(F))try{let K=A(F,"utf-8"),X=JSON.parse(K).mcp;if(X){let $=C(V,"mcp.json");w($,JSON.stringify({servers:X},null,2)+`
5
+ `),U.push($)}}catch{Q.push("Failed to parse opencode.json")}let R=Y(q,".opencodeignore");if(L(R))_(R,C(V,"ignore")),U.push(C(V,"ignore"));let n={name:"opencode-import",version:"1.0.0",description:"Imported from OpenCode",tags:["imported","opencode"],dependencies:[],conflicts:[],targets:"*",features:"*"},g=C(V,"pack.json");return w(g,JSON.stringify(n,null,2)+`
6
+ `),U.push(g),{packDir:V,filesImported:U,warnings:Q,configGenerated:!1}}function v(q,B,Q){if(!L(q))return;J(B);let U=b(q,{extension:".md"});for(let W of U){let V=C(B,I(W));_(W,V),Q.push(V)}}export{yq as importFromOpenCode};