@deimoscloud/coreai 0.1.9 → 0.1.11
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 +7 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/package.json +6 -1
- package/.prettierrc +0 -9
- package/AGENT_SPEC.md +0 -347
- package/ARCHITECTURE.md +0 -547
- package/DRAFT_PRD.md +0 -1440
- package/IMPLEMENTATION_PLAN.md +0 -256
- package/PRODUCT.md +0 -473
- package/WORKFLOWS.md +0 -295
- package/commands/core/check-inbox.md +0 -34
- package/commands/core/delegate.md +0 -30
- package/commands/core/git-commit.md +0 -144
- package/commands/core/pr-create.md +0 -193
- package/commands/core/review.md +0 -56
- package/commands/core/sprint-status.md +0 -65
- package/commands/optional/docs-update.md +0 -200
- package/commands/optional/jira-create.md +0 -200
- package/commands/optional/jira-transition.md +0 -184
- package/commands/optional/worktree-cleanup.md +0 -167
- package/commands/optional/worktree-setup.md +0 -110
- package/eslint.config.js +0 -29
- package/jest.config.js +0 -22
- package/knowledge-library/README.md +0 -118
- package/knowledge-library/android-engineer/context/current.txt +0 -42
- package/knowledge-library/android-engineer/control/decisions.txt +0 -9
- package/knowledge-library/android-engineer/control/dependencies.txt +0 -19
- package/knowledge-library/android-engineer/control/objectives.txt +0 -26
- package/knowledge-library/android-engineer/history/.gitkeep +0 -0
- package/knowledge-library/android-engineer/inbox/processed/.gitkeep +0 -0
- package/knowledge-library/android-engineer/outbox/.gitkeep +0 -0
- package/knowledge-library/android-engineer/tech/.gitkeep +0 -0
- package/knowledge-library/architecture.txt +0 -61
- package/knowledge-library/backend-engineer/context/current.txt +0 -42
- package/knowledge-library/backend-engineer/control/decisions.txt +0 -9
- package/knowledge-library/backend-engineer/control/dependencies.txt +0 -19
- package/knowledge-library/backend-engineer/control/objectives.txt +0 -26
- package/knowledge-library/backend-engineer/history/.gitkeep +0 -0
- package/knowledge-library/backend-engineer/inbox/processed/.gitkeep +0 -0
- package/knowledge-library/backend-engineer/outbox/.gitkeep +0 -0
- package/knowledge-library/backend-engineer/tech/.gitkeep +0 -0
- package/knowledge-library/context.txt +0 -52
- package/knowledge-library/devops-engineer/context/current.txt +0 -42
- package/knowledge-library/devops-engineer/control/decisions.txt +0 -9
- package/knowledge-library/devops-engineer/control/dependencies.txt +0 -19
- package/knowledge-library/devops-engineer/control/objectives.txt +0 -26
- package/knowledge-library/devops-engineer/history/.gitkeep +0 -0
- package/knowledge-library/devops-engineer/inbox/processed/.gitkeep +0 -0
- package/knowledge-library/devops-engineer/outbox/.gitkeep +0 -0
- package/knowledge-library/devops-engineer/tech/.gitkeep +0 -0
- package/knowledge-library/engineering-manager/context/current.txt +0 -40
- package/knowledge-library/engineering-manager/control/decisions.txt +0 -9
- package/knowledge-library/engineering-manager/control/objectives.txt +0 -27
- package/knowledge-library/engineering-manager/history/.gitkeep +0 -0
- package/knowledge-library/engineering-manager/inbox/processed/.gitkeep +0 -0
- package/knowledge-library/engineering-manager/outbox/.gitkeep +0 -0
- package/knowledge-library/engineering-manager/tech/.gitkeep +0 -0
- package/knowledge-library/prd.txt +0 -81
- package/knowledge-library/product-manager/context/current.txt +0 -42
- package/knowledge-library/product-manager/control/decisions.txt +0 -9
- package/knowledge-library/product-manager/control/dependencies.txt +0 -19
- package/knowledge-library/product-manager/control/objectives.txt +0 -26
- package/knowledge-library/product-manager/history/.gitkeep +0 -0
- package/knowledge-library/product-manager/inbox/processed/.gitkeep +0 -0
- package/knowledge-library/product-manager/outbox/.gitkeep +0 -0
- package/knowledge-library/product-manager/tech/.gitkeep +0 -0
- package/knowledge-library/qa-engineer/context/current.txt +0 -42
- package/knowledge-library/qa-engineer/control/decisions.txt +0 -9
- package/knowledge-library/qa-engineer/control/dependencies.txt +0 -19
- package/knowledge-library/qa-engineer/control/objectives.txt +0 -26
- package/knowledge-library/qa-engineer/history/.gitkeep +0 -0
- package/knowledge-library/qa-engineer/inbox/processed/.gitkeep +0 -0
- package/knowledge-library/qa-engineer/outbox/.gitkeep +0 -0
- package/knowledge-library/qa-engineer/tech/.gitkeep +0 -0
- package/knowledge-library/security-engineer/context/current.txt +0 -42
- package/knowledge-library/security-engineer/control/decisions.txt +0 -9
- package/knowledge-library/security-engineer/control/dependencies.txt +0 -19
- package/knowledge-library/security-engineer/control/objectives.txt +0 -26
- package/knowledge-library/security-engineer/history/.gitkeep +0 -0
- package/knowledge-library/security-engineer/inbox/processed/.gitkeep +0 -0
- package/knowledge-library/security-engineer/outbox/.gitkeep +0 -0
- package/knowledge-library/security-engineer/tech/.gitkeep +0 -0
- package/knowledge-library/solutions-architect/context/current.txt +0 -42
- package/knowledge-library/solutions-architect/control/decisions.txt +0 -9
- package/knowledge-library/solutions-architect/control/dependencies.txt +0 -19
- package/knowledge-library/solutions-architect/control/objectives.txt +0 -26
- package/knowledge-library/solutions-architect/history/.gitkeep +0 -0
- package/knowledge-library/solutions-architect/inbox/processed/.gitkeep +0 -0
- package/knowledge-library/solutions-architect/outbox/.gitkeep +0 -0
- package/knowledge-library/solutions-architect/tech/.gitkeep +0 -0
- package/knowledge-library/wearos-engineer/context/current.txt +0 -42
- package/knowledge-library/wearos-engineer/control/decisions.txt +0 -9
- package/knowledge-library/wearos-engineer/control/dependencies.txt +0 -19
- package/knowledge-library/wearos-engineer/control/objectives.txt +0 -26
- package/knowledge-library/wearos-engineer/history/.gitkeep +0 -0
- package/knowledge-library/wearos-engineer/inbox/processed/.gitkeep +0 -0
- package/knowledge-library/wearos-engineer/outbox/.gitkeep +0 -0
- package/knowledge-library/wearos-engineer/tech/.gitkeep +0 -0
- package/scripts/add-agent.sh +0 -323
- package/scripts/install.sh +0 -354
- package/src/adapters/factory.test.ts +0 -386
- package/src/adapters/factory.ts +0 -305
- package/src/adapters/index.ts +0 -113
- package/src/adapters/interfaces.ts +0 -268
- package/src/adapters/mcp/client.test.ts +0 -130
- package/src/adapters/mcp/client.ts +0 -451
- package/src/adapters/mcp/discovery.test.ts +0 -315
- package/src/adapters/mcp/discovery.ts +0 -340
- package/src/adapters/mcp/index.ts +0 -66
- package/src/adapters/mcp/mapper.test.ts +0 -218
- package/src/adapters/mcp/mapper.ts +0 -536
- package/src/adapters/mcp/registry.test.ts +0 -433
- package/src/adapters/mcp/registry.ts +0 -550
- package/src/adapters/mcp/types.ts +0 -258
- package/src/adapters/native/filesystem.test.ts +0 -350
- package/src/adapters/native/filesystem.ts +0 -393
- package/src/adapters/native/github.test.ts +0 -173
- package/src/adapters/native/github.ts +0 -627
- package/src/adapters/native/index.ts +0 -22
- package/src/adapters/native/selector.test.ts +0 -224
- package/src/adapters/native/selector.ts +0 -150
- package/src/adapters/types.ts +0 -270
- package/src/agents/compiler.test.ts +0 -410
- package/src/agents/compiler.ts +0 -424
- package/src/agents/index.ts +0 -37
- package/src/agents/loader.test.ts +0 -319
- package/src/agents/loader.ts +0 -143
- package/src/agents/resolver.test.ts +0 -282
- package/src/agents/resolver.ts +0 -262
- package/src/agents/types.ts +0 -97
- package/src/cache/index.ts +0 -38
- package/src/cache/interfaces.ts +0 -283
- package/src/cache/manager.test.ts +0 -266
- package/src/cache/manager.ts +0 -388
- package/src/cache/provider.test.ts +0 -485
- package/src/cache/provider.ts +0 -745
- package/src/cache/types.test.ts +0 -192
- package/src/cache/types.ts +0 -313
- package/src/cli/commands/build.test.ts +0 -248
- package/src/cli/commands/build.ts +0 -284
- package/src/cli/commands/cache.test.ts +0 -221
- package/src/cli/commands/cache.ts +0 -229
- package/src/cli/commands/index.ts +0 -63
- package/src/cli/commands/init.test.ts +0 -173
- package/src/cli/commands/init.ts +0 -296
- package/src/cli/commands/skills.test.ts +0 -272
- package/src/cli/commands/skills.ts +0 -348
- package/src/cli/commands/status.test.ts +0 -392
- package/src/cli/commands/status.ts +0 -332
- package/src/cli/commands/sync.test.ts +0 -213
- package/src/cli/commands/sync.ts +0 -251
- package/src/cli/commands/validate.test.ts +0 -216
- package/src/cli/commands/validate.ts +0 -340
- package/src/cli/index.test.ts +0 -190
- package/src/cli/index.ts +0 -493
- package/src/commands/context.test.ts +0 -163
- package/src/commands/context.ts +0 -111
- package/src/commands/index.ts +0 -56
- package/src/commands/loader.test.ts +0 -273
- package/src/commands/loader.ts +0 -355
- package/src/commands/registry.test.ts +0 -384
- package/src/commands/registry.ts +0 -248
- package/src/commands/runner.test.ts +0 -297
- package/src/commands/runner.ts +0 -222
- package/src/commands/types.ts +0 -361
- package/src/config/index.ts +0 -19
- package/src/config/loader.test.ts +0 -262
- package/src/config/loader.ts +0 -188
- package/src/config/types.ts +0 -154
- package/src/context/index.ts +0 -14
- package/src/context/loader.test.ts +0 -334
- package/src/context/loader.ts +0 -357
- package/src/index.test.ts +0 -13
- package/src/index.ts +0 -268
- package/src/knowledge-library/index.ts +0 -44
- package/src/knowledge-library/manager.test.ts +0 -536
- package/src/knowledge-library/manager.ts +0 -804
- package/src/knowledge-library/types.ts +0 -432
- package/src/skills/generator.test.ts +0 -602
- package/src/skills/generator.ts +0 -491
- package/src/skills/index.ts +0 -27
- package/src/skills/templates.ts +0 -520
- package/src/skills/types.ts +0 -251
- package/templates/completion-report.md +0 -72
- package/templates/feedback.md +0 -56
- package/templates/project-files/CLAUDE.md.template +0 -109
- package/templates/project-files/coreai.json.example +0 -47
- package/templates/project-files/mcp.json.template +0 -20
- package/templates/review-complete.md +0 -64
- package/templates/review-request.md +0 -67
- package/templates/task-assignment.md +0 -51
- package/tsconfig.build.json +0 -4
- package/tsconfig.json +0 -26
- package/tsup.config.ts +0 -23
package/src/agents/compiler.ts
DELETED
|
@@ -1,424 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent Compiler
|
|
3
|
-
*
|
|
4
|
-
* Transforms YAML agent definitions into Claude-compatible Markdown files.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
8
|
-
import { join, dirname } from 'path';
|
|
9
|
-
import type { CoreAIConfig } from '../config/types.js';
|
|
10
|
-
import type { AgentDefinition, AgentMetadata, AgentSource } from './types.js';
|
|
11
|
-
import { DEFAULT_AGENT_TOOLS } from './types.js';
|
|
12
|
-
import { loadAgentsFromDirectory } from './loader.js';
|
|
13
|
-
import { resolveAgentDefinition } from './resolver.js';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Options for compiling agents
|
|
17
|
-
*/
|
|
18
|
-
export interface CompileOptions {
|
|
19
|
-
/**
|
|
20
|
-
* Output directory for compiled markdown files.
|
|
21
|
-
* Default: .claude/agents
|
|
22
|
-
*/
|
|
23
|
-
outputDir?: string;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Core agents directory (built-in agents).
|
|
27
|
-
* Default: uses package's agents/ directory
|
|
28
|
-
*/
|
|
29
|
-
coreAgentsDir?: string;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Custom agents directory (project-specific agents).
|
|
33
|
-
* Default: coreai/agents in project root
|
|
34
|
-
*/
|
|
35
|
-
customAgentsDir?: string;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Project root directory.
|
|
39
|
-
* Default: process.cwd()
|
|
40
|
-
*/
|
|
41
|
-
projectRoot?: string;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Filter function to select which agents to compile.
|
|
45
|
-
* Returns true to include the agent, false to exclude.
|
|
46
|
-
*/
|
|
47
|
-
filter?: (agent: AgentDefinition) => boolean;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* MCP server names to include as tools.
|
|
51
|
-
* These will be added to the agent's tools as mcp__<server-name>.
|
|
52
|
-
* Example: ['github', 'postgres'] -> 'mcp__github, mcp__postgres'
|
|
53
|
-
*/
|
|
54
|
-
mcpServers?: string[];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Result of compiling agents
|
|
59
|
-
*/
|
|
60
|
-
export interface CompileResult {
|
|
61
|
-
/**
|
|
62
|
-
* Successfully compiled agents
|
|
63
|
-
*/
|
|
64
|
-
compiled: {
|
|
65
|
-
role: string;
|
|
66
|
-
source: AgentSource;
|
|
67
|
-
outputPath: string;
|
|
68
|
-
}[];
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Agents that failed to compile
|
|
72
|
-
*/
|
|
73
|
-
errors: {
|
|
74
|
-
role: string;
|
|
75
|
-
source: AgentSource;
|
|
76
|
-
error: string;
|
|
77
|
-
}[];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Build the tools string for agent frontmatter
|
|
82
|
-
*
|
|
83
|
-
* @param agent - Agent definition (may have custom tools)
|
|
84
|
-
* @param mcpServers - Optional MCP server names to include
|
|
85
|
-
* @returns Comma-separated list of tools
|
|
86
|
-
*/
|
|
87
|
-
export function buildAgentTools(agent: AgentDefinition, mcpServers?: string[]): string {
|
|
88
|
-
// Start with agent-specific tools or defaults
|
|
89
|
-
const tools: string[] = agent.tools
|
|
90
|
-
? [...agent.tools]
|
|
91
|
-
: [...DEFAULT_AGENT_TOOLS];
|
|
92
|
-
|
|
93
|
-
// Add MCP tools if servers are specified
|
|
94
|
-
if (mcpServers && mcpServers.length > 0) {
|
|
95
|
-
for (const server of mcpServers) {
|
|
96
|
-
tools.push(`mcp__${server}`);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return tools.join(', ');
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Generate markdown content from a resolved agent definition
|
|
105
|
-
*
|
|
106
|
-
* The output includes YAML frontmatter required by Claude Code for subagent detection.
|
|
107
|
-
* See: https://code.claude.com/docs/en/sub-agents
|
|
108
|
-
*
|
|
109
|
-
* @param agent - Resolved agent definition
|
|
110
|
-
* @param mcpServers - Optional MCP server names to include as tools
|
|
111
|
-
*/
|
|
112
|
-
export function generateAgentMarkdown(agent: AgentDefinition, mcpServers?: string[]): string {
|
|
113
|
-
const lines: string[] = [];
|
|
114
|
-
|
|
115
|
-
// Build tools string
|
|
116
|
-
const tools = buildAgentTools(agent, mcpServers);
|
|
117
|
-
|
|
118
|
-
// YAML frontmatter (required by Claude Code for subagent detection)
|
|
119
|
-
lines.push('---');
|
|
120
|
-
lines.push(`name: ${agent.role}`);
|
|
121
|
-
// Flatten description to single line for YAML frontmatter
|
|
122
|
-
lines.push(`description: ${agent.description.replace(/\n/g, ' ').trim()}`);
|
|
123
|
-
lines.push(`tools: ${tools}`);
|
|
124
|
-
lines.push('---');
|
|
125
|
-
lines.push('');
|
|
126
|
-
|
|
127
|
-
// Header
|
|
128
|
-
lines.push(`# ${agent.display_name}`);
|
|
129
|
-
lines.push('');
|
|
130
|
-
lines.push(`**Role:** ${agent.role}`);
|
|
131
|
-
lines.push(`**Type:** ${agent.type}`);
|
|
132
|
-
lines.push('');
|
|
133
|
-
|
|
134
|
-
// Description
|
|
135
|
-
lines.push('## Description');
|
|
136
|
-
lines.push('');
|
|
137
|
-
lines.push(agent.description.trim());
|
|
138
|
-
lines.push('');
|
|
139
|
-
|
|
140
|
-
// Responsibilities
|
|
141
|
-
if (agent.responsibilities && agent.responsibilities.length > 0) {
|
|
142
|
-
lines.push('## Responsibilities');
|
|
143
|
-
lines.push('');
|
|
144
|
-
for (const responsibility of agent.responsibilities) {
|
|
145
|
-
lines.push(`- ${responsibility}`);
|
|
146
|
-
}
|
|
147
|
-
lines.push('');
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Expertise
|
|
151
|
-
if (agent.expertise) {
|
|
152
|
-
lines.push('## Expertise');
|
|
153
|
-
lines.push('');
|
|
154
|
-
|
|
155
|
-
if (agent.expertise.primary && agent.expertise.primary.length > 0) {
|
|
156
|
-
lines.push('### Primary Areas');
|
|
157
|
-
lines.push('');
|
|
158
|
-
for (const area of agent.expertise.primary) {
|
|
159
|
-
lines.push(`- ${area}`);
|
|
160
|
-
}
|
|
161
|
-
lines.push('');
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (agent.expertise.tech_stack) {
|
|
165
|
-
lines.push('### Tech Stack');
|
|
166
|
-
lines.push('');
|
|
167
|
-
const techStack = agent.expertise.tech_stack;
|
|
168
|
-
if (typeof techStack === 'string') {
|
|
169
|
-
lines.push(techStack);
|
|
170
|
-
} else if (typeof techStack === 'object') {
|
|
171
|
-
lines.push('```json');
|
|
172
|
-
lines.push(JSON.stringify(techStack, null, 2));
|
|
173
|
-
lines.push('```');
|
|
174
|
-
}
|
|
175
|
-
lines.push('');
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// Skills
|
|
180
|
-
if (agent.skills && agent.skills.length > 0) {
|
|
181
|
-
lines.push('## Skills');
|
|
182
|
-
lines.push('');
|
|
183
|
-
for (const skill of agent.skills) {
|
|
184
|
-
lines.push(`- ${skill}`);
|
|
185
|
-
}
|
|
186
|
-
lines.push('');
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// Principles
|
|
190
|
-
if (agent.principles) {
|
|
191
|
-
lines.push('## Principles');
|
|
192
|
-
lines.push('');
|
|
193
|
-
|
|
194
|
-
for (const [category, items] of Object.entries(agent.principles)) {
|
|
195
|
-
if (items && Array.isArray(items) && items.length > 0) {
|
|
196
|
-
const title = formatTitle(category);
|
|
197
|
-
lines.push(`### ${title}`);
|
|
198
|
-
lines.push('');
|
|
199
|
-
for (const item of items) {
|
|
200
|
-
lines.push(`- ${item}`);
|
|
201
|
-
}
|
|
202
|
-
lines.push('');
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Behaviors
|
|
208
|
-
if (agent.behaviors) {
|
|
209
|
-
lines.push('## Behaviors');
|
|
210
|
-
lines.push('');
|
|
211
|
-
|
|
212
|
-
if (agent.behaviors.workflow) {
|
|
213
|
-
lines.push(`**Workflow:** ${agent.behaviors.workflow}`);
|
|
214
|
-
lines.push('');
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
if (agent.behaviors.quality_gates) {
|
|
218
|
-
lines.push('### Quality Gates');
|
|
219
|
-
lines.push('');
|
|
220
|
-
const gates = agent.behaviors.quality_gates;
|
|
221
|
-
if (typeof gates === 'string') {
|
|
222
|
-
lines.push(gates);
|
|
223
|
-
} else if (typeof gates === 'object') {
|
|
224
|
-
lines.push('```json');
|
|
225
|
-
lines.push(JSON.stringify(gates, null, 2));
|
|
226
|
-
lines.push('```');
|
|
227
|
-
}
|
|
228
|
-
lines.push('');
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// Context Sources
|
|
233
|
-
if (agent.context_sources) {
|
|
234
|
-
lines.push('## Context Sources');
|
|
235
|
-
lines.push('');
|
|
236
|
-
|
|
237
|
-
if (agent.context_sources.shared && agent.context_sources.shared.length > 0) {
|
|
238
|
-
lines.push('### Shared');
|
|
239
|
-
lines.push('');
|
|
240
|
-
for (const source of agent.context_sources.shared) {
|
|
241
|
-
lines.push(`- ${source}`);
|
|
242
|
-
}
|
|
243
|
-
lines.push('');
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (agent.context_sources.personal && agent.context_sources.personal.length > 0) {
|
|
247
|
-
lines.push('### Personal');
|
|
248
|
-
lines.push('');
|
|
249
|
-
for (const source of agent.context_sources.personal) {
|
|
250
|
-
lines.push(`- ${source}`);
|
|
251
|
-
}
|
|
252
|
-
lines.push('');
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// Communication
|
|
257
|
-
if (agent.communication) {
|
|
258
|
-
lines.push('## Communication');
|
|
259
|
-
lines.push('');
|
|
260
|
-
if (agent.communication.inbox) {
|
|
261
|
-
lines.push(`**Inbox:** ${agent.communication.inbox}`);
|
|
262
|
-
}
|
|
263
|
-
if (agent.communication.outbox) {
|
|
264
|
-
lines.push(`**Outbox:** ${agent.communication.outbox}`);
|
|
265
|
-
}
|
|
266
|
-
lines.push('');
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// Footer
|
|
270
|
-
lines.push('---');
|
|
271
|
-
lines.push('');
|
|
272
|
-
lines.push('*Generated by CoreAI*');
|
|
273
|
-
lines.push('');
|
|
274
|
-
|
|
275
|
-
return lines.join('\n');
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Format a snake_case or kebab-case string as a title
|
|
280
|
-
*/
|
|
281
|
-
function formatTitle(str: string): string {
|
|
282
|
-
return str.replace(/[_-]/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Compile a single agent to markdown
|
|
287
|
-
*
|
|
288
|
-
* @param agent - Agent definition to compile
|
|
289
|
-
* @param config - Optional CoreAI config for variable resolution
|
|
290
|
-
* @param mcpServers - Optional MCP server names to include as tools
|
|
291
|
-
*/
|
|
292
|
-
export function compileAgent(
|
|
293
|
-
agent: AgentDefinition,
|
|
294
|
-
config?: CoreAIConfig,
|
|
295
|
-
mcpServers?: string[]
|
|
296
|
-
): string {
|
|
297
|
-
const resolved = resolveAgentDefinition(agent, config);
|
|
298
|
-
return generateAgentMarkdown(resolved, mcpServers);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Load all agents from core and custom directories
|
|
303
|
-
*/
|
|
304
|
-
export function loadAllAgents(options: CompileOptions = {}): Map<string, AgentMetadata> {
|
|
305
|
-
const agents = new Map<string, AgentMetadata>();
|
|
306
|
-
|
|
307
|
-
// Load core agents
|
|
308
|
-
if (options.coreAgentsDir && existsSync(options.coreAgentsDir)) {
|
|
309
|
-
const coreAgents = loadAgentsFromDirectory(options.coreAgentsDir, 'core');
|
|
310
|
-
for (const [role, metadata] of coreAgents) {
|
|
311
|
-
agents.set(role, metadata);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
// Load custom agents (can override core agents)
|
|
316
|
-
if (options.customAgentsDir && existsSync(options.customAgentsDir)) {
|
|
317
|
-
const customAgents = loadAgentsFromDirectory(options.customAgentsDir, 'custom');
|
|
318
|
-
for (const [role, metadata] of customAgents) {
|
|
319
|
-
// Check if this is overriding a core agent
|
|
320
|
-
if (agents.has(role)) {
|
|
321
|
-
metadata.source = 'override';
|
|
322
|
-
}
|
|
323
|
-
agents.set(role, metadata);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
return agents;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Filter agents based on team configuration.
|
|
332
|
-
* Custom and override agents are always included regardless of team filter.
|
|
333
|
-
*/
|
|
334
|
-
export function filterAgentsByTeam(
|
|
335
|
-
agents: Map<string, AgentMetadata>,
|
|
336
|
-
config?: CoreAIConfig
|
|
337
|
-
): Map<string, AgentMetadata> {
|
|
338
|
-
if (!config?.team?.agents || config.team.agents.length === 0) {
|
|
339
|
-
// No team filter, return all agents
|
|
340
|
-
return agents;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
const filtered = new Map<string, AgentMetadata>();
|
|
344
|
-
|
|
345
|
-
for (const [role, metadata] of agents) {
|
|
346
|
-
// Always include custom and override agents
|
|
347
|
-
if (metadata.source === 'custom' || metadata.source === 'override') {
|
|
348
|
-
filtered.set(role, metadata);
|
|
349
|
-
}
|
|
350
|
-
// Include core agents only if they're in the team list
|
|
351
|
-
else if (config.team.agents.includes(role)) {
|
|
352
|
-
filtered.set(role, metadata);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
return filtered;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Compile all agents and write to output directory
|
|
361
|
-
*/
|
|
362
|
-
export function compileAgents(config?: CoreAIConfig, options: CompileOptions = {}): CompileResult {
|
|
363
|
-
const projectRoot = options.projectRoot ?? process.cwd();
|
|
364
|
-
const outputDir = options.outputDir ?? join(projectRoot, '.claude', 'agents');
|
|
365
|
-
const coreAgentsDir = options.coreAgentsDir ?? getCoreAgentsDir();
|
|
366
|
-
const customAgentsDir = options.customAgentsDir ?? join(projectRoot, 'coreai', 'agents');
|
|
367
|
-
|
|
368
|
-
const result: CompileResult = {
|
|
369
|
-
compiled: [],
|
|
370
|
-
errors: [],
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
// Load all agents
|
|
374
|
-
const allAgents = loadAllAgents({
|
|
375
|
-
...options,
|
|
376
|
-
coreAgentsDir,
|
|
377
|
-
customAgentsDir,
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
// Filter by team if configured
|
|
381
|
-
const agents = filterAgentsByTeam(allAgents, config);
|
|
382
|
-
|
|
383
|
-
// Ensure output directory exists
|
|
384
|
-
if (!existsSync(outputDir)) {
|
|
385
|
-
mkdirSync(outputDir, { recursive: true });
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
// Compile each agent
|
|
389
|
-
for (const [role, metadata] of agents) {
|
|
390
|
-
// Apply custom filter if provided
|
|
391
|
-
if (options.filter && !options.filter(metadata.definition)) {
|
|
392
|
-
continue;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
try {
|
|
396
|
-
const markdown = compileAgent(metadata.definition, config, options.mcpServers);
|
|
397
|
-
const outputPath = join(outputDir, `${role}.md`);
|
|
398
|
-
|
|
399
|
-
writeFileSync(outputPath, markdown, 'utf-8');
|
|
400
|
-
|
|
401
|
-
result.compiled.push({
|
|
402
|
-
role,
|
|
403
|
-
source: metadata.source,
|
|
404
|
-
outputPath,
|
|
405
|
-
});
|
|
406
|
-
} catch (error) {
|
|
407
|
-
result.errors.push({
|
|
408
|
-
role,
|
|
409
|
-
source: metadata.source,
|
|
410
|
-
error: error instanceof Error ? error.message : String(error),
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
return result;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* Get the default core agents directory
|
|
420
|
-
*/
|
|
421
|
-
export function getCoreAgentsDir(): string {
|
|
422
|
-
// Navigate from dist/agents/compiler.js to agents/
|
|
423
|
-
return join(dirname(dirname(dirname(import.meta.url.replace('file://', '')))), 'agents');
|
|
424
|
-
}
|
package/src/agents/index.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agents Module
|
|
3
|
-
*
|
|
4
|
-
* Provides agent loading, validation, and management for CoreAI.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export * from './types.js';
|
|
8
|
-
export {
|
|
9
|
-
loadAgentFromFile,
|
|
10
|
-
loadAgentsFromDirectory,
|
|
11
|
-
parseAgentYaml,
|
|
12
|
-
validateAgentDefinition,
|
|
13
|
-
getRoleFromFilename,
|
|
14
|
-
AgentError,
|
|
15
|
-
type AgentErrorCode,
|
|
16
|
-
} from './loader.js';
|
|
17
|
-
export {
|
|
18
|
-
resolveString,
|
|
19
|
-
resolveObject,
|
|
20
|
-
resolveAgentDefinition,
|
|
21
|
-
hasVariables,
|
|
22
|
-
extractVariables,
|
|
23
|
-
ResolutionError,
|
|
24
|
-
type ResolutionContext,
|
|
25
|
-
type ResolutionOptions,
|
|
26
|
-
} from './resolver.js';
|
|
27
|
-
export {
|
|
28
|
-
buildAgentTools,
|
|
29
|
-
generateAgentMarkdown,
|
|
30
|
-
compileAgent,
|
|
31
|
-
compileAgents,
|
|
32
|
-
loadAllAgents,
|
|
33
|
-
filterAgentsByTeam,
|
|
34
|
-
getCoreAgentsDir,
|
|
35
|
-
type CompileOptions,
|
|
36
|
-
type CompileResult,
|
|
37
|
-
} from './compiler.js';
|