@deimoscloud/coreai 0.1.0

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 (216) hide show
  1. package/.prettierrc +9 -0
  2. package/AGENT_SPEC.md +347 -0
  3. package/ARCHITECTURE.md +547 -0
  4. package/DRAFT_PRD.md +1440 -0
  5. package/IMPLEMENTATION_PLAN.md +256 -0
  6. package/PRODUCT.md +473 -0
  7. package/README.md +303 -0
  8. package/WORKFLOWS.md +295 -0
  9. package/agents/_templates/ic-engineer.md +185 -0
  10. package/agents/_templates/reviewer.md +182 -0
  11. package/agents/backend-engineer.yaml +72 -0
  12. package/agents/devops-engineer.yaml +72 -0
  13. package/agents/engineering-manager.yaml +70 -0
  14. package/agents/examples/android-engineer.md +302 -0
  15. package/agents/examples/backend-engineer.md +320 -0
  16. package/agents/examples/devops-engineer.md +742 -0
  17. package/agents/examples/engineering-manager.md +469 -0
  18. package/agents/examples/frontend-engineer.md +58 -0
  19. package/agents/examples/product-manager.md +315 -0
  20. package/agents/examples/qa-engineer.md +371 -0
  21. package/agents/examples/security-engineer.md +525 -0
  22. package/agents/examples/solutions-architect.md +351 -0
  23. package/agents/examples/wearos-engineer.md +359 -0
  24. package/agents/frontend-engineer.yaml +72 -0
  25. package/commands/core/check-inbox.md +34 -0
  26. package/commands/core/delegate.md +30 -0
  27. package/commands/core/git-commit.md +144 -0
  28. package/commands/core/pr-create.md +193 -0
  29. package/commands/core/review.md +56 -0
  30. package/commands/core/sprint-status.md +65 -0
  31. package/commands/optional/docs-update.md +200 -0
  32. package/commands/optional/jira-create.md +200 -0
  33. package/commands/optional/jira-transition.md +184 -0
  34. package/commands/optional/worktree-cleanup.md +167 -0
  35. package/commands/optional/worktree-setup.md +110 -0
  36. package/dist/cli/index.js +4037 -0
  37. package/dist/cli/index.js.map +1 -0
  38. package/dist/index.d.ts +2978 -0
  39. package/dist/index.js +3867 -0
  40. package/dist/index.js.map +1 -0
  41. package/eslint.config.js +29 -0
  42. package/jest.config.js +22 -0
  43. package/knowledge-library/README.md +118 -0
  44. package/knowledge-library/android-engineer/context/current.txt +42 -0
  45. package/knowledge-library/android-engineer/control/decisions.txt +9 -0
  46. package/knowledge-library/android-engineer/control/dependencies.txt +19 -0
  47. package/knowledge-library/android-engineer/control/objectives.txt +26 -0
  48. package/knowledge-library/android-engineer/history/.gitkeep +0 -0
  49. package/knowledge-library/android-engineer/inbox/processed/.gitkeep +0 -0
  50. package/knowledge-library/android-engineer/outbox/.gitkeep +0 -0
  51. package/knowledge-library/android-engineer/tech/.gitkeep +0 -0
  52. package/knowledge-library/architecture.txt +61 -0
  53. package/knowledge-library/backend-engineer/context/current.txt +42 -0
  54. package/knowledge-library/backend-engineer/control/decisions.txt +9 -0
  55. package/knowledge-library/backend-engineer/control/dependencies.txt +19 -0
  56. package/knowledge-library/backend-engineer/control/objectives.txt +26 -0
  57. package/knowledge-library/backend-engineer/history/.gitkeep +0 -0
  58. package/knowledge-library/backend-engineer/inbox/processed/.gitkeep +0 -0
  59. package/knowledge-library/backend-engineer/outbox/.gitkeep +0 -0
  60. package/knowledge-library/backend-engineer/tech/.gitkeep +0 -0
  61. package/knowledge-library/context.txt +52 -0
  62. package/knowledge-library/devops-engineer/context/current.txt +42 -0
  63. package/knowledge-library/devops-engineer/control/decisions.txt +9 -0
  64. package/knowledge-library/devops-engineer/control/dependencies.txt +19 -0
  65. package/knowledge-library/devops-engineer/control/objectives.txt +26 -0
  66. package/knowledge-library/devops-engineer/history/.gitkeep +0 -0
  67. package/knowledge-library/devops-engineer/inbox/processed/.gitkeep +0 -0
  68. package/knowledge-library/devops-engineer/outbox/.gitkeep +0 -0
  69. package/knowledge-library/devops-engineer/tech/.gitkeep +0 -0
  70. package/knowledge-library/engineering-manager/context/current.txt +40 -0
  71. package/knowledge-library/engineering-manager/control/decisions.txt +9 -0
  72. package/knowledge-library/engineering-manager/control/objectives.txt +27 -0
  73. package/knowledge-library/engineering-manager/history/.gitkeep +0 -0
  74. package/knowledge-library/engineering-manager/inbox/processed/.gitkeep +0 -0
  75. package/knowledge-library/engineering-manager/outbox/.gitkeep +0 -0
  76. package/knowledge-library/engineering-manager/tech/.gitkeep +0 -0
  77. package/knowledge-library/prd.txt +81 -0
  78. package/knowledge-library/product-manager/context/current.txt +42 -0
  79. package/knowledge-library/product-manager/control/decisions.txt +9 -0
  80. package/knowledge-library/product-manager/control/dependencies.txt +19 -0
  81. package/knowledge-library/product-manager/control/objectives.txt +26 -0
  82. package/knowledge-library/product-manager/history/.gitkeep +0 -0
  83. package/knowledge-library/product-manager/inbox/processed/.gitkeep +0 -0
  84. package/knowledge-library/product-manager/outbox/.gitkeep +0 -0
  85. package/knowledge-library/product-manager/tech/.gitkeep +0 -0
  86. package/knowledge-library/qa-engineer/context/current.txt +42 -0
  87. package/knowledge-library/qa-engineer/control/decisions.txt +9 -0
  88. package/knowledge-library/qa-engineer/control/dependencies.txt +19 -0
  89. package/knowledge-library/qa-engineer/control/objectives.txt +26 -0
  90. package/knowledge-library/qa-engineer/history/.gitkeep +0 -0
  91. package/knowledge-library/qa-engineer/inbox/processed/.gitkeep +0 -0
  92. package/knowledge-library/qa-engineer/outbox/.gitkeep +0 -0
  93. package/knowledge-library/qa-engineer/tech/.gitkeep +0 -0
  94. package/knowledge-library/security-engineer/context/current.txt +42 -0
  95. package/knowledge-library/security-engineer/control/decisions.txt +9 -0
  96. package/knowledge-library/security-engineer/control/dependencies.txt +19 -0
  97. package/knowledge-library/security-engineer/control/objectives.txt +26 -0
  98. package/knowledge-library/security-engineer/history/.gitkeep +0 -0
  99. package/knowledge-library/security-engineer/inbox/processed/.gitkeep +0 -0
  100. package/knowledge-library/security-engineer/outbox/.gitkeep +0 -0
  101. package/knowledge-library/security-engineer/tech/.gitkeep +0 -0
  102. package/knowledge-library/solutions-architect/context/current.txt +42 -0
  103. package/knowledge-library/solutions-architect/control/decisions.txt +9 -0
  104. package/knowledge-library/solutions-architect/control/dependencies.txt +19 -0
  105. package/knowledge-library/solutions-architect/control/objectives.txt +26 -0
  106. package/knowledge-library/solutions-architect/history/.gitkeep +0 -0
  107. package/knowledge-library/solutions-architect/inbox/processed/.gitkeep +0 -0
  108. package/knowledge-library/solutions-architect/outbox/.gitkeep +0 -0
  109. package/knowledge-library/solutions-architect/tech/.gitkeep +0 -0
  110. package/knowledge-library/wearos-engineer/context/current.txt +42 -0
  111. package/knowledge-library/wearos-engineer/control/decisions.txt +9 -0
  112. package/knowledge-library/wearos-engineer/control/dependencies.txt +19 -0
  113. package/knowledge-library/wearos-engineer/control/objectives.txt +26 -0
  114. package/knowledge-library/wearos-engineer/history/.gitkeep +0 -0
  115. package/knowledge-library/wearos-engineer/inbox/processed/.gitkeep +0 -0
  116. package/knowledge-library/wearos-engineer/outbox/.gitkeep +0 -0
  117. package/knowledge-library/wearos-engineer/tech/.gitkeep +0 -0
  118. package/package.json +66 -0
  119. package/schemas/agent.schema.json +171 -0
  120. package/schemas/coreai.config.schema.json +257 -0
  121. package/scripts/add-agent.sh +323 -0
  122. package/scripts/install.sh +354 -0
  123. package/src/adapters/factory.test.ts +386 -0
  124. package/src/adapters/factory.ts +305 -0
  125. package/src/adapters/index.ts +113 -0
  126. package/src/adapters/interfaces.ts +268 -0
  127. package/src/adapters/mcp/client.test.ts +130 -0
  128. package/src/adapters/mcp/client.ts +451 -0
  129. package/src/adapters/mcp/discovery.test.ts +315 -0
  130. package/src/adapters/mcp/discovery.ts +340 -0
  131. package/src/adapters/mcp/index.ts +66 -0
  132. package/src/adapters/mcp/mapper.test.ts +218 -0
  133. package/src/adapters/mcp/mapper.ts +536 -0
  134. package/src/adapters/mcp/registry.test.ts +433 -0
  135. package/src/adapters/mcp/registry.ts +550 -0
  136. package/src/adapters/mcp/types.ts +258 -0
  137. package/src/adapters/native/filesystem.test.ts +350 -0
  138. package/src/adapters/native/filesystem.ts +393 -0
  139. package/src/adapters/native/github.test.ts +173 -0
  140. package/src/adapters/native/github.ts +627 -0
  141. package/src/adapters/native/index.ts +22 -0
  142. package/src/adapters/native/selector.test.ts +224 -0
  143. package/src/adapters/native/selector.ts +150 -0
  144. package/src/adapters/types.ts +270 -0
  145. package/src/agents/compiler.test.ts +399 -0
  146. package/src/agents/compiler.ts +359 -0
  147. package/src/agents/index.ts +36 -0
  148. package/src/agents/loader.test.ts +319 -0
  149. package/src/agents/loader.ts +143 -0
  150. package/src/agents/resolver.test.ts +282 -0
  151. package/src/agents/resolver.ts +262 -0
  152. package/src/agents/types.ts +87 -0
  153. package/src/cache/index.ts +38 -0
  154. package/src/cache/interfaces.ts +283 -0
  155. package/src/cache/manager.test.ts +266 -0
  156. package/src/cache/manager.ts +388 -0
  157. package/src/cache/provider.test.ts +485 -0
  158. package/src/cache/provider.ts +745 -0
  159. package/src/cache/types.test.ts +192 -0
  160. package/src/cache/types.ts +313 -0
  161. package/src/cli/commands/build.test.ts +248 -0
  162. package/src/cli/commands/build.ts +244 -0
  163. package/src/cli/commands/cache.test.ts +221 -0
  164. package/src/cli/commands/cache.ts +229 -0
  165. package/src/cli/commands/index.ts +63 -0
  166. package/src/cli/commands/init.test.ts +173 -0
  167. package/src/cli/commands/init.ts +296 -0
  168. package/src/cli/commands/skills.test.ts +272 -0
  169. package/src/cli/commands/skills.ts +348 -0
  170. package/src/cli/commands/status.test.ts +392 -0
  171. package/src/cli/commands/status.ts +332 -0
  172. package/src/cli/commands/sync.test.ts +213 -0
  173. package/src/cli/commands/sync.ts +251 -0
  174. package/src/cli/commands/validate.test.ts +216 -0
  175. package/src/cli/commands/validate.ts +340 -0
  176. package/src/cli/index.test.ts +190 -0
  177. package/src/cli/index.ts +493 -0
  178. package/src/commands/context.test.ts +163 -0
  179. package/src/commands/context.ts +111 -0
  180. package/src/commands/index.ts +56 -0
  181. package/src/commands/loader.test.ts +273 -0
  182. package/src/commands/loader.ts +355 -0
  183. package/src/commands/registry.test.ts +384 -0
  184. package/src/commands/registry.ts +248 -0
  185. package/src/commands/runner.test.ts +297 -0
  186. package/src/commands/runner.ts +222 -0
  187. package/src/commands/types.ts +361 -0
  188. package/src/config/index.ts +19 -0
  189. package/src/config/loader.test.ts +262 -0
  190. package/src/config/loader.ts +188 -0
  191. package/src/config/types.ts +154 -0
  192. package/src/context/index.ts +14 -0
  193. package/src/context/loader.test.ts +334 -0
  194. package/src/context/loader.ts +357 -0
  195. package/src/index.test.ts +13 -0
  196. package/src/index.ts +244 -0
  197. package/src/knowledge-library/index.ts +44 -0
  198. package/src/knowledge-library/manager.test.ts +536 -0
  199. package/src/knowledge-library/manager.ts +804 -0
  200. package/src/knowledge-library/types.ts +432 -0
  201. package/src/skills/generator.test.ts +602 -0
  202. package/src/skills/generator.ts +491 -0
  203. package/src/skills/index.ts +27 -0
  204. package/src/skills/templates.ts +520 -0
  205. package/src/skills/types.ts +251 -0
  206. package/templates/completion-report.md +72 -0
  207. package/templates/feedback.md +56 -0
  208. package/templates/project-files/CLAUDE.md.template +109 -0
  209. package/templates/project-files/coreai.json.example +47 -0
  210. package/templates/project-files/mcp.json.template +20 -0
  211. package/templates/review-complete.md +64 -0
  212. package/templates/review-request.md +67 -0
  213. package/templates/task-assignment.md +51 -0
  214. package/tsconfig.build.json +4 -0
  215. package/tsconfig.json +26 -0
  216. package/tsup.config.ts +23 -0
