@deimoscloud/coreai 0.1.14 → 0.1.16
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/agents/_templates/ic-engineer.md +99 -14
- package/agents/_templates/reviewer.md +95 -13
- package/agents/android-engineer.md +289 -0
- package/agents/backend-engineer.md +287 -0
- package/agents/database-administrator.md +289 -0
- package/agents/devops-engineer.md +323 -0
- package/agents/{examples/engineering-manager.md → engineering-manager.md} +208 -171
- package/agents/frontend-engineer.md +287 -0
- package/agents/product-manager.md +371 -0
- package/agents/react-engineer.md +289 -0
- package/agents/react-native-engineer.md +289 -0
- package/agents/software-security-engineer.md +451 -0
- package/agents/software-solutions-architect.md +469 -0
- package/agents/sre-huawei-cloud-architect.md +289 -0
- package/agents/sre-iac-specialist.md +289 -0
- package/agents/sre-kubernetes-specialist.md +289 -0
- package/agents/sre-network-specialist.md +289 -0
- package/agents/wearos-engineer.md +289 -0
- package/dist/cli/index.js +281 -55
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +78 -51
- package/dist/index.js +265 -44
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/schemas/agent.schema.json +140 -3
- package/agents/android-engineer.yaml +0 -74
- package/agents/backend-engineer.yaml +0 -72
- package/agents/database-administrator.yaml +0 -74
- package/agents/devops-engineer.yaml +0 -72
- package/agents/engineering-manager.yaml +0 -70
- package/agents/examples/android-engineer.md +0 -302
- package/agents/examples/backend-engineer.md +0 -320
- package/agents/examples/devops-engineer.md +0 -742
- package/agents/examples/frontend-engineer.md +0 -58
- package/agents/examples/product-manager.md +0 -315
- package/agents/examples/qa-engineer.md +0 -371
- package/agents/examples/security-engineer.md +0 -525
- package/agents/examples/solutions-architect.md +0 -351
- package/agents/examples/wearos-engineer.md +0 -359
- package/agents/frontend-engineer.yaml +0 -72
- package/agents/product-manager.yaml +0 -75
- package/agents/react-engineer.yaml +0 -74
- package/agents/react-native-engineer.yaml +0 -74
- package/agents/software-security-engineer.yaml +0 -74
- package/agents/software-solutions-architect.yaml +0 -73
- package/agents/sre-huawei-cloud-architect.yaml +0 -74
- package/agents/sre-iac-specialist.yaml +0 -74
- package/agents/sre-kubernetes-specialist.yaml +0 -74
- package/agents/sre-network-specialist.yaml +0 -74
- package/agents/wearos-engineer.yaml +0 -74
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { readFileSync as
|
|
2
|
+
import { readFileSync as readFileSync6 } from "fs";
|
|
3
3
|
import { dirname as dirname5, join as join8 } from "path";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
|
|
@@ -149,6 +149,61 @@ var AgentError = class extends Error {
|
|
|
149
149
|
this.name = "AgentError";
|
|
150
150
|
}
|
|
151
151
|
};
|
|
152
|
+
function extractFrontmatter(content) {
|
|
153
|
+
const match = content.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
|
|
154
|
+
if (!match) {
|
|
155
|
+
throw new AgentError(
|
|
156
|
+
"No YAML frontmatter found. Agent MD files must start with YAML frontmatter (---)",
|
|
157
|
+
"PARSE_ERROR"
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
const frontmatterYaml = match[1];
|
|
161
|
+
const body = match[2] ?? "";
|
|
162
|
+
let frontmatter;
|
|
163
|
+
try {
|
|
164
|
+
frontmatter = parseYaml2(frontmatterYaml);
|
|
165
|
+
} catch (error) {
|
|
166
|
+
const message = error instanceof Error ? error.message : "Unknown parse error";
|
|
167
|
+
throw new AgentError(`Failed to parse YAML frontmatter: ${message}`, "PARSE_ERROR", error);
|
|
168
|
+
}
|
|
169
|
+
if (!frontmatter || typeof frontmatter !== "object") {
|
|
170
|
+
throw new AgentError("Invalid frontmatter: expected an object", "PARSE_ERROR");
|
|
171
|
+
}
|
|
172
|
+
return { frontmatter, body };
|
|
173
|
+
}
|
|
174
|
+
function loadAgentFromMdFile(filePath) {
|
|
175
|
+
if (!existsSync2(filePath)) {
|
|
176
|
+
throw new AgentError(`Agent file not found: ${filePath}`, "NOT_FOUND");
|
|
177
|
+
}
|
|
178
|
+
let content;
|
|
179
|
+
try {
|
|
180
|
+
content = readFileSync2(filePath, "utf-8");
|
|
181
|
+
} catch (error) {
|
|
182
|
+
const message = error instanceof Error ? error.message : "Unknown read error";
|
|
183
|
+
throw new AgentError(`Failed to read agent file ${filePath}: ${message}`, "READ_ERROR", error);
|
|
184
|
+
}
|
|
185
|
+
const { frontmatter } = extractFrontmatter(content);
|
|
186
|
+
const role = frontmatter.name || getRoleFromFilename(filePath);
|
|
187
|
+
if (!role) {
|
|
188
|
+
throw new AgentError(
|
|
189
|
+
`Agent MD file must have a 'name' field in frontmatter or a valid filename: ${filePath}`,
|
|
190
|
+
"VALIDATION_ERROR"
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
const description = frontmatter.description || "";
|
|
194
|
+
const tools = typeof frontmatter.tools === "string" ? frontmatter.tools.split(",").map((t) => t.trim()).filter(Boolean) : void 0;
|
|
195
|
+
const definition = {
|
|
196
|
+
role,
|
|
197
|
+
type: "ic-engineer",
|
|
198
|
+
// Default, actual identity is in the MD content
|
|
199
|
+
display_name: role.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" "),
|
|
200
|
+
description
|
|
201
|
+
};
|
|
202
|
+
if (tools) {
|
|
203
|
+
definition.tools = tools;
|
|
204
|
+
}
|
|
205
|
+
return definition;
|
|
206
|
+
}
|
|
152
207
|
function parseAgentYaml(content, filePath) {
|
|
153
208
|
try {
|
|
154
209
|
return parseYaml2(content);
|
|
@@ -180,7 +235,7 @@ function validateAgentDefinition(agent) {
|
|
|
180
235
|
}
|
|
181
236
|
return agent;
|
|
182
237
|
}
|
|
183
|
-
function
|
|
238
|
+
function loadAgentFromYamlFile(filePath) {
|
|
184
239
|
if (!existsSync2(filePath)) {
|
|
185
240
|
throw new AgentError(`Agent file not found: ${filePath}`, "NOT_FOUND");
|
|
186
241
|
}
|
|
@@ -194,18 +249,36 @@ function loadAgentFromFile(filePath) {
|
|
|
194
249
|
const parsed = parseAgentYaml(content, filePath);
|
|
195
250
|
return validateAgentDefinition(parsed);
|
|
196
251
|
}
|
|
197
|
-
function
|
|
252
|
+
function loadAgentFromFile(filePath) {
|
|
253
|
+
const ext = extname(filePath).toLowerCase();
|
|
254
|
+
if (ext === ".md") {
|
|
255
|
+
return loadAgentFromMdFile(filePath);
|
|
256
|
+
}
|
|
257
|
+
if (ext === ".yaml" || ext === ".yml") {
|
|
258
|
+
console.warn(
|
|
259
|
+
`Warning: YAML agent definitions are deprecated and will be removed in a future version.
|
|
260
|
+
Please migrate ${basename(filePath)} to Markdown format.`
|
|
261
|
+
);
|
|
262
|
+
return loadAgentFromYamlFile(filePath);
|
|
263
|
+
}
|
|
264
|
+
throw new AgentError(
|
|
265
|
+
`Unsupported agent file format: ${ext}. Use .md (recommended) or .yaml/.yml (deprecated)`,
|
|
266
|
+
"PARSE_ERROR"
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
function listAgentFiles(dir) {
|
|
198
270
|
if (!existsSync2(dir)) {
|
|
199
271
|
return [];
|
|
200
272
|
}
|
|
201
273
|
return readdirSync(dir).filter((file) => {
|
|
274
|
+
if (file.startsWith("_")) return false;
|
|
202
275
|
const ext = extname(file).toLowerCase();
|
|
203
|
-
return ext === ".yaml" || ext === ".yml";
|
|
276
|
+
return ext === ".md" || ext === ".yaml" || ext === ".yml";
|
|
204
277
|
}).map((file) => join2(dir, file));
|
|
205
278
|
}
|
|
206
279
|
function loadAgentsFromDirectory(dir, source) {
|
|
207
280
|
const agents = /* @__PURE__ */ new Map();
|
|
208
|
-
const files =
|
|
281
|
+
const files = listAgentFiles(dir);
|
|
209
282
|
for (const filePath of files) {
|
|
210
283
|
try {
|
|
211
284
|
const definition = loadAgentFromFile(filePath);
|
|
@@ -372,17 +445,46 @@ function resolveAgentDefinition(agent, config, options = {}) {
|
|
|
372
445
|
}
|
|
373
446
|
|
|
374
447
|
// src/agents/compiler.ts
|
|
375
|
-
import { existsSync as existsSync3, mkdirSync, writeFileSync } from "fs";
|
|
376
|
-
import { join as join3, dirname as dirname2 } from "path";
|
|
448
|
+
import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
|
|
449
|
+
import { join as join3, dirname as dirname2, extname as extname2 } from "path";
|
|
450
|
+
import { parse as parseYaml3, stringify as stringifyYaml } from "yaml";
|
|
377
451
|
function buildAgentTools(agent, mcpServers) {
|
|
378
452
|
const tools = agent.tools ? [...agent.tools] : [...DEFAULT_AGENT_TOOLS];
|
|
379
453
|
if (mcpServers && mcpServers.length > 0) {
|
|
380
454
|
for (const server of mcpServers) {
|
|
381
|
-
|
|
455
|
+
const mcpTool = `mcp__${server}`;
|
|
456
|
+
if (!tools.includes(mcpTool)) {
|
|
457
|
+
tools.push(mcpTool);
|
|
458
|
+
}
|
|
382
459
|
}
|
|
383
460
|
}
|
|
384
461
|
return tools.join(", ");
|
|
385
462
|
}
|
|
463
|
+
function processAgentTemplate(templatePath, agent, config, mcpServers) {
|
|
464
|
+
const template = readFileSync3(templatePath, "utf-8");
|
|
465
|
+
const context = { agent };
|
|
466
|
+
if (config) {
|
|
467
|
+
context.config = config;
|
|
468
|
+
}
|
|
469
|
+
const resolved = resolveString(template, context);
|
|
470
|
+
const frontmatterMatch = resolved.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
|
|
471
|
+
if (!frontmatterMatch) {
|
|
472
|
+
throw new Error(`Invalid markdown format in ${templatePath}: no frontmatter found`);
|
|
473
|
+
}
|
|
474
|
+
const frontmatterYaml = frontmatterMatch[1];
|
|
475
|
+
const body = frontmatterMatch[2] ?? "";
|
|
476
|
+
const frontmatter = parseYaml3(frontmatterYaml);
|
|
477
|
+
const tools = buildAgentTools(agent, mcpServers);
|
|
478
|
+
frontmatter.tools = tools;
|
|
479
|
+
if (typeof frontmatter.description === "string") {
|
|
480
|
+
frontmatter.description = frontmatter.description.replace(/\n/g, " ").trim();
|
|
481
|
+
}
|
|
482
|
+
const updatedFrontmatter = stringifyYaml(frontmatter, { lineWidth: 0 }).trim();
|
|
483
|
+
return `---
|
|
484
|
+
${updatedFrontmatter}
|
|
485
|
+
---
|
|
486
|
+
${body}`;
|
|
487
|
+
}
|
|
386
488
|
function generateAgentMarkdown(agent, mcpServers) {
|
|
387
489
|
const lines = [];
|
|
388
490
|
const tools = buildAgentTools(agent, mcpServers);
|
|
@@ -404,8 +506,8 @@ function generateAgentMarkdown(agent, mcpServers) {
|
|
|
404
506
|
if (agent.responsibilities && agent.responsibilities.length > 0) {
|
|
405
507
|
lines.push("## Responsibilities");
|
|
406
508
|
lines.push("");
|
|
407
|
-
for (const
|
|
408
|
-
lines.push(`- ${
|
|
509
|
+
for (const r of agent.responsibilities) {
|
|
510
|
+
lines.push(`- ${r}`);
|
|
409
511
|
}
|
|
410
512
|
lines.push("");
|
|
411
513
|
}
|
|
@@ -423,12 +525,12 @@ function generateAgentMarkdown(agent, mcpServers) {
|
|
|
423
525
|
if (agent.expertise.tech_stack) {
|
|
424
526
|
lines.push("### Tech Stack");
|
|
425
527
|
lines.push("");
|
|
426
|
-
const
|
|
427
|
-
if (typeof
|
|
428
|
-
lines.push(
|
|
429
|
-
} else if (typeof
|
|
528
|
+
const ts = agent.expertise.tech_stack;
|
|
529
|
+
if (typeof ts === "string") {
|
|
530
|
+
lines.push(ts);
|
|
531
|
+
} else if (typeof ts === "object") {
|
|
430
532
|
lines.push("```json");
|
|
431
|
-
lines.push(JSON.stringify(
|
|
533
|
+
lines.push(JSON.stringify(ts, null, 2));
|
|
432
534
|
lines.push("```");
|
|
433
535
|
}
|
|
434
536
|
lines.push("");
|
|
@@ -447,7 +549,7 @@ function generateAgentMarkdown(agent, mcpServers) {
|
|
|
447
549
|
lines.push("");
|
|
448
550
|
for (const [category, items] of Object.entries(agent.principles)) {
|
|
449
551
|
if (items && Array.isArray(items) && items.length > 0) {
|
|
450
|
-
const title =
|
|
552
|
+
const title = category.replace(/[_-]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
451
553
|
lines.push(`### ${title}`);
|
|
452
554
|
lines.push("");
|
|
453
555
|
for (const item of items) {
|
|
@@ -478,47 +580,161 @@ function generateAgentMarkdown(agent, mcpServers) {
|
|
|
478
580
|
lines.push("");
|
|
479
581
|
}
|
|
480
582
|
}
|
|
481
|
-
if (agent.
|
|
583
|
+
if (agent.knowledge_library) {
|
|
584
|
+
generateKnowledgeLibrarySection(agent, lines);
|
|
585
|
+
}
|
|
586
|
+
if (agent.communication) {
|
|
587
|
+
generateCommunicationSection(agent, lines);
|
|
588
|
+
}
|
|
589
|
+
if (agent.protocols?.startup) {
|
|
590
|
+
generateStartupProtocolSection(agent, lines);
|
|
591
|
+
}
|
|
592
|
+
if (agent.protocols?.completion) {
|
|
593
|
+
generateCompletionProtocolSection(agent, lines);
|
|
594
|
+
}
|
|
595
|
+
if (agent.context_sources && !agent.knowledge_library) {
|
|
482
596
|
lines.push("## Context Sources");
|
|
483
597
|
lines.push("");
|
|
484
|
-
if (agent.context_sources.shared
|
|
598
|
+
if (agent.context_sources.shared?.length) {
|
|
485
599
|
lines.push("### Shared");
|
|
486
600
|
lines.push("");
|
|
487
|
-
for (const
|
|
488
|
-
lines.push(`- ${source}`);
|
|
489
|
-
}
|
|
601
|
+
for (const s of agent.context_sources.shared) lines.push(`- ${s}`);
|
|
490
602
|
lines.push("");
|
|
491
603
|
}
|
|
492
|
-
if (agent.context_sources.personal
|
|
604
|
+
if (agent.context_sources.personal?.length) {
|
|
493
605
|
lines.push("### Personal");
|
|
494
606
|
lines.push("");
|
|
495
|
-
for (const
|
|
496
|
-
lines.push(`- ${source}`);
|
|
497
|
-
}
|
|
607
|
+
for (const p of agent.context_sources.personal) lines.push(`- ${p}`);
|
|
498
608
|
lines.push("");
|
|
499
609
|
}
|
|
500
610
|
}
|
|
501
|
-
|
|
502
|
-
|
|
611
|
+
lines.push("---");
|
|
612
|
+
lines.push("");
|
|
613
|
+
lines.push("*Generated by CoreAI*");
|
|
614
|
+
lines.push("");
|
|
615
|
+
return lines.join("\n");
|
|
616
|
+
}
|
|
617
|
+
function generateKnowledgeLibrarySection(agent, lines) {
|
|
618
|
+
const kl = agent.knowledge_library;
|
|
619
|
+
if (!kl) return;
|
|
620
|
+
lines.push("## Knowledge Library Structure");
|
|
621
|
+
lines.push("");
|
|
622
|
+
if (kl.shared) {
|
|
623
|
+
lines.push("### Shared Context (Root - All Agents)");
|
|
624
|
+
lines.push("```");
|
|
625
|
+
lines.push("/KnowledgeLibrary/");
|
|
626
|
+
if (kl.shared.context) lines.push(`\u251C\u2500\u2500 ${kl.shared.context.split("/").pop()}`);
|
|
627
|
+
if (kl.shared.architecture) lines.push(`\u251C\u2500\u2500 ${kl.shared.architecture.split("/").pop()}`);
|
|
628
|
+
if (kl.shared.prd) lines.push(`\u2514\u2500\u2500 ${kl.shared.prd.split("/").pop()}`);
|
|
629
|
+
lines.push("```");
|
|
630
|
+
if (kl.shared.remote?.length) {
|
|
631
|
+
lines.push("");
|
|
632
|
+
lines.push("**Remote Documentation:**");
|
|
633
|
+
for (const r of kl.shared.remote) lines.push(`- ${r}`);
|
|
634
|
+
}
|
|
503
635
|
lines.push("");
|
|
504
|
-
|
|
505
|
-
|
|
636
|
+
}
|
|
637
|
+
if (kl.personal) {
|
|
638
|
+
lines.push(`### Personal Context (${agent.role})`);
|
|
639
|
+
lines.push("```");
|
|
640
|
+
lines.push(`/KnowledgeLibrary/${agent.role}/`);
|
|
641
|
+
if (kl.personal.context) {
|
|
642
|
+
lines.push("\u251C\u2500\u2500 context/");
|
|
643
|
+
lines.push("\u2502 \u2514\u2500\u2500 current.txt");
|
|
506
644
|
}
|
|
507
|
-
if (
|
|
508
|
-
lines.push(
|
|
645
|
+
if (kl.personal.history) {
|
|
646
|
+
lines.push("\u251C\u2500\u2500 history/");
|
|
509
647
|
}
|
|
648
|
+
if (kl.personal.inbox) {
|
|
649
|
+
lines.push("\u251C\u2500\u2500 inbox/");
|
|
650
|
+
}
|
|
651
|
+
if (kl.personal.outbox) {
|
|
652
|
+
lines.push("\u251C\u2500\u2500 outbox/");
|
|
653
|
+
}
|
|
654
|
+
if (kl.personal.tech) {
|
|
655
|
+
lines.push("\u251C\u2500\u2500 tech/");
|
|
656
|
+
}
|
|
657
|
+
if (kl.personal.control) {
|
|
658
|
+
lines.push("\u2514\u2500\u2500 control/");
|
|
659
|
+
if (kl.personal.control.objectives) lines.push(" \u251C\u2500\u2500 objectives.txt");
|
|
660
|
+
if (kl.personal.control.decisions) lines.push(" \u251C\u2500\u2500 decisions.txt");
|
|
661
|
+
if (kl.personal.control.dependencies) lines.push(" \u251C\u2500\u2500 dependencies.txt");
|
|
662
|
+
if (kl.personal.control.index) lines.push(" \u2514\u2500\u2500 index.txt");
|
|
663
|
+
}
|
|
664
|
+
lines.push("```");
|
|
510
665
|
lines.push("");
|
|
511
666
|
}
|
|
512
667
|
lines.push("---");
|
|
513
668
|
lines.push("");
|
|
514
|
-
|
|
669
|
+
}
|
|
670
|
+
function generateCommunicationSection(agent, lines) {
|
|
671
|
+
const comm = agent.communication;
|
|
672
|
+
if (!comm) return;
|
|
673
|
+
lines.push("## Communication");
|
|
515
674
|
lines.push("");
|
|
516
|
-
|
|
675
|
+
if (comm.inbox) lines.push(`**Inbox:** \`${comm.inbox}\``);
|
|
676
|
+
if (comm.outbox) lines.push(`**Outbox:** \`${comm.outbox}\``);
|
|
677
|
+
lines.push("");
|
|
678
|
+
if (comm.message_format || comm.outbox_format || comm.processed_dir) {
|
|
679
|
+
lines.push("### Message Conventions");
|
|
680
|
+
lines.push("");
|
|
681
|
+
if (comm.message_format) lines.push(`- **Inbox message naming:** \`${comm.message_format}\``);
|
|
682
|
+
if (comm.outbox_format) lines.push(`- **Outbox message naming:** \`${comm.outbox_format}\``);
|
|
683
|
+
if (comm.processed_dir) lines.push(`- **Processed messages:** Move handled inbox messages to \`${comm.processed_dir}\``);
|
|
684
|
+
lines.push("");
|
|
685
|
+
}
|
|
517
686
|
}
|
|
518
|
-
function
|
|
519
|
-
|
|
687
|
+
function generateStartupProtocolSection(agent, lines) {
|
|
688
|
+
const p = agent.protocols;
|
|
689
|
+
if (!p?.startup) return;
|
|
690
|
+
lines.push("## When Invoked");
|
|
691
|
+
lines.push("");
|
|
692
|
+
lines.push("> **MANDATORY STARTUP PROTOCOL** - Execute before proceeding with any task.");
|
|
693
|
+
lines.push("");
|
|
694
|
+
lines.push("### Session Context Check");
|
|
695
|
+
lines.push("");
|
|
696
|
+
if (p.startup.first_session?.length) {
|
|
697
|
+
lines.push("**If this is your FIRST invocation in this session:**");
|
|
698
|
+
lines.push("");
|
|
699
|
+
for (const s of p.startup.first_session) lines.push(`- [ ] ${s}`);
|
|
700
|
+
lines.push("");
|
|
701
|
+
lines.push('Acknowledge: "Startup protocol complete. Full context loaded."');
|
|
702
|
+
lines.push("");
|
|
703
|
+
}
|
|
704
|
+
if (p.startup.subsequent?.length) {
|
|
705
|
+
lines.push("**If you have ALREADY loaded context in this session:**");
|
|
706
|
+
lines.push("");
|
|
707
|
+
for (const s of p.startup.subsequent) lines.push(`- [ ] ${s}`);
|
|
708
|
+
lines.push("");
|
|
709
|
+
lines.push('Acknowledge: "Context already loaded. Checked inbox for new messages."');
|
|
710
|
+
lines.push("");
|
|
711
|
+
}
|
|
712
|
+
lines.push("Then proceed with the task.");
|
|
713
|
+
lines.push("");
|
|
714
|
+
lines.push("---");
|
|
715
|
+
lines.push("");
|
|
520
716
|
}
|
|
521
|
-
function
|
|
717
|
+
function generateCompletionProtocolSection(agent, lines) {
|
|
718
|
+
const p = agent.protocols;
|
|
719
|
+
if (!p?.completion?.length) return;
|
|
720
|
+
lines.push("## Before Finishing");
|
|
721
|
+
lines.push("");
|
|
722
|
+
lines.push("> **MANDATORY COMPLETION PROTOCOL** - Execute ALL steps before ending any task.");
|
|
723
|
+
lines.push("");
|
|
724
|
+
for (let i = 0; i < p.completion.length; i++) {
|
|
725
|
+
lines.push(`### ${i + 1}. ${p.completion[i]}`);
|
|
726
|
+
lines.push("");
|
|
727
|
+
}
|
|
728
|
+
lines.push('Acknowledge: "Completion protocol finished. Context updated."');
|
|
729
|
+
lines.push("");
|
|
730
|
+
lines.push("---");
|
|
731
|
+
lines.push("");
|
|
732
|
+
}
|
|
733
|
+
function compileAgent(agent, filePath, config, mcpServers) {
|
|
734
|
+
const ext = extname2(filePath).toLowerCase();
|
|
735
|
+
if (ext === ".md") {
|
|
736
|
+
return processAgentTemplate(filePath, agent, config, mcpServers);
|
|
737
|
+
}
|
|
522
738
|
const resolved = resolveAgentDefinition(agent, config);
|
|
523
739
|
return generateAgentMarkdown(resolved, mcpServers);
|
|
524
740
|
}
|
|
@@ -578,7 +794,12 @@ function compileAgents(config, options = {}) {
|
|
|
578
794
|
continue;
|
|
579
795
|
}
|
|
580
796
|
try {
|
|
581
|
-
const markdown = compileAgent(
|
|
797
|
+
const markdown = compileAgent(
|
|
798
|
+
metadata.definition,
|
|
799
|
+
metadata.filePath,
|
|
800
|
+
config,
|
|
801
|
+
options.mcpServers
|
|
802
|
+
);
|
|
582
803
|
const outputPath = join3(outputDir, `${role}.md`);
|
|
583
804
|
writeFileSync(outputPath, markdown, "utf-8");
|
|
584
805
|
result.compiled.push({
|
|
@@ -2445,7 +2666,7 @@ var StepTracker = class {
|
|
|
2445
2666
|
};
|
|
2446
2667
|
|
|
2447
2668
|
// src/skills/generator.ts
|
|
2448
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync2, writeFileSync as writeFileSync2, readFileSync as
|
|
2669
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, writeFileSync as writeFileSync2, readFileSync as readFileSync4, readdirSync as readdirSync2, statSync } from "fs";
|
|
2449
2670
|
import { join as join6, basename as basename3 } from "path";
|
|
2450
2671
|
|
|
2451
2672
|
// src/skills/templates.ts
|
|
@@ -3030,7 +3251,7 @@ function loadCustomTemplates(templatesDir) {
|
|
|
3030
3251
|
const stat = statSync(filePath);
|
|
3031
3252
|
if (!stat.isFile()) continue;
|
|
3032
3253
|
try {
|
|
3033
|
-
const content =
|
|
3254
|
+
const content = readFileSync4(filePath, "utf-8");
|
|
3034
3255
|
const template = parseSkillTemplate(file, content);
|
|
3035
3256
|
templates.push(template);
|
|
3036
3257
|
} catch {
|
|
@@ -3243,7 +3464,7 @@ import {
|
|
|
3243
3464
|
existsSync as existsSync5,
|
|
3244
3465
|
mkdirSync as mkdirSync3,
|
|
3245
3466
|
writeFileSync as writeFileSync3,
|
|
3246
|
-
readFileSync as
|
|
3467
|
+
readFileSync as readFileSync5,
|
|
3247
3468
|
readdirSync as readdirSync3,
|
|
3248
3469
|
renameSync,
|
|
3249
3470
|
statSync as statSync2
|
|
@@ -3498,7 +3719,7 @@ function getAgentKnowledgeState(agentName, options = {}) {
|
|
|
3498
3719
|
let context;
|
|
3499
3720
|
const currentContextPath = join7(dirs.context, "current.txt");
|
|
3500
3721
|
if (existsSync5(currentContextPath)) {
|
|
3501
|
-
const content =
|
|
3722
|
+
const content = readFileSync5(currentContextPath, "utf-8");
|
|
3502
3723
|
context = parseContextFile(content);
|
|
3503
3724
|
}
|
|
3504
3725
|
const state = {
|
|
@@ -3598,7 +3819,7 @@ function readInboxMessages(agentName, options = {}) {
|
|
|
3598
3819
|
);
|
|
3599
3820
|
for (const file of files) {
|
|
3600
3821
|
const filePath = join7(dirs.inbox, file);
|
|
3601
|
-
const rawContent =
|
|
3822
|
+
const rawContent = readFileSync5(filePath, "utf-8");
|
|
3602
3823
|
const { metadata, body } = parseMessageFrontmatter(rawContent);
|
|
3603
3824
|
if (options.type && metadata.type !== options.type) continue;
|
|
3604
3825
|
if (options.from && metadata.from !== options.from) continue;
|
|
@@ -3618,7 +3839,7 @@ function readInboxMessages(agentName, options = {}) {
|
|
|
3618
3839
|
);
|
|
3619
3840
|
for (const file of files) {
|
|
3620
3841
|
const filePath = join7(dirs.inboxProcessed, file);
|
|
3621
|
-
const rawContent =
|
|
3842
|
+
const rawContent = readFileSync5(filePath, "utf-8");
|
|
3622
3843
|
const { metadata, body } = parseMessageFrontmatter(rawContent);
|
|
3623
3844
|
if (options.type && metadata.type !== options.type) continue;
|
|
3624
3845
|
if (options.from && metadata.from !== options.from) continue;
|
|
@@ -3823,7 +4044,7 @@ function findPackageJson() {
|
|
|
3823
4044
|
while (dir !== dirname5(dir)) {
|
|
3824
4045
|
const pkgPath = join8(dir, "package.json");
|
|
3825
4046
|
try {
|
|
3826
|
-
const content =
|
|
4047
|
+
const content = readFileSync6(pkgPath, "utf-8");
|
|
3827
4048
|
const pkg = JSON.parse(content);
|
|
3828
4049
|
if (pkg.name === "@deimoscloud/coreai") {
|
|
3829
4050
|
return content;
|