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,51 +1,85 @@
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/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
5
  import { z } from "zod";
46
6
  import { readFileSync, existsSync } from "fs";
47
7
  import { resolve } from "path";
48
8
  import { parse as parseJsonc } from "jsonc-parser";
9
+ var TARGET_IDS = [
10
+ "opencode",
11
+ "cursor",
12
+ "claudecode",
13
+ "codexcli",
14
+ "geminicli",
15
+ "copilot",
16
+ "agentsmd",
17
+ "cline",
18
+ "kilo",
19
+ "roo",
20
+ "qwencode",
21
+ "kiro",
22
+ "factorydroid",
23
+ "antigravity",
24
+ "junie",
25
+ "augmentcode",
26
+ "windsurf",
27
+ "warp",
28
+ "replit",
29
+ "zed"
30
+ ];
31
+ var FEATURE_IDS = [
32
+ "rules",
33
+ "commands",
34
+ "agents",
35
+ "skills",
36
+ "hooks",
37
+ "plugins",
38
+ "mcp",
39
+ "ignore",
40
+ "models"
41
+ ];
42
+ var REPO_MODES = ["repo", "monorepo", "metarepo"];
43
+ var PackManifestSchema = z.object({
44
+ name: z.string().min(1),
45
+ version: z.string().default("1.0.0"),
46
+ description: z.string().default(""),
47
+ author: z.union([
48
+ z.string(),
49
+ z.object({ name: z.string(), email: z.string().optional() })
50
+ ]).optional(),
51
+ tags: z.array(z.string()).default([]),
52
+ dependencies: z.array(z.string()).default([]),
53
+ conflicts: z.array(z.string()).default([]),
54
+ targets: z.union([z.literal("*"), z.array(z.string())]).default("*"),
55
+ features: z.union([z.literal("*"), z.array(z.string())]).default("*")
56
+ });
57
+ var FeaturesSchema = z.union([
58
+ z.literal("*"),
59
+ z.array(z.string()),
60
+ z.record(z.string(), z.union([z.literal("*"), z.array(z.string())]))
61
+ ]);
62
+ var WorkspaceConfigSchema = z.object({
63
+ $schema: z.string().optional(),
64
+ packs: z.array(z.string()).default(["./packs/default"]),
65
+ disabled: z.array(z.string()).default([]),
66
+ targets: z.union([z.literal("*"), z.array(z.string())]).default("*"),
67
+ features: FeaturesSchema.default("*"),
68
+ mode: z.enum(REPO_MODES).default("repo"),
69
+ baseDirs: z.array(z.string()).default(["."]),
70
+ global: z.boolean().default(false),
71
+ delete: z.boolean().default(true),
72
+ verbose: z.boolean().default(false),
73
+ silent: z.boolean().default(false),
74
+ overrides: z.record(z.string(), z.record(z.string(), z.string())).default({}),
75
+ sources: z.array(z.object({
76
+ source: z.string(),
77
+ packs: z.array(z.string()).optional(),
78
+ skills: z.array(z.string()).optional()
79
+ })).default([]),
80
+ modelProfile: z.string().optional()
81
+ });
82
+ var CONFIG_FILES = ["agentpacks.local.jsonc", "agentpacks.jsonc"];
49
83
  function loadWorkspaceConfig(projectRoot) {
50
84
  for (const filename of CONFIG_FILES) {
51
85
  const filepath = resolve(projectRoot, filename);
@@ -91,81 +125,6 @@ function resolveTargets(config) {
91
125
  return [...TARGET_IDS];
92
126
  return config.targets;
93
127
  }
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
128
 
170
129
  // src/utils/filesystem.ts
171
130
  import {
@@ -174,10 +133,10 @@ import {
174
133
  readFileSync as readFileSync2,
175
134
  writeFileSync,
176
135
  readdirSync,
136
+ rmSync,
177
137
  statSync
178
138
  } from "fs";
179
139
  import { dirname, relative, join } from "path";
180
- import { removeSync } from "fs-extra";
181
140
  var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
182
141
  var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
183
142
  var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
@@ -218,7 +177,7 @@ function ensureDir(dirPath) {
218
177
  }
219
178
  function removeIfExists(targetPath) {
220
179
  if (existsSync2(targetPath)) {
221
- removeSync(targetPath);
180
+ rmSync(targetPath, { recursive: true, force: true });
222
181
  }
223
182
  }
224
183
  function listFiles(dirPath, options = {}) {
@@ -544,10 +503,178 @@ function mergeIgnorePatterns(configs) {
544
503
  return result;
545
504
  }
546
505
 
506
+ // src/features/models.ts
507
+ import { join as join7 } from "path";
508
+ import { z as z2 } from "zod";
509
+ var SECRET_PATTERNS = [
510
+ /["']api[_-]?key["']\s*:/i,
511
+ /["']apiKey["']\s*:/i,
512
+ /["']secret["']\s*:/i,
513
+ /["']password["']\s*:/i,
514
+ /["'](?:auth_token|access_token|bearer_token)["']\s*:/i,
515
+ /["']private[_-]?key["']\s*:/i,
516
+ /-----BEGIN\s+(RSA|EC|DSA|OPENSSH|PGP)\s+PRIVATE\s+KEY-----/,
517
+ /sk-[a-zA-Z0-9]{20,}/,
518
+ /Bearer\s+[a-zA-Z0-9._-]{20,}/
519
+ ];
520
+ var AgentModelSchema = z2.object({
521
+ model: z2.string(),
522
+ temperature: z2.number().min(0).max(2).optional(),
523
+ top_p: z2.number().min(0).max(1).optional()
524
+ });
525
+ var ModelProfileSchema = z2.object({
526
+ extends: z2.string().optional(),
527
+ description: z2.string().optional(),
528
+ default: z2.string().optional(),
529
+ small: z2.string().optional(),
530
+ agents: z2.record(z2.string(), AgentModelSchema).optional()
531
+ });
532
+ var RoutingConditionSchema = z2.object({
533
+ complexity: z2.enum(["low", "medium", "high", "critical"]).optional().describe("Task complexity level"),
534
+ urgency: z2.enum(["low", "normal", "high"]).optional().describe("Time sensitivity"),
535
+ budget: z2.enum(["minimal", "standard", "premium"]).optional().describe("Cost/token budget tier"),
536
+ contextWindowNeed: z2.enum(["small", "medium", "large", "max"]).optional().describe("Required context window size"),
537
+ toolUseIntensity: z2.enum(["none", "light", "heavy"]).optional().describe("Expected tool/function calling intensity")
538
+ });
539
+ var RoutingRuleSchema = z2.object({
540
+ when: z2.record(z2.string(), z2.string()),
541
+ use: z2.string(),
542
+ description: z2.string().optional(),
543
+ priority: z2.number().optional()
544
+ });
545
+ var ProviderModelSchema = z2.object({
546
+ options: z2.record(z2.string(), z2.unknown()).optional(),
547
+ variants: z2.record(z2.string(), z2.record(z2.string(), z2.unknown())).optional()
548
+ });
549
+ var ProviderConfigSchema = z2.object({
550
+ options: z2.record(z2.string(), z2.unknown()).optional(),
551
+ models: z2.record(z2.string(), ProviderModelSchema).optional()
552
+ });
553
+ var ModelsSchema = z2.object({
554
+ default: z2.string().optional(),
555
+ small: z2.string().optional(),
556
+ agents: z2.record(z2.string(), AgentModelSchema).optional(),
557
+ profiles: z2.record(z2.string(), ModelProfileSchema).optional(),
558
+ providers: z2.record(z2.string(), ProviderConfigSchema).optional(),
559
+ routing: z2.array(RoutingRuleSchema).optional(),
560
+ overrides: z2.record(z2.string(), z2.object({
561
+ default: z2.string().optional(),
562
+ small: z2.string().optional(),
563
+ agents: z2.record(z2.string(), AgentModelSchema).optional()
564
+ })).optional()
565
+ });
566
+ function parseModels(packDir, packName) {
567
+ const modelsPath = join7(packDir, "models.json");
568
+ const raw = readJsonOrNull(modelsPath);
569
+ if (!raw)
570
+ return null;
571
+ const parsed = ModelsSchema.parse(raw);
572
+ return {
573
+ packName,
574
+ sourcePath: modelsPath,
575
+ config: parsed
576
+ };
577
+ }
578
+ function mergeModelsConfigs(configs) {
579
+ const warnings = [];
580
+ const result = {};
581
+ for (const entry of configs) {
582
+ const { config, packName } = entry;
583
+ if (config.default !== undefined && result.default === undefined) {
584
+ result.default = config.default;
585
+ } else if (config.default !== undefined && result.default !== undefined) {
586
+ warnings.push(`Models "default" from pack "${packName}" skipped (already defined).`);
587
+ }
588
+ if (config.small !== undefined && result.small === undefined) {
589
+ result.small = config.small;
590
+ } else if (config.small !== undefined && result.small !== undefined) {
591
+ warnings.push(`Models "small" from pack "${packName}" skipped (already defined).`);
592
+ }
593
+ if (config.agents) {
594
+ if (!result.agents)
595
+ result.agents = {};
596
+ for (const [name, assignment] of Object.entries(config.agents)) {
597
+ if (name in result.agents) {
598
+ warnings.push(`Models agent "${name}" from pack "${packName}" skipped (already defined).`);
599
+ continue;
600
+ }
601
+ result.agents[name] = assignment;
602
+ }
603
+ }
604
+ if (config.profiles) {
605
+ if (!result.profiles)
606
+ result.profiles = {};
607
+ for (const [name, profile] of Object.entries(config.profiles)) {
608
+ if (name in result.profiles) {
609
+ warnings.push(`Models profile "${name}" from pack "${packName}" skipped (already defined).`);
610
+ continue;
611
+ }
612
+ result.profiles[name] = profile;
613
+ }
614
+ }
615
+ if (config.providers) {
616
+ if (!result.providers)
617
+ result.providers = {};
618
+ for (const [providerName, providerConfig] of Object.entries(config.providers)) {
619
+ if (!(providerName in result.providers)) {
620
+ result.providers[providerName] = providerConfig;
621
+ } else {
622
+ const existing = result.providers[providerName];
623
+ if (!existing) {
624
+ result.providers[providerName] = providerConfig;
625
+ continue;
626
+ }
627
+ if (providerConfig.options) {
628
+ existing.options = {
629
+ ...providerConfig.options,
630
+ ...existing.options
631
+ };
632
+ }
633
+ if (providerConfig.models) {
634
+ if (!existing.models)
635
+ existing.models = {};
636
+ for (const [modelName, modelConfig] of Object.entries(providerConfig.models)) {
637
+ if (!(modelName in existing.models)) {
638
+ existing.models[modelName] = modelConfig;
639
+ }
640
+ }
641
+ }
642
+ }
643
+ }
644
+ }
645
+ if (config.routing) {
646
+ if (!result.routing)
647
+ result.routing = [];
648
+ result.routing.push(...config.routing);
649
+ }
650
+ if (config.overrides) {
651
+ if (!result.overrides)
652
+ result.overrides = {};
653
+ for (const [targetId, override] of Object.entries(config.overrides)) {
654
+ if (targetId in result.overrides) {
655
+ warnings.push(`Models override for target "${targetId}" from pack "${packName}" skipped (already defined).`);
656
+ continue;
657
+ }
658
+ result.overrides[targetId] = override;
659
+ }
660
+ }
661
+ }
662
+ return { config: result, warnings };
663
+ }
664
+ function scanModelsForSecrets(config) {
665
+ const warnings = [];
666
+ const json = JSON.stringify(config);
667
+ for (const pattern of SECRET_PATTERNS) {
668
+ if (pattern.test(json)) {
669
+ warnings.push(`Potential secret detected in models.json matching pattern: ${pattern.source}`);
670
+ }
671
+ }
672
+ return warnings;
673
+ }
674
+
547
675
  // src/core/pack-loader.ts
548
- init_config();
549
676
  import { existsSync as existsSync6 } from "fs";
550
- import { resolve as resolve3, isAbsolute } from "path";
677
+ import { resolve as resolve2, isAbsolute } from "path";
551
678
  class PackLoader {
552
679
  projectRoot;
553
680
  config;
@@ -580,10 +707,10 @@ class PackLoader {
580
707
  }
581
708
  loadPack(packDir, manifest) {
582
709
  const name = manifest.name;
583
- const rulesDir = resolve3(packDir, "rules");
584
- const commandsDir = resolve3(packDir, "commands");
585
- const agentsDir = resolve3(packDir, "agents");
586
- const skillsDir = resolve3(packDir, "skills");
710
+ const rulesDir = resolve2(packDir, "rules");
711
+ const commandsDir = resolve2(packDir, "commands");
712
+ const agentsDir = resolve2(packDir, "agents");
713
+ const skillsDir = resolve2(packDir, "skills");
587
714
  return {
588
715
  manifest,
589
716
  directory: packDir,
@@ -594,23 +721,25 @@ class PackLoader {
594
721
  hooks: parseHooks(packDir, name),
595
722
  plugins: parsePlugins(packDir, name),
596
723
  mcp: parseMcp(packDir, name),
597
- ignore: parseIgnore(packDir, name)
724
+ ignore: parseIgnore(packDir, name),
725
+ models: parseModels(packDir, name)
598
726
  };
599
727
  }
600
728
  loadForBaseDir(baseDir) {
601
- const baseDirRoot = resolve3(this.projectRoot, baseDir);
602
- const localConfigPath = resolve3(baseDirRoot, "agentpacks.jsonc");
729
+ const baseDirRoot = resolve2(this.projectRoot, baseDir);
730
+ const localConfigPath = resolve2(baseDirRoot, "agentpacks.jsonc");
603
731
  if (!existsSync6(localConfigPath)) {
604
732
  return { packs: [], warnings: [] };
605
733
  }
606
- const { loadWorkspaceConfig: loadWorkspaceConfig2 } = (init_config(), __toCommonJS(exports_config));
607
- const localConfig = loadWorkspaceConfig2(baseDirRoot);
734
+ const localConfig = loadWorkspaceConfig(baseDirRoot);
608
735
  const loader = new PackLoader(baseDirRoot, localConfig);
609
736
  return loader.loadAll();
610
737
  }
611
738
  resolveCuratedPack(packRef) {
612
- const curatedDir = resolve3(this.projectRoot, ".agentpacks", ".curated");
739
+ const curatedDir = resolve2(this.projectRoot, ".agentpacks", ".curated");
613
740
  let packName = packRef;
741
+ if (packName.startsWith("registry:"))
742
+ packName = packName.slice(9);
614
743
  if (packName.startsWith("npm:"))
615
744
  packName = packName.slice(4);
616
745
  if (packName.startsWith("github:"))
@@ -621,24 +750,28 @@ class PackLoader {
621
750
  const parts = packName.split("/");
622
751
  packName = packName.includes("@") ? parts.join("-") : parts[parts.length - 1] ?? packName;
623
752
  }
624
- packName = packName.split("@")[0].split(":")[0];
625
- const resolved = resolve3(curatedDir, packName);
753
+ const withoutVersion = packName.split("@")[0] ?? packName;
754
+ packName = withoutVersion.split(":")[0] ?? withoutVersion;
755
+ const resolved = resolve2(curatedDir, packName);
626
756
  return existsSync6(resolved) ? resolved : null;
627
757
  }
628
758
  resolvePackPath(packRef) {
629
759
  if (packRef.startsWith("./") || packRef.startsWith("../")) {
630
- return resolve3(this.projectRoot, packRef);
760
+ return resolve2(this.projectRoot, packRef);
631
761
  }
632
762
  if (isAbsolute(packRef)) {
633
763
  return packRef;
634
764
  }
765
+ if (packRef.startsWith("registry:")) {
766
+ return this.resolveCuratedPack(packRef);
767
+ }
635
768
  if (packRef.startsWith("@") || packRef.startsWith("npm:") || !packRef.includes("/")) {
636
769
  return this.resolveCuratedPack(packRef);
637
770
  }
638
771
  if (packRef.startsWith("github:") || packRef.includes("/")) {
639
772
  return this.resolveCuratedPack(packRef);
640
773
  }
641
- return resolve3(this.projectRoot, packRef);
774
+ return resolve2(this.projectRoot, packRef);
642
775
  }
643
776
  }
644
777
 
@@ -659,7 +792,8 @@ class FeatureMerger {
659
792
  hooks: this.mergeHooks(),
660
793
  plugins: this.mergePlugins(),
661
794
  mcpServers: this.mergeMcp(),
662
- ignorePatterns: this.mergeIgnore()
795
+ ignorePatterns: this.mergeIgnore(),
796
+ models: this.mergeModels()
663
797
  };
664
798
  return { features, warnings: this.warnings };
665
799
  }
@@ -746,16 +880,24 @@ class FeatureMerger {
746
880
  }
747
881
  return result;
748
882
  }
883
+ mergeModels() {
884
+ const configs = this.packs.map((p) => p.models).filter((m) => m != null);
885
+ if (configs.length === 0)
886
+ return null;
887
+ const { config, warnings } = mergeModelsConfigs(configs);
888
+ this.warnings.push(...warnings);
889
+ return config;
890
+ }
749
891
  }
750
892
 
751
893
  // src/core/lockfile.ts
752
894
  import { existsSync as existsSync7, readFileSync as readFileSync9, writeFileSync as writeFileSync2 } from "fs";
753
- import { resolve as resolve4 } from "path";
895
+ import { resolve as resolve3 } from "path";
754
896
  import { createHash } from "crypto";
755
897
  var LOCKFILE_VERSION = 1;
756
898
  var LOCKFILE_NAME = "agentpacks.lock";
757
899
  function loadLockfile(projectRoot) {
758
- const filepath = resolve4(projectRoot, LOCKFILE_NAME);
900
+ const filepath = resolve3(projectRoot, LOCKFILE_NAME);
759
901
  if (!existsSync7(filepath)) {
760
902
  return { lockfileVersion: LOCKFILE_VERSION, sources: {} };
761
903
  }
@@ -763,7 +905,7 @@ function loadLockfile(projectRoot) {
763
905
  return JSON.parse(raw);
764
906
  }
765
907
  function saveLockfile(projectRoot, lockfile) {
766
- const filepath = resolve4(projectRoot, LOCKFILE_NAME);
908
+ const filepath = resolve3(projectRoot, LOCKFILE_NAME);
767
909
  writeFileSync2(filepath, JSON.stringify(lockfile, null, 2) + `
768
910
  `);
769
911
  }
@@ -831,8 +973,12 @@ function topologicalSort(graph) {
831
973
  const sorted = [];
832
974
  while (queue.length > 0) {
833
975
  const current = queue.shift();
976
+ if (!current)
977
+ continue;
834
978
  sorted.push(current);
835
979
  const node = graph.get(current);
980
+ if (!node)
981
+ continue;
836
982
  for (const dep of node.dependencies) {
837
983
  if (!graph.has(dep))
838
984
  continue;
@@ -898,9 +1044,6 @@ function detectConflicts(graph) {
898
1044
  }
899
1045
  return conflicts;
900
1046
  }
901
-
902
- // src/core/index.ts
903
- init_config();
904
1047
  export {
905
1048
  setLockedSource,
906
1049
  saveLockfile,
@@ -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/core/lockfile.ts