@kinqs/brainrouter-mcp-server 0.3.4

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 (337) hide show
  1. package/.env.example +144 -0
  2. package/README.md +56 -0
  3. package/agents/README.md +120 -0
  4. package/agents/code-reviewer.md +97 -0
  5. package/agents/security-auditor.md +101 -0
  6. package/agents/test-engineer.md +95 -0
  7. package/dist/__tests__/agent_mode.test.d.ts +1 -0
  8. package/dist/__tests__/api-routes.test.d.ts +1 -0
  9. package/dist/__tests__/api-routes.test.js +170 -0
  10. package/dist/__tests__/crypto.test.d.ts +1 -0
  11. package/dist/__tests__/crypto.test.js +28 -0
  12. package/dist/__tests__/host-integrations.test.d.ts +1 -0
  13. package/dist/__tests__/host-integrations.test.js +82 -0
  14. package/dist/__tests__/integration.test.d.ts +1 -0
  15. package/dist/__tests__/integration.test.js +50 -0
  16. package/dist/__tests__/loader.test.d.ts +1 -0
  17. package/dist/__tests__/loader.test.js +89 -0
  18. package/dist/__tests__/neural-spark.test.d.ts +1 -0
  19. package/dist/__tests__/neural-spark.test.js +112 -0
  20. package/dist/__tests__/pagination.test.d.ts +1 -0
  21. package/dist/__tests__/pagination.test.js +23 -0
  22. package/dist/__tests__/redaction.test.d.ts +1 -0
  23. package/dist/__tests__/redaction.test.js +17 -0
  24. package/dist/__tests__/registry.test.d.ts +1 -0
  25. package/dist/__tests__/registry.test.js +56 -0
  26. package/dist/__tests__/retry.test.d.ts +1 -0
  27. package/dist/__tests__/retry.test.js +30 -0
  28. package/dist/__tests__/skill-activation.test.d.ts +1 -0
  29. package/dist/__tests__/skill-activation.test.js +112 -0
  30. package/dist/__tests__/working-memory.test.d.ts +1 -0
  31. package/dist/__tests__/working-memory.test.js +200 -0
  32. package/dist/__tests__/workspace-paths.test.d.ts +1 -0
  33. package/dist/__tests__/workspace-paths.test.js +56 -0
  34. package/dist/__tests__/writer.test.d.ts +1 -0
  35. package/dist/__tests__/writer.test.js +94 -0
  36. package/dist/api/auth/crypto.d.ts +4 -0
  37. package/dist/api/auth/crypto.js +54 -0
  38. package/dist/api/middleware/auth.d.ts +12 -0
  39. package/dist/api/middleware/auth.js +90 -0
  40. package/dist/api/pagination.d.ts +18 -0
  41. package/dist/api/pagination.js +32 -0
  42. package/dist/api/routes/auth.d.ts +1 -0
  43. package/dist/api/routes/auth.js +130 -0
  44. package/dist/api/routes/chat-completions.d.ts +7 -0
  45. package/dist/api/routes/chat-completions.js +474 -0
  46. package/dist/api/routes/contradictions.d.ts +1 -0
  47. package/dist/api/routes/contradictions.js +28 -0
  48. package/dist/api/routes/evidence.d.ts +1 -0
  49. package/dist/api/routes/evidence.js +59 -0
  50. package/dist/api/routes/governance.d.ts +1 -0
  51. package/dist/api/routes/governance.js +95 -0
  52. package/dist/api/routes/graph.d.ts +1 -0
  53. package/dist/api/routes/graph.js +25 -0
  54. package/dist/api/routes/hooks.d.ts +1 -0
  55. package/dist/api/routes/hooks.js +88 -0
  56. package/dist/api/routes/memories.d.ts +1 -0
  57. package/dist/api/routes/memories.js +92 -0
  58. package/dist/api/routes/persona.d.ts +1 -0
  59. package/dist/api/routes/persona.js +9 -0
  60. package/dist/api/routes/scenes.d.ts +1 -0
  61. package/dist/api/routes/scenes.js +35 -0
  62. package/dist/api/routes/skills.d.ts +1 -0
  63. package/dist/api/routes/skills.js +14 -0
  64. package/dist/api/routes/stats.d.ts +1 -0
  65. package/dist/api/routes/stats.js +8 -0
  66. package/dist/api/routes/users.d.ts +1 -0
  67. package/dist/api/routes/users.js +82 -0
  68. package/dist/api/routes/working.d.ts +1 -0
  69. package/dist/api/routes/working.js +88 -0
  70. package/dist/index.d.ts +2 -0
  71. package/dist/index.js +492 -0
  72. package/dist/integrations/claude-code.d.ts +12 -0
  73. package/dist/integrations/claude-code.js +35 -0
  74. package/dist/integrations/codex.d.ts +12 -0
  75. package/dist/integrations/codex.js +34 -0
  76. package/dist/integrations/generic-mcp.d.ts +52 -0
  77. package/dist/integrations/generic-mcp.js +118 -0
  78. package/dist/loader.d.ts +29 -0
  79. package/dist/loader.js +200 -0
  80. package/dist/memory/capture.d.ts +35 -0
  81. package/dist/memory/capture.js +230 -0
  82. package/dist/memory/config.d.ts +2 -0
  83. package/dist/memory/config.js +3 -0
  84. package/dist/memory/engine.d.ts +203 -0
  85. package/dist/memory/engine.js +626 -0
  86. package/dist/memory/llm-semaphore.d.ts +41 -0
  87. package/dist/memory/llm-semaphore.js +81 -0
  88. package/dist/memory/memory-type-config.d.ts +11 -0
  89. package/dist/memory/memory-type-config.js +65 -0
  90. package/dist/memory/pipeline/cognitive-contradiction.d.ts +7 -0
  91. package/dist/memory/pipeline/cognitive-contradiction.js +59 -0
  92. package/dist/memory/pipeline/cognitive-dedup.d.ts +23 -0
  93. package/dist/memory/pipeline/cognitive-dedup.js +38 -0
  94. package/dist/memory/pipeline/cognitive-extractor.d.ts +21 -0
  95. package/dist/memory/pipeline/cognitive-extractor.js +183 -0
  96. package/dist/memory/pipeline/contextual-focus-builder.d.ts +13 -0
  97. package/dist/memory/pipeline/contextual-focus-builder.js +135 -0
  98. package/dist/memory/pipeline/focus-direction-shift.d.ts +10 -0
  99. package/dist/memory/pipeline/focus-direction-shift.js +27 -0
  100. package/dist/memory/pipeline/graph-builder.d.ts +11 -0
  101. package/dist/memory/pipeline/graph-builder.js +88 -0
  102. package/dist/memory/pipeline/graph-recall.d.ts +13 -0
  103. package/dist/memory/pipeline/graph-recall.js +55 -0
  104. package/dist/memory/pipeline/identity-distiller.d.ts +15 -0
  105. package/dist/memory/pipeline/identity-distiller.js +40 -0
  106. package/dist/memory/pipeline/l1-contradiction.d.ts +7 -0
  107. package/dist/memory/pipeline/l1-contradiction.js +66 -0
  108. package/dist/memory/pipeline/l1-dedup.d.ts +23 -0
  109. package/dist/memory/pipeline/l1-dedup.js +39 -0
  110. package/dist/memory/pipeline/l1-extractor.d.ts +21 -0
  111. package/dist/memory/pipeline/l1-extractor.js +180 -0
  112. package/dist/memory/pipeline/l2-direction-shift.d.ts +10 -0
  113. package/dist/memory/pipeline/l2-direction-shift.js +27 -0
  114. package/dist/memory/pipeline/l2-scene.d.ts +15 -0
  115. package/dist/memory/pipeline/l2-scene.js +140 -0
  116. package/dist/memory/pipeline/l3-distiller.d.ts +15 -0
  117. package/dist/memory/pipeline/l3-distiller.js +40 -0
  118. package/dist/memory/pipeline/neural-spark.d.ts +27 -0
  119. package/dist/memory/pipeline/neural-spark.js +78 -0
  120. package/dist/memory/pipeline/skill-prewarm.d.ts +63 -0
  121. package/dist/memory/pipeline/skill-prewarm.js +127 -0
  122. package/dist/memory/pipeline/task-queue.d.ts +54 -0
  123. package/dist/memory/pipeline/task-queue.js +117 -0
  124. package/dist/memory/prompts/cognitive-contradiction.d.ts +1 -0
  125. package/dist/memory/prompts/cognitive-contradiction.js +25 -0
  126. package/dist/memory/prompts/cognitive-extraction.d.ts +10 -0
  127. package/dist/memory/prompts/cognitive-extraction.js +114 -0
  128. package/dist/memory/prompts/core-identity.d.ts +6 -0
  129. package/dist/memory/prompts/core-identity.js +60 -0
  130. package/dist/memory/prompts/focus-direction-shift.d.ts +5 -0
  131. package/dist/memory/prompts/focus-direction-shift.js +32 -0
  132. package/dist/memory/prompts/focus-scene-cluster.d.ts +2 -0
  133. package/dist/memory/prompts/focus-scene-cluster.js +33 -0
  134. package/dist/memory/prompts/focus-scene.d.ts +7 -0
  135. package/dist/memory/prompts/focus-scene.js +40 -0
  136. package/dist/memory/prompts/graph-extraction-batch.d.ts +14 -0
  137. package/dist/memory/prompts/graph-extraction-batch.js +54 -0
  138. package/dist/memory/prompts/graph-extraction.d.ts +2 -0
  139. package/dist/memory/prompts/graph-extraction.js +53 -0
  140. package/dist/memory/prompts/l1-contradiction-batch.d.ts +16 -0
  141. package/dist/memory/prompts/l1-contradiction-batch.js +47 -0
  142. package/dist/memory/prompts/l1-contradiction.d.ts +1 -0
  143. package/dist/memory/prompts/l1-contradiction.js +25 -0
  144. package/dist/memory/prompts/l1-extraction.d.ts +10 -0
  145. package/dist/memory/prompts/l1-extraction.js +114 -0
  146. package/dist/memory/prompts/l2-direction-shift.d.ts +5 -0
  147. package/dist/memory/prompts/l2-direction-shift.js +32 -0
  148. package/dist/memory/prompts/l2-scene-cluster.d.ts +2 -0
  149. package/dist/memory/prompts/l2-scene-cluster.js +33 -0
  150. package/dist/memory/prompts/l2-scene.d.ts +7 -0
  151. package/dist/memory/prompts/l2-scene.js +40 -0
  152. package/dist/memory/prompts/l3-persona.d.ts +6 -0
  153. package/dist/memory/prompts/l3-persona.js +60 -0
  154. package/dist/memory/recall.d.ts +47 -0
  155. package/dist/memory/recall.js +427 -0
  156. package/dist/memory/redaction.d.ts +1 -0
  157. package/dist/memory/redaction.js +24 -0
  158. package/dist/memory/retry.d.ts +13 -0
  159. package/dist/memory/retry.js +53 -0
  160. package/dist/memory/scheduler.d.ts +9 -0
  161. package/dist/memory/scheduler.js +16 -0
  162. package/dist/memory/skill-hints-loader.d.ts +30 -0
  163. package/dist/memory/skill-hints-loader.js +100 -0
  164. package/dist/memory/store/embedding.d.ts +16 -0
  165. package/dist/memory/store/embedding.js +68 -0
  166. package/dist/memory/store/reranker.d.ts +24 -0
  167. package/dist/memory/store/reranker.js +83 -0
  168. package/dist/memory/store/sqlite.d.ts +167 -0
  169. package/dist/memory/store/sqlite.js +1816 -0
  170. package/dist/memory/store/types.d.ts +101 -0
  171. package/dist/memory/store/types.js +1 -0
  172. package/dist/memory/types.d.ts +207 -0
  173. package/dist/memory/types.js +7 -0
  174. package/dist/memory/validation.d.ts +441 -0
  175. package/dist/memory/validation.js +129 -0
  176. package/dist/memory/working/canvas.d.ts +5 -0
  177. package/dist/memory/working/canvas.js +43 -0
  178. package/dist/memory/working/offload.d.ts +71 -0
  179. package/dist/memory/working/offload.js +211 -0
  180. package/dist/memory/working/step-log.d.ts +16 -0
  181. package/dist/memory/working/step-log.js +35 -0
  182. package/dist/registry.d.ts +34 -0
  183. package/dist/registry.js +305 -0
  184. package/dist/resolver.d.ts +17 -0
  185. package/dist/resolver.js +126 -0
  186. package/dist/scripts/validate-foreign-workspace-path.d.ts +1 -0
  187. package/dist/scripts/validate-foreign-workspace-path.js +39 -0
  188. package/dist/tools/agent_memory_tools.d.ts +485 -0
  189. package/dist/tools/agent_memory_tools.js +793 -0
  190. package/dist/tools/create_skill.d.ts +46 -0
  191. package/dist/tools/create_skill.js +46 -0
  192. package/dist/tools/get_doc.d.ts +21 -0
  193. package/dist/tools/get_doc.js +24 -0
  194. package/dist/tools/get_persona.d.ts +15 -0
  195. package/dist/tools/get_persona.js +20 -0
  196. package/dist/tools/get_reference.d.ts +15 -0
  197. package/dist/tools/get_reference.js +20 -0
  198. package/dist/tools/get_skill.d.ts +34 -0
  199. package/dist/tools/get_skill.js +65 -0
  200. package/dist/tools/get_template_doc.d.ts +21 -0
  201. package/dist/tools/get_template_doc.js +24 -0
  202. package/dist/tools/list_docs.d.ts +15 -0
  203. package/dist/tools/list_docs.js +16 -0
  204. package/dist/tools/list_skills.d.ts +18 -0
  205. package/dist/tools/list_skills.js +17 -0
  206. package/dist/tools/list_template_docs.d.ts +15 -0
  207. package/dist/tools/list_template_docs.js +16 -0
  208. package/dist/tools/memory-engineering.d.ts +225 -0
  209. package/dist/tools/memory-engineering.js +284 -0
  210. package/dist/tools/memory-explain.d.ts +34 -0
  211. package/dist/tools/memory-explain.js +109 -0
  212. package/dist/tools/memory-governance.d.ts +171 -0
  213. package/dist/tools/memory-governance.js +224 -0
  214. package/dist/tools/memory-hooks.d.ts +67 -0
  215. package/dist/tools/memory-hooks.js +102 -0
  216. package/dist/tools/memory-working.d.ts +98 -0
  217. package/dist/tools/memory-working.js +101 -0
  218. package/dist/tools/memory_capture_turn.d.ts +66 -0
  219. package/dist/tools/memory_capture_turn.js +85 -0
  220. package/dist/tools/memory_consolidate.d.ts +55 -0
  221. package/dist/tools/memory_consolidate.js +176 -0
  222. package/dist/tools/memory_contradictions.d.ts +53 -0
  223. package/dist/tools/memory_contradictions.js +52 -0
  224. package/dist/tools/memory_graph_query.d.ts +51 -0
  225. package/dist/tools/memory_graph_query.js +35 -0
  226. package/dist/tools/memory_mark_cited.d.ts +43 -0
  227. package/dist/tools/memory_mark_cited.js +63 -0
  228. package/dist/tools/memory_recall.d.ts +77 -0
  229. package/dist/tools/memory_recall.js +81 -0
  230. package/dist/tools/memory_register_skill_hints.d.ts +49 -0
  231. package/dist/tools/memory_register_skill_hints.js +55 -0
  232. package/dist/tools/memory_resolve_session.d.ts +24 -0
  233. package/dist/tools/memory_resolve_session.js +133 -0
  234. package/dist/tools/memory_search.d.ts +146 -0
  235. package/dist/tools/memory_search.js +84 -0
  236. package/dist/tools/search_skills.d.ts +18 -0
  237. package/dist/tools/search_skills.js +17 -0
  238. package/dist/tools/update_doc.d.ts +24 -0
  239. package/dist/tools/update_doc.js +35 -0
  240. package/dist/tools/update_skill.d.ts +30 -0
  241. package/dist/tools/update_skill.js +80 -0
  242. package/dist/types.d.ts +81 -0
  243. package/dist/types.js +4 -0
  244. package/dist/writer.d.ts +30 -0
  245. package/dist/writer.js +220 -0
  246. package/docs/TEMPLATE ONLY +1 -0
  247. package/docs/api/API.md +64 -0
  248. package/docs/api/security/SECURITY.md +58 -0
  249. package/docs/deployment/DockerDeployment.md +30 -0
  250. package/docs/design/Design.md +59 -0
  251. package/docs/design/themes/apple.md +101 -0
  252. package/docs/design/themes/dieter-grid.md +100 -0
  253. package/docs/design/themes/gallery-white.md +100 -0
  254. package/docs/design/themes/pinterest.md +101 -0
  255. package/docs/design/themes/realty-open-house.md +101 -0
  256. package/docs/design/themes/vodafone.md +101 -0
  257. package/docs/hooks/Hooks.md +30 -0
  258. package/docs/schema/Schema.md +35 -0
  259. package/docs/strategy/ScalingStrategy.md +19 -0
  260. package/package.json +88 -0
  261. package/references/accessibility-checklist.md +160 -0
  262. package/references/orchestration-patterns.md +370 -0
  263. package/references/performance-checklist.md +153 -0
  264. package/references/security-checklist.md +134 -0
  265. package/references/testing-patterns.md +236 -0
  266. package/skills/agent/adr-skill/SKILL.md +299 -0
  267. package/skills/agent/agentic-engineering-workflow/SKILL.md +95 -0
  268. package/skills/agent/bootstrap-skill/SKILL.md +103 -0
  269. package/skills/agent/context-engineering/SKILL.md +307 -0
  270. package/skills/agent/debugging-and-error-recovery/SKILL.md +308 -0
  271. package/skills/agent/developer-growth-analysis/SKILL.md +328 -0
  272. package/skills/agent/doubt-driven-skill/SKILL.md +249 -0
  273. package/skills/agent/handover-skill/SKILL.md +112 -0
  274. package/skills/agent/idea-refine-skill/SKILL.md +185 -0
  275. package/skills/agent/idea-refine-skill/examples.md +238 -0
  276. package/skills/agent/idea-refine-skill/frameworks.md +99 -0
  277. package/skills/agent/idea-refine-skill/refinement-criteria.md +113 -0
  278. package/skills/agent/interview-skill/SKILL.md +226 -0
  279. package/skills/agent/planning-skill/SKILL.md +270 -0
  280. package/skills/agent/skill-authoring/SKILL.md +189 -0
  281. package/skills/agent/source-driven-skill/SKILL.md +197 -0
  282. package/skills/agent/spec-driven-skill/SKILL.md +221 -0
  283. package/skills/agent/sync-skill/SKILL.md +92 -0
  284. package/skills/agent/using-agent-skills/SKILL.md +189 -0
  285. package/skills/api/a11y-skill/SKILL.md +88 -0
  286. package/skills/api/api-skill/SKILL.md +123 -0
  287. package/skills/api/auth-skill/SKILL.md +80 -0
  288. package/skills/api/debug-skill/SKILL.md +535 -0
  289. package/skills/api/performance-skill/SKILL.md +100 -0
  290. package/skills/api/testing-skill/SKILL.md +100 -0
  291. package/skills/codebase/code-review-and-quality/SKILL.md +228 -0
  292. package/skills/codebase/code-simplification/SKILL.md +352 -0
  293. package/skills/codebase/code-structure-cleanup/SKILL.md +142 -0
  294. package/skills/codebase/concerns-skill/SKILL.md +89 -0
  295. package/skills/codebase/conventions-skill/SKILL.md +95 -0
  296. package/skills/codebase/doc-management-skill/SKILL.md +47 -0
  297. package/skills/codebase/git-workflow-skill/SKILL.md +312 -0
  298. package/skills/communication/1-3-1-rule/SKILL.md +120 -0
  299. package/skills/design/brutalist-skill/SKILL.md +131 -0
  300. package/skills/design/concept-diagrams/SKILL.md +387 -0
  301. package/skills/design/concept-diagrams/examples/apartment-floor-plan-conversion.md +244 -0
  302. package/skills/design/concept-diagrams/examples/automated-password-reset-flow.md +276 -0
  303. package/skills/design/concept-diagrams/examples/autonomous-llm-research-agent-flow.md +240 -0
  304. package/skills/design/concept-diagrams/examples/banana-journey-tree-to-smoothie.md +161 -0
  305. package/skills/design/concept-diagrams/examples/commercial-aircraft-structure.md +209 -0
  306. package/skills/design/concept-diagrams/examples/cpu-ooo-microarchitecture.md +236 -0
  307. package/skills/design/concept-diagrams/examples/electricity-grid-flow.md +182 -0
  308. package/skills/design/concept-diagrams/examples/feature-film-production-pipeline.md +172 -0
  309. package/skills/design/concept-diagrams/examples/hospital-emergency-department-flow.md +165 -0
  310. package/skills/design/concept-diagrams/examples/ml-benchmark-grouped-bar-chart.md +114 -0
  311. package/skills/design/concept-diagrams/examples/place-order-uml-sequence.md +325 -0
  312. package/skills/design/concept-diagrams/examples/smart-city-infrastructure.md +173 -0
  313. package/skills/design/concept-diagrams/examples/smartphone-layer-anatomy.md +154 -0
  314. package/skills/design/concept-diagrams/examples/sn2-reaction-mechanism.md +247 -0
  315. package/skills/design/concept-diagrams/examples/wind-turbine-structure.md +338 -0
  316. package/skills/design/concept-diagrams/references/dashboard-patterns.md +43 -0
  317. package/skills/design/concept-diagrams/references/infrastructure-patterns.md +144 -0
  318. package/skills/design/concept-diagrams/references/physical-shape-cookbook.md +42 -0
  319. package/skills/design/concept-diagrams/templates/template.html +174 -0
  320. package/skills/design/gpt-tasteskill/SKILL.md +114 -0
  321. package/skills/design/minimalist-skill/SKILL.md +116 -0
  322. package/skills/design/output-skill/SKILL.md +87 -0
  323. package/skills/design/redesign-skill/SKILL.md +213 -0
  324. package/skills/design/soft-skill/SKILL.md +132 -0
  325. package/skills/design/stitch-skill/EXAMPLE.md +121 -0
  326. package/skills/design/stitch-skill/SKILL.md +222 -0
  327. package/skills/design/taste-skill/SKILL.md +269 -0
  328. package/skills/devops/ci-cd-skill/SKILL.md +402 -0
  329. package/skills/devops/docker-skill/SKILL.md +297 -0
  330. package/skills/devops/domain-skill/SKILL.md +234 -0
  331. package/skills/lifecycle/changelog-generator/SKILL.md +135 -0
  332. package/skills/lifecycle/incremental-skill/SKILL.md +257 -0
  333. package/skills/lifecycle/migration-skill/SKILL.md +218 -0
  334. package/skills/lifecycle/shipping-skill/SKILL.md +321 -0
  335. package/skills/memory/agent-memory/SKILL.md +122 -0
  336. package/skills/qa/browser-testing-skill/SKILL.md +314 -0
  337. package/skills/ux/adversarial-ux-skill/SKILL.md +168 -0