@@ -0,0 +1,547 @@
1
+ # CoreAI Architecture
2
+
3
+ Technical documentation for understanding and modifying the CoreAI multi-agent framework.
4
+
5
+ ## Overview
6
+
7
+ CoreAI enables multiple AI agents to collaborate on software development tasks using Claude Code. Agents communicate through file-based messaging (inboxes), follow defined workflows, and use MCP (Model Context Protocol) tools for external integrations.
8
+
9
+ ---
10
+
11
+ ## Core Concepts
12
+
13
+ ### 1. Agents
14
+
15
+ Agents are Claude Code personas defined in markdown files. Each agent has:
16
+
17
+ - **Identity**: Name, role, responsibilities
18
+ - **Tools**: MCP tools they can access (Jira, GitHub, etc.)
19
+ - **Behavior**: Startup protocol, work patterns, completion protocol
20
+ - **Context**: KnowledgeLibrary directory for state and communication
21
+
22
+ **Agent Types:**
23
+
24
+ | Type | Purpose | Examples |
25
+ |------|---------|----------|
26
+ | Manager | Coordinate, delegate, validate | engineering-manager |
27
+ | IC Engineer | Implement features, fix bugs | backend-engineer, frontend-engineer |
28
+ | Reviewer | Code review, specialized guidance | security-engineer, qa-engineer |
29
+
30
+ **File Location:** `.claude/agents/<agent-name>.md`
31
+
32
+ ### 2. Commands (Skills)
33
+
34
+ Commands are user-invocable workflows defined in markdown. They provide:
35
+
36
+ - **Instructions**: Step-by-step process for the agent to follow
37
+ - **Templates**: Output formats, message structures
38
+ - **Integrations**: Which MCP tools to use
39
+
40
+ **File Location:** `.claude/commands/<command-name>.md`
41
+
42
+ **Invocation:** User types `/command-name` or agent is instructed to use it
43
+
44
+ ### 3. KnowledgeLibrary
45
+
46
+ File-based storage for agent state and inter-agent communication.
47
+
48
+ ```
49
+ KnowledgeLibrary/
50
+ ├── context.txt # Project-wide state (sprint, priorities)
51
+ ├── architecture.txt # Technical decisions
52
+ ├── prd.txt # Product requirements
53
+
54
+ └── <agent-name>/
55
+ ├── inbox/ # Incoming messages from other agents
56
+ │ └── processed/ # Archived completed messages
57
+ ├── outbox/ # Copies of sent messages
58
+ ├── context/
59
+ │ └── current.txt # Agent's current state and tasks
60
+ ├── control/
61
+ │ ├── objectives.txt # Goals and success criteria
62
+ │ ├── decisions.txt # Decision log
63
+ │ └── dependencies.txt # Blocking/blocked-by tracking
64
+ ├── history/ # Historical records
65
+ └── tech/ # Technical notes, research
66
+ ```
67
+
68
+ ### 4. Workflows
69
+
70
+ State machines defining how work progresses through the system.
71
+
72
+ **Ticket Implementation Workflow:**
73
+ ```
74
+ BACKLOG → IN_PROGRESS → PR_CREATED → IN_REVIEW → APPROVED → MERGED → DONE
75
+ ```
76
+
77
+ **Code Review Workflow:**
78
+ ```
79
+ ASSIGNED → REVIEWING → DECISION_POSTED
80
+ ```
81
+
82
+ Defined in: `coreai/WORKFLOWS.md`
83
+
84
+ ---
85
+
86
+ ## Communication Model
87
+
88
+ ### Why File-Based Messaging?
89
+
90
+ Claude Code agents cannot directly invoke each other. The Task tool spawns subagents that **lose MCP access** (no Jira, GitHub, etc.). File-based messaging solves this:
91
+
92
+ 1. Agent A writes message to Agent B's inbox
93
+ 2. Agent A tells user: "Please invoke @agent-b"
94
+ 3. User invokes Agent B (gets full MCP access)
95
+ 4. Agent B reads inbox, processes task
96
+ 5. Agent B writes response to Agent A's inbox
97
+ 6. User invokes Agent A to continue
98
+
99
+ ### Message Format
100
+
101
+ Inbox messages follow a standard template:
102
+
103
+ ```markdown
104
+ ---
105
+ type: task-assignment | completion-report | review-request | feedback
106
+ from: <sender-agent>
107
+ to: <recipient-agent>
108
+ date: YYYY-MM-DD HH:MM
109
+ ticket: PROJ-XX (optional)
110
+ priority: P0-P3 (optional)
111
+ ---
112
+
113
+ ## Subject
114
+
115
+ ### Details
116
+ [Content]
117
+
118
+ ### Expected Actions
119
+ 1. Action 1
120
+ 2. Action 2
121
+ ```
122
+
123
+ **Filename Convention:** `YYYYMMDD_HHMM-<from-agent>-<ticket-or-subject>.md`
124
+
125
+ ### Message Flow Example
126
+
127
+ ```
128
+ ┌─────────────────┐ writes to inbox ┌─────────────────┐
129
+ │ Engineering │ ───────────────────────▶│ Backend │
130
+ │ Manager │ │ Engineer │
131
+ └────────┬────────┘ └────────┬────────┘
132
+ │ │
133
+ │ tells user: │ reads inbox
134
+ │ "invoke @backend-engineer" │ works on task
135
+ │ │
136
+ ▼ ▼
137
+ ┌─────────────────┐ ┌─────────────────┐
138
+ │ User │ ─── invokes agent ────▶ │ Backend │
139
+ │ │ │ Engineer │
140
+ └─────────────────┘ └────────┬────────┘
141
+
142
+ │ writes completion
143
+ │ to EM inbox
144
+
145
+ ┌─────────────────┐
146
+ │ EM Inbox │
147
+ └─────────────────┘
148
+ ```
149
+
150
+ ---
151
+
152
+ ## MCP Integration
153
+
154
+ MCP (Model Context Protocol) provides external tool access. Agents declare which MCP tools they need in their frontmatter:
155
+
156
+ ```yaml
157
+ ---
158
+ tools: Read, Write, Edit, Glob, Grep, mcp__github, mcp__atlassian
159
+ ---
160
+ ```
161
+
162
+ ### Available MCP Servers
163
+
164
+ | Server | Tools | Purpose |
165
+ |--------|-------|---------|
166
+ | `mcp__github` | PR management, issues, repo operations | GitHub integration |
167
+ | `mcp__atlassian` | Jira tickets, Confluence pages | Atlassian integration |
168
+ | `mcp__postgres` | Database queries | PostgreSQL access |
169
+ | `mcp__firebase` | Firebase operations | Firebase/GCP access |
170
+
171
+ ### MCP Configuration
172
+
173
+ MCP servers are configured in `mcp.json` or `.claude/mcp.json`:
174
+
175
+ ```json
176
+ {
177
+ "mcpServers": {
178
+ "github": {
179
+ "command": "npx",
180
+ "args": ["-y", "@modelcontextprotocol/server-github"],
181
+ "env": {
182
+ "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}"
183
+ }
184
+ }
185
+ }
186
+ }
187
+ ```
188
+
189
+ **Critical:** Agents invoked via Task tool lose MCP access. Always invoke agents directly via `@agent-name`.
190
+
191
+ ### CLI MCP Integration Layer
192
+
193
+ The CoreAI CLI provides a programmatic MCP integration layer (`src/adapters/mcp/`) for connecting to MCP servers and mapping their tools to adapter interfaces.
194
+
195
+ #### Architecture
196
+
197
+ ```
198
+ ┌─────────────────────────────────────────────────────────────────┐
199
+ │ Adapter Layer │
200
+ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
201
+ │ │ IssueTracker │ │ GitProvider │ │ State │ │
202
+ │ │ Adapter │ │ Adapter │ │ Adapter │ │
203
+ │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
204
+ └─────────┼─────────────────┼─────────────────┼───────────────────┘
205
+ │ │ │
206
+ └────────────┬────┴─────────────────┘
207
+
208
+ ┌────────────▼────────────┐
209
+ │ Tool Mapper │
210
+ │ (MCP tools → Adapter │
211
+ │ interface methods) │
212
+ └────────────┬────────────┘
213
+
214
+ ┌────────────▼────────────┐
215
+ │ MCP Client │
216
+ │ (SDK wrapper) │
217
+ └────────────┬────────────┘
218
+
219
+ ┌────────────▼────────────┐
220
+ │ Server Discovery │
221
+ │ (config file parsing) │
222
+ └─────────────────────────┘
223
+ ```
224
+
225
+ #### Components
226
+
227
+ | Component | File | Purpose |
228
+ |-----------|------|---------|
229
+ | Types | `src/adapters/mcp/types.ts` | Server configs, tool definitions, errors |
230
+ | Client | `src/adapters/mcp/client.ts` | MCP SDK wrapper with simplified API |
231
+ | Discovery | `src/adapters/mcp/discovery.ts` | Config file discovery and parsing |
232
+ | Mapper | `src/adapters/mcp/mapper.ts` | Tool-to-adapter mapping with known servers |
233
+ | Registry | `src/adapters/mcp/registry.ts` | Central registry for connection management |
234
+
235
+ #### Server Discovery
236
+
237
+ The CLI discovers MCP servers from multiple locations (in priority order):
238
+
239
+ 1. **Project-level**: `mcp.json`, `.mcp.json`, `.claude/mcp.json`
240
+ 2. **Global config**: `~/.config/claude/mcp.json`, `~/.claude/mcp.json`
241
+ 3. **Claude Desktop**: `~/Library/Application Support/Claude/claude_desktop_config.json`
242
+
243
+ ```typescript
244
+ import { discoverMcpServers } from '@deimoscloud/coreai';
245
+
246
+ const servers = discoverMcpServers({
247
+ projectRoot: '/path/to/project',
248
+ includeGlobal: true,
249
+ });
250
+ ```
251
+
252
+ #### Tool Mapping
253
+
254
+ MCP tools are mapped to adapter interface methods using either:
255
+
256
+ 1. **Known server mappings** - Pre-defined mappings for popular servers (GitHub, Jira, Confluence, Filesystem)
257
+ 2. **Auto-discovery** - Heuristic-based mapping using tool naming patterns with confidence scoring
258
+
259
+ ```typescript
260
+ import { getMappingsForServer, McpTool } from '@deimoscloud/coreai';
261
+
262
+ const tools: McpTool[] = await client.listTools();
263
+ const mappings = getMappingsForServer('github', tools);
264
+
265
+ // mappings contains:
266
+ // { toolName: 'create_pull_request', adapterType: 'git', method: 'createPullRequest', ... }
267
+ ```
268
+
269
+ #### Supported Transports
270
+
271
+ | Transport | Config Field | Description |
272
+ |-----------|--------------|-------------|
273
+ | stdio | `command`, `args`, `env`, `cwd` | Local process communication |
274
+ | http | `url`, `headers` | HTTP-based remote servers |
275
+ | sse | `url`, `headers` | Server-Sent Events for streaming |
276
+
277
+ ---
278
+
279
+ ## Template System
280
+
281
+ ### Placeholders
282
+
283
+ Templates use double-brace placeholders that get replaced during installation:
284
+
285
+ | Placeholder | Source | Example |
286
+ |-------------|--------|---------|
287
+ | `{{PROJECT_NAME}}` | coreai.json: project.name | "SurfTrack" |
288
+ | `{{JIRA_PROJECT}}` | coreai.json: project.jiraProject | "SUR" |
289
+ | `{{GITHUB_REPO}}` | coreai.json: project.githubRepo | "owner/repo" |
290
+ | `{{CONFLUENCE_SPACE}}` | coreai.json: project.confluenceSpace | "SUR" |
291
+ | `{{CONFLUENCE_URL}}` | coreai.json: project.confluenceUrl | "https://..." |
292
+ | `{{JIRA_URL}}` | coreai.json: project.jiraUrl | "https://..." |
293
+ | `{{LINT_CMD}}` | coreai.json: qualityChecks.lint | "./gradlew ktlintCheck" |
294
+ | `{{STATIC_ANALYSIS_CMD}}` | coreai.json: qualityChecks.staticAnalysis | "./gradlew detekt" |
295
+ | `{{TEST_CMD}}` | coreai.json: qualityChecks.test | "./gradlew test" |
296
+ | `{{BUILD_CMD}}` | coreai.json: qualityChecks.build | "./gradlew assembleDebug" |
297
+
298
+ ### Agent-Specific Placeholders
299
+
300
+ Used in agent templates (`_templates/`):
301
+
302
+ | Placeholder | Purpose |
303
+ |-------------|---------|
304
+ | `{{AGENT_NAME}}` | Lowercase hyphenated name (e.g., "backend-engineer") |
305
+ | `{{AGENT_DISPLAY_NAME}}` | Title case name (e.g., "Backend Engineer") |
306
+ | `{{AGENT_DESCRIPTION}}` | Role description |
307
+ | `{{TEAM_MEMBERS_LIST}}` | List of team members (EM only) |
308
+
309
+ ### Substitution Process
310
+
311
+ `install.sh` and `add-agent.sh` use `sed` to replace placeholders:
312
+
313
+ ```bash
314
+ sed -i.bak \
315
+ -e "s|{{PROJECT_NAME}}|$PROJECT_NAME|g" \
316
+ -e "s|{{JIRA_PROJECT}}|$JIRA_PROJECT|g" \
317
+ "$TARGET_FILE"
318
+ ```
319
+
320
+ ---
321
+
322
+ ## File Structure
323
+
324
+ ### Framework Files (coreai/)
325
+
326
+ ```
327
+ coreai/
328
+ ├── README.md # Installation guide
329
+ ├── ARCHITECTURE.md # This file
330
+ ├── AGENT_SPEC.md # Agent behavior specification
331
+ ├── WORKFLOWS.md # Workflow state machines
332
+
333
+ ├── scripts/
334
+ │ ├── install.sh # Main installer
335
+ │ └── add-agent.sh # Add new agent
336
+
337
+ ├── agents/
338
+ │ ├── _templates/ # Agent templates for add-agent.sh
339
+ │ │ ├── ic-engineer.md # IC engineer template
340
+ │ │ └── reviewer.md # Reviewer template
341
+ │ └── examples/ # Ready-to-use agents (copied on install)
342
+ │ ├── engineering-manager.md # Required core agent
343
+ │ ├── backend-engineer.md
344
+ │ ├── android-engineer.md
345
+ │ ├── wearos-engineer.md
346
+ │ ├── devops-engineer.md
347
+ │ ├── solutions-architect.md
348
+ │ ├── qa-engineer.md
349
+ │ ├── security-engineer.md
350
+ │ ├── product-manager.md
351
+ │ └── frontend-engineer.md
352
+
353
+ ├── commands/
354
+ │ ├── core/ # Always installed
355
+ │ │ ├── delegate.md
356
+ │ │ ├── check-inbox.md
357
+ │ │ ├── review.md
358
+ │ │ ├── sprint-status.md
359
+ │ │ ├── git-commit.md
360
+ │ │ └── pr-create.md
361
+ │ └── optional/ # Install as needed
362
+ │ ├── worktree-setup.md
363
+ │ ├── worktree-cleanup.md
364
+ │ ├── jira-create.md
365
+ │ ├── jira-transition.md
366
+ │ └── docs-update.md
367
+
368
+ ├── templates/
369
+ │ ├── inbox-messages/ # Message templates
370
+ │ └── project-files/ # Config templates
371
+
372
+ └── knowledge-library/ # KnowledgeLibrary templates
373
+ ```
374
+
375
+ ### Installed Files (Target Project)
376
+
377
+ ```
378
+ project/
379
+ ├── .claude/
380
+ │ ├── agents/ # Copied from coreai/agents/
381
+ │ └── commands/ # Copied from coreai/commands/
382
+
383
+ ├── KnowledgeLibrary/ # Created by install.sh
384
+ │ ├── context.txt
385
+ │ ├── architecture.txt
386
+ │ ├── prd.txt
387
+ │ └── <agent>/ # Per-agent directories
388
+
389
+ ├── coreai.json # Project configuration
390
+ └── .mcp.json # MCP server configuration
391
+ ```
392
+
393
+ ---
394
+
395
+ ## Key Design Decisions
396
+
397
+ ### 1. Engineers Own Ticket Lifecycle
398
+
399
+ The Engineering Manager delegates tasks but does NOT move tickets through states. Engineers are responsible for:
400
+
401
+ - Moving ticket to "In Progress" when starting
402
+ - Creating the PR
403
+ - Moving ticket to "In Review" when PR is ready
404
+
405
+ This reduces back-and-forth and gives engineers ownership.
406
+
407
+ ### 2. File-Based Over Database
408
+
409
+ Using files for communication instead of a database:
410
+
411
+ - **Pro:** Works offline, no infrastructure needed
412
+ - **Pro:** Human-readable, auditable
413
+ - **Pro:** Git-trackable for history
414
+ - **Con:** No real-time notifications
415
+ - **Con:** Requires manual processing
416
+
417
+ ### 3. Validation Checkpoints
418
+
419
+ The EM validates completion reports before assigning reviewers:
420
+
421
+ - Ticket is in correct state
422
+ - PR exists and CI is passing
423
+ - All acceptance criteria addressed
424
+
425
+ This catches issues early and enforces workflow compliance.
426
+
427
+ ### 4. Quality-Gated Commits
428
+
429
+ The `/git-commit` command requires all quality checks to pass:
430
+
431
+ 1. ktlint/linting
432
+ 2. Static analysis (detekt)
433
+ 3. Unit tests
434
+ 4. Build
435
+
436
+ This prevents broken code from being committed.
437
+
438
+ ---
439
+
440
+ ## Modifying the Framework
441
+
442
+ ### Adding a New Command
443
+
444
+ 1. Create `coreai/commands/core/<command>.md` or `optional/<command>.md`
445
+ 2. Add placeholders for project-specific values
446
+ 3. Update `install.sh` to copy the command
447
+ 4. Update `README.md` command list
448
+
449
+ ### Adding a New Agent Template
450
+
451
+ 1. Create `coreai/agents/_templates/<type>.md`
452
+ 2. Include startup protocol, work patterns, completion protocol
453
+ 3. Use `{{AGENT_NAME}}` and other placeholders
454
+ 4. Update `add-agent.sh` to support the new type
455
+
456
+ ### Adding a New Placeholder
457
+
458
+ 1. Add to `coreai.json` template (`templates/project-files/coreai.json.example`)
459
+ 2. Add `sed` replacement in `install.sh` and `add-agent.sh`
460
+ 3. Document in this file's Placeholders section
461
+
462
+ ### Changing Workflow States
463
+
464
+ 1. Update `coreai/WORKFLOWS.md` with new states
465
+ 2. Update affected commands (especially `/jira-transition`)
466
+ 3. Update agent templates that reference workflows
467
+
468
+ ### Adding MCP Integration
469
+
470
+ 1. Add server config to `templates/project-files/mcp.json.template`
471
+ 2. Document required environment variables
472
+ 3. Update agent frontmatter to include new tools
473
+ 4. Add usage examples to relevant commands
474
+
475
+ ---
476
+
477
+ ## Troubleshooting
478
+
479
+ ### Agent Can't Access Jira/GitHub
480
+
481
+ **Cause:** Agent was invoked via Task tool instead of directly.
482
+
483
+ **Fix:** Always use `@agent-name` to invoke agents, never Task tool.
484
+
485
+ ### Placeholders Not Replaced
486
+
487
+ **Cause:** `sed` command failed or placeholder syntax wrong.
488
+
489
+ **Fix:** Check for typos in placeholder names. Ensure `{{` and `}}` are used.
490
+
491
+ ### Inbox Messages Not Found
492
+
493
+ **Cause:** Wrong directory path or filename convention.
494
+
495
+ **Fix:** Verify KnowledgeLibrary structure exists. Check filename follows `YYYYMMDD_HHMM-agent-subject.md` format.
496
+
497
+ ### Quality Checks Failing
498
+
499
+ **Cause:** Commands in `coreai.json` don't match project setup.
500
+
501
+ **Fix:** Update `qualityChecks` in `coreai.json` to match actual project commands.
502
+
503
+ ---
504
+
505
+ ## CLI Development Status
506
+
507
+ The CoreAI CLI (`@deimoscloud/coreai`) is under active development. Current implementation status:
508
+
509
+ ### Implemented
510
+
511
+ - **Configuration System** - YAML-based config loading with environment variable support
512
+ - **Agent System** - Agent definition loading, compilation, and resolution
513
+ - **Adapter Interfaces** - Abstract interfaces for issue trackers, git providers, documentation, and state
514
+ - **MCP Integration** - Server discovery, client wrapper, and tool-to-adapter mapping
515
+ - **MCP Server Registry** - Central registry for managing MCP server connections
516
+ - **Native Adapter Fallbacks** - Filesystem and GitHub adapters when MCP servers unavailable
517
+ - **Cache System** - CacheProvider interface, FileCacheProvider implementation with full CRUD operations
518
+ - **Context Loader** - CacheManager and ContextLoader with cache-first resolution strategy
519
+ - **Sync Commands** - `coreai sync`, `coreai cache clear`, `coreai cache status` CLI commands
520
+ - **Command Framework** - Command registration, runtime config, graceful degradation
521
+ - **Core CLI Commands** - `coreai init`, `coreai build`, `coreai validate`
522
+ - **Skill Generation** - Generate Claude skills from config to `.claude/commands/`
523
+ - **KnowledgeLibrary** - Local agent state management with inbox/outbox directories
524
+ - **State Commands** - `coreai status` for agent states and pending messages
525
+ - **CLI Binary** - Complete command-line interface with all Phase 1 commands
526
+
527
+ ### CLI Commands Reference
528
+
529
+ | Command | Description |
530
+ |---------|-------------|
531
+ | `coreai init` | Initialize a new CoreAI project |
532
+ | `coreai build` | Compile agent definitions to `.claude/agents/` |
533
+ | `coreai build --init-knowledge-library` | Build agents + create KnowledgeLibrary directories |
534
+ | `coreai validate` | Validate config and project setup |
535
+ | `coreai status` | Show agent states and pending messages |
536
+ | `coreai status --detailed` | Show detailed message information |
537
+ | `coreai sync` | Sync shared context from remote sources |
538
+ | `coreai cache status` | Show cache statistics |
539
+ | `coreai cache clear` | Clear the local cache |
540
+ | `coreai agents list` | List available agents |
541
+ | `coreai agents show <name>` | Show agent details |
542
+ | `coreai skills generate` | Generate Claude skills from templates |
543
+ | `coreai skills list` | List available skills |
544
+
545
+ ---
546
+
547
+ *Last Updated: 2026-01-22*