@deimoscloud/coreai 0.1.9 → 0.1.10

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.
Files changed (196) hide show
  1. package/dist/cli/index.js +1 -1
  2. package/dist/cli/index.js.map +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/package.json +6 -1
  6. package/.prettierrc +0 -9
  7. package/AGENT_SPEC.md +0 -347
  8. package/ARCHITECTURE.md +0 -547
  9. package/DRAFT_PRD.md +0 -1440
  10. package/IMPLEMENTATION_PLAN.md +0 -256
  11. package/PRODUCT.md +0 -473
  12. package/WORKFLOWS.md +0 -295
  13. package/commands/core/check-inbox.md +0 -34
  14. package/commands/core/delegate.md +0 -30
  15. package/commands/core/git-commit.md +0 -144
  16. package/commands/core/pr-create.md +0 -193
  17. package/commands/core/review.md +0 -56
  18. package/commands/core/sprint-status.md +0 -65
  19. package/commands/optional/docs-update.md +0 -200
  20. package/commands/optional/jira-create.md +0 -200
  21. package/commands/optional/jira-transition.md +0 -184
  22. package/commands/optional/worktree-cleanup.md +0 -167
  23. package/commands/optional/worktree-setup.md +0 -110
  24. package/eslint.config.js +0 -29
  25. package/jest.config.js +0 -22
  26. package/knowledge-library/README.md +0 -118
  27. package/knowledge-library/android-engineer/context/current.txt +0 -42
  28. package/knowledge-library/android-engineer/control/decisions.txt +0 -9
  29. package/knowledge-library/android-engineer/control/dependencies.txt +0 -19
  30. package/knowledge-library/android-engineer/control/objectives.txt +0 -26
  31. package/knowledge-library/android-engineer/history/.gitkeep +0 -0
  32. package/knowledge-library/android-engineer/inbox/processed/.gitkeep +0 -0
  33. package/knowledge-library/android-engineer/outbox/.gitkeep +0 -0
  34. package/knowledge-library/android-engineer/tech/.gitkeep +0 -0
  35. package/knowledge-library/architecture.txt +0 -61
  36. package/knowledge-library/backend-engineer/context/current.txt +0 -42
  37. package/knowledge-library/backend-engineer/control/decisions.txt +0 -9
  38. package/knowledge-library/backend-engineer/control/dependencies.txt +0 -19
  39. package/knowledge-library/backend-engineer/control/objectives.txt +0 -26
  40. package/knowledge-library/backend-engineer/history/.gitkeep +0 -0
  41. package/knowledge-library/backend-engineer/inbox/processed/.gitkeep +0 -0
  42. package/knowledge-library/backend-engineer/outbox/.gitkeep +0 -0
  43. package/knowledge-library/backend-engineer/tech/.gitkeep +0 -0
  44. package/knowledge-library/context.txt +0 -52
  45. package/knowledge-library/devops-engineer/context/current.txt +0 -42
  46. package/knowledge-library/devops-engineer/control/decisions.txt +0 -9
  47. package/knowledge-library/devops-engineer/control/dependencies.txt +0 -19
  48. package/knowledge-library/devops-engineer/control/objectives.txt +0 -26
  49. package/knowledge-library/devops-engineer/history/.gitkeep +0 -0
  50. package/knowledge-library/devops-engineer/inbox/processed/.gitkeep +0 -0
  51. package/knowledge-library/devops-engineer/outbox/.gitkeep +0 -0
  52. package/knowledge-library/devops-engineer/tech/.gitkeep +0 -0
  53. package/knowledge-library/engineering-manager/context/current.txt +0 -40
  54. package/knowledge-library/engineering-manager/control/decisions.txt +0 -9
  55. package/knowledge-library/engineering-manager/control/objectives.txt +0 -27
  56. package/knowledge-library/engineering-manager/history/.gitkeep +0 -0
  57. package/knowledge-library/engineering-manager/inbox/processed/.gitkeep +0 -0
  58. package/knowledge-library/engineering-manager/outbox/.gitkeep +0 -0
  59. package/knowledge-library/engineering-manager/tech/.gitkeep +0 -0
  60. package/knowledge-library/prd.txt +0 -81
  61. package/knowledge-library/product-manager/context/current.txt +0 -42
  62. package/knowledge-library/product-manager/control/decisions.txt +0 -9
  63. package/knowledge-library/product-manager/control/dependencies.txt +0 -19
  64. package/knowledge-library/product-manager/control/objectives.txt +0 -26
  65. package/knowledge-library/product-manager/history/.gitkeep +0 -0
  66. package/knowledge-library/product-manager/inbox/processed/.gitkeep +0 -0
  67. package/knowledge-library/product-manager/outbox/.gitkeep +0 -0
  68. package/knowledge-library/product-manager/tech/.gitkeep +0 -0
  69. package/knowledge-library/qa-engineer/context/current.txt +0 -42
  70. package/knowledge-library/qa-engineer/control/decisions.txt +0 -9
  71. package/knowledge-library/qa-engineer/control/dependencies.txt +0 -19
  72. package/knowledge-library/qa-engineer/control/objectives.txt +0 -26
  73. package/knowledge-library/qa-engineer/history/.gitkeep +0 -0
  74. package/knowledge-library/qa-engineer/inbox/processed/.gitkeep +0 -0
  75. package/knowledge-library/qa-engineer/outbox/.gitkeep +0 -0
  76. package/knowledge-library/qa-engineer/tech/.gitkeep +0 -0
  77. package/knowledge-library/security-engineer/context/current.txt +0 -42
  78. package/knowledge-library/security-engineer/control/decisions.txt +0 -9
  79. package/knowledge-library/security-engineer/control/dependencies.txt +0 -19
  80. package/knowledge-library/security-engineer/control/objectives.txt +0 -26
  81. package/knowledge-library/security-engineer/history/.gitkeep +0 -0
  82. package/knowledge-library/security-engineer/inbox/processed/.gitkeep +0 -0
  83. package/knowledge-library/security-engineer/outbox/.gitkeep +0 -0
  84. package/knowledge-library/security-engineer/tech/.gitkeep +0 -0
  85. package/knowledge-library/solutions-architect/context/current.txt +0 -42
  86. package/knowledge-library/solutions-architect/control/decisions.txt +0 -9
  87. package/knowledge-library/solutions-architect/control/dependencies.txt +0 -19
  88. package/knowledge-library/solutions-architect/control/objectives.txt +0 -26
  89. package/knowledge-library/solutions-architect/history/.gitkeep +0 -0
  90. package/knowledge-library/solutions-architect/inbox/processed/.gitkeep +0 -0
  91. package/knowledge-library/solutions-architect/outbox/.gitkeep +0 -0
  92. package/knowledge-library/solutions-architect/tech/.gitkeep +0 -0
  93. package/knowledge-library/wearos-engineer/context/current.txt +0 -42
  94. package/knowledge-library/wearos-engineer/control/decisions.txt +0 -9
  95. package/knowledge-library/wearos-engineer/control/dependencies.txt +0 -19
  96. package/knowledge-library/wearos-engineer/control/objectives.txt +0 -26
  97. package/knowledge-library/wearos-engineer/history/.gitkeep +0 -0
  98. package/knowledge-library/wearos-engineer/inbox/processed/.gitkeep +0 -0
  99. package/knowledge-library/wearos-engineer/outbox/.gitkeep +0 -0
  100. package/knowledge-library/wearos-engineer/tech/.gitkeep +0 -0
  101. package/scripts/add-agent.sh +0 -323
  102. package/scripts/install.sh +0 -354
  103. package/src/adapters/factory.test.ts +0 -386
  104. package/src/adapters/factory.ts +0 -305
  105. package/src/adapters/index.ts +0 -113
  106. package/src/adapters/interfaces.ts +0 -268
  107. package/src/adapters/mcp/client.test.ts +0 -130
  108. package/src/adapters/mcp/client.ts +0 -451
  109. package/src/adapters/mcp/discovery.test.ts +0 -315
  110. package/src/adapters/mcp/discovery.ts +0 -340
  111. package/src/adapters/mcp/index.ts +0 -66
  112. package/src/adapters/mcp/mapper.test.ts +0 -218
  113. package/src/adapters/mcp/mapper.ts +0 -536
  114. package/src/adapters/mcp/registry.test.ts +0 -433
  115. package/src/adapters/mcp/registry.ts +0 -550
  116. package/src/adapters/mcp/types.ts +0 -258
  117. package/src/adapters/native/filesystem.test.ts +0 -350
  118. package/src/adapters/native/filesystem.ts +0 -393
  119. package/src/adapters/native/github.test.ts +0 -173
  120. package/src/adapters/native/github.ts +0 -627
  121. package/src/adapters/native/index.ts +0 -22
  122. package/src/adapters/native/selector.test.ts +0 -224
  123. package/src/adapters/native/selector.ts +0 -150
  124. package/src/adapters/types.ts +0 -270
  125. package/src/agents/compiler.test.ts +0 -410
  126. package/src/agents/compiler.ts +0 -424
  127. package/src/agents/index.ts +0 -37
  128. package/src/agents/loader.test.ts +0 -319
  129. package/src/agents/loader.ts +0 -143
  130. package/src/agents/resolver.test.ts +0 -282
  131. package/src/agents/resolver.ts +0 -262
  132. package/src/agents/types.ts +0 -97
  133. package/src/cache/index.ts +0 -38
  134. package/src/cache/interfaces.ts +0 -283
  135. package/src/cache/manager.test.ts +0 -266
  136. package/src/cache/manager.ts +0 -388
  137. package/src/cache/provider.test.ts +0 -485
  138. package/src/cache/provider.ts +0 -745
  139. package/src/cache/types.test.ts +0 -192
  140. package/src/cache/types.ts +0 -313
  141. package/src/cli/commands/build.test.ts +0 -248
  142. package/src/cli/commands/build.ts +0 -284
  143. package/src/cli/commands/cache.test.ts +0 -221
  144. package/src/cli/commands/cache.ts +0 -229
  145. package/src/cli/commands/index.ts +0 -63
  146. package/src/cli/commands/init.test.ts +0 -173
  147. package/src/cli/commands/init.ts +0 -296
  148. package/src/cli/commands/skills.test.ts +0 -272
  149. package/src/cli/commands/skills.ts +0 -348
  150. package/src/cli/commands/status.test.ts +0 -392
  151. package/src/cli/commands/status.ts +0 -332
  152. package/src/cli/commands/sync.test.ts +0 -213
  153. package/src/cli/commands/sync.ts +0 -251
  154. package/src/cli/commands/validate.test.ts +0 -216
  155. package/src/cli/commands/validate.ts +0 -340
  156. package/src/cli/index.test.ts +0 -190
  157. package/src/cli/index.ts +0 -493
  158. package/src/commands/context.test.ts +0 -163
  159. package/src/commands/context.ts +0 -111
  160. package/src/commands/index.ts +0 -56
  161. package/src/commands/loader.test.ts +0 -273
  162. package/src/commands/loader.ts +0 -355
  163. package/src/commands/registry.test.ts +0 -384
  164. package/src/commands/registry.ts +0 -248
  165. package/src/commands/runner.test.ts +0 -297
  166. package/src/commands/runner.ts +0 -222
  167. package/src/commands/types.ts +0 -361
  168. package/src/config/index.ts +0 -19
  169. package/src/config/loader.test.ts +0 -262
  170. package/src/config/loader.ts +0 -188
  171. package/src/config/types.ts +0 -154
  172. package/src/context/index.ts +0 -14
  173. package/src/context/loader.test.ts +0 -334
  174. package/src/context/loader.ts +0 -357
  175. package/src/index.test.ts +0 -13
  176. package/src/index.ts +0 -268
  177. package/src/knowledge-library/index.ts +0 -44
  178. package/src/knowledge-library/manager.test.ts +0 -536
  179. package/src/knowledge-library/manager.ts +0 -804
  180. package/src/knowledge-library/types.ts +0 -432
  181. package/src/skills/generator.test.ts +0 -602
  182. package/src/skills/generator.ts +0 -491
  183. package/src/skills/index.ts +0 -27
  184. package/src/skills/templates.ts +0 -520
  185. package/src/skills/types.ts +0 -251
  186. package/templates/completion-report.md +0 -72
  187. package/templates/feedback.md +0 -56
  188. package/templates/project-files/CLAUDE.md.template +0 -109
  189. package/templates/project-files/coreai.json.example +0 -47
  190. package/templates/project-files/mcp.json.template +0 -20
  191. package/templates/review-complete.md +0 -64
  192. package/templates/review-request.md +0 -67
  193. package/templates/task-assignment.md +0 -51
  194. package/tsconfig.build.json +0 -4
  195. package/tsconfig.json +0 -26
  196. package/tsup.config.ts +0 -23
