@deimoscloud/coreai 0.1.0 → 0.1.2
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 +228 -26
- package/dist/cli/index.js +362 -108
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +23 -2
- package/dist/index.js +23 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/agents/compiler.ts +61 -4
- package/src/agents/index.ts +1 -0
- package/src/agents/types.ts +10 -0
- package/src/cli/commands/build.ts +40 -0
package/dist/index.d.ts
CHANGED
|
@@ -207,6 +207,11 @@ interface AgentDefinition {
|
|
|
207
207
|
behaviors?: AgentBehaviors;
|
|
208
208
|
context_sources?: AgentContextSources;
|
|
209
209
|
communication?: AgentCommunication;
|
|
210
|
+
/**
|
|
211
|
+
* Claude Code tools available to this agent.
|
|
212
|
+
* If not specified, defaults to: Read, Write, Edit, Bash, Glob, Grep
|
|
213
|
+
*/
|
|
214
|
+
tools?: string[];
|
|
210
215
|
}
|
|
211
216
|
/**
|
|
212
217
|
* Agent definition after variable resolution
|
|
@@ -354,6 +359,12 @@ interface CompileOptions {
|
|
|
354
359
|
* Returns true to include the agent, false to exclude.
|
|
355
360
|
*/
|
|
356
361
|
filter?: (agent: AgentDefinition) => boolean;
|
|
362
|
+
/**
|
|
363
|
+
* MCP server names to include as tools.
|
|
364
|
+
* These will be added to the agent's tools as mcp__<server-name>.
|
|
365
|
+
* Example: ['github', 'postgres'] -> 'mcp__github, mcp__postgres'
|
|
366
|
+
*/
|
|
367
|
+
mcpServers?: string[];
|
|
357
368
|
}
|
|
358
369
|
/**
|
|
359
370
|
* Result of compiling agents
|
|
@@ -378,12 +389,22 @@ interface CompileResult {
|
|
|
378
389
|
}
|
|
379
390
|
/**
|
|
380
391
|
* Generate markdown content from a resolved agent definition
|
|
392
|
+
*
|
|
393
|
+
* The output includes YAML frontmatter required by Claude Code for subagent detection.
|
|
394
|
+
* See: https://code.claude.com/docs/en/sub-agents
|
|
395
|
+
*
|
|
396
|
+
* @param agent - Resolved agent definition
|
|
397
|
+
* @param mcpServers - Optional MCP server names to include as tools
|
|
381
398
|
*/
|
|
382
|
-
declare function generateAgentMarkdown(agent: AgentDefinition): string;
|
|
399
|
+
declare function generateAgentMarkdown(agent: AgentDefinition, mcpServers?: string[]): string;
|
|
383
400
|
/**
|
|
384
401
|
* Compile a single agent to markdown
|
|
402
|
+
*
|
|
403
|
+
* @param agent - Agent definition to compile
|
|
404
|
+
* @param config - Optional CoreAI config for variable resolution
|
|
405
|
+
* @param mcpServers - Optional MCP server names to include as tools
|
|
385
406
|
*/
|
|
386
|
-
declare function compileAgent(agent: AgentDefinition, config?: CoreAIConfig): string;
|
|
407
|
+
declare function compileAgent(agent: AgentDefinition, config?: CoreAIConfig, mcpServers?: string[]): string;
|
|
387
408
|
/**
|
|
388
409
|
* Load all agents from core and custom directories
|
|
389
410
|
*/
|
package/dist/index.js
CHANGED
|
@@ -125,6 +125,9 @@ function getConfigPath(startDir) {
|
|
|
125
125
|
return findConfigFile(startDir);
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
// src/agents/types.ts
|
|
129
|
+
var DEFAULT_AGENT_TOOLS = ["Read", "Write", "Edit", "Bash", "Glob", "Grep"];
|
|
130
|
+
|
|
128
131
|
// src/agents/loader.ts
|
|
129
132
|
import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2 } from "fs";
|
|
130
133
|
import { basename, extname, join as join2 } from "path";
|
|
@@ -366,8 +369,24 @@ function resolveAgentDefinition(agent, config, options = {}) {
|
|
|
366
369
|
// src/agents/compiler.ts
|
|
367
370
|
import { existsSync as existsSync3, mkdirSync, writeFileSync } from "fs";
|
|
368
371
|
import { join as join3, dirname as dirname2 } from "path";
|
|
369
|
-
function
|
|
372
|
+
function buildAgentTools(agent, mcpServers) {
|
|
373
|
+
const tools = agent.tools ? [...agent.tools] : [...DEFAULT_AGENT_TOOLS];
|
|
374
|
+
if (mcpServers && mcpServers.length > 0) {
|
|
375
|
+
for (const server of mcpServers) {
|
|
376
|
+
tools.push(`mcp__${server}`);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return tools.join(", ");
|
|
380
|
+
}
|
|
381
|
+
function generateAgentMarkdown(agent, mcpServers) {
|
|
370
382
|
const lines = [];
|
|
383
|
+
const tools = buildAgentTools(agent, mcpServers);
|
|
384
|
+
lines.push("---");
|
|
385
|
+
lines.push(`name: ${agent.role}`);
|
|
386
|
+
lines.push(`description: ${agent.description.replace(/\n/g, " ").trim()}`);
|
|
387
|
+
lines.push(`tools: ${tools}`);
|
|
388
|
+
lines.push("---");
|
|
389
|
+
lines.push("");
|
|
371
390
|
lines.push(`# ${agent.display_name}`);
|
|
372
391
|
lines.push("");
|
|
373
392
|
lines.push(`**Role:** ${agent.role}`);
|
|
@@ -494,9 +513,9 @@ function generateAgentMarkdown(agent) {
|
|
|
494
513
|
function formatTitle(str) {
|
|
495
514
|
return str.replace(/[_-]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
496
515
|
}
|
|
497
|
-
function compileAgent(agent, config) {
|
|
516
|
+
function compileAgent(agent, config, mcpServers) {
|
|
498
517
|
const resolved = resolveAgentDefinition(agent, config);
|
|
499
|
-
return generateAgentMarkdown(resolved);
|
|
518
|
+
return generateAgentMarkdown(resolved, mcpServers);
|
|
500
519
|
}
|
|
501
520
|
function loadAllAgents(options = {}) {
|
|
502
521
|
const agents = /* @__PURE__ */ new Map();
|
|
@@ -551,7 +570,7 @@ function compileAgents(config, options = {}) {
|
|
|
551
570
|
continue;
|
|
552
571
|
}
|
|
553
572
|
try {
|
|
554
|
-
const markdown = compileAgent(metadata.definition, config);
|
|
573
|
+
const markdown = compileAgent(metadata.definition, config, options.mcpServers);
|
|
555
574
|
const outputPath = join3(outputDir, `${role}.md`);
|
|
556
575
|
writeFileSync(outputPath, markdown, "utf-8");
|
|
557
576
|
result.compiled.push({
|