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,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
|
-
|
|
55
|
+
rmSync(targetPath, { recursive: true, force: true });
|
|
84
56
|
}
|
|
85
57
|
}
|
|
86
58
|
function listFiles(dirPath, options = {}) {
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
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
|
+
export {
|
|
283
|
+
scanModelsForSecrets,
|
|
284
|
+
parseModels,
|
|
285
|
+
mergeModelsConfigs,
|
|
286
|
+
RoutingRuleSchema,
|
|
287
|
+
RoutingConditionSchema,
|
|
288
|
+
ProviderModelSchema,
|
|
289
|
+
ProviderConfigSchema,
|
|
290
|
+
ModelsSchema,
|
|
291
|
+
ModelProfileSchema,
|
|
292
|
+
AgentModelSchema
|
|
293
|
+
};
|
|
@@ -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
|
-
|
|
55
|
+
rmSync(targetPath, { recursive: true, force: true });
|
|
84
56
|
}
|
|
85
57
|
}
|
|
86
58
|
function listFiles(dirPath, options = {}) {
|
|
@@ -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
|
-
|
|
55
|
+
rmSync(targetPath, { recursive: true, force: true });
|
|
84
56
|
}
|
|
85
57
|
}
|
|
86
58
|
function listFiles(dirPath, options = {}) {
|
|
@@ -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
|
-
|
|
55
|
+
rmSync(targetPath, { recursive: true, force: true });
|
|
84
56
|
}
|
|
85
57
|
}
|
|
86
58
|
function listFiles(dirPath, options = {}) {
|
|
@@ -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
|
-
|
|
55
|
+
rmSync(targetPath, { recursive: true, force: true });
|
|
84
56
|
}
|
|
85
57
|
}
|
|
86
58
|
function listFiles(dirPath, options = {}) {
|
|
@@ -141,12 +113,12 @@ function getHeader(type) {
|
|
|
141
113
|
|
|
142
114
|
// src/importers/claude-code.ts
|
|
143
115
|
import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2, copyFileSync } from "fs";
|
|
144
|
-
import { resolve
|
|
116
|
+
import { resolve, join as join2, basename } from "path";
|
|
145
117
|
function importFromClaudeCode(projectRoot, outputPackDir) {
|
|
146
118
|
const warnings = [];
|
|
147
119
|
const filesImported = [];
|
|
148
|
-
const claudeDir =
|
|
149
|
-
const hasClaudeMd = existsSync2(
|
|
120
|
+
const claudeDir = resolve(projectRoot, ".claude");
|
|
121
|
+
const hasClaudeMd = existsSync2(resolve(projectRoot, "CLAUDE.md"));
|
|
150
122
|
const hasClaudeDir = existsSync2(claudeDir);
|
|
151
123
|
if (!hasClaudeMd && !hasClaudeDir) {
|
|
152
124
|
return {
|
|
@@ -156,12 +128,12 @@ function importFromClaudeCode(projectRoot, outputPackDir) {
|
|
|
156
128
|
configGenerated: false
|
|
157
129
|
};
|
|
158
130
|
}
|
|
159
|
-
const packDir = outputPackDir ??
|
|
131
|
+
const packDir = outputPackDir ?? resolve(projectRoot, "packs", "claude-import");
|
|
160
132
|
ensureDir(packDir);
|
|
161
|
-
const rulesDir =
|
|
133
|
+
const rulesDir = resolve(packDir, "rules");
|
|
162
134
|
ensureDir(rulesDir);
|
|
163
135
|
if (hasClaudeMd) {
|
|
164
|
-
const raw = readFileSync2(
|
|
136
|
+
const raw = readFileSync2(resolve(projectRoot, "CLAUDE.md"), "utf-8");
|
|
165
137
|
const ruleContent = [
|
|
166
138
|
"---",
|
|
167
139
|
"root: true",
|
|
@@ -176,7 +148,7 @@ function importFromClaudeCode(projectRoot, outputPackDir) {
|
|
|
176
148
|
filesImported.push(dest);
|
|
177
149
|
}
|
|
178
150
|
if (hasClaudeDir) {
|
|
179
|
-
const claudeRulesDir =
|
|
151
|
+
const claudeRulesDir = resolve(claudeDir, "rules");
|
|
180
152
|
if (existsSync2(claudeRulesDir)) {
|
|
181
153
|
const files = listFiles(claudeRulesDir, { extension: ".md" });
|
|
182
154
|
for (const file of files) {
|
|
@@ -185,7 +157,7 @@ function importFromClaudeCode(projectRoot, outputPackDir) {
|
|
|
185
157
|
filesImported.push(dest);
|
|
186
158
|
}
|
|
187
159
|
}
|
|
188
|
-
const settingsPath =
|
|
160
|
+
const settingsPath = resolve(claudeDir, "settings.json");
|
|
189
161
|
if (existsSync2(settingsPath)) {
|
|
190
162
|
try {
|
|
191
163
|
const raw = readFileSync2(settingsPath, "utf-8");
|