agentpacks 0.3.0 → 0.4.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 (166) hide show
  1. package/README.md +168 -8
  2. package/dist/api.d.ts +2 -0
  3. package/dist/api.js +929 -409
  4. package/dist/cli/export-cmd.js +281 -149
  5. package/dist/cli/generate.js +740 -247
  6. package/dist/cli/import-cmd.js +57 -85
  7. package/dist/cli/info.d.ts +4 -0
  8. package/dist/cli/info.js +232 -0
  9. package/dist/cli/init.js +8 -36
  10. package/dist/cli/install.js +414 -129
  11. package/dist/cli/login.d.ts +9 -0
  12. package/dist/cli/login.js +202 -0
  13. package/dist/cli/models-explain.d.ts +16 -0
  14. package/dist/cli/models-explain.js +1205 -0
  15. package/dist/cli/pack/create.js +4 -32
  16. package/dist/cli/pack/enable.js +1 -29
  17. package/dist/cli/pack/list.js +266 -134
  18. package/dist/cli/pack/validate.js +274 -127
  19. package/dist/cli/publish.d.ts +8 -0
  20. package/dist/cli/publish.js +672 -0
  21. package/dist/cli/search.d.ts +12 -0
  22. package/dist/cli/search.js +210 -0
  23. package/dist/core/config.d.ts +2 -1
  24. package/dist/core/config.js +74 -117
  25. package/dist/core/dependency-resolver.js +4 -28
  26. package/dist/core/feature-merger.d.ts +7 -0
  27. package/dist/core/feature-merger.js +289 -29
  28. package/dist/core/index.js +283 -140
  29. package/dist/core/lockfile.js +0 -28
  30. package/dist/core/metarepo.js +74 -116
  31. package/dist/core/pack-loader.d.ts +2 -0
  32. package/dist/core/pack-loader.js +266 -133
  33. package/dist/core/profile-resolver.d.ts +75 -0
  34. package/dist/core/profile-resolver.js +111 -0
  35. package/dist/exporters/cursor-plugin.js +4 -32
  36. package/dist/exporters/index.js +4 -32
  37. package/dist/features/agents.d.ts +5 -0
  38. package/dist/features/agents.js +2 -30
  39. package/dist/features/commands.js +2 -30
  40. package/dist/features/hooks.js +2 -30
  41. package/dist/features/ignore.js +0 -28
  42. package/dist/features/index.d.ts +1 -0
  43. package/dist/features/index.js +176 -31
  44. package/dist/features/mcp.js +2 -30
  45. package/dist/features/models.d.ts +167 -0
  46. package/dist/features/models.js +293 -0
  47. package/dist/features/plugins.js +2 -30
  48. package/dist/features/rules.js +2 -30
  49. package/dist/features/skills.js +2 -30
  50. package/dist/importers/claude-code.js +10 -38
  51. package/dist/importers/cursor.js +15 -43
  52. package/dist/importers/opencode.js +16 -44
  53. package/dist/importers/rulesync.js +22 -50
  54. package/dist/index.js +1710 -538
  55. package/dist/node/api.js +929 -409
  56. package/dist/node/cli/export-cmd.js +281 -149
  57. package/dist/node/cli/generate.js +740 -247
  58. package/dist/node/cli/import-cmd.js +57 -85
  59. package/dist/node/cli/info.js +232 -0
  60. package/dist/node/cli/init.js +8 -36
  61. package/dist/node/cli/install.js +414 -129
  62. package/dist/node/cli/login.js +202 -0
  63. package/dist/node/cli/models-explain.js +1205 -0
  64. package/dist/node/cli/pack/create.js +4 -32
  65. package/dist/node/cli/pack/enable.js +1 -29
  66. package/dist/node/cli/pack/list.js +266 -134
  67. package/dist/node/cli/pack/validate.js +274 -127
  68. package/dist/node/cli/publish.js +672 -0
  69. package/dist/node/cli/search.js +210 -0
  70. package/dist/node/core/config.js +74 -117
  71. package/dist/node/core/dependency-resolver.js +4 -28
  72. package/dist/node/core/feature-merger.js +289 -29
  73. package/dist/node/core/index.js +283 -140
  74. package/dist/node/core/lockfile.js +0 -28
  75. package/dist/node/core/metarepo.js +74 -116
  76. package/dist/node/core/pack-loader.js +266 -133
  77. package/dist/node/core/profile-resolver.js +111 -0
  78. package/dist/node/exporters/cursor-plugin.js +4 -32
  79. package/dist/node/exporters/index.js +4 -32
  80. package/dist/node/features/agents.js +2 -30
  81. package/dist/node/features/commands.js +2 -30
  82. package/dist/node/features/hooks.js +2 -30
  83. package/dist/node/features/ignore.js +0 -28
  84. package/dist/node/features/index.js +176 -31
  85. package/dist/node/features/mcp.js +2 -30
  86. package/dist/node/features/models.js +293 -0
  87. package/dist/node/features/plugins.js +2 -30
  88. package/dist/node/features/rules.js +2 -30
  89. package/dist/node/features/skills.js +2 -30
  90. package/dist/node/importers/claude-code.js +10 -38
  91. package/dist/node/importers/cursor.js +15 -43
  92. package/dist/node/importers/opencode.js +16 -44
  93. package/dist/node/importers/rulesync.js +22 -50
  94. package/dist/node/index.js +1710 -538
  95. package/dist/node/sources/git-ref.js +7 -30
  96. package/dist/node/sources/git.js +7 -30
  97. package/dist/node/sources/index.js +337 -39
  98. package/dist/node/sources/local.js +0 -28
  99. package/dist/node/sources/npm-ref.js +0 -28
  100. package/dist/node/sources/npm.js +10 -37
  101. package/dist/node/sources/registry-ref.js +37 -0
  102. package/dist/node/sources/registry.js +355 -0
  103. package/dist/node/targets/additional-targets.js +196 -37
  104. package/dist/node/targets/agents-md.js +5 -33
  105. package/dist/node/targets/base-target.js +0 -28
  106. package/dist/node/targets/claude-code.js +211 -41
  107. package/dist/node/targets/codex-cli.js +7 -35
  108. package/dist/node/targets/copilot.js +202 -41
  109. package/dist/node/targets/cursor.js +188 -40
  110. package/dist/node/targets/gemini-cli.js +10 -38
  111. package/dist/node/targets/generic-md-target.js +196 -37
  112. package/dist/node/targets/index.js +414 -106
  113. package/dist/node/targets/opencode.js +171 -51
  114. package/dist/node/targets/registry.js +414 -106
  115. package/dist/node/utils/credentials.js +38 -0
  116. package/dist/node/utils/diff.js +22 -34
  117. package/dist/node/utils/filesystem.js +2 -30
  118. package/dist/node/utils/frontmatter.js +0 -28
  119. package/dist/node/utils/global.js +3 -31
  120. package/dist/node/utils/markdown.js +0 -28
  121. package/dist/node/utils/model-allowlist.js +110 -0
  122. package/dist/node/utils/model-guidance.js +78 -0
  123. package/dist/node/utils/registry-client.js +142 -0
  124. package/dist/node/utils/tarball.js +49 -0
  125. package/dist/sources/git-ref.js +7 -30
  126. package/dist/sources/git.d.ts +2 -2
  127. package/dist/sources/git.js +7 -30
  128. package/dist/sources/index.d.ts +2 -0
  129. package/dist/sources/index.js +337 -39
  130. package/dist/sources/local.js +0 -28
  131. package/dist/sources/npm-ref.js +0 -28
  132. package/dist/sources/npm.js +10 -37
  133. package/dist/sources/registry-ref.d.ts +30 -0
  134. package/dist/sources/registry-ref.js +37 -0
  135. package/dist/sources/registry.d.ts +18 -0
  136. package/dist/sources/registry.js +355 -0
  137. package/dist/targets/additional-targets.js +196 -37
  138. package/dist/targets/agents-md.js +5 -33
  139. package/dist/targets/base-target.d.ts +2 -0
  140. package/dist/targets/base-target.js +0 -28
  141. package/dist/targets/claude-code.js +211 -41
  142. package/dist/targets/codex-cli.js +7 -35
  143. package/dist/targets/copilot.js +202 -41
  144. package/dist/targets/cursor.js +188 -40
  145. package/dist/targets/gemini-cli.js +10 -38
  146. package/dist/targets/generic-md-target.js +196 -37
  147. package/dist/targets/index.js +414 -106
  148. package/dist/targets/opencode.js +171 -51
  149. package/dist/targets/registry.js +414 -106
  150. package/dist/utils/credentials.d.ts +19 -0
  151. package/dist/utils/credentials.js +38 -0
  152. package/dist/utils/diff.js +22 -34
  153. package/dist/utils/filesystem.js +2 -30
  154. package/dist/utils/frontmatter.js +0 -28
  155. package/dist/utils/global.js +3 -31
  156. package/dist/utils/markdown.js +0 -28
  157. package/dist/utils/model-allowlist.d.ts +39 -0
  158. package/dist/utils/model-allowlist.js +110 -0
  159. package/dist/utils/model-guidance.d.ts +6 -0
  160. package/dist/utils/model-guidance.js +78 -0
  161. package/dist/utils/registry-client.d.ts +141 -0
  162. package/dist/utils/registry-client.js +142 -0
  163. package/dist/utils/tarball.d.ts +13 -0
  164. package/dist/utils/tarball.js +49 -0
  165. package/package.json +171 -5
  166. package/templates/pack/models.json +38 -0