@@ -1,248 +0,0 @@
1
- /**
2
- * Build Command Tests
3
- */
4
-
5
- import { promises as fs } from 'fs';
6
- import { join } from 'path';
7
- import { tmpdir } from 'os';
8
- import { build, formatBuildResult } from './build.js';
9
-
10
- describe('Build Command', () => {
11
- let testDir: string;
12
- let agentsDir: string;
13
-
14
- beforeEach(async () => {
15
- testDir = join(tmpdir(), `build-cmd-test-${Date.now()}-${Math.random().toString(36).slice(2)}`);
16
- agentsDir = join(testDir, 'coreai', 'agents');
17
- await fs.mkdir(agentsDir, { recursive: true });
18
- });
19
-
20
- afterEach(async () => {
21
- try {
22
- await fs.rm(testDir, { recursive: true, force: true });
23
- } catch {
24
- // Ignore cleanup errors
25
- }
26
- });
27
-
28
- describe('build', () => {
29
- it('should build without config file', async () => {
30
- const result = build({
31
- projectRoot: testDir,
32
- coreAgentsDir: join(testDir, 'core-agents'), // Non-existent, will use custom only
33
- });
34
-
35
- expect(result.success).toBe(true);
36
- expect(result.warnings).toBeDefined();
37
- expect(result.warnings?.some((w) => w.includes('No configuration'))).toBe(true);
38
- });
39
-
40
- it('should build with config file', async () => {
41
- const configPath = join(testDir, 'coreai.config.yaml');
42
- await fs.writeFile(
43
- configPath,
44
- `version: "1.0"
45
- project:
46
- name: test-project
47
- team:
48
- agents: []
49
- `
50
- );
51
-
52
- const result = build({
53
- projectRoot: testDir,
54
- coreAgentsDir: join(testDir, 'core-agents'),
55
- });
56
-
57
- expect(result.success).toBe(true);
58
- expect(result.config).toBeDefined();
59
- });
60
-
61
- it('should report config errors', async () => {
62
- const configPath = join(testDir, 'coreai.config.yaml');
63
- await fs.writeFile(configPath, 'invalid: yaml: [');
64
-
65
- const result = build({
66
- projectRoot: testDir,
67
- });
68
-
69
- expect(result.success).toBe(false);
70
- expect(result.error).toContain('Configuration error');
71
- });
72
-
73
- it('should build custom agents', async () => {
74
- // Create a custom agent
75
- await fs.writeFile(
76
- join(agentsDir, 'test-agent.yaml'),
77
- `role: test-agent
78
- type: ic-engineer
79
- display_name: Test Agent
80
- description: A test agent
81
- responsibilities:
82
- - Testing
83
- expertise:
84
- primary:
85
- - Testing
86
- `
87
- );
88
-
89
- const result = build({
90
- projectRoot: testDir,
91
- coreAgentsDir: join(testDir, 'non-existent'),
92
- });
93
-
94
- expect(result.success).toBe(true);
95
- expect(result.result?.compiled.length).toBeGreaterThan(0);
96
- expect(result.result?.compiled.some((a) => a.role === 'test-agent')).toBe(true);
97
- });
98
-
99
- it('should filter agents when specified', async () => {
100
- // Create multiple agents
101
- await fs.writeFile(
102
- join(agentsDir, 'agent-a.yaml'),
103
- `role: agent-a
104
- type: ic-engineer
105
- display_name: Agent A
106
- description: Agent A
107
- responsibilities: []
108
- expertise:
109
- primary: []
110
- `
111
- );
112
-
113
- await fs.writeFile(
114
- join(agentsDir, 'agent-b.yaml'),
115
- `role: agent-b
116
- type: ic-engineer
117
- display_name: Agent B
118
- description: Agent B
119
- responsibilities: []
120
- expertise:
121
- primary: []
122
- `
123
- );
124
-
125
- const result = build({
126
- projectRoot: testDir,
127
- coreAgentsDir: join(testDir, 'non-existent'),
128
- agents: ['agent-a'],
129
- });
130
-
131
- expect(result.success).toBe(true);
132
- expect(result.result?.compiled.length).toBe(1);
133
- expect(result.result?.compiled[0].role).toBe('agent-a');
134
- });
135
-
136
- it('should use custom output directory', async () => {
137
- await fs.writeFile(
138
- join(agentsDir, 'test-agent.yaml'),
139
- `role: test-agent
140
- type: ic-engineer
141
- display_name: Test Agent
142
- description: A test agent
143
- responsibilities: []
144
- expertise:
145
- primary: []
146
- `
147
- );
148
-
149
- const outputDir = join(testDir, 'custom-output');
150
-
151
- const result = build({
152
- projectRoot: testDir,
153
- coreAgentsDir: join(testDir, 'non-existent'),
154
- outputDir,
155
- });
156
-
157
- expect(result.success).toBe(true);
158
- expect(result.result?.compiled[0].outputPath).toContain('custom-output');
159
- });
160
- });
161
-
162
- describe('formatBuildResult', () => {
163
- it('should format success result', () => {
164
- const result = {
165
- success: true,
166
- result: {
167
- compiled: [
168
- { role: 'agent-a', source: 'custom' as const, outputPath: '/path/to/agent-a.md' },
169
- ],
170
- errors: [],
171
- },
172
- };
173
-
174
- const output = formatBuildResult(result);
175
-
176
- expect(output).toContain('Compiled');
177
- expect(output).toContain('agent-a');
178
- expect(output).toContain('Build complete');
179
- });
180
-
181
- it('should format error result', () => {
182
- const result = {
183
- success: false,
184
- error: 'Build failed',
185
- result: {
186
- compiled: [],
187
- errors: [{ role: 'agent-a', error: 'Invalid definition' }],
188
- },
189
- };
190
-
191
- const output = formatBuildResult(result);
192
-
193
- expect(output).toContain('Build failed');
194
- expect(output).toContain('agent-a');
195
- expect(output).toContain('Invalid definition');
196
- });
197
-
198
- it('should show warnings', () => {
199
- const result = {
200
- success: true,
201
- warnings: ['No config file found'],
202
- result: {
203
- compiled: [],
204
- errors: [],
205
- },
206
- };
207
-
208
- const output = formatBuildResult(result);
209
-
210
- expect(output).toContain('⚠');
211
- expect(output).toContain('No config file found');
212
- });
213
-
214
- it('should group agents by source', () => {
215
- const result = {
216
- success: true,
217
- result: {
218
- compiled: [
219
- { role: 'core-agent', source: 'core' as const, outputPath: '/core.md' },
220
- { role: 'custom-agent', source: 'custom' as const, outputPath: '/custom.md' },
221
- { role: 'override-agent', source: 'override' as const, outputPath: '/override.md' },
222
- ],
223
- errors: [],
224
- },
225
- };
226
-
227
- const output = formatBuildResult(result);
228
-
229
- expect(output).toContain('Core agents');
230
- expect(output).toContain('Custom agents');
231
- expect(output).toContain('Override agents');
232
- });
233
-
234
- it('should handle no agents to compile', () => {
235
- const result = {
236
- success: true,
237
- result: {
238
- compiled: [],
239
- errors: [],
240
- },
241
- };
242
-
243
- const output = formatBuildResult(result);
244
-
245
- expect(output).toContain('No agents to compile');
246
- });
247
- });
248
- });
@@ -1,284 +0,0 @@
1
- /**
2
- * Build Command
3
- *
4
- * Compiles agent definitions to Claude-compatible markdown files.
5
- */
6
-
7
- import { configExists, loadConfig, ConfigError } from '../../config/loader.js';
8
- import type { ResolvedCoreAIConfig } from '../../config/types.js';
9
- import { compileAgents, type CompileOptions, type CompileResult } from '../../agents/index.js';
10
- import { initAgentKnowledgeLibrary } from '../../knowledge-library/index.js';
11
- import { discoverMcpServers } from '../../adapters/mcp/index.js';
12
-
13
- /**
14
- * Options for build command
15
- */
16
- export interface BuildCommandOptions {
17
- /**
18
- * Project root directory
19
- */
20
- projectRoot?: string;
21
-
22
- /**
23
- * Path to core agents directory
24
- */
25
- coreAgentsDir?: string;
26
-
27
- /**
28
- * Output directory for compiled agents
29
- */
30
- outputDir?: string;
31
-
32
- /**
33
- * Watch for changes (not yet implemented)
34
- */
35
- watch?: boolean;
36
-
37
- /**
38
- * Only compile specific agents
39
- */
40
- agents?: string[];
41
-
42
- /**
43
- * Skip validation before build
44
- */
45
- skipValidation?: boolean;
46
-
47
- /**
48
- * Initialize KnowledgeLibrary directories for agents
49
- */
50
- initKnowledgeLibrary?: boolean;
51
-
52
- /**
53
- * Include MCP servers as agent tools.
54
- * If true, discovers MCP servers from config files.
55
- * If an array, uses the specified server names.
56
- * Default: true (auto-discover)
57
- */
58
- mcpServers?: boolean | string[];
59
- }
60
-
61
- /**
62
- * Result of build command
63
- */
64
- export interface BuildCommandResult {
65
- success: boolean;
66
- result?: CompileResult;
67
- config?: ResolvedCoreAIConfig;
68
- error?: string;
69
- warnings?: string[];
70
- knowledgeLibraryInitialized?: string[];
71
- mcpServers?: string[];
72
- }
73
-
74
- /**
75
- * Build agents
76
- */
77
- export function build(options: BuildCommandOptions = {}): BuildCommandResult {
78
- const projectRoot = options.projectRoot ?? process.cwd();
79
- const warnings: string[] = [];
80
-
81
- // Load config if available
82
- let config: ResolvedCoreAIConfig | undefined;
83
- if (configExists(projectRoot)) {
84
- try {
85
- config = loadConfig(projectRoot);
86
- } catch (error) {
87
- if (error instanceof ConfigError) {
88
- return {
89
- success: false,
90
- error: `Configuration error: ${error.message}`,
91
- };
92
- }
93
- return {
94
- success: false,
95
- error: `Failed to load config: ${error instanceof Error ? error.message : String(error)}`,
96
- };
97
- }
98
- } else {
99
- warnings.push('No configuration file found. Building with defaults.');
100
- }
101
-
102
- // Set up compile options
103
- const compileOptions: CompileOptions = {
104
- projectRoot,
105
- };
106
-
107
- if (options.coreAgentsDir) {
108
- compileOptions.coreAgentsDir = options.coreAgentsDir;
109
- }
110
-
111
- if (options.outputDir) {
112
- compileOptions.outputDir = options.outputDir;
113
- }
114
-
115
- // Filter to specific agents if requested
116
- if (options.agents && options.agents.length > 0) {
117
- const agentsList = options.agents;
118
- compileOptions.filter = (agent) => agentsList.includes(agent.role);
119
- }
120
-
121
- // Discover MCP servers for tools
122
- const includeMcpServers = options.mcpServers ?? true;
123
- if (includeMcpServers !== false) {
124
- try {
125
- if (Array.isArray(includeMcpServers)) {
126
- // Use explicitly provided server names
127
- compileOptions.mcpServers = includeMcpServers;
128
- } else {
129
- // Auto-discover from config files
130
- const discoveredServers = discoverMcpServers({
131
- projectRoot,
132
- includeGlobal: false, // Only use project-level MCP config
133
- });
134
- if (discoveredServers.length > 0) {
135
- compileOptions.mcpServers = discoveredServers.map((s) => s.name);
136
- }
137
- }
138
- } catch {
139
- // MCP discovery failed, continue without MCP tools
140
- // This is non-fatal - agents will just use default tools
141
- }
142
- }
143
-
144
- // Compile agents
145
- try {
146
- const result = compileAgents(config, compileOptions);
147
-
148
- // Check for errors
149
- if (result.errors.length > 0) {
150
- return {
151
- success: false,
152
- result,
153
- config,
154
- error: `Failed to compile ${result.errors.length} agent(s)`,
155
- warnings,
156
- };
157
- }
158
-
159
- // Initialize KnowledgeLibrary for agents if requested
160
- let knowledgeLibraryInitialized: string[] | undefined;
161
- if (options.initKnowledgeLibrary) {
162
- knowledgeLibraryInitialized = [];
163
- for (const compiled of result.compiled) {
164
- const initResult = initAgentKnowledgeLibrary(compiled.role, {
165
- projectRoot,
166
- createDefaults: true,
167
- });
168
- if (initResult.success && initResult.createdDirs.length > 0) {
169
- knowledgeLibraryInitialized.push(compiled.role);
170
- }
171
- }
172
- }
173
-
174
- return {
175
- success: true,
176
- result,
177
- config,
178
- warnings: warnings.length > 0 ? warnings : undefined,
179
- knowledgeLibraryInitialized,
180
- mcpServers: compileOptions.mcpServers,
181
- };
182
- } catch (error) {
183
- return {
184
- success: false,
185
- error: `Build failed: ${error instanceof Error ? error.message : String(error)}`,
186
- warnings: warnings.length > 0 ? warnings : undefined,
187
- };
188
- }
189
- }
190
-
191
- /**
192
- * Format build result for display
193
- */
194
- export function formatBuildResult(result: BuildCommandResult): string {
195
- const lines: string[] = [];
196
-
197
- // Warnings
198
- if (result.warnings && result.warnings.length > 0) {
199
- for (const warning of result.warnings) {
200
- lines.push(`⚠ ${warning}`);
201
- }
202
- lines.push('');
203
- }
204
-
205
- if (!result.success) {
206
- lines.push(`Build failed: ${result.error}`);
207
-
208
- // Show individual errors
209
- if (result.result?.errors && result.result.errors.length > 0) {
210
- lines.push('');
211
- for (const error of result.result.errors) {
212
- lines.push(` ✗ ${error.role}: ${error.error}`);
213
- }
214
- }
215
-
216
- return lines.join('\n');
217
- }
218
-
219
- const compileResult = result.result;
220
- if (!compileResult) {
221
- lines.push('No agents to compile.');
222
- return lines.join('\n');
223
- }
224
-
225
- if (compileResult.compiled.length === 0) {
226
- lines.push('No agents to compile.');
227
- return lines.join('\n');
228
- }
229
-
230
- lines.push(`Compiled ${compileResult.compiled.length} agent(s):\n`);
231
-
232
- // Group by source
233
- const coreAgents = compileResult.compiled.filter((a) => a.source === 'core');
234
- const customAgents = compileResult.compiled.filter((a) => a.source === 'custom');
235
- const overrideAgents = compileResult.compiled.filter((a) => a.source === 'override');
236
-
237
- if (coreAgents.length > 0) {
238
- lines.push('Core agents:');
239
- for (const agent of coreAgents) {
240
- lines.push(` ✓ ${agent.role}`);
241
- lines.push(` → ${agent.outputPath}`);
242
- }
243
- lines.push('');
244
- }
245
-
246
- if (customAgents.length > 0) {
247
- lines.push('Custom agents:');
248
- for (const agent of customAgents) {
249
- lines.push(` ✓ ${agent.role}`);
250
- lines.push(` → ${agent.outputPath}`);
251
- }
252
- lines.push('');
253
- }
254
-
255
- if (overrideAgents.length > 0) {
256
- lines.push('Override agents:');
257
- for (const agent of overrideAgents) {
258
- lines.push(` ✓ ${agent.role} (overrides core)`);
259
- lines.push(` → ${agent.outputPath}`);
260
- }
261
- lines.push('');
262
- }
263
-
264
- // MCP servers included
265
- if (result.mcpServers && result.mcpServers.length > 0) {
266
- lines.push(`MCP tools included: ${result.mcpServers.map((s) => `mcp__${s}`).join(', ')}`);
267
- lines.push('');
268
- }
269
-
270
- // KnowledgeLibrary initialization
271
- if (result.knowledgeLibraryInitialized && result.knowledgeLibraryInitialized.length > 0) {
272
- lines.push(
273
- `KnowledgeLibrary initialized for ${result.knowledgeLibraryInitialized.length} agent(s):`
274
- );
275
- for (const agent of result.knowledgeLibraryInitialized) {
276
- lines.push(` ✓ ${agent}`);
277
- }
278
- lines.push('');
279
- }
280
-
281
- lines.push('Build complete!');
282
-
283
- return lines.join('\n');
284
- }