agentpacks 1.7.6 → 1.7.9
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 +69 -742
- package/dist/api.d.ts +15 -15
- package/dist/api.js +2706 -2706
- package/dist/cli/export-cmd.js +364 -364
- package/dist/cli/generate.js +1409 -1409
- package/dist/cli/import-cmd.js +249 -249
- package/dist/cli/info.js +31 -31
- package/dist/cli/init.js +6 -6
- package/dist/cli/install.js +141 -141
- package/dist/cli/login.js +31 -31
- package/dist/cli/models-explain.js +514 -514
- package/dist/cli/pack/create.js +6 -6
- package/dist/cli/pack/enable.js +2 -2
- package/dist/cli/pack/list.js +362 -362
- package/dist/cli/pack/validate.js +119 -119
- package/dist/cli/publish.js +42 -42
- package/dist/cli/search.js +31 -31
- package/dist/core/config.js +3 -3
- package/dist/core/feature-merger.d.ts +5 -5
- package/dist/core/feature-merger.js +4 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +633 -633
- package/dist/core/lockfile.js +1 -1
- package/dist/core/metarepo.js +3 -3
- package/dist/core/pack-loader.d.ts +6 -6
- package/dist/core/pack-loader.js +362 -362
- package/dist/core/profile-resolver.d.ts +1 -1
- package/dist/exporters/cursor-plugin.d.ts +12 -0
- package/dist/exporters/cursor-plugin.js +46 -46
- package/dist/exporters/index.d.ts +1 -1
- package/dist/exporters/index.js +46 -46
- package/dist/features/agents.js +4 -4
- package/dist/features/commands.js +4 -4
- package/dist/features/hooks.js +4 -4
- package/dist/features/index.d.ts +8 -8
- package/dist/features/index.js +350 -350
- package/dist/features/mcp.js +4 -4
- package/dist/features/models.js +4 -4
- package/dist/features/plugins.js +5 -5
- package/dist/features/rules.js +4 -4
- package/dist/features/skills.js +5 -5
- package/dist/importers/claude-code.js +6 -6
- package/dist/importers/cursor.js +7 -7
- package/dist/importers/opencode.js +7 -7
- package/dist/importers/rulesync.js +7 -7
- package/dist/index.js +2674 -2674
- package/dist/node/api.js +2706 -2706
- package/dist/node/cli/export-cmd.js +364 -364
- package/dist/node/cli/generate.js +1409 -1409
- package/dist/node/cli/import-cmd.js +249 -249
- package/dist/node/cli/info.js +31 -31
- package/dist/node/cli/init.js +6 -6
- package/dist/node/cli/install.js +141 -141
- package/dist/node/cli/login.js +31 -31
- package/dist/node/cli/models-explain.js +514 -514
- package/dist/node/cli/pack/create.js +6 -6
- package/dist/node/cli/pack/enable.js +2 -2
- package/dist/node/cli/pack/list.js +362 -362
- package/dist/node/cli/pack/validate.js +119 -119
- package/dist/node/cli/publish.js +42 -42
- package/dist/node/cli/search.js +31 -31
- package/dist/node/core/config.js +3 -3
- package/dist/node/core/feature-merger.js +4 -4
- package/dist/node/core/index.js +633 -633
- package/dist/node/core/lockfile.js +1 -1
- package/dist/node/core/metarepo.js +3 -3
- package/dist/node/core/pack-loader.js +362 -362
- package/dist/node/exporters/cursor-plugin.js +46 -46
- package/dist/node/exporters/index.js +46 -46
- package/dist/node/features/agents.js +4 -4
- package/dist/node/features/commands.js +4 -4
- package/dist/node/features/hooks.js +4 -4
- package/dist/node/features/index.js +350 -350
- package/dist/node/features/mcp.js +4 -4
- package/dist/node/features/models.js +4 -4
- package/dist/node/features/plugins.js +5 -5
- package/dist/node/features/rules.js +4 -4
- package/dist/node/features/skills.js +5 -5
- package/dist/node/importers/claude-code.js +6 -6
- package/dist/node/importers/cursor.js +7 -7
- package/dist/node/importers/opencode.js +7 -7
- package/dist/node/importers/rulesync.js +7 -7
- package/dist/node/index.js +2674 -2674
- package/dist/node/sources/git.js +2 -2
- package/dist/node/sources/index.js +138 -138
- package/dist/node/sources/local.js +1 -1
- package/dist/node/sources/npm.js +3 -3
- package/dist/node/sources/registry.js +35 -35
- package/dist/node/targets/additional-targets.js +43 -43
- package/dist/node/targets/agents-md.js +4 -4
- package/dist/node/targets/claude-code.js +86 -86
- package/dist/node/targets/codex-cli.js +6 -6
- package/dist/node/targets/copilot.js +46 -46
- package/dist/node/targets/cursor.js +68 -68
- package/dist/node/targets/gemini-cli.js +25 -25
- package/dist/node/targets/generic-md-target.js +43 -43
- package/dist/node/targets/index.js +911 -911
- package/dist/node/targets/mistral-vibe.js +46 -46
- package/dist/node/targets/opencode.js +68 -68
- package/dist/node/targets/registry.js +911 -911
- package/dist/node/utils/credentials.js +2 -2
- package/dist/node/utils/filesystem.js +4 -4
- package/dist/node/utils/global.js +1 -1
- package/dist/node/utils/tarball.js +2 -2
- package/dist/sources/git.js +2 -2
- package/dist/sources/index.d.ts +6 -6
- package/dist/sources/index.js +138 -138
- package/dist/sources/local.js +1 -1
- package/dist/sources/npm.d.ts +3 -0
- package/dist/sources/npm.js +3 -3
- package/dist/sources/registry.js +35 -35
- package/dist/targets/additional-targets.js +43 -43
- package/dist/targets/agents-md.js +4 -4
- package/dist/targets/claude-code.js +86 -86
- package/dist/targets/codex-cli.js +6 -6
- package/dist/targets/copilot.js +46 -46
- package/dist/targets/cursor.js +68 -68
- package/dist/targets/gemini-cli.js +25 -25
- package/dist/targets/generic-md-target.js +43 -43
- package/dist/targets/index.d.ts +6 -6
- package/dist/targets/index.js +911 -911
- package/dist/targets/mistral-vibe.js +46 -46
- package/dist/targets/opencode.js +68 -68
- package/dist/targets/registry.js +911 -911
- package/dist/utils/credentials.js +2 -2
- package/dist/utils/filesystem.js +4 -4
- package/dist/utils/global.d.ts +3 -0
- package/dist/utils/global.js +1 -1
- package/dist/utils/tarball.js +2 -2
- package/package.json +5 -5
- package/templates/pack/models.json +36 -36
- package/templates/pack/pack.json +8 -8
- package/templates/workspace/agentpacks.jsonc +24 -24
package/dist/targets/cursor.js
CHANGED
|
@@ -5,13 +5,13 @@ var __require = import.meta.require;
|
|
|
5
5
|
import {
|
|
6
6
|
existsSync,
|
|
7
7
|
mkdirSync,
|
|
8
|
-
readFileSync,
|
|
9
|
-
writeFileSync,
|
|
10
8
|
readdirSync,
|
|
9
|
+
readFileSync,
|
|
11
10
|
rmSync,
|
|
12
|
-
statSync
|
|
11
|
+
statSync,
|
|
12
|
+
writeFileSync
|
|
13
13
|
} from "fs";
|
|
14
|
-
import { dirname,
|
|
14
|
+
import { dirname, join, relative } from "path";
|
|
15
15
|
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
16
16
|
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
17
17
|
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
@@ -129,38 +129,32 @@ function serializeFrontmatter(data, content) {
|
|
|
129
129
|
return matter.stringify(content, filtered);
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
// src/features/
|
|
132
|
+
// src/features/agents.ts
|
|
133
133
|
import { readFileSync as readFileSync2 } from "fs";
|
|
134
134
|
import { basename } from "path";
|
|
135
|
-
function
|
|
136
|
-
const files = listFiles(
|
|
137
|
-
return files.map((filepath) =>
|
|
135
|
+
function parseAgents(agentsDir, packName) {
|
|
136
|
+
const files = listFiles(agentsDir, { extension: ".md" });
|
|
137
|
+
return files.map((filepath) => parseAgentFile(filepath, packName));
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function parseAgentFile(filepath, packName) {
|
|
140
140
|
const raw = readFileSync2(filepath, "utf-8");
|
|
141
141
|
const { data, content } = parseFrontmatter(raw);
|
|
142
142
|
return {
|
|
143
|
-
name: basename(filepath, ".md"),
|
|
143
|
+
name: data.name ?? basename(filepath, ".md"),
|
|
144
144
|
sourcePath: filepath,
|
|
145
145
|
packName,
|
|
146
146
|
meta: data,
|
|
147
147
|
content
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
|
-
function
|
|
151
|
-
const { targets } =
|
|
150
|
+
function agentMatchesTarget(agent, targetId) {
|
|
151
|
+
const { targets } = agent.meta;
|
|
152
152
|
if (!targets || targets === "*")
|
|
153
153
|
return true;
|
|
154
154
|
if (Array.isArray(targets) && targets.includes("*"))
|
|
155
155
|
return true;
|
|
156
156
|
return Array.isArray(targets) && targets.includes(targetId);
|
|
157
157
|
}
|
|
158
|
-
function getRootRules(rules) {
|
|
159
|
-
return rules.filter((r) => r.meta.root === true);
|
|
160
|
-
}
|
|
161
|
-
function getDetailRules(rules) {
|
|
162
|
-
return rules.filter((r) => r.meta.root !== true);
|
|
163
|
-
}
|
|
164
158
|
|
|
165
159
|
// src/features/commands.ts
|
|
166
160
|
import { readFileSync as readFileSync3 } from "fs";
|
|
@@ -189,43 +183,87 @@ function commandMatchesTarget(cmd, targetId) {
|
|
|
189
183
|
return Array.isArray(targets) && targets.includes(targetId);
|
|
190
184
|
}
|
|
191
185
|
|
|
192
|
-
// src/features/
|
|
186
|
+
// src/features/hooks.ts
|
|
187
|
+
import { join as join2 } from "path";
|
|
188
|
+
var TARGET_OVERRIDE_KEYS = ["cursor", "claudecode", "opencode"];
|
|
189
|
+
function parseHooks(packDir, packName) {
|
|
190
|
+
const hooksPath = join2(packDir, "hooks", "hooks.json");
|
|
191
|
+
const raw = readJsonOrNull(hooksPath);
|
|
192
|
+
if (!raw)
|
|
193
|
+
return null;
|
|
194
|
+
const shared = raw.hooks ?? {};
|
|
195
|
+
const targetOverrides = {};
|
|
196
|
+
for (const key of TARGET_OVERRIDE_KEYS) {
|
|
197
|
+
const override = raw[key];
|
|
198
|
+
if (override && typeof override === "object" && "hooks" in override && override.hooks) {
|
|
199
|
+
targetOverrides[key] = override.hooks;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
packName,
|
|
204
|
+
sourcePath: hooksPath,
|
|
205
|
+
version: raw.version,
|
|
206
|
+
shared,
|
|
207
|
+
targetOverrides
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function resolveHooksForTarget(hooks, targetId) {
|
|
211
|
+
const merged = {};
|
|
212
|
+
for (const [event, entries] of Object.entries(hooks.shared)) {
|
|
213
|
+
merged[event] = [...entries];
|
|
214
|
+
}
|
|
215
|
+
const overrides = hooks.targetOverrides[targetId];
|
|
216
|
+
if (overrides) {
|
|
217
|
+
for (const [event, entries] of Object.entries(overrides)) {
|
|
218
|
+
merged[event] = [...merged[event] ?? [], ...entries];
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return merged;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// src/features/rules.ts
|
|
193
225
|
import { readFileSync as readFileSync4 } from "fs";
|
|
194
226
|
import { basename as basename3 } from "path";
|
|
195
|
-
function
|
|
196
|
-
const files = listFiles(
|
|
197
|
-
return files.map((filepath) =>
|
|
227
|
+
function parseRules(rulesDir, packName) {
|
|
228
|
+
const files = listFiles(rulesDir, { extension: ".md" });
|
|
229
|
+
return files.map((filepath) => parseRuleFile(filepath, packName));
|
|
198
230
|
}
|
|
199
|
-
function
|
|
231
|
+
function parseRuleFile(filepath, packName) {
|
|
200
232
|
const raw = readFileSync4(filepath, "utf-8");
|
|
201
233
|
const { data, content } = parseFrontmatter(raw);
|
|
202
234
|
return {
|
|
203
|
-
name:
|
|
235
|
+
name: basename3(filepath, ".md"),
|
|
204
236
|
sourcePath: filepath,
|
|
205
237
|
packName,
|
|
206
238
|
meta: data,
|
|
207
239
|
content
|
|
208
240
|
};
|
|
209
241
|
}
|
|
210
|
-
function
|
|
211
|
-
const { targets } =
|
|
242
|
+
function ruleMatchesTarget(rule, targetId) {
|
|
243
|
+
const { targets } = rule.meta;
|
|
212
244
|
if (!targets || targets === "*")
|
|
213
245
|
return true;
|
|
214
246
|
if (Array.isArray(targets) && targets.includes("*"))
|
|
215
247
|
return true;
|
|
216
248
|
return Array.isArray(targets) && targets.includes(targetId);
|
|
217
249
|
}
|
|
250
|
+
function getRootRules(rules) {
|
|
251
|
+
return rules.filter((r) => r.meta.root === true);
|
|
252
|
+
}
|
|
253
|
+
function getDetailRules(rules) {
|
|
254
|
+
return rules.filter((r) => r.meta.root !== true);
|
|
255
|
+
}
|
|
218
256
|
|
|
219
257
|
// src/features/skills.ts
|
|
220
|
-
import {
|
|
221
|
-
import { basename as basename4, join as
|
|
258
|
+
import { existsSync as existsSync2, readFileSync as readFileSync5 } from "fs";
|
|
259
|
+
import { basename as basename4, join as join3 } from "path";
|
|
222
260
|
var SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
223
261
|
var SKILL_NAME_MAX_LENGTH = 64;
|
|
224
262
|
function parseSkills(skillsDir, packName) {
|
|
225
263
|
const dirs = listDirs(skillsDir);
|
|
226
264
|
const skills = [];
|
|
227
265
|
for (const dir of dirs) {
|
|
228
|
-
const skillMd =
|
|
266
|
+
const skillMd = join3(dir, "SKILL.md");
|
|
229
267
|
if (existsSync2(skillMd)) {
|
|
230
268
|
skills.push(parseSkillFile(skillMd, dir, packName));
|
|
231
269
|
}
|
|
@@ -306,44 +344,6 @@ function skillMatchesTarget(skill, targetId) {
|
|
|
306
344
|
return Array.isArray(targets) && targets.includes(targetId);
|
|
307
345
|
}
|
|
308
346
|
|
|
309
|
-
// src/features/hooks.ts
|
|
310
|
-
import { join as join3 } from "path";
|
|
311
|
-
var TARGET_OVERRIDE_KEYS = ["cursor", "claudecode", "opencode"];
|
|
312
|
-
function parseHooks(packDir, packName) {
|
|
313
|
-
const hooksPath = join3(packDir, "hooks", "hooks.json");
|
|
314
|
-
const raw = readJsonOrNull(hooksPath);
|
|
315
|
-
if (!raw)
|
|
316
|
-
return null;
|
|
317
|
-
const shared = raw.hooks ?? {};
|
|
318
|
-
const targetOverrides = {};
|
|
319
|
-
for (const key of TARGET_OVERRIDE_KEYS) {
|
|
320
|
-
const override = raw[key];
|
|
321
|
-
if (override && typeof override === "object" && "hooks" in override && override.hooks) {
|
|
322
|
-
targetOverrides[key] = override.hooks;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
return {
|
|
326
|
-
packName,
|
|
327
|
-
sourcePath: hooksPath,
|
|
328
|
-
version: raw.version,
|
|
329
|
-
shared,
|
|
330
|
-
targetOverrides
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
function resolveHooksForTarget(hooks, targetId) {
|
|
334
|
-
const merged = {};
|
|
335
|
-
for (const [event, entries] of Object.entries(hooks.shared)) {
|
|
336
|
-
merged[event] = [...entries];
|
|
337
|
-
}
|
|
338
|
-
const overrides = hooks.targetOverrides[targetId];
|
|
339
|
-
if (overrides) {
|
|
340
|
-
for (const [event, entries] of Object.entries(overrides)) {
|
|
341
|
-
merged[event] = [...merged[event] ?? [], ...entries];
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
return merged;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
347
|
// src/core/profile-resolver.ts
|
|
348
348
|
function resolveModels(merged, modelProfile, targetId) {
|
|
349
349
|
let defaultModel = merged.default;
|
|
@@ -467,7 +467,7 @@ class BaseTarget {
|
|
|
467
467
|
}
|
|
468
468
|
|
|
469
469
|
// src/targets/cursor.ts
|
|
470
|
-
import {
|
|
470
|
+
import { join as join4, resolve } from "path";
|
|
471
471
|
var TARGET_ID = "cursor";
|
|
472
472
|
|
|
473
473
|
class CursorTarget extends BaseTarget {
|
|
@@ -5,13 +5,13 @@ var __require = import.meta.require;
|
|
|
5
5
|
import {
|
|
6
6
|
existsSync,
|
|
7
7
|
mkdirSync,
|
|
8
|
-
readFileSync,
|
|
9
|
-
writeFileSync,
|
|
10
8
|
readdirSync,
|
|
9
|
+
readFileSync,
|
|
11
10
|
rmSync,
|
|
12
|
-
statSync
|
|
11
|
+
statSync,
|
|
12
|
+
writeFileSync
|
|
13
13
|
} from "fs";
|
|
14
|
-
import { dirname,
|
|
14
|
+
import { dirname, join, relative } from "path";
|
|
15
15
|
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
16
16
|
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
17
17
|
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
@@ -129,14 +129,14 @@ function serializeFrontmatter(data, content) {
|
|
|
129
129
|
return matter.stringify(content, filtered);
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
// src/features/
|
|
132
|
+
// src/features/commands.ts
|
|
133
133
|
import { readFileSync as readFileSync2 } from "fs";
|
|
134
134
|
import { basename } from "path";
|
|
135
|
-
function
|
|
136
|
-
const files = listFiles(
|
|
137
|
-
return files.map((filepath) =>
|
|
135
|
+
function parseCommands(commandsDir, packName) {
|
|
136
|
+
const files = listFiles(commandsDir, { extension: ".md" });
|
|
137
|
+
return files.map((filepath) => parseCommandFile(filepath, packName));
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function parseCommandFile(filepath, packName) {
|
|
140
140
|
const raw = readFileSync2(filepath, "utf-8");
|
|
141
141
|
const { data, content } = parseFrontmatter(raw);
|
|
142
142
|
return {
|
|
@@ -147,29 +147,23 @@ function parseRuleFile(filepath, packName) {
|
|
|
147
147
|
content
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
|
-
function
|
|
151
|
-
const { targets } =
|
|
150
|
+
function commandMatchesTarget(cmd, targetId) {
|
|
151
|
+
const { targets } = cmd.meta;
|
|
152
152
|
if (!targets || targets === "*")
|
|
153
153
|
return true;
|
|
154
154
|
if (Array.isArray(targets) && targets.includes("*"))
|
|
155
155
|
return true;
|
|
156
156
|
return Array.isArray(targets) && targets.includes(targetId);
|
|
157
157
|
}
|
|
158
|
-
function getRootRules(rules) {
|
|
159
|
-
return rules.filter((r) => r.meta.root === true);
|
|
160
|
-
}
|
|
161
|
-
function getDetailRules(rules) {
|
|
162
|
-
return rules.filter((r) => r.meta.root !== true);
|
|
163
|
-
}
|
|
164
158
|
|
|
165
|
-
// src/features/
|
|
159
|
+
// src/features/rules.ts
|
|
166
160
|
import { readFileSync as readFileSync3 } from "fs";
|
|
167
161
|
import { basename as basename2 } from "path";
|
|
168
|
-
function
|
|
169
|
-
const files = listFiles(
|
|
170
|
-
return files.map((filepath) =>
|
|
162
|
+
function parseRules(rulesDir, packName) {
|
|
163
|
+
const files = listFiles(rulesDir, { extension: ".md" });
|
|
164
|
+
return files.map((filepath) => parseRuleFile(filepath, packName));
|
|
171
165
|
}
|
|
172
|
-
function
|
|
166
|
+
function parseRuleFile(filepath, packName) {
|
|
173
167
|
const raw = readFileSync3(filepath, "utf-8");
|
|
174
168
|
const { data, content } = parseFrontmatter(raw);
|
|
175
169
|
return {
|
|
@@ -180,14 +174,20 @@ function parseCommandFile(filepath, packName) {
|
|
|
180
174
|
content
|
|
181
175
|
};
|
|
182
176
|
}
|
|
183
|
-
function
|
|
184
|
-
const { targets } =
|
|
177
|
+
function ruleMatchesTarget(rule, targetId) {
|
|
178
|
+
const { targets } = rule.meta;
|
|
185
179
|
if (!targets || targets === "*")
|
|
186
180
|
return true;
|
|
187
181
|
if (Array.isArray(targets) && targets.includes("*"))
|
|
188
182
|
return true;
|
|
189
183
|
return Array.isArray(targets) && targets.includes(targetId);
|
|
190
184
|
}
|
|
185
|
+
function getRootRules(rules) {
|
|
186
|
+
return rules.filter((r) => r.meta.root === true);
|
|
187
|
+
}
|
|
188
|
+
function getDetailRules(rules) {
|
|
189
|
+
return rules.filter((r) => r.meta.root !== true);
|
|
190
|
+
}
|
|
191
191
|
|
|
192
192
|
// src/targets/base-target.ts
|
|
193
193
|
class BaseTarget {
|
|
@@ -208,7 +208,7 @@ class BaseTarget {
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
// src/targets/gemini-cli.ts
|
|
211
|
-
import {
|
|
211
|
+
import { join as join2, resolve } from "path";
|
|
212
212
|
var TARGET_ID = "geminicli";
|
|
213
213
|
|
|
214
214
|
class GeminiCliTarget extends BaseTarget {
|
|
@@ -5,13 +5,13 @@ var __require = import.meta.require;
|
|
|
5
5
|
import {
|
|
6
6
|
existsSync,
|
|
7
7
|
mkdirSync,
|
|
8
|
-
readFileSync,
|
|
9
|
-
writeFileSync,
|
|
10
8
|
readdirSync,
|
|
9
|
+
readFileSync,
|
|
11
10
|
rmSync,
|
|
12
|
-
statSync
|
|
11
|
+
statSync,
|
|
12
|
+
writeFileSync
|
|
13
13
|
} from "fs";
|
|
14
|
-
import { dirname,
|
|
14
|
+
import { dirname, join, relative } from "path";
|
|
15
15
|
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
16
16
|
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
17
17
|
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
@@ -129,14 +129,14 @@ function serializeFrontmatter(data, content) {
|
|
|
129
129
|
return matter.stringify(content, filtered);
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
// src/features/
|
|
132
|
+
// src/features/commands.ts
|
|
133
133
|
import { readFileSync as readFileSync2 } from "fs";
|
|
134
134
|
import { basename } from "path";
|
|
135
|
-
function
|
|
136
|
-
const files = listFiles(
|
|
137
|
-
return files.map((filepath) =>
|
|
135
|
+
function parseCommands(commandsDir, packName) {
|
|
136
|
+
const files = listFiles(commandsDir, { extension: ".md" });
|
|
137
|
+
return files.map((filepath) => parseCommandFile(filepath, packName));
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function parseCommandFile(filepath, packName) {
|
|
140
140
|
const raw = readFileSync2(filepath, "utf-8");
|
|
141
141
|
const { data, content } = parseFrontmatter(raw);
|
|
142
142
|
return {
|
|
@@ -147,29 +147,23 @@ function parseRuleFile(filepath, packName) {
|
|
|
147
147
|
content
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
|
-
function
|
|
151
|
-
const { targets } =
|
|
150
|
+
function commandMatchesTarget(cmd, targetId) {
|
|
151
|
+
const { targets } = cmd.meta;
|
|
152
152
|
if (!targets || targets === "*")
|
|
153
153
|
return true;
|
|
154
154
|
if (Array.isArray(targets) && targets.includes("*"))
|
|
155
155
|
return true;
|
|
156
156
|
return Array.isArray(targets) && targets.includes(targetId);
|
|
157
157
|
}
|
|
158
|
-
function getRootRules(rules) {
|
|
159
|
-
return rules.filter((r) => r.meta.root === true);
|
|
160
|
-
}
|
|
161
|
-
function getDetailRules(rules) {
|
|
162
|
-
return rules.filter((r) => r.meta.root !== true);
|
|
163
|
-
}
|
|
164
158
|
|
|
165
|
-
// src/features/
|
|
159
|
+
// src/features/rules.ts
|
|
166
160
|
import { readFileSync as readFileSync3 } from "fs";
|
|
167
161
|
import { basename as basename2 } from "path";
|
|
168
|
-
function
|
|
169
|
-
const files = listFiles(
|
|
170
|
-
return files.map((filepath) =>
|
|
162
|
+
function parseRules(rulesDir, packName) {
|
|
163
|
+
const files = listFiles(rulesDir, { extension: ".md" });
|
|
164
|
+
return files.map((filepath) => parseRuleFile(filepath, packName));
|
|
171
165
|
}
|
|
172
|
-
function
|
|
166
|
+
function parseRuleFile(filepath, packName) {
|
|
173
167
|
const raw = readFileSync3(filepath, "utf-8");
|
|
174
168
|
const { data, content } = parseFrontmatter(raw);
|
|
175
169
|
return {
|
|
@@ -180,14 +174,20 @@ function parseCommandFile(filepath, packName) {
|
|
|
180
174
|
content
|
|
181
175
|
};
|
|
182
176
|
}
|
|
183
|
-
function
|
|
184
|
-
const { targets } =
|
|
177
|
+
function ruleMatchesTarget(rule, targetId) {
|
|
178
|
+
const { targets } = rule.meta;
|
|
185
179
|
if (!targets || targets === "*")
|
|
186
180
|
return true;
|
|
187
181
|
if (Array.isArray(targets) && targets.includes("*"))
|
|
188
182
|
return true;
|
|
189
183
|
return Array.isArray(targets) && targets.includes(targetId);
|
|
190
184
|
}
|
|
185
|
+
function getRootRules(rules) {
|
|
186
|
+
return rules.filter((r) => r.meta.root === true);
|
|
187
|
+
}
|
|
188
|
+
function getDetailRules(rules) {
|
|
189
|
+
return rules.filter((r) => r.meta.root !== true);
|
|
190
|
+
}
|
|
191
191
|
|
|
192
192
|
// src/core/profile-resolver.ts
|
|
193
193
|
function resolveModels(merged, modelProfile, targetId) {
|
|
@@ -293,24 +293,6 @@ function resolveProfileChain(name, profiles, visited, depth) {
|
|
|
293
293
|
};
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
-
// src/targets/base-target.ts
|
|
297
|
-
class BaseTarget {
|
|
298
|
-
supportsFeature(feature) {
|
|
299
|
-
return this.supportedFeatures.includes(feature);
|
|
300
|
-
}
|
|
301
|
-
getEffectiveFeatures(enabledFeatures) {
|
|
302
|
-
return enabledFeatures.filter((f) => this.supportsFeature(f));
|
|
303
|
-
}
|
|
304
|
-
createResult(filesWritten = [], filesDeleted = [], warnings = []) {
|
|
305
|
-
return {
|
|
306
|
-
targetId: this.id,
|
|
307
|
-
filesWritten,
|
|
308
|
-
filesDeleted,
|
|
309
|
-
warnings
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
296
|
// src/utils/model-guidance.ts
|
|
315
297
|
function generateModelGuidanceMarkdown(resolved) {
|
|
316
298
|
if (!resolved.default && !resolved.small && Object.keys(resolved.agents).length === 0 && Object.keys(resolved.profiles).length === 0) {
|
|
@@ -384,8 +366,26 @@ function generateModelGuidanceMarkdown(resolved) {
|
|
|
384
366
|
`);
|
|
385
367
|
}
|
|
386
368
|
|
|
369
|
+
// src/targets/base-target.ts
|
|
370
|
+
class BaseTarget {
|
|
371
|
+
supportsFeature(feature) {
|
|
372
|
+
return this.supportedFeatures.includes(feature);
|
|
373
|
+
}
|
|
374
|
+
getEffectiveFeatures(enabledFeatures) {
|
|
375
|
+
return enabledFeatures.filter((f) => this.supportsFeature(f));
|
|
376
|
+
}
|
|
377
|
+
createResult(filesWritten = [], filesDeleted = [], warnings = []) {
|
|
378
|
+
return {
|
|
379
|
+
targetId: this.id,
|
|
380
|
+
filesWritten,
|
|
381
|
+
filesDeleted,
|
|
382
|
+
warnings
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
387
|
// src/targets/generic-md-target.ts
|
|
388
|
-
import {
|
|
388
|
+
import { join as join2, resolve } from "path";
|
|
389
389
|
function createGenericMdTarget(config) {
|
|
390
390
|
return new GenericMdTarget(config);
|
|
391
391
|
}
|
package/dist/targets/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
export { AgentsMdTarget } from './agents-md.js';
|
|
1
2
|
export { BaseTarget, type GenerateOptions, type GenerateResult, } from './base-target.js';
|
|
2
|
-
export { OpenCodeTarget } from './opencode.js';
|
|
3
|
-
export { CursorTarget } from './cursor.js';
|
|
4
3
|
export { ClaudeCodeTarget } from './claude-code.js';
|
|
5
4
|
export { CodexCliTarget } from './codex-cli.js';
|
|
6
|
-
export { MistralVibeTarget } from './mistral-vibe.js';
|
|
7
|
-
export { GeminiCliTarget } from './gemini-cli.js';
|
|
8
5
|
export { CopilotTarget } from './copilot.js';
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
6
|
+
export { CursorTarget } from './cursor.js';
|
|
7
|
+
export { GeminiCliTarget } from './gemini-cli.js';
|
|
8
|
+
export { MistralVibeTarget } from './mistral-vibe.js';
|
|
9
|
+
export { OpenCodeTarget } from './opencode.js';
|
|
10
|
+
export { getAllTargets, getTarget, getTargets, listTargetIds, } from './registry.js';
|