@cortex-agent/server 2026.5.19-1

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 (503) hide show
  1. package/defaults/.claude/settings.json +13 -0
  2. package/defaults/CORTEX.md +15 -0
  3. package/defaults/config/budget.json +4 -0
  4. package/defaults/config/session-hooks.json +7 -0
  5. package/defaults/config/thread-templates.json +528 -0
  6. package/defaults/context/CORTEX.md +40 -0
  7. package/defaults/context/decisions/DR-0012.md +54 -0
  8. package/defaults/context/ideas/CORTEX.md +10 -0
  9. package/defaults/context/projects/CORTEX.md +25 -0
  10. package/defaults/context/scans/CORTEX.md +13 -0
  11. package/defaults/context/user/CORTEX.md +21 -0
  12. package/defaults/data/schedules.json +52 -0
  13. package/defaults/gitignore +44 -0
  14. package/defaults/hooks/ask-user-question-hook.mjs +66 -0
  15. package/defaults/hooks/cortex-md-injector.mjs +237 -0
  16. package/defaults/hooks/exit-plan-mode-hook.mjs +84 -0
  17. package/defaults/hooks/memory-ref-tracker.mjs +154 -0
  18. package/defaults/hooks/new-session-hook.mjs +83 -0
  19. package/defaults/hooks/post-task-hook.mjs +63 -0
  20. package/defaults/hooks/rules-loader.mjs +212 -0
  21. package/defaults/hooks/sensitive-file-edit.mjs +84 -0
  22. package/defaults/hooks/session-activity-tracker.mjs +254 -0
  23. package/defaults/hooks/task-status-check.mjs +218 -0
  24. package/defaults/hooks/tasks-yaml-guard.mjs +230 -0
  25. package/defaults/plugins/cortex-coder/.claude-plugin/plugin.json +5 -0
  26. package/defaults/plugins/cortex-coder/skills/cli-standards/SKILL.md +208 -0
  27. package/defaults/plugins/cortex-coder/skills/code-standards/SKILL.md +146 -0
  28. package/defaults/plugins/cortex-coder/skills/develop/SKILL.md +164 -0
  29. package/defaults/plugins/cortex-common/.claude-plugin/plugin.json +5 -0
  30. package/defaults/plugins/cortex-common/skills/compound/SKILL.md +349 -0
  31. package/defaults/plugins/cortex-common/skills/compound-simple/SKILL.md +104 -0
  32. package/defaults/plugins/cortex-common/skills/critique/SKILL.md +88 -0
  33. package/defaults/plugins/cortex-common/skills/debug-campaign/SKILL.md +508 -0
  34. package/defaults/plugins/cortex-common/skills/diagnose/SKILL.md +169 -0
  35. package/defaults/plugins/cortex-common/skills/postmortem/SKILL.md +135 -0
  36. package/defaults/plugins/cortex-common/skills/solution-design/SKILL.md +183 -0
  37. package/defaults/plugins/cortex-common/skills/synthesize/SKILL.md +120 -0
  38. package/defaults/plugins/cortex-stage-gate/.claude-plugin/plugin.json +5 -0
  39. package/defaults/plugins/cortex-stage-gate/skills/need-approval/SKILL.md +89 -0
  40. package/defaults/plugins/cortex-stage-gate/skills/reorient/SKILL.md +163 -0
  41. package/defaults/plugins/cortex-stage-gate/skills/task/SKILL.md +425 -0
  42. package/defaults/plugins/cortex-system/.claude-plugin/plugin.json +5 -0
  43. package/defaults/plugins/cortex-system/skills/approval/SKILL.md +84 -0
  44. package/defaults/plugins/cortex-system/skills/client-manage/SKILL.md +199 -0
  45. package/defaults/plugins/cortex-system/skills/deep-retrospective/CORTEX.md +8 -0
  46. package/defaults/plugins/cortex-system/skills/deep-retrospective/SKILL.md +201 -0
  47. package/defaults/plugins/cortex-system/skills/deep-retrospective/scripts/CORTEX.md +8 -0
  48. package/defaults/plugins/cortex-system/skills/deep-retrospective/scripts/extract_session.py +165 -0
  49. package/defaults/plugins/cortex-system/skills/deep-retrospective/scripts/scan_logs.py +402 -0
  50. package/defaults/plugins/cortex-system/skills/evolve/SKILL.md +115 -0
  51. package/defaults/plugins/cortex-system/skills/feedback/SKILL.md +262 -0
  52. package/defaults/plugins/cortex-system/skills/gravity/SKILL.md +125 -0
  53. package/defaults/plugins/cortex-system/skills/orient/SKILL.md +310 -0
  54. package/defaults/plugins/cortex-system/skills/orient-project/SKILL.md +85 -0
  55. package/defaults/plugins/cortex-system/skills/project-init/SKILL.md +167 -0
  56. package/defaults/plugins/cortex-system/skills/refresh-skills/SKILL.md +153 -0
  57. package/defaults/plugins/cortex-system/skills/schedule/SKILL.md +209 -0
  58. package/defaults/plugins/cortex-system/skills/thread/SKILL.md +478 -0
  59. package/defaults/plugins/cortex-system/skills/user-learn/SKILL.md +95 -0
  60. package/defaults/prompts/directives/coder-reviewer.md +106 -0
  61. package/defaults/prompts/directives/coder.md +90 -0
  62. package/defaults/prompts/directives/director.md +97 -0
  63. package/defaults/prompts/directives/doc-reviewer.md +93 -0
  64. package/defaults/prompts/directives/doc-writer.md +85 -0
  65. package/defaults/prompts/directives/executor-reviewer.md +96 -0
  66. package/defaults/prompts/directives/executor.md +85 -0
  67. package/defaults/prompts/directives/milestone-executor.md +119 -0
  68. package/defaults/prompts/directives/milestone-reviewer.md +108 -0
  69. package/defaults/prompts/directives/plan-executor.md +121 -0
  70. package/defaults/prompts/directives/plan-reviewer.md +99 -0
  71. package/defaults/prompts/systemPrompts/coder.md +64 -0
  72. package/defaults/prompts/systemPrompts/direct.md +92 -0
  73. package/defaults/prompts/systemPrompts/web-opus-4-6.md +68 -0
  74. package/defaults/prompts/systemPrompts/web-sonnet-4-6.md +76 -0
  75. package/defaults/prompts/systemPrompts/web.md +50 -0
  76. package/defaults/prompts/systemPrompts/worker.md +67 -0
  77. package/defaults/rules/correction-propagation.md +31 -0
  78. package/defaults/rules/decision-records.md +49 -0
  79. package/defaults/rules/experiment-format.md +165 -0
  80. package/defaults/rules/issues-md.md +37 -0
  81. package/defaults/rules/meta-conventions.md +45 -0
  82. package/defaults/rules/mission-md.md +47 -0
  83. package/defaults/rules/overview-md.md +41 -0
  84. package/defaults/rules/roadmap-md.md +55 -0
  85. package/defaults/rules/status-md.md +49 -0
  86. package/defaults/rules/task-system.md +53 -0
  87. package/dist/agent-adapter/capabilities.d.ts +12 -0
  88. package/dist/agent-adapter/capabilities.js +52 -0
  89. package/dist/agent-adapter/claude/adapter-tui.d.ts +140 -0
  90. package/dist/agent-adapter/claude/adapter-tui.js +422 -0
  91. package/dist/agent-adapter/claude/adapter.d.ts +85 -0
  92. package/dist/agent-adapter/claude/adapter.js +771 -0
  93. package/dist/agent-adapter/claude/cost-from-usage.d.ts +62 -0
  94. package/dist/agent-adapter/claude/cost-from-usage.js +97 -0
  95. package/dist/agent-adapter/claude/defaults.d.ts +30 -0
  96. package/dist/agent-adapter/claude/defaults.js +49 -0
  97. package/dist/agent-adapter/claude/event-parser.d.ts +28 -0
  98. package/dist/agent-adapter/claude/event-parser.js +173 -0
  99. package/dist/agent-adapter/claude/hooks-builder.d.ts +36 -0
  100. package/dist/agent-adapter/claude/hooks-builder.js +57 -0
  101. package/dist/agent-adapter/claude/jsonl-tail.d.ts +68 -0
  102. package/dist/agent-adapter/claude/jsonl-tail.js +344 -0
  103. package/dist/agent-adapter/claude/spawn-args.d.ts +38 -0
  104. package/dist/agent-adapter/claude/spawn-args.js +83 -0
  105. package/dist/agent-adapter/claude/tmux-control.d.ts +69 -0
  106. package/dist/agent-adapter/claude/tmux-control.js +127 -0
  107. package/dist/agent-adapter/claude/tool-summarizers.d.ts +2 -0
  108. package/dist/agent-adapter/claude/tool-summarizers.js +24 -0
  109. package/dist/agent-adapter/codex/adapter.d.ts +42 -0
  110. package/dist/agent-adapter/codex/adapter.js +916 -0
  111. package/dist/agent-adapter/codex/event-parser.d.ts +17 -0
  112. package/dist/agent-adapter/codex/event-parser.js +41 -0
  113. package/dist/agent-adapter/codex/spawn-args.d.ts +6 -0
  114. package/dist/agent-adapter/codex/spawn-args.js +30 -0
  115. package/dist/agent-adapter/index.d.ts +8 -0
  116. package/dist/agent-adapter/index.js +33 -0
  117. package/dist/agent-adapter/normalize/event-stream.d.ts +6 -0
  118. package/dist/agent-adapter/normalize/event-stream.js +47 -0
  119. package/dist/agent-adapter/normalize/event-types.d.ts +58 -0
  120. package/dist/agent-adapter/normalize/event-types.js +5 -0
  121. package/dist/agent-adapter/normalize/hooks.d.ts +26 -0
  122. package/dist/agent-adapter/normalize/hooks.js +5 -0
  123. package/dist/agent-adapter/normalize/prompt-builder.d.ts +6 -0
  124. package/dist/agent-adapter/normalize/prompt-builder.js +23 -0
  125. package/dist/agent-adapter/normalize/tool-names.d.ts +6 -0
  126. package/dist/agent-adapter/normalize/tool-names.js +73 -0
  127. package/dist/agent-adapter/pi/adapter.d.ts +60 -0
  128. package/dist/agent-adapter/pi/adapter.js +626 -0
  129. package/dist/agent-adapter/pi/agent-dir.d.ts +11 -0
  130. package/dist/agent-adapter/pi/agent-dir.js +34 -0
  131. package/dist/agent-adapter/pi/event-parser.d.ts +26 -0
  132. package/dist/agent-adapter/pi/event-parser.js +313 -0
  133. package/dist/agent-adapter/pi/framing.d.ts +6 -0
  134. package/dist/agent-adapter/pi/framing.js +35 -0
  135. package/dist/agent-adapter/pi/hook-bridge.d.ts +59 -0
  136. package/dist/agent-adapter/pi/hook-bridge.js +233 -0
  137. package/dist/agent-adapter/pi/mcp-bridge.d.ts +26 -0
  138. package/dist/agent-adapter/pi/mcp-bridge.js +140 -0
  139. package/dist/agent-adapter/pi/pi-ext-types.d.ts +90 -0
  140. package/dist/agent-adapter/pi/pi-ext-types.js +5 -0
  141. package/dist/agent-adapter/pi/spawn-args.d.ts +20 -0
  142. package/dist/agent-adapter/pi/spawn-args.js +54 -0
  143. package/dist/agent-adapter/pi/tool-shims.d.ts +2 -0
  144. package/dist/agent-adapter/pi/tool-shims.js +181 -0
  145. package/dist/agent-adapter/types.d.ts +94 -0
  146. package/dist/agent-adapter/types.js +5 -0
  147. package/dist/core/async-mutex.d.ts +6 -0
  148. package/dist/core/async-mutex.js +36 -0
  149. package/dist/core/cli-utils.d.ts +37 -0
  150. package/dist/core/cli-utils.js +69 -0
  151. package/dist/core/config-generator.d.ts +9 -0
  152. package/dist/core/config-generator.js +58 -0
  153. package/dist/core/gateway-generator.d.ts +46 -0
  154. package/dist/core/gateway-generator.js +336 -0
  155. package/dist/core/log.d.ts +7 -0
  156. package/dist/core/log.js +103 -0
  157. package/dist/core/paths.d.ts +32 -0
  158. package/dist/core/paths.js +49 -0
  159. package/dist/core/profile-generator.d.ts +65 -0
  160. package/dist/core/profile-generator.js +310 -0
  161. package/dist/core/running-executions.d.ts +88 -0
  162. package/dist/core/running-executions.js +186 -0
  163. package/dist/core/status-format.d.ts +18 -0
  164. package/dist/core/status-format.js +31 -0
  165. package/dist/core/task-parser.d.ts +69 -0
  166. package/dist/core/task-parser.js +423 -0
  167. package/dist/core/types/agent-types.d.ts +31 -0
  168. package/dist/core/types/agent-types.js +5 -0
  169. package/dist/core/types/thread-types.d.ts +261 -0
  170. package/dist/core/types/thread-types.js +5 -0
  171. package/dist/core/utils.d.ts +29 -0
  172. package/dist/core/utils.js +98 -0
  173. package/dist/core/version.d.ts +3 -0
  174. package/dist/core/version.js +12 -0
  175. package/dist/domain/agents/config.d.ts +58 -0
  176. package/dist/domain/agents/config.js +313 -0
  177. package/dist/domain/agents/facade.d.ts +52 -0
  178. package/dist/domain/agents/facade.js +264 -0
  179. package/dist/domain/agents/index.d.ts +2 -0
  180. package/dist/domain/agents/index.js +4 -0
  181. package/dist/domain/agents/profile-manager.d.ts +54 -0
  182. package/dist/domain/agents/profile-manager.js +161 -0
  183. package/dist/domain/costs/codex-event-format.d.ts +4 -0
  184. package/dist/domain/costs/codex-event-format.js +66 -0
  185. package/dist/domain/costs/codex-usage-monitor.d.ts +7 -0
  186. package/dist/domain/costs/codex-usage-monitor.js +72 -0
  187. package/dist/domain/costs/cost-tracker.d.ts +115 -0
  188. package/dist/domain/costs/cost-tracker.js +327 -0
  189. package/dist/domain/costs/gateway-manager.d.ts +6 -0
  190. package/dist/domain/costs/gateway-manager.js +228 -0
  191. package/dist/domain/costs/rate-limit-parser.d.ts +11 -0
  192. package/dist/domain/costs/rate-limit-parser.js +87 -0
  193. package/dist/domain/costs/rate-limit-throttle.d.ts +32 -0
  194. package/dist/domain/costs/rate-limit-throttle.js +129 -0
  195. package/dist/domain/executions/registry.d.ts +20 -0
  196. package/dist/domain/executions/registry.js +124 -0
  197. package/dist/domain/mcp/core-server.d.ts +2 -0
  198. package/dist/domain/mcp/core-server.js +34 -0
  199. package/dist/domain/mcp/server.d.ts +3 -0
  200. package/dist/domain/mcp/server.js +78 -0
  201. package/dist/domain/mcp/tools/context.d.ts +23 -0
  202. package/dist/domain/mcp/tools/context.js +51 -0
  203. package/dist/domain/mcp/tools/cortex-md.d.ts +17 -0
  204. package/dist/domain/mcp/tools/cortex-md.js +36 -0
  205. package/dist/domain/mcp/tools/cost.d.ts +2 -0
  206. package/dist/domain/mcp/tools/cost.js +54 -0
  207. package/dist/domain/mcp/tools/executions.d.ts +2 -0
  208. package/dist/domain/mcp/tools/executions.js +94 -0
  209. package/dist/domain/mcp/tools/schedule.d.ts +23 -0
  210. package/dist/domain/mcp/tools/schedule.js +245 -0
  211. package/dist/domain/mcp/tools/slack.d.ts +21 -0
  212. package/dist/domain/mcp/tools/slack.js +124 -0
  213. package/dist/domain/mcp/tools/task-ops.d.ts +2 -0
  214. package/dist/domain/mcp/tools/task-ops.js +509 -0
  215. package/dist/domain/mcp/tools/tui-ask.d.ts +31 -0
  216. package/dist/domain/mcp/tools/tui-ask.js +108 -0
  217. package/dist/domain/mcp/tools/tui-plan.d.ts +28 -0
  218. package/dist/domain/mcp/tools/tui-plan.js +118 -0
  219. package/dist/domain/mcp/tui-server.d.ts +2 -0
  220. package/dist/domain/mcp/tui-server.js +69 -0
  221. package/dist/domain/memory/consolidate.d.ts +55 -0
  222. package/dist/domain/memory/consolidate.js +471 -0
  223. package/dist/domain/memory/cortex-md-injector.d.ts +30 -0
  224. package/dist/domain/memory/cortex-md-injector.js +123 -0
  225. package/dist/domain/memory/cortex-md-scanner.d.ts +9 -0
  226. package/dist/domain/memory/cortex-md-scanner.js +67 -0
  227. package/dist/domain/memory/index-regen.d.ts +19 -0
  228. package/dist/domain/memory/index-regen.js +398 -0
  229. package/dist/domain/memory/rules-loader.d.ts +27 -0
  230. package/dist/domain/memory/rules-loader.js +97 -0
  231. package/dist/domain/memory/skill-scanner.d.ts +5 -0
  232. package/dist/domain/memory/skill-scanner.js +132 -0
  233. package/dist/domain/memory/user-context.d.ts +5 -0
  234. package/dist/domain/memory/user-context.js +34 -0
  235. package/dist/domain/memory/watcher.d.ts +2 -0
  236. package/dist/domain/memory/watcher.js +81 -0
  237. package/dist/domain/monitor/disk-monitor.d.ts +20 -0
  238. package/dist/domain/monitor/disk-monitor.js +97 -0
  239. package/dist/domain/monitor/gpu-monitor.d.ts +26 -0
  240. package/dist/domain/monitor/gpu-monitor.js +135 -0
  241. package/dist/domain/remote/client-bootstrap.d.ts +1 -0
  242. package/dist/domain/remote/client-bootstrap.js +139 -0
  243. package/dist/domain/remote/client-hot-reload.d.ts +18 -0
  244. package/dist/domain/remote/client-hot-reload.js +142 -0
  245. package/dist/domain/remote/client-manager.d.ts +50 -0
  246. package/dist/domain/remote/client-manager.js +452 -0
  247. package/dist/domain/remote/cortex-client.d.ts +1 -0
  248. package/dist/domain/remote/cortex-client.js +704 -0
  249. package/dist/domain/scheduling/job-registry.d.ts +31 -0
  250. package/dist/domain/scheduling/job-registry.js +34 -0
  251. package/dist/domain/scheduling/jobs/_shared.d.ts +14 -0
  252. package/dist/domain/scheduling/jobs/_shared.js +45 -0
  253. package/dist/domain/scheduling/jobs/memory-index-regen.d.ts +1 -0
  254. package/dist/domain/scheduling/jobs/memory-index-regen.js +16 -0
  255. package/dist/domain/scheduling/jobs/scheduled-task.d.ts +11 -0
  256. package/dist/domain/scheduling/jobs/scheduled-task.js +186 -0
  257. package/dist/domain/scheduling/jobs/target-dispatch.d.ts +41 -0
  258. package/dist/domain/scheduling/jobs/target-dispatch.js +48 -0
  259. package/dist/domain/scheduling/jobs/task-archive.d.ts +1 -0
  260. package/dist/domain/scheduling/jobs/task-archive.js +19 -0
  261. package/dist/domain/scheduling/jobs/task-dispatch.d.ts +12 -0
  262. package/dist/domain/scheduling/jobs/task-dispatch.js +214 -0
  263. package/dist/domain/scheduling/runner.d.ts +13 -0
  264. package/dist/domain/scheduling/runner.js +24 -0
  265. package/dist/domain/scheduling/schedule-cli.d.ts +16 -0
  266. package/dist/domain/scheduling/schedule-cli.js +268 -0
  267. package/dist/domain/scheduling/schedule-command.d.ts +4 -0
  268. package/dist/domain/scheduling/schedule-command.js +274 -0
  269. package/dist/domain/scheduling/scheduler.d.ts +86 -0
  270. package/dist/domain/scheduling/scheduler.js +544 -0
  271. package/dist/domain/sessions/session-backup.d.ts +49 -0
  272. package/dist/domain/sessions/session-backup.js +217 -0
  273. package/dist/domain/sessions/session-hooks.d.ts +103 -0
  274. package/dist/domain/sessions/session-hooks.js +311 -0
  275. package/dist/domain/sessions/session-registry.d.ts +21 -0
  276. package/dist/domain/sessions/session-registry.js +31 -0
  277. package/dist/domain/sessions/session.d.ts +3 -0
  278. package/dist/domain/sessions/session.js +14 -0
  279. package/dist/domain/tasks/archiver.d.ts +9 -0
  280. package/dist/domain/tasks/archiver.js +123 -0
  281. package/dist/domain/tasks/dispatch-utils.d.ts +37 -0
  282. package/dist/domain/tasks/dispatch-utils.js +143 -0
  283. package/dist/domain/tasks/dispatcher.d.ts +48 -0
  284. package/dist/domain/tasks/dispatcher.js +285 -0
  285. package/dist/domain/tasks/lint.d.ts +12 -0
  286. package/dist/domain/tasks/lint.js +102 -0
  287. package/dist/domain/tasks/mutator.d.ts +21 -0
  288. package/dist/domain/tasks/mutator.js +208 -0
  289. package/dist/domain/tasks/parser.d.ts +1 -0
  290. package/dist/domain/tasks/parser.js +6 -0
  291. package/dist/domain/tasks/pending-tracker.d.ts +67 -0
  292. package/dist/domain/tasks/pending-tracker.js +163 -0
  293. package/dist/domain/tasks/recommendation/extractor.d.ts +12 -0
  294. package/dist/domain/tasks/recommendation/extractor.js +563 -0
  295. package/dist/domain/tasks/recommendation/patterns.d.ts +11 -0
  296. package/dist/domain/tasks/recommendation/patterns.js +99 -0
  297. package/dist/domain/tasks/recommendation/types.d.ts +67 -0
  298. package/dist/domain/tasks/recommendation/types.js +5 -0
  299. package/dist/domain/tasks/store.d.ts +1 -0
  300. package/dist/domain/tasks/store.js +3 -0
  301. package/dist/domain/tasks/system/cortex-run.d.ts +24 -0
  302. package/dist/domain/tasks/system/cortex-run.js +342 -0
  303. package/dist/domain/tasks/system/task-cli.d.ts +49 -0
  304. package/dist/domain/tasks/system/task-cli.js +664 -0
  305. package/dist/domain/tasks/system/task-completion.d.ts +22 -0
  306. package/dist/domain/tasks/system/task-completion.js +89 -0
  307. package/dist/domain/tasks/system/task-id-utils.d.ts +24 -0
  308. package/dist/domain/tasks/system/task-id-utils.js +84 -0
  309. package/dist/domain/tasks/system/task-lifecycle-edit.d.ts +34 -0
  310. package/dist/domain/tasks/system/task-lifecycle-edit.js +208 -0
  311. package/dist/domain/tasks/system/task-lock.d.ts +25 -0
  312. package/dist/domain/tasks/system/task-lock.js +139 -0
  313. package/dist/domain/tasks/system/task-mutations.d.ts +31 -0
  314. package/dist/domain/tasks/system/task-mutations.js +110 -0
  315. package/dist/domain/tasks/system/task-process.d.ts +37 -0
  316. package/dist/domain/tasks/system/task-process.js +119 -0
  317. package/dist/domain/tasks/system/task-state.d.ts +70 -0
  318. package/dist/domain/tasks/system/task-state.js +176 -0
  319. package/dist/domain/threads/artifact-io.d.ts +18 -0
  320. package/dist/domain/threads/artifact-io.js +182 -0
  321. package/dist/domain/threads/auto-thread.d.ts +3 -0
  322. package/dist/domain/threads/auto-thread.js +19 -0
  323. package/dist/domain/threads/hook-runner.d.ts +4 -0
  324. package/dist/domain/threads/hook-runner.js +250 -0
  325. package/dist/domain/threads/index.d.ts +5 -0
  326. package/dist/domain/threads/index.js +7 -0
  327. package/dist/domain/threads/prompt-builder.d.ts +25 -0
  328. package/dist/domain/threads/prompt-builder.js +176 -0
  329. package/dist/domain/threads/runner.d.ts +83 -0
  330. package/dist/domain/threads/runner.js +434 -0
  331. package/dist/domain/threads/state-machine.d.ts +61 -0
  332. package/dist/domain/threads/state-machine.js +440 -0
  333. package/dist/domain/threads/template-loader.d.ts +20 -0
  334. package/dist/domain/threads/template-loader.js +189 -0
  335. package/dist/domain/threads/template-resolver.d.ts +1 -0
  336. package/dist/domain/threads/template-resolver.js +95 -0
  337. package/dist/domain/threads/utils.d.ts +19 -0
  338. package/dist/domain/threads/utils.js +49 -0
  339. package/dist/entry/app.d.ts +1 -0
  340. package/dist/entry/app.js +234 -0
  341. package/dist/entry/cli.d.ts +12 -0
  342. package/dist/entry/cli.js +254 -0
  343. package/dist/entry/daemon.d.ts +11 -0
  344. package/dist/entry/daemon.js +521 -0
  345. package/dist/entry/init.d.ts +93 -0
  346. package/dist/entry/init.js +1299 -0
  347. package/dist/entry/startup-helpers.d.ts +2 -0
  348. package/dist/entry/startup-helpers.js +56 -0
  349. package/dist/entry/startup-notify.d.ts +10 -0
  350. package/dist/entry/startup-notify.js +20 -0
  351. package/dist/events/event-bus.d.ts +42 -0
  352. package/dist/events/event-bus.js +84 -0
  353. package/dist/events/event-logger.d.ts +12 -0
  354. package/dist/events/event-logger.js +135 -0
  355. package/dist/events/event-replay.d.ts +1 -0
  356. package/dist/events/event-replay.js +51 -0
  357. package/dist/events/event-types.d.ts +145 -0
  358. package/dist/events/event-types.js +5 -0
  359. package/dist/events/index.d.ts +5 -0
  360. package/dist/events/index.js +6 -0
  361. package/dist/hooks/ask-user-question-hook.mjs +66 -0
  362. package/dist/hooks/cortex-md-injector.mjs +237 -0
  363. package/dist/hooks/exit-plan-mode-hook.mjs +84 -0
  364. package/dist/hooks/memory-ref-tracker.mjs +154 -0
  365. package/dist/hooks/new-session-hook.mjs +83 -0
  366. package/dist/hooks/post-task-hook.mjs +63 -0
  367. package/dist/hooks/rules-loader.mjs +212 -0
  368. package/dist/hooks/sensitive-file-edit.mjs +84 -0
  369. package/dist/hooks/session-activity-tracker.mjs +254 -0
  370. package/dist/hooks/task-status-check.mjs +218 -0
  371. package/dist/hooks/tasks-yaml-guard.mjs +230 -0
  372. package/dist/orchestration/agent-runner.d.ts +72 -0
  373. package/dist/orchestration/agent-runner.js +289 -0
  374. package/dist/orchestration/busy-tracker.d.ts +12 -0
  375. package/dist/orchestration/busy-tracker.js +35 -0
  376. package/dist/orchestration/channel-queue.d.ts +18 -0
  377. package/dist/orchestration/channel-queue.js +32 -0
  378. package/dist/orchestration/dispatch-reconciler.d.ts +1 -0
  379. package/dist/orchestration/dispatch-reconciler.js +16 -0
  380. package/dist/orchestration/durable-helpers.d.ts +4 -0
  381. package/dist/orchestration/durable-helpers.js +42 -0
  382. package/dist/orchestration/interactions/ask-user-question.d.ts +32 -0
  383. package/dist/orchestration/interactions/ask-user-question.js +182 -0
  384. package/dist/orchestration/interactions/command-action-router.d.ts +47 -0
  385. package/dist/orchestration/interactions/command-action-router.js +91 -0
  386. package/dist/orchestration/interactions/interaction-handlers.d.ts +5 -0
  387. package/dist/orchestration/interactions/interaction-handlers.js +279 -0
  388. package/dist/orchestration/interactions/plan-approvals.d.ts +47 -0
  389. package/dist/orchestration/interactions/plan-approvals.js +77 -0
  390. package/dist/orchestration/interactions/plan-handler.d.ts +6 -0
  391. package/dist/orchestration/interactions/plan-handler.js +12 -0
  392. package/dist/orchestration/lifecycle.d.ts +50 -0
  393. package/dist/orchestration/lifecycle.js +308 -0
  394. package/dist/orchestration/orchestrator.d.ts +29 -0
  395. package/dist/orchestration/orchestrator.js +25 -0
  396. package/dist/orchestration/routing/commands/cancel.d.ts +10 -0
  397. package/dist/orchestration/routing/commands/cancel.js +136 -0
  398. package/dist/orchestration/routing/commands/channel.d.ts +11 -0
  399. package/dist/orchestration/routing/commands/channel.js +219 -0
  400. package/dist/orchestration/routing/commands/command-context.d.ts +29 -0
  401. package/dist/orchestration/routing/commands/command-context.js +4 -0
  402. package/dist/orchestration/routing/commands/cost.d.ts +3 -0
  403. package/dist/orchestration/routing/commands/cost.js +22 -0
  404. package/dist/orchestration/routing/commands/device.d.ts +6 -0
  405. package/dist/orchestration/routing/commands/device.js +83 -0
  406. package/dist/orchestration/routing/commands/dispatch.d.ts +2 -0
  407. package/dist/orchestration/routing/commands/dispatch.js +49 -0
  408. package/dist/orchestration/routing/commands/index.d.ts +15 -0
  409. package/dist/orchestration/routing/commands/index.js +130 -0
  410. package/dist/orchestration/routing/commands/mode.d.ts +13 -0
  411. package/dist/orchestration/routing/commands/mode.js +290 -0
  412. package/dist/orchestration/routing/commands/nvtop.d.ts +3 -0
  413. package/dist/orchestration/routing/commands/nvtop.js +103 -0
  414. package/dist/orchestration/routing/commands/orient.d.ts +2 -0
  415. package/dist/orchestration/routing/commands/orient.js +3 -0
  416. package/dist/orchestration/routing/commands/schedule.d.ts +4 -0
  417. package/dist/orchestration/routing/commands/schedule.js +132 -0
  418. package/dist/orchestration/routing/commands/sendfile.d.ts +2 -0
  419. package/dist/orchestration/routing/commands/sendfile.js +92 -0
  420. package/dist/orchestration/routing/commands/session.d.ts +9 -0
  421. package/dist/orchestration/routing/commands/session.js +153 -0
  422. package/dist/orchestration/routing/commands/status.d.ts +7 -0
  423. package/dist/orchestration/routing/commands/status.js +180 -0
  424. package/dist/orchestration/routing/commands/tail.d.ts +2 -0
  425. package/dist/orchestration/routing/commands/tail.js +73 -0
  426. package/dist/orchestration/routing/commands/task.d.ts +6 -0
  427. package/dist/orchestration/routing/commands/task.js +142 -0
  428. package/dist/orchestration/routing/commands/thread-handlers.d.ts +2 -0
  429. package/dist/orchestration/routing/commands/thread-handlers.js +138 -0
  430. package/dist/orchestration/routing/commands/thread.d.ts +2 -0
  431. package/dist/orchestration/routing/commands/thread.js +2 -0
  432. package/dist/orchestration/routing/edit-handler.d.ts +24 -0
  433. package/dist/orchestration/routing/edit-handler.js +161 -0
  434. package/dist/orchestration/routing/file-handler.d.ts +6 -0
  435. package/dist/orchestration/routing/file-handler.js +23 -0
  436. package/dist/orchestration/routing/hook-bridge-subscribers.d.ts +4 -0
  437. package/dist/orchestration/routing/hook-bridge-subscribers.js +79 -0
  438. package/dist/orchestration/routing/hook-bridge.d.ts +30 -0
  439. package/dist/orchestration/routing/hook-bridge.js +112 -0
  440. package/dist/orchestration/routing/message-router.d.ts +6 -0
  441. package/dist/orchestration/routing/message-router.js +70 -0
  442. package/dist/orchestration/routing/webhook.d.ts +10 -0
  443. package/dist/orchestration/routing/webhook.js +239 -0
  444. package/dist/orchestration/status-helpers.d.ts +66 -0
  445. package/dist/orchestration/status-helpers.js +222 -0
  446. package/dist/orchestration/superseded-edits.d.ts +22 -0
  447. package/dist/orchestration/superseded-edits.js +31 -0
  448. package/dist/orchestration/thread-executor.d.ts +31 -0
  449. package/dist/orchestration/thread-executor.js +234 -0
  450. package/dist/platform/adapter.d.ts +28 -0
  451. package/dist/platform/adapter.js +5 -0
  452. package/dist/platform/adapters/feishu.d.ts +66 -0
  453. package/dist/platform/adapters/feishu.js +558 -0
  454. package/dist/platform/adapters/index.d.ts +16 -0
  455. package/dist/platform/adapters/index.js +65 -0
  456. package/dist/platform/adapters/slack.d.ts +90 -0
  457. package/dist/platform/adapters/slack.js +630 -0
  458. package/dist/platform/index.d.ts +12 -0
  459. package/dist/platform/index.js +10 -0
  460. package/dist/platform/interactive-builder.d.ts +27 -0
  461. package/dist/platform/interactive-builder.js +120 -0
  462. package/dist/platform/testing.d.ts +100 -0
  463. package/dist/platform/testing.js +190 -0
  464. package/dist/platform/tool-trace.d.ts +33 -0
  465. package/dist/platform/tool-trace.js +165 -0
  466. package/dist/platform/types.d.ts +176 -0
  467. package/dist/platform/types.js +5 -0
  468. package/dist/platform/utils/rate-limiter.d.ts +92 -0
  469. package/dist/platform/utils/rate-limiter.js +213 -0
  470. package/dist/platform/virtual-message.d.ts +68 -0
  471. package/dist/platform/virtual-message.js +464 -0
  472. package/dist/store/atomic-write.d.ts +6 -0
  473. package/dist/store/atomic-write.js +18 -0
  474. package/dist/store/channel-repo.d.ts +21 -0
  475. package/dist/store/channel-repo.js +55 -0
  476. package/dist/store/conversation-ledger-repo.d.ts +86 -0
  477. package/dist/store/conversation-ledger-repo.js +220 -0
  478. package/dist/store/cost-repo.d.ts +57 -0
  479. package/dist/store/cost-repo.js +135 -0
  480. package/dist/store/execution-repo.d.ts +172 -0
  481. package/dist/store/execution-repo.js +343 -0
  482. package/dist/store/in-memory-repository.d.ts +14 -0
  483. package/dist/store/in-memory-repository.js +31 -0
  484. package/dist/store/json-repository.d.ts +51 -0
  485. package/dist/store/json-repository.js +118 -0
  486. package/dist/store/outbound-queue.d.ts +65 -0
  487. package/dist/store/outbound-queue.js +269 -0
  488. package/dist/store/profile-repo.d.ts +36 -0
  489. package/dist/store/profile-repo.js +144 -0
  490. package/dist/store/project-dir-repo.d.ts +22 -0
  491. package/dist/store/project-dir-repo.js +60 -0
  492. package/dist/store/schedule-repo.d.ts +92 -0
  493. package/dist/store/schedule-repo.js +88 -0
  494. package/dist/store/session-registry-repo.d.ts +38 -0
  495. package/dist/store/session-registry-repo.js +96 -0
  496. package/dist/store/session-repo.d.ts +14 -0
  497. package/dist/store/session-repo.js +56 -0
  498. package/dist/store/task-repo.d.ts +41 -0
  499. package/dist/store/task-repo.js +137 -0
  500. package/dist/store/thread-repo.d.ts +50 -0
  501. package/dist/store/thread-repo.js +190 -0
  502. package/package.json +58 -0
  503. package/scripts/postinstall-restart-trigger.mjs +39 -0
