agentpacks 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +168 -8
- package/dist/api.d.ts +2 -0
- package/dist/api.js +929 -409
- package/dist/cli/export-cmd.js +281 -149
- package/dist/cli/generate.js +740 -247
- package/dist/cli/import-cmd.js +57 -85
- package/dist/cli/info.d.ts +4 -0
- package/dist/cli/info.js +232 -0
- package/dist/cli/init.js +8 -36
- package/dist/cli/install.js +414 -129
- package/dist/cli/login.d.ts +9 -0
- package/dist/cli/login.js +202 -0
- package/dist/cli/models-explain.d.ts +16 -0
- package/dist/cli/models-explain.js +1205 -0
- package/dist/cli/pack/create.js +4 -32
- package/dist/cli/pack/enable.js +1 -29
- package/dist/cli/pack/list.js +266 -134
- package/dist/cli/pack/validate.js +274 -127
- package/dist/cli/publish.d.ts +8 -0
- package/dist/cli/publish.js +672 -0
- package/dist/cli/search.d.ts +12 -0
- package/dist/cli/search.js +210 -0
- package/dist/core/config.d.ts +2 -1
- package/dist/core/config.js +74 -117
- package/dist/core/dependency-resolver.js +4 -28
- package/dist/core/feature-merger.d.ts +7 -0
- package/dist/core/feature-merger.js +289 -29
- package/dist/core/index.js +283 -140
- package/dist/core/lockfile.js +0 -28
- package/dist/core/metarepo.js +74 -116
- package/dist/core/pack-loader.d.ts +2 -0
- package/dist/core/pack-loader.js +266 -133
- package/dist/core/profile-resolver.d.ts +75 -0
- package/dist/core/profile-resolver.js +111 -0
- package/dist/exporters/cursor-plugin.js +4 -32
- package/dist/exporters/index.js +4 -32
- package/dist/features/agents.d.ts +5 -0
- package/dist/features/agents.js +2 -30
- package/dist/features/commands.js +2 -30
- package/dist/features/hooks.js +2 -30
- package/dist/features/ignore.js +0 -28
- package/dist/features/index.d.ts +1 -0
- package/dist/features/index.js +176 -31
- package/dist/features/mcp.js +2 -30
- package/dist/features/models.d.ts +167 -0
- package/dist/features/models.js +293 -0
- package/dist/features/plugins.js +2 -30
- package/dist/features/rules.js +2 -30
- package/dist/features/skills.js +2 -30
- package/dist/importers/claude-code.js +10 -38
- package/dist/importers/cursor.js +15 -43
- package/dist/importers/opencode.js +16 -44
- package/dist/importers/rulesync.js +22 -50
- package/dist/index.js +1710 -538
- package/dist/node/api.js +929 -409
- package/dist/node/cli/export-cmd.js +281 -149
- package/dist/node/cli/generate.js +740 -247
- package/dist/node/cli/import-cmd.js +57 -85
- package/dist/node/cli/info.js +232 -0
- package/dist/node/cli/init.js +8 -36
- package/dist/node/cli/install.js +414 -129
- package/dist/node/cli/login.js +202 -0
- package/dist/node/cli/models-explain.js +1205 -0
- package/dist/node/cli/pack/create.js +4 -32
- package/dist/node/cli/pack/enable.js +1 -29
- package/dist/node/cli/pack/list.js +266 -134
- package/dist/node/cli/pack/validate.js +274 -127
- package/dist/node/cli/publish.js +672 -0
- package/dist/node/cli/search.js +210 -0
- package/dist/node/core/config.js +74 -117
- package/dist/node/core/dependency-resolver.js +4 -28
- package/dist/node/core/feature-merger.js +289 -29
- package/dist/node/core/index.js +283 -140
- package/dist/node/core/lockfile.js +0 -28
- package/dist/node/core/metarepo.js +74 -116
- package/dist/node/core/pack-loader.js +266 -133
- package/dist/node/core/profile-resolver.js +111 -0
- package/dist/node/exporters/cursor-plugin.js +4 -32
- package/dist/node/exporters/index.js +4 -32
- package/dist/node/features/agents.js +2 -30
- package/dist/node/features/commands.js +2 -30
- package/dist/node/features/hooks.js +2 -30
- package/dist/node/features/ignore.js +0 -28
- package/dist/node/features/index.js +176 -31
- package/dist/node/features/mcp.js +2 -30
- package/dist/node/features/models.js +293 -0
- package/dist/node/features/plugins.js +2 -30
- package/dist/node/features/rules.js +2 -30
- package/dist/node/features/skills.js +2 -30
- package/dist/node/importers/claude-code.js +10 -38
- package/dist/node/importers/cursor.js +15 -43
- package/dist/node/importers/opencode.js +16 -44
- package/dist/node/importers/rulesync.js +22 -50
- package/dist/node/index.js +1710 -538
- package/dist/node/sources/git-ref.js +7 -30
- package/dist/node/sources/git.js +7 -30
- package/dist/node/sources/index.js +337 -39
- package/dist/node/sources/local.js +0 -28
- package/dist/node/sources/npm-ref.js +0 -28
- package/dist/node/sources/npm.js +10 -37
- package/dist/node/sources/registry-ref.js +37 -0
- package/dist/node/sources/registry.js +355 -0
- package/dist/node/targets/additional-targets.js +196 -37
- package/dist/node/targets/agents-md.js +5 -33
- package/dist/node/targets/base-target.js +0 -28
- package/dist/node/targets/claude-code.js +211 -41
- package/dist/node/targets/codex-cli.js +7 -35
- package/dist/node/targets/copilot.js +202 -41
- package/dist/node/targets/cursor.js +188 -40
- package/dist/node/targets/gemini-cli.js +10 -38
- package/dist/node/targets/generic-md-target.js +196 -37
- package/dist/node/targets/index.js +414 -106
- package/dist/node/targets/opencode.js +171 -51
- package/dist/node/targets/registry.js +414 -106
- package/dist/node/utils/credentials.js +38 -0
- package/dist/node/utils/diff.js +22 -34
- package/dist/node/utils/filesystem.js +2 -30
- package/dist/node/utils/frontmatter.js +0 -28
- package/dist/node/utils/global.js +3 -31
- package/dist/node/utils/markdown.js +0 -28
- package/dist/node/utils/model-allowlist.js +110 -0
- package/dist/node/utils/model-guidance.js +78 -0
- package/dist/node/utils/registry-client.js +142 -0
- package/dist/node/utils/tarball.js +49 -0
- package/dist/sources/git-ref.js +7 -30
- package/dist/sources/git.d.ts +2 -2
- package/dist/sources/git.js +7 -30
- package/dist/sources/index.d.ts +2 -0
- package/dist/sources/index.js +337 -39
- package/dist/sources/local.js +0 -28
- package/dist/sources/npm-ref.js +0 -28
- package/dist/sources/npm.js +10 -37
- package/dist/sources/registry-ref.d.ts +30 -0
- package/dist/sources/registry-ref.js +37 -0
- package/dist/sources/registry.d.ts +18 -0
- package/dist/sources/registry.js +355 -0
- package/dist/targets/additional-targets.js +196 -37
- package/dist/targets/agents-md.js +5 -33
- package/dist/targets/base-target.d.ts +2 -0
- package/dist/targets/base-target.js +0 -28
- package/dist/targets/claude-code.js +211 -41
- package/dist/targets/codex-cli.js +7 -35
- package/dist/targets/copilot.js +202 -41
- package/dist/targets/cursor.js +188 -40
- package/dist/targets/gemini-cli.js +10 -38
- package/dist/targets/generic-md-target.js +196 -37
- package/dist/targets/index.js +414 -106
- package/dist/targets/opencode.js +171 -51
- package/dist/targets/registry.js +414 -106
- package/dist/utils/credentials.d.ts +19 -0
- package/dist/utils/credentials.js +38 -0
- package/dist/utils/diff.js +22 -34
- package/dist/utils/filesystem.js +2 -30
- package/dist/utils/frontmatter.js +0 -28
- package/dist/utils/global.js +3 -31
- package/dist/utils/markdown.js +0 -28
- package/dist/utils/model-allowlist.d.ts +39 -0
- package/dist/utils/model-allowlist.js +110 -0
- package/dist/utils/model-guidance.d.ts +6 -0
- package/dist/utils/model-guidance.js +78 -0
- package/dist/utils/registry-client.d.ts +141 -0
- package/dist/utils/registry-client.js +142 -0
- package/dist/utils/tarball.d.ts +13 -0
- package/dist/utils/tarball.js +49 -0
- package/package.json +171 -5
- package/templates/pack/models.json +38 -0
|
@@ -1,32 +1,4 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
-
var __toCommonJS = (from) => {
|
|
8
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
-
if (entry)
|
|
10
|
-
return entry;
|
|
11
|
-
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
-
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
-
get: () => from[key],
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
}));
|
|
17
|
-
__moduleCache.set(from, entry);
|
|
18
|
-
return entry;
|
|
19
|
-
};
|
|
20
|
-
var __export = (target, all) => {
|
|
21
|
-
for (var name in all)
|
|
22
|
-
__defProp(target, name, {
|
|
23
|
-
get: all[name],
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
set: (newValue) => all[name] = () => newValue
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
2
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
3
|
|
|
32
4
|
// src/utils/filesystem.ts
|
|
@@ -36,10 +8,10 @@ import {
|
|
|
36
8
|
readFileSync,
|
|
37
9
|
writeFileSync,
|
|
38
10
|
readdirSync,
|
|
11
|
+
rmSync,
|
|
39
12
|
statSync
|
|
40
13
|
} from "fs";
|
|
41
14
|
import { dirname, relative, join } from "path";
|
|
42
|
-
import { removeSync } from "fs-extra";
|
|
43
15
|
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
44
16
|
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
45
17
|
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
@@ -80,7 +52,7 @@ function ensureDir(dirPath) {
|
|
|
80
52
|
}
|
|
81
53
|
function removeIfExists(targetPath) {
|
|
82
54
|
if (existsSync(targetPath)) {
|
|
83
|
-
|
|
55
|
+
rmSync(targetPath, { recursive: true, force: true });
|
|
84
56
|
}
|
|
85
57
|
}
|
|
86
58
|
function listFiles(dirPath, options = {}) {
|
|
@@ -217,6 +189,110 @@ function commandMatchesTarget(cmd, targetId) {
|
|
|
217
189
|
return Array.isArray(targets) && targets.includes(targetId);
|
|
218
190
|
}
|
|
219
191
|
|
|
192
|
+
// src/core/profile-resolver.ts
|
|
193
|
+
function resolveModels(merged, modelProfile, targetId) {
|
|
194
|
+
let defaultModel = merged.default;
|
|
195
|
+
let smallModel = merged.small;
|
|
196
|
+
let agents = { ...merged.agents };
|
|
197
|
+
if (modelProfile && merged.profiles?.[modelProfile]) {
|
|
198
|
+
const resolvedProfile = resolveProfileInheritance(modelProfile, merged.profiles);
|
|
199
|
+
if (resolvedProfile.default)
|
|
200
|
+
defaultModel = resolvedProfile.default;
|
|
201
|
+
if (resolvedProfile.small)
|
|
202
|
+
smallModel = resolvedProfile.small;
|
|
203
|
+
if (resolvedProfile.agents) {
|
|
204
|
+
agents = { ...agents, ...resolvedProfile.agents };
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (targetId) {
|
|
208
|
+
const targetOverride = merged.overrides?.[targetId];
|
|
209
|
+
if (targetOverride) {
|
|
210
|
+
if (targetOverride.default)
|
|
211
|
+
defaultModel = targetOverride.default;
|
|
212
|
+
if (targetOverride.small)
|
|
213
|
+
smallModel = targetOverride.small;
|
|
214
|
+
if (targetOverride.agents) {
|
|
215
|
+
agents = { ...agents, ...targetOverride.agents };
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const providers = {};
|
|
220
|
+
if (merged.providers) {
|
|
221
|
+
for (const [name, config] of Object.entries(merged.providers)) {
|
|
222
|
+
providers[name] = {
|
|
223
|
+
...config.options ? { options: config.options } : {},
|
|
224
|
+
...config.models ? { models: config.models } : {}
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
const profileNames = Object.keys(merged.profiles ?? {});
|
|
229
|
+
const profiles = {};
|
|
230
|
+
if (merged.profiles) {
|
|
231
|
+
for (const [name, profile] of Object.entries(merged.profiles)) {
|
|
232
|
+
profiles[name] = {
|
|
233
|
+
description: profile.description,
|
|
234
|
+
default: profile.default,
|
|
235
|
+
small: profile.small
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
default: defaultModel,
|
|
241
|
+
small: smallModel,
|
|
242
|
+
agents,
|
|
243
|
+
providers,
|
|
244
|
+
routing: merged.routing ?? [],
|
|
245
|
+
profileNames,
|
|
246
|
+
activeProfile: modelProfile,
|
|
247
|
+
profiles
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function resolveAgentModel(resolved, agentName, frontmatterModel) {
|
|
251
|
+
const fromModels = resolved.agents[agentName];
|
|
252
|
+
if (fromModels) {
|
|
253
|
+
return {
|
|
254
|
+
model: fromModels.model,
|
|
255
|
+
temperature: fromModels.temperature,
|
|
256
|
+
top_p: fromModels.top_p
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
if (frontmatterModel) {
|
|
260
|
+
return { model: frontmatterModel };
|
|
261
|
+
}
|
|
262
|
+
return {};
|
|
263
|
+
}
|
|
264
|
+
function resolveProfileInheritance(profileName, profiles) {
|
|
265
|
+
const visited = new Set;
|
|
266
|
+
return resolveProfileChain(profileName, profiles, visited, 0);
|
|
267
|
+
}
|
|
268
|
+
var MAX_INHERITANCE_DEPTH = 10;
|
|
269
|
+
function resolveProfileChain(name, profiles, visited, depth) {
|
|
270
|
+
if (depth > MAX_INHERITANCE_DEPTH) {
|
|
271
|
+
throw new Error(`Profile inheritance too deep (max ${MAX_INHERITANCE_DEPTH}): ${name}`);
|
|
272
|
+
}
|
|
273
|
+
if (visited.has(name)) {
|
|
274
|
+
throw new Error(`Circular profile inheritance detected: ${[...visited, name].join(" → ")}`);
|
|
275
|
+
}
|
|
276
|
+
const profile = profiles[name];
|
|
277
|
+
if (!profile) {
|
|
278
|
+
throw new Error(`Profile "${name}" not found`);
|
|
279
|
+
}
|
|
280
|
+
visited.add(name);
|
|
281
|
+
if (!profile.extends) {
|
|
282
|
+
return { ...profile };
|
|
283
|
+
}
|
|
284
|
+
const parent = resolveProfileChain(profile.extends, profiles, visited, depth + 1);
|
|
285
|
+
return {
|
|
286
|
+
description: profile.description ?? parent.description,
|
|
287
|
+
default: profile.default ?? parent.default,
|
|
288
|
+
small: profile.small ?? parent.small,
|
|
289
|
+
agents: {
|
|
290
|
+
...parent.agents,
|
|
291
|
+
...profile.agents
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
220
296
|
// src/targets/base-target.ts
|
|
221
297
|
class BaseTarget {
|
|
222
298
|
supportsFeature(feature) {
|
|
@@ -235,8 +311,81 @@ class BaseTarget {
|
|
|
235
311
|
}
|
|
236
312
|
}
|
|
237
313
|
|
|
314
|
+
// src/utils/model-guidance.ts
|
|
315
|
+
function generateModelGuidanceMarkdown(resolved) {
|
|
316
|
+
if (!resolved.default && !resolved.small && Object.keys(resolved.agents).length === 0 && Object.keys(resolved.profiles).length === 0) {
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
const lines = [];
|
|
320
|
+
lines.push("# Model Configuration");
|
|
321
|
+
lines.push("");
|
|
322
|
+
lines.push("Use the following model preferences when working in this project.");
|
|
323
|
+
lines.push("");
|
|
324
|
+
if (resolved.default || resolved.small) {
|
|
325
|
+
lines.push("## Default Models");
|
|
326
|
+
lines.push("");
|
|
327
|
+
if (resolved.default) {
|
|
328
|
+
lines.push(`- **Primary model**: ${resolved.default}`);
|
|
329
|
+
}
|
|
330
|
+
if (resolved.small) {
|
|
331
|
+
lines.push(`- **Lightweight tasks** (titles, summaries): ${resolved.small}`);
|
|
332
|
+
}
|
|
333
|
+
lines.push("");
|
|
334
|
+
}
|
|
335
|
+
const agentEntries = Object.entries(resolved.agents);
|
|
336
|
+
if (agentEntries.length > 0) {
|
|
337
|
+
lines.push("## Agent Model Assignments");
|
|
338
|
+
lines.push("");
|
|
339
|
+
lines.push("| Agent | Model | Temperature |");
|
|
340
|
+
lines.push("| --- | --- | --- |");
|
|
341
|
+
for (const [name, assignment] of agentEntries) {
|
|
342
|
+
const temp = assignment.temperature !== undefined ? String(assignment.temperature) : "—";
|
|
343
|
+
lines.push(`| ${name} | ${assignment.model} | ${temp} |`);
|
|
344
|
+
}
|
|
345
|
+
lines.push("");
|
|
346
|
+
}
|
|
347
|
+
if (Object.keys(resolved.profiles).length > 0) {
|
|
348
|
+
lines.push("## Available Profiles");
|
|
349
|
+
lines.push("");
|
|
350
|
+
lines.push("| Profile | Description | Default Model |");
|
|
351
|
+
lines.push("| --- | --- | --- |");
|
|
352
|
+
for (const [name, profile] of Object.entries(resolved.profiles)) {
|
|
353
|
+
lines.push(`| ${name} | ${profile.description ?? "—"} | ${profile.default ?? "—"} |`);
|
|
354
|
+
}
|
|
355
|
+
lines.push("");
|
|
356
|
+
}
|
|
357
|
+
if (resolved.activeProfile) {
|
|
358
|
+
lines.push(`**Active profile**: \`${resolved.activeProfile}\``);
|
|
359
|
+
lines.push("");
|
|
360
|
+
}
|
|
361
|
+
if (resolved.routing.length > 0) {
|
|
362
|
+
lines.push("## Task-Aware Routing");
|
|
363
|
+
lines.push("");
|
|
364
|
+
lines.push("Select the appropriate profile based on the task context:");
|
|
365
|
+
lines.push("");
|
|
366
|
+
lines.push("| Condition | Profile | Description |");
|
|
367
|
+
lines.push("| --- | --- | --- |");
|
|
368
|
+
for (const rule of resolved.routing) {
|
|
369
|
+
const conditions = Object.entries(rule.when).map(([k, v]) => `${k}=${v}`).join(", ");
|
|
370
|
+
const desc = rule.description ?? "—";
|
|
371
|
+
lines.push(`| ${conditions} | ${rule.use} | ${desc} |`);
|
|
372
|
+
}
|
|
373
|
+
lines.push("");
|
|
374
|
+
lines.push("### Condition Reference");
|
|
375
|
+
lines.push("");
|
|
376
|
+
lines.push("- **complexity**: low | medium | high | critical");
|
|
377
|
+
lines.push("- **urgency**: low | normal | high");
|
|
378
|
+
lines.push("- **budget**: minimal | standard | premium");
|
|
379
|
+
lines.push("- **contextWindowNeed**: small | medium | large | max");
|
|
380
|
+
lines.push("- **toolUseIntensity**: none | light | heavy");
|
|
381
|
+
lines.push("");
|
|
382
|
+
}
|
|
383
|
+
return lines.join(`
|
|
384
|
+
`);
|
|
385
|
+
}
|
|
386
|
+
|
|
238
387
|
// src/targets/generic-md-target.ts
|
|
239
|
-
import { resolve
|
|
388
|
+
import { resolve, join as join2 } from "path";
|
|
240
389
|
function createGenericMdTarget(config) {
|
|
241
390
|
return new GenericMdTarget(config);
|
|
242
391
|
}
|
|
@@ -255,16 +404,16 @@ class GenericMdTarget extends BaseTarget {
|
|
|
255
404
|
}
|
|
256
405
|
generate(options) {
|
|
257
406
|
const { projectRoot, baseDir, features, enabledFeatures, deleteExisting } = options;
|
|
258
|
-
const root =
|
|
407
|
+
const root = resolve(projectRoot, baseDir);
|
|
259
408
|
const effective = this.getEffectiveFeatures(enabledFeatures);
|
|
260
409
|
const filesWritten = [];
|
|
261
410
|
const filesDeleted = [];
|
|
262
411
|
const warnings = [];
|
|
263
|
-
const configDir =
|
|
412
|
+
const configDir = resolve(root, this.config.configDir);
|
|
264
413
|
const rulesSubDir = this.config.rulesDir ?? "rules";
|
|
265
414
|
const ext = this.config.ruleExtension ?? ".md";
|
|
266
415
|
if (effective.includes("rules")) {
|
|
267
|
-
const rulesDir =
|
|
416
|
+
const rulesDir = resolve(configDir, rulesSubDir);
|
|
268
417
|
if (deleteExisting) {
|
|
269
418
|
removeIfExists(rulesDir);
|
|
270
419
|
filesDeleted.push(rulesDir);
|
|
@@ -278,7 +427,7 @@ class GenericMdTarget extends BaseTarget {
|
|
|
278
427
|
}
|
|
279
428
|
}
|
|
280
429
|
if (effective.includes("commands")) {
|
|
281
|
-
const commandsDir =
|
|
430
|
+
const commandsDir = resolve(configDir, "commands");
|
|
282
431
|
if (deleteExisting) {
|
|
283
432
|
removeIfExists(commandsDir);
|
|
284
433
|
filesDeleted.push(commandsDir);
|
|
@@ -295,7 +444,7 @@ class GenericMdTarget extends BaseTarget {
|
|
|
295
444
|
const mcpEntries = Object.entries(features.mcpServers);
|
|
296
445
|
if (mcpEntries.length > 0) {
|
|
297
446
|
const mcpDir = this.config.mcpInConfigDir ? configDir : root;
|
|
298
|
-
const filepath =
|
|
447
|
+
const filepath = resolve(mcpDir, "mcp.json");
|
|
299
448
|
writeGeneratedJson(filepath, { mcpServers: features.mcpServers }, {
|
|
300
449
|
header: false
|
|
301
450
|
});
|
|
@@ -304,13 +453,23 @@ class GenericMdTarget extends BaseTarget {
|
|
|
304
453
|
}
|
|
305
454
|
if (effective.includes("ignore") && this.config.ignoreFile) {
|
|
306
455
|
if (features.ignorePatterns.length > 0) {
|
|
307
|
-
const filepath =
|
|
456
|
+
const filepath = resolve(root, this.config.ignoreFile);
|
|
308
457
|
writeGeneratedFile(filepath, features.ignorePatterns.join(`
|
|
309
458
|
`) + `
|
|
310
459
|
`);
|
|
311
460
|
filesWritten.push(filepath);
|
|
312
461
|
}
|
|
313
462
|
}
|
|
463
|
+
if (effective.includes("models") && features.models) {
|
|
464
|
+
const resolved = resolveModels(features.models, options.modelProfile, this.id);
|
|
465
|
+
const guidance = generateModelGuidanceMarkdown(resolved);
|
|
466
|
+
if (guidance) {
|
|
467
|
+
ensureDir(configDir);
|
|
468
|
+
const filepath = join2(configDir, "model-config.md");
|
|
469
|
+
writeGeneratedFile(filepath, guidance);
|
|
470
|
+
filesWritten.push(filepath);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
314
473
|
return this.createResult(filesWritten, filesDeleted, warnings);
|
|
315
474
|
}
|
|
316
475
|
}
|
|
@@ -1,32 +1,4 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
-
var __toCommonJS = (from) => {
|
|
8
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
-
if (entry)
|
|
10
|
-
return entry;
|
|
11
|
-
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
-
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
-
get: () => from[key],
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
}));
|
|
17
|
-
__moduleCache.set(from, entry);
|
|
18
|
-
return entry;
|
|
19
|
-
};
|
|
20
|
-
var __export = (target, all) => {
|
|
21
|
-
for (var name in all)
|
|
22
|
-
__defProp(target, name, {
|
|
23
|
-
get: all[name],
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
set: (newValue) => all[name] = () => newValue
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
2
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
3
|
|
|
32
4
|
// src/utils/filesystem.ts
|
|
@@ -36,10 +8,10 @@ import {
|
|
|
36
8
|
readFileSync,
|
|
37
9
|
writeFileSync,
|
|
38
10
|
readdirSync,
|
|
11
|
+
rmSync,
|
|
39
12
|
statSync
|
|
40
13
|
} from "fs";
|
|
41
14
|
import { dirname, relative, join } from "path";
|
|
42
|
-
import { removeSync } from "fs-extra";
|
|
43
15
|
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
44
16
|
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
45
17
|
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
@@ -80,7 +52,7 @@ function ensureDir(dirPath) {
|
|
|
80
52
|
}
|
|
81
53
|
function removeIfExists(targetPath) {
|
|
82
54
|
if (existsSync(targetPath)) {
|
|
83
|
-
|
|
55
|
+
rmSync(targetPath, { recursive: true, force: true });
|
|
84
56
|
}
|
|
85
57
|
}
|
|
86
58
|
function listFiles(dirPath, options = {}) {
|
|
@@ -209,14 +181,14 @@ class BaseTarget {
|
|
|
209
181
|
}
|
|
210
182
|
|
|
211
183
|
// src/targets/agents-md.ts
|
|
212
|
-
import { resolve
|
|
184
|
+
import { resolve } from "path";
|
|
213
185
|
class AgentsMdTarget extends BaseTarget {
|
|
214
186
|
id = "agentsmd";
|
|
215
187
|
name = "AGENTS.md";
|
|
216
188
|
supportedFeatures = ["rules"];
|
|
217
189
|
generate(options) {
|
|
218
190
|
const { projectRoot, baseDir, features } = options;
|
|
219
|
-
const root =
|
|
191
|
+
const root = resolve(projectRoot, baseDir);
|
|
220
192
|
const filesWritten = [];
|
|
221
193
|
const warnings = [];
|
|
222
194
|
const rootRules = getRootRules(features.rules);
|
|
@@ -228,7 +200,7 @@ class AgentsMdTarget extends BaseTarget {
|
|
|
228
200
|
const content = sections.join(`
|
|
229
201
|
|
|
230
202
|
`);
|
|
231
|
-
const filepath =
|
|
203
|
+
const filepath = resolve(root, "AGENTS.md");
|
|
232
204
|
writeGeneratedFile(filepath, content);
|
|
233
205
|
filesWritten.push(filepath);
|
|
234
206
|
return this.createResult(filesWritten, [], warnings);
|
|
@@ -1,32 +1,4 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
-
var __toCommonJS = (from) => {
|
|
8
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
-
if (entry)
|
|
10
|
-
return entry;
|
|
11
|
-
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
-
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
-
get: () => from[key],
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
}));
|
|
17
|
-
__moduleCache.set(from, entry);
|
|
18
|
-
return entry;
|
|
19
|
-
};
|
|
20
|
-
var __export = (target, all) => {
|
|
21
|
-
for (var name in all)
|
|
22
|
-
__defProp(target, name, {
|
|
23
|
-
get: all[name],
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
set: (newValue) => all[name] = () => newValue
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
2
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
3
|
|
|
32
4
|
// src/targets/base-target.ts
|