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
package/dist/targets/copilot.js
CHANGED
|
@@ -1,606 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
existsSync,
|
|
7
|
-
mkdirSync,
|
|
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(" \u2192 ")}`);
|
|
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) : "\u2014";
|
|
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 ?? "\u2014"} | ${profile.default ?? "\u2014"} |`);
|
|
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 ?? "\u2014";
|
|
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/copilot.ts
|
|
505
|
-
import { join as join3, resolve } from "path";
|
|
506
|
-
var TARGET_ID = "copilot";
|
|
507
|
-
|
|
508
|
-
class CopilotTarget extends BaseTarget {
|
|
509
|
-
id = TARGET_ID;
|
|
510
|
-
name = "GitHub Copilot";
|
|
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 githubDir = resolve(root, ".github");
|
|
528
|
-
if (effective.includes("rules")) {
|
|
529
|
-
const rules = features.rules.filter((r) => ruleMatchesTarget(r, TARGET_ID));
|
|
530
|
-
if (rules.length > 0) {
|
|
531
|
-
const combinedContent = rules.map((r) => r.content).join(`
|
|
2
|
+
var bq=import.meta.require;import{existsSync as I,mkdirSync as l,readdirSync as F,readFileSync as i,rmSync as r,statSync as T,writeFileSync as t}from"fs";import{dirname as e,join as P,relative as qq}from"path";var N="<!-- Generated by agentpacks. DO NOT EDIT. -->",E="// Generated by agentpacks. DO NOT EDIT.",k="// Generated by agentpacks. DO NOT EDIT.";function G(q,Q,V={}){let{header:Y=!0,type:Z}=V,$=Z??Qq(q);w(e(q));let J=Q;if(Y){let X=Vq($);if(X)J=`${X}
|
|
3
|
+
${Q}`}t(q,J,"utf-8")}function _q(q,Q,V={}){let Y=JSON.stringify(Q,null,2);G(q,Y+`
|
|
4
|
+
`,{...V,type:"json"})}function D(q){if(!I(q))return null;return i(q,"utf-8")}function Sq(q){let Q=D(q);if(Q===null)return null;return JSON.parse(Q)}function w(q){if(!I(q))l(q,{recursive:!0})}function S(q){if(I(q))r(q,{recursive:!0,force:!0})}function b(q,Q={}){let{extension:V,recursive:Y=!1}=Q;if(!I(q))return[];let Z=[],$=F(q);for(let J of $){let X=P(q,J),z=T(X);if(z.isDirectory()&&Y)Z.push(...b(X,Q));else if(z.isFile()){if(!V||J.endsWith(V))Z.push(X)}}return Z}function u(q){if(!I(q))return[];return F(q).map((Q)=>P(q,Q)).filter((Q)=>T(Q).isDirectory())}function Aq(q,Q){return qq(q,Q)}function Mq(q){let Q=D(q);if(!Q)return!1;return Q.startsWith(N)||Q.startsWith(E)||Q.startsWith(k)}function Qq(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 Vq(q){switch(q){case"md":return N;case"json":return E;case"js":case"ts":return k;default:return null}}import v from"gray-matter";function x(q){let{data:Q,content:V}=v(q);return{data:Q,content:V.trim(),raw:q}}function A(q,Q){let V=Object.fromEntries(Object.entries(q).filter(([,Y])=>Y!==void 0));if(Object.keys(V).length===0)return Q;return v.stringify(Q,V)}import{readFileSync as Yq}from"fs";import{basename as Zq}from"path";function Dq(q,Q){return b(q,{extension:".md"}).map((Y)=>$q(Y,Q))}function $q(q,Q){let V=Yq(q,"utf-8"),{data:Y,content:Z}=x(V);return{name:Y.name??Zq(q,".md"),sourcePath:q,packName:Q,meta:Y,content:Z}}function h(q,Q){let{targets:V}=q.meta;if(!V||V==="*")return!0;if(Array.isArray(V)&&V.includes("*"))return!0;return Array.isArray(V)&&V.includes(Q)}import{readFileSync as Bq}from"fs";import{basename as Uq}from"path";function mq(q,Q){return b(q,{extension:".md"}).map((Y)=>Kq(Y,Q))}function Kq(q,Q){let V=Bq(q,"utf-8"),{data:Y,content:Z}=x(V);return{name:Uq(q,".md"),sourcePath:q,packName:Q,meta:Y,content:Z}}function c(q,Q){let{targets:V}=q.meta;if(!V||V==="*")return!0;if(Array.isArray(V)&&V.includes("*"))return!0;return Array.isArray(V)&&V.includes(Q)}import{readFileSync as Jq}from"fs";import{basename as Xq}from"path";function sq(q,Q){return b(q,{extension:".md"}).map((Y)=>zq(Y,Q))}function zq(q,Q){let V=Jq(q,"utf-8"),{data:Y,content:Z}=x(V);return{name:Xq(q,".md"),sourcePath:q,packName:Q,meta:Y,content:Z}}function g(q,Q){let{targets:V}=q.meta;if(!V||V==="*")return!0;if(Array.isArray(V)&&V.includes("*"))return!0;return Array.isArray(V)&&V.includes(Q)}function aq(q){return q.filter((Q)=>Q.meta.root===!0)}function lq(q){return q.filter((Q)=>Q.meta.root!==!0)}import{existsSync as Lq,readFileSync as Wq}from"fs";import{basename as p,join as Oq}from"path";var Hq=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,m=64;function QQ(q,Q){let V=u(q),Y=[];for(let Z of V){let $=Oq(Z,"SKILL.md");if(Lq($))Y.push(xq($,Z,Q))}return Y}function xq(q,Q,V){let Y=Wq(q,"utf-8"),{data:Z,content:$}=x(Y);return{name:Z.name??p(Q),sourcePath:q,sourceDir:Q,packName:V,meta:Z,content:$}}function Cq(q){return{...q.meta,name:q.name}}function f(q){return A(Cq(q),q.content)}function VQ(q,Q){let{data:V,content:Y}=x(q),Z={...V,name:Q},$=!1,J=Z.description;if(typeof J!=="string"||J.trim().length===0)Z.description=`Imported skill: ${Q}`,$=!0;return{content:A(Z,Y),addedDescription:$}}function YQ(q){let Q=[],V=p(q.sourceDir),Y=q.meta.name;if(typeof Y!=="string"||Y.trim().length===0)Q.push('Missing required frontmatter field "name".');else{if(Y.length>m)Q.push(`Invalid "name": must be at most ${m} characters.`);if(!Hq.test(Y))Q.push('Invalid "name": use lowercase letters, numbers, and single hyphens only.');if(Y!==V)Q.push(`Invalid "name": must match containing directory "${V}".`)}let Z=q.meta.description;if(typeof Z!=="string"||Z.trim().length===0)Q.push('Missing required frontmatter field "description".');let $=q.meta["allowed-tools"];if($!==void 0&&(!Array.isArray($)||$.some((J)=>typeof J!=="string"||J.length===0)))Q.push('Invalid "allowed-tools": expected an array of non-empty strings.');return Q}function d(q,Q){let{targets:V}=q.meta;if(!V||V==="*")return!0;if(Array.isArray(V)&&V.includes("*"))return!0;return Array.isArray(V)&&V.includes(Q)}function o(q,Q,V){let{default:Y,small:Z}=q,$={...q.agents};if(Q&&q.profiles?.[Q]){let B=wq(Q,q.profiles);if(B.default)Y=B.default;if(B.small)Z=B.small;if(B.agents)$={...$,...B.agents}}if(V){let B=q.overrides?.[V];if(B){if(B.default)Y=B.default;if(B.small)Z=B.small;if(B.agents)$={...$,...B.agents}}}let J={};if(q.providers)for(let[B,W]of Object.entries(q.providers))J[B]={...W.options?{options:W.options}:{},...W.models?{models:W.models}:{}};let X=Object.keys(q.profiles??{}),z={};if(q.profiles)for(let[B,W]of Object.entries(q.profiles))z[B]={description:W.description,default:W.default,small:W.small};return{default:Y,small:Z,agents:$,providers:J,routing:q.routing??[],profileNames:X,activeProfile:Q,profiles:z}}function $Q(q,Q,V){let Y=q.agents[Q];if(Y)return{model:Y.model,temperature:Y.temperature,top_p:Y.top_p};if(V)return{model:V};return{}}function wq(q,Q){return s(q,Q,new Set,0)}var n=10;function s(q,Q,V,Y){if(Y>n)throw Error(`Profile inheritance too deep (max ${n}): ${q}`);if(V.has(q))throw Error(`Circular profile inheritance detected: ${[...V,q].join(" \u2192 ")}`);let Z=Q[q];if(!Z)throw Error(`Profile "${q}" not found`);if(V.add(q),!Z.extends)return{...Z};let $=s(Z.extends,Q,V,Y+1);return{description:Z.description??$.description,default:Z.default??$.default,small:Z.small??$.small,agents:{...$.agents,...Z.agents}}}function a(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 V=Object.entries(q.agents);if(V.length>0){Q.push("## Agent Model Assignments"),Q.push(""),Q.push("| Agent | Model | Temperature |"),Q.push("| --- | --- | --- |");for(let[Y,Z]of V){let $=Z.temperature!==void 0?String(Z.temperature):"\u2014";Q.push(`| ${Y} | ${Z.model} | ${$} |`)}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[Y,Z]of Object.entries(q.profiles))Q.push(`| ${Y} | ${Z.description??"\u2014"} | ${Z.default??"\u2014"} |`);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 Y of q.routing){let Z=Object.entries(Y.when).map(([J,X])=>`${J}=${X}`).join(", "),$=Y.description??"\u2014";Q.push(`| ${Z} | ${Y.use} | ${$} |`)}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(`
|
|
5
|
+
`)}class M{supportsFeature(q){return this.supportedFeatures.includes(q)}getEffectiveFeatures(q){return q.filter((Q)=>this.supportsFeature(Q))}createResult(q=[],Q=[],V=[]){return{targetId:this.id,filesWritten:q,filesDeleted:Q,warnings:V}}}import{join as _,resolve as H}from"path";var j="copilot";class Gq extends M{id=j;name="GitHub Copilot";supportedFeatures=["rules","commands","agents","skills","mcp","ignore","models"];generate(q){let{projectRoot:Q,baseDir:V,features:Y,enabledFeatures:Z,deleteExisting:$}=q,J=H(Q,V),X=this.getEffectiveFeatures(Z),z=[],B=[],W=[],R=H(J,".github");if(X.includes("rules")){let O=Y.rules.filter((U)=>g(U,j));if(O.length>0){let U=O.map((K)=>K.content).join(`
|
|
532
6
|
|
|
533
7
|
---
|
|
534
8
|
|
|
535
|
-
`);
|
|
536
|
-
const filepath = resolve(githubDir, "copilot-instructions.md");
|
|
537
|
-
ensureDir(githubDir);
|
|
538
|
-
writeGeneratedFile(filepath, combinedContent);
|
|
539
|
-
filesWritten.push(filepath);
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
if (effective.includes("agents")) {
|
|
543
|
-
const copilotDir = resolve(githubDir, "copilot");
|
|
544
|
-
const agentsDir = resolve(copilotDir, "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 copilotDir = resolve(githubDir, "copilot");
|
|
559
|
-
const skillsDir = resolve(copilotDir, "skills");
|
|
560
|
-
if (deleteExisting) {
|
|
561
|
-
removeIfExists(skillsDir);
|
|
562
|
-
filesDeleted.push(skillsDir);
|
|
563
|
-
}
|
|
564
|
-
ensureDir(skillsDir);
|
|
565
|
-
const skills = features.skills.filter((s) => skillMatchesTarget(s, TARGET_ID));
|
|
566
|
-
for (const skill of skills) {
|
|
567
|
-
const skillSubDir = join3(skillsDir, skill.name);
|
|
568
|
-
ensureDir(skillSubDir);
|
|
569
|
-
const filepath = join3(skillSubDir, "SKILL.md");
|
|
570
|
-
writeGeneratedFile(filepath, serializeSkill(skill));
|
|
571
|
-
filesWritten.push(filepath);
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
if (effective.includes("commands")) {
|
|
575
|
-
const copilotDir = resolve(githubDir, "copilot");
|
|
576
|
-
const commandsDir = resolve(copilotDir, "commands");
|
|
577
|
-
if (deleteExisting) {
|
|
578
|
-
removeIfExists(commandsDir);
|
|
579
|
-
filesDeleted.push(commandsDir);
|
|
580
|
-
}
|
|
581
|
-
ensureDir(commandsDir);
|
|
582
|
-
const commands = features.commands.filter((c) => commandMatchesTarget(c, TARGET_ID));
|
|
583
|
-
for (const cmd of commands) {
|
|
584
|
-
const filepath = join3(commandsDir, `${cmd.name}.md`);
|
|
585
|
-
writeGeneratedFile(filepath, cmd.content);
|
|
586
|
-
filesWritten.push(filepath);
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
if (effective.includes("ignore")) {}
|
|
590
|
-
if (effective.includes("models") && features.models) {
|
|
591
|
-
const resolved = resolveModels(features.models, options.modelProfile, TARGET_ID);
|
|
592
|
-
const guidance = generateModelGuidanceMarkdown(resolved);
|
|
593
|
-
if (guidance) {
|
|
594
|
-
const copilotDir = resolve(githubDir, "copilot");
|
|
595
|
-
ensureDir(copilotDir);
|
|
596
|
-
const filepath = join3(copilotDir, "model-config.md");
|
|
597
|
-
writeGeneratedFile(filepath, guidance);
|
|
598
|
-
filesWritten.push(filepath);
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
return this.createResult(filesWritten, filesDeleted, warnings);
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
export {
|
|
605
|
-
CopilotTarget
|
|
606
|
-
};
|
|
9
|
+
`),L=H(R,"copilot-instructions.md");w(R),G(L,U),z.push(L)}}if(X.includes("agents")){let O=H(R,"copilot"),U=H(O,"agents");if($)S(U),B.push(U);w(U);let L=Y.agents.filter((K)=>h(K,j));for(let K of L){let C=_(U,`${K.name}.md`);G(C,K.content),z.push(C)}}if(X.includes("skills")){let O=H(R,"copilot"),U=H(O,"skills");if($)S(U),B.push(U);w(U);let L=Y.skills.filter((K)=>d(K,j));for(let K of L){let C=_(U,K.name);w(C);let y=_(C,"SKILL.md");G(y,f(K)),z.push(y)}}if(X.includes("commands")){let O=H(R,"copilot"),U=H(O,"commands");if($)S(U),B.push(U);w(U);let L=Y.commands.filter((K)=>c(K,j));for(let K of L){let C=_(U,`${K.name}.md`);G(C,K.content),z.push(C)}}if(X.includes("ignore"));if(X.includes("models")&&Y.models){let O=o(Y.models,q.modelProfile,j),U=a(O);if(U){let L=H(R,"copilot");w(L);let K=_(L,"model-config.md");G(K,U),z.push(K)}}return this.createResult(z,B,W)}}export{Gq as CopilotTarget};
|