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,151 @@
1
+ // @bun
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 = import.meta.require;
31
+
32
+ // src/core/dependency-resolver.ts
33
+ function buildDependencyGraph(manifests) {
34
+ const graph = new Map;
35
+ for (const m of manifests) {
36
+ graph.set(m.name, {
37
+ name: m.name,
38
+ manifest: m,
39
+ dependencies: m.dependencies,
40
+ conflicts: m.conflicts
41
+ });
42
+ }
43
+ return graph;
44
+ }
45
+ function resolveDependencies(manifests) {
46
+ const graph = buildDependencyGraph(manifests);
47
+ const allNames = new Set(graph.keys());
48
+ const missingDeps = [];
49
+ for (const [name, node] of graph) {
50
+ for (const dep of node.dependencies) {
51
+ if (!allNames.has(dep)) {
52
+ missingDeps.push([name, dep]);
53
+ }
54
+ }
55
+ }
56
+ const { sorted, cycles } = topologicalSort(graph);
57
+ const conflictPairs = detectConflicts(graph);
58
+ const ok = cycles.length === 0 && conflictPairs.length === 0 && missingDeps.length === 0;
59
+ return { sorted, cycles, conflictPairs, missingDeps, ok };
60
+ }
61
+ function topologicalSort(graph) {
62
+ const inDegree = new Map;
63
+ for (const name of graph.keys()) {
64
+ inDegree.set(name, 0);
65
+ }
66
+ for (const [, node] of graph) {
67
+ for (const dep of node.dependencies) {
68
+ if (graph.has(dep)) {
69
+ inDegree.set(dep, (inDegree.get(dep) ?? 0) + 1);
70
+ }
71
+ }
72
+ }
73
+ const queue = [];
74
+ for (const [name, degree] of inDegree) {
75
+ if (degree === 0)
76
+ queue.push(name);
77
+ }
78
+ const sorted = [];
79
+ while (queue.length > 0) {
80
+ const current = queue.shift();
81
+ sorted.push(current);
82
+ const node = graph.get(current);
83
+ for (const dep of node.dependencies) {
84
+ if (!graph.has(dep))
85
+ continue;
86
+ const newDegree = (inDegree.get(dep) ?? 1) - 1;
87
+ inDegree.set(dep, newDegree);
88
+ if (newDegree === 0) {
89
+ queue.push(dep);
90
+ }
91
+ }
92
+ }
93
+ const cycles = [];
94
+ if (sorted.length < graph.size) {
95
+ const remaining = new Set;
96
+ for (const name of graph.keys()) {
97
+ if (!sorted.includes(name))
98
+ remaining.add(name);
99
+ }
100
+ const visited = new Set;
101
+ for (const start of remaining) {
102
+ if (visited.has(start))
103
+ continue;
104
+ const cycle = traceCycle(start, graph, remaining);
105
+ if (cycle.length > 0) {
106
+ cycles.push(cycle);
107
+ for (const n of cycle)
108
+ visited.add(n);
109
+ }
110
+ }
111
+ }
112
+ return { sorted: sorted.reverse(), cycles };
113
+ }
114
+ function traceCycle(start, graph, remaining) {
115
+ const path = [];
116
+ const pathSet = new Set;
117
+ let current = start;
118
+ while (current && !pathSet.has(current)) {
119
+ path.push(current);
120
+ pathSet.add(current);
121
+ const node = graph.get(current);
122
+ if (!node)
123
+ break;
124
+ current = node.dependencies.find((d) => remaining.has(d) && graph.has(d));
125
+ }
126
+ if (current && pathSet.has(current)) {
127
+ const cycleStart = path.indexOf(current);
128
+ return path.slice(cycleStart);
129
+ }
130
+ return path;
131
+ }
132
+ function detectConflicts(graph) {
133
+ const conflicts = [];
134
+ const seen = new Set;
135
+ for (const [name, node] of graph) {
136
+ for (const conflict of node.conflicts) {
137
+ if (graph.has(conflict)) {
138
+ const key = [name, conflict].sort().join(":");
139
+ if (!seen.has(key)) {
140
+ seen.add(key);
141
+ conflicts.push([name, conflict]);
142
+ }
143
+ }
144
+ }
145
+ }
146
+ return conflicts;
147
+ }
148
+ export {
149
+ resolveDependencies,
150
+ buildDependencyGraph
151
+ };
@@ -0,0 +1,61 @@
1
+ import type { LoadedPack } from './pack-loader.js';
2
+ import type { ParsedRule } from '../features/rules.js';
3
+ import type { ParsedCommand } from '../features/commands.js';
4
+ import type { ParsedAgent } from '../features/agents.js';
5
+ import type { ParsedSkill } from '../features/skills.js';
6
+ import type { ParsedHooks } from '../features/hooks.js';
7
+ import type { ParsedPlugin } from '../features/plugins.js';
8
+ import type { McpServerEntry } from '../features/mcp.js';
9
+ /**
10
+ * Merged features from all active packs.
11
+ */
12
+ export interface MergedFeatures {
13
+ rules: ParsedRule[];
14
+ commands: ParsedCommand[];
15
+ agents: ParsedAgent[];
16
+ skills: ParsedSkill[];
17
+ hooks: ParsedHooks[];
18
+ plugins: ParsedPlugin[];
19
+ mcpServers: Record<string, McpServerEntry>;
20
+ ignorePatterns: string[];
21
+ }
22
+ /**
23
+ * Merges features from multiple packs with conflict detection.
24
+ * First pack wins for name-based conflicts.
25
+ */
26
+ export declare class FeatureMerger {
27
+ private packs;
28
+ private warnings;
29
+ constructor(packs: LoadedPack[]);
30
+ /**
31
+ * Merge all features from loaded packs.
32
+ */
33
+ merge(): {
34
+ features: MergedFeatures;
35
+ warnings: string[];
36
+ };
37
+ /**
38
+ * Rules are additive. Same filename from different packs: first wins.
39
+ */
40
+ private mergeRules;
41
+ /**
42
+ * Generic name-based merge for commands, agents, skills.
43
+ */
44
+ private mergeByName;
45
+ /**
46
+ * Hooks are additive per event.
47
+ */
48
+ private mergeHooks;
49
+ /**
50
+ * Plugins are additive.
51
+ */
52
+ private mergePlugins;
53
+ /**
54
+ * MCP servers merge by name. First pack wins.
55
+ */
56
+ private mergeMcp;
57
+ /**
58
+ * Ignore patterns are additive (deduplicated).
59
+ */
60
+ private mergeIgnore;
61
+ }
@@ -0,0 +1,139 @@
1
+ // @bun
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 = import.meta.require;
31
+
32
+ // src/core/feature-merger.ts
33
+ class FeatureMerger {
34
+ packs;
35
+ warnings = [];
36
+ constructor(packs) {
37
+ this.packs = packs;
38
+ }
39
+ merge() {
40
+ this.warnings = [];
41
+ const features = {
42
+ rules: this.mergeRules(),
43
+ commands: this.mergeByName("commands"),
44
+ agents: this.mergeByName("agents"),
45
+ skills: this.mergeByName("skills"),
46
+ hooks: this.mergeHooks(),
47
+ plugins: this.mergePlugins(),
48
+ mcpServers: this.mergeMcp(),
49
+ ignorePatterns: this.mergeIgnore()
50
+ };
51
+ return { features, warnings: this.warnings };
52
+ }
53
+ mergeRules() {
54
+ const seen = new Map;
55
+ const result = [];
56
+ for (const pack of this.packs) {
57
+ for (const rule of pack.rules) {
58
+ const existing = seen.get(rule.name);
59
+ if (existing) {
60
+ this.warnings.push(`Rule "${rule.name}" from pack "${rule.packName}" skipped (already defined by "${existing}").`);
61
+ continue;
62
+ }
63
+ seen.set(rule.name, rule.packName);
64
+ result.push(rule);
65
+ }
66
+ }
67
+ return result;
68
+ }
69
+ mergeByName(featureKey) {
70
+ const seen = new Map;
71
+ const result = [];
72
+ for (const pack of this.packs) {
73
+ const items = pack[featureKey];
74
+ for (const item of items) {
75
+ const existing = seen.get(item.name);
76
+ if (existing) {
77
+ this.warnings.push(`${featureKey.slice(0, -1)} "${item.name}" from pack "${item.packName}" skipped (already defined by "${existing}").`);
78
+ continue;
79
+ }
80
+ seen.set(item.name, item.packName);
81
+ result.push(item);
82
+ }
83
+ }
84
+ return result;
85
+ }
86
+ mergeHooks() {
87
+ return this.packs.map((p) => p.hooks).filter((h) => h !== null);
88
+ }
89
+ mergePlugins() {
90
+ const seen = new Map;
91
+ const result = [];
92
+ for (const pack of this.packs) {
93
+ for (const plugin of pack.plugins) {
94
+ const key = `${plugin.name}.${plugin.extension}`;
95
+ const existing = seen.get(key);
96
+ if (existing) {
97
+ this.warnings.push(`Plugin "${key}" from pack "${plugin.packName}" skipped (already defined by "${existing}").`);
98
+ continue;
99
+ }
100
+ seen.set(key, plugin.packName);
101
+ result.push(plugin);
102
+ }
103
+ }
104
+ return result;
105
+ }
106
+ mergeMcp() {
107
+ const servers = {};
108
+ for (const pack of this.packs) {
109
+ if (!pack.mcp)
110
+ continue;
111
+ for (const [name, entry] of Object.entries(pack.mcp.servers)) {
112
+ if (name in servers) {
113
+ this.warnings.push(`MCP server "${name}" from pack "${pack.manifest.name}" skipped (already defined).`);
114
+ continue;
115
+ }
116
+ servers[name] = entry;
117
+ }
118
+ }
119
+ return servers;
120
+ }
121
+ mergeIgnore() {
122
+ const seen = new Set;
123
+ const result = [];
124
+ for (const pack of this.packs) {
125
+ if (!pack.ignore)
126
+ continue;
127
+ for (const pattern of pack.ignore.patterns) {
128
+ if (!seen.has(pattern)) {
129
+ seen.add(pattern);
130
+ result.push(pattern);
131
+ }
132
+ }
133
+ }
134
+ return result;
135
+ }
136
+ }
137
+ export {
138
+ FeatureMerger
139
+ };
@@ -0,0 +1,5 @@
1
+ export { type TargetId, type FeatureId, type RepoMode, type PackManifest, type WorkspaceConfig, TARGET_IDS, FEATURE_IDS, REPO_MODES, PackManifestSchema, WorkspaceConfigSchema, loadWorkspaceConfig, loadPackManifest, resolveFeatures, resolveTargets, } from './config.js';
2
+ export { PackLoader } from './pack-loader.js';
3
+ export { FeatureMerger } from './feature-merger.js';
4
+ export { type Lockfile, type LockfileSourceEntry, type LockfileSkillEntry, loadLockfile, saveLockfile, getLockedSource, setLockedSource, computeIntegrity, isLockfileFrozenValid, } from './lockfile.js';
5
+ export { type DependencyNode, type DependencyResolution, buildDependencyGraph, resolveDependencies, } from './dependency-resolver.js';