@@ -1,32 +1,4 @@
1
1
  import { createRequire } from "node:module";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __moduleCache = /* @__PURE__ */ new WeakMap;
7
- var __toCommonJS = (from) => {
8
- var entry = __moduleCache.get(from), desc;
9
- if (entry)
10
- return entry;
11
- entry = __defProp({}, "__esModule", { value: true });
12
- if (from && typeof from === "object" || typeof from === "function")
13
- __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
14
- get: () => from[key],
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- }));
17
- __moduleCache.set(from, entry);
18
- return entry;
19
- };
20
- var __export = (target, all) => {
21
- for (var name in all)
22
- __defProp(target, name, {
23
- get: all[name],
24
- enumerable: true,
25
- configurable: true,
26
- set: (newValue) => all[name] = () => newValue
27
- });
28
- };
29
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
30
2
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
31
3
 
32
4
  // src/utils/filesystem.ts
@@ -36,10 +8,10 @@ import {
36
8
  readFileSync,
37
9
  writeFileSync,
38
10
  readdirSync,
11
+ rmSync,
39
12
  statSync
40
13
  } from "fs";
41
14
  import { dirname, relative, join } from "path";
42
- import { removeSync } from "fs-extra";
43
15
  var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
44
16
  var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
45
17
  var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
@@ -80,7 +52,7 @@ function ensureDir(dirPath) {
80
52
  }