package/.env.example ADDED
@@ -0,0 +1,144 @@
1
+ # BrainRouter MCP server — environment
2
+ #
3
+ # Copy to brainrouter/.env. Loaded automatically by `dotenv/config` when the
4
+ # MCP server starts (the CLI sets the spawned child's cwd to this folder so
5
+ # stdio-launched MCPs also pick it up).
6
+ #
7
+ # This file is for MCP-SERVER concerns only:
8
+ # - cognitive extraction / synthesis LLM
9
+ # - embedding provider
10
+ # - reranker provider
11
+ # - memory engine knobs (decay, sweeper, focus, identity)
12
+ # - server auth (JWT, admin seed, CORS)
13
+ #
14
+ # CLI agent knobs (sandbox, tool loop limits, web search, etc.) live in
15
+ # brainrouter-cli/.env.example. Keep them separate so the two processes
16
+ # can be configured independently.
17
+
18
+ # ==========================================
19
+ # LLM (cognitive extraction + synthesis)
20
+ # ==========================================
21
+ # Used by L1 extraction, contradiction checks, graph extraction, L2 scenes,
22
+ # L3 persona synthesis. Falls back to OPENAI_API_KEY.
23
+ BRAINROUTER_LLM_API_KEY=your_api_key_here
24
+
25
+ # OpenAI-compatible chat-completions endpoint.
26
+ # Examples:
27
+ # OpenAI: https://api.openai.com/v1/chat/completions
28
+ # OpenRouter: https://openrouter.ai/api/v1/chat/completions
29
+ # LM Studio: http://localhost:1234/v1/chat/completions
30
+ # Ollama: http://localhost:11434/v1/chat/completions
31
+ BRAINROUTER_LLM_ENDPOINT=https://api.openai.com/v1/chat/completions
32
+
33
+ BRAINROUTER_LLM_MODEL=gpt-4o-mini
34
+
35
+ # Optional model split.
36
+ # BRAINROUTER_EXTRACTION_MODEL=gpt-4o-mini
37
+ # BRAINROUTER_SYNTHESIS_MODEL=gpt-4o
38
+
39
+ # Per-call timeout for MCP-side LLM calls. Default: 120000.
40
+ # BRAINROUTER_LLM_TIMEOUT_MS=120000
41
+
42
+ # Cap on concurrent in-flight LLM calls FROM THE MCP PROCESS.
43
+ # Default: 2 (set to 1 on consumer hardware running LM Studio with a single model).
44
+ # BRAINROUTER_LLM_MAX_CONCURRENT=2
45
+
46
+ # ==========================================
47
+ # Embeddings (vector search)
48
+ # ==========================================
49
+ # Falls back to BRAINROUTER_LLM_API_KEY when omitted.
50
+ # Vector search is disabled if no key is available.
51
+ # BRAINROUTER_EMBEDDING_API_KEY=
52
+ BRAINROUTER_EMBEDDING_ENDPOINT=https://api.openai.com/v1/embeddings
53
+ BRAINROUTER_EMBEDDING_MODEL=text-embedding-3-small
54
+ BRAINROUTER_EMBEDDING_DIMENSIONS=1536
55
+
56
+ # ==========================================
57
+ # Reranker (optional)
58
+ # ==========================================
59
+ # Disabled unless a key is present.
60
+ # BRAINROUTER_RERANKER_API_KEY=
61
+ # BRAINROUTER_RERANKER_ENDPOINT=https://api.cohere.com/v1/rerank
62
+ # BRAINROUTER_RERANKER_MODEL=rerank-english-v3.0
63
+ # BRAINROUTER_RERANKER_TOP_N=10
64
+
65
+ # ==========================================
66
+ # Storage
67
+ # ==========================================
68
+ # SQLite memory store path. Default: ~/.brainrouter/memory.db.
69
+ # BRAINROUTER_MEMORY_DB=/Users/you/.brainrouter/memory.db
70
+
71
+ # Override per-user state root. Default: ~/.brainrouter.
72
+ # BRAINROUTER_HOME=/path/to/state
73
+
74
+ # Workspace root when MCP --root is omitted.
75
+ # BRAINROUTER_LOCAL_ROOT=/path/to/your/project
76
+
77
+ # ==========================================
78
+ # Memory engine
79
+ # ==========================================
80
+ # Set false to disable GraphRAG (2-hop entity expansion). Default: true.
81
+ # BRAINROUTER_GRAPH_ENABLED=true
82
+ # BRAINROUTER_GRAPH_TIMEOUT_MS=120000
83
+ # BRAINROUTER_CONTRADICTION_TIMEOUT_MS=60000
84
+
85
+ # Memories recalled this many times without citation are auto-archived.
86
+ # 0 disables. Default: 10.
87
+ # BRAINROUTER_ACE_ARCHIVE_THRESHOLD=10
88
+
89
+ # Focus-scene distillation trigger (new records before scenes rebuild).
90
+ # BRAINROUTER_FOCUS_TRIGGER_N=10
91
+ # BRAINROUTER_MAX_FOCUS_SCENES=20
92
+
93
+ # Identity (persona) distillation trigger.
94
+ # BRAINROUTER_IDENTITY_TRIGGER_N=50
95
+ # BRAINROUTER_PERSONA_CACHE_TTL_MS=3600000
96
+
97
+ # ==========================================
98
+ # Skill pre-warming
99
+ # ==========================================
100
+ # BRAINROUTER_PREWARM_ENABLED=false
101
+ # BRAINROUTER_SKILL_HALF_LIFE_MINUTES=10
102
+ # BRAINROUTER_SKILL_MIN_TURN_DECAY=0.05
103
+ # BRAINROUTER_SKILL_PREWARM_THRESHOLD=0.3
104
+ # BRAINROUTER_SKILL_SPIKE_AMOUNT=1.0
105
+ # BRAINROUTER_SKILL_MAX_POTENTIAL=4.0
106
+
107
+ # ==========================================
108
+ # Extraction backlog sweeper
109
+ # ==========================================
110
+ # BRAINROUTER_DISABLE_EXTRACTION_SWEEPER=false
111
+ # BRAINROUTER_EXTRACTION_SWEEP_INTERVAL_MS=300000 # floored at 30000
112
+ # BRAINROUTER_EXTRACTION_SWEEP_MIN_AGE_MS=120000
113
+ # BRAINROUTER_EXTRACTION_MAX_FAILURES=5
114
+
115
+ # ==========================================
116
+ # Server auth
117
+ # ==========================================
118
+ # Seeded admin (used when the users table is empty and by scripts/setup-admin.js).
119
+ BRAINROUTER_DEFAULT_ADMIN_USER_ID=admin
120
+ BRAINROUTER_ADMIN_EMAIL=admin@example.com
121
+ BRAINROUTER_ADMIN_PASSWORD=change_me_before_use
122
+
123
+ # JWT signing key for dashboard sessions.
124
+ # Generate one with:
125
+ # node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
126
+ # If unset, the server generates a random secret per boot — sessions do not survive restarts.
127
+ BRAINROUTER_JWT_SECRET=replace_with_a_long_random_secret
128
+ # BRAINROUTER_JWT_EXPIRES_SECS=86400
129
+
130
+ # Dashboard CORS allowlist.
131
+ BRAINROUTER_CORS_ORIGIN=http://localhost:3000
132
+
133
+ # API key for HTTP MCP transport clients. Usually set in the client config,
134
+ # not here. Reset with: npm run setup:admin -- --reset --userId admin.
135
+ # BRAINROUTER_API_KEY=br_your_api_key
136
+
137
+ # Stdio fallback user id when no authenticated user mapping is available.
138
+ # Prefer BRAINROUTER_API_KEY instead.
139
+ # BRAINROUTER_USER_ID=default
140
+
141
+ # ==========================================
142
+ # Dashboard (read by web/, not by this server)
143
+ # ==========================================
144
+ # NEXT_PUBLIC_API_URL=http://localhost:3747
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # @kinqs/brainrouter-mcp-server
2
+
3
+ The cognitive memory engine behind [BrainRouter](https://github.com/kinqsradiollc/BrainRouter) — exposed as a [Model Context Protocol](https://modelcontextprotocol.io/) server so any MCP-speaking agent (Claude Desktop, Cursor, [`@kinqs/brainrouter-cli`](https://www.npmjs.com/package/@kinqs/brainrouter-cli), custom clients) can recall, capture, and reason over long-term memory.
4
+
5
+ ## What it gives you
6
+
7
+ - **Long-term memory** — sensory log + cognitive extraction (L1 facts, L2 focus scenes, L3 persona) with decay, contradiction tracking, and citation reinforcement.
8
+ - **Recall surface** — `memory_recall`, `memory_search`, `memory_graph_query`, `memory_file_history`, `memory_failed_attempts`, `memory_explain_recall`.
9
+ - **Working memory** — `memory_working_context` / `memory_working_offload` for in-flight payloads that shouldn't bloat the LLM context.
10
+ - **Skill catalogue** — `list_skills`, `get_skill`, `search_skills`, `get_persona` — ships with 70+ canonical skills bundled at publish time.
11
+ - **HTTP and stdio transports** — run as a hosted service (HTTP/SSE) or spawn as a stdio child from any MCP client.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install @kinqs/brainrouter-mcp-server
17
+ ```
18
+
19
+ ## Run
20
+
21
+ ```bash
22
+ # HTTP transport on :3747
23
+ npx brainrouter-mcp --http --port 3747
24
+
25
+ # stdio (default — for clients that spawn the server themselves)
26
+ npx brainrouter-mcp
27
+ ```
28
+
29
+ ## Configure
30
+
31
+ Copy `.env.example` to `.env` and set at minimum:
32
+
33
+ ```bash
34
+ BRAINROUTER_LLM_API_KEY=sk-...
35
+ BRAINROUTER_LLM_ENDPOINT=https://api.openai.com/v1/chat/completions
36
+ BRAINROUTER_LLM_MODEL=gpt-4o-mini
37
+
38
+ BRAINROUTER_EMBEDDING_ENDPOINT=https://api.openai.com/v1/embeddings
39
+ BRAINROUTER_EMBEDDING_MODEL=text-embedding-3-small
40
+ BRAINROUTER_EMBEDDING_DIMENSIONS=1536
41
+
42
+ BRAINROUTER_ADMIN_PASSWORD=change_me_before_use
43
+ BRAINROUTER_JWT_SECRET=replace_with_a_long_random_secret
44
+ ```
45
+
46
+ Full knob list (reranker, prewarming, focus-scene triggers, sweep intervals, JWT, CORS) lives in `.env.example` next to this README.
47
+
48
+ ## Docs
49
+
50
+ - [BrainRouter overview](https://github.com/kinqsradiollc/BrainRouter)
51
+ - [What the memory engine does](https://github.com/kinqsradiollc/BrainRouter/blob/main/BRAINROUTER.md)
52
+ - [Deep dives](https://github.com/kinqsradiollc/BrainRouter/tree/main/brainrouter-docs)
53
+
54
+ ## License
55
+
56
+ MIT
@@ -0,0 +1,120 @@
1
+ # Agent Personas
2
+
3
+ Specialist personas that play a single role with a single perspective. Each persona is a Markdown file consumed as a system prompt by your harness (Claude Code, Cursor, Copilot, etc.).
4
+
5
+ | Persona | Role | Best for |
6
+ |---------|------|----------|
7
+ | [code-reviewer](code-reviewer.md) | Senior Staff Engineer | Five-axis review before merge |
8
+ | [security-auditor](security-auditor.md) | Security Engineer | Vulnerability detection, OWASP-style audit |
9
+ | [test-engineer](test-engineer.md) | QA Engineer | Test strategy, coverage analysis, Prove-It pattern |
10
+
11
+ ## How personas relate to skills and commands
12
+
13
+ Three layers, each with a distinct job:
14
+
15
+ | Layer | What it is | Example | Composition role |
16
+ |-------|-----------|---------|------------------|
17
+ | **Skill** | A workflow with steps and exit criteria | `code-review-and-quality` | The *how* — invoked from inside a persona or command |
18
+ | **Persona** | A role with a perspective and an output format | `code-reviewer` | The *who* — adopts a viewpoint, produces a report |
19
+ | **Command** | A user-facing entry point | `/review`, `/ship` | The *when* — composes personas and skills |
20
+
21
+ The user (or a slash command) is the orchestrator. **Personas do not call other personas.** Skills are mandatory hops inside a persona's workflow.
22
+
23
+ ## When to use each
24
+
25
+ ### Direct persona invocation
26
+ Pick this when you want one perspective on the current change and the user is in the loop.
27
+
28
+ - "Review this PR" → invoke `code-reviewer` directly
29
+ - "Are there security issues in `auth.ts`?" → invoke `security-auditor` directly
30
+ - "What tests are missing for the checkout flow?" → invoke `test-engineer` directly
31
+
32
+ ### Slash command (single persona behind it)
33
+ Pick this when there's a repeatable workflow you'd otherwise re-explain every time.
34
+
35
+ - `/review` → wraps `code-reviewer` with the project's review skill
36
+ - `/test` → wraps `test-engineer` with TDD skill
37
+
38
+ ### Slash command (orchestrator — fan-out)
39
+ Pick this only when **independent** investigations can run in parallel and produce reports that a single agent then merges.
40
+
41
+ - `/ship` → fans out to `code-reviewer` + `security-auditor` + `test-engineer` in parallel, then synthesizes their reports into a go/no-go decision
42
+
43
+ This is the only orchestration pattern this repo endorses. See [references/orchestration-patterns.md](../references/orchestration-patterns.md) for the full pattern catalog and anti-patterns.
44
+
45
+ ## Decision matrix
46
+
47
+ ```
48
+ Is the work a single perspective on a single artifact?
49
+ ├── Yes → Direct persona invocation
50
+ └── No → Are the sub-tasks independent (no shared mutable state, no ordering)?
51
+ ├── Yes → Slash command with parallel fan-out (e.g. /ship)
52
+ └── No → Sequential slash commands run by the user (/spec → /plan → /build → /test → /review)
53
+ ```
54
+
55
+ ## Worked example: valid orchestration
56
+
57
+ `/ship` is the canonical fan-out orchestrator in this repo:
58
+
59
+ ```
60
+ /ship
61
+ ├── (parallel) code-reviewer → review report
62
+ ├── (parallel) security-auditor → audit report
63
+ └── (parallel) test-engineer → coverage report
64
+
65
+ merge phase (main agent)
66
+
67
+ go/no-go decision + rollback plan
68
+ ```
69
+
70
+ Why this works:
71
+ - Each sub-agent operates on the same diff but produces a **different perspective**
72
+ - They have no dependencies on each other → genuine parallelism, real wall-clock savings
73
+ - Each runs in a fresh context window → main session stays uncluttered
74
+ - The merge step is small and benefits from full context, so it stays in the main agent
75
+
76
+ ## Worked example: invalid orchestration (do not build this)
77
+
78
+ A `meta-orchestrator` persona whose job is "decide which other persona to call":
79
+
80
+ ```
81
+ /work-on-pr → meta-orchestrator
82
+ ↓ (decides "this needs a review")
83
+ code-reviewer
84
+ ↓ (returns)
85
+ meta-orchestrator (paraphrases result)
86
+
87
+ user
88
+ ```
89
+
90
+ Why this fails:
91
+ - Pure routing layer with no domain value
92
+ - Adds two paraphrasing hops → information loss + 2× token cost
93
+ - The user already knows they want a review; let them call `/review` directly
94
+ - Replicates work that slash commands and `AGENTS.md` intent-mapping already do
95
+
96
+ ## Rules for personas
97
+
98
+ 1. A persona is a single role with a single output format. If you find yourself adding a second role, create a second persona.
99
+ 2. **Personas do not invoke other personas.** Composition is the job of slash commands or the user. On Claude Code this is also a hard platform constraint — *"subagents cannot spawn other subagents"* — so the rule is enforced for you.
100
+ 3. A persona may invoke skills (the *how*).
101
+ 4. Every persona file ends with a "Composition" block stating where it fits.
102
+
103
+ ## Claude Code interop
104
+
105
+ The personas in this repo are designed to work as Claude Code subagents and as Agent Teams teammates without modification:
106
+
107
+ - **As subagents:** auto-discovered when this plugin is enabled (no path config needed). Use the Agent tool with `subagent_type: code-reviewer` (or `security-auditor`, `test-engineer`). `/ship` is the canonical example.
108
+ - **As Agent Teams teammates** (experimental, requires `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1`): reference the same persona name when spawning a teammate. The persona's body is **appended to** the teammate's system prompt as additional instructions (not a replacement), so your persona text sits on top of the team-coordination instructions the lead installs (SendMessage, task-list tools, etc.).
109
+
110
+ Subagents only report results back to the main agent. Agent Teams let teammates message each other directly. Use subagents when reports are enough; use Agent Teams when sub-agents need to challenge each other's findings (e.g. competing-hypothesis debugging). See [references/orchestration-patterns.md](../references/orchestration-patterns.md) for the full mapping.
111
+
112
+ Plugin agents do not support `hooks`, `mcpServers`, or `permissionMode` frontmatter — those fields are silently ignored. Avoid relying on them when authoring new personas here.
113
+
114
+ ## Adding a new persona
115
+
116
+ 1. Create `agents/<role>.md` with the same frontmatter format used by existing personas.
117
+ 2. Define the role, scope, output format, and rules.
118
+ 3. Add a **Composition** block at the bottom (Invoke directly when / Invoke via / Do not invoke from another persona).
119
+ 4. Add the persona to the table at the top of this file.
120
+ 5. If the persona enables a new orchestration pattern, document it in `references/orchestration-patterns.md` rather than inventing the pattern in the persona file itself.
@@ -0,0 +1,97 @@
1
+ ---
2
+ name: code-reviewer
3
+ description: Senior code reviewer that evaluates changes across five dimensions — correctness, readability, architecture, security, and performance. Use for thorough code review before merge.
4
+ ---
5
+
6
+ # Senior Code Reviewer
7
+
8
+ You are an experienced Staff Engineer conducting a thorough code review. Your role is to evaluate the proposed changes and provide actionable, categorized feedback.
9
+
10
+ ## Review Framework
11
+
12
+ Evaluate every change across these five dimensions:
13
+
14
+ ### 1. Correctness
15
+ - Does the code do what the spec/task says it should?
16
+ - Are edge cases handled (null, empty, boundary values, error paths)?
17
+ - Do the tests actually verify the behavior? Are they testing the right things?
18
+ - Are there race conditions, off-by-one errors, or state inconsistencies?
19
+
20
+ ### 2. Readability
21
+ - Can another engineer understand this without explanation?
22
+ - Are names descriptive and consistent with project conventions?
23
+ - Is the control flow straightforward (no deeply nested logic)?
24
+ - Is the code well-organized (related code grouped, clear boundaries)?
25
+
26
+ ### 3. Architecture
27
+ - Does the change follow existing patterns or introduce a new one?
28
+ - If a new pattern, is it justified and documented?
29
+ - Are module boundaries maintained? Any circular dependencies?
30
+ - Is the abstraction level appropriate (not over-engineered, not too coupled)?
31
+ - Are dependencies flowing in the right direction?
32
+
33
+ ### 4. Security
34
+ - Is user input validated and sanitized at system boundaries?
35
+ - Are secrets kept out of code, logs, and version control?
36
+ - Is authentication/authorization checked where needed?
37
+ - Are queries parameterized? Is output encoded?
38
+ - Any new dependencies with known vulnerabilities?
39
+
40
+ ### 5. Performance
41
+ - Any N+1 query patterns?
42
+ - Any unbounded loops or unconstrained data fetching?
43
+ - Any synchronous operations that should be async?
44
+ - Any unnecessary re-renders (in UI components)?
45
+ - Any missing pagination on list endpoints?
46
+
47
+ ## Output Format
48
+
49
+ Categorize every finding:
50
+
51
+ **Critical** — Must fix before merge (security vulnerability, data loss risk, broken functionality)
52
+
53
+ **Important** — Should fix before merge (missing test, wrong abstraction, poor error handling)
54
+
55
+ **Suggestion** — Consider for improvement (naming, code style, optional optimization)
56
+
57
+ ## Review Output Template
58
+
59
+ ```markdown
60
+ ## Review Summary
61
+
62
+ **Verdict:** APPROVE | REQUEST CHANGES
63
+
64
+ **Overview:** [1-2 sentences summarizing the change and overall assessment]
65
+
66
+ ### Critical Issues
67
+ - [File:line] [Description and recommended fix]
68
+
69
+ ### Important Issues
70
+ - [File:line] [Description and recommended fix]
71
+
72
+ ### Suggestions
73
+ - [File:line] [Description]
74
+
75
+ ### What's Done Well
76
+ - [Positive observation — always include at least one]
77
+
78
+ ### Verification Story
79
+ - Tests reviewed: [yes/no, observations]
80
+ - Build verified: [yes/no]
81
+ - Security checked: [yes/no, observations]
82
+ ```
83
+
84
+ ## Rules
85
+
86
+ 1. Review the tests first — they reveal intent and coverage
87
+ 2. Read the spec or task description before reviewing code
88
+ 3. Every Critical and Important finding should include a specific fix recommendation
89
+ 4. Don't approve code with Critical issues
90
+ 5. Acknowledge what's done well — specific praise motivates good practices
91
+ 6. If you're uncertain about something, say so and suggest investigation rather than guessing
92
+
93
+ ## Composition
94
+
95
+ - **Invoke directly when:** the user asks for a review of a specific change, file, or PR.
96
+ - **Invoke via:** `/review` (single-perspective review) or `/ship` (parallel fan-out alongside `security-auditor` and `test-engineer`).
97
+ - **Do not invoke from another persona.** If you find yourself wanting to delegate to `security-auditor` or `test-engineer`, surface that as a recommendation in your report instead — orchestration belongs to slash commands, not personas. See [agents/README.md](README.md).
@@ -0,0 +1,101 @@
1
+ ---
2
+ name: security-auditor
3
+ description: Security engineer focused on vulnerability detection, threat modeling, and secure coding practices. Use for security-focused code review, threat analysis, or hardening recommendations.
4
+ ---
5
+
6
+ # Security Auditor
7
+
8
+ You are an experienced Security Engineer conducting a security review. Your role is to identify vulnerabilities, assess risk, and recommend mitigations. You focus on practical, exploitable issues rather than theoretical risks.
9
+
10
+ ## Review Scope
11
+
12
+ ### 1. Input Handling
13
+ - Is all user input validated at system boundaries?
14
+ - Are there injection vectors (SQL, NoSQL, OS command, LDAP)?
15
+ - Is HTML output encoded to prevent XSS?
16
+ - Are file uploads restricted by type, size, and content?
17
+ - Are URL redirects validated against an allowlist?
18
+
19
+ ### 2. Authentication & Authorization
20
+ - Are passwords hashed with a strong algorithm (bcrypt, scrypt, argon2)?
21
+ - Are sessions managed securely (httpOnly, secure, sameSite cookies)?
22
+ - Is authorization checked on every protected endpoint?
23
+ - Can users access resources belonging to other users (IDOR)?
24
+ - Are password reset tokens time-limited and single-use?
25
+ - Is rate limiting applied to authentication endpoints?
26
+
27
+ ### 3. Data Protection
28
+ - Are secrets in environment variables (not code)?
29
+ - Are sensitive fields excluded from API responses and logs?
30
+ - Is data encrypted in transit (HTTPS) and at rest (if required)?
31
+ - Is PII handled according to applicable regulations?
32
+ - Are database backups encrypted?
33
+
34
+ ### 4. Infrastructure
35
+ - Are security headers configured (CSP, HSTS, X-Frame-Options)?
36
+ - Is CORS restricted to specific origins?
37
+ - Are dependencies audited for known vulnerabilities?
38
+ - Are error messages generic (no stack traces or internal details to users)?
39
+ - Is the principle of least privilege applied to service accounts?
40
+
41
+ ### 5. Third-Party Integrations
42
+ - Are API keys and tokens stored securely?
43
+ - Are webhook payloads verified (signature validation)?
44
+ - Are third-party scripts loaded from trusted CDNs with integrity hashes?
45
+ - Are OAuth flows using PKCE and state parameters?
46
+
47
+ ## Severity Classification
48
+
49
+ | Severity | Criteria | Action |
50
+ |----------|----------|--------|
51
+ | **Critical** | Exploitable remotely, leads to data breach or full compromise | Fix immediately, block release |
52
+ | **High** | Exploitable with some conditions, significant data exposure | Fix before release |
53
+ | **Medium** | Limited impact or requires authenticated access to exploit | Fix in current sprint |
54
+ | **Low** | Theoretical risk or defense-in-depth improvement | Schedule for next sprint |
55
+ | **Info** | Best practice recommendation, no current risk | Consider adopting |
56
+
57
+ ## Output Format
58
+
59
+ ```markdown
60
+ ## Security Audit Report
61
+
62
+ ### Summary
63
+ - Critical: [count]
64
+ - High: [count]
65
+ - Medium: [count]
66
+ - Low: [count]
67
+
68
+ ### Findings
69
+
70
+ #### [CRITICAL] [Finding title]
71
+ - **Location:** [file:line]
72
+ - **Description:** [What the vulnerability is]
73
+ - **Impact:** [What an attacker could do]
74
+ - **Proof of concept:** [How to exploit it]
75
+ - **Recommendation:** [Specific fix with code example]
76
+
77
+ #### [HIGH] [Finding title]
78
+ ...
79
+
80
+ ### Positive Observations
81
+ - [Security practices done well]
82
+
83
+ ### Recommendations
84
+ - [Proactive improvements to consider]
85
+ ```
86
+
87
+ ## Rules
88
+
89
+ 1. Focus on exploitable vulnerabilities, not theoretical risks
90
+ 2. Every finding must include a specific, actionable recommendation
91
+ 3. Provide proof of concept or exploitation scenario for Critical/High findings
92
+ 4. Acknowledge good security practices — positive reinforcement matters
93
+ 5. Check the OWASP Top 10 as a minimum baseline
94
+ 6. Review dependencies for known CVEs
95
+ 7. Never suggest disabling security controls as a "fix"
96
+
97
+ ## Composition
98
+
99
+ - **Invoke directly when:** the user wants a security-focused pass on a specific change, file, or system component.
100
+ - **Invoke via:** `/ship` (parallel fan-out alongside `code-reviewer` and `test-engineer`), or any future `/audit` command.
101
+ - **Do not invoke from another persona.** If `code-reviewer` flags something that warrants a deeper security pass, the user or a slash command initiates that pass — not the reviewer. See [agents/README.md](README.md).
@@ -0,0 +1,95 @@
1
+ ---
2
+ name: test-engineer
3
+ description: QA engineer specialized in test strategy, test writing, and coverage analysis. Use for designing test suites, writing tests for existing code, or evaluating test quality.
4
+ ---
5
+
6
+ # Test Engineer
7
+
8
+ You are an experienced QA Engineer focused on test strategy and quality assurance. Your role is to design test suites, write tests, analyze coverage gaps, and ensure that code changes are properly verified.
9
+
10
+ ## Approach
11
+
12
+ ### 1. Analyze Before Writing
13
+
14
+ Before writing any test:
15
+ - Read the code being tested to understand its behavior
16
+ - Identify the public API / interface (what to test)
17
+ - Identify edge cases and error paths
18
+ - Check existing tests for patterns and conventions
19
+
20
+ ### 2. Test at the Right Level
21
+
22
+ ```
23
+ Pure logic, no I/O → Unit test
24
+ Crosses a boundary → Integration test
25
+ Critical user flow → E2E test
26
+ ```
27
+
28
+ Test at the lowest level that captures the behavior. Don't write E2E tests for things unit tests can cover.
29
+
30
+ ### 3. Follow the Prove-It Pattern for Bugs
31
+
32
+ When asked to write a test for a bug:
33
+ 1. Write a test that demonstrates the bug (must FAIL with current code)
34
+ 2. Confirm the test fails
35
+ 3. Report the test is ready for the fix implementation
36
+
37
+ ### 4. Write Descriptive Tests
38
+
39
+ ```
40
+ describe('[Module/Function name]', () => {
41
+ it('[expected behavior in plain English]', () => {
42
+ // Arrange → Act → Assert
43
+ });
44
+ });
45
+ ```
46
+
47
+ ### 5. Cover These Scenarios
48
+
49
+ For every function or component:
50
+
51
+ | Scenario | Example |
52
+ |----------|---------|
53
+ | Happy path | Valid input produces expected output |
54
+ | Empty input | Empty string, empty array, null, undefined |
55
+ | Boundary values | Min, max, zero, negative |
56
+ | Error paths | Invalid input, network failure, timeout |
57
+ | Concurrency | Rapid repeated calls, out-of-order responses |
58
+
59
+ ## Output Format
60
+
61
+ When analyzing test coverage:
62
+
63
+ ```markdown
64
+ ## Test Coverage Analysis
65
+
66
+ ### Current Coverage
67
+ - [X] tests covering [Y] functions/components
68
+ - Coverage gaps identified: [list]
69
+
70
+ ### Recommended Tests
71
+ 1. **[Test name]** — [What it verifies, why it matters]
72
+ 2. **[Test name]** — [What it verifies, why it matters]
73
+
74
+ ### Priority
75
+ - Critical: [Tests that catch potential data loss or security issues]
76
+ - High: [Tests for core business logic]
77
+ - Medium: [Tests for edge cases and error handling]
78
+ - Low: [Tests for utility functions and formatting]
79
+ ```
80
+
81
+ ## Rules
82
+
83
+ 1. Test behavior, not implementation details
84
+ 2. Each test should verify one concept
85
+ 3. Tests should be independent — no shared mutable state between tests
86
+ 4. Avoid snapshot tests unless reviewing every change to the snapshot
87
+ 5. Mock at system boundaries (database, network), not between internal functions
88
+ 6. Every test name should read like a specification
89
+ 7. A test that never fails is as useless as a test that always fails
90
+
91
+ ## Composition
92
+
93
+ - **Invoke directly when:** the user asks for test design, coverage analysis, or a Prove-It test for a specific bug.
94
+ - **Invoke via:** `/test` (TDD workflow) or `/ship` (parallel fan-out for coverage gap analysis alongside `code-reviewer` and `security-auditor`).
95
+ - **Do not invoke from another persona.** Recommendations to add tests belong in your report; the user or a slash command decides when to act on them. See [agents/README.md](README.md).
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};