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.
- package/README.md +168 -8
- package/dist/api.d.ts +2 -0
- package/dist/api.js +929 -409
- package/dist/cli/export-cmd.js +281 -149
- package/dist/cli/generate.js +740 -247
- package/dist/cli/import-cmd.js +57 -85
- package/dist/cli/info.d.ts +4 -0
- package/dist/cli/info.js +232 -0
- package/dist/cli/init.js +8 -36
- package/dist/cli/install.js +414 -129
- package/dist/cli/login.d.ts +9 -0
- package/dist/cli/login.js +202 -0
- package/dist/cli/models-explain.d.ts +16 -0
- package/dist/cli/models-explain.js +1205 -0
- package/dist/cli/pack/create.js +4 -32
- package/dist/cli/pack/enable.js +1 -29
- package/dist/cli/pack/list.js +266 -134
- package/dist/cli/pack/validate.js +274 -127
- package/dist/cli/publish.d.ts +8 -0
- package/dist/cli/publish.js +672 -0
- package/dist/cli/search.d.ts +12 -0
- package/dist/cli/search.js +210 -0
- package/dist/core/config.d.ts +2 -1
- package/dist/core/config.js +74 -117
- package/dist/core/dependency-resolver.js +4 -28
- package/dist/core/feature-merger.d.ts +7 -0
- package/dist/core/feature-merger.js +289 -29
- package/dist/core/index.js +283 -140
- package/dist/core/lockfile.js +0 -28
- package/dist/core/metarepo.js +74 -116
- package/dist/core/pack-loader.d.ts +2 -0
- package/dist/core/pack-loader.js +266 -133
- package/dist/core/profile-resolver.d.ts +75 -0
- package/dist/core/profile-resolver.js +111 -0
- package/dist/exporters/cursor-plugin.js +4 -32
- package/dist/exporters/index.js +4 -32
- package/dist/features/agents.d.ts +5 -0
- package/dist/features/agents.js +2 -30
- package/dist/features/commands.js +2 -30
- package/dist/features/hooks.js +2 -30
- package/dist/features/ignore.js +0 -28
- package/dist/features/index.d.ts +1 -0
- package/dist/features/index.js +176 -31
- package/dist/features/mcp.js +2 -30
- package/dist/features/models.d.ts +167 -0
- package/dist/features/models.js +293 -0
- package/dist/features/plugins.js +2 -30
- package/dist/features/rules.js +2 -30
- package/dist/features/skills.js +2 -30
- package/dist/importers/claude-code.js +10 -38
- package/dist/importers/cursor.js +15 -43
- package/dist/importers/opencode.js +16 -44
- package/dist/importers/rulesync.js +22 -50
- package/dist/index.js +1710 -538
- package/dist/node/api.js +929 -409
- package/dist/node/cli/export-cmd.js +281 -149
- package/dist/node/cli/generate.js +740 -247
- package/dist/node/cli/import-cmd.js +57 -85
- package/dist/node/cli/info.js +232 -0
- package/dist/node/cli/init.js +8 -36
- package/dist/node/cli/install.js +414 -129
- package/dist/node/cli/login.js +202 -0
- package/dist/node/cli/models-explain.js +1205 -0
- package/dist/node/cli/pack/create.js +4 -32
- package/dist/node/cli/pack/enable.js +1 -29
- package/dist/node/cli/pack/list.js +266 -134
- package/dist/node/cli/pack/validate.js +274 -127
- package/dist/node/cli/publish.js +672 -0
- package/dist/node/cli/search.js +210 -0
- package/dist/node/core/config.js +74 -117
- package/dist/node/core/dependency-resolver.js +4 -28
- package/dist/node/core/feature-merger.js +289 -29
- package/dist/node/core/index.js +283 -140
- package/dist/node/core/lockfile.js +0 -28
- package/dist/node/core/metarepo.js +74 -116
- package/dist/node/core/pack-loader.js +266 -133
- package/dist/node/core/profile-resolver.js +111 -0
- package/dist/node/exporters/cursor-plugin.js +4 -32
- package/dist/node/exporters/index.js +4 -32
- package/dist/node/features/agents.js +2 -30
- package/dist/node/features/commands.js +2 -30
- package/dist/node/features/hooks.js +2 -30
- package/dist/node/features/ignore.js +0 -28
- package/dist/node/features/index.js +176 -31
- package/dist/node/features/mcp.js +2 -30
- package/dist/node/features/models.js +293 -0
- package/dist/node/features/plugins.js +2 -30
- package/dist/node/features/rules.js +2 -30
- package/dist/node/features/skills.js +2 -30
- package/dist/node/importers/claude-code.js +10 -38
- package/dist/node/importers/cursor.js +15 -43
- package/dist/node/importers/opencode.js +16 -44
- package/dist/node/importers/rulesync.js +22 -50
- package/dist/node/index.js +1710 -538
- package/dist/node/sources/git-ref.js +7 -30
- package/dist/node/sources/git.js +7 -30
- package/dist/node/sources/index.js +337 -39
- package/dist/node/sources/local.js +0 -28
- package/dist/node/sources/npm-ref.js +0 -28
- package/dist/node/sources/npm.js +10 -37
- package/dist/node/sources/registry-ref.js +37 -0
- package/dist/node/sources/registry.js +355 -0
- package/dist/node/targets/additional-targets.js +196 -37
- package/dist/node/targets/agents-md.js +5 -33
- package/dist/node/targets/base-target.js +0 -28
- package/dist/node/targets/claude-code.js +211 -41
- package/dist/node/targets/codex-cli.js +7 -35
- package/dist/node/targets/copilot.js +202 -41
- package/dist/node/targets/cursor.js +188 -40
- package/dist/node/targets/gemini-cli.js +10 -38
- package/dist/node/targets/generic-md-target.js +196 -37
- package/dist/node/targets/index.js +414 -106
- package/dist/node/targets/opencode.js +171 -51
- package/dist/node/targets/registry.js +414 -106
- package/dist/node/utils/credentials.js +38 -0
- package/dist/node/utils/diff.js +22 -34
- package/dist/node/utils/filesystem.js +2 -30
- package/dist/node/utils/frontmatter.js +0 -28
- package/dist/node/utils/global.js +3 -31
- package/dist/node/utils/markdown.js +0 -28
- package/dist/node/utils/model-allowlist.js +110 -0
- package/dist/node/utils/model-guidance.js +78 -0
- package/dist/node/utils/registry-client.js +142 -0
- package/dist/node/utils/tarball.js +49 -0
- package/dist/sources/git-ref.js +7 -30
- package/dist/sources/git.d.ts +2 -2
- package/dist/sources/git.js +7 -30
- package/dist/sources/index.d.ts +2 -0
- package/dist/sources/index.js +337 -39
- package/dist/sources/local.js +0 -28
- package/dist/sources/npm-ref.js +0 -28
- package/dist/sources/npm.js +10 -37
- package/dist/sources/registry-ref.d.ts +30 -0
- package/dist/sources/registry-ref.js +37 -0
- package/dist/sources/registry.d.ts +18 -0
- package/dist/sources/registry.js +355 -0
- package/dist/targets/additional-targets.js +196 -37
- package/dist/targets/agents-md.js +5 -33
- package/dist/targets/base-target.d.ts +2 -0
- package/dist/targets/base-target.js +0 -28
- package/dist/targets/claude-code.js +211 -41
- package/dist/targets/codex-cli.js +7 -35
- package/dist/targets/copilot.js +202 -41
- package/dist/targets/cursor.js +188 -40
- package/dist/targets/gemini-cli.js +10 -38
- package/dist/targets/generic-md-target.js +196 -37
- package/dist/targets/index.js +414 -106
- package/dist/targets/opencode.js +171 -51
- package/dist/targets/registry.js +414 -106
- package/dist/utils/credentials.d.ts +19 -0
- package/dist/utils/credentials.js +38 -0
- package/dist/utils/diff.js +22 -34
- package/dist/utils/filesystem.js +2 -30
- package/dist/utils/frontmatter.js +0 -28
- package/dist/utils/global.js +3 -31
- package/dist/utils/markdown.js +0 -28
- package/dist/utils/model-allowlist.d.ts +39 -0
- package/dist/utils/model-allowlist.js +110 -0
- package/dist/utils/model-guidance.d.ts +6 -0
- package/dist/utils/model-guidance.js +78 -0
- package/dist/utils/registry-client.d.ts +141 -0
- package/dist/utils/registry-client.js +142 -0
- package/dist/utils/tarball.d.ts +13 -0
- package/dist/utils/tarball.js +49 -0
- package/package.json +171 -5
- package/templates/pack/models.json +38 -0
|
@@ -1,34 +1,285 @@
|
|
|
1
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
2
|
var __require = import.meta.require;
|
|
31
3
|
|
|
4
|
+
// src/utils/filesystem.ts
|
|
5
|
+
import {
|
|
6
|
+
existsSync,
|
|
7
|
+
mkdirSync,
|
|
8
|
+
readFileSync,
|
|
9
|
+
writeFileSync,
|
|
10
|
+
readdirSync,
|
|
11
|
+
rmSync,
|
|
12
|
+
statSync
|
|
13
|
+
} from "fs";
|
|
14
|
+
import { dirname, relative, join } from "path";
|
|
15
|
+
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
16
|
+
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
17
|
+
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
18
|
+
function writeGeneratedFile(filepath, content, options = {}) {
|
|
19
|
+
const { header = true, type } = options;
|
|
20
|
+
const ext = type ?? inferFileType(filepath);
|
|
21
|
+
ensureDir(dirname(filepath));
|
|
22
|
+
let output = content;
|
|
23
|
+
if (header) {
|
|
24
|
+
const headerComment = getHeader(ext);
|
|
25
|
+
if (headerComment) {
|
|
26
|
+
output = `${headerComment}
|
|
27
|
+
${content}`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
writeFileSync(filepath, output, "utf-8");
|
|
31
|
+
}
|
|
32
|
+
function writeGeneratedJson(filepath, data, options = {}) {
|
|
33
|
+
const json = JSON.stringify(data, null, 2);
|
|
34
|
+
writeGeneratedFile(filepath, json + `
|
|
35
|
+
`, { ...options, type: "json" });
|
|
36
|
+
}
|
|
37
|
+
function readFileOrNull(filepath) {
|
|
38
|
+
if (!existsSync(filepath))
|
|
39
|
+
return null;
|
|
40
|
+
return readFileSync(filepath, "utf-8");
|
|
41
|
+
}
|
|
42
|
+
function readJsonOrNull(filepath) {
|
|
43
|
+
const content = readFileOrNull(filepath);
|
|
44
|
+
if (content === null)
|
|
45
|
+
return null;
|
|
46
|
+
return JSON.parse(content);
|
|
47
|
+
}
|
|
48
|
+
function ensureDir(dirPath) {
|
|
49
|
+
if (!existsSync(dirPath)) {
|
|
50
|
+
mkdirSync(dirPath, { recursive: true });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function removeIfExists(targetPath) {
|
|
54
|
+
if (existsSync(targetPath)) {
|
|
55
|
+
rmSync(targetPath, { recursive: true, force: true });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function listFiles(dirPath, options = {}) {
|
|
59
|
+
const { extension, recursive = false } = options;
|
|
60
|
+
if (!existsSync(dirPath))
|
|
61
|
+
return [];
|
|
62
|
+
const results = [];
|
|
63
|
+
const entries = readdirSync(dirPath);
|
|
64
|
+
for (const entry of entries) {
|
|
65
|
+
const fullPath = join(dirPath, entry);
|
|
66
|
+
const stat = statSync(fullPath);
|
|
67
|
+
if (stat.isDirectory() && recursive) {
|
|
68
|
+
results.push(...listFiles(fullPath, options));
|
|
69
|
+
} else if (stat.isFile()) {
|
|
70
|
+
if (!extension || entry.endsWith(extension)) {
|
|
71
|
+
results.push(fullPath);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return results;
|
|
76
|
+
}
|
|
77
|
+
function listDirs(dirPath) {
|
|
78
|
+
if (!existsSync(dirPath))
|
|
79
|
+
return [];
|
|
80
|
+
return readdirSync(dirPath).map((entry) => join(dirPath, entry)).filter((fullPath) => statSync(fullPath).isDirectory());
|
|
81
|
+
}
|
|
82
|
+
function relPath(projectRoot, filepath) {
|
|
83
|
+
return relative(projectRoot, filepath);
|
|
84
|
+
}
|
|
85
|
+
function isGeneratedFile(filepath) {
|
|
86
|
+
const content = readFileOrNull(filepath);
|
|
87
|
+
if (!content)
|
|
88
|
+
return false;
|
|
89
|
+
return content.startsWith(GENERATED_HEADER_MD) || content.startsWith(GENERATED_HEADER_JSON) || content.startsWith(GENERATED_HEADER_JS);
|
|
90
|
+
}
|
|
91
|
+
function inferFileType(filepath) {
|
|
92
|
+
if (filepath.endsWith(".json") || filepath.endsWith(".jsonc"))
|
|
93
|
+
return "json";
|
|
94
|
+
if (filepath.endsWith(".ts") || filepath.endsWith(".mts"))
|
|
95
|
+
return "ts";
|
|
96
|
+
if (filepath.endsWith(".js") || filepath.endsWith(".mjs"))
|
|
97
|
+
return "js";
|
|
98
|
+
return "md";
|
|
99
|
+
}
|
|
100
|
+
function getHeader(type) {
|
|
101
|
+
switch (type) {
|
|
102
|
+
case "md":
|
|
103
|
+
return GENERATED_HEADER_MD;
|
|
104
|
+
case "json":
|
|
105
|
+
return GENERATED_HEADER_JSON;
|
|
106
|
+
case "js":
|
|
107
|
+
case "ts":
|
|
108
|
+
return GENERATED_HEADER_JS;
|
|
109
|
+
default:
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// src/features/models.ts
|
|
115
|
+
import { join as join2 } from "path";
|
|
116
|
+
import { z } from "zod";
|
|
117
|
+
var SECRET_PATTERNS = [
|
|
118
|
+
/["']api[_-]?key["']\s*:/i,
|
|
119
|
+
/["']apiKey["']\s*:/i,
|
|
120
|
+
/["']secret["']\s*:/i,
|
|
121
|
+
/["']password["']\s*:/i,
|
|
122
|
+
/["'](?:auth_token|access_token|bearer_token)["']\s*:/i,
|
|
123
|
+
/["']private[_-]?key["']\s*:/i,
|
|
124
|
+
/-----BEGIN\s+(RSA|EC|DSA|OPENSSH|PGP)\s+PRIVATE\s+KEY-----/,
|
|
125
|
+
/sk-[a-zA-Z0-9]{20,}/,
|
|
126
|
+
/Bearer\s+[a-zA-Z0-9._-]{20,}/
|
|
127
|
+
];
|
|
128
|
+
var AgentModelSchema = z.object({
|
|
129
|
+
model: z.string(),
|
|
130
|
+
temperature: z.number().min(0).max(2).optional(),
|
|
131
|
+
top_p: z.number().min(0).max(1).optional()
|
|
132
|
+
});
|
|
133
|
+
var ModelProfileSchema = z.object({
|
|
134
|
+
extends: z.string().optional(),
|
|
135
|
+
description: z.string().optional(),
|
|
136
|
+
default: z.string().optional(),
|
|
137
|
+
small: z.string().optional(),
|
|
138
|
+
agents: z.record(z.string(), AgentModelSchema).optional()
|
|
139
|
+
});
|
|
140
|
+
var RoutingConditionSchema = z.object({
|
|
141
|
+
complexity: z.enum(["low", "medium", "high", "critical"]).optional().describe("Task complexity level"),
|
|
142
|
+
urgency: z.enum(["low", "normal", "high"]).optional().describe("Time sensitivity"),
|
|
143
|
+
budget: z.enum(["minimal", "standard", "premium"]).optional().describe("Cost/token budget tier"),
|
|
144
|
+
contextWindowNeed: z.enum(["small", "medium", "large", "max"]).optional().describe("Required context window size"),
|
|
145
|
+
toolUseIntensity: z.enum(["none", "light", "heavy"]).optional().describe("Expected tool/function calling intensity")
|
|
146
|
+
});
|
|
147
|
+
var RoutingRuleSchema = z.object({
|
|
148
|
+
when: z.record(z.string(), z.string()),
|
|
149
|
+
use: z.string(),
|
|
150
|
+
description: z.string().optional(),
|
|
151
|
+
priority: z.number().optional()
|
|
152
|
+
});
|
|
153
|
+
var ProviderModelSchema = z.object({
|
|
154
|
+
options: z.record(z.string(), z.unknown()).optional(),
|
|
155
|
+
variants: z.record(z.string(), z.record(z.string(), z.unknown())).optional()
|
|
156
|
+
});
|
|
157
|
+
var ProviderConfigSchema = z.object({
|
|
158
|
+
options: z.record(z.string(), z.unknown()).optional(),
|
|
159
|
+
models: z.record(z.string(), ProviderModelSchema).optional()
|
|
160
|
+
});
|
|
161
|
+
var ModelsSchema = z.object({
|
|
162
|
+
default: z.string().optional(),
|
|
163
|
+
small: z.string().optional(),
|
|
164
|
+
agents: z.record(z.string(), AgentModelSchema).optional(),
|
|
165
|
+
profiles: z.record(z.string(), ModelProfileSchema).optional(),
|
|
166
|
+
providers: z.record(z.string(), ProviderConfigSchema).optional(),
|
|
167
|
+
routing: z.array(RoutingRuleSchema).optional(),
|
|
168
|
+
overrides: z.record(z.string(), z.object({
|
|
169
|
+
default: z.string().optional(),
|
|
170
|
+
small: z.string().optional(),
|
|
171
|
+
agents: z.record(z.string(), AgentModelSchema).optional()
|
|
172
|
+
})).optional()
|
|
173
|
+
});
|
|
174
|
+
function parseModels(packDir, packName) {
|
|
175
|
+
const modelsPath = join2(packDir, "models.json");
|
|
176
|
+
const raw = readJsonOrNull(modelsPath);
|
|
177
|
+
if (!raw)
|
|
178
|
+
return null;
|
|
179
|
+
const parsed = ModelsSchema.parse(raw);
|
|
180
|
+
return {
|
|
181
|
+
packName,
|
|
182
|
+
sourcePath: modelsPath,
|
|
183
|
+
config: parsed
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function mergeModelsConfigs(configs) {
|
|
187
|
+
const warnings = [];
|
|
188
|
+
const result = {};
|
|
189
|
+
for (const entry of configs) {
|
|
190
|
+
const { config, packName } = entry;
|
|
191
|
+
if (config.default !== undefined && result.default === undefined) {
|
|
192
|
+
result.default = config.default;
|
|
193
|
+
} else if (config.default !== undefined && result.default !== undefined) {
|
|
194
|
+
warnings.push(`Models "default" from pack "${packName}" skipped (already defined).`);
|
|
195
|
+
}
|
|
196
|
+
if (config.small !== undefined && result.small === undefined) {
|
|
197
|
+
result.small = config.small;
|
|
198
|
+
} else if (config.small !== undefined && result.small !== undefined) {
|
|
199
|
+
warnings.push(`Models "small" from pack "${packName}" skipped (already defined).`);
|
|
200
|
+
}
|
|
201
|
+
if (config.agents) {
|
|
202
|
+
if (!result.agents)
|
|
203
|
+
result.agents = {};
|
|
204
|
+
for (const [name, assignment] of Object.entries(config.agents)) {
|
|
205
|
+
if (name in result.agents) {
|
|
206
|
+
warnings.push(`Models agent "${name}" from pack "${packName}" skipped (already defined).`);
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
result.agents[name] = assignment;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (config.profiles) {
|
|
213
|
+
if (!result.profiles)
|
|
214
|
+
result.profiles = {};
|
|
215
|
+
for (const [name, profile] of Object.entries(config.profiles)) {
|
|
216
|
+
if (name in result.profiles) {
|
|
217
|
+
warnings.push(`Models profile "${name}" from pack "${packName}" skipped (already defined).`);
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
result.profiles[name] = profile;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (config.providers) {
|
|
224
|
+
if (!result.providers)
|
|
225
|
+
result.providers = {};
|
|
226
|
+
for (const [providerName, providerConfig] of Object.entries(config.providers)) {
|
|
227
|
+
if (!(providerName in result.providers)) {
|
|
228
|
+
result.providers[providerName] = providerConfig;
|
|
229
|
+
} else {
|
|
230
|
+
const existing = result.providers[providerName];
|
|
231
|
+
if (!existing) {
|
|
232
|
+
result.providers[providerName] = providerConfig;
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
if (providerConfig.options) {
|
|
236
|
+
existing.options = {
|
|
237
|
+
...providerConfig.options,
|
|
238
|
+
...existing.options
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
if (providerConfig.models) {
|
|
242
|
+
if (!existing.models)
|
|
243
|
+
existing.models = {};
|
|
244
|
+
for (const [modelName, modelConfig] of Object.entries(providerConfig.models)) {
|
|
245
|
+
if (!(modelName in existing.models)) {
|
|
246
|
+
existing.models[modelName] = modelConfig;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (config.routing) {
|
|
254
|
+
if (!result.routing)
|
|
255
|
+
result.routing = [];
|
|
256
|
+
result.routing.push(...config.routing);
|
|
257
|
+
}
|
|
258
|
+
if (config.overrides) {
|
|
259
|
+
if (!result.overrides)
|
|
260
|
+
result.overrides = {};
|
|
261
|
+
for (const [targetId, override] of Object.entries(config.overrides)) {
|
|
262
|
+
if (targetId in result.overrides) {
|
|
263
|
+
warnings.push(`Models override for target "${targetId}" from pack "${packName}" skipped (already defined).`);
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
result.overrides[targetId] = override;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return { config: result, warnings };
|
|
271
|
+
}
|
|
272
|
+
function scanModelsForSecrets(config) {
|
|
273
|
+
const warnings = [];
|
|
274
|
+
const json = JSON.stringify(config);
|
|
275
|
+
for (const pattern of SECRET_PATTERNS) {
|
|
276
|
+
if (pattern.test(json)) {
|
|
277
|
+
warnings.push(`Potential secret detected in models.json matching pattern: ${pattern.source}`);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return warnings;
|
|
281
|
+
}
|
|
282
|
+
|
|
32
283
|
// src/core/feature-merger.ts
|
|
33
284
|
class FeatureMerger {
|
|
34
285
|
packs;
|
|
@@ -46,7 +297,8 @@ class FeatureMerger {
|
|
|
46
297
|
hooks: this.mergeHooks(),
|
|
47
298
|
plugins: this.mergePlugins(),
|
|
48
299
|
mcpServers: this.mergeMcp(),
|
|
49
|
-
ignorePatterns: this.mergeIgnore()
|
|
300
|
+
ignorePatterns: this.mergeIgnore(),
|
|
301
|
+
models: this.mergeModels()
|
|
50
302
|
};
|
|
51
303
|
return { features, warnings: this.warnings };
|
|
52
304
|
}
|
|
@@ -133,6 +385,14 @@ class FeatureMerger {
|
|
|
133
385
|
}
|
|
134
386
|
return result;
|
|
135
387
|
}
|
|
388
|
+
mergeModels() {
|
|
389
|
+
const configs = this.packs.map((p) => p.models).filter((m) => m != null);
|
|
390
|
+
if (configs.length === 0)
|
|
391
|
+
return null;
|
|
392
|
+
const { config, warnings } = mergeModelsConfigs(configs);
|
|
393
|
+
this.warnings.push(...warnings);
|
|
394
|
+
return config;
|
|
395
|
+
}
|
|
136
396
|
}
|
|
137
397
|
export {
|
|
138
398
|
FeatureMerger
|