@@ -0,0 +1,349 @@
1
+ ---
2
+ name: compound
3
+ description: "Use at the end of a work session, or when accumulated findings need to be embedded into conventions, skills, or patterns"
4
+ argument-hint: "[optional: 'fast', 'full', 'deep', or no argument for auto-detect]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Grep
11
+ - Glob
12
+ - Agent
13
+ ---
14
+
15
+ # /compound [tier]
16
+
17
+ Compound engineering phase — turns session work into accumulated system advantage by embedding learnings into conventions, skills, and patterns. Invoked at session close or standalone.
18
+
19
+ ## Tier selection
20
+
21
+ $ARGUMENTS
22
+
23
+ If an explicit tier is provided ("fast", "full", "deep"), use it. Otherwise, auto-detect:
24
+
25
+ 1. Read `agent-server/orient-state.json` → `lastFullCompoundAt`
26
+ 2. Read CORTEX.md → `Last consolidation` date, count experiments since then across all projects
27
+ 3. Decision:
28
+ - `lastFullCompoundAt` < 3h ago AND experiments since consolidation < 5 → **FAST**
29
+ - Experiments since consolidation >= 5 → **DEEP** (consolidation is due)
30
+ - Otherwise → **FULL**
31
+
32
+ | Tier | Steps | Duration | When |
33
+ |------|-------|----------|------|
34
+ | Fast | 1, 2, 10 | ~1-2 turns | Full ran <3h ago, no consolidation trigger |
35
+ | Full | 1-3c, 4-6c, 10 | ~2-5 min | Standard end-of-session |
36
+ | Deep | 1-10 | ~10-15 min | 5+ experiments since consolidation, or standalone |
37
+
38
+ **Pre-compound commit:** Check `git status`. If there are uncommitted session changes, commit them first.
39
+
40
+ ## Principles
41
+
42
+ 1. **Small, correct updates over ambitious rewrites.** Fix a typo, add a gotcha, note a pattern. Don't redesign CORTEX.md in a compound step.
43
+ 2. **Evidence over intuition.** Only embed learnings grounded in concrete session experience. "I noticed X went wrong" → update. "I think Y might be better" → task for evaluation.
44
+ 3. **Classify before acting.** Every compound finding falls into one of the output categories in Step 10. Classify first, then act.
45
+ 4. **Respect approval gates.** Governance changes (budget rules, approval workflow, core CORTEX.md structure) → PENDING_APPROVALS.md. Convention clarifications, gotcha additions, project knowledge/index.md updates → apply directly.
46
+
47
+ ---
48
+
49
+ ## Fast compound
50
+
51
+ ### Step 1: Review session work
52
+
53
+ Run `git diff --stat HEAD~3..HEAD` and `git log --oneline -5`. Identify:
54
+ - What task was completed (or partially completed)?
55
+ - What files were created or modified?
56
+ - Were there surprises or difficulties?
57
+
58
+ ### Step 2: Session learnings (4 questions)
59
+
60
+ Ask about this session's work:
61
+
62
+ 1. **Did I discover a non-obvious fact?** (API quirk, hidden constraint, undocumented behavior)
63
+ → If yes: update to project knowledge/index.md or relevant project file.
64
+
65
+ 2. **Did I encounter a failure mode future sessions should avoid?** (silent error, misleading config, common mistake)
66
+ → If yes: add gotcha to relevant skill or project knowledge/index.md.
67
+
68
+ 3. **Did I develop a technique that worked well?** (debugging strategy, analysis pattern, verification method)
69
+ → If yes and generalizes: note as gravity candidate or add to skill.
70
+
71
+ 4. **Did I work around a convention that didn't fit?** (CORTEX.md rule unhelpful, schema too rigid, skill misleading)
72
+ → If yes: update the convention/skill, or note friction.
73
+
74
+ 5. **Did I make or confirm a significant design choice?** (chose approach X over Y, rejected a direction, confirmed an architecture)
75
+ → If yes and meets DR criteria (multiple options, lasting impact, rationale matters): create a Decision Record in the appropriate `decisions/` directory (system-level for cross-project impact, project-level otherwise), then add an inline reference in the corresponding CORTEX.md.
76
+
77
+ ### Step 10 (fast): Act on findings
78
+
79
+ For each finding from Steps 1-2, classify and act per the classification table below. Also do quick task discovery: if an experiment/analysis was completed, check experiments/index.md Findings for implied tasks (failed criteria, insufficient sample, unexplained results, multi-phase gaps).
80
+
81
+ **Output (fast):** `Compound (fast): N actions — <summary>.` or `Compound (fast): no actions.`
82
+
83
+ ---
84
+
85
+ ## Full compound
86
+
87
+ Steps 1-2 are the same as fast compound above. Continue with:
88
+
89
+ ### Step 3: Scan unactioned recommendations
90
+
91
+ First, run the recommendation extractor for a structured scan:
92
+
93
+ ```bash
94
+ npx tsx agent-server/src/recommendation-extractor.ts --days 7 --json
95
+ ```
96
+
97
+ This tool extracts reflection fields, implied tasks from findings, and recommendation sections from skill outputs (diagnose/postmortem/synthesize), deduplicates against existing TASKS.md, and outputs structured candidates.
98
+
99
+ Use the tool output as a starting point, then apply judgment:
100
+
101
+ **Part A: Reflection field scan**
102
+ - Review the `reflection_fields` section from tool output.
103
+ - For each `behavior adjustments`: Has the adjusted behavior been applied in subsequent experiments? If not and it's actionable → create task or apply directly.
104
+ - For each `process defects`: Has a corresponding improvement been made or task created? If not → create task.
105
+ - Skip entries that describe one-time situational adjustments already superseded by later experiments.
106
+
107
+ **Part B: Implied tasks and recommendations**
108
+ - Review the `candidates` section from tool output.
109
+ - For candidates with `is_duplicate: false`: verify they are genuinely actionable, then create task in TASKS.md.
110
+ - For candidates with `is_duplicate: true`: skip (already covered).
111
+ - The tool detects these implied task patterns from experiment findings:
112
+
113
+ | Pattern | Signal phrases | Implied task |
114
+ |---------|----------------|--------------|
115
+ | Failed criterion | "FAIL", "below threshold", "not achieved" | Refined experiment |
116
+ | Insufficient sample | "N too small", "cannot draw conclusions" | Larger replication |
117
+ | Confound | "confound", "cannot separate" | Controlled follow-up |
118
+ | Unexplained result | "unexpected", "mechanism unclear" | Diagnosis |
119
+ | Multi-phase plan | "Phase N" in body | Check phase-tasks exist |
120
+
121
+ **Anti-loop check**: For recommendations about analyzing running experiments, split into preliminary analysis task (satisfiable mid-experiment) and final analysis task (blocked-by experiment completion). Do not create a single "analyze results" task for an experiment that isn't done — it will be selected repeatedly and produce incomplete conclusions each time.
122
+
123
+ ### Step 3c: Correction propagation check
124
+
125
+ Check whether the current session made corrections but lacked Downstream Impact analysis.
126
+
127
+ **Detection method**:
128
+ 1. Use `git diff` to check if the experiments/index.md index status column has newly added `superseded` or `refined` entries
129
+ 2. Check if a CORRECTION paragraph has been added
130
+ 3. Check if the project knowledge/index.md has substantive modifications
131
+
132
+ **For each detected correction**:
133
+ - Check whether the correction record includes a `#### Downstream Impact` paragraph
134
+ - If missing: run grep to search for consumers, build an Impact table, create tasks for `needs-update` items
135
+ - If all corrections already include Impact analysis: skip
136
+
137
+ **Skip condition**: No corrections in this session (no supersede/refine, no CORRECTION, no knowledge/index.md modification)
138
+
139
+ ### Step 4: Surface open investigations
140
+
141
+ Scan active project `experiments/index.md` for unresolved questions:
142
+
143
+ | Pattern | Signal phrases | Question form |
144
+ |---------|----------------|---------------|
145
+ | Unexplained result | "unexpected", "mechanism unclear" | "Why does X despite Y?" |
146
+ | Untestable hypothesis | "cannot be tested", "future work" | "Under what conditions does H hold?" |
147
+ | Methodology confound | "asymmetric setup", "confound" | "How to disentangle X from Y?" |
148
+
149
+ Also check STATUS.md for unresolved "Next" items that imply investigation needs. Generate follow-up tasks in TASKS.yaml if none exist for identified questions.
150
+
151
+ **Part B: Parameter-tuning pattern detection**
152
+
153
+ Scan this session's `git diff` for "threshold adjustments" — changes where a numeric value was changed from X to Y (timeouts, token limits, retry counts, batch sizes, buffer sizes, etc.).
154
+
155
+ For each such change, apply five tests:
156
+
157
+ 1. **Understanding**: Do I know the mechanism that required this adjustment?
158
+ 2. **Generalization**: Is this a problem anyone with a similar system would face?
159
+ 3. **Solution existence**: Is there a known structural solution, or am I just bumping a number?
160
+ 4. **Recurrence**: Has this same parameter (or a related one) been adjusted before?
161
+ 5. **Trade-off nature**: Is the underlying pressure resource-solvable or fundamental?
162
+
163
+ If ≥2 tests point toward "structural problem" for any adjustment → create a structural review task with provenance citing this session's diff.
164
+
165
+ **Signal to watch for**: The same parameter adjusted 2+ times, or two different parameters adjusted for the same underlying reason — these are strong indicators of a structural problem hiding behind incremental fixes.
166
+
167
+ ### Step 5: Detect gravity candidates
168
+
169
+ Check whether this session reveals a pattern that has recurred 3+ times:
170
+ - Did you do something manually that a script or validator could do?
171
+ - Did you apply judgment that has become routine enough for a convention?
172
+ - Did you follow a multi-step procedure that could be simplified into a skill?
173
+
174
+ Cross-reference with project knowledge/index.md entries: if a knowledge entry has been referenced as decision basis in 3+ experiments, flag it as a knowledge→rule promotion candidate for Step 10.
175
+
176
+ ### Step 6: Convention lifecycle check
177
+
178
+ #### 6a: Project knowledge/index.md lifecycle
179
+
180
+ Scan each active project's knowledge/index.md:
181
+
182
+ **(i) Staleness check**
183
+ Knowledge entries with verification date > 60 days → flag as potentially stale. Consider: does the problem still exist? Should evidence be refreshed?
184
+
185
+ **(ii) Contradiction check**
186
+ Compare recent experiment conclusions against knowledge/index.md claims. If a recent experiment's findings contradict a knowledge entry → flag for revision.
187
+
188
+ **(iii) Anti-templating check**
189
+ Read the last 3 experiment Reflection blocks. If `process defects` or `behavior adjustments` have been "none" for 3+ consecutive experiments → force at least one specific observation next time (per CORTEX.md anti-templating rule).
190
+
191
+ #### 6b: Decision staleness
192
+
193
+ Scan `context/decisions/` and project-level `decisions/` directories:
194
+ - Decisions with Status `accepted` older than 90 days where the context has materially changed → flag for review
195
+ - Decisions referenced by K-entries that have been superseded or modified → check if the decision's rationale still holds
196
+
197
+ #### 6c: Skill drift signal
198
+
199
+ If during this session you worked around a skill instruction or found a skill misleading:
200
+ - Note the skill name and the specific instruction that didn't fit
201
+ - Flag for `/refresh-skills` evaluation
202
+ - Do not edit the skill inline during compound — skill edits need full context
203
+
204
+ ### Step 10 (full): Act
205
+
206
+ For each compound finding from Steps 1-6, classify and act:
207
+
208
+ | Category | Criterion | Action |
209
+ |----------|-----------|--------|
210
+ | Direct update | Small, verifiable, self-contained | Apply now (CORTEX.md, skill, project file) |
211
+ | New task | Larger change, needs design | Add to TASKS.md with provenance |
212
+ | Knowledge candidate | Recurring pattern with evidence | Add to project knowledge/index.md |
213
+ | Knowledge→Rule promotion | Knowledge entry referenced in 3+ experiments | Queue to PENDING_APPROVALS.md |
214
+ | Decision record | Significant design choice with alternatives | Create DR in decisions/ + add CORTEX.md inline reference |
215
+ | Approval needed | Governance change | Write to PENDING_APPROVALS.md |
216
+
217
+ **Direct update rules:**
218
+ - Additions preferred over modifications (gotchas safer than rewrites)
219
+ - Self-contained (future agent understands without this session's context)
220
+ - Propagate changes to all locations in same turn
221
+ - **Growth accounting**: When adding 10+ lines to any artifact, identify lines to compress or remove
222
+ - **Gate**: If target skill is >400 lines, must simplify before adding new content. A 300-line skill gets a task; a 400-line skill blocks the addition until simplified. This prevents indefinite deferral of complexity management.
223
+
224
+ **Post-execution state update:**
225
+ Read `agent-server/orient-state.json`, set `lastFullCompoundAt` to current timestamp (milliseconds), write back. Preserve all other fields.
226
+
227
+ **Output (full):**
228
+ ```
229
+ Compound (full) — [date]
230
+
231
+ Session: [1-2 lines what changed]
232
+ Learnings: [knowledge candidates or "none"]
233
+ Recommendations actioned: [count or "none"]
234
+ Corrections propagated: [count or "none" or "no corrections"]
235
+ Open investigations: [count or "none"]
236
+ Gravity candidates: [count or "none"]
237
+ Convention lifecycle: [flags or "none"]
238
+ Tasks discovered: [count or "none"]
239
+ ```
240
+
241
+ If no compound actions: `Compound (full): no actions this session.`
242
+
243
+ ---
244
+
245
+ ## Deep compound
246
+
247
+ Steps 1-6d and 10 are the same as full compound. Continue with:
248
+
249
+ ### Step 7: Consolidation
250
+
251
+ **Trigger**: 5+ new experiment entries (across all projects) since the last deep compound.
252
+
253
+ Read each project's experiments/index.md (entries since last deep compound). Perform:
254
+
255
+ **(a) Pattern scanning**
256
+ Look for recurring patterns across experiments. If a pattern appears in 2+ experiments and isn't already in the relevant project's knowledge/index.md → add new entry to project knowledge/index.md.
257
+ If a pattern confirms existing knowledge → update evidence and verification date.
258
+ Cross-project patterns → add to system-level knowledge under `context/decisions/` or a project-spanning knowledge note.
259
+
260
+ Also scan **Reflection.behavior adjustments** fields: if the same behavioral adjustment appears in 2+ experiments → add to knowledge/index.md (high confidence, verified process improvement).
261
+
262
+ **(b) Gap detection**
263
+ 1. **Process defect clustering**: Same type of process defect in 2+ experiments → log as capability gap
264
+ 2. **Goal achievement degradation**: 3+ experiments with "partially achieved" and similar root causes → log as systematic blocker
265
+ 3. **Repeated blocking**: Same step/action blocked in 3+ cycles → log as process/system gap
266
+
267
+ Classify gaps → Skill gap (propose improvement) | Process gap (propose knowledge/index.md entry or rule) | Knowledge gap (queue an investigation task) | System gap (propose architecture fix).
268
+
269
+ **(c) Knowledge→Rule promotion evaluation**
270
+ Criteria: Entry validated recently + content is process/methodology rule + referenced in 3+ experiments + not redundant with existing CORTEX.md rules.
271
+ Candidates → queue to PENDING_APPROVALS.md.
272
+
273
+ **(d) Effectiveness tracking**
274
+ 1. Knowledge reference scan: check if new experiments reference knowledge/index.md entries as decision basis
275
+ 2. Gap→action closure: check if gaps from previous consolidations had recommended actions that were executed successfully
276
+ 3. Behavioral adjustment follow-through: check if behavior adjustment items from earlier experiments were applied in later ones
277
+
278
+ ### Step 7b: Domain knowledge synthesis check (deep mode only)
279
+
280
+ Check whether any active project has accumulated enough experiment records to warrant domain knowledge synthesis.
281
+
282
+ 1. For each active project, count completed experiments in experiments/index.md
283
+ 2. Check whether the project has a knowledge/index.md (or equivalent consolidated knowledge file)
284
+ 3. If a project has **10+ completed experiments** AND **no knowledge/index.md** (or knowledge/index.md hasn't been updated while 5+ new experiments completed since its last update):
285
+ - Flag as a domain synthesis candidate
286
+ - Create a task: `- [ ] Run domain knowledge synthesis for <project>`
287
+ 4. If a project already has knowledge/index.md and <5 new experiments since last update, skip it
288
+
289
+ **Rationale:** Domain knowledge accumulates across experiments but doesn't naturally consolidate. After 10+ experiments, searching individual records becomes impractical. Periodic synthesis makes accumulated knowledge accessible without reading every source.
290
+
291
+ ### Step 8: Artifact complexity monitoring
292
+
293
+ Check line counts of high-frequency artifacts:
294
+
295
+ | Artifact | Threshold | Action |
296
+ |----------|-----------|--------|
297
+ | Project knowledge/index.md entries | >30 per project | Flag for compression or split |
298
+ | `.claude/skills/*/SKILL.md` | >200 flag, >300 task, >400 gate | Tiered response |
299
+ | `context/projects/*/TASKS.md` | >150 | Create archival task |
300
+
301
+ For each exceeding threshold: check TASKS.md for existing task. Create one if missing.
302
+
303
+ ### Step 10 (deep): Act
304
+
305
+ Same as full compound Step 10, plus:
306
+ - Record consolidation actions (or "no consolidation needed")
307
+ - Record domain synthesis candidates (or "none needed")
308
+ - Record complexity monitoring results
309
+ - Log compression actions if any
310
+
311
+ **Post-execution state update:**
312
+ Read `agent-server/orient-state.json`, set both `lastFullCompoundAt` and `lastDeepCompoundAt` to current timestamp. Write back preserving all fields.
313
+
314
+ **Output (deep):**
315
+ ```
316
+ Compound (deep) — [date]
317
+
318
+ Session: [1-2 lines what changed]
319
+ Learnings: [knowledge candidates or "none"]
320
+ Recommendations actioned: [count or "none"]
321
+ Corrections propagated: [count or "none" or "no corrections"]
322
+ Open investigations: [count or "none"]
323
+ Gravity candidates: [count or "none"]
324
+ Convention lifecycle: [flags or "none"]
325
+ Consolidation: [patterns found / gaps detected / promotions / effectiveness verified]
326
+ Domain synthesis: [projects flagged or "none needed"]
327
+ Complexity: [artifacts flagged or "all within limits"]
328
+ Tasks discovered: [count or "none"]
329
+ ```
330
+
331
+ ---
332
+
333
+ ## Relationship to other skills
334
+
335
+ - **/orient**: Session-start awareness. Compound is session-end embedding. Orient reads what compound wrote — feedback cycle.
336
+ - **/deep-retrospective**: Mines historical JSONL logs across days/weeks. Compound operates on single-session learnings.
337
+ - **/evolve**: Discovers skill improvements. Compound may generate evolution candidates.
338
+ - **/compound-simple**: Lightweight version for quick post-task reflection.
339
+
340
+ ## Anti-patterns
341
+
342
+ - **Compound theater**: Trivial updates to show activity. If nothing learned, log "no compound actions".
343
+ - **Scope creep**: Executing new work. Compound creates tasks and embeds learnings — it does not do the work.
344
+ - **Ungrounded proposals**: Convention changes from single data point. Need 3x recurrence for knowledge entries.
345
+ - **Skipping**: Most common failure. Even "routine work" may have friction worth documenting.
346
+
347
+ ## Commit
348
+
349
+ If standalone: commit changes with descriptive message. If another orchestrated workflow already owns the commit step, defer to that workflow.
@@ -0,0 +1,104 @@
1
+ ---
2
+ name: compound-simple
3
+ description: "Use when completing a task and need lightweight post-task reflection"
4
+ allowed-tools:
5
+ - Read
6
+ - Write
7
+ - Edit
8
+ - Bash
9
+ - Grep
10
+ - Glob
11
+ ---
12
+
13
+ # compound-simple
14
+
15
+ Simplified compound skill for lightweight post-task reflection. Embed session learnings in <3 turns.
16
+
17
+ ## When to use
18
+
19
+ At the end of a task, after completing work but before final output. Also usable when only a quick reflection is needed.
20
+
21
+ ## Procedure
22
+
23
+ Execute these steps in order:
24
+
25
+ ### Step 1: Review what changed
26
+
27
+ Identify this session's own commits (not other workers' commits that may have landed in parallel):
28
+
29
+ 1. Run `git log --oneline -20` to see recent commits
30
+ 2. Identify which commits belong to **this task/session** by matching commit messages to the work you just did (project name, task ID, topic). Ignore commits from other concurrent workers.
31
+ 3. Run `git diff --stat <parent-of-earliest-own-commit>..HEAD` using only your own commit range. If you made no commits, check `git diff --stat` for uncommitted changes instead.
32
+
33
+ Answer:
34
+ - What files changed (in your own commits only)?
35
+ - What was accomplished?
36
+ - Was the task's Done-when condition fully met?
37
+
38
+ ### Step 2: Check for learnings (5 questions)
39
+
40
+ Answer each question. If yes, note what to update:
41
+
42
+ 1. **Something fail unexpectedly?** (silent error, missing dependency, wrong assumption)
43
+ → Note the failure and workaround in task completion note
44
+
45
+ 2. **Something succeed unexpectedly?** (easier than expected, found shortcut)
46
+ → Note the technique for potential reuse
47
+
48
+ 3. **Workaround worth noting?** (non-obvious trick, configuration quirk)
49
+ → Add to project STATUS.md or task note
50
+
51
+ 4. **Task description miss something?** (prerequisite not listed, scope underestimated)
52
+ → Note for future task writing improvement
53
+
54
+ 5. **Anything reduce work efficiency?** (misleading requirements, confusing docs, awkward tool behavior, wrong parameters, tiny annoyances, or other friction)
55
+ → Write it to the relevant project's `ISSUES.md`: what happened, when you hit it, and how you investigated it. Record even small friction if it slowed you down at all — minor annoyances are still worth capturing because a later model can remove the root cause.
56
+
57
+ ### Step 3: Check for implied tasks
58
+
59
+ If you completed an experiment/analysis, scan results for:
60
+ - "FAIL" or "below threshold" → task: refined experiment
61
+ - "N too small" → task: larger replication
62
+ - "unexpected", "mechanism unclear" → task: diagnosis
63
+ - Multi-phase plan → check phase tasks exist
64
+ - New bugs discovered → task: bug fix
65
+ - Documentation outdated → task: doc update
66
+
67
+ ### Step 4: Act on findings
68
+
69
+ For each compound opportunity:
70
+
71
+ | Type | Action |
72
+ |------|--------|
73
+ | Small update (1-3 lines) | Apply directly to file (STATUS.md, task note, ISSUES.md) |
74
+ | Larger change | Create task in TASKS.md with provenance |
75
+ | Process improvement | Note in task completion output for orchestrator |
76
+
77
+ ### Step 5: Report actions
78
+
79
+ Output in this format:
80
+
81
+ ```
82
+ Compound: N actions
83
+ - <action 1>
84
+ - <action 2>
85
+ ...
86
+ ```
87
+
88
+ If no actions: `Compound: no actions this session.`
89
+
90
+ ## What NOT to do
91
+
92
+ - Do NOT run full `/compound` — that's for the orchestrator
93
+ - Do NOT manage K-entries in CORTEX.md — orchestrator concern
94
+ - Do NOT run consolidation or convention lifecycle checks
95
+ - Do NOT start new work — compound embeds learnings only
96
+ - Do NOT add >10 lines to any file without identifying lines to compress
97
+ - Do NOT make governance changes — note them for the orchestrator
98
+
99
+ ## Key files to update
100
+
101
+ - Project `STATUS.md` — if work changed project state
102
+ - Project `TASKS.md` — implied follow-up tasks
103
+ - Project `ISSUES.md` — workflow friction that reduced efficiency
104
+ - Task completion note — learnings and findings for callback
@@ -0,0 +1,88 @@
1
+ ---
2
+ name: critique
3
+ description: "Adversarial review of plans, findings, or designs before committing. Use before: multi-file plans, experiment conclusions (experiments/EXP-NNN.md) that others will cite, or architecture changes from /solution-design. Prioritize when irreversible or consumed by fleet workers."
4
+ allowed-tools:
5
+ - Read
6
+ - Grep
7
+ - Glob
8
+ argument-hint: "[file path or description of artifact to review]"
9
+ ---
10
+
11
+ # /critique <path or description>
12
+
13
+ You are an adversarial internal reviewer. Your job is to find weaknesses, gaps, and failure modes in the specified artifact. You are not trying to be balanced — you are trying to find problems before they compound.
14
+
15
+ The argument is a file path or a description of an artifact to review. If a file path, read it first.
16
+
17
+ ## When to use this vs alternatives
18
+
19
+ - **Use `/critique`** for broad adversarial review of any artifact (plans, designs, implementations, reports). Covers 10 failure dimensions; wide but shallow on each.
20
+ - **Use `/review`** when the artifact contains specific empirical findings/conclusions you want to validate one by one. Deeper on finding validity, narrower in scope. Also validates metric definitions upstream.
21
+ - **Use `/simplify`** when the primary concern is unnecessary complexity rather than correctness. Simplify asks "should this exist?"; critique asks "is this wrong?"
22
+ - **Use `/solution-design`** before implementation to prevent architecture-level mistakes. Solution-design is proactive; critique is reactive.
23
+
24
+ ## Failure Dimensions
25
+
26
+ Evaluate the artifact against each of these failure modes. Skip any that are clearly irrelevant, but err toward inclusion.
27
+
28
+ ### 1. Layer misattribution
29
+ Is a problem attributed to the wrong layer? (e.g., calling something a "model problem" when it's actually a workflow or evaluation gap)
30
+
31
+ ### 2. Interaction blindness
32
+ Does the analysis treat different system layers as independent when they interact? (e.g., ignoring how interface constraints shape what the model can express)
33
+
34
+ ### 3. Grounding failure
35
+ Are claims about capability made without specifying task, constraints, and success criteria? Are conclusions drawn from anecdote rather than measured rates?
36
+
37
+ ### 4. Single-example reasoning
38
+ Are conclusions drawn from one or few examples rather than distributions? Is variance acknowledged?
39
+
40
+ ### 5. Stalled gravity
41
+ Are there manual workarounds or recurring fixes that should have moved downward (been formalized) but haven't? Is the artifact perpetuating a hack instead of systematizing it?
42
+
43
+ ### 6. Provenance gaps
44
+ Are claims made without traceable sources? Are URLs/DOIs missing? Are results reported without the commands/scripts that produced them? (Cross-reference with provenance requirement: "every numerical claim must include script + data file or inline arithmetic.")
45
+
46
+ ### 7. Scope drift
47
+ Has the artifact strayed from the project's stated Mission and Done-when? Are new goals being introduced without updating the mission?
48
+
49
+ ### 8. Missing uncertainty
50
+ Are there places where the author should have said "we don't know" but instead filled with plausible-sounding text? Are confidence levels stated?
51
+
52
+ ### 9. Schema violations
53
+ Does the artifact follow the relevant schema from CORTEX.md? Are required fields present? (experiment file format, DR schema, task schema, etc.)
54
+
55
+ ### 10. Anthropomorphic model explanations
56
+ Does the artifact attribute LLM failures to human psychological states (pressure, confusion, fatigue, rushing, carelessness)? LLMs do not experience these. Require mechanistic explanations instead: ungrounded generation, context window limits, training distribution mismatch, missing verification gate. Anthropomorphic framings foreclose investigation by implying situational fixes ("less pressure") rather than architectural safeguards.
57
+
58
+ ## Output format
59
+
60
+ ```
61
+ ## Critique: <artifact name or path>
62
+
63
+ ### Summary
64
+ <1-2 sentence overall assessment — how serious are the issues?>
65
+
66
+ ### Issues
67
+
68
+ #### <dimension name>
69
+ <specific finding with evidence — quote or reference the artifact>
70
+ Severity: high | medium | low
71
+ Suggestion: <concrete action to fix>
72
+
73
+ [repeat for each issue found]
74
+
75
+ ### What's working
76
+ <1-2 things the artifact does well — be specific>
77
+ ```
78
+
79
+ Be specific. Quote the artifact. Point to exact lines or sections. Vague criticism ("could be better") is worse than no criticism.
80
+
81
+ ## Task Bridge
82
+
83
+ For high-severity issues with concrete suggestions:
84
+ 1. Create a task in the relevant project's TASKS.md
85
+ 2. `Done when:` derived from the suggestion
86
+ 3. `Why:` referencing this critique and the artifact reviewed
87
+
88
+ Skip medium/low-severity issues — these inform the artifact author but don't warrant dedicated tasks.