81
53
  function removeIfExists(targetPath) {
82
54
  if (existsSync(targetPath)) {
83
- removeSync(targetPath);
55
+ rmSync(targetPath, { recursive: true, force: true });
84
56
  }
85
57
  }
86
58
  function listFiles(dirPath, options = {}) {
@@ -159,10 +131,10 @@ function serializeFrontmatter(data, content) {
159
131
 
160
132
  // src/importers/rulesync.ts
161
133
  import { existsSync as existsSync2, readFileSync as readFileSync2, copyFileSync, writeFileSync as writeFileSync2 } from "fs";
162
- import { resolve as resolve2, join as join2, basename } from "path";
134
+ import { resolve, join as join2, basename } from "path";
163
135
  import { parse as parseJsonc } from "jsonc-parser";
164
136
  function importFromRulesync(projectRoot, outputPackDir) {
165
- const rulesyncDir = resolve2(projectRoot, ".rulesync");
137
+ const rulesyncDir = resolve(projectRoot, ".rulesync");
166
138
  const warnings = [];
167
139
  const filesImported = [];
168
140
  if (!existsSync2(rulesyncDir)) {
@@ -173,11 +145,11 @@ function importFromRulesync(projectRoot, outputPackDir) {
173
145
  configGenerated: false
174
146
  };
175
147
  }
176
- const packDir = outputPackDir ?? resolve2(projectRoot, "packs", "default");
148
+ const packDir = outputPackDir ?? resolve(projectRoot, "packs", "default");
177
149
  ensureDir(packDir);
178
- const rulesDir = resolve2(rulesyncDir, "rules");
150
+ const rulesDir = resolve(rulesyncDir, "rules");
179
151
  if (existsSync2(rulesDir)) {
180
- const outRulesDir = resolve2(packDir, "rules");
152
+ const outRulesDir = resolve(packDir, "rules");
181
153
  ensureDir(outRulesDir);
182
154
  const files = listFiles(rulesDir, { extension: ".md" });
183
155
  for (const file of files) {
@@ -186,9 +158,9 @@ function importFromRulesync(projectRoot, outputPackDir) {
186
158
  filesImported.push(dest);
187
159
  }
188
160
  }
189
- const commandsDir = resolve2(rulesyncDir, "commands");
161
+ const commandsDir = resolve(rulesyncDir, "commands");
190
162
  if (existsSync2(commandsDir)) {
191
- const outCommandsDir = resolve2(packDir, "commands");
163
+ const outCommandsDir = resolve(packDir, "commands");
192
164
  ensureDir(outCommandsDir);
193
165
  const files = listFiles(commandsDir, { extension: ".md" });
194
166
  for (const file of files) {
@@ -197,9 +169,9 @@ function importFromRulesync(projectRoot, outputPackDir) {
197
169
  filesImported.push(dest);
198
170
  }
199
171
  }
200
- const subagentsDir = resolve2(rulesyncDir, "subagents");
172
+ const subagentsDir = resolve(rulesyncDir, "subagents");
201
173
  if (existsSync2(subagentsDir)) {
202
- const outAgentsDir = resolve2(packDir, "agents");
174
+ const outAgentsDir = resolve(packDir, "agents");
203
175
  ensureDir(outAgentsDir);
204
176
  const files = listFiles(subagentsDir, { extension: ".md" });
205
177
  for (const file of files) {
@@ -208,9 +180,9 @@ function importFromRulesync(projectRoot, outputPackDir) {
208
180
  filesImported.push(dest);
209
181
  }
210
182
  }
211
- const skillsDir = resolve2(rulesyncDir, "skills");
183
+ const skillsDir = resolve(rulesyncDir, "skills");
212
184
  if (existsSync2(skillsDir)) {
213
- const outSkillsDir = resolve2(packDir, "skills");
185
+ const outSkillsDir = resolve(packDir, "skills");
214
186
  ensureDir(outSkillsDir);
215
187
  const skillDirs = listDirs(skillsDir);
216
188
  for (const skillDir of skillDirs) {
@@ -226,20 +198,20 @@ function importFromRulesync(projectRoot, outputPackDir) {
226
198
  }
227
199
  }
228
200
  }
229
- const hooksJson = resolve2(rulesyncDir, "hooks.json");
201
+ const hooksJson = resolve(rulesyncDir, "hooks.json");
230
202
  if (existsSync2(hooksJson)) {
231
- const outHooksDir = resolve2(packDir, "hooks");
203
+ const outHooksDir = resolve(packDir, "hooks");
232
204
  ensureDir(outHooksDir);
233
205
  copyFileSync(hooksJson, join2(outHooksDir, "hooks.json"));
234
206
  filesImported.push(join2(outHooksDir, "hooks.json"));
235
207
  }
236
- const mcpJson = resolve2(rulesyncDir, "mcp.json");
208
+ const mcpJson = resolve(rulesyncDir, "mcp.json");
237
209
  if (existsSync2(mcpJson)) {
238
210
  copyFileSync(mcpJson, join2(packDir, "mcp.json"));
239
211
  filesImported.push(join2(packDir, "mcp.json"));
240
212
  }
241
- const aiIgnore = resolve2(rulesyncDir, ".aiignore");
242
- const rulesyncIgnore = resolve2(projectRoot, ".rulesyncignore");
213
+ const aiIgnore = resolve(rulesyncDir, ".aiignore");
214
+ const rulesyncIgnore = resolve(projectRoot, ".rulesyncignore");
243
215
  if (existsSync2(aiIgnore)) {
244
216
  copyFileSync(aiIgnore, join2(packDir, "ignore"));
245
217
  filesImported.push(join2(packDir, "ignore"));
@@ -261,16 +233,16 @@ function importFromRulesync(projectRoot, outputPackDir) {
261
233
  `);
262
234
  filesImported.push(join2(packDir, "pack.json"));
263
235
  let configGenerated = false;
264
- const rulesyncConfig = resolve2(projectRoot, "rulesync.jsonc");
236
+ const rulesyncConfig = resolve(projectRoot, "rulesync.jsonc");
265
237
  if (existsSync2(rulesyncConfig)) {
266
- const agentpacksConfig = convertRulesyncConfig(rulesyncConfig, packDir, projectRoot);
267
- const configPath = resolve2(projectRoot, "agentpacks.jsonc");
238
+ const agentpacksConfig = convertRulesyncConfig(rulesyncConfig, packDir);
239
+ const configPath = resolve(projectRoot, "agentpacks.jsonc");
268
240
  writeFileSync2(configPath, agentpacksConfig);
269
241
  configGenerated = true;
270
242
  }
271
243
  return { packDir, filesImported, warnings, configGenerated };
272
244
  }
273
- function convertRulesyncConfig(rulesyncPath, packDir, projectRoot) {
245
+ function convertRulesyncConfig(rulesyncPath, _packDir) {
274
246
  const raw = readFileSync2(rulesyncPath, "utf-8");
275
247
  const parsed = parseJsonc(raw);
276
248
  const targets = parsed.targets ?? ["opencode", "cursor", "claudecode"];
@@ -296,9 +268,9 @@ function convertRulesyncConfig(rulesyncPath, packDir, projectRoot) {
296
268
 
297
269
  // src/importers/cursor.ts
298
270
  import { existsSync as existsSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3, copyFileSync as copyFileSync2 } from "fs";
299
- import { resolve as resolve3, join as join3, basename as basename2 } from "path";
271
+ import { resolve as resolve2, join as join3, basename as basename2 } from "path";
300
272
  function importFromCursor(projectRoot, outputPackDir) {
301
- const cursorDir = resolve3(projectRoot, ".cursor");
273
+ const cursorDir = resolve2(projectRoot, ".cursor");
302
274
  const warnings = [];
303
275
  const filesImported = [];
304
276
  if (!existsSync3(cursorDir)) {
@@ -309,11 +281,11 @@ function importFromCursor(projectRoot, outputPackDir) {
309
281
  configGenerated: false
310
282
  };
311
283
  }
312
- const packDir = outputPackDir ?? resolve3(projectRoot, "packs", "cursor-import");
284
+ const packDir = outputPackDir ?? resolve2(projectRoot, "packs", "cursor-import");
313
285
  ensureDir(packDir);
314
- const rulesDir = resolve3(cursorDir, "rules");
286
+ const rulesDir = resolve2(cursorDir, "rules");
315
287
  if (existsSync3(rulesDir)) {
316
- const outRulesDir = resolve3(packDir, "rules");
288
+ const outRulesDir = resolve2(packDir, "rules");
317
289
  ensureDir(outRulesDir);
318
290
  const files = listFiles(rulesDir, { extension: ".mdc" });
319
291
  for (const file of files) {
@@ -340,9 +312,9 @@ function importFromCursor(projectRoot, outputPackDir) {
340
312
  filesImported.push(dest);
341
313
  }
342
314
  }
343
- const agentsDir = resolve3(cursorDir, "agents");
315
+ const agentsDir = resolve2(cursorDir, "agents");
344
316
  if (existsSync3(agentsDir)) {
345
- const outDir = resolve3(packDir, "agents");
317
+ const outDir = resolve2(packDir, "agents");
346
318
  ensureDir(outDir);
347
319
  const files = listFiles(agentsDir, { extension: ".md" });
348
320
  for (const file of files) {
@@ -351,9 +323,9 @@ function importFromCursor(projectRoot, outputPackDir) {
351
323
  filesImported.push(dest);
352
324
  }
353
325
  }
354
- const skillsDir = resolve3(cursorDir, "skills");
326
+ const skillsDir = resolve2(cursorDir, "skills");
355
327
  if (existsSync3(skillsDir)) {
356
- const outDir = resolve3(packDir, "skills");
328
+ const outDir = resolve2(packDir, "skills");
357
329
  ensureDir(outDir);
358
330
  const dirs = listDirs(skillsDir);
359
331
  for (const dir of dirs) {
@@ -367,9 +339,9 @@ function importFromCursor(projectRoot, outputPackDir) {
367
339
  }
368
340
  }
369
341
  }
370
- const commandsDir = resolve3(cursorDir, "commands");
342
+ const commandsDir = resolve2(cursorDir, "commands");
371
343
  if (existsSync3(commandsDir)) {
372
- const outDir = resolve3(packDir, "commands");
344
+ const outDir = resolve2(packDir, "commands");
373
345
  ensureDir(outDir);
374
346
  const files = listFiles(commandsDir, { extension: ".md" });
375
347
  for (const file of files) {
@@ -378,12 +350,12 @@ function importFromCursor(projectRoot, outputPackDir) {
378
350
  filesImported.push(dest);
379
351
  }
380
352
  }
381
- const mcpJson = resolve3(cursorDir, "mcp.json");
353
+ const mcpJson = resolve2(cursorDir, "mcp.json");
382
354
  if (existsSync3(mcpJson)) {
383
355
  copyFileSync2(mcpJson, join3(packDir, "mcp.json"));
384
356
  filesImported.push(join3(packDir, "mcp.json"));
385
357
  }
386
- const cursorIgnore = resolve3(projectRoot, ".cursorignore");
358
+ const cursorIgnore = resolve2(projectRoot, ".cursorignore");
387
359
  if (existsSync3(cursorIgnore)) {
388
360
  copyFileSync2(cursorIgnore, join3(packDir, "ignore"));
389
361
  filesImported.push(join3(packDir, "ignore"));
@@ -423,12 +395,12 @@ function writePackJson(packDir, name, filesImported) {
423
395
 
424
396
  // src/importers/claude-code.ts
425
397
  import { existsSync as existsSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync4, copyFileSync as copyFileSync3 } from "fs";
426
- import { resolve as resolve4, join as join4, basename as basename3 } from "path";
398
+ import { resolve as resolve3, join as join4, basename as basename3 } from "path";
427
399
  function importFromClaudeCode(projectRoot, outputPackDir) {
428
400
  const warnings = [];
429
401
  const filesImported = [];
430
- const claudeDir = resolve4(projectRoot, ".claude");
431
- const hasClaudeMd = existsSync4(resolve4(projectRoot, "CLAUDE.md"));
402
+ const claudeDir = resolve3(projectRoot, ".claude");
403
+ const hasClaudeMd = existsSync4(resolve3(projectRoot, "CLAUDE.md"));
432
404
  const hasClaudeDir = existsSync4(claudeDir);
433
405
  if (!hasClaudeMd && !hasClaudeDir) {
434
406
  return {
@@ -438,12 +410,12 @@ function importFromClaudeCode(projectRoot, outputPackDir) {
438
410
  configGenerated: false
439
411
  };
440
412
  }
441
- const packDir = outputPackDir ?? resolve4(projectRoot, "packs", "claude-import");
413
+ const packDir = outputPackDir ?? resolve3(projectRoot, "packs", "claude-import");
442
414
  ensureDir(packDir);
443
- const rulesDir = resolve4(packDir, "rules");
415
+ const rulesDir = resolve3(packDir, "rules");
444
416
  ensureDir(rulesDir);
445
417
  if (hasClaudeMd) {
446
- const raw = readFileSync4(resolve4(projectRoot, "CLAUDE.md"), "utf-8");
418
+ const raw = readFileSync4(resolve3(projectRoot, "CLAUDE.md"), "utf-8");
447
419
  const ruleContent = [
448
420
  "---",
449
421
  "root: true",
@@ -458,7 +430,7 @@ function importFromClaudeCode(projectRoot, outputPackDir) {
458
430
  filesImported.push(dest);
459
431
  }
460
432
  if (hasClaudeDir) {
461
- const claudeRulesDir = resolve4(claudeDir, "rules");
433
+ const claudeRulesDir = resolve3(claudeDir, "rules");
462
434
  if (existsSync4(claudeRulesDir)) {
463
435
  const files = listFiles(claudeRulesDir, { extension: ".md" });
464
436
  for (const file of files) {
@@ -467,7 +439,7 @@ function importFromClaudeCode(projectRoot, outputPackDir) {
467
439
  filesImported.push(dest);
468
440
  }
469
441
  }
470
- const settingsPath = resolve4(claudeDir, "settings.json");
442
+ const settingsPath = resolve3(claudeDir, "settings.json");
471
443
  if (existsSync4(settingsPath)) {
472
444
  try {
473
445
  const raw = readFileSync4(settingsPath, "utf-8");
@@ -504,11 +476,11 @@ function importFromClaudeCode(projectRoot, outputPackDir) {
504
476
 
505
477
  // src/importers/opencode.ts
506
478
  import { existsSync as existsSync5, readFileSync as readFileSync5, writeFileSync as writeFileSync5, copyFileSync as copyFileSync4 } from "fs";
507
- import { resolve as resolve5, join as join5, basename as basename4 } from "path";
479
+ import { resolve as resolve4, join as join5, basename as basename4 } from "path";
508
480
  function importFromOpenCode(projectRoot, outputPackDir) {
509
481
  const warnings = [];
510
482
  const filesImported = [];
511
- const ocDir = resolve5(projectRoot, ".opencode");
483
+ const ocDir = resolve4(projectRoot, ".opencode");
512
484
  if (!existsSync5(ocDir)) {
513
485
  return {
514
486
  packDir: "",
@@ -517,14 +489,14 @@ function importFromOpenCode(projectRoot, outputPackDir) {
517
489
  configGenerated: false
518
490
  };
519
491
  }
520
- const packDir = outputPackDir ?? resolve5(projectRoot, "packs", "opencode-import");
492
+ const packDir = outputPackDir ?? resolve4(projectRoot, "packs", "opencode-import");
521
493
  ensureDir(packDir);
522
- importDirMd(resolve5(ocDir, "rules"), resolve5(packDir, "rules"), filesImported);
523
- importDirMd(resolve5(ocDir, "commands"), resolve5(packDir, "commands"), filesImported);
524
- importDirMd(resolve5(ocDir, "agents"), resolve5(packDir, "agents"), filesImported);
525
- const skillDir = resolve5(ocDir, "skill");
494
+ importDirMd(resolve4(ocDir, "rules"), resolve4(packDir, "rules"), filesImported);
495
+ importDirMd(resolve4(ocDir, "commands"), resolve4(packDir, "commands"), filesImported);
496
+ importDirMd(resolve4(ocDir, "agents"), resolve4(packDir, "agents"), filesImported);
497
+ const skillDir = resolve4(ocDir, "skill");
526
498
  if (existsSync5(skillDir)) {
527
- const outSkillDir = resolve5(packDir, "skills");
499
+ const outSkillDir = resolve4(packDir, "skills");
528
500
  ensureDir(outSkillDir);
529
501
  const dirs = listDirs(skillDir);
530
502
  for (const dir of dirs) {
@@ -540,9 +512,9 @@ function importFromOpenCode(projectRoot, outputPackDir) {
540
512
  }
541
513
  }
542
514
  }
543
- const pluginsDir = resolve5(ocDir, "plugins");
515
+ const pluginsDir = resolve4(ocDir, "plugins");
544
516
  if (existsSync5(pluginsDir)) {
545
- const outPluginsDir = resolve5(packDir, "plugins");
517
+ const outPluginsDir = resolve4(packDir, "plugins");
546
518
  ensureDir(outPluginsDir);
547
519
  const files = listFiles(pluginsDir);
548
520
  for (const file of files) {
@@ -553,9 +525,9 @@ function importFromOpenCode(projectRoot, outputPackDir) {
553
525
  }
554
526
  }
555
527
  }
556
- const agentsMd = resolve5(projectRoot, "AGENTS.md");
528
+ const agentsMd = resolve4(projectRoot, "AGENTS.md");
557
529
  if (existsSync5(agentsMd)) {
558
- const outRulesDir = resolve5(packDir, "rules");
530
+ const outRulesDir = resolve4(packDir, "rules");
559
531
  ensureDir(outRulesDir);
560
532
  const raw = readFileSync5(agentsMd, "utf-8");
561
533
  const ruleContent = [
@@ -571,7 +543,7 @@ function importFromOpenCode(projectRoot, outputPackDir) {
571
543
  writeFileSync5(dest2, ruleContent);
572
544
  filesImported.push(dest2);
573
545
  }
574
- const ocJson = resolve5(projectRoot, "opencode.json");
546
+ const ocJson = resolve4(projectRoot, "opencode.json");
575
547
  if (existsSync5(ocJson)) {
576
548
  try {
577
549
  const raw = readFileSync5(ocJson, "utf-8");
@@ -587,7 +559,7 @@ function importFromOpenCode(projectRoot, outputPackDir) {
587
559
  warnings.push("Failed to parse opencode.json");
588
560
  }
589
561
  }
590
- const ocIgnore = resolve5(projectRoot, ".opencodeignore");
562
+ const ocIgnore = resolve4(projectRoot, ".opencodeignore");
591
563
  if (existsSync5(ocIgnore)) {
592
564
  copyFileSync4(ocIgnore, join5(packDir, "ignore"));
593
565
  filesImported.push(join5(packDir, "ignore"));
@@ -0,0 +1,232 @@
1
+ import { createRequire } from "node:module";
2
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
+
4
+ // src/utils/registry-client.ts
5
+ var DEFAULT_REGISTRY_URL = "https://registry.agentpacks.dev";
6
+ function createRegistryClient(config) {
7
+ return new RegistryClient({
8
+ registryUrl: config?.registryUrl ?? DEFAULT_REGISTRY_URL,
9
+ authToken: config?.authToken,
10
+ timeout: config?.timeout ?? 30000
11
+ });
12
+ }
13
+
14
+ class RegistryClient {
15
+ config;
16
+ constructor(config) {
17
+ this.config = {
18
+ registryUrl: config.registryUrl.replace(/\/+$/, ""),
19
+ authToken: config.authToken,
20
+ timeout: config.timeout ?? 30000
21
+ };
22
+ }
23
+ async search(params) {
24
+ const searchParams = new URLSearchParams;
25
+ if (params.query)
26
+ searchParams.set("q", params.query);
27
+ if (params.tags?.length)
28
+ searchParams.set("tags", params.tags.join(","));
29
+ if (params.targets?.length)
30
+ searchParams.set("targets", params.targets.join(","));
31
+ if (params.features?.length)
32
+ searchParams.set("features", params.features.join(","));
33
+ if (params.author)
34
+ searchParams.set("author", params.author);
35
+ if (params.sort)
36
+ searchParams.set("sort", params.sort);
37
+ if (params.limit)
38
+ searchParams.set("limit", String(params.limit));
39
+ if (params.offset)
40
+ searchParams.set("offset", String(params.offset));
41
+ const url = `${this.config.registryUrl}/packs?${searchParams.toString()}`;
42
+ const res = await this.fetch(url);
43
+ return res;
44
+ }
45
+ async info(packName) {
46
+ const url = `${this.config.registryUrl}/packs/${encodeURIComponent(packName)}`;
47
+ const res = await this.fetch(url);
48
+ return res;
49
+ }
50
+ async download(packName, version = "latest") {
51
+ const url = `${this.config.registryUrl}/packs/${encodeURIComponent(packName)}/versions/${encodeURIComponent(version)}/download`;
52
+ const response = await fetch(url, {
53
+ headers: this.headers(),
54
+ signal: AbortSignal.timeout(this.config.timeout)
55
+ });
56
+ if (!response.ok) {
57
+ throw new RegistryApiError(response.status, `Failed to download ${packName}@${version}: ${response.statusText}`);
58
+ }
59
+ const integrity = response.headers.get("x-integrity") ?? "";
60
+ const data = await response.arrayBuffer();
61
+ return { data, integrity };
62
+ }
63
+ async publish(tarball, metadata) {
64
+ if (!this.config.authToken) {
65
+ throw new Error("Authentication required. Run `agentpacks login` first.");
66
+ }
67
+ const formData = new FormData;
68
+ formData.append("tarball", new Blob([tarball], { type: "application/gzip" }), `${metadata.name}-${metadata.version}.tgz`);
69
+ formData.append("metadata", JSON.stringify(metadata));
70
+ const url = `${this.config.registryUrl}/packs`;
71
+ const response = await fetch(url, {
72
+ method: "POST",
73
+ headers: {
74
+ Authorization: `Bearer ${this.config.authToken}`
75
+ },
76
+ body: formData,
77
+ signal: AbortSignal.timeout(this.config.timeout)
78
+ });
79
+ if (!response.ok) {
80
+ const body = await response.text();
81
+ throw new RegistryApiError(response.status, `Publish failed: ${body || response.statusText}`);
82
+ }
83
+ return await response.json();
84
+ }
85
+ async featured(limit) {
86
+ const url = limit ? `${this.config.registryUrl}/featured?limit=${limit}` : `${this.config.registryUrl}/featured`;
87
+ const res = await this.fetch(url);
88
+ return res.packs;
89
+ }
90
+ async tags() {
91
+ const url = `${this.config.registryUrl}/tags`;
92
+ const res = await this.fetch(url);
93
+ return res.tags;
94
+ }
95
+ async stats() {
96
+ const url = `${this.config.registryUrl}/stats`;
97
+ return await this.fetch(url);
98
+ }
99
+ async health() {
100
+ try {
101
+ const url = `${this.config.registryUrl}/health`;
102
+ await this.fetch(url);
103
+ return true;
104
+ } catch {
105
+ return false;
106
+ }
107
+ }
108
+ async fetch(url) {
109
+ const response = await fetch(url, {
110
+ headers: this.headers(),
111
+ signal: AbortSignal.timeout(this.config.timeout)
112
+ });
113
+ if (!response.ok) {
114
+ const body = await response.text();
115
+ throw new RegistryApiError(response.status, body || response.statusText);
116
+ }
117
+ return response.json();
118
+ }
119
+ headers() {
120
+ const h = {
121
+ Accept: "application/json"
122
+ };
123
+ if (this.config.authToken) {
124
+ h["Authorization"] = `Bearer ${this.config.authToken}`;
125
+ }
126
+ return h;
127
+ }
128
+ }
129
+
130
+ class RegistryApiError extends Error {
131
+ status;
132
+ constructor(status, message) {
133
+ super(message);
134
+ this.name = "RegistryApiError";
135
+ this.status = status;
136
+ }
137
+ }
138
+
139
+ // src/utils/credentials.ts
140
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
141
+ import { join, dirname } from "path";
142
+ import { homedir } from "os";
143
+ var CONFIG_DIR = join(homedir(), ".config", "agentpacks");
144
+ var CREDENTIALS_FILE = join(CONFIG_DIR, "credentials.json");
145
+ function loadCredentials() {
146
+ if (!existsSync(CREDENTIALS_FILE)) {
147
+ return { registryUrl: "https://registry.agentpacks.dev" };
148
+ }
149
+ try {
150
+ const raw = readFileSync(CREDENTIALS_FILE, "utf-8");
151
+ return JSON.parse(raw);
152
+ } catch {
153
+ return { registryUrl: "https://registry.agentpacks.dev" };
154
+ }
155
+ }
156
+ function saveCredentials(credentials) {
157
+ mkdirSync(dirname(CREDENTIALS_FILE), { recursive: true });
158
+ writeFileSync(CREDENTIALS_FILE, JSON.stringify(credentials, null, 2) + `
159
+ `, {
160
+ mode: 384
161
+ });
162
+ }
163
+ function clearCredentials() {
164
+ if (existsSync(CREDENTIALS_FILE)) {
165
+ writeFileSync(CREDENTIALS_FILE, JSON.stringify({ registryUrl: "https://registry.agentpacks.dev" }) + `
166
+ `);
167
+ }
168
+ }
169
+
170
+ // src/cli/info.ts
171
+ import chalk from "chalk";
172
+ async function runInfo(packName) {
173
+ const credentials = loadCredentials();
174
+ const client = createRegistryClient({
175
+ registryUrl: credentials.registryUrl,
176
+ authToken: credentials.token
177
+ });
178
+ try {
179
+ const pack = await client.info(packName);
180
+ console.log(chalk.bold(`
181
+ ${pack.displayName}`));
182
+ console.log(chalk.dim(` ${pack.name}`));
183
+ console.log(` ${pack.description}`);
184
+ console.log();
185
+ console.log(` ${chalk.dim("Author:")} ${pack.author}`);
186
+ console.log(` ${chalk.dim("License:")} ${pack.license}`);
187
+ console.log(` ${chalk.dim("Downloads:")} ${pack.downloads}`);
188
+ if (pack.homepage) {
189
+ console.log(` ${chalk.dim("Homepage:")} ${pack.homepage}`);
190
+ }
191
+ if (pack.repository) {
192
+ console.log(` ${chalk.dim("Repository:")} ${pack.repository}`);
193
+ }
194
+ console.log();
195
+ if (pack.tags.length > 0) {
196
+ console.log(` ${chalk.dim("Tags:")} ${pack.tags.join(", ")}`);
197
+ }
198
+ if (pack.targets.length > 0) {
199
+ console.log(` ${chalk.dim("Targets:")} ${pack.targets.join(", ")}`);
200
+ }
201
+ if (pack.features.length > 0) {
202
+ console.log(` ${chalk.dim("Features:")} ${pack.features.join(", ")}`);
203
+ }
204
+ console.log();
205
+ if (pack.versions.length > 0) {
206
+ console.log(chalk.bold(" Versions:"));
207
+ for (const v of pack.versions.slice(0, 10)) {
208
+ console.log(` ${v.version} — ${v.createdAt} (${v.fileCount} files, ${formatBytes(v.tarballSize)})`);
209
+ }
210
+ if (pack.versions.length > 10) {
211
+ console.log(chalk.dim(` ... and ${pack.versions.length - 10} more`));
212
+ }
213
+ }
214
+ console.log();
215
+ console.log(chalk.bold(" Install:"));
216
+ console.log(` registry:${pack.name}`);
217
+ console.log();
218
+ } catch (err) {
219
+ console.log(chalk.red(`Failed to get pack info: ${err instanceof Error ? err.message : String(err)}`));
220
+ process.exit(1);
221
+ }
222
+ }
223
+ function formatBytes(bytes) {
224
+ if (bytes < 1024)
225
+ return `${bytes} B`;
226
+ if (bytes < 1024 * 1024)
227
+ return `${(bytes / 1024).toFixed(1)} KB`;
228
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
229
+ }
230
+ export {
231
+ runInfo
232
+ };
@@ -1,32 +1,4 @@
1
1
  import { createRequire } from "node:module";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __moduleCache = /* @__PURE__ */ new WeakMap;
7
- var __toCommonJS = (from) => {
8
- var entry = __moduleCache.get(from), desc;
9
- if (entry)
10
- return entry;
11
- entry = __defProp({}, "__esModule", { value: true });
12
- if (from && typeof from === "object" || typeof from === "function")
13
- __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
14
- get: () => from[key],
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- }));
17
- __moduleCache.set(from, entry);
18
- return entry;
19
- };
20
- var __export = (target, all) => {
21
- for (var name in all)
22
- __defProp(target, name, {
23
- get: all[name],
24
- enumerable: true,
25
- configurable: true,
26
- set: (newValue) => all[name] = () => newValue
27
- });
28
- };
29
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
30
2
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
31
3
 
32
4
  // src/utils/filesystem.ts
@@ -36,10 +8,10 @@ import {
36
8
  readFileSync,
37
9
  writeFileSync,
38
10
  readdirSync,
11
+ rmSync,
39
12
  statSync
40
13
  } from "fs";
41
14
  import { dirname, relative, join } from "path";
42
- import { removeSync } from "fs-extra";
43
15
  var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
44
16
  var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
45
17
  var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
@@ -80,7 +52,7 @@ function ensureDir(dirPath) {
80
52
  }
81
53
  function removeIfExists(targetPath) {
82
54
  if (existsSync(targetPath)) {
83
- removeSync(targetPath);
55
+ rmSync(targetPath, { recursive: true, force: true });
84
56
  }
85
57
  }
86
58
  function listFiles(dirPath, options = {}) {
@@ -141,16 +113,16 @@ function getHeader(type) {
141
113
 
142
114
  // src/cli/init.ts
143
115
  import { existsSync as existsSync2, copyFileSync, writeFileSync as writeFileSync2 } from "fs";
144
- import { resolve as resolve2, join as join2 } from "path";
116
+ import { resolve, join as join2 } from "path";
145
117
  import chalk from "chalk";
146
118
  function runInit(projectRoot) {
147
- const configPath = resolve2(projectRoot, "agentpacks.jsonc");
148
- const packsDir = resolve2(projectRoot, "packs", "default");
119
+ const configPath = resolve(projectRoot, "agentpacks.jsonc");
120
+ const packsDir = resolve(projectRoot, "packs", "default");
149
121
  if (existsSync2(configPath)) {
150
122
  console.log(chalk.yellow("agentpacks.jsonc already exists. Skipping config creation."));
151
123
  } else {
152
- const templateDir = resolve2(import.meta.dirname, "..", "..", "templates");
153
- const templateConfig = resolve2(templateDir, "workspace", "agentpacks.jsonc");
124
+ const templateDir = resolve(import.meta.dirname, "..", "..", "templates");
125
+ const templateConfig = resolve(templateDir, "workspace", "agentpacks.jsonc");
154
126
  if (existsSync2(templateConfig)) {
155
127
  copyFileSync(templateConfig, configPath);
156
128
  } else {
@@ -197,7 +169,7 @@ function runInit(projectRoot) {
197
169
  };
198
170
  writeFileSync2(join2(packsDir, "pack.json"), JSON.stringify(packJson, null, 2) + `
199
171
  `);
200
- const templateRule = resolve2(import.meta.dirname, "..", "..", "templates", "pack", "rules", "overview.md");
172
+ const templateRule = resolve(import.meta.dirname, "..", "..", "templates", "pack", "rules", "overview.md");
201
173
  if (existsSync2(templateRule)) {
202
174
  copyFileSync(templateRule, join2(packsDir, "rules", "overview.md"));
203
175
  }