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
package/dist/cli/export-cmd.js
CHANGED
|
@@ -1,51 +1,85 @@
|
|
|
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
|
|
|
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
|
-
|
|
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
|
|
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 =
|
|
584
|
-
const commandsDir =
|
|
585
|
-
const agentsDir =
|
|
586
|
-
const skillsDir =
|
|
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 =
|
|
602
|
-
const localConfigPath =
|
|
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
|
|
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 =
|
|
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,33 +750,37 @@ class PackLoader {
|
|
|
621
750
|
const parts = packName.split("/");
|
|
622
751
|
packName = packName.includes("@") ? parts.join("-") : parts[parts.length - 1] ?? packName;
|
|
623
752
|
}
|
|
624
|
-
|
|
625
|
-
|
|
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
|
|
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
|
|
774
|
+
return resolve2(this.projectRoot, packRef);
|
|
642
775
|
}
|
|
643
776
|
}
|
|
644
777
|
|
|
645
778
|
// src/exporters/cursor-plugin.ts
|
|
646
|
-
import { resolve as
|
|
779
|
+
import { resolve as resolve3, join as join8 } from "path";
|
|
647
780
|
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
648
781
|
function exportCursorPlugin(pack, outputDir) {
|
|
649
782
|
const filesWritten = [];
|
|
650
|
-
const pluginDir =
|
|
783
|
+
const pluginDir = resolve3(outputDir, pack.manifest.name);
|
|
651
784
|
mkdirSync2(pluginDir, { recursive: true });
|
|
652
785
|
const manifest = {
|
|
653
786
|
name: pack.manifest.name,
|
|
@@ -661,7 +794,7 @@ function exportCursorPlugin(pack, outputDir) {
|
|
|
661
794
|
manifest.tags = pack.manifest.tags;
|
|
662
795
|
}
|
|
663
796
|
if (pack.rules.length > 0) {
|
|
664
|
-
const rulesDir =
|
|
797
|
+
const rulesDir = join8(pluginDir, "rules");
|
|
665
798
|
ensureDir(rulesDir);
|
|
666
799
|
manifest.rules = [];
|
|
667
800
|
for (const rule of pack.rules) {
|
|
@@ -674,14 +807,14 @@ function exportCursorPlugin(pack, outputDir) {
|
|
|
674
807
|
if (globs)
|
|
675
808
|
fm.globs = globs;
|
|
676
809
|
const filename = `${rule.name}.mdc`;
|
|
677
|
-
const filepath =
|
|
810
|
+
const filepath = join8(rulesDir, filename);
|
|
678
811
|
writeFileSync2(filepath, serializeFrontmatter(fm, rule.content));
|
|
679
812
|
filesWritten.push(filepath);
|
|
680
813
|
manifest.rules.push(filename);
|
|
681
814
|
}
|
|
682
815
|
}
|
|
683
816
|
if (pack.agents.length > 0) {
|
|
684
|
-
const agentsDir =
|
|
817
|
+
const agentsDir = join8(pluginDir, "agents");
|
|
685
818
|
ensureDir(agentsDir);
|
|
686
819
|
manifest.agents = [];
|
|
687
820
|
for (const agent of pack.agents) {
|
|
@@ -690,36 +823,36 @@ function exportCursorPlugin(pack, outputDir) {
|
|
|
690
823
|
description: agent.meta.description ?? ""
|
|
691
824
|
};
|
|
692
825
|
const filename = `${agent.name}.md`;
|
|
693
|
-
const filepath =
|
|
826
|
+
const filepath = join8(agentsDir, filename);
|
|
694
827
|
writeFileSync2(filepath, serializeFrontmatter(fm, agent.content));
|
|
695
828
|
filesWritten.push(filepath);
|
|
696
829
|
manifest.agents.push(filename);
|
|
697
830
|
}
|
|
698
831
|
}
|
|
699
832
|
if (pack.skills.length > 0) {
|
|
700
|
-
const skillsDir =
|
|
833
|
+
const skillsDir = join8(pluginDir, "skills");
|
|
701
834
|
ensureDir(skillsDir);
|
|
702
835
|
manifest.skills = [];
|
|
703
836
|
for (const skill of pack.skills) {
|
|
704
|
-
const skillSubDir =
|
|
837
|
+
const skillSubDir = join8(skillsDir, skill.name);
|
|
705
838
|
ensureDir(skillSubDir);
|
|
706
839
|
const fm = {
|
|
707
840
|
name: skill.name,
|
|
708
841
|
description: skill.meta.description ?? ""
|
|
709
842
|
};
|
|
710
|
-
const filepath =
|
|
843
|
+
const filepath = join8(skillSubDir, "SKILL.md");
|
|
711
844
|
writeFileSync2(filepath, serializeFrontmatter(fm, skill.content));
|
|
712
845
|
filesWritten.push(filepath);
|
|
713
846
|
manifest.skills.push(skill.name);
|
|
714
847
|
}
|
|
715
848
|
}
|
|
716
849
|
if (pack.commands.length > 0) {
|
|
717
|
-
const commandsDir =
|
|
850
|
+
const commandsDir = join8(pluginDir, "commands");
|
|
718
851
|
ensureDir(commandsDir);
|
|
719
852
|
manifest.commands = [];
|
|
720
853
|
for (const cmd of pack.commands) {
|
|
721
854
|
const filename = `${cmd.name}.md`;
|
|
722
|
-
const filepath =
|
|
855
|
+
const filepath = join8(commandsDir, filename);
|
|
723
856
|
writeFileSync2(filepath, cmd.content);
|
|
724
857
|
filesWritten.push(filepath);
|
|
725
858
|
manifest.commands.push(filename);
|
|
@@ -727,12 +860,12 @@ function exportCursorPlugin(pack, outputDir) {
|
|
|
727
860
|
}
|
|
728
861
|
if (pack.mcp && Object.keys(pack.mcp.servers).length > 0) {
|
|
729
862
|
manifest.mcp = true;
|
|
730
|
-
const filepath =
|
|
863
|
+
const filepath = join8(pluginDir, "mcp.json");
|
|
731
864
|
writeFileSync2(filepath, JSON.stringify({ mcpServers: pack.mcp.servers }, null, 2) + `
|
|
732
865
|
`);
|
|
733
866
|
filesWritten.push(filepath);
|
|
734
867
|
}
|
|
735
|
-
const manifestPath =
|
|
868
|
+
const manifestPath = join8(pluginDir, "manifest.json");
|
|
736
869
|
writeFileSync2(manifestPath, JSON.stringify(manifest, null, 2) + `
|
|
737
870
|
`);
|
|
738
871
|
filesWritten.push(manifestPath);
|
|
@@ -740,8 +873,7 @@ function exportCursorPlugin(pack, outputDir) {
|
|
|
740
873
|
}
|
|
741
874
|
|
|
742
875
|
// src/cli/export-cmd.ts
|
|
743
|
-
|
|
744
|
-
import { resolve as resolve5 } from "path";
|
|
876
|
+
import { resolve as resolve4 } from "path";
|
|
745
877
|
import chalk from "chalk";
|
|
746
878
|
function runExport(projectRoot, options) {
|
|
747
879
|
const config = loadWorkspaceConfig(projectRoot);
|
|
@@ -760,7 +892,7 @@ function runExport(projectRoot, options) {
|
|
|
760
892
|
console.log(chalk.red(`Pack "${options.pack}" not found.`));
|
|
761
893
|
return;
|
|
762
894
|
}
|
|
763
|
-
const outputDir =
|
|
895
|
+
const outputDir = resolve4(projectRoot, options.output ?? "dist/cursor-plugins");
|
|
764
896
|
switch (options.format) {
|
|
765
897
|
case "cursor-plugin": {
|
|
766
898
|
let totalFiles = 0;
|