@wairon/cli 5.1.1-dev.54 → 5.1.1-dev.55
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/cli/index.js +447 -401
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +282 -233
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1233,7 +1233,7 @@ var init_defaults = __esm({
|
|
|
1233
1233
|
copilot: ".github/prompts",
|
|
1234
1234
|
codex: ".codex/agents"
|
|
1235
1235
|
};
|
|
1236
|
-
WAIRON_VERSION = "5.1.1-dev.
|
|
1236
|
+
WAIRON_VERSION = "5.1.1-dev.55";
|
|
1237
1237
|
GITHUB_REPO = "SYW-Apps/Waffle-AIron";
|
|
1238
1238
|
ARCHITECT_AGENT_ID = "agent-architect";
|
|
1239
1239
|
ARCHITECT_TEMPLATE_ID = "architect";
|
|
@@ -27354,6 +27354,273 @@ var init_treetransfer = __esm({
|
|
|
27354
27354
|
}
|
|
27355
27355
|
});
|
|
27356
27356
|
|
|
27357
|
+
// src/exporters/claude.ts
|
|
27358
|
+
function toolsFor(budget) {
|
|
27359
|
+
const base = TOOLS_BY_CLASS[budget.toolClass];
|
|
27360
|
+
if (!base) return void 0;
|
|
27361
|
+
if (budget.allowNestedDelegation && !base.includes("Agent")) {
|
|
27362
|
+
return [...base, "Agent"];
|
|
27363
|
+
}
|
|
27364
|
+
if (!budget.allowNestedDelegation) {
|
|
27365
|
+
return base.filter((t) => t !== "Agent");
|
|
27366
|
+
}
|
|
27367
|
+
return base;
|
|
27368
|
+
}
|
|
27369
|
+
function mcpServersFor(access) {
|
|
27370
|
+
return access === "none" ? "[]" : void 0;
|
|
27371
|
+
}
|
|
27372
|
+
function yamlScalar(value) {
|
|
27373
|
+
return /[:#\n]/.test(value) ? `"${value.replace(/"/g, '\\"')}"` : value;
|
|
27374
|
+
}
|
|
27375
|
+
var path23, MODEL_BY_TIER, TOOLS_BY_CLASS, ClaudeExporter;
|
|
27376
|
+
var init_claude = __esm({
|
|
27377
|
+
"src/exporters/claude.ts"() {
|
|
27378
|
+
"use strict";
|
|
27379
|
+
path23 = __toESM(require("path"));
|
|
27380
|
+
init_fs();
|
|
27381
|
+
MODEL_BY_TIER = {
|
|
27382
|
+
small: "haiku",
|
|
27383
|
+
standard: "sonnet",
|
|
27384
|
+
large: "opus",
|
|
27385
|
+
frontier: "fable"
|
|
27386
|
+
};
|
|
27387
|
+
TOOLS_BY_CLASS = {
|
|
27388
|
+
"read-only": ["Read", "Grep", "Glob"],
|
|
27389
|
+
implement: ["Read", "Grep", "Glob", "Edit", "Write", "Bash"],
|
|
27390
|
+
orchestrate: ["Agent", "SendMessage", "TodoWrite"],
|
|
27391
|
+
// `full` means "inherit everything" — expressed by omitting the field.
|
|
27392
|
+
full: void 0
|
|
27393
|
+
};
|
|
27394
|
+
ClaudeExporter = class {
|
|
27395
|
+
constructor(options = {}) {
|
|
27396
|
+
this.options = options;
|
|
27397
|
+
this.targetType = "claude";
|
|
27398
|
+
}
|
|
27399
|
+
outputPath(ctx) {
|
|
27400
|
+
const { agent, target, projectRoot } = ctx;
|
|
27401
|
+
const outputDir = "outputDir" in target ? target.outputDir : ".claude/agents";
|
|
27402
|
+
return path23.resolve(projectRoot, outputDir, `${agent.id.replace(/::/g, "--")}.md`);
|
|
27403
|
+
}
|
|
27404
|
+
export(ctx) {
|
|
27405
|
+
const { agent, renderedInstructions, budget } = ctx;
|
|
27406
|
+
const filePath = this.outputPath(ctx);
|
|
27407
|
+
const frontmatter = [
|
|
27408
|
+
`name: ${agent.name}`,
|
|
27409
|
+
`description: ${yamlScalar(agent.description)}`
|
|
27410
|
+
];
|
|
27411
|
+
if (budget && this.options.emitBudget) {
|
|
27412
|
+
if (budget.modelTier) frontmatter.push(`model: ${MODEL_BY_TIER[budget.modelTier]}`);
|
|
27413
|
+
if (budget.effort) frontmatter.push(`effort: ${budget.effort}`);
|
|
27414
|
+
if (budget.maxTurns !== void 0) frontmatter.push(`maxTurns: ${budget.maxTurns}`);
|
|
27415
|
+
const tools = toolsFor(budget);
|
|
27416
|
+
if (tools) frontmatter.push(`tools: ${tools.join(", ")}`);
|
|
27417
|
+
const servers = mcpServersFor(budget.mcp);
|
|
27418
|
+
if (servers) frontmatter.push(`mcpServers: ${servers}`);
|
|
27419
|
+
}
|
|
27420
|
+
const content = ["---", ...frontmatter, "---", "", renderedInstructions, ""].join("\n");
|
|
27421
|
+
const changed = writeFileIfChanged(filePath, content);
|
|
27422
|
+
return { outputPath: filePath, content, unchanged: !changed };
|
|
27423
|
+
}
|
|
27424
|
+
};
|
|
27425
|
+
}
|
|
27426
|
+
});
|
|
27427
|
+
|
|
27428
|
+
// src/exporters/custom.ts
|
|
27429
|
+
var path24, CustomExporter;
|
|
27430
|
+
var init_custom = __esm({
|
|
27431
|
+
"src/exporters/custom.ts"() {
|
|
27432
|
+
"use strict";
|
|
27433
|
+
path24 = __toESM(require("path"));
|
|
27434
|
+
init_fs();
|
|
27435
|
+
CustomExporter = class {
|
|
27436
|
+
constructor() {
|
|
27437
|
+
this.targetType = "custom";
|
|
27438
|
+
}
|
|
27439
|
+
outputPath(ctx) {
|
|
27440
|
+
const { agent, target, projectRoot } = ctx;
|
|
27441
|
+
if (!("outputDir" in target)) {
|
|
27442
|
+
throw new Error("CustomExporter requires target.outputDir");
|
|
27443
|
+
}
|
|
27444
|
+
return path24.resolve(projectRoot, target.outputDir, `${agent.id.replace(/::/g, "--")}.md`);
|
|
27445
|
+
}
|
|
27446
|
+
export(ctx) {
|
|
27447
|
+
const { agent, target, renderedInstructions } = ctx;
|
|
27448
|
+
const label = "label" in target ? target.label : "Custom";
|
|
27449
|
+
const filePath = this.outputPath(ctx);
|
|
27450
|
+
const content = [
|
|
27451
|
+
"---",
|
|
27452
|
+
`name: ${agent.name}`,
|
|
27453
|
+
`description: ${agent.description}`,
|
|
27454
|
+
`id: ${agent.id}`,
|
|
27455
|
+
`target: ${label}`,
|
|
27456
|
+
"---",
|
|
27457
|
+
"",
|
|
27458
|
+
renderedInstructions,
|
|
27459
|
+
""
|
|
27460
|
+
].join("\n");
|
|
27461
|
+
const changed = writeFileIfChanged(filePath, content);
|
|
27462
|
+
return { outputPath: filePath, content, unchanged: !changed };
|
|
27463
|
+
}
|
|
27464
|
+
};
|
|
27465
|
+
}
|
|
27466
|
+
});
|
|
27467
|
+
|
|
27468
|
+
// src/exporters/gemini.ts
|
|
27469
|
+
function yamlString(value) {
|
|
27470
|
+
if (/[:#\[\]{},&*!|>'"%@`]/.test(value) || value.startsWith(" ") || value.endsWith(" ")) {
|
|
27471
|
+
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
27472
|
+
}
|
|
27473
|
+
return value;
|
|
27474
|
+
}
|
|
27475
|
+
var path25, GeminiExporter;
|
|
27476
|
+
var init_gemini = __esm({
|
|
27477
|
+
"src/exporters/gemini.ts"() {
|
|
27478
|
+
"use strict";
|
|
27479
|
+
path25 = __toESM(require("path"));
|
|
27480
|
+
init_fs();
|
|
27481
|
+
GeminiExporter = class {
|
|
27482
|
+
constructor() {
|
|
27483
|
+
this.targetType = "gemini";
|
|
27484
|
+
}
|
|
27485
|
+
outputPath(ctx) {
|
|
27486
|
+
const { agent, target, projectRoot } = ctx;
|
|
27487
|
+
const outputDir = "outputDir" in target ? target.outputDir : ".gemini/agents";
|
|
27488
|
+
return path25.resolve(projectRoot, outputDir, `${agent.id.replace(/::/g, "--")}.yaml`);
|
|
27489
|
+
}
|
|
27490
|
+
export(ctx) {
|
|
27491
|
+
const { agent, renderedInstructions } = ctx;
|
|
27492
|
+
const filePath = this.outputPath(ctx);
|
|
27493
|
+
const indentedInstructions = renderedInstructions.split("\n").map((line) => line.length > 0 ? ` ${line}` : "").join("\n");
|
|
27494
|
+
const content = [
|
|
27495
|
+
`name: ${yamlString(agent.name)}`,
|
|
27496
|
+
`description: ${yamlString(agent.description)}`,
|
|
27497
|
+
`system_prompt: |`,
|
|
27498
|
+
indentedInstructions,
|
|
27499
|
+
""
|
|
27500
|
+
].join("\n");
|
|
27501
|
+
const changed = writeFileIfChanged(filePath, content);
|
|
27502
|
+
return { outputPath: filePath, content, unchanged: !changed };
|
|
27503
|
+
}
|
|
27504
|
+
};
|
|
27505
|
+
}
|
|
27506
|
+
});
|
|
27507
|
+
|
|
27508
|
+
// src/exporters/registry.ts
|
|
27509
|
+
function getExporter(target) {
|
|
27510
|
+
const type = typeof target === "string" ? target : target.type;
|
|
27511
|
+
const exporter = EXPORTERS.get(type);
|
|
27512
|
+
if (!exporter) {
|
|
27513
|
+
throw new WaironError(`No exporter registered for target type: "${type}"`);
|
|
27514
|
+
}
|
|
27515
|
+
return exporter;
|
|
27516
|
+
}
|
|
27517
|
+
function registerExporter(type, exporter) {
|
|
27518
|
+
EXPORTERS.set(type, exporter);
|
|
27519
|
+
}
|
|
27520
|
+
var EXPORTERS;
|
|
27521
|
+
var init_registry2 = __esm({
|
|
27522
|
+
"src/exporters/registry.ts"() {
|
|
27523
|
+
"use strict";
|
|
27524
|
+
init_claude();
|
|
27525
|
+
init_custom();
|
|
27526
|
+
init_gemini();
|
|
27527
|
+
init_errors();
|
|
27528
|
+
EXPORTERS = /* @__PURE__ */ new Map([
|
|
27529
|
+
["claude", new ClaudeExporter({ emitBudget: true })],
|
|
27530
|
+
["gemini", new GeminiExporter()],
|
|
27531
|
+
["agy", new GeminiExporter()],
|
|
27532
|
+
["cursor", new ClaudeExporter()],
|
|
27533
|
+
["copilot", new ClaudeExporter()],
|
|
27534
|
+
["codex", new ClaudeExporter()],
|
|
27535
|
+
["custom", new CustomExporter()]
|
|
27536
|
+
]);
|
|
27537
|
+
}
|
|
27538
|
+
});
|
|
27539
|
+
|
|
27540
|
+
// src/exporters/base.ts
|
|
27541
|
+
var WAIRON_MANAGED_MARKER, WAIRON_MANAGED_BANNER;
|
|
27542
|
+
var init_base = __esm({
|
|
27543
|
+
"src/exporters/base.ts"() {
|
|
27544
|
+
"use strict";
|
|
27545
|
+
WAIRON_MANAGED_MARKER = "wairon:managed";
|
|
27546
|
+
WAIRON_MANAGED_BANNER = `<!-- ${WAIRON_MANAGED_MARKER} \u2014 generated by \`wairon generate\`; do not edit, changes are overwritten -->`;
|
|
27547
|
+
}
|
|
27548
|
+
});
|
|
27549
|
+
|
|
27550
|
+
// src/exporters/generate.ts
|
|
27551
|
+
function generateAgent(agent, projectConfig, options = {}) {
|
|
27552
|
+
const projectRoot = options.projectRoot ?? getProjectRoot();
|
|
27553
|
+
const template = loadTemplate(agent.template, projectConfig.globalTemplatesDir);
|
|
27554
|
+
const rendered = `${WAIRON_MANAGED_BANNER}
|
|
27555
|
+
${composeAgentBrief(agent.id).instructions}`;
|
|
27556
|
+
const results = [];
|
|
27557
|
+
const budget = resolveBudget(
|
|
27558
|
+
deriveExecutionProfile(agent),
|
|
27559
|
+
projectConfig.execution,
|
|
27560
|
+
agent.id
|
|
27561
|
+
);
|
|
27562
|
+
for (const agentTarget of agent.targets) {
|
|
27563
|
+
const targetConfig = resolveTargetConfig(agentTarget, projectConfig);
|
|
27564
|
+
if (!targetConfig) continue;
|
|
27565
|
+
if (options.filterTargets) {
|
|
27566
|
+
const type = "type" in targetConfig ? targetConfig.type : targetConfig;
|
|
27567
|
+
if (!options.filterTargets.includes(type)) continue;
|
|
27568
|
+
}
|
|
27569
|
+
if (!options.dryRun) {
|
|
27570
|
+
results.push(getExporter(targetConfig).export({
|
|
27571
|
+
agent,
|
|
27572
|
+
template,
|
|
27573
|
+
renderedInstructions: rendered,
|
|
27574
|
+
projectRoot,
|
|
27575
|
+
target: targetConfig,
|
|
27576
|
+
budget
|
|
27577
|
+
}));
|
|
27578
|
+
}
|
|
27579
|
+
}
|
|
27580
|
+
return { agent, results };
|
|
27581
|
+
}
|
|
27582
|
+
function generateAll(agents, projectConfig, options = {}) {
|
|
27583
|
+
let pool = agents;
|
|
27584
|
+
if (options.filterDomainIds && options.filterDomainIds.length > 0) {
|
|
27585
|
+
const ids = new Set(options.filterDomainIds);
|
|
27586
|
+
pool = agents.filter((a) => ids.has(a.domainRoot ?? "root"));
|
|
27587
|
+
}
|
|
27588
|
+
return pool.map((agent) => generateAgent(agent, projectConfig, options));
|
|
27589
|
+
}
|
|
27590
|
+
function resolveExpectedOutputPaths(agents, projectConfig, projectRoot = getProjectRoot()) {
|
|
27591
|
+
const expected = /* @__PURE__ */ new Set();
|
|
27592
|
+
for (const agent of agents) {
|
|
27593
|
+
for (const agentTarget of agent.targets) {
|
|
27594
|
+
const targetConfig = resolveTargetConfig(agentTarget, projectConfig);
|
|
27595
|
+
if (!targetConfig) continue;
|
|
27596
|
+
const ctx = { agent, projectRoot, target: targetConfig };
|
|
27597
|
+
expected.add(path26.resolve(getExporter(targetConfig).outputPath(ctx)));
|
|
27598
|
+
}
|
|
27599
|
+
}
|
|
27600
|
+
return expected;
|
|
27601
|
+
}
|
|
27602
|
+
function resolveTargetConfig(agentTarget, projectConfig) {
|
|
27603
|
+
const targetType = typeof agentTarget === "string" ? agentTarget : agentTarget.type;
|
|
27604
|
+
return projectConfig.targets.find((t) => {
|
|
27605
|
+
if (typeof t === "string") return t === targetType;
|
|
27606
|
+
return t.type === targetType;
|
|
27607
|
+
});
|
|
27608
|
+
}
|
|
27609
|
+
var path26;
|
|
27610
|
+
var init_generate = __esm({
|
|
27611
|
+
"src/exporters/generate.ts"() {
|
|
27612
|
+
"use strict";
|
|
27613
|
+
path26 = __toESM(require("path"));
|
|
27614
|
+
init_templates();
|
|
27615
|
+
init_agent_resolver();
|
|
27616
|
+
init_execution_profile();
|
|
27617
|
+
init_budget_policy();
|
|
27618
|
+
init_fs();
|
|
27619
|
+
init_registry2();
|
|
27620
|
+
init_base();
|
|
27621
|
+
}
|
|
27622
|
+
});
|
|
27623
|
+
|
|
27357
27624
|
// src/core/stereotype-migration.ts
|
|
27358
27625
|
function retireSpecialists(apply) {
|
|
27359
27626
|
const components = loadComponentSpecs();
|
|
@@ -27510,12 +27777,12 @@ function digest(content) {
|
|
|
27510
27777
|
return crypto4.createHash("sha256").update(normalized, "utf8").digest("hex");
|
|
27511
27778
|
}
|
|
27512
27779
|
function currentSpecDigests(root = getProjectRoot()) {
|
|
27513
|
-
const mountDirs = loadSubsystemSpecs().filter((s) => s.projectPath && !s.id.includes("::")).map((s) => `${
|
|
27780
|
+
const mountDirs = loadSubsystemSpecs().filter((s) => s.projectPath && !s.id.includes("::")).map((s) => `${path27.resolve(root, s.projectPath).split(path27.sep).join("/")}/`);
|
|
27514
27781
|
const out = {};
|
|
27515
27782
|
for (const [abs, content] of snapshotSpecFiles()) {
|
|
27516
|
-
const normalized =
|
|
27783
|
+
const normalized = path27.resolve(abs).split(path27.sep).join("/");
|
|
27517
27784
|
if (mountDirs.some((dir) => normalized.startsWith(dir))) continue;
|
|
27518
|
-
out[
|
|
27785
|
+
out[path27.relative(root, abs).split(path27.sep).join("/")] = digest(content);
|
|
27519
27786
|
}
|
|
27520
27787
|
return out;
|
|
27521
27788
|
}
|
|
@@ -27573,7 +27840,7 @@ function currentChildPins(mounts, root = getProjectRoot()) {
|
|
|
27573
27840
|
const pins = {};
|
|
27574
27841
|
for (const mount of mounts) {
|
|
27575
27842
|
if (!mount.projectPath || mount.id.includes("::")) continue;
|
|
27576
|
-
const child = readLockRecordAt(
|
|
27843
|
+
const child = readLockRecordAt(path27.resolve(root, mount.projectPath));
|
|
27577
27844
|
if (child) pins[mount.id] = pinOf(child.stateId);
|
|
27578
27845
|
}
|
|
27579
27846
|
return pins;
|
|
@@ -27589,12 +27856,12 @@ function movedChildren(mounts, root = getProjectRoot()) {
|
|
|
27589
27856
|
}
|
|
27590
27857
|
return moved;
|
|
27591
27858
|
}
|
|
27592
|
-
var crypto4,
|
|
27859
|
+
var crypto4, path27;
|
|
27593
27860
|
var init_approval = __esm({
|
|
27594
27861
|
"src/core/approval.ts"() {
|
|
27595
27862
|
"use strict";
|
|
27596
27863
|
crypto4 = __toESM(require("crypto"));
|
|
27597
|
-
|
|
27864
|
+
path27 = __toESM(require("path"));
|
|
27598
27865
|
init_fs();
|
|
27599
27866
|
init_specs2();
|
|
27600
27867
|
init_lockfile();
|
|
@@ -27678,6 +27945,7 @@ var init_core = __esm({
|
|
|
27678
27945
|
init_treetransfer();
|
|
27679
27946
|
init_extensions();
|
|
27680
27947
|
init_agent_resolver();
|
|
27948
|
+
init_generate();
|
|
27681
27949
|
init_treetransfer();
|
|
27682
27950
|
init_provision();
|
|
27683
27951
|
init_stereotype_migration();
|
|
@@ -28144,232 +28412,13 @@ init_loader();
|
|
|
28144
28412
|
// src/index.ts
|
|
28145
28413
|
init_core();
|
|
28146
28414
|
|
|
28147
|
-
// src/exporters/
|
|
28148
|
-
|
|
28149
|
-
|
|
28150
|
-
|
|
28151
|
-
|
|
28152
|
-
|
|
28153
|
-
|
|
28154
|
-
var MODEL_BY_TIER = {
|
|
28155
|
-
small: "haiku",
|
|
28156
|
-
standard: "sonnet",
|
|
28157
|
-
large: "opus",
|
|
28158
|
-
frontier: "fable"
|
|
28159
|
-
};
|
|
28160
|
-
var TOOLS_BY_CLASS = {
|
|
28161
|
-
"read-only": ["Read", "Grep", "Glob"],
|
|
28162
|
-
implement: ["Read", "Grep", "Glob", "Edit", "Write", "Bash"],
|
|
28163
|
-
orchestrate: ["Agent", "SendMessage", "TodoWrite"],
|
|
28164
|
-
// `full` means "inherit everything" — expressed by omitting the field.
|
|
28165
|
-
full: void 0
|
|
28166
|
-
};
|
|
28167
|
-
function toolsFor(budget) {
|
|
28168
|
-
const base = TOOLS_BY_CLASS[budget.toolClass];
|
|
28169
|
-
if (!base) return void 0;
|
|
28170
|
-
if (budget.allowNestedDelegation && !base.includes("Agent")) {
|
|
28171
|
-
return [...base, "Agent"];
|
|
28172
|
-
}
|
|
28173
|
-
if (!budget.allowNestedDelegation) {
|
|
28174
|
-
return base.filter((t) => t !== "Agent");
|
|
28175
|
-
}
|
|
28176
|
-
return base;
|
|
28177
|
-
}
|
|
28178
|
-
function mcpServersFor(access) {
|
|
28179
|
-
return access === "none" ? "[]" : void 0;
|
|
28180
|
-
}
|
|
28181
|
-
function yamlScalar(value) {
|
|
28182
|
-
return /[:#\n]/.test(value) ? `"${value.replace(/"/g, '\\"')}"` : value;
|
|
28183
|
-
}
|
|
28184
|
-
var ClaudeExporter = class {
|
|
28185
|
-
constructor(options = {}) {
|
|
28186
|
-
this.options = options;
|
|
28187
|
-
this.targetType = "claude";
|
|
28188
|
-
}
|
|
28189
|
-
outputPath(ctx) {
|
|
28190
|
-
const { agent, target, projectRoot } = ctx;
|
|
28191
|
-
const outputDir = "outputDir" in target ? target.outputDir : ".claude/agents";
|
|
28192
|
-
return path24.resolve(projectRoot, outputDir, `${agent.id.replace(/::/g, "--")}.md`);
|
|
28193
|
-
}
|
|
28194
|
-
export(ctx) {
|
|
28195
|
-
const { agent, renderedInstructions, budget } = ctx;
|
|
28196
|
-
const filePath = this.outputPath(ctx);
|
|
28197
|
-
const frontmatter = [
|
|
28198
|
-
`name: ${agent.name}`,
|
|
28199
|
-
`description: ${yamlScalar(agent.description)}`
|
|
28200
|
-
];
|
|
28201
|
-
if (budget && this.options.emitBudget) {
|
|
28202
|
-
if (budget.modelTier) frontmatter.push(`model: ${MODEL_BY_TIER[budget.modelTier]}`);
|
|
28203
|
-
if (budget.effort) frontmatter.push(`effort: ${budget.effort}`);
|
|
28204
|
-
if (budget.maxTurns !== void 0) frontmatter.push(`maxTurns: ${budget.maxTurns}`);
|
|
28205
|
-
const tools = toolsFor(budget);
|
|
28206
|
-
if (tools) frontmatter.push(`tools: ${tools.join(", ")}`);
|
|
28207
|
-
const servers = mcpServersFor(budget.mcp);
|
|
28208
|
-
if (servers) frontmatter.push(`mcpServers: ${servers}`);
|
|
28209
|
-
}
|
|
28210
|
-
const content = ["---", ...frontmatter, "---", "", renderedInstructions, ""].join("\n");
|
|
28211
|
-
const changed = writeFileIfChanged(filePath, content);
|
|
28212
|
-
return { outputPath: filePath, content, unchanged: !changed };
|
|
28213
|
-
}
|
|
28214
|
-
};
|
|
28215
|
-
|
|
28216
|
-
// src/exporters/custom.ts
|
|
28217
|
-
var path25 = __toESM(require("path"));
|
|
28218
|
-
init_fs();
|
|
28219
|
-
var CustomExporter = class {
|
|
28220
|
-
constructor() {
|
|
28221
|
-
this.targetType = "custom";
|
|
28222
|
-
}
|
|
28223
|
-
outputPath(ctx) {
|
|
28224
|
-
const { agent, target, projectRoot } = ctx;
|
|
28225
|
-
if (!("outputDir" in target)) {
|
|
28226
|
-
throw new Error("CustomExporter requires target.outputDir");
|
|
28227
|
-
}
|
|
28228
|
-
return path25.resolve(projectRoot, target.outputDir, `${agent.id.replace(/::/g, "--")}.md`);
|
|
28229
|
-
}
|
|
28230
|
-
export(ctx) {
|
|
28231
|
-
const { agent, target, renderedInstructions } = ctx;
|
|
28232
|
-
const label = "label" in target ? target.label : "Custom";
|
|
28233
|
-
const filePath = this.outputPath(ctx);
|
|
28234
|
-
const content = [
|
|
28235
|
-
"---",
|
|
28236
|
-
`name: ${agent.name}`,
|
|
28237
|
-
`description: ${agent.description}`,
|
|
28238
|
-
`id: ${agent.id}`,
|
|
28239
|
-
`target: ${label}`,
|
|
28240
|
-
"---",
|
|
28241
|
-
"",
|
|
28242
|
-
renderedInstructions,
|
|
28243
|
-
""
|
|
28244
|
-
].join("\n");
|
|
28245
|
-
const changed = writeFileIfChanged(filePath, content);
|
|
28246
|
-
return { outputPath: filePath, content, unchanged: !changed };
|
|
28247
|
-
}
|
|
28248
|
-
};
|
|
28249
|
-
|
|
28250
|
-
// src/exporters/gemini.ts
|
|
28251
|
-
var path26 = __toESM(require("path"));
|
|
28252
|
-
init_fs();
|
|
28253
|
-
var GeminiExporter = class {
|
|
28254
|
-
constructor() {
|
|
28255
|
-
this.targetType = "gemini";
|
|
28256
|
-
}
|
|
28257
|
-
outputPath(ctx) {
|
|
28258
|
-
const { agent, target, projectRoot } = ctx;
|
|
28259
|
-
const outputDir = "outputDir" in target ? target.outputDir : ".gemini/agents";
|
|
28260
|
-
return path26.resolve(projectRoot, outputDir, `${agent.id.replace(/::/g, "--")}.yaml`);
|
|
28261
|
-
}
|
|
28262
|
-
export(ctx) {
|
|
28263
|
-
const { agent, renderedInstructions } = ctx;
|
|
28264
|
-
const filePath = this.outputPath(ctx);
|
|
28265
|
-
const indentedInstructions = renderedInstructions.split("\n").map((line) => line.length > 0 ? ` ${line}` : "").join("\n");
|
|
28266
|
-
const content = [
|
|
28267
|
-
`name: ${yamlString(agent.name)}`,
|
|
28268
|
-
`description: ${yamlString(agent.description)}`,
|
|
28269
|
-
`system_prompt: |`,
|
|
28270
|
-
indentedInstructions,
|
|
28271
|
-
""
|
|
28272
|
-
].join("\n");
|
|
28273
|
-
const changed = writeFileIfChanged(filePath, content);
|
|
28274
|
-
return { outputPath: filePath, content, unchanged: !changed };
|
|
28275
|
-
}
|
|
28276
|
-
};
|
|
28277
|
-
function yamlString(value) {
|
|
28278
|
-
if (/[:#\[\]{},&*!|>'"%@`]/.test(value) || value.startsWith(" ") || value.endsWith(" ")) {
|
|
28279
|
-
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
28280
|
-
}
|
|
28281
|
-
return value;
|
|
28282
|
-
}
|
|
28283
|
-
|
|
28284
|
-
// src/exporters/generate.ts
|
|
28285
|
-
var path27 = __toESM(require("path"));
|
|
28286
|
-
init_core();
|
|
28287
|
-
init_execution_profile();
|
|
28288
|
-
init_budget_policy();
|
|
28289
|
-
init_fs();
|
|
28290
|
-
|
|
28291
|
-
// src/exporters/registry.ts
|
|
28292
|
-
init_errors();
|
|
28293
|
-
var EXPORTERS = /* @__PURE__ */ new Map([
|
|
28294
|
-
["claude", new ClaudeExporter({ emitBudget: true })],
|
|
28295
|
-
["gemini", new GeminiExporter()],
|
|
28296
|
-
["agy", new GeminiExporter()],
|
|
28297
|
-
["cursor", new ClaudeExporter()],
|
|
28298
|
-
["copilot", new ClaudeExporter()],
|
|
28299
|
-
["codex", new ClaudeExporter()],
|
|
28300
|
-
["custom", new CustomExporter()]
|
|
28301
|
-
]);
|
|
28302
|
-
function getExporter(target) {
|
|
28303
|
-
const type = typeof target === "string" ? target : target.type;
|
|
28304
|
-
const exporter = EXPORTERS.get(type);
|
|
28305
|
-
if (!exporter) {
|
|
28306
|
-
throw new WaironError(`No exporter registered for target type: "${type}"`);
|
|
28307
|
-
}
|
|
28308
|
-
return exporter;
|
|
28309
|
-
}
|
|
28310
|
-
function registerExporter(type, exporter) {
|
|
28311
|
-
EXPORTERS.set(type, exporter);
|
|
28312
|
-
}
|
|
28313
|
-
|
|
28314
|
-
// src/exporters/generate.ts
|
|
28315
|
-
function generateAgent(agent, projectConfig, options = {}) {
|
|
28316
|
-
const projectRoot = options.projectRoot ?? getProjectRoot();
|
|
28317
|
-
const template = loadTemplate(agent.template, projectConfig.globalTemplatesDir);
|
|
28318
|
-
const rendered = `${WAIRON_MANAGED_BANNER}
|
|
28319
|
-
${composeAgentBrief(agent.id).instructions}`;
|
|
28320
|
-
const results = [];
|
|
28321
|
-
const budget = resolveBudget(
|
|
28322
|
-
deriveExecutionProfile(agent),
|
|
28323
|
-
projectConfig.execution,
|
|
28324
|
-
agent.id
|
|
28325
|
-
);
|
|
28326
|
-
for (const agentTarget of agent.targets) {
|
|
28327
|
-
const targetConfig = resolveTargetConfig(agentTarget, projectConfig);
|
|
28328
|
-
if (!targetConfig) continue;
|
|
28329
|
-
if (options.filterTargets) {
|
|
28330
|
-
const type = "type" in targetConfig ? targetConfig.type : targetConfig;
|
|
28331
|
-
if (!options.filterTargets.includes(type)) continue;
|
|
28332
|
-
}
|
|
28333
|
-
if (!options.dryRun) {
|
|
28334
|
-
results.push(getExporter(targetConfig).export({
|
|
28335
|
-
agent,
|
|
28336
|
-
template,
|
|
28337
|
-
renderedInstructions: rendered,
|
|
28338
|
-
projectRoot,
|
|
28339
|
-
target: targetConfig,
|
|
28340
|
-
budget
|
|
28341
|
-
}));
|
|
28342
|
-
}
|
|
28343
|
-
}
|
|
28344
|
-
return { agent, results };
|
|
28345
|
-
}
|
|
28346
|
-
function generateAll(agents, projectConfig, options = {}) {
|
|
28347
|
-
let pool = agents;
|
|
28348
|
-
if (options.filterDomainIds && options.filterDomainIds.length > 0) {
|
|
28349
|
-
const ids = new Set(options.filterDomainIds);
|
|
28350
|
-
pool = agents.filter((a) => ids.has(a.domainRoot ?? "root"));
|
|
28351
|
-
}
|
|
28352
|
-
return pool.map((agent) => generateAgent(agent, projectConfig, options));
|
|
28353
|
-
}
|
|
28354
|
-
function resolveExpectedOutputPaths(agents, projectConfig, projectRoot = getProjectRoot()) {
|
|
28355
|
-
const expected = /* @__PURE__ */ new Set();
|
|
28356
|
-
for (const agent of agents) {
|
|
28357
|
-
for (const agentTarget of agent.targets) {
|
|
28358
|
-
const targetConfig = resolveTargetConfig(agentTarget, projectConfig);
|
|
28359
|
-
if (!targetConfig) continue;
|
|
28360
|
-
const ctx = { agent, projectRoot, target: targetConfig };
|
|
28361
|
-
expected.add(path27.resolve(getExporter(targetConfig).outputPath(ctx)));
|
|
28362
|
-
}
|
|
28363
|
-
}
|
|
28364
|
-
return expected;
|
|
28365
|
-
}
|
|
28366
|
-
function resolveTargetConfig(agentTarget, projectConfig) {
|
|
28367
|
-
const targetType = typeof agentTarget === "string" ? agentTarget : agentTarget.type;
|
|
28368
|
-
return projectConfig.targets.find((t) => {
|
|
28369
|
-
if (typeof t === "string") return t === targetType;
|
|
28370
|
-
return t.type === targetType;
|
|
28371
|
-
});
|
|
28372
|
-
}
|
|
28415
|
+
// src/exporters/index.ts
|
|
28416
|
+
init_base();
|
|
28417
|
+
init_claude();
|
|
28418
|
+
init_custom();
|
|
28419
|
+
init_gemini();
|
|
28420
|
+
init_generate();
|
|
28421
|
+
init_registry2();
|
|
28373
28422
|
|
|
28374
28423
|
// src/utils/index.ts
|
|
28375
28424
|
init_errors();
|