agentpacks 0.2.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 (172) hide show
  1. package/dist/api.d.ts +32 -0
  2. package/dist/api.js +2852 -0
  3. package/dist/cli/export-cmd.d.ts +12 -0
  4. package/dist/cli/export-cmd.js +786 -0
  5. package/dist/cli/generate.d.ts +13 -0
  6. package/dist/cli/generate.js +2018 -0
  7. package/dist/cli/import-cmd.d.ts +9 -0
  8. package/dist/cli/import-cmd.js +691 -0
  9. package/dist/cli/init.d.ts +5 -0
  10. package/dist/cli/init.js +214 -0
  11. package/dist/cli/install.d.ts +11 -0
  12. package/dist/cli/install.js +610 -0
  13. package/dist/cli/pack/create.d.ts +4 -0
  14. package/dist/cli/pack/create.js +175 -0
  15. package/dist/cli/pack/enable.d.ts +8 -0
  16. package/dist/cli/pack/enable.js +96 -0
  17. package/dist/cli/pack/list.d.ts +4 -0
  18. package/dist/cli/pack/list.js +699 -0
  19. package/dist/cli/pack/validate.d.ts +4 -0
  20. package/dist/cli/pack/validate.js +364 -0
  21. package/dist/core/config.d.ts +77 -0
  22. package/dist/core/config.js +181 -0
  23. package/dist/core/dependency-resolver.d.ts +38 -0
  24. package/dist/core/dependency-resolver.js +151 -0
  25. package/dist/core/feature-merger.d.ts +61 -0
  26. package/dist/core/feature-merger.js +139 -0
  27. package/dist/core/index.d.ts +5 -0
  28. package/dist/core/index.js +924 -0
  29. package/dist/core/lockfile.d.ts +50 -0
  30. package/dist/core/lockfile.js +72 -0
  31. package/dist/core/metarepo.d.ts +26 -0
  32. package/dist/core/metarepo.js +218 -0
  33. package/dist/core/pack-loader.d.ts +61 -0
  34. package/dist/core/pack-loader.js +646 -0
  35. package/dist/exporters/cursor-plugin.d.ts +29 -0
  36. package/dist/exporters/cursor-plugin.js +258 -0
  37. package/dist/exporters/index.d.ts +1 -0
  38. package/dist/exporters/index.js +258 -0
  39. package/dist/features/agents.d.ts +48 -0
  40. package/dist/features/agents.js +190 -0
  41. package/dist/features/commands.d.ts +33 -0
  42. package/dist/features/commands.js +190 -0
  43. package/dist/features/hooks.d.ts +33 -0
  44. package/dist/features/hooks.js +182 -0
  45. package/dist/features/ignore.d.ts +21 -0
  46. package/dist/features/ignore.js +72 -0
  47. package/dist/features/index.d.ts +8 -0
  48. package/dist/features/index.js +426 -0
  49. package/dist/features/mcp.d.ts +34 -0
  50. package/dist/features/mcp.js +172 -0
  51. package/dist/features/plugins.d.ts +23 -0
  52. package/dist/features/plugins.js +168 -0
  53. package/dist/features/rules.d.ts +53 -0
  54. package/dist/features/rules.js +198 -0
  55. package/dist/features/skills.d.ts +42 -0
  56. package/dist/features/skills.js +198 -0
  57. package/dist/importers/claude-code.d.ts +5 -0
  58. package/dist/importers/claude-code.js +224 -0
  59. package/dist/importers/cursor.d.ts +5 -0
  60. package/dist/importers/cursor.js +288 -0
  61. package/dist/importers/opencode.d.ts +5 -0
  62. package/dist/importers/opencode.js +261 -0
  63. package/dist/importers/rulesync.d.ts +14 -0
  64. package/dist/importers/rulesync.js +280 -0
  65. package/dist/index.d.ts +2 -0
  66. package/dist/index.js +3464 -0
  67. package/dist/node/api.js +2852 -0
  68. package/dist/node/cli/export-cmd.js +786 -0
  69. package/dist/node/cli/generate.js +2018 -0
  70. package/dist/node/cli/import-cmd.js +691 -0
  71. package/dist/node/cli/init.js +214 -0
  72. package/dist/node/cli/install.js +610 -0
  73. package/dist/node/cli/pack/create.js +175 -0
  74. package/dist/node/cli/pack/enable.js +96 -0
  75. package/dist/node/cli/pack/list.js +699 -0
  76. package/dist/node/cli/pack/validate.js +364 -0
  77. package/dist/node/core/config.js +181 -0
  78. package/dist/node/core/dependency-resolver.js +151 -0
  79. package/dist/node/core/feature-merger.js +139 -0
  80. package/dist/node/core/index.js +924 -0
  81. package/dist/node/core/lockfile.js +72 -0
  82. package/dist/node/core/metarepo.js +218 -0
  83. package/dist/node/core/pack-loader.js +646 -0
  84. package/dist/node/exporters/cursor-plugin.js +258 -0
  85. package/dist/node/exporters/index.js +258 -0
  86. package/dist/node/features/agents.js +190 -0
  87. package/dist/node/features/commands.js +190 -0
  88. package/dist/node/features/hooks.js +182 -0
  89. package/dist/node/features/ignore.js +72 -0
  90. package/dist/node/features/index.js +426 -0
  91. package/dist/node/features/mcp.js +172 -0
  92. package/dist/node/features/plugins.js +168 -0
  93. package/dist/node/features/rules.js +198 -0
  94. package/dist/node/features/skills.js +198 -0
  95. package/dist/node/importers/claude-code.js +224 -0
  96. package/dist/node/importers/cursor.js +288 -0
  97. package/dist/node/importers/opencode.js +261 -0
  98. package/dist/node/importers/rulesync.js +280 -0
  99. package/dist/node/index.js +3464 -0
  100. package/dist/node/sources/git-ref.js +79 -0
  101. package/dist/node/sources/git.js +245 -0
  102. package/dist/node/sources/index.js +416 -0
  103. package/dist/node/sources/local.js +52 -0
  104. package/dist/node/sources/npm-ref.js +84 -0
  105. package/dist/node/sources/npm.js +211 -0
  106. package/dist/node/targets/additional-targets.js +428 -0
  107. package/dist/node/targets/agents-md.js +239 -0
  108. package/dist/node/targets/base-target.js +51 -0
  109. package/dist/node/targets/claude-code.js +490 -0
  110. package/dist/node/targets/codex-cli.js +297 -0
  111. package/dist/node/targets/copilot.js +390 -0
  112. package/dist/node/targets/cursor.js +441 -0
  113. package/dist/node/targets/gemini-cli.js +352 -0
  114. package/dist/node/targets/generic-md-target.js +319 -0
  115. package/dist/node/targets/index.js +1351 -0
  116. package/dist/node/targets/opencode.js +556 -0
  117. package/dist/node/targets/registry.js +1343 -0
  118. package/dist/node/utils/diff.js +144 -0
  119. package/dist/node/utils/filesystem.js +152 -0
  120. package/dist/node/utils/frontmatter.js +52 -0
  121. package/dist/node/utils/global.js +81 -0
  122. package/dist/node/utils/markdown.js +62 -0
  123. package/dist/sources/git-ref.d.ts +27 -0
  124. package/dist/sources/git-ref.js +79 -0
  125. package/dist/sources/git.d.ts +29 -0
  126. package/dist/sources/git.js +245 -0
  127. package/dist/sources/index.d.ts +5 -0
  128. package/dist/sources/index.js +416 -0
  129. package/dist/sources/local.d.ts +8 -0
  130. package/dist/sources/local.js +52 -0
  131. package/dist/sources/npm-ref.d.ts +30 -0
  132. package/dist/sources/npm-ref.js +84 -0
  133. package/dist/sources/npm.d.ts +20 -0
  134. package/dist/sources/npm.js +211 -0
  135. package/dist/targets/additional-targets.d.ts +65 -0
  136. package/dist/targets/additional-targets.js +428 -0
  137. package/dist/targets/agents-md.d.ts +13 -0
  138. package/dist/targets/agents-md.js +239 -0
  139. package/dist/targets/base-target.d.ts +61 -0
  140. package/dist/targets/base-target.js +51 -0
  141. package/dist/targets/claude-code.d.ts +13 -0
  142. package/dist/targets/claude-code.js +490 -0
  143. package/dist/targets/codex-cli.d.ts +12 -0
  144. package/dist/targets/codex-cli.js +297 -0
  145. package/dist/targets/copilot.d.ts +12 -0
  146. package/dist/targets/copilot.js +390 -0
  147. package/dist/targets/cursor.d.ts +13 -0
  148. package/dist/targets/cursor.js +441 -0
  149. package/dist/targets/gemini-cli.d.ts +12 -0
  150. package/dist/targets/gemini-cli.js +352 -0
  151. package/dist/targets/generic-md-target.d.ts +25 -0
  152. package/dist/targets/generic-md-target.js +319 -0
  153. package/dist/targets/index.d.ts +9 -0
  154. package/dist/targets/index.js +1351 -0
  155. package/dist/targets/opencode.d.ts +13 -0
  156. package/dist/targets/opencode.js +556 -0
  157. package/dist/targets/registry.d.ts +17 -0
  158. package/dist/targets/registry.js +1343 -0
  159. package/dist/utils/diff.d.ts +13 -0
  160. package/dist/utils/diff.js +144 -0
  161. package/dist/utils/filesystem.d.ts +49 -0
  162. package/dist/utils/filesystem.js +152 -0
  163. package/dist/utils/frontmatter.d.ts +19 -0
  164. package/dist/utils/frontmatter.js +52 -0
  165. package/dist/utils/global.d.ts +17 -0
  166. package/dist/utils/global.js +81 -0
  167. package/dist/utils/markdown.d.ts +20 -0
  168. package/dist/utils/markdown.js +62 -0
  169. package/package.json +808 -0
  170. package/templates/pack/pack.json +10 -0
  171. package/templates/pack/rules/overview.md +22 -0
  172. package/templates/workspace/agentpacks.jsonc +34 -0
