agentpacks 1.7.13 → 1.8.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/dist/api.js +48 -3658
- package/dist/cli/export-cmd.js +7 -1027
- package/dist/cli/generate.js +39 -2731
- package/dist/cli/import-cmd.js +19 -770
- package/dist/cli/info.js +4 -231
- package/dist/cli/init.js +9 -185
- package/dist/cli/install.js +4 -902
- package/dist/cli/login.js +6 -201
- package/dist/cli/models-explain.js +14 -1266
- package/dist/cli/pack/create.js +4 -146
- package/dist/cli/pack/enable.js +2 -65
- package/dist/cli/pack/list.js +5 -893
- package/dist/cli/pack/validate.js +4 -642
- package/dist/cli/publish.js +8 -679
- package/dist/cli/search.js +4 -209
- package/dist/core/config.d.ts +1 -1
- package/dist/core/config.js +1 -145
- package/dist/core/dependency-resolver.js +1 -126
- package/dist/core/feature-merger.js +3 -398
- package/dist/core/index.js +5 -1129
- package/dist/core/lockfile.js +2 -43
- package/dist/core/metarepo.js +1 -183
- package/dist/core/pack-loader.js +4 -841
- package/dist/core/profile-resolver.js +1 -110
- package/dist/exporters/cursor-plugin.js +6 -404
- package/dist/exporters/index.js +6 -404
- package/dist/features/agents.js +3 -161
- package/dist/features/commands.js +3 -161
- package/dist/features/hooks.js +3 -153
- package/dist/features/ignore.js +2 -43
- package/dist/features/index.js +4 -629
- package/dist/features/mcp.js +3 -143
- package/dist/features/models.js +3 -292
- package/dist/features/plugins.js +3 -139
- package/dist/features/rules.d.ts +0 -1
- package/dist/features/rules.js +3 -169
- package/dist/features/skills.js +3 -228
- package/dist/importers/claude-code.js +6 -195
- package/dist/importers/cursor.js +5 -355
- package/dist/importers/opencode.js +6 -346
- package/dist/importers/rulesync.js +5 -365
- package/dist/index.js +89 -4934
- package/dist/node/api.js +48 -3659
- package/dist/node/cli/export-cmd.js +7 -1028
- package/dist/node/cli/generate.js +39 -2732
- package/dist/node/cli/import-cmd.js +19 -771
- package/dist/node/cli/info.js +4 -232
- package/dist/node/cli/init.js +9 -186
- package/dist/node/cli/install.js +4 -903
- package/dist/node/cli/login.js +6 -202
- package/dist/node/cli/models-explain.js +14 -1267
- package/dist/node/cli/pack/create.js +4 -147
- package/dist/node/cli/pack/enable.js +2 -66
- package/dist/node/cli/pack/list.js +5 -894
- package/dist/node/cli/pack/validate.js +4 -643
- package/dist/node/cli/publish.js +8 -680
- package/dist/node/cli/search.js +4 -210
- package/dist/node/core/config.js +1 -146
- package/dist/node/core/dependency-resolver.js +1 -127
- package/dist/node/core/feature-merger.js +3 -399
- package/dist/node/core/index.js +5 -1130
- package/dist/node/core/lockfile.js +2 -44
- package/dist/node/core/metarepo.js +1 -184
- package/dist/node/core/pack-loader.js +4 -842
- package/dist/node/core/profile-resolver.js +1 -111
- package/dist/node/exporters/cursor-plugin.js +6 -405
- package/dist/node/exporters/index.js +6 -405
- package/dist/node/features/agents.js +3 -162
- package/dist/node/features/commands.js +3 -162
- package/dist/node/features/hooks.js +3 -154
- package/dist/node/features/ignore.js +2 -44
- package/dist/node/features/index.js +4 -630
- package/dist/node/features/mcp.js +3 -144
- package/dist/node/features/models.js +3 -293
- package/dist/node/features/plugins.js +3 -140
- package/dist/node/features/rules.js +3 -170
- package/dist/node/features/skills.js +3 -229
- package/dist/node/importers/claude-code.js +6 -196
- package/dist/node/importers/cursor.js +5 -356
- package/dist/node/importers/opencode.js +6 -347
- package/dist/node/importers/rulesync.js +5 -366
- package/dist/node/index.js +89 -4935
- package/dist/node/sources/git-ref.js +1 -56
- package/dist/node/sources/git.js +2 -222
- package/dist/node/sources/index.js +4 -714
- package/dist/node/sources/local.js +1 -24
- package/dist/node/sources/npm-ref.js +1 -56
- package/dist/node/sources/npm.js +2 -184
- package/dist/node/sources/registry-ref.js +1 -37
- package/dist/node/sources/registry.js +4 -355
- package/dist/node/targets/additional-targets.js +6 -587
- package/dist/node/targets/base-target.js +1 -23
- package/dist/node/targets/claude-code.js +6 -714
- package/dist/node/targets/codex-cli.js +3 -324
- package/dist/node/targets/copilot.js +5 -603
- package/dist/node/targets/cursor.js +6 -700
- package/dist/node/targets/gemini-cli.js +10 -319
- package/dist/node/targets/generic-md-target.js +6 -478
- package/dist/node/targets/index.js +32 -1873
- package/dist/node/targets/mistral-vibe.js +7 -661
- package/dist/node/targets/opencode.js +13 -723
- package/dist/node/targets/registry.js +32 -1864
- package/dist/node/utils/credentials.js +3 -38
- package/dist/node/utils/diff.js +5 -132
- package/dist/node/utils/filesystem.js +3 -124
- package/dist/node/utils/frontmatter.js +1 -24
- package/dist/node/utils/global.js +1 -53
- package/dist/node/utils/markdown.js +3 -30
- package/dist/node/utils/model-allowlist.js +1 -126
- package/dist/node/utils/model-guidance.js +2 -78
- package/dist/node/utils/registry-client.js +1 -142
- package/dist/node/utils/tarball.js +1 -49
- package/dist/sources/git-ref.js +1 -55
- package/dist/sources/git.js +2 -221
- package/dist/sources/index.js +4 -713
- package/dist/sources/local.js +1 -23
- package/dist/sources/npm-ref.js +1 -55
- package/dist/sources/npm.js +2 -183
- package/dist/sources/registry-ref.js +1 -36
- package/dist/sources/registry.js +4 -354
- package/dist/targets/additional-targets.js +6 -586
- package/dist/targets/base-target.js +1 -22
- package/dist/targets/claude-code.js +6 -713
- package/dist/targets/codex-cli.js +3 -323
- package/dist/targets/copilot.js +5 -602
- package/dist/targets/cursor.js +6 -699
- package/dist/targets/gemini-cli.js +10 -318
- package/dist/targets/generic-md-target.js +6 -477
- package/dist/targets/index.d.ts +0 -1
- package/dist/targets/index.js +32 -1872
- package/dist/targets/mistral-vibe.js +7 -660
- package/dist/targets/opencode.js +13 -722
- package/dist/targets/registry.js +32 -1863
- package/dist/utils/credentials.js +3 -37
- package/dist/utils/diff.js +5 -131
- package/dist/utils/filesystem.js +3 -123
- package/dist/utils/frontmatter.js +1 -23
- package/dist/utils/global.js +1 -52
- package/dist/utils/markdown.js +3 -29
- package/dist/utils/model-allowlist.js +1 -125
- package/dist/utils/model-guidance.js +2 -77
- package/dist/utils/registry-client.js +1 -141
- package/dist/utils/tarball.js +1 -48
- package/package.json +4 -16
- package/dist/node/targets/agents-md.js +0 -211
- package/dist/targets/agents-md.d.ts +0 -13
- package/dist/targets/agents-md.js +0 -211
|
@@ -1,661 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
readdirSync,
|
|
9
|
-
readFileSync,
|
|
10
|
-
rmSync,
|
|
11
|
-
statSync,
|
|
12
|
-
writeFileSync
|
|
13
|
-
} from "fs";
|
|
14
|
-
import { dirname, join, relative } 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/utils/frontmatter.ts
|
|
115
|
-
import matter from "gray-matter";
|
|
116
|
-
function parseFrontmatter(source) {
|
|
117
|
-
const { data, content } = matter(source);
|
|
118
|
-
return {
|
|
119
|
-
data,
|
|
120
|
-
content: content.trim(),
|
|
121
|
-
raw: source
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
function serializeFrontmatter(data, content) {
|
|
125
|
-
const filtered = Object.fromEntries(Object.entries(data).filter(([, v]) => v !== undefined));
|
|
126
|
-
if (Object.keys(filtered).length === 0) {
|
|
127
|
-
return content;
|
|
128
|
-
}
|
|
129
|
-
return matter.stringify(content, filtered);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// src/features/agents.ts
|
|
133
|
-
import { readFileSync as readFileSync2 } from "fs";
|
|
134
|
-
import { basename } from "path";
|
|
135
|
-
function parseAgents(agentsDir, packName) {
|
|
136
|
-
const files = listFiles(agentsDir, { extension: ".md" });
|
|
137
|
-
return files.map((filepath) => parseAgentFile(filepath, packName));
|
|
138
|
-
}
|
|
139
|
-
function parseAgentFile(filepath, packName) {
|
|
140
|
-
const raw = readFileSync2(filepath, "utf-8");
|
|
141
|
-
const { data, content } = parseFrontmatter(raw);
|
|
142
|
-
return {
|
|
143
|
-
name: data.name ?? basename(filepath, ".md"),
|
|
144
|
-
sourcePath: filepath,
|
|
145
|
-
packName,
|
|
146
|
-
meta: data,
|
|
147
|
-
content
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
function agentMatchesTarget(agent, targetId) {
|
|
151
|
-
const { targets } = agent.meta;
|
|
152
|
-
if (!targets || targets === "*")
|
|
153
|
-
return true;
|
|
154
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
155
|
-
return true;
|
|
156
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// src/features/commands.ts
|
|
160
|
-
import { readFileSync as readFileSync3 } from "fs";
|
|
161
|
-
import { basename as basename2 } from "path";
|
|
162
|
-
function parseCommands(commandsDir, packName) {
|
|
163
|
-
const files = listFiles(commandsDir, { extension: ".md" });
|
|
164
|
-
return files.map((filepath) => parseCommandFile(filepath, packName));
|
|
165
|
-
}
|
|
166
|
-
function parseCommandFile(filepath, packName) {
|
|
167
|
-
const raw = readFileSync3(filepath, "utf-8");
|
|
168
|
-
const { data, content } = parseFrontmatter(raw);
|
|
169
|
-
return {
|
|
170
|
-
name: basename2(filepath, ".md"),
|
|
171
|
-
sourcePath: filepath,
|
|
172
|
-
packName,
|
|
173
|
-
meta: data,
|
|
174
|
-
content
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
function commandMatchesTarget(cmd, targetId) {
|
|
178
|
-
const { targets } = cmd.meta;
|
|
179
|
-
if (!targets || targets === "*")
|
|
180
|
-
return true;
|
|
181
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
182
|
-
return true;
|
|
183
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// src/features/rules.ts
|
|
187
|
-
import { readFileSync as readFileSync4 } from "fs";
|
|
188
|
-
import { basename as basename3 } from "path";
|
|
189
|
-
function parseRules(rulesDir, packName) {
|
|
190
|
-
const files = listFiles(rulesDir, { extension: ".md" });
|
|
191
|
-
return files.map((filepath) => parseRuleFile(filepath, packName));
|
|
192
|
-
}
|
|
193
|
-
function parseRuleFile(filepath, packName) {
|
|
194
|
-
const raw = readFileSync4(filepath, "utf-8");
|
|
195
|
-
const { data, content } = parseFrontmatter(raw);
|
|
196
|
-
return {
|
|
197
|
-
name: basename3(filepath, ".md"),
|
|
198
|
-
sourcePath: filepath,
|
|
199
|
-
packName,
|
|
200
|
-
meta: data,
|
|
201
|
-
content
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
function ruleMatchesTarget(rule, targetId) {
|
|
205
|
-
const { targets } = rule.meta;
|
|
206
|
-
if (!targets || targets === "*")
|
|
207
|
-
return true;
|
|
208
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
209
|
-
return true;
|
|
210
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
211
|
-
}
|
|
212
|
-
function getRootRules(rules) {
|
|
213
|
-
return rules.filter((r) => r.meta.root === true);
|
|
214
|
-
}
|
|
215
|
-
function getDetailRules(rules) {
|
|
216
|
-
return rules.filter((r) => r.meta.root !== true);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// src/features/skills.ts
|
|
220
|
-
import { existsSync as existsSync2, readFileSync as readFileSync5 } from "fs";
|
|
221
|
-
import { basename as basename4, join as join2 } from "path";
|
|
222
|
-
var SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
223
|
-
var SKILL_NAME_MAX_LENGTH = 64;
|
|
224
|
-
function parseSkills(skillsDir, packName) {
|
|
225
|
-
const dirs = listDirs(skillsDir);
|
|
226
|
-
const skills = [];
|
|
227
|
-
for (const dir of dirs) {
|
|
228
|
-
const skillMd = join2(dir, "SKILL.md");
|
|
229
|
-
if (existsSync2(skillMd)) {
|
|
230
|
-
skills.push(parseSkillFile(skillMd, dir, packName));
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
return skills;
|
|
234
|
-
}
|
|
235
|
-
function parseSkillFile(filepath, skillDir, packName) {
|
|
236
|
-
const raw = readFileSync5(filepath, "utf-8");
|
|
237
|
-
const { data, content } = parseFrontmatter(raw);
|
|
238
|
-
return {
|
|
239
|
-
name: data.name ?? basename4(skillDir),
|
|
240
|
-
sourcePath: filepath,
|
|
241
|
-
sourceDir: skillDir,
|
|
242
|
-
packName,
|
|
243
|
-
meta: data,
|
|
244
|
-
content
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
function buildSkillFrontmatter(skill) {
|
|
248
|
-
return {
|
|
249
|
-
...skill.meta,
|
|
250
|
-
name: skill.name
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
function serializeSkill(skill) {
|
|
254
|
-
return serializeFrontmatter(buildSkillFrontmatter(skill), skill.content);
|
|
255
|
-
}
|
|
256
|
-
function normalizeImportedSkillMarkdown(source, skillName) {
|
|
257
|
-
const { data, content } = parseFrontmatter(source);
|
|
258
|
-
const normalized = {
|
|
259
|
-
...data,
|
|
260
|
-
name: skillName
|
|
261
|
-
};
|
|
262
|
-
let addedDescription = false;
|
|
263
|
-
const description = normalized.description;
|
|
264
|
-
if (typeof description !== "string" || description.trim().length === 0) {
|
|
265
|
-
normalized.description = `Imported skill: ${skillName}`;
|
|
266
|
-
addedDescription = true;
|
|
267
|
-
}
|
|
268
|
-
return {
|
|
269
|
-
content: serializeFrontmatter(normalized, content),
|
|
270
|
-
addedDescription
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
function validateAgentSkillsFrontmatter(skill) {
|
|
274
|
-
const errors = [];
|
|
275
|
-
const dirName = basename4(skill.sourceDir);
|
|
276
|
-
const declaredName = skill.meta.name;
|
|
277
|
-
if (typeof declaredName !== "string" || declaredName.trim().length === 0) {
|
|
278
|
-
errors.push('Missing required frontmatter field "name".');
|
|
279
|
-
} else {
|
|
280
|
-
if (declaredName.length > SKILL_NAME_MAX_LENGTH) {
|
|
281
|
-
errors.push(`Invalid "name": must be at most ${SKILL_NAME_MAX_LENGTH} characters.`);
|
|
282
|
-
}
|
|
283
|
-
if (!SKILL_NAME_PATTERN.test(declaredName)) {
|
|
284
|
-
errors.push('Invalid "name": use lowercase letters, numbers, and single hyphens only.');
|
|
285
|
-
}
|
|
286
|
-
if (declaredName !== dirName) {
|
|
287
|
-
errors.push(`Invalid "name": must match containing directory "${dirName}".`);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
const description = skill.meta.description;
|
|
291
|
-
if (typeof description !== "string" || description.trim().length === 0) {
|
|
292
|
-
errors.push('Missing required frontmatter field "description".');
|
|
293
|
-
}
|
|
294
|
-
const allowedTools = skill.meta["allowed-tools"];
|
|
295
|
-
if (allowedTools !== undefined && (!Array.isArray(allowedTools) || allowedTools.some((tool) => typeof tool !== "string" || tool.length === 0))) {
|
|
296
|
-
errors.push('Invalid "allowed-tools": expected an array of non-empty strings.');
|
|
297
|
-
}
|
|
298
|
-
return errors;
|
|
299
|
-
}
|
|
300
|
-
function skillMatchesTarget(skill, targetId) {
|
|
301
|
-
const { targets } = skill.meta;
|
|
302
|
-
if (!targets || targets === "*")
|
|
303
|
-
return true;
|
|
304
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
305
|
-
return true;
|
|
306
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
// src/core/profile-resolver.ts
|
|
310
|
-
function resolveModels(merged, modelProfile, targetId) {
|
|
311
|
-
let defaultModel = merged.default;
|
|
312
|
-
let smallModel = merged.small;
|
|
313
|
-
let agents = { ...merged.agents };
|
|
314
|
-
if (modelProfile && merged.profiles?.[modelProfile]) {
|
|
315
|
-
const resolvedProfile = resolveProfileInheritance(modelProfile, merged.profiles);
|
|
316
|
-
if (resolvedProfile.default)
|
|
317
|
-
defaultModel = resolvedProfile.default;
|
|
318
|
-
if (resolvedProfile.small)
|
|
319
|
-
smallModel = resolvedProfile.small;
|
|
320
|
-
if (resolvedProfile.agents) {
|
|
321
|
-
agents = { ...agents, ...resolvedProfile.agents };
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
if (targetId) {
|
|
325
|
-
const targetOverride = merged.overrides?.[targetId];
|
|
326
|
-
if (targetOverride) {
|
|
327
|
-
if (targetOverride.default)
|
|
328
|
-
defaultModel = targetOverride.default;
|
|
329
|
-
if (targetOverride.small)
|
|
330
|
-
smallModel = targetOverride.small;
|
|
331
|
-
if (targetOverride.agents) {
|
|
332
|
-
agents = { ...agents, ...targetOverride.agents };
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
const providers = {};
|
|
337
|
-
if (merged.providers) {
|
|
338
|
-
for (const [name, config] of Object.entries(merged.providers)) {
|
|
339
|
-
providers[name] = {
|
|
340
|
-
...config.options ? { options: config.options } : {},
|
|
341
|
-
...config.models ? { models: config.models } : {}
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
const profileNames = Object.keys(merged.profiles ?? {});
|
|
346
|
-
const profiles = {};
|
|
347
|
-
if (merged.profiles) {
|
|
348
|
-
for (const [name, profile] of Object.entries(merged.profiles)) {
|
|
349
|
-
profiles[name] = {
|
|
350
|
-
description: profile.description,
|
|
351
|
-
default: profile.default,
|
|
352
|
-
small: profile.small
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
return {
|
|
357
|
-
default: defaultModel,
|
|
358
|
-
small: smallModel,
|
|
359
|
-
agents,
|
|
360
|
-
providers,
|
|
361
|
-
routing: merged.routing ?? [],
|
|
362
|
-
profileNames,
|
|
363
|
-
activeProfile: modelProfile,
|
|
364
|
-
profiles
|
|
365
|
-
};
|
|
366
|
-
}
|
|
367
|
-
function resolveAgentModel(resolved, agentName, frontmatterModel) {
|
|
368
|
-
const fromModels = resolved.agents[agentName];
|
|
369
|
-
if (fromModels) {
|
|
370
|
-
return {
|
|
371
|
-
model: fromModels.model,
|
|
372
|
-
temperature: fromModels.temperature,
|
|
373
|
-
top_p: fromModels.top_p
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
if (frontmatterModel) {
|
|
377
|
-
return { model: frontmatterModel };
|
|
378
|
-
}
|
|
379
|
-
return {};
|
|
380
|
-
}
|
|
381
|
-
function resolveProfileInheritance(profileName, profiles) {
|
|
382
|
-
const visited = new Set;
|
|
383
|
-
return resolveProfileChain(profileName, profiles, visited, 0);
|
|
384
|
-
}
|
|
385
|
-
var MAX_INHERITANCE_DEPTH = 10;
|
|
386
|
-
function resolveProfileChain(name, profiles, visited, depth) {
|
|
387
|
-
if (depth > MAX_INHERITANCE_DEPTH) {
|
|
388
|
-
throw new Error(`Profile inheritance too deep (max ${MAX_INHERITANCE_DEPTH}): ${name}`);
|
|
389
|
-
}
|
|
390
|
-
if (visited.has(name)) {
|
|
391
|
-
throw new Error(`Circular profile inheritance detected: ${[...visited, name].join(" → ")}`);
|
|
392
|
-
}
|
|
393
|
-
const profile = profiles[name];
|
|
394
|
-
if (!profile) {
|
|
395
|
-
throw new Error(`Profile "${name}" not found`);
|
|
396
|
-
}
|
|
397
|
-
visited.add(name);
|
|
398
|
-
if (!profile.extends) {
|
|
399
|
-
return { ...profile };
|
|
400
|
-
}
|
|
401
|
-
const parent = resolveProfileChain(profile.extends, profiles, visited, depth + 1);
|
|
402
|
-
return {
|
|
403
|
-
description: profile.description ?? parent.description,
|
|
404
|
-
default: profile.default ?? parent.default,
|
|
405
|
-
small: profile.small ?? parent.small,
|
|
406
|
-
agents: {
|
|
407
|
-
...parent.agents,
|
|
408
|
-
...profile.agents
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
// src/utils/model-guidance.ts
|
|
414
|
-
function generateModelGuidanceMarkdown(resolved) {
|
|
415
|
-
if (!resolved.default && !resolved.small && Object.keys(resolved.agents).length === 0 && Object.keys(resolved.profiles).length === 0) {
|
|
416
|
-
return null;
|
|
417
|
-
}
|
|
418
|
-
const lines = [];
|
|
419
|
-
lines.push("# Model Configuration");
|
|
420
|
-
lines.push("");
|
|
421
|
-
lines.push("Use the following model preferences when working in this project.");
|
|
422
|
-
lines.push("");
|
|
423
|
-
if (resolved.default || resolved.small) {
|
|
424
|
-
lines.push("## Default Models");
|
|
425
|
-
lines.push("");
|
|
426
|
-
if (resolved.default) {
|
|
427
|
-
lines.push(`- **Primary model**: ${resolved.default}`);
|
|
428
|
-
}
|
|
429
|
-
if (resolved.small) {
|
|
430
|
-
lines.push(`- **Lightweight tasks** (titles, summaries): ${resolved.small}`);
|
|
431
|
-
}
|
|
432
|
-
lines.push("");
|
|
433
|
-
}
|
|
434
|
-
const agentEntries = Object.entries(resolved.agents);
|
|
435
|
-
if (agentEntries.length > 0) {
|
|
436
|
-
lines.push("## Agent Model Assignments");
|
|
437
|
-
lines.push("");
|
|
438
|
-
lines.push("| Agent | Model | Temperature |");
|
|
439
|
-
lines.push("| --- | --- | --- |");
|
|
440
|
-
for (const [name, assignment] of agentEntries) {
|
|
441
|
-
const temp = assignment.temperature !== undefined ? String(assignment.temperature) : "—";
|
|
442
|
-
lines.push(`| ${name} | ${assignment.model} | ${temp} |`);
|
|
443
|
-
}
|
|
444
|
-
lines.push("");
|
|
445
|
-
}
|
|
446
|
-
if (Object.keys(resolved.profiles).length > 0) {
|
|
447
|
-
lines.push("## Available Profiles");
|
|
448
|
-
lines.push("");
|
|
449
|
-
lines.push("| Profile | Description | Default Model |");
|
|
450
|
-
lines.push("| --- | --- | --- |");
|
|
451
|
-
for (const [name, profile] of Object.entries(resolved.profiles)) {
|
|
452
|
-
lines.push(`| ${name} | ${profile.description ?? "—"} | ${profile.default ?? "—"} |`);
|
|
453
|
-
}
|
|
454
|
-
lines.push("");
|
|
455
|
-
}
|
|
456
|
-
if (resolved.activeProfile) {
|
|
457
|
-
lines.push(`**Active profile**: \`${resolved.activeProfile}\``);
|
|
458
|
-
lines.push("");
|
|
459
|
-
}
|
|
460
|
-
if (resolved.routing.length > 0) {
|
|
461
|
-
lines.push("## Task-Aware Routing");
|
|
462
|
-
lines.push("");
|
|
463
|
-
lines.push("Select the appropriate profile based on the task context:");
|
|
464
|
-
lines.push("");
|
|
465
|
-
lines.push("| Condition | Profile | Description |");
|
|
466
|
-
lines.push("| --- | --- | --- |");
|
|
467
|
-
for (const rule of resolved.routing) {
|
|
468
|
-
const conditions = Object.entries(rule.when).map(([k, v]) => `${k}=${v}`).join(", ");
|
|
469
|
-
const desc = rule.description ?? "—";
|
|
470
|
-
lines.push(`| ${conditions} | ${rule.use} | ${desc} |`);
|
|
471
|
-
}
|
|
472
|
-
lines.push("");
|
|
473
|
-
lines.push("### Condition Reference");
|
|
474
|
-
lines.push("");
|
|
475
|
-
lines.push("- **complexity**: low | medium | high | critical");
|
|
476
|
-
lines.push("- **urgency**: low | normal | high");
|
|
477
|
-
lines.push("- **budget**: minimal | standard | premium");
|
|
478
|
-
lines.push("- **contextWindowNeed**: small | medium | large | max");
|
|
479
|
-
lines.push("- **toolUseIntensity**: none | light | heavy");
|
|
480
|
-
lines.push("");
|
|
481
|
-
}
|
|
482
|
-
return lines.join(`
|
|
483
|
-
`);
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
// src/targets/base-target.ts
|
|
487
|
-
class BaseTarget {
|
|
488
|
-
supportsFeature(feature) {
|
|
489
|
-
return this.supportedFeatures.includes(feature);
|
|
490
|
-
}
|
|
491
|
-
getEffectiveFeatures(enabledFeatures) {
|
|
492
|
-
return enabledFeatures.filter((f) => this.supportsFeature(f));
|
|
493
|
-
}
|
|
494
|
-
createResult(filesWritten = [], filesDeleted = [], warnings = []) {
|
|
495
|
-
return {
|
|
496
|
-
targetId: this.id,
|
|
497
|
-
filesWritten,
|
|
498
|
-
filesDeleted,
|
|
499
|
-
warnings
|
|
500
|
-
};
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
// src/targets/mistral-vibe.ts
|
|
505
|
-
import { join as join3, resolve } from "path";
|
|
506
|
-
var TARGET_ID = "mistralvibe";
|
|
507
|
-
|
|
508
|
-
class MistralVibeTarget extends BaseTarget {
|
|
509
|
-
id = TARGET_ID;
|
|
510
|
-
name = "Mistral Vibe";
|
|
511
|
-
supportedFeatures = [
|
|
512
|
-
"rules",
|
|
513
|
-
"commands",
|
|
514
|
-
"agents",
|
|
515
|
-
"skills",
|
|
516
|
-
"mcp",
|
|
517
|
-
"ignore",
|
|
518
|
-
"models"
|
|
519
|
-
];
|
|
520
|
-
generate(options) {
|
|
521
|
-
const { projectRoot, baseDir, features, enabledFeatures, deleteExisting } = options;
|
|
522
|
-
const root = resolve(projectRoot, baseDir);
|
|
523
|
-
const effective = this.getEffectiveFeatures(enabledFeatures);
|
|
524
|
-
const filesWritten = [];
|
|
525
|
-
const filesDeleted = [];
|
|
526
|
-
const warnings = [];
|
|
527
|
-
const vibeDir = resolve(root, ".vibe");
|
|
528
|
-
ensureDir(vibeDir);
|
|
529
|
-
if (effective.includes("rules")) {
|
|
530
|
-
const rulesDir = resolve(vibeDir, "rules");
|
|
531
|
-
if (deleteExisting) {
|
|
532
|
-
removeIfExists(rulesDir);
|
|
533
|
-
filesDeleted.push(rulesDir);
|
|
534
|
-
}
|
|
535
|
-
ensureDir(rulesDir);
|
|
536
|
-
const rules = features.rules.filter((r) => ruleMatchesTarget(r, TARGET_ID));
|
|
537
|
-
for (const rule of rules) {
|
|
538
|
-
const filepath = join3(rulesDir, `${rule.name}.md`);
|
|
539
|
-
writeGeneratedFile(filepath, rule.content);
|
|
540
|
-
filesWritten.push(filepath);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
if (effective.includes("agents")) {
|
|
544
|
-
const agentsDir = resolve(vibeDir, "agents");
|
|
545
|
-
if (deleteExisting) {
|
|
546
|
-
removeIfExists(agentsDir);
|
|
547
|
-
filesDeleted.push(agentsDir);
|
|
548
|
-
}
|
|
549
|
-
ensureDir(agentsDir);
|
|
550
|
-
const agents = features.agents.filter((a) => agentMatchesTarget(a, TARGET_ID));
|
|
551
|
-
for (const agent of agents) {
|
|
552
|
-
const filepath = join3(agentsDir, `${agent.name}.md`);
|
|
553
|
-
writeGeneratedFile(filepath, agent.content);
|
|
554
|
-
filesWritten.push(filepath);
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
if (effective.includes("skills")) {
|
|
558
|
-
const skillsDir = resolve(vibeDir, "skills");
|
|
559
|
-
if (deleteExisting) {
|
|
560
|
-
removeIfExists(skillsDir);
|
|
561
|
-
filesDeleted.push(skillsDir);
|
|
562
|
-
}
|
|
563
|
-
ensureDir(skillsDir);
|
|
564
|
-
const skills = features.skills.filter((s) => skillMatchesTarget(s, TARGET_ID));
|
|
565
|
-
for (const skill of skills) {
|
|
566
|
-
const skillSubDir = join3(skillsDir, skill.name);
|
|
567
|
-
ensureDir(skillSubDir);
|
|
568
|
-
const filepath = join3(skillSubDir, "SKILL.md");
|
|
569
|
-
writeGeneratedFile(filepath, serializeSkill(skill));
|
|
570
|
-
filesWritten.push(filepath);
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
if (effective.includes("commands")) {
|
|
574
|
-
const commandsDir = resolve(vibeDir, "commands");
|
|
575
|
-
if (deleteExisting) {
|
|
576
|
-
removeIfExists(commandsDir);
|
|
577
|
-
filesDeleted.push(commandsDir);
|
|
578
|
-
}
|
|
579
|
-
ensureDir(commandsDir);
|
|
580
|
-
const commands = features.commands.filter((c) => commandMatchesTarget(c, TARGET_ID));
|
|
581
|
-
for (const command of commands) {
|
|
582
|
-
const filepath = join3(commandsDir, `${command.name}.md`);
|
|
583
|
-
writeGeneratedFile(filepath, command.content);
|
|
584
|
-
filesWritten.push(filepath);
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
let hasMcpConfig = false;
|
|
588
|
-
if (effective.includes("mcp")) {
|
|
589
|
-
const mcpEntries = Object.entries(features.mcpServers);
|
|
590
|
-
if (mcpEntries.length > 0) {
|
|
591
|
-
const filepath = resolve(vibeDir, "mcp.json");
|
|
592
|
-
writeGeneratedJson(filepath, { mcpServers: features.mcpServers }, {
|
|
593
|
-
header: false
|
|
594
|
-
});
|
|
595
|
-
filesWritten.push(filepath);
|
|
596
|
-
hasMcpConfig = true;
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
if (effective.includes("ignore") && features.ignorePatterns.length > 0) {
|
|
600
|
-
const filepath = resolve(root, ".vibeignore");
|
|
601
|
-
writeGeneratedFile(filepath, features.ignorePatterns.join(`
|
|
602
|
-
`) + `
|
|
603
|
-
`);
|
|
604
|
-
filesWritten.push(filepath);
|
|
605
|
-
}
|
|
606
|
-
let defaultModel;
|
|
607
|
-
let smallModel;
|
|
608
|
-
if (effective.includes("models") && features.models) {
|
|
609
|
-
const resolved = resolveModels(features.models, options.modelProfile, TARGET_ID);
|
|
610
|
-
defaultModel = resolved.default;
|
|
611
|
-
smallModel = resolved.small;
|
|
612
|
-
const guidance = generateModelGuidanceMarkdown(resolved);
|
|
613
|
-
if (guidance) {
|
|
614
|
-
const filepath = join3(vibeDir, "model-config.md");
|
|
615
|
-
writeGeneratedFile(filepath, guidance);
|
|
616
|
-
filesWritten.push(filepath);
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
const vibeConfig = buildVibeConfigToml({
|
|
620
|
-
hasMcpConfig,
|
|
621
|
-
defaultModel,
|
|
622
|
-
smallModel,
|
|
623
|
-
profile: options.modelProfile
|
|
624
|
-
});
|
|
625
|
-
if (vibeConfig.length > 0) {
|
|
626
|
-
const filepath = resolve(vibeDir, "config.toml");
|
|
627
|
-
writeGeneratedFile(filepath, vibeConfig);
|
|
628
|
-
filesWritten.push(filepath);
|
|
629
|
-
}
|
|
630
|
-
return this.createResult(filesWritten, filesDeleted, warnings);
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
function buildVibeConfigToml(options) {
|
|
634
|
-
const lines = [];
|
|
635
|
-
if (options.defaultModel || options.smallModel || options.profile) {
|
|
636
|
-
lines.push("[models]");
|
|
637
|
-
if (options.defaultModel) {
|
|
638
|
-
lines.push(`default = "${escapeTomlString(options.defaultModel)}"`);
|
|
639
|
-
}
|
|
640
|
-
if (options.smallModel) {
|
|
641
|
-
lines.push(`small = "${escapeTomlString(options.smallModel)}"`);
|
|
642
|
-
}
|
|
643
|
-
if (options.profile) {
|
|
644
|
-
lines.push(`profile = "${escapeTomlString(options.profile)}"`);
|
|
645
|
-
}
|
|
646
|
-
lines.push("");
|
|
647
|
-
}
|
|
648
|
-
if (options.hasMcpConfig) {
|
|
649
|
-
lines.push("[mcp]");
|
|
650
|
-
lines.push('config_path = ".vibe/mcp.json"');
|
|
651
|
-
lines.push("");
|
|
652
|
-
}
|
|
653
|
-
return lines.join(`
|
|
654
|
-
`).trim();
|
|
655
|
-
}
|
|
656
|
-
function escapeTomlString(value) {
|
|
657
|
-
return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
658
|
-
}
|
|
659
|
-
export {
|
|
660
|
-
MistralVibeTarget
|
|
661
|
-
};
|
|
1
|
+
import{createRequire as qq}from"node:module";var Fq=qq(import.meta.url);import{existsSync as _,mkdirSync as Qq,readdirSync as E,readFileSync as Yq,rmSync as Zq,statSync as k,writeFileSync as $q}from"fs";import{dirname as Bq,join as D,relative as Uq}from"path";var u="<!-- Generated by agentpacks. DO NOT EDIT. -->",v="// Generated by agentpacks. DO NOT EDIT.",h="// Generated by agentpacks. DO NOT EDIT.";function H(q,Q,Y={}){let{header:Z=!0,type:$}=Y,B=$??Vq(q);G(Bq(q));let X=Q;if(Z){let J=Kq(B);if(J)X=`${J}
|
|
2
|
+
${Q}`}$q(q,X,"utf-8")}function c(q,Q,Y={}){let Z=JSON.stringify(Q,null,2);H(q,Z+`
|
|
3
|
+
`,{...Y,type:"json"})}function g(q){if(!_(q))return null;return Yq(q,"utf-8")}function Nq(q){let Q=g(q);if(Q===null)return null;return JSON.parse(Q)}function G(q){if(!_(q))Qq(q,{recursive:!0})}function A(q){if(_(q))Zq(q,{recursive:!0,force:!0})}function R(q,Q={}){let{extension:Y,recursive:Z=!1}=Q;if(!_(q))return[];let $=[],B=E(q);for(let X of B){let J=D(q,X),z=k(J);if(z.isDirectory()&&Z)$.push(...R(J,Q));else if(z.isFile()){if(!Y||X.endsWith(Y))$.push(J)}}return $}function m(q){if(!_(q))return[];return E(q).map((Q)=>D(q,Q)).filter((Q)=>k(Q).isDirectory())}function Eq(q,Q){return Uq(q,Q)}function kq(q){let Q=g(q);if(!Q)return!1;return Q.startsWith(u)||Q.startsWith(v)||Q.startsWith(h)}function Vq(q){if(q.endsWith(".json")||q.endsWith(".jsonc"))return"json";if(q.endsWith(".ts")||q.endsWith(".mts"))return"ts";if(q.endsWith(".js")||q.endsWith(".mjs"))return"js";return"md"}function Kq(q){switch(q){case"md":return u;case"json":return v;case"js":case"ts":return h;default:return null}}import p from"gray-matter";function x(q){let{data:Q,content:Y}=p(q);return{data:Q,content:Y.trim(),raw:q}}function y(q,Q){let Y=Object.fromEntries(Object.entries(q).filter(([,Z])=>Z!==void 0));if(Object.keys(Y).length===0)return Q;return p.stringify(Q,Y)}import{readFileSync as Xq}from"fs";import{basename as Jq}from"path";function pq(q,Q){return R(q,{extension:".md"}).map((Z)=>zq(Z,Q))}function zq(q,Q){let Y=Xq(q,"utf-8"),{data:Z,content:$}=x(Y);return{name:Z.name??Jq(q,".md"),sourcePath:q,packName:Q,meta:Z,content:$}}function f(q,Q){let{targets:Y}=q.meta;if(!Y||Y==="*")return!0;if(Array.isArray(Y)&&Y.includes("*"))return!0;return Array.isArray(Y)&&Y.includes(Q)}import{readFileSync as Lq}from"fs";import{basename as Oq}from"path";function sq(q,Q){return R(q,{extension:".md"}).map((Z)=>Wq(Z,Q))}function Wq(q,Q){let Y=Lq(q,"utf-8"),{data:Z,content:$}=x(Y);return{name:Oq(q,".md"),sourcePath:q,packName:Q,meta:Z,content:$}}function d(q,Q){let{targets:Y}=q.meta;if(!Y||Y==="*")return!0;if(Array.isArray(Y)&&Y.includes("*"))return!0;return Array.isArray(Y)&&Y.includes(Q)}import{readFileSync as Hq}from"fs";import{basename as xq}from"path";function qQ(q,Q){return R(q,{extension:".md"}).map((Z)=>Cq(Z,Q))}function Cq(q,Q){let Y=Hq(q,"utf-8"),{data:Z,content:$}=x(Y);return{name:xq(q,".md"),sourcePath:q,packName:Q,meta:Z,content:$}}function n(q,Q){let{targets:Y}=q.meta;if(!Y||Y==="*")return!0;if(Array.isArray(Y)&&Y.includes("*"))return!0;return Array.isArray(Y)&&Y.includes(Q)}function QQ(q){return q.filter((Q)=>Q.meta.root===!0)}function YQ(q){return q.filter((Q)=>Q.meta.root!==!0)}import{existsSync as wq,readFileSync as Gq}from"fs";import{basename as a,join as Rq}from"path";var jq=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,o=64;function KQ(q,Q){let Y=m(q),Z=[];for(let $ of Y){let B=Rq($,"SKILL.md");if(wq(B))Z.push(Iq(B,$,Q))}return Z}function Iq(q,Q,Y){let Z=Gq(q,"utf-8"),{data:$,content:B}=x(Z);return{name:$.name??a(Q),sourcePath:q,sourceDir:Q,packName:Y,meta:$,content:B}}function _q(q){return{...q.meta,name:q.name}}function s(q){return y(_q(q),q.content)}function XQ(q,Q){let{data:Y,content:Z}=x(q),$={...Y,name:Q},B=!1,X=$.description;if(typeof X!=="string"||X.trim().length===0)$.description=`Imported skill: ${Q}`,B=!0;return{content:y($,Z),addedDescription:B}}function JQ(q){let Q=[],Y=a(q.sourceDir),Z=q.meta.name;if(typeof Z!=="string"||Z.trim().length===0)Q.push('Missing required frontmatter field "name".');else{if(Z.length>o)Q.push(`Invalid "name": must be at most ${o} characters.`);if(!jq.test(Z))Q.push('Invalid "name": use lowercase letters, numbers, and single hyphens only.');if(Z!==Y)Q.push(`Invalid "name": must match containing directory "${Y}".`)}let $=q.meta.description;if(typeof $!=="string"||$.trim().length===0)Q.push('Missing required frontmatter field "description".');let B=q.meta["allowed-tools"];if(B!==void 0&&(!Array.isArray(B)||B.some((X)=>typeof X!=="string"||X.length===0)))Q.push('Invalid "allowed-tools": expected an array of non-empty strings.');return Q}function r(q,Q){let{targets:Y}=q.meta;if(!Y||Y==="*")return!0;if(Array.isArray(Y)&&Y.includes("*"))return!0;return Array.isArray(Y)&&Y.includes(Q)}function i(q,Q,Y){let{default:Z,small:$}=q,B={...q.agents};if(Q&&q.profiles?.[Q]){let V=Aq(Q,q.profiles);if(V.default)Z=V.default;if(V.small)$=V.small;if(V.agents)B={...B,...V.agents}}if(Y){let V=q.overrides?.[Y];if(V){if(V.default)Z=V.default;if(V.small)$=V.small;if(V.agents)B={...B,...V.agents}}}let X={};if(q.providers)for(let[V,W]of Object.entries(q.providers))X[V]={...W.options?{options:W.options}:{},...W.models?{models:W.models}:{}};let J=Object.keys(q.profiles??{}),z={};if(q.profiles)for(let[V,W]of Object.entries(q.profiles))z[V]={description:W.description,default:W.default,small:W.small};return{default:Z,small:$,agents:B,providers:X,routing:q.routing??[],profileNames:J,activeProfile:Q,profiles:z}}function LQ(q,Q,Y){let Z=q.agents[Q];if(Z)return{model:Z.model,temperature:Z.temperature,top_p:Z.top_p};if(Y)return{model:Y};return{}}function Aq(q,Q){return t(q,Q,new Set,0)}var l=10;function t(q,Q,Y,Z){if(Z>l)throw Error(`Profile inheritance too deep (max ${l}): ${q}`);if(Y.has(q))throw Error(`Circular profile inheritance detected: ${[...Y,q].join(" → ")}`);let $=Q[q];if(!$)throw Error(`Profile "${q}" not found`);if(Y.add(q),!$.extends)return{...$};let B=t($.extends,Q,Y,Z+1);return{description:$.description??B.description,default:$.default??B.default,small:$.small??B.small,agents:{...B.agents,...$.agents}}}function e(q){if(!q.default&&!q.small&&Object.keys(q.agents).length===0&&Object.keys(q.profiles).length===0)return null;let Q=[];if(Q.push("# Model Configuration"),Q.push(""),Q.push("Use the following model preferences when working in this project."),Q.push(""),q.default||q.small){if(Q.push("## Default Models"),Q.push(""),q.default)Q.push(`- **Primary model**: ${q.default}`);if(q.small)Q.push(`- **Lightweight tasks** (titles, summaries): ${q.small}`);Q.push("")}let Y=Object.entries(q.agents);if(Y.length>0){Q.push("## Agent Model Assignments"),Q.push(""),Q.push("| Agent | Model | Temperature |"),Q.push("| --- | --- | --- |");for(let[Z,$]of Y){let B=$.temperature!==void 0?String($.temperature):"—";Q.push(`| ${Z} | ${$.model} | ${B} |`)}Q.push("")}if(Object.keys(q.profiles).length>0){Q.push("## Available Profiles"),Q.push(""),Q.push("| Profile | Description | Default Model |"),Q.push("| --- | --- | --- |");for(let[Z,$]of Object.entries(q.profiles))Q.push(`| ${Z} | ${$.description??"—"} | ${$.default??"—"} |`);Q.push("")}if(q.activeProfile)Q.push(`**Active profile**: \`${q.activeProfile}\``),Q.push("");if(q.routing.length>0){Q.push("## Task-Aware Routing"),Q.push(""),Q.push("Select the appropriate profile based on the task context:"),Q.push(""),Q.push("| Condition | Profile | Description |"),Q.push("| --- | --- | --- |");for(let Z of q.routing){let $=Object.entries(Z.when).map(([X,J])=>`${X}=${J}`).join(", "),B=Z.description??"—";Q.push(`| ${$} | ${Z.use} | ${B} |`)}Q.push(""),Q.push("### Condition Reference"),Q.push(""),Q.push("- **complexity**: low | medium | high | critical"),Q.push("- **urgency**: low | normal | high"),Q.push("- **budget**: minimal | standard | premium"),Q.push("- **contextWindowNeed**: small | medium | large | max"),Q.push("- **toolUseIntensity**: none | light | heavy"),Q.push("")}return Q.join(`
|
|
4
|
+
`)}class S{supportsFeature(q){return this.supportedFeatures.includes(q)}getEffectiveFeatures(q){return q.filter((Q)=>this.supportsFeature(Q))}createResult(q=[],Q=[],Y=[]){return{targetId:this.id,filesWritten:q,filesDeleted:Q,warnings:Y}}}import{join as j,resolve as C}from"path";var I="mistralvibe";class yq extends S{id=I;name="Mistral Vibe";supportedFeatures=["rules","commands","agents","skills","mcp","ignore","models"];generate(q){let{projectRoot:Q,baseDir:Y,features:Z,enabledFeatures:$,deleteExisting:B}=q,X=C(Q,Y),J=this.getEffectiveFeatures($),z=[],V=[],W=[],w=C(X,".vibe");if(G(w),J.includes("rules")){let U=C(w,"rules");if(B)A(U),V.push(U);G(U);let L=Z.rules.filter((K)=>n(K,I));for(let K of L){let O=j(U,`${K.name}.md`);H(O,K.content),z.push(O)}}if(J.includes("agents")){let U=C(w,"agents");if(B)A(U),V.push(U);G(U);let L=Z.agents.filter((K)=>f(K,I));for(let K of L){let O=j(U,`${K.name}.md`);H(O,K.content),z.push(O)}}if(J.includes("skills")){let U=C(w,"skills");if(B)A(U),V.push(U);G(U);let L=Z.skills.filter((K)=>r(K,I));for(let K of L){let O=j(U,K.name);G(O);let N=j(O,"SKILL.md");H(N,s(K)),z.push(N)}}if(J.includes("commands")){let U=C(w,"commands");if(B)A(U),V.push(U);G(U);let L=Z.commands.filter((K)=>d(K,I));for(let K of L){let O=j(U,`${K.name}.md`);H(O,K.content),z.push(O)}}let F=!1;if(J.includes("mcp")){if(Object.entries(Z.mcpServers).length>0){let L=C(w,"mcp.json");c(L,{mcpServers:Z.mcpServers},{header:!1}),z.push(L),F=!0}}if(J.includes("ignore")&&Z.ignorePatterns.length>0){let U=C(X,".vibeignore");H(U,Z.ignorePatterns.join(`
|
|
5
|
+
`)+`
|
|
6
|
+
`),z.push(U)}let M,T;if(J.includes("models")&&Z.models){let U=i(Z.models,q.modelProfile,I);M=U.default,T=U.small;let L=e(U);if(L){let K=j(w,"model-config.md");H(K,L),z.push(K)}}let P=Sq({hasMcpConfig:F,defaultModel:M,smallModel:T,profile:q.modelProfile});if(P.length>0){let U=C(w,"config.toml");H(U,P),z.push(U)}return this.createResult(z,V,W)}}function Sq(q){let Q=[];if(q.defaultModel||q.smallModel||q.profile){if(Q.push("[models]"),q.defaultModel)Q.push(`default = "${b(q.defaultModel)}"`);if(q.smallModel)Q.push(`small = "${b(q.smallModel)}"`);if(q.profile)Q.push(`profile = "${b(q.profile)}"`);Q.push("")}if(q.hasMcpConfig)Q.push("[mcp]"),Q.push('config_path = ".vibe/mcp.json"'),Q.push("");return Q.join(`
|
|
7
|
+
`).trim()}function b(q){return q.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}export{yq as MistralVibeTarget};
|