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
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/core/profile-resolver.ts
|
|
5
|
+
function resolveModels(merged, modelProfile, targetId) {
|
|
6
|
+
let defaultModel = merged.default;
|
|
7
|
+
let smallModel = merged.small;
|
|
8
|
+
let agents = { ...merged.agents };
|
|
9
|
+
if (modelProfile && merged.profiles?.[modelProfile]) {
|
|
10
|
+
const resolvedProfile = resolveProfileInheritance(modelProfile, merged.profiles);
|
|
11
|
+
if (resolvedProfile.default)
|
|
12
|
+
defaultModel = resolvedProfile.default;
|
|
13
|
+
if (resolvedProfile.small)
|
|
14
|
+
smallModel = resolvedProfile.small;
|
|
15
|
+
if (resolvedProfile.agents) {
|
|
16
|
+
agents = { ...agents, ...resolvedProfile.agents };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (targetId) {
|
|
20
|
+
const targetOverride = merged.overrides?.[targetId];
|
|
21
|
+
if (targetOverride) {
|
|
22
|
+
if (targetOverride.default)
|
|
23
|
+
defaultModel = targetOverride.default;
|
|
24
|
+
if (targetOverride.small)
|
|
25
|
+
smallModel = targetOverride.small;
|
|
26
|
+
if (targetOverride.agents) {
|
|
27
|
+
agents = { ...agents, ...targetOverride.agents };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const providers = {};
|
|
32
|
+
if (merged.providers) {
|
|
33
|
+
for (const [name, config] of Object.entries(merged.providers)) {
|
|
34
|
+
providers[name] = {
|
|
35
|
+
...config.options ? { options: config.options } : {},
|
|
36
|
+
...config.models ? { models: config.models } : {}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const profileNames = Object.keys(merged.profiles ?? {});
|
|
41
|
+
const profiles = {};
|
|
42
|
+
if (merged.profiles) {
|
|
43
|
+
for (const [name, profile] of Object.entries(merged.profiles)) {
|
|
44
|
+
profiles[name] = {
|
|
45
|
+
description: profile.description,
|
|
46
|
+
default: profile.default,
|
|
47
|
+
small: profile.small
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
default: defaultModel,
|
|
53
|
+
small: smallModel,
|
|
54
|
+
agents,
|
|
55
|
+
providers,
|
|
56
|
+
routing: merged.routing ?? [],
|
|
57
|
+
profileNames,
|
|
58
|
+
activeProfile: modelProfile,
|
|
59
|
+
profiles
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function resolveAgentModel(resolved, agentName, frontmatterModel) {
|
|
63
|
+
const fromModels = resolved.agents[agentName];
|
|
64
|
+
if (fromModels) {
|
|
65
|
+
return {
|
|
66
|
+
model: fromModels.model,
|
|
67
|
+
temperature: fromModels.temperature,
|
|
68
|
+
top_p: fromModels.top_p
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (frontmatterModel) {
|
|
72
|
+
return { model: frontmatterModel };
|
|
73
|
+
}
|
|
74
|
+
return {};
|
|
75
|
+
}
|
|
76
|
+
function resolveProfileInheritance(profileName, profiles) {
|
|
77
|
+
const visited = new Set;
|
|
78
|
+
return resolveProfileChain(profileName, profiles, visited, 0);
|
|
79
|
+
}
|
|
80
|
+
var MAX_INHERITANCE_DEPTH = 10;
|
|
81
|
+
function resolveProfileChain(name, profiles, visited, depth) {
|
|
82
|
+
if (depth > MAX_INHERITANCE_DEPTH) {
|
|
83
|
+
throw new Error(`Profile inheritance too deep (max ${MAX_INHERITANCE_DEPTH}): ${name}`);
|
|
84
|
+
}
|
|
85
|
+
if (visited.has(name)) {
|
|
86
|
+
throw new Error(`Circular profile inheritance detected: ${[...visited, name].join(" → ")}`);
|
|
87
|
+
}
|
|
88
|
+
const profile = profiles[name];
|
|
89
|
+
if (!profile) {
|
|
90
|
+
throw new Error(`Profile "${name}" not found`);
|
|
91
|
+
}
|
|
92
|
+
visited.add(name);
|
|
93
|
+
if (!profile.extends) {
|
|
94
|
+
return { ...profile };
|
|
95
|
+
}
|
|
96
|
+
const parent = resolveProfileChain(profile.extends, profiles, visited, depth + 1);
|
|
97
|
+
return {
|
|
98
|
+
description: profile.description ?? parent.description,
|
|
99
|
+
default: profile.default ?? parent.default,
|
|
100
|
+
small: profile.small ?? parent.small,
|
|
101
|
+
agents: {
|
|
102
|
+
...parent.agents,
|
|
103
|
+
...profile.agents
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export {
|
|
108
|
+
resolveProfileInheritance,
|
|
109
|
+
resolveModels,
|
|
110
|
+
resolveAgentModel
|
|
111
|
+
};
|
|
@@ -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 = {}) {
|
|
@@ -158,11 +130,11 @@ function serializeFrontmatter(data, content) {
|
|
|
158
130
|
}
|
|
159
131
|
|
|
160
132
|
// src/exporters/cursor-plugin.ts
|
|
161
|
-
import { resolve
|
|
133
|
+
import { resolve, join as join2 } from "path";
|
|
162
134
|
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
163
135
|
function exportCursorPlugin(pack, outputDir) {
|
|
164
136
|
const filesWritten = [];
|
|
165
|
-
const pluginDir =
|
|
137
|
+
const pluginDir = resolve(outputDir, pack.manifest.name);
|
|
166
138
|
mkdirSync2(pluginDir, { recursive: true });
|
|
167
139
|
const manifest = {
|
|
168
140
|
name: pack.manifest.name,
|
|
@@ -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 = {}) {
|
|
@@ -158,11 +130,11 @@ function serializeFrontmatter(data, content) {
|
|
|
158
130
|
}
|
|
159
131
|
|
|
160
132
|
// src/exporters/cursor-plugin.ts
|
|
161
|
-
import { resolve
|
|
133
|
+
import { resolve, join as join2 } from "path";
|
|
162
134
|
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
163
135
|
function exportCursorPlugin(pack, outputDir) {
|
|
164
136
|
const filesWritten = [];
|
|
165
|
-
const pluginDir =
|
|
137
|
+
const pluginDir = resolve(outputDir, pack.manifest.name);
|
|
166
138
|
mkdirSync2(pluginDir, { recursive: true });
|
|
167
139
|
const manifest = {
|
|
168
140
|
name: pack.manifest.name,
|
|
@@ -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/features/ignore.ts
|
|
@@ -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 = {}) {
|
|
@@ -405,22 +377,195 @@ function mergeIgnorePatterns(configs) {
|
|
|
405
377
|
}
|
|
406
378
|
return result;
|
|
407
379
|
}
|
|
380
|
+
|
|
381
|
+
// src/features/models.ts
|
|
382
|
+
import { join as join7 } from "path";
|
|
383
|
+
import { z } from "zod";
|
|
384
|
+
var SECRET_PATTERNS = [
|
|
385
|
+
/["']api[_-]?key["']\s*:/i,
|
|
386
|
+
/["']apiKey["']\s*:/i,
|
|
387
|
+
/["']secret["']\s*:/i,
|
|
388
|
+
/["']password["']\s*:/i,
|
|
389
|
+
/["'](?:auth_token|access_token|bearer_token)["']\s*:/i,
|
|
390
|
+
/["']private[_-]?key["']\s*:/i,
|
|
391
|
+
/-----BEGIN\s+(RSA|EC|DSA|OPENSSH|PGP)\s+PRIVATE\s+KEY-----/,
|
|
392
|
+
/sk-[a-zA-Z0-9]{20,}/,
|
|
393
|
+
/Bearer\s+[a-zA-Z0-9._-]{20,}/
|
|
394
|
+
];
|
|
395
|
+
var AgentModelSchema = z.object({
|
|
396
|
+
model: z.string(),
|
|
397
|
+
temperature: z.number().min(0).max(2).optional(),
|
|
398
|
+
top_p: z.number().min(0).max(1).optional()
|
|
399
|
+
});
|
|
400
|
+
var ModelProfileSchema = z.object({
|
|
401
|
+
extends: z.string().optional(),
|
|
402
|
+
description: z.string().optional(),
|
|
403
|
+
default: z.string().optional(),
|
|
404
|
+
small: z.string().optional(),
|
|
405
|
+
agents: z.record(z.string(), AgentModelSchema).optional()
|
|
406
|
+
});
|
|
407
|
+
var RoutingConditionSchema = z.object({
|
|
408
|
+
complexity: z.enum(["low", "medium", "high", "critical"]).optional().describe("Task complexity level"),
|
|
409
|
+
urgency: z.enum(["low", "normal", "high"]).optional().describe("Time sensitivity"),
|
|
410
|
+
budget: z.enum(["minimal", "standard", "premium"]).optional().describe("Cost/token budget tier"),
|
|
411
|
+
contextWindowNeed: z.enum(["small", "medium", "large", "max"]).optional().describe("Required context window size"),
|
|
412
|
+
toolUseIntensity: z.enum(["none", "light", "heavy"]).optional().describe("Expected tool/function calling intensity")
|
|
413
|
+
});
|
|
414
|
+
var RoutingRuleSchema = z.object({
|
|
415
|
+
when: z.record(z.string(), z.string()),
|
|
416
|
+
use: z.string(),
|
|
417
|
+
description: z.string().optional(),
|
|
418
|
+
priority: z.number().optional()
|
|
419
|
+
});
|
|
420
|
+
var ProviderModelSchema = z.object({
|
|
421
|
+
options: z.record(z.string(), z.unknown()).optional(),
|
|
422
|
+
variants: z.record(z.string(), z.record(z.string(), z.unknown())).optional()
|
|
423
|
+
});
|
|
424
|
+
var ProviderConfigSchema = z.object({
|
|
425
|
+
options: z.record(z.string(), z.unknown()).optional(),
|
|
426
|
+
models: z.record(z.string(), ProviderModelSchema).optional()
|
|
427
|
+
});
|
|
428
|
+
var ModelsSchema = z.object({
|
|
429
|
+
default: z.string().optional(),
|
|
430
|
+
small: z.string().optional(),
|
|
431
|
+
agents: z.record(z.string(), AgentModelSchema).optional(),
|
|
432
|
+
profiles: z.record(z.string(), ModelProfileSchema).optional(),
|
|
433
|
+
providers: z.record(z.string(), ProviderConfigSchema).optional(),
|
|
434
|
+
routing: z.array(RoutingRuleSchema).optional(),
|
|
435
|
+
overrides: z.record(z.string(), z.object({
|
|
436
|
+
default: z.string().optional(),
|
|
437
|
+
small: z.string().optional(),
|
|
438
|
+
agents: z.record(z.string(), AgentModelSchema).optional()
|
|
439
|
+
})).optional()
|
|
440
|
+
});
|
|
441
|
+
function parseModels(packDir, packName) {
|
|
442
|
+
const modelsPath = join7(packDir, "models.json");
|
|
443
|
+
const raw = readJsonOrNull(modelsPath);
|
|
444
|
+
if (!raw)
|
|
445
|
+
return null;
|
|
446
|
+
const parsed = ModelsSchema.parse(raw);
|
|
447
|
+
return {
|
|
448
|
+
packName,
|
|
449
|
+
sourcePath: modelsPath,
|
|
450
|
+
config: parsed
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
function mergeModelsConfigs(configs) {
|
|
454
|
+
const warnings = [];
|
|
455
|
+
const result = {};
|
|
456
|
+
for (const entry of configs) {
|
|
457
|
+
const { config, packName } = entry;
|
|
458
|
+
if (config.default !== undefined && result.default === undefined) {
|
|
459
|
+
result.default = config.default;
|
|
460
|
+
} else if (config.default !== undefined && result.default !== undefined) {
|
|
461
|
+
warnings.push(`Models "default" from pack "${packName}" skipped (already defined).`);
|
|
462
|
+
}
|
|
463
|
+
if (config.small !== undefined && result.small === undefined) {
|
|
464
|
+
result.small = config.small;
|
|
465
|
+
} else if (config.small !== undefined && result.small !== undefined) {
|
|
466
|
+
warnings.push(`Models "small" from pack "${packName}" skipped (already defined).`);
|
|
467
|
+
}
|
|
468
|
+
if (config.agents) {
|
|
469
|
+
if (!result.agents)
|
|
470
|
+
result.agents = {};
|
|
471
|
+
for (const [name, assignment] of Object.entries(config.agents)) {
|
|
472
|
+
if (name in result.agents) {
|
|
473
|
+
warnings.push(`Models agent "${name}" from pack "${packName}" skipped (already defined).`);
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
result.agents[name] = assignment;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (config.profiles) {
|
|
480
|
+
if (!result.profiles)
|
|
481
|
+
result.profiles = {};
|
|
482
|
+
for (const [name, profile] of Object.entries(config.profiles)) {
|
|
483
|
+
if (name in result.profiles) {
|
|
484
|
+
warnings.push(`Models profile "${name}" from pack "${packName}" skipped (already defined).`);
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
result.profiles[name] = profile;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
if (config.providers) {
|
|
491
|
+
if (!result.providers)
|
|
492
|
+
result.providers = {};
|
|
493
|
+
for (const [providerName, providerConfig] of Object.entries(config.providers)) {
|
|
494
|
+
if (!(providerName in result.providers)) {
|
|
495
|
+
result.providers[providerName] = providerConfig;
|
|
496
|
+
} else {
|
|
497
|
+
const existing = result.providers[providerName];
|
|
498
|
+
if (!existing) {
|
|
499
|
+
result.providers[providerName] = providerConfig;
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
if (providerConfig.options) {
|
|
503
|
+
existing.options = {
|
|
504
|
+
...providerConfig.options,
|
|
505
|
+
...existing.options
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
if (providerConfig.models) {
|
|
509
|
+
if (!existing.models)
|
|
510
|
+
existing.models = {};
|
|
511
|
+
for (const [modelName, modelConfig] of Object.entries(providerConfig.models)) {
|
|
512
|
+
if (!(modelName in existing.models)) {
|
|
513
|
+
existing.models[modelName] = modelConfig;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
if (config.routing) {
|
|
521
|
+
if (!result.routing)
|
|
522
|
+
result.routing = [];
|
|
523
|
+
result.routing.push(...config.routing);
|
|
524
|
+
}
|
|
525
|
+
if (config.overrides) {
|
|
526
|
+
if (!result.overrides)
|
|
527
|
+
result.overrides = {};
|
|
528
|
+
for (const [targetId, override] of Object.entries(config.overrides)) {
|
|
529
|
+
if (targetId in result.overrides) {
|
|
530
|
+
warnings.push(`Models override for target "${targetId}" from pack "${packName}" skipped (already defined).`);
|
|
531
|
+
continue;
|
|
532
|
+
}
|
|
533
|
+
result.overrides[targetId] = override;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
return { config: result, warnings };
|
|
538
|
+
}
|
|
539
|
+
function scanModelsForSecrets(config) {
|
|
540
|
+
const warnings = [];
|
|
541
|
+
const json = JSON.stringify(config);
|
|
542
|
+
for (const pattern of SECRET_PATTERNS) {
|
|
543
|
+
if (pattern.test(json)) {
|
|
544
|
+
warnings.push(`Potential secret detected in models.json matching pattern: ${pattern.source}`);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
return warnings;
|
|
548
|
+
}
|
|
408
549
|
export {
|
|
409
550
|
skillMatchesTarget,
|
|
551
|
+
scanModelsForSecrets,
|
|
410
552
|
ruleMatchesTarget,
|
|
411
553
|
resolveHooksForTarget,
|
|
412
554
|
parseSkills,
|
|
413
555
|
parseRules,
|
|
414
556
|
parsePlugins,
|
|
557
|
+
parseModels,
|
|
415
558
|
parseMcp,
|
|
416
559
|
parseIgnore,
|
|
417
560
|
parseHooks,
|
|
418
561
|
parseCommands,
|
|
419
562
|
parseAgents,
|
|
563
|
+
mergeModelsConfigs,
|
|
420
564
|
mergeMcpConfigs,
|
|
421
565
|
mergeIgnorePatterns,
|
|
422
566
|
getRootRules,
|
|
423
567
|
getDetailRules,
|
|
424
568
|
commandMatchesTarget,
|
|
425
|
-
agentMatchesTarget
|
|
569
|
+
agentMatchesTarget,
|
|
570
|
+
ModelsSchema
|
|
426
571
|
};
|