@@ -0,0 +1,72 @@
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
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
31
+
32
+ // src/core/lockfile.ts
33
+ import { existsSync, readFileSync, writeFileSync } from "fs";
34
+ import { resolve } from "path";
35
+ import { createHash } from "crypto";
36
+ var LOCKFILE_VERSION = 1;
37
+ var LOCKFILE_NAME = "agentpacks.lock";
38
+ function loadLockfile(projectRoot) {
39
+ const filepath = resolve(projectRoot, LOCKFILE_NAME);
40
+ if (!existsSync(filepath)) {
41
+ return { lockfileVersion: LOCKFILE_VERSION, sources: {} };
42
+ }
43
+ const raw = readFileSync(filepath, "utf-8");
44
+ return JSON.parse(raw);
45
+ }
46
+ function saveLockfile(projectRoot, lockfile) {
47
+ const filepath = resolve(projectRoot, LOCKFILE_NAME);
48
+ writeFileSync(filepath, JSON.stringify(lockfile, null, 2) + `
49
+ `);
50
+ }
51
+ function getLockedSource(lockfile, sourceKey) {
52
+ return lockfile.sources[sourceKey];
53
+ }
54
+ function setLockedSource(lockfile, sourceKey, entry) {
55
+ lockfile.sources[sourceKey] = entry;
56
+ }
57
+ function computeIntegrity(content) {
58
+ const hash = createHash("sha256").update(content).digest("hex");
59
+ return `sha256-${hash}`;
60
+ }
61
+ function isLockfileFrozenValid(lockfile, sourceKeys) {
62
+ const missing = sourceKeys.filter((key) => !(key in lockfile.sources));
63
+ return { valid: missing.length === 0, missing };
64
+ }
65
+ export {
66
+ setLockedSource,
67
+ saveLockfile,
68
+ loadLockfile,
69
+ isLockfileFrozenValid,
70
+ getLockedSource,
71
+ computeIntegrity
72
+ };
@@ -0,0 +1,218 @@
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
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
31
+
32
+ // src/core/config.ts
33
+ var exports_config = {};
34
+ __export(exports_config, {
35
+ resolveTargets: () => resolveTargets,
36
+ resolveFeatures: () => resolveFeatures,
37
+ loadWorkspaceConfig: () => loadWorkspaceConfig,
38
+ loadPackManifest: () => loadPackManifest,
39
+ WorkspaceConfigSchema: () => WorkspaceConfigSchema,
40
+ TARGET_IDS: () => TARGET_IDS,
41
+ REPO_MODES: () => REPO_MODES,
42
+ PackManifestSchema: () => PackManifestSchema,
43
+ FEATURE_IDS: () => FEATURE_IDS
44
+ });
45
+ import { z } from "zod";
46
+ import { readFileSync, existsSync } from "fs";
47
+ import { resolve } from "path";
48
+ import { parse as parseJsonc } from "jsonc-parser";
49
+ function loadWorkspaceConfig(projectRoot) {
50
+ for (const filename of CONFIG_FILES) {
51
+ const filepath = resolve(projectRoot, filename);
52
+ if (existsSync(filepath)) {
53
+ const raw = readFileSync(filepath, "utf-8");
54
+ const parsed = parseJsonc(raw);
55
+ return WorkspaceConfigSchema.parse(parsed);
56
+ }
57
+ }
58
+ return WorkspaceConfigSchema.parse({});
59
+ }
60
+ function loadPackManifest(packDir) {
61
+ const filepath = resolve(packDir, "pack.json");
62
+ if (!existsSync(filepath)) {
63
+ const dirName = packDir.split("/").pop() ?? "unknown";
64
+ return PackManifestSchema.parse({ name: dirName });
65
+ }
66
+ const raw = readFileSync(filepath, "utf-8");
67
+ const parsed = JSON.parse(raw);
68
+ return PackManifestSchema.parse(parsed);
69
+ }
70
+ function resolveFeatures(config, targetId) {
71
+ const { features } = config;
72
+ if (features === "*") {
73
+ return [...FEATURE_IDS];
74
+ }
75
+ if (Array.isArray(features)) {
76
+ if (features.includes("*"))
77
+ return [...FEATURE_IDS];
78
+ return features.filter((f) => FEATURE_IDS.includes(f));
79
+ }
80
+ const targetFeatures = features[targetId];
81
+ if (!targetFeatures)
82
+ return [];
83
+ if (targetFeatures === "*")
84
+ return [...FEATURE_IDS];
85
+ if (Array.isArray(targetFeatures) && targetFeatures.includes("*"))
86
+ return [...FEATURE_IDS];
87
+ return targetFeatures.filter((f) => FEATURE_IDS.includes(f));
88
+ }
89
+ function resolveTargets(config) {
90
+ if (config.targets === "*")
91
+ return [...TARGET_IDS];
92
+ return config.targets;
93
+ }
94
+ var TARGET_IDS, FEATURE_IDS, REPO_MODES, PackManifestSchema, FeaturesSchema, WorkspaceConfigSchema, CONFIG_FILES;
95
+ var init_config = __esm(() => {
96
+ TARGET_IDS = [
97
+ "opencode",
98
+ "cursor",
99
+ "claudecode",
100
+ "codexcli",
101
+ "geminicli",
102
+ "copilot",
103
+ "agentsmd",
104
+ "cline",
105
+ "kilo",
106
+ "roo",
107
+ "qwencode",
108
+ "kiro",
109
+ "factorydroid",
110
+ "antigravity",
111
+ "junie",
112
+ "augmentcode",
113
+ "windsurf",
114
+ "warp",
115
+ "replit",
116
+ "zed"
117
+ ];
118
+ FEATURE_IDS = [
119
+ "rules",
120
+ "commands",
121
+ "agents",
122
+ "skills",
123
+ "hooks",
124
+ "plugins",
125
+ "mcp",
126
+ "ignore"
127
+ ];
128
+ REPO_MODES = ["repo", "monorepo", "metarepo"];
129
+ PackManifestSchema = z.object({
130
+ name: z.string().min(1),
131
+ version: z.string().default("1.0.0"),
132
+ description: z.string().default(""),
133
+ author: z.union([
134
+ z.string(),
135
+ z.object({ name: z.string(), email: z.string().optional() })
136
+ ]).optional(),
137
+ tags: z.array(z.string()).default([]),
138
+ dependencies: z.array(z.string()).default([]),
139
+ conflicts: z.array(z.string()).default([]),
140
+ targets: z.union([z.literal("*"), z.array(z.string())]).default("*"),
141
+ features: z.union([z.literal("*"), z.array(z.string())]).default("*")
142
+ });
143
+ FeaturesSchema = z.union([
144
+ z.literal("*"),
145
+ z.array(z.string()),
146
+ z.record(z.string(), z.union([z.literal("*"), z.array(z.string())]))
147
+ ]);
148
+ WorkspaceConfigSchema = z.object({
149
+ $schema: z.string().optional(),
150
+ packs: z.array(z.string()).default(["./packs/default"]),
151
+ disabled: z.array(z.string()).default([]),
152
+ targets: z.union([z.literal("*"), z.array(z.string())]).default("*"),
153
+ features: FeaturesSchema.default("*"),
154
+ mode: z.enum(REPO_MODES).default("repo"),
155
+ baseDirs: z.array(z.string()).default(["."]),
156
+ global: z.boolean().default(false),
157
+ delete: z.boolean().default(true),
158
+ verbose: z.boolean().default(false),
159
+ silent: z.boolean().default(false),
160
+ overrides: z.record(z.string(), z.record(z.string(), z.string())).default({}),
161
+ sources: z.array(z.object({
162
+ source: z.string(),
163
+ packs: z.array(z.string()).optional(),
164
+ skills: z.array(z.string()).optional()
165
+ })).default([])
166
+ });
167
+ CONFIG_FILES = ["agentpacks.local.jsonc", "agentpacks.jsonc"];
168
+ });
169
+
170
+ // src/core/metarepo.ts
171
+ init_config();
172
+ import { existsSync as existsSync2, readdirSync } from "fs";
173
+ import { join, relative } from "path";
174
+ function discoverMetarepoEntries(metarepoRoot, options = {}) {
175
+ const maxDepth = options.maxDepth ?? 2;
176
+ const entries = [];
177
+ scanDir(metarepoRoot, metarepoRoot, 0, maxDepth, entries);
178
+ return entries;
179
+ }
180
+ function scanDir(root, dir, depth, maxDepth, entries) {
181
+ if (depth > maxDepth)
182
+ return;
183
+ const children = readdirSync(dir, { withFileTypes: true });
184
+ for (const child of children) {
185
+ if (!child.isDirectory())
186
+ continue;
187
+ if (child.name.startsWith(".") || child.name === "node_modules")
188
+ continue;
189
+ const childPath = join(dir, child.name);
190
+ const hasConfig = existsSync2(join(childPath, "agentpacks.jsonc")) || existsSync2(join(childPath, "agentpacks.local.jsonc"));
191
+ const hasPackageJson = existsSync2(join(childPath, "package.json"));
192
+ if (hasConfig || hasPackageJson) {
193
+ let config = null;
194
+ if (hasConfig) {
195
+ try {
196
+ config = loadWorkspaceConfig(childPath);
197
+ } catch {
198
+ config = null;
199
+ }
200
+ }
201
+ entries.push({
202
+ path: relative(root, childPath),
203
+ absolutePath: childPath,
204
+ hasConfig,
205
+ config
206
+ });
207
+ }
208
+ scanDir(root, childPath, depth + 1, maxDepth, entries);
209
+ }
210
+ }
211
+ function getMetarepoBaseDirs(metarepoRoot) {
212
+ const entries = discoverMetarepoEntries(metarepoRoot);
213
+ return entries.filter((e) => e.hasConfig).map((e) => e.path);
214
+ }
215
+ export {
216
+ getMetarepoBaseDirs,
217
+ discoverMetarepoEntries
218
+ };