@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/cli/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { fileURLToPath as fileURLToPath2 } from "url";
|
|
|
6
6
|
import { Command } from "commander";
|
|
7
7
|
|
|
8
8
|
// src/index.ts
|
|
9
|
-
import { readFileSync as
|
|
9
|
+
import { readFileSync as readFileSync7 } from "fs";
|
|
10
10
|
import { dirname as dirname5, join as join8 } from "path";
|
|
11
11
|
import { fileURLToPath } from "url";
|
|
12
12
|
|
|
@@ -153,6 +153,61 @@ var AgentError = class extends Error {
|
|
|
153
153
|
this.name = "AgentError";
|
|
154
154
|
}
|
|
155
155
|
};
|
|
156
|
+
function extractFrontmatter(content) {
|
|
157
|
+
const match = content.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
|
|
158
|
+
if (!match) {
|
|
159
|
+
throw new AgentError(
|
|
160
|
+
"No YAML frontmatter found. Agent MD files must start with YAML frontmatter (---)",
|
|
161
|
+
"PARSE_ERROR"
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
const frontmatterYaml = match[1];
|
|
165
|
+
const body = match[2] ?? "";
|
|
166
|
+
let frontmatter;
|
|
167
|
+
try {
|
|
168
|
+
frontmatter = parseYaml2(frontmatterYaml);
|
|
169
|
+
} catch (error) {
|
|
170
|
+
const message = error instanceof Error ? error.message : "Unknown parse error";
|
|
171
|
+
throw new AgentError(`Failed to parse YAML frontmatter: ${message}`, "PARSE_ERROR", error);
|
|
172
|
+
}
|
|
173
|
+
if (!frontmatter || typeof frontmatter !== "object") {
|
|
174
|
+
throw new AgentError("Invalid frontmatter: expected an object", "PARSE_ERROR");
|
|
175
|
+
}
|
|
176
|
+
return { frontmatter, body };
|
|
177
|
+
}
|
|
178
|
+
function loadAgentFromMdFile(filePath) {
|
|
179
|
+
if (!existsSync2(filePath)) {
|
|
180
|
+
throw new AgentError(`Agent file not found: ${filePath}`, "NOT_FOUND");
|
|
181
|
+
}
|
|
182
|
+
let content;
|
|
183
|
+
try {
|
|
184
|
+
content = readFileSync2(filePath, "utf-8");
|
|
185
|
+
} catch (error) {
|
|
186
|
+
const message = error instanceof Error ? error.message : "Unknown read error";
|
|
187
|
+
throw new AgentError(`Failed to read agent file ${filePath}: ${message}`, "READ_ERROR", error);
|
|
188
|
+
}
|
|
189
|
+
const { frontmatter } = extractFrontmatter(content);
|
|
190
|
+
const role = frontmatter.name || getRoleFromFilename(filePath);
|
|
191
|
+
if (!role) {
|
|
192
|
+
throw new AgentError(
|
|
193
|
+
`Agent MD file must have a 'name' field in frontmatter or a valid filename: ${filePath}`,
|
|
194
|
+
"VALIDATION_ERROR"
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
const description = frontmatter.description || "";
|
|
198
|
+
const tools = typeof frontmatter.tools === "string" ? frontmatter.tools.split(",").map((t) => t.trim()).filter(Boolean) : void 0;
|
|
199
|
+
const definition = {
|
|
200
|
+
role,
|
|
201
|
+
type: "ic-engineer",
|
|
202
|
+
// Default, actual identity is in the MD content
|
|
203
|
+
display_name: role.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" "),
|
|
204
|
+
description
|
|
205
|
+
};
|
|
206
|
+
if (tools) {
|
|
207
|
+
definition.tools = tools;
|
|
208
|
+
}
|
|
209
|
+
return definition;
|
|
210
|
+
}
|
|
156
211
|
function parseAgentYaml(content, filePath) {
|
|
157
212
|
try {
|
|
158
213
|
return parseYaml2(content);
|
|
@@ -184,7 +239,7 @@ function validateAgentDefinition(agent) {
|
|
|
184
239
|
}
|
|
185
240
|
return agent;
|
|
186
241
|
}
|
|
187
|
-
function
|
|
242
|
+
function loadAgentFromYamlFile(filePath) {
|
|
188
243
|
if (!existsSync2(filePath)) {
|
|
189
244
|
throw new AgentError(`Agent file not found: ${filePath}`, "NOT_FOUND");
|
|
190
245
|
}
|
|
@@ -198,18 +253,36 @@ function loadAgentFromFile(filePath) {
|
|
|
198
253
|
const parsed = parseAgentYaml(content, filePath);
|
|
199
254
|
return validateAgentDefinition(parsed);
|
|
200
255
|
}
|
|
201
|
-
function
|
|
256
|
+
function loadAgentFromFile(filePath) {
|
|
257
|
+
const ext = extname(filePath).toLowerCase();
|
|
258
|
+
if (ext === ".md") {
|
|
259
|
+
return loadAgentFromMdFile(filePath);
|
|
260
|
+
}
|
|
261
|
+
if (ext === ".yaml" || ext === ".yml") {
|
|
262
|
+
console.warn(
|
|
263
|
+
`Warning: YAML agent definitions are deprecated and will be removed in a future version.
|
|
264
|
+
Please migrate ${basename(filePath)} to Markdown format.`
|
|
265
|
+
);
|
|
266
|
+
return loadAgentFromYamlFile(filePath);
|
|
267
|
+
}
|
|
268
|
+
throw new AgentError(
|
|
269
|
+
`Unsupported agent file format: ${ext}. Use .md (recommended) or .yaml/.yml (deprecated)`,
|
|
270
|
+
"PARSE_ERROR"
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
function listAgentFiles(dir) {
|
|
202
274
|
if (!existsSync2(dir)) {
|
|
203
275
|
return [];
|
|
204
276
|
}
|
|
205
277
|
return readdirSync(dir).filter((file) => {
|
|
278
|
+
if (file.startsWith("_")) return false;
|
|
206
279
|
const ext = extname(file).toLowerCase();
|
|
207
|
-
return ext === ".yaml" || ext === ".yml";
|
|
280
|
+
return ext === ".md" || ext === ".yaml" || ext === ".yml";
|
|
208
281
|
}).map((file) => join2(dir, file));
|
|
209
282
|
}
|
|
210
283
|
function loadAgentsFromDirectory(dir, source) {
|
|
211
284
|
const agents2 = /* @__PURE__ */ new Map();
|
|
212
|
-
const files =
|
|
285
|
+
const files = listAgentFiles(dir);
|
|
213
286
|
for (const filePath of files) {
|
|
214
287
|
try {
|
|
215
288
|
const definition = loadAgentFromFile(filePath);
|
|
@@ -225,6 +298,11 @@ function loadAgentsFromDirectory(dir, source) {
|
|
|
225
298
|
}
|
|
226
299
|
return agents2;
|
|
227
300
|
}
|
|
301
|
+
function getRoleFromFilename(filePath) {
|
|
302
|
+
const fileName = basename(filePath);
|
|
303
|
+
const ext = extname(fileName);
|
|
304
|
+
return fileName.slice(0, -ext.length);
|
|
305
|
+
}
|
|
228
306
|
|
|
229
307
|
// src/agents/resolver.ts
|
|
230
308
|
var ResolutionError = class extends Error {
|
|
@@ -363,17 +441,46 @@ function resolveAgentDefinition(agent, config, options = {}) {
|
|
|
363
441
|
}
|
|
364
442
|
|
|
365
443
|
// src/agents/compiler.ts
|
|
366
|
-
import { existsSync as existsSync3, mkdirSync, writeFileSync } from "fs";
|
|
367
|
-
import { join as join3, dirname as dirname2 } from "path";
|
|
444
|
+
import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
|
|
445
|
+
import { join as join3, dirname as dirname2, extname as extname2 } from "path";
|
|
446
|
+
import { parse as parseYaml3, stringify as stringifyYaml } from "yaml";
|
|
368
447
|
function buildAgentTools(agent, mcpServers) {
|
|
369
448
|
const tools = agent.tools ? [...agent.tools] : [...DEFAULT_AGENT_TOOLS];
|
|
370
449
|
if (mcpServers && mcpServers.length > 0) {
|
|
371
450
|
for (const server of mcpServers) {
|
|
372
|
-
|
|
451
|
+
const mcpTool = `mcp__${server}`;
|
|
452
|
+
if (!tools.includes(mcpTool)) {
|
|
453
|
+
tools.push(mcpTool);
|
|
454
|
+
}
|
|
373
455
|
}
|
|
374
456
|
}
|
|
375
457
|
return tools.join(", ");
|
|
376
458
|
}
|
|
459
|
+
function processAgentTemplate(templatePath, agent, config, mcpServers) {
|
|
460
|
+
const template = readFileSync3(templatePath, "utf-8");
|
|
461
|
+
const context = { agent };
|
|
462
|
+
if (config) {
|
|
463
|
+
context.config = config;
|
|
464
|
+
}
|
|
465
|
+
const resolved = resolveString(template, context);
|
|
466
|
+
const frontmatterMatch = resolved.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
|
|
467
|
+
if (!frontmatterMatch) {
|
|
468
|
+
throw new Error(`Invalid markdown format in ${templatePath}: no frontmatter found`);
|
|
469
|
+
}
|
|
470
|
+
const frontmatterYaml = frontmatterMatch[1];
|
|
471
|
+
const body = frontmatterMatch[2] ?? "";
|
|
472
|
+
const frontmatter = parseYaml3(frontmatterYaml);
|
|
473
|
+
const tools = buildAgentTools(agent, mcpServers);
|
|
474
|
+
frontmatter.tools = tools;
|
|
475
|
+
if (typeof frontmatter.description === "string") {
|
|
476
|
+
frontmatter.description = frontmatter.description.replace(/\n/g, " ").trim();
|
|
477
|
+
}
|
|
478
|
+
const updatedFrontmatter = stringifyYaml(frontmatter, { lineWidth: 0 }).trim();
|
|
479
|
+
return `---
|
|
480
|
+
${updatedFrontmatter}
|
|
481
|
+
---
|
|
482
|
+
${body}`;
|
|
483
|
+
}
|
|
377
484
|
function generateAgentMarkdown(agent, mcpServers) {
|
|
378
485
|
const lines = [];
|
|
379
486
|
const tools = buildAgentTools(agent, mcpServers);
|
|
@@ -395,8 +502,8 @@ function generateAgentMarkdown(agent, mcpServers) {
|
|
|
395
502
|
if (agent.responsibilities && agent.responsibilities.length > 0) {
|
|
396
503
|
lines.push("## Responsibilities");
|
|
397
504
|
lines.push("");
|
|
398
|
-
for (const
|
|
399
|
-
lines.push(`- ${
|
|
505
|
+
for (const r of agent.responsibilities) {
|
|
506
|
+
lines.push(`- ${r}`);
|
|
400
507
|
}
|
|
401
508
|
lines.push("");
|
|
402
509
|
}
|
|
@@ -414,12 +521,12 @@ function generateAgentMarkdown(agent, mcpServers) {
|
|
|
414
521
|
if (agent.expertise.tech_stack) {
|
|
415
522
|
lines.push("### Tech Stack");
|
|
416
523
|
lines.push("");
|
|
417
|
-
const
|
|
418
|
-
if (typeof
|
|
419
|
-
lines.push(
|
|
420
|
-
} else if (typeof
|
|
524
|
+
const ts = agent.expertise.tech_stack;
|
|
525
|
+
if (typeof ts === "string") {
|
|
526
|
+
lines.push(ts);
|
|
527
|
+
} else if (typeof ts === "object") {
|
|
421
528
|
lines.push("```json");
|
|
422
|
-
lines.push(JSON.stringify(
|
|
529
|
+
lines.push(JSON.stringify(ts, null, 2));
|
|
423
530
|
lines.push("```");
|
|
424
531
|
}
|
|
425
532
|
lines.push("");
|
|
@@ -438,7 +545,7 @@ function generateAgentMarkdown(agent, mcpServers) {
|
|
|
438
545
|
lines.push("");
|
|
439
546
|
for (const [category, items] of Object.entries(agent.principles)) {
|
|
440
547
|
if (items && Array.isArray(items) && items.length > 0) {
|
|
441
|
-
const title =
|
|
548
|
+
const title = category.replace(/[_-]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
442
549
|
lines.push(`### ${title}`);
|
|
443
550
|
lines.push("");
|
|
444
551
|
for (const item of items) {
|
|
@@ -469,47 +576,161 @@ function generateAgentMarkdown(agent, mcpServers) {
|
|
|
469
576
|
lines.push("");
|
|
470
577
|
}
|
|
471
578
|
}
|
|
472
|
-
if (agent.
|
|
579
|
+
if (agent.knowledge_library) {
|
|
580
|
+
generateKnowledgeLibrarySection(agent, lines);
|
|
581
|
+
}
|
|
582
|
+
if (agent.communication) {
|
|
583
|
+
generateCommunicationSection(agent, lines);
|
|
584
|
+
}
|
|
585
|
+
if (agent.protocols?.startup) {
|
|
586
|
+
generateStartupProtocolSection(agent, lines);
|
|
587
|
+
}
|
|
588
|
+
if (agent.protocols?.completion) {
|
|
589
|
+
generateCompletionProtocolSection(agent, lines);
|
|
590
|
+
}
|
|
591
|
+
if (agent.context_sources && !agent.knowledge_library) {
|
|
473
592
|
lines.push("## Context Sources");
|
|
474
593
|
lines.push("");
|
|
475
|
-
if (agent.context_sources.shared
|
|
594
|
+
if (agent.context_sources.shared?.length) {
|
|
476
595
|
lines.push("### Shared");
|
|
477
596
|
lines.push("");
|
|
478
|
-
for (const
|
|
479
|
-
lines.push(`- ${source}`);
|
|
480
|
-
}
|
|
597
|
+
for (const s of agent.context_sources.shared) lines.push(`- ${s}`);
|
|
481
598
|
lines.push("");
|
|
482
599
|
}
|
|
483
|
-
if (agent.context_sources.personal
|
|
600
|
+
if (agent.context_sources.personal?.length) {
|
|
484
601
|
lines.push("### Personal");
|
|
485
602
|
lines.push("");
|
|
486
|
-
for (const
|
|
487
|
-
lines.push(`- ${source}`);
|
|
488
|
-
}
|
|
603
|
+
for (const p of agent.context_sources.personal) lines.push(`- ${p}`);
|
|
489
604
|
lines.push("");
|
|
490
605
|
}
|
|
491
606
|
}
|
|
492
|
-
|
|
493
|
-
|
|
607
|
+
lines.push("---");
|
|
608
|
+
lines.push("");
|
|
609
|
+
lines.push("*Generated by CoreAI*");
|
|
610
|
+
lines.push("");
|
|
611
|
+
return lines.join("\n");
|
|
612
|
+
}
|
|
613
|
+
function generateKnowledgeLibrarySection(agent, lines) {
|
|
614
|
+
const kl = agent.knowledge_library;
|
|
615
|
+
if (!kl) return;
|
|
616
|
+
lines.push("## Knowledge Library Structure");
|
|
617
|
+
lines.push("");
|
|
618
|
+
if (kl.shared) {
|
|
619
|
+
lines.push("### Shared Context (Root - All Agents)");
|
|
620
|
+
lines.push("```");
|
|
621
|
+
lines.push("/KnowledgeLibrary/");
|
|
622
|
+
if (kl.shared.context) lines.push(`\u251C\u2500\u2500 ${kl.shared.context.split("/").pop()}`);
|
|
623
|
+
if (kl.shared.architecture) lines.push(`\u251C\u2500\u2500 ${kl.shared.architecture.split("/").pop()}`);
|
|
624
|
+
if (kl.shared.prd) lines.push(`\u2514\u2500\u2500 ${kl.shared.prd.split("/").pop()}`);
|
|
625
|
+
lines.push("```");
|
|
626
|
+
if (kl.shared.remote?.length) {
|
|
627
|
+
lines.push("");
|
|
628
|
+
lines.push("**Remote Documentation:**");
|
|
629
|
+
for (const r of kl.shared.remote) lines.push(`- ${r}`);
|
|
630
|
+
}
|
|
494
631
|
lines.push("");
|
|
495
|
-
|
|
496
|
-
|
|
632
|
+
}
|
|
633
|
+
if (kl.personal) {
|
|
634
|
+
lines.push(`### Personal Context (${agent.role})`);
|
|
635
|
+
lines.push("```");
|
|
636
|
+
lines.push(`/KnowledgeLibrary/${agent.role}/`);
|
|
637
|
+
if (kl.personal.context) {
|
|
638
|
+
lines.push("\u251C\u2500\u2500 context/");
|
|
639
|
+
lines.push("\u2502 \u2514\u2500\u2500 current.txt");
|
|
640
|
+
}
|
|
641
|
+
if (kl.personal.history) {
|
|
642
|
+
lines.push("\u251C\u2500\u2500 history/");
|
|
497
643
|
}
|
|
498
|
-
if (
|
|
499
|
-
lines.push(
|
|
644
|
+
if (kl.personal.inbox) {
|
|
645
|
+
lines.push("\u251C\u2500\u2500 inbox/");
|
|
500
646
|
}
|
|
647
|
+
if (kl.personal.outbox) {
|
|
648
|
+
lines.push("\u251C\u2500\u2500 outbox/");
|
|
649
|
+
}
|
|
650
|
+
if (kl.personal.tech) {
|
|
651
|
+
lines.push("\u251C\u2500\u2500 tech/");
|
|
652
|
+
}
|
|
653
|
+
if (kl.personal.control) {
|
|
654
|
+
lines.push("\u2514\u2500\u2500 control/");
|
|
655
|
+
if (kl.personal.control.objectives) lines.push(" \u251C\u2500\u2500 objectives.txt");
|
|
656
|
+
if (kl.personal.control.decisions) lines.push(" \u251C\u2500\u2500 decisions.txt");
|
|
657
|
+
if (kl.personal.control.dependencies) lines.push(" \u251C\u2500\u2500 dependencies.txt");
|
|
658
|
+
if (kl.personal.control.index) lines.push(" \u2514\u2500\u2500 index.txt");
|
|
659
|
+
}
|
|
660
|
+
lines.push("```");
|
|
501
661
|
lines.push("");
|
|
502
662
|
}
|
|
503
663
|
lines.push("---");
|
|
504
664
|
lines.push("");
|
|
505
|
-
|
|
665
|
+
}
|
|
666
|
+
function generateCommunicationSection(agent, lines) {
|
|
667
|
+
const comm = agent.communication;
|
|
668
|
+
if (!comm) return;
|
|
669
|
+
lines.push("## Communication");
|
|
506
670
|
lines.push("");
|
|
507
|
-
|
|
671
|
+
if (comm.inbox) lines.push(`**Inbox:** \`${comm.inbox}\``);
|
|
672
|
+
if (comm.outbox) lines.push(`**Outbox:** \`${comm.outbox}\``);
|
|
673
|
+
lines.push("");
|
|
674
|
+
if (comm.message_format || comm.outbox_format || comm.processed_dir) {
|
|
675
|
+
lines.push("### Message Conventions");
|
|
676
|
+
lines.push("");
|
|
677
|
+
if (comm.message_format) lines.push(`- **Inbox message naming:** \`${comm.message_format}\``);
|
|
678
|
+
if (comm.outbox_format) lines.push(`- **Outbox message naming:** \`${comm.outbox_format}\``);
|
|
679
|
+
if (comm.processed_dir) lines.push(`- **Processed messages:** Move handled inbox messages to \`${comm.processed_dir}\``);
|
|
680
|
+
lines.push("");
|
|
681
|
+
}
|
|
508
682
|
}
|
|
509
|
-
function
|
|
510
|
-
|
|
683
|
+
function generateStartupProtocolSection(agent, lines) {
|
|
684
|
+
const p = agent.protocols;
|
|
685
|
+
if (!p?.startup) return;
|
|
686
|
+
lines.push("## When Invoked");
|
|
687
|
+
lines.push("");
|
|
688
|
+
lines.push("> **MANDATORY STARTUP PROTOCOL** - Execute before proceeding with any task.");
|
|
689
|
+
lines.push("");
|
|
690
|
+
lines.push("### Session Context Check");
|
|
691
|
+
lines.push("");
|
|
692
|
+
if (p.startup.first_session?.length) {
|
|
693
|
+
lines.push("**If this is your FIRST invocation in this session:**");
|
|
694
|
+
lines.push("");
|
|
695
|
+
for (const s of p.startup.first_session) lines.push(`- [ ] ${s}`);
|
|
696
|
+
lines.push("");
|
|
697
|
+
lines.push('Acknowledge: "Startup protocol complete. Full context loaded."');
|
|
698
|
+
lines.push("");
|
|
699
|
+
}
|
|
700
|
+
if (p.startup.subsequent?.length) {
|
|
701
|
+
lines.push("**If you have ALREADY loaded context in this session:**");
|
|
702
|
+
lines.push("");
|
|
703
|
+
for (const s of p.startup.subsequent) lines.push(`- [ ] ${s}`);
|
|
704
|
+
lines.push("");
|
|
705
|
+
lines.push('Acknowledge: "Context already loaded. Checked inbox for new messages."');
|
|
706
|
+
lines.push("");
|
|
707
|
+
}
|
|
708
|
+
lines.push("Then proceed with the task.");
|
|
709
|
+
lines.push("");
|
|
710
|
+
lines.push("---");
|
|
711
|
+
lines.push("");
|
|
511
712
|
}
|
|
512
|
-
function
|
|
713
|
+
function generateCompletionProtocolSection(agent, lines) {
|
|
714
|
+
const p = agent.protocols;
|
|
715
|
+
if (!p?.completion?.length) return;
|
|
716
|
+
lines.push("## Before Finishing");
|
|
717
|
+
lines.push("");
|
|
718
|
+
lines.push("> **MANDATORY COMPLETION PROTOCOL** - Execute ALL steps before ending any task.");
|
|
719
|
+
lines.push("");
|
|
720
|
+
for (let i = 0; i < p.completion.length; i++) {
|
|
721
|
+
lines.push(`### ${i + 1}. ${p.completion[i]}`);
|
|
722
|
+
lines.push("");
|
|
723
|
+
}
|
|
724
|
+
lines.push('Acknowledge: "Completion protocol finished. Context updated."');
|
|
725
|
+
lines.push("");
|
|
726
|
+
lines.push("---");
|
|
727
|
+
lines.push("");
|
|
728
|
+
}
|
|
729
|
+
function compileAgent(agent, filePath, config, mcpServers) {
|
|
730
|
+
const ext = extname2(filePath).toLowerCase();
|
|
731
|
+
if (ext === ".md") {
|
|
732
|
+
return processAgentTemplate(filePath, agent, config, mcpServers);
|
|
733
|
+
}
|
|
513
734
|
const resolved = resolveAgentDefinition(agent, config);
|
|
514
735
|
return generateAgentMarkdown(resolved, mcpServers);
|
|
515
736
|
}
|
|
@@ -569,7 +790,12 @@ function compileAgents(config, options = {}) {
|
|
|
569
790
|
continue;
|
|
570
791
|
}
|
|
571
792
|
try {
|
|
572
|
-
const markdown = compileAgent(
|
|
793
|
+
const markdown = compileAgent(
|
|
794
|
+
metadata.definition,
|
|
795
|
+
metadata.filePath,
|
|
796
|
+
config,
|
|
797
|
+
options.mcpServers
|
|
798
|
+
);
|
|
573
799
|
const outputPath = join3(outputDir, `${role}.md`);
|
|
574
800
|
writeFileSync(outputPath, markdown, "utf-8");
|
|
575
801
|
result.compiled.push({
|
|
@@ -613,7 +839,7 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
|
613
839
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
614
840
|
|
|
615
841
|
// src/adapters/mcp/discovery.ts
|
|
616
|
-
import { existsSync as existsSync4, readFileSync as
|
|
842
|
+
import { existsSync as existsSync4, readFileSync as readFileSync4 } from "fs";
|
|
617
843
|
import { join as join4, dirname as dirname3 } from "path";
|
|
618
844
|
import { homedir } from "os";
|
|
619
845
|
var CONFIG_FILENAMES = ["mcp.json", ".mcp.json", "claude_desktop_config.json"];
|
|
@@ -662,7 +888,7 @@ function loadServersFromFile(filePath) {
|
|
|
662
888
|
if (!existsSync4(filePath)) {
|
|
663
889
|
throw new McpError(`Config file not found: ${filePath}`, "invalid_config");
|
|
664
890
|
}
|
|
665
|
-
const content =
|
|
891
|
+
const content = readFileSync4(filePath, "utf-8");
|
|
666
892
|
let config;
|
|
667
893
|
try {
|
|
668
894
|
config = JSON.parse(content);
|
|
@@ -1649,7 +1875,7 @@ var CacheManager = class {
|
|
|
1649
1875
|
};
|
|
1650
1876
|
|
|
1651
1877
|
// src/skills/generator.ts
|
|
1652
|
-
import { existsSync as existsSync5, mkdirSync as mkdirSync2, writeFileSync as writeFileSync2, readFileSync as
|
|
1878
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync2, writeFileSync as writeFileSync2, readFileSync as readFileSync5, readdirSync as readdirSync2, statSync } from "fs";
|
|
1653
1879
|
import { join as join6, basename as basename2 } from "path";
|
|
1654
1880
|
|
|
1655
1881
|
// src/skills/templates.ts
|
|
@@ -2234,7 +2460,7 @@ function loadCustomTemplates(templatesDir) {
|
|
|
2234
2460
|
const stat = statSync(filePath);
|
|
2235
2461
|
if (!stat.isFile()) continue;
|
|
2236
2462
|
try {
|
|
2237
|
-
const content =
|
|
2463
|
+
const content = readFileSync5(filePath, "utf-8");
|
|
2238
2464
|
const template = parseSkillTemplate(file, content);
|
|
2239
2465
|
templates.push(template);
|
|
2240
2466
|
} catch {
|
|
@@ -2447,7 +2673,7 @@ import {
|
|
|
2447
2673
|
existsSync as existsSync6,
|
|
2448
2674
|
mkdirSync as mkdirSync3,
|
|
2449
2675
|
writeFileSync as writeFileSync3,
|
|
2450
|
-
readFileSync as
|
|
2676
|
+
readFileSync as readFileSync6,
|
|
2451
2677
|
readdirSync as readdirSync3,
|
|
2452
2678
|
renameSync,
|
|
2453
2679
|
statSync as statSync2
|
|
@@ -2702,7 +2928,7 @@ function getAgentKnowledgeState(agentName, options = {}) {
|
|
|
2702
2928
|
let context;
|
|
2703
2929
|
const currentContextPath = join7(dirs.context, "current.txt");
|
|
2704
2930
|
if (existsSync6(currentContextPath)) {
|
|
2705
|
-
const content =
|
|
2931
|
+
const content = readFileSync6(currentContextPath, "utf-8");
|
|
2706
2932
|
context = parseContextFile(content);
|
|
2707
2933
|
}
|
|
2708
2934
|
const state = {
|
|
@@ -2796,7 +3022,7 @@ function readInboxMessages(agentName, options = {}) {
|
|
|
2796
3022
|
);
|
|
2797
3023
|
for (const file of files) {
|
|
2798
3024
|
const filePath = join7(dirs.inbox, file);
|
|
2799
|
-
const rawContent =
|
|
3025
|
+
const rawContent = readFileSync6(filePath, "utf-8");
|
|
2800
3026
|
const { metadata, body } = parseMessageFrontmatter(rawContent);
|
|
2801
3027
|
if (options.type && metadata.type !== options.type) continue;
|
|
2802
3028
|
if (options.from && metadata.from !== options.from) continue;
|
|
@@ -2816,7 +3042,7 @@ function readInboxMessages(agentName, options = {}) {
|
|
|
2816
3042
|
);
|
|
2817
3043
|
for (const file of files) {
|
|
2818
3044
|
const filePath = join7(dirs.inboxProcessed, file);
|
|
2819
|
-
const rawContent =
|
|
3045
|
+
const rawContent = readFileSync6(filePath, "utf-8");
|
|
2820
3046
|
const { metadata, body } = parseMessageFrontmatter(rawContent);
|
|
2821
3047
|
if (options.type && metadata.type !== options.type) continue;
|
|
2822
3048
|
if (options.from && metadata.from !== options.from) continue;
|
|
@@ -2869,7 +3095,7 @@ function findPackageJson() {
|
|
|
2869
3095
|
while (dir !== dirname5(dir)) {
|
|
2870
3096
|
const pkgPath = join8(dir, "package.json");
|
|
2871
3097
|
try {
|
|
2872
|
-
const content =
|
|
3098
|
+
const content = readFileSync7(pkgPath, "utf-8");
|
|
2873
3099
|
const pkg = JSON.parse(content);
|
|
2874
3100
|
if (pkg.name === "@deimoscloud/coreai") {
|
|
2875
3101
|
return content;
|
|
@@ -3153,7 +3379,7 @@ function formatSyncResult(result) {
|
|
|
3153
3379
|
}
|
|
3154
3380
|
|
|
3155
3381
|
// src/cli/commands/init.ts
|
|
3156
|
-
import { existsSync as existsSync7, writeFileSync as writeFileSync4, mkdirSync as mkdirSync4, readFileSync as
|
|
3382
|
+
import { existsSync as existsSync7, writeFileSync as writeFileSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync8 } from "fs";
|
|
3157
3383
|
import { join as join11, basename as basename4 } from "path";
|
|
3158
3384
|
import { execSync } from "child_process";
|
|
3159
3385
|
function detectGitInfo() {
|
|
@@ -3184,7 +3410,7 @@ function detectProjectName(projectRoot) {
|
|
|
3184
3410
|
const packageJsonPath = join11(projectRoot, "package.json");
|
|
3185
3411
|
if (existsSync7(packageJsonPath)) {
|
|
3186
3412
|
try {
|
|
3187
|
-
const content = JSON.parse(
|
|
3413
|
+
const content = JSON.parse(readFileSync8(packageJsonPath, "utf-8"));
|
|
3188
3414
|
if (content.name) {
|
|
3189
3415
|
return content.name;
|
|
3190
3416
|
}
|
|
@@ -4030,22 +4256,22 @@ function formatStatusResult(result) {
|
|
|
4030
4256
|
}
|
|
4031
4257
|
|
|
4032
4258
|
// src/cli/commands/agents.ts
|
|
4033
|
-
import { readFileSync as
|
|
4259
|
+
import { readFileSync as readFileSync9, writeFileSync as writeFileSync5 } from "fs";
|
|
4034
4260
|
import { join as join13, dirname as dirname6 } from "path";
|
|
4035
|
-
import { parse as
|
|
4261
|
+
import { parse as parseYaml4, stringify as stringifyYaml2 } from "yaml";
|
|
4036
4262
|
function readConfigFile(configPath) {
|
|
4037
|
-
const content =
|
|
4038
|
-
const parsed =
|
|
4263
|
+
const content = readFileSync9(configPath, "utf-8");
|
|
4264
|
+
const parsed = parseYaml4(content);
|
|
4039
4265
|
return { content, parsed };
|
|
4040
4266
|
}
|
|
4041
4267
|
function updateConfigAgents(configPath, agents2) {
|
|
4042
|
-
const content =
|
|
4043
|
-
const parsed =
|
|
4268
|
+
const content = readFileSync9(configPath, "utf-8");
|
|
4269
|
+
const parsed = parseYaml4(content);
|
|
4044
4270
|
if (!parsed.team) {
|
|
4045
4271
|
parsed.team = {};
|
|
4046
4272
|
}
|
|
4047
4273
|
parsed.team.agents = agents2;
|
|
4048
|
-
const newContent =
|
|
4274
|
+
const newContent = stringifyYaml2(parsed, {
|
|
4049
4275
|
indent: 2,
|
|
4050
4276
|
lineWidth: 0,
|
|
4051
4277
|
singleQuote: false
|