cognitive-core 0.1.0 → 0.1.2

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 (637) hide show
  1. package/.claude/settings.json +88 -0
  2. package/.claude/settings.local.json +11 -0
  3. package/.entire/settings.json +4 -0
  4. package/README.md +524 -254
  5. package/dist/atlas.d.ts +144 -6
  6. package/dist/atlas.d.ts.map +1 -1
  7. package/dist/atlas.js +339 -10
  8. package/dist/atlas.js.map +1 -1
  9. package/dist/embeddings/provider.d.ts.map +1 -1
  10. package/dist/embeddings/provider.js +6 -3
  11. package/dist/embeddings/provider.js.map +1 -1
  12. package/dist/index.d.ts +8 -6
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +37 -6
  15. package/dist/index.js.map +1 -1
  16. package/dist/learning/index.d.ts +5 -1
  17. package/dist/learning/index.d.ts.map +1 -1
  18. package/dist/learning/index.js +8 -2
  19. package/dist/learning/index.js.map +1 -1
  20. package/dist/learning/knowledge-extractor.d.ts +56 -0
  21. package/dist/learning/knowledge-extractor.d.ts.map +1 -0
  22. package/dist/learning/knowledge-extractor.js +336 -0
  23. package/dist/learning/knowledge-extractor.js.map +1 -0
  24. package/dist/learning/meta-learner.d.ts +7 -0
  25. package/dist/learning/meta-learner.d.ts.map +1 -1
  26. package/dist/learning/meta-learner.js +43 -0
  27. package/dist/learning/meta-learner.js.map +1 -1
  28. package/dist/learning/pipeline.d.ts +24 -0
  29. package/dist/learning/pipeline.d.ts.map +1 -1
  30. package/dist/learning/pipeline.js +70 -4
  31. package/dist/learning/pipeline.js.map +1 -1
  32. package/dist/learning/team-ingester.d.ts +152 -0
  33. package/dist/learning/team-ingester.d.ts.map +1 -0
  34. package/dist/learning/team-ingester.js +333 -0
  35. package/dist/learning/team-ingester.js.map +1 -0
  36. package/dist/learning/team-meta-learner.d.ts +50 -0
  37. package/dist/learning/team-meta-learner.d.ts.map +1 -0
  38. package/dist/learning/team-meta-learner.js +417 -0
  39. package/dist/learning/team-meta-learner.js.map +1 -0
  40. package/dist/learning/team-pipeline.d.ts +76 -0
  41. package/dist/learning/team-pipeline.d.ts.map +1 -0
  42. package/dist/learning/team-pipeline.js +266 -0
  43. package/dist/learning/team-pipeline.js.map +1 -0
  44. package/dist/learning/trajectory-sources/dataclaw.d.ts +41 -0
  45. package/dist/learning/trajectory-sources/dataclaw.d.ts.map +1 -0
  46. package/dist/learning/trajectory-sources/dataclaw.js +330 -0
  47. package/dist/learning/trajectory-sources/dataclaw.js.map +1 -0
  48. package/dist/learning/trajectory-sources/entire.d.ts +28 -0
  49. package/dist/learning/trajectory-sources/entire.d.ts.map +1 -0
  50. package/dist/learning/trajectory-sources/entire.js +182 -0
  51. package/dist/learning/trajectory-sources/entire.js.map +1 -0
  52. package/dist/learning/trajectory-sources/file.d.ts +23 -0
  53. package/dist/learning/trajectory-sources/file.d.ts.map +1 -0
  54. package/dist/learning/trajectory-sources/file.js +101 -0
  55. package/dist/learning/trajectory-sources/file.js.map +1 -0
  56. package/dist/learning/trajectory-sources/huggingface.d.ts +36 -0
  57. package/dist/learning/trajectory-sources/huggingface.d.ts.map +1 -0
  58. package/dist/learning/trajectory-sources/huggingface.js +157 -0
  59. package/dist/learning/trajectory-sources/huggingface.js.map +1 -0
  60. package/dist/learning/trajectory-sources/in-memory.d.ts +21 -0
  61. package/dist/learning/trajectory-sources/in-memory.d.ts.map +1 -0
  62. package/dist/learning/trajectory-sources/in-memory.js +43 -0
  63. package/dist/learning/trajectory-sources/in-memory.js.map +1 -0
  64. package/dist/learning/trajectory-sources/index.d.ts +7 -0
  65. package/dist/learning/trajectory-sources/index.d.ts.map +1 -0
  66. package/dist/learning/trajectory-sources/index.js +7 -0
  67. package/dist/learning/trajectory-sources/index.js.map +1 -0
  68. package/dist/learning/trajectory-sources/pipeline.d.ts +24 -0
  69. package/dist/learning/trajectory-sources/pipeline.d.ts.map +1 -0
  70. package/dist/learning/trajectory-sources/pipeline.js +47 -0
  71. package/dist/learning/trajectory-sources/pipeline.js.map +1 -0
  72. package/dist/memory/graph-layers/base.d.ts +29 -0
  73. package/dist/memory/graph-layers/base.d.ts.map +1 -0
  74. package/dist/memory/graph-layers/base.js +143 -0
  75. package/dist/memory/graph-layers/base.js.map +1 -0
  76. package/dist/memory/graph-layers/causal.d.ts +14 -0
  77. package/dist/memory/graph-layers/causal.d.ts.map +1 -0
  78. package/dist/memory/graph-layers/causal.js +14 -0
  79. package/dist/memory/graph-layers/causal.js.map +1 -0
  80. package/dist/memory/graph-layers/entity.d.ts +14 -0
  81. package/dist/memory/graph-layers/entity.d.ts.map +1 -0
  82. package/dist/memory/graph-layers/entity.js +14 -0
  83. package/dist/memory/graph-layers/entity.js.map +1 -0
  84. package/dist/memory/graph-layers/index.d.ts +6 -0
  85. package/dist/memory/graph-layers/index.d.ts.map +1 -0
  86. package/dist/memory/graph-layers/index.js +6 -0
  87. package/dist/memory/graph-layers/index.js.map +1 -0
  88. package/dist/memory/graph-layers/semantic.d.ts +14 -0
  89. package/dist/memory/graph-layers/semantic.d.ts.map +1 -0
  90. package/dist/memory/graph-layers/semantic.js +14 -0
  91. package/dist/memory/graph-layers/semantic.js.map +1 -0
  92. package/dist/memory/graph-layers/temporal.d.ts +14 -0
  93. package/dist/memory/graph-layers/temporal.d.ts.map +1 -0
  94. package/dist/memory/graph-layers/temporal.js +14 -0
  95. package/dist/memory/graph-layers/temporal.js.map +1 -0
  96. package/dist/memory/index.d.ts +8 -0
  97. package/dist/memory/index.d.ts.map +1 -1
  98. package/dist/memory/index.js +10 -0
  99. package/dist/memory/index.js.map +1 -1
  100. package/dist/memory/knowledge-bank.d.ts +220 -0
  101. package/dist/memory/knowledge-bank.d.ts.map +1 -0
  102. package/dist/memory/knowledge-bank.js +1003 -0
  103. package/dist/memory/knowledge-bank.js.map +1 -0
  104. package/dist/memory/knowledge-defrag.d.ts +49 -0
  105. package/dist/memory/knowledge-defrag.d.ts.map +1 -0
  106. package/dist/memory/knowledge-defrag.js +257 -0
  107. package/dist/memory/knowledge-defrag.js.map +1 -0
  108. package/dist/memory/knowledge-graph.d.ts +41 -0
  109. package/dist/memory/knowledge-graph.d.ts.map +1 -0
  110. package/dist/memory/knowledge-graph.js +273 -0
  111. package/dist/memory/knowledge-graph.js.map +1 -0
  112. package/dist/memory/search-provider.d.ts +31 -0
  113. package/dist/memory/search-provider.d.ts.map +1 -0
  114. package/dist/memory/search-provider.js +2 -0
  115. package/dist/memory/search-provider.js.map +1 -0
  116. package/dist/memory/search-providers/index.d.ts +3 -0
  117. package/dist/memory/search-providers/index.d.ts.map +1 -0
  118. package/dist/memory/search-providers/index.js +3 -0
  119. package/dist/memory/search-providers/index.js.map +1 -0
  120. package/dist/memory/search-providers/minimem.d.ts +43 -0
  121. package/dist/memory/search-providers/minimem.d.ts.map +1 -0
  122. package/dist/memory/search-providers/minimem.js +56 -0
  123. package/dist/memory/search-providers/minimem.js.map +1 -0
  124. package/dist/memory/search-providers/text-similarity.d.ts +15 -0
  125. package/dist/memory/search-providers/text-similarity.d.ts.map +1 -0
  126. package/dist/memory/search-providers/text-similarity.js +21 -0
  127. package/dist/memory/search-providers/text-similarity.js.map +1 -0
  128. package/dist/memory/skill-exporter.d.ts +75 -0
  129. package/dist/memory/skill-exporter.d.ts.map +1 -0
  130. package/dist/memory/skill-exporter.js +248 -0
  131. package/dist/memory/skill-exporter.js.map +1 -0
  132. package/dist/memory/system.d.ts +15 -3
  133. package/dist/memory/system.d.ts.map +1 -1
  134. package/dist/memory/system.js +46 -8
  135. package/dist/memory/system.js.map +1 -1
  136. package/dist/memory/team-experience.d.ts +298 -0
  137. package/dist/memory/team-experience.d.ts.map +1 -0
  138. package/dist/memory/team-experience.js +355 -0
  139. package/dist/memory/team-experience.js.map +1 -0
  140. package/dist/runtime/backends/acp-protocol.d.ts +49 -0
  141. package/dist/runtime/backends/acp-protocol.d.ts.map +1 -0
  142. package/dist/runtime/backends/acp-protocol.js +166 -0
  143. package/dist/runtime/backends/acp-protocol.js.map +1 -0
  144. package/dist/runtime/backends/acp.d.ts +26 -26
  145. package/dist/runtime/backends/acp.d.ts.map +1 -1
  146. package/dist/runtime/backends/acp.js +32 -156
  147. package/dist/runtime/backends/acp.js.map +1 -1
  148. package/dist/runtime/backends/index.d.ts +3 -1
  149. package/dist/runtime/backends/index.d.ts.map +1 -1
  150. package/dist/runtime/backends/index.js +3 -1
  151. package/dist/runtime/backends/index.js.map +1 -1
  152. package/dist/runtime/backends/macro-agent.d.ts +104 -0
  153. package/dist/runtime/backends/macro-agent.d.ts.map +1 -0
  154. package/dist/runtime/backends/macro-agent.js +107 -0
  155. package/dist/runtime/backends/macro-agent.js.map +1 -0
  156. package/dist/runtime/compute-provider.d.ts +87 -0
  157. package/dist/runtime/compute-provider.d.ts.map +1 -0
  158. package/dist/runtime/compute-provider.js +87 -0
  159. package/dist/runtime/compute-provider.js.map +1 -0
  160. package/dist/runtime/index.d.ts +3 -2
  161. package/dist/runtime/index.d.ts.map +1 -1
  162. package/dist/runtime/index.js +3 -1
  163. package/dist/runtime/index.js.map +1 -1
  164. package/dist/runtime/manager.d.ts +37 -4
  165. package/dist/runtime/manager.d.ts.map +1 -1
  166. package/dist/runtime/manager.js +139 -20
  167. package/dist/runtime/manager.js.map +1 -1
  168. package/dist/runtime/types.d.ts +38 -0
  169. package/dist/runtime/types.d.ts.map +1 -1
  170. package/dist/search/evaluator.d.ts +7 -0
  171. package/dist/search/evaluator.d.ts.map +1 -1
  172. package/dist/search/evaluator.js +24 -4
  173. package/dist/search/evaluator.js.map +1 -1
  174. package/dist/search/index.d.ts +1 -0
  175. package/dist/search/index.d.ts.map +1 -1
  176. package/dist/search/index.js +2 -0
  177. package/dist/search/index.js.map +1 -1
  178. package/dist/search/refinement-loop.d.ts +17 -0
  179. package/dist/search/refinement-loop.d.ts.map +1 -1
  180. package/dist/search/refinement-loop.js +77 -6
  181. package/dist/search/refinement-loop.js.map +1 -1
  182. package/dist/search/refinement-types.d.ts +2 -2
  183. package/dist/search/team-router.d.ts +91 -0
  184. package/dist/search/team-router.d.ts.map +1 -0
  185. package/dist/search/team-router.js +315 -0
  186. package/dist/search/team-router.js.map +1 -0
  187. package/dist/session-bank/git-reader.d.ts +39 -0
  188. package/dist/session-bank/git-reader.d.ts.map +1 -0
  189. package/dist/session-bank/git-reader.js +165 -0
  190. package/dist/session-bank/git-reader.js.map +1 -0
  191. package/dist/session-bank/index.d.ts +5 -0
  192. package/dist/session-bank/index.d.ts.map +1 -0
  193. package/dist/session-bank/index.js +4 -0
  194. package/dist/session-bank/index.js.map +1 -0
  195. package/dist/session-bank/parser.d.ts +39 -0
  196. package/dist/session-bank/parser.d.ts.map +1 -0
  197. package/dist/session-bank/parser.js +231 -0
  198. package/dist/session-bank/parser.js.map +1 -0
  199. package/dist/session-bank/session-bank.d.ts +35 -0
  200. package/dist/session-bank/session-bank.d.ts.map +1 -0
  201. package/dist/session-bank/session-bank.js +326 -0
  202. package/dist/session-bank/session-bank.js.map +1 -0
  203. package/dist/session-bank/types.d.ts +129 -0
  204. package/dist/session-bank/types.d.ts.map +1 -0
  205. package/dist/session-bank/types.js +7 -0
  206. package/dist/session-bank/types.js.map +1 -0
  207. package/dist/surfacing/index.d.ts +4 -0
  208. package/dist/surfacing/index.d.ts.map +1 -1
  209. package/dist/surfacing/index.js +3 -0
  210. package/dist/surfacing/index.js.map +1 -1
  211. package/dist/surfacing/publisher.d.ts +22 -0
  212. package/dist/surfacing/publisher.d.ts.map +1 -0
  213. package/dist/surfacing/publisher.js +9 -0
  214. package/dist/surfacing/publisher.js.map +1 -0
  215. package/dist/surfacing/skill-library.d.ts +12 -0
  216. package/dist/surfacing/skill-library.d.ts.map +1 -1
  217. package/dist/surfacing/skill-library.js +26 -0
  218. package/dist/surfacing/skill-library.js.map +1 -1
  219. package/dist/surfacing/skill-publisher.d.ts +43 -0
  220. package/dist/surfacing/skill-publisher.d.ts.map +1 -0
  221. package/dist/surfacing/skill-publisher.js +197 -0
  222. package/dist/surfacing/skill-publisher.js.map +1 -0
  223. package/dist/surfacing/sqlite-storage-adapter.d.ts +42 -0
  224. package/dist/surfacing/sqlite-storage-adapter.d.ts.map +1 -0
  225. package/dist/surfacing/sqlite-storage-adapter.js +207 -0
  226. package/dist/surfacing/sqlite-storage-adapter.js.map +1 -0
  227. package/dist/surfacing/team-skill-library.d.ts +180 -0
  228. package/dist/surfacing/team-skill-library.d.ts.map +1 -0
  229. package/dist/surfacing/team-skill-library.js +384 -0
  230. package/dist/surfacing/team-skill-library.js.map +1 -0
  231. package/dist/types/config.d.ts +1218 -44
  232. package/dist/types/config.d.ts.map +1 -1
  233. package/dist/types/config.js +216 -0
  234. package/dist/types/config.js.map +1 -1
  235. package/dist/types/dataclaw.d.ts +286 -0
  236. package/dist/types/dataclaw.d.ts.map +1 -0
  237. package/dist/types/dataclaw.js +84 -0
  238. package/dist/types/dataclaw.js.map +1 -0
  239. package/dist/types/index.d.ts +8 -1
  240. package/dist/types/index.d.ts.map +1 -1
  241. package/dist/types/index.js +13 -1
  242. package/dist/types/index.js.map +1 -1
  243. package/dist/types/knowledge-graph.d.ts +148 -0
  244. package/dist/types/knowledge-graph.d.ts.map +1 -0
  245. package/dist/types/knowledge-graph.js +40 -0
  246. package/dist/types/knowledge-graph.js.map +1 -0
  247. package/dist/types/knowledge.d.ts +280 -0
  248. package/dist/types/knowledge.d.ts.map +1 -0
  249. package/dist/types/knowledge.js +191 -0
  250. package/dist/types/knowledge.js.map +1 -0
  251. package/dist/types/team-meta.d.ts +160 -0
  252. package/dist/types/team-meta.d.ts.map +1 -0
  253. package/dist/types/team-meta.js +42 -0
  254. package/dist/types/team-meta.js.map +1 -0
  255. package/dist/types/team-playbook.d.ts +276 -0
  256. package/dist/types/team-playbook.d.ts.map +1 -0
  257. package/dist/types/team-playbook.js +85 -0
  258. package/dist/types/team-playbook.js.map +1 -0
  259. package/dist/types/team-trajectory.d.ts +305 -0
  260. package/dist/types/team-trajectory.d.ts.map +1 -0
  261. package/dist/types/team-trajectory.js +304 -0
  262. package/dist/types/team-trajectory.js.map +1 -0
  263. package/dist/types/trajectory-source.d.ts +39 -0
  264. package/dist/types/trajectory-source.d.ts.map +1 -0
  265. package/dist/types/trajectory-source.js +2 -0
  266. package/dist/types/trajectory-source.js.map +1 -0
  267. package/dist/utils/frontmatter.d.ts +34 -0
  268. package/dist/utils/frontmatter.d.ts.map +1 -0
  269. package/dist/utils/frontmatter.js +93 -0
  270. package/dist/utils/frontmatter.js.map +1 -0
  271. package/dist/utils/index.d.ts +1 -0
  272. package/dist/utils/index.d.ts.map +1 -1
  273. package/dist/utils/index.js +1 -0
  274. package/dist/utils/index.js.map +1 -1
  275. package/dist/workspace/index.d.ts +6 -0
  276. package/dist/workspace/index.d.ts.map +1 -0
  277. package/dist/workspace/index.js +11 -0
  278. package/dist/workspace/index.js.map +1 -0
  279. package/dist/workspace/runner.d.ts +50 -0
  280. package/dist/workspace/runner.d.ts.map +1 -0
  281. package/dist/workspace/runner.js +219 -0
  282. package/dist/workspace/runner.js.map +1 -0
  283. package/dist/workspace/skill-converter.d.ts +18 -0
  284. package/dist/workspace/skill-converter.d.ts.map +1 -0
  285. package/dist/workspace/skill-converter.js +257 -0
  286. package/dist/workspace/skill-converter.js.map +1 -0
  287. package/dist/workspace/templates/index.d.ts +11 -0
  288. package/dist/workspace/templates/index.d.ts.map +1 -0
  289. package/dist/workspace/templates/index.js +21 -0
  290. package/dist/workspace/templates/index.js.map +1 -0
  291. package/dist/workspace/templates/knowledge-defrag.d.ts +25 -0
  292. package/dist/workspace/templates/knowledge-defrag.d.ts.map +1 -0
  293. package/dist/workspace/templates/knowledge-defrag.js +154 -0
  294. package/dist/workspace/templates/knowledge-defrag.js.map +1 -0
  295. package/dist/workspace/templates/knowledge-extraction.d.ts +25 -0
  296. package/dist/workspace/templates/knowledge-extraction.d.ts.map +1 -0
  297. package/dist/workspace/templates/knowledge-extraction.js +246 -0
  298. package/dist/workspace/templates/knowledge-extraction.js.map +1 -0
  299. package/dist/workspace/templates/meta-reflection.d.ts +47 -0
  300. package/dist/workspace/templates/meta-reflection.d.ts.map +1 -0
  301. package/dist/workspace/templates/meta-reflection.js +135 -0
  302. package/dist/workspace/templates/meta-reflection.js.map +1 -0
  303. package/dist/workspace/templates/playbook-extraction.d.ts +20 -0
  304. package/dist/workspace/templates/playbook-extraction.d.ts.map +1 -0
  305. package/dist/workspace/templates/playbook-extraction.js +189 -0
  306. package/dist/workspace/templates/playbook-extraction.js.map +1 -0
  307. package/dist/workspace/templates/refinement-analysis.d.ts +31 -0
  308. package/dist/workspace/templates/refinement-analysis.d.ts.map +1 -0
  309. package/dist/workspace/templates/refinement-analysis.js +107 -0
  310. package/dist/workspace/templates/refinement-analysis.js.map +1 -0
  311. package/dist/workspace/templates/solution-evaluation.d.ts +21 -0
  312. package/dist/workspace/templates/solution-evaluation.d.ts.map +1 -0
  313. package/dist/workspace/templates/solution-evaluation.js +131 -0
  314. package/dist/workspace/templates/solution-evaluation.js.map +1 -0
  315. package/dist/workspace/templates/team-playbook-extraction.d.ts +44 -0
  316. package/dist/workspace/templates/team-playbook-extraction.d.ts.map +1 -0
  317. package/dist/workspace/templates/team-playbook-extraction.js +497 -0
  318. package/dist/workspace/templates/team-playbook-extraction.js.map +1 -0
  319. package/dist/workspace/templates/team-trajectory-analysis.d.ts +19 -0
  320. package/dist/workspace/templates/team-trajectory-analysis.d.ts.map +1 -0
  321. package/dist/workspace/templates/team-trajectory-analysis.js +442 -0
  322. package/dist/workspace/templates/team-trajectory-analysis.js.map +1 -0
  323. package/dist/workspace/templates/trajectory-analysis.d.ts +19 -0
  324. package/dist/workspace/templates/trajectory-analysis.d.ts.map +1 -0
  325. package/dist/workspace/templates/trajectory-analysis.js +170 -0
  326. package/dist/workspace/templates/trajectory-analysis.js.map +1 -0
  327. package/dist/workspace/templates/usage-inference.d.ts +19 -0
  328. package/dist/workspace/templates/usage-inference.d.ts.map +1 -0
  329. package/dist/workspace/templates/usage-inference.js +125 -0
  330. package/dist/workspace/templates/usage-inference.js.map +1 -0
  331. package/dist/workspace/types.d.ts +145 -0
  332. package/dist/workspace/types.d.ts.map +1 -0
  333. package/dist/workspace/types.js +17 -0
  334. package/dist/workspace/types.js.map +1 -0
  335. package/docs/DESIGN-agentic-workspace.md +2057 -0
  336. package/docs/DESIGN-semantic-memory-knowledge-bank.md +1789 -0
  337. package/docs/DESIGN-session-bank.md +1134 -0
  338. package/docs/DESIGN-team-extraction-pipeline.md +1369 -0
  339. package/docs/DESIGN-workspace-migration.md +1079 -0
  340. package/docs/PLAN-agentic-workspace-implementation.md +717 -0
  341. package/docs/PLAN-graph-migration.md +299 -0
  342. package/docs/PLAN-session-bank-implementation.md +474 -0
  343. package/docs/PROPOSAL-team-aware-learning.md +1080 -0
  344. package/docs/RESEARCH-semantic-memory-knowledge-structures.md +517 -0
  345. package/docs/RESEARCH-team-trajectory-learning.md +553 -0
  346. package/gaps.md +204 -0
  347. package/package.json +24 -6
  348. package/references/agent-workspace/CLAUDE.md +74 -0
  349. package/references/agent-workspace/README.md +587 -0
  350. package/references/agent-workspace/media/banner.png +0 -0
  351. package/references/agent-workspace/package-lock.json +2061 -0
  352. package/references/agent-workspace/package.json +54 -0
  353. package/references/agent-workspace/src/handle.ts +122 -0
  354. package/references/agent-workspace/src/index.ts +32 -0
  355. package/references/agent-workspace/src/manager.ts +102 -0
  356. package/references/agent-workspace/src/readers/json.ts +71 -0
  357. package/references/agent-workspace/src/readers/markdown.ts +37 -0
  358. package/references/agent-workspace/src/readers/raw.ts +27 -0
  359. package/references/agent-workspace/src/types.ts +68 -0
  360. package/references/agent-workspace/src/validation.ts +93 -0
  361. package/references/agent-workspace/src/writers/json.ts +17 -0
  362. package/references/agent-workspace/src/writers/markdown.ts +27 -0
  363. package/references/agent-workspace/src/writers/raw.ts +22 -0
  364. package/references/agent-workspace/tests/errors.test.ts +652 -0
  365. package/references/agent-workspace/tests/handle.test.ts +144 -0
  366. package/references/agent-workspace/tests/manager.test.ts +124 -0
  367. package/references/agent-workspace/tests/readers.test.ts +205 -0
  368. package/references/agent-workspace/tests/validation.test.ts +196 -0
  369. package/references/agent-workspace/tests/writers.test.ts +108 -0
  370. package/references/agent-workspace/tsconfig.json +20 -0
  371. package/references/agent-workspace/tsup.config.ts +9 -0
  372. package/references/minimem/.claude/settings.json +7 -0
  373. package/references/minimem/.sudocode/issues.jsonl +18 -0
  374. package/references/minimem/.sudocode/specs.jsonl +1 -0
  375. package/references/minimem/CLAUDE.md +310 -0
  376. package/references/minimem/README.md +556 -0
  377. package/references/minimem/claude-plugin/.claude-plugin/plugin.json +10 -0
  378. package/references/minimem/claude-plugin/.mcp.json +7 -0
  379. package/references/minimem/claude-plugin/README.md +158 -0
  380. package/references/minimem/claude-plugin/commands/recall.md +47 -0
  381. package/references/minimem/claude-plugin/commands/remember.md +41 -0
  382. package/references/minimem/claude-plugin/hooks/__tests__/hooks.test.ts +272 -0
  383. package/references/minimem/claude-plugin/hooks/hooks.json +27 -0
  384. package/references/minimem/claude-plugin/hooks/session-end.sh +86 -0
  385. package/references/minimem/claude-plugin/hooks/session-start.sh +85 -0
  386. package/references/minimem/claude-plugin/skills/memory/SKILL.md +108 -0
  387. package/references/minimem/package-lock.json +5373 -0
  388. package/references/minimem/package.json +60 -0
  389. package/references/minimem/scripts/postbuild.js +35 -0
  390. package/references/minimem/src/__tests__/edge-cases.test.ts +371 -0
  391. package/references/minimem/src/__tests__/errors.test.ts +265 -0
  392. package/references/minimem/src/__tests__/helpers.ts +199 -0
  393. package/references/minimem/src/__tests__/internal.test.ts +407 -0
  394. package/references/minimem/src/__tests__/knowledge.test.ts +287 -0
  395. package/references/minimem/src/__tests__/minimem.integration.test.ts +1127 -0
  396. package/references/minimem/src/__tests__/session.test.ts +190 -0
  397. package/references/minimem/src/cli/__tests__/commands.test.ts +759 -0
  398. package/references/minimem/src/cli/commands/__tests__/conflicts.test.ts +141 -0
  399. package/references/minimem/src/cli/commands/append.ts +76 -0
  400. package/references/minimem/src/cli/commands/config.ts +262 -0
  401. package/references/minimem/src/cli/commands/conflicts.ts +413 -0
  402. package/references/minimem/src/cli/commands/daemon.ts +169 -0
  403. package/references/minimem/src/cli/commands/index.ts +12 -0
  404. package/references/minimem/src/cli/commands/init.ts +88 -0
  405. package/references/minimem/src/cli/commands/mcp.ts +177 -0
  406. package/references/minimem/src/cli/commands/push-pull.ts +213 -0
  407. package/references/minimem/src/cli/commands/search.ts +158 -0
  408. package/references/minimem/src/cli/commands/status.ts +84 -0
  409. package/references/minimem/src/cli/commands/sync-init.ts +290 -0
  410. package/references/minimem/src/cli/commands/sync.ts +70 -0
  411. package/references/minimem/src/cli/commands/upsert.ts +197 -0
  412. package/references/minimem/src/cli/config.ts +584 -0
  413. package/references/minimem/src/cli/index.ts +264 -0
  414. package/references/minimem/src/cli/shared.ts +161 -0
  415. package/references/minimem/src/cli/sync/__tests__/central.test.ts +152 -0
  416. package/references/minimem/src/cli/sync/__tests__/conflicts.test.ts +209 -0
  417. package/references/minimem/src/cli/sync/__tests__/daemon.test.ts +118 -0
  418. package/references/minimem/src/cli/sync/__tests__/detection.test.ts +207 -0
  419. package/references/minimem/src/cli/sync/__tests__/integration.test.ts +476 -0
  420. package/references/minimem/src/cli/sync/__tests__/registry.test.ts +363 -0
  421. package/references/minimem/src/cli/sync/__tests__/state.test.ts +255 -0
  422. package/references/minimem/src/cli/sync/__tests__/validation.test.ts +193 -0
  423. package/references/minimem/src/cli/sync/__tests__/watcher.test.ts +178 -0
  424. package/references/minimem/src/cli/sync/central.ts +292 -0
  425. package/references/minimem/src/cli/sync/conflicts.ts +204 -0
  426. package/references/minimem/src/cli/sync/daemon.ts +407 -0
  427. package/references/minimem/src/cli/sync/detection.ts +138 -0
  428. package/references/minimem/src/cli/sync/index.ts +107 -0
  429. package/references/minimem/src/cli/sync/operations.ts +373 -0
  430. package/references/minimem/src/cli/sync/registry.ts +279 -0
  431. package/references/minimem/src/cli/sync/state.ts +355 -0
  432. package/references/minimem/src/cli/sync/validation.ts +206 -0
  433. package/references/minimem/src/cli/sync/watcher.ts +234 -0
  434. package/references/minimem/src/cli/version.ts +34 -0
  435. package/references/minimem/src/core/index.ts +9 -0
  436. package/references/minimem/src/core/indexer.ts +628 -0
  437. package/references/minimem/src/core/searcher.ts +221 -0
  438. package/references/minimem/src/db/schema.ts +183 -0
  439. package/references/minimem/src/db/sqlite-vec.ts +24 -0
  440. package/references/minimem/src/embeddings/__tests__/embeddings.test.ts +431 -0
  441. package/references/minimem/src/embeddings/batch-gemini.ts +392 -0
  442. package/references/minimem/src/embeddings/batch-openai.ts +409 -0
  443. package/references/minimem/src/embeddings/embeddings.ts +434 -0
  444. package/references/minimem/src/index.ts +109 -0
  445. package/references/minimem/src/internal.ts +299 -0
  446. package/references/minimem/src/minimem.ts +1276 -0
  447. package/references/minimem/src/search/__tests__/hybrid.test.ts +247 -0
  448. package/references/minimem/src/search/graph.ts +234 -0
  449. package/references/minimem/src/search/hybrid.ts +151 -0
  450. package/references/minimem/src/search/search.ts +256 -0
  451. package/references/minimem/src/server/__tests__/mcp.test.ts +341 -0
  452. package/references/minimem/src/server/__tests__/tools.test.ts +364 -0
  453. package/references/minimem/src/server/mcp.ts +326 -0
  454. package/references/minimem/src/server/tools.ts +720 -0
  455. package/references/minimem/src/session.ts +460 -0
  456. package/references/minimem/tsconfig.json +19 -0
  457. package/references/minimem/tsup.config.ts +26 -0
  458. package/references/minimem/vitest.config.ts +24 -0
  459. package/references/skill-tree/.claude/settings.json +6 -0
  460. package/references/skill-tree/.sudocode/issues.jsonl +11 -0
  461. package/references/skill-tree/.sudocode/specs.jsonl +1 -0
  462. package/references/skill-tree/CLAUDE.md +150 -0
  463. package/references/skill-tree/README.md +324 -0
  464. package/references/skill-tree/docs/GAPS_v1.md +221 -0
  465. package/references/skill-tree/docs/INTEGRATION_PLAN.md +467 -0
  466. package/references/skill-tree/docs/TODOS.md +91 -0
  467. package/references/skill-tree/docs/anthropic_skill_guide.md +1364 -0
  468. package/references/skill-tree/docs/design/federated-skill-trees.md +524 -0
  469. package/references/skill-tree/docs/design/multi-agent-sync.md +759 -0
  470. package/references/skill-tree/docs/scraper/BRAINSTORM.md +583 -0
  471. package/references/skill-tree/docs/scraper/POC_PLAN.md +420 -0
  472. package/references/skill-tree/docs/scraper/README.md +170 -0
  473. package/references/skill-tree/examples/basic-usage.ts +190 -0
  474. package/references/skill-tree/package-lock.json +1509 -0
  475. package/references/skill-tree/package.json +66 -0
  476. package/references/skill-tree/scraper/README.md +123 -0
  477. package/references/skill-tree/scraper/docs/DESIGN.md +683 -0
  478. package/references/skill-tree/scraper/docs/PLAN.md +336 -0
  479. package/references/skill-tree/scraper/drizzle.config.ts +10 -0
  480. package/references/skill-tree/scraper/package-lock.json +6329 -0
  481. package/references/skill-tree/scraper/package.json +68 -0
  482. package/references/skill-tree/scraper/test/fixtures/invalid-skill/missing-description.md +7 -0
  483. package/references/skill-tree/scraper/test/fixtures/invalid-skill/missing-name.md +7 -0
  484. package/references/skill-tree/scraper/test/fixtures/minimal-skill/SKILL.md +27 -0
  485. package/references/skill-tree/scraper/test/fixtures/skill-json/SKILL.json +21 -0
  486. package/references/skill-tree/scraper/test/fixtures/skill-with-meta/SKILL.md +54 -0
  487. package/references/skill-tree/scraper/test/fixtures/skill-with-meta/_meta.json +24 -0
  488. package/references/skill-tree/scraper/test/fixtures/valid-skill/SKILL.md +93 -0
  489. package/references/skill-tree/scraper/test/fixtures/valid-skill/_meta.json +22 -0
  490. package/references/skill-tree/scraper/tsup.config.ts +14 -0
  491. package/references/skill-tree/scraper/vitest.config.ts +17 -0
  492. package/references/skill-tree/scripts/convert-to-vitest.ts +166 -0
  493. package/references/skill-tree/skills/skill-writer/SKILL.md +339 -0
  494. package/references/skill-tree/skills/skill-writer/references/examples.md +326 -0
  495. package/references/skill-tree/skills/skill-writer/references/patterns.md +210 -0
  496. package/references/skill-tree/skills/skill-writer/references/quality-checklist.md +123 -0
  497. package/references/skill-tree/test/run-all.ts +106 -0
  498. package/references/skill-tree/test/utils.ts +128 -0
  499. package/references/skill-tree/vitest.config.ts +16 -0
  500. package/src/atlas.ts +525 -13
  501. package/src/embeddings/provider.ts +10 -3
  502. package/src/index.ts +127 -5
  503. package/src/learning/index.ts +41 -6
  504. package/src/learning/knowledge-extractor.ts +470 -0
  505. package/src/learning/meta-learner.ts +54 -0
  506. package/src/learning/pipeline.ts +87 -8
  507. package/src/learning/team-ingester.ts +499 -0
  508. package/src/learning/team-meta-learner.ts +558 -0
  509. package/src/learning/team-pipeline.ts +364 -0
  510. package/src/learning/trajectory-sources/dataclaw.ts +403 -0
  511. package/src/learning/trajectory-sources/entire.ts +240 -0
  512. package/src/learning/trajectory-sources/file.ts +136 -0
  513. package/src/learning/trajectory-sources/huggingface.ts +248 -0
  514. package/src/learning/trajectory-sources/in-memory.ts +61 -0
  515. package/src/learning/trajectory-sources/index.ts +15 -0
  516. package/src/learning/trajectory-sources/pipeline.ts +69 -0
  517. package/src/memory/graph-layers/base.ts +184 -0
  518. package/src/memory/graph-layers/causal.ts +16 -0
  519. package/src/memory/graph-layers/entity.ts +16 -0
  520. package/src/memory/graph-layers/index.ts +5 -0
  521. package/src/memory/graph-layers/semantic.ts +16 -0
  522. package/src/memory/graph-layers/temporal.ts +16 -0
  523. package/src/memory/index.ts +45 -0
  524. package/src/memory/knowledge-bank.ts +1260 -0
  525. package/src/memory/knowledge-defrag.ts +329 -0
  526. package/src/memory/knowledge-graph.ts +361 -0
  527. package/src/memory/search-provider.ts +35 -0
  528. package/src/memory/search-providers/index.ts +3 -0
  529. package/src/memory/search-providers/minimem.ts +84 -0
  530. package/src/memory/search-providers/text-similarity.ts +35 -0
  531. package/src/memory/skill-exporter.ts +357 -0
  532. package/src/memory/system.ts +61 -8
  533. package/src/memory/team-experience.ts +604 -0
  534. package/src/runtime/backends/acp-protocol.ts +231 -0
  535. package/src/runtime/backends/acp.ts +57 -196
  536. package/src/runtime/backends/index.ts +14 -0
  537. package/src/runtime/backends/macro-agent.ts +177 -0
  538. package/src/runtime/compute-provider.ts +206 -0
  539. package/src/runtime/index.ts +22 -0
  540. package/src/runtime/manager.ts +167 -23
  541. package/src/runtime/types.ts +41 -0
  542. package/src/search/evaluator.ts +29 -4
  543. package/src/search/index.ts +9 -0
  544. package/src/search/refinement-loop.ts +106 -12
  545. package/src/search/team-router.ts +459 -0
  546. package/src/session-bank/git-reader.ts +190 -0
  547. package/src/session-bank/index.ts +24 -0
  548. package/src/session-bank/parser.ts +366 -0
  549. package/src/session-bank/session-bank.ts +464 -0
  550. package/src/session-bank/types.ts +173 -0
  551. package/src/surfacing/index.ts +23 -0
  552. package/src/surfacing/publisher.ts +23 -0
  553. package/src/surfacing/skill-library.ts +31 -0
  554. package/src/surfacing/skill-publisher.ts +223 -0
  555. package/src/surfacing/sqlite-storage-adapter.ts +301 -0
  556. package/src/surfacing/team-skill-library.ts +610 -0
  557. package/src/types/config.ts +252 -0
  558. package/src/types/dataclaw.ts +99 -0
  559. package/src/types/huggingface-transformers.d.ts +12 -0
  560. package/src/types/index.ts +156 -0
  561. package/src/types/knowledge-graph.ts +246 -0
  562. package/src/types/knowledge.ts +388 -0
  563. package/src/types/team-meta.ts +212 -0
  564. package/src/types/team-playbook.ts +384 -0
  565. package/src/types/team-trajectory.ts +673 -0
  566. package/src/types/trajectory-source.ts +47 -0
  567. package/src/utils/frontmatter.ts +118 -0
  568. package/src/utils/index.ts +7 -0
  569. package/src/workspace/index.ts +48 -0
  570. package/src/workspace/runner.ts +281 -0
  571. package/src/workspace/skill-converter.ts +288 -0
  572. package/src/workspace/templates/index.ts +64 -0
  573. package/src/workspace/templates/knowledge-defrag.ts +223 -0
  574. package/src/workspace/templates/knowledge-extraction.ts +337 -0
  575. package/src/workspace/templates/meta-reflection.ts +208 -0
  576. package/src/workspace/templates/playbook-extraction.ts +240 -0
  577. package/src/workspace/templates/refinement-analysis.ts +162 -0
  578. package/src/workspace/templates/solution-evaluation.ts +199 -0
  579. package/src/workspace/templates/team-playbook-extraction.ts +631 -0
  580. package/src/workspace/templates/team-trajectory-analysis.ts +564 -0
  581. package/src/workspace/templates/trajectory-analysis.ts +234 -0
  582. package/src/workspace/templates/usage-inference.ts +163 -0
  583. package/src/workspace/types.ts +233 -0
  584. package/tests/atlas-knowledge.test.ts +165 -0
  585. package/tests/gap-fixes.test.ts +1103 -0
  586. package/tests/integration/dataclaw-e2e.test.ts +559 -0
  587. package/tests/integration/e2e.test.ts +407 -0
  588. package/tests/integration/entire-e2e.test.ts +187 -0
  589. package/tests/integration/huggingface-e2e.test.ts +627 -0
  590. package/tests/integration/session-bank.test.ts +225 -0
  591. package/tests/integration/skill-tree-wiring.test.ts +152 -0
  592. package/tests/learning/dataclaw-trajectory-source.test.ts +642 -0
  593. package/tests/learning/entire-trajectory-source.test.ts +380 -0
  594. package/tests/learning/huggingface-trajectory-source.test.ts +817 -0
  595. package/tests/learning/knowledge-extractor.test.ts +491 -0
  596. package/tests/learning/team-ingester.test.ts +349 -0
  597. package/tests/learning/team-meta-learner.test.ts +618 -0
  598. package/tests/learning/team-pipeline.test.ts +334 -0
  599. package/tests/learning/trajectory-sources.test.ts +312 -0
  600. package/tests/memory/graph-layers/semantic.test.ts +219 -0
  601. package/tests/memory/knowledge-bank-extraction.test.ts +558 -0
  602. package/tests/memory/knowledge-bank.test.ts +705 -0
  603. package/tests/memory/knowledge-defrag.test.ts +366 -0
  604. package/tests/memory/knowledge-evolution.test.ts +563 -0
  605. package/tests/memory/knowledge-graph.test.ts +492 -0
  606. package/tests/memory/knowledge-inbox.test.ts +258 -0
  607. package/tests/memory/knowledge-minimem.test.ts +251 -0
  608. package/tests/memory/skill-exporter.test.ts +470 -0
  609. package/tests/memory/team-experience.test.ts +411 -0
  610. package/tests/runtime/agent-manager.test.ts +1 -1
  611. package/tests/runtime/compute-provider.test.ts +288 -0
  612. package/tests/runtime/delegate.test.ts +349 -0
  613. package/tests/runtime/macro-agent-backend.test.ts +266 -0
  614. package/tests/search/team-router.test.ts +376 -0
  615. package/tests/session-bank/fixtures/multi-tool-session/full.jsonl +12 -0
  616. package/tests/session-bank/fixtures/multi-tool-session/metadata.json +28 -0
  617. package/tests/session-bank/fixtures/root-metadata.json +18 -0
  618. package/tests/session-bank/fixtures/simple-session/full.jsonl +6 -0
  619. package/tests/session-bank/fixtures/simple-session/metadata.json +38 -0
  620. package/tests/session-bank/git-reader.test.ts +232 -0
  621. package/tests/session-bank/parser.test.ts +321 -0
  622. package/tests/session-bank/session-bank.test.ts +546 -0
  623. package/tests/surfacing/skill-publisher.test.ts +398 -0
  624. package/tests/surfacing/sqlite-storage-adapter.test.ts +218 -0
  625. package/tests/surfacing/team-skill-library.test.ts +444 -0
  626. package/tests/types/team-meta.test.ts +147 -0
  627. package/tests/types/team-playbook.test.ts +246 -0
  628. package/tests/types/team-trajectory.test.ts +557 -0
  629. package/tests/utils/frontmatter.test.ts +208 -0
  630. package/tests/workspace/full-flow.test.ts +839 -0
  631. package/tests/workspace/manager.test.ts +215 -0
  632. package/tests/workspace/runner.test.ts +330 -0
  633. package/tests/workspace/skill-converter.test.ts +205 -0
  634. package/tests/workspace/templates/knowledge-extraction.test.ts +235 -0
  635. package/tests/workspace/templates/team-playbook-extraction.test.ts +341 -0
  636. package/tests/workspace/templates/team-trajectory-analysis.test.ts +417 -0
  637. package/src/learning/llm-extractor.ts +0 -542
@@ -0,0 +1,212 @@
1
+ /**
2
+ * Team Meta-Learning Types
3
+ *
4
+ * Types for meta-learning about team formation and coordination.
5
+ * Observes patterns about which team configurations work for which contexts.
6
+ * The team-level analog of MetaObservation and MetaStrategy.
7
+ */
8
+
9
+ /**
10
+ * TeamMetaObservation - Records team formation decisions and outcomes.
11
+ * The team-level analog of MetaObservation.
12
+ */
13
+ export interface TeamMetaObservation {
14
+ id: string;
15
+ /** Source team trajectory */
16
+ teamTrajectoryId: string;
17
+
18
+ // === FORMATION DECISION ===
19
+ formation: FormationObservation;
20
+
21
+ // === COMPOSITION EFFECTIVENESS ===
22
+ compositionEffectiveness: CompositionObservation;
23
+
24
+ // === COORDINATION EFFECTIVENESS ===
25
+ coordinationEffectiveness: CoordinationObservation;
26
+
27
+ // === OUTCOME ===
28
+ outcome: TeamOutcomeObservation;
29
+
30
+ // === LESSONS ===
31
+ lessons: TeamLessonsLearned;
32
+
33
+ timestamp: Date;
34
+ }
35
+
36
+ /**
37
+ * How the team was formed and why.
38
+ */
39
+ export interface FormationObservation {
40
+ /** Was a team playbook used to form this team? */
41
+ playbookUsed?: string;
42
+ /** Was the team formed from a template or ad-hoc? */
43
+ formationMethod: 'template' | 'playbook' | 'manual' | 'adaptive';
44
+ /** Confidence in the formation decision */
45
+ confidence: number;
46
+ /** Reasoning for formation choice */
47
+ reasoning: string;
48
+ /** Whether the formation was effective (DESIGN doc field) */
49
+ wasEffective?: boolean;
50
+ /** Topology type used (stored for reliable extraction in meta-learner) */
51
+ topologyUsed?: 'hierarchical' | 'flat' | 'wave' | 'custom';
52
+ /** Domain of the task */
53
+ domain?: string;
54
+ }
55
+
56
+ /**
57
+ * How effective was the team composition?
58
+ */
59
+ export interface CompositionObservation {
60
+ /** Were all roles utilized? */
61
+ roleUtilization: Record<string, number>; // role → 0-1 utilization
62
+ /** Were any roles missing that would have helped? */
63
+ missingRoles: string[];
64
+ /** Were any roles redundant? */
65
+ redundantRoles: string[];
66
+ /** Was team size appropriate? */
67
+ teamSizeAssessment: 'too-small' | 'right-sized' | 'too-large';
68
+ /** Was the topology appropriate? */
69
+ topologyAssessment: 'effective' | 'neutral' | 'hindering';
70
+ }
71
+
72
+ /**
73
+ * How effective was the coordination?
74
+ */
75
+ export interface CoordinationObservation {
76
+ /** Was enforcement mode appropriate? */
77
+ enforcementAssessment: 'too-strict' | 'appropriate' | 'too-loose';
78
+ /** Were communication channels well-defined? */
79
+ channelEffectiveness: 'helpful' | 'neutral' | 'noisy';
80
+ /** Were there coordination bottlenecks? */
81
+ bottlenecks: string[];
82
+ /** Actual coordination overhead ratio */
83
+ coordinationOverhead: number;
84
+ }
85
+
86
+ /**
87
+ * Team outcome assessment.
88
+ */
89
+ export interface TeamOutcomeObservation {
90
+ success: boolean;
91
+ quality: 'excellent' | 'good' | 'acceptable' | 'poor';
92
+ /** Was this faster than a single agent would have been? (estimated) */
93
+ speedupEstimate: number; // >1 means team was faster
94
+ /** Cost efficiency: quality / tokens */
95
+ costEfficiency: number;
96
+ }
97
+
98
+ /**
99
+ * Lessons about team formation and coordination.
100
+ */
101
+ export interface TeamLessonsLearned {
102
+ /** What team patterns worked */
103
+ whatWorked: string[];
104
+ /** What team patterns didn't work */
105
+ whatFailed: string[];
106
+ /** Suggestions for future team formation */
107
+ formationSuggestions: string[];
108
+ /** Suggestions for future coordination */
109
+ coordinationSuggestions: string[];
110
+ /** Role-specific suggestions (DESIGN doc field) */
111
+ roleSuggestions?: string[];
112
+ }
113
+
114
+ /**
115
+ * TeamMetaStrategy - Learned patterns about team formation.
116
+ * The team-level analog of MetaStrategy.
117
+ */
118
+ export interface TeamMetaStrategy {
119
+ id: string;
120
+ name: string;
121
+
122
+ /** When to apply this team meta-strategy */
123
+ condition: TeamMetaCondition;
124
+
125
+ /** What formation/coordination adjustments to make */
126
+ adjustment: TeamMetaAdjustment;
127
+
128
+ /** Track effectiveness */
129
+ applicationCount: number;
130
+ successRate: number;
131
+
132
+ createdAt: Date;
133
+ updatedAt: Date;
134
+ }
135
+
136
+ /**
137
+ * Conditions for applying a team meta-strategy.
138
+ */
139
+ export interface TeamMetaCondition {
140
+ /** Task characteristics that trigger this strategy */
141
+ taskCharacteristics: string[];
142
+ /** Available resources */
143
+ resourceConstraints: string[];
144
+ /** Domain context */
145
+ domains: string[];
146
+ }
147
+
148
+ /**
149
+ * Adjustments to team formation and coordination.
150
+ */
151
+ export interface TeamMetaAdjustment {
152
+ /** Topology recommendation */
153
+ topologyBias?: Record<string, number>;
154
+ /** Team size adjustment */
155
+ teamSizeAdjustment: 'increase' | 'decrease' | 'maintain';
156
+ /** Role adjustments */
157
+ roleAdjustments: string[];
158
+ /** Coordination hints */
159
+ coordinationHints: string[];
160
+ /** Enforcement mode recommendation */
161
+ enforcementBias?: 'strict' | 'permissive' | 'audit';
162
+ }
163
+
164
+ // ============================================================
165
+ // Factory functions
166
+ // ============================================================
167
+
168
+ /**
169
+ * Create a new team meta-observation.
170
+ */
171
+ export function createTeamMetaObservation(params: {
172
+ id?: string;
173
+ teamTrajectoryId: string;
174
+ formation: FormationObservation;
175
+ compositionEffectiveness: CompositionObservation;
176
+ coordinationEffectiveness: CoordinationObservation;
177
+ outcome: TeamOutcomeObservation;
178
+ lessons: TeamLessonsLearned;
179
+ }): TeamMetaObservation {
180
+ return {
181
+ id: params.id ?? crypto.randomUUID(),
182
+ teamTrajectoryId: params.teamTrajectoryId,
183
+ formation: params.formation,
184
+ compositionEffectiveness: params.compositionEffectiveness,
185
+ coordinationEffectiveness: params.coordinationEffectiveness,
186
+ outcome: params.outcome,
187
+ lessons: params.lessons,
188
+ timestamp: new Date(),
189
+ };
190
+ }
191
+
192
+ /**
193
+ * Create a new team meta-strategy.
194
+ */
195
+ export function createTeamMetaStrategy(params: {
196
+ id?: string;
197
+ name: string;
198
+ condition: TeamMetaCondition;
199
+ adjustment: TeamMetaAdjustment;
200
+ }): TeamMetaStrategy {
201
+ const now = new Date();
202
+ return {
203
+ id: params.id ?? crypto.randomUUID(),
204
+ name: params.name,
205
+ condition: params.condition,
206
+ adjustment: params.adjustment,
207
+ applicationCount: 0,
208
+ successRate: 0,
209
+ createdAt: now,
210
+ updatedAt: now,
211
+ };
212
+ }
@@ -0,0 +1,384 @@
1
+ /**
2
+ * Team Playbook Types
3
+ *
4
+ * TeamPlaybook - Learned coordination patterns extracted from successful
5
+ * team trajectories. The team-level analog of Playbook.
6
+ *
7
+ * RolePlaybook - How to be effective in a specific team role.
8
+ * Distinct from individual task playbooks (about solving problems alone)
9
+ * and team coordination playbooks (about team composition).
10
+ */
11
+
12
+ // ============================================================
13
+ // Team Coordination Playbook
14
+ // ============================================================
15
+
16
+ /**
17
+ * TeamPlaybook - Learned coordination pattern.
18
+ * Answers: "Given this type of task, how should a team be organized and coordinated?"
19
+ */
20
+ export interface TeamPlaybook {
21
+ id: string;
22
+ name: string; // kebab-case, e.g. "wave-parallel-refactoring"
23
+
24
+ // === APPLICABILITY (when to use this team pattern) ===
25
+ applicability: TeamPlaybookApplicability;
26
+
27
+ // === COMPOSITION (what team to build) ===
28
+ composition: TeamCompositionGuidance;
29
+
30
+ // === COORDINATION (how the team should work together) ===
31
+ coordination: TeamCoordinationGuidance;
32
+
33
+ // === VERIFICATION ===
34
+ verification: TeamPlaybookVerification;
35
+
36
+ // === EVOLUTION ===
37
+ evolution: TeamPlaybookEvolution;
38
+
39
+ // === METADATA ===
40
+ confidence: number; // 0-1
41
+ complexity: 'simple' | 'moderate' | 'complex' | 'epic';
42
+ createdAt: Date;
43
+ updatedAt: Date;
44
+
45
+ // === CROSS-POLLINATION ===
46
+ /** Links to individual playbooks suggested for each role */
47
+ rolePlaybookReferences?: RolePlaybookReference[];
48
+ }
49
+
50
+ /**
51
+ * When to use this team pattern.
52
+ */
53
+ export interface TeamPlaybookApplicability {
54
+ /** Task types this pattern works for */
55
+ taskTypes: string[];
56
+ /** Scale indicators */
57
+ teamSizeRange: { min: number; max: number };
58
+ /** Complexity levels this pattern handles */
59
+ complexityLevels: Array<'simple' | 'moderate' | 'complex' | 'epic'>;
60
+ /** Domains where this pattern has been proven */
61
+ domains: string[];
62
+ /** When NOT to use this pattern */
63
+ antiPatterns: string[];
64
+ }
65
+
66
+ /**
67
+ * How to compose the team.
68
+ */
69
+ export interface TeamCompositionGuidance {
70
+ /** Recommended topology */
71
+ topology: 'hierarchical' | 'flat' | 'wave' | 'custom';
72
+ /** Role specifications */
73
+ roles: TeamRoleSpec[];
74
+ /** Spawn rules: which roles can spawn which */
75
+ spawnRules: Record<string, string[]>;
76
+ /** Recommended enforcement mode */
77
+ enforcement: 'strict' | 'permissive' | 'audit';
78
+ }
79
+
80
+ /**
81
+ * Specification for a role within the team pattern.
82
+ */
83
+ export interface TeamRoleSpec {
84
+ /** Role name */
85
+ role: string;
86
+ /** Why this role is needed */
87
+ rationale: string;
88
+ /** Required capabilities */
89
+ capabilities: string[];
90
+ /** Whether this role is essential or optional */
91
+ optional: boolean;
92
+ /** Recommended model tier */
93
+ modelTier?: 'fast' | 'balanced' | 'capable';
94
+ /** Recommended spawn position */
95
+ spawnAs: 'root' | 'companion' | 'on-demand';
96
+ }
97
+
98
+ /**
99
+ * How team members should coordinate.
100
+ */
101
+ export interface TeamCoordinationGuidance {
102
+ /** Execution model */
103
+ executionModel: 'sequential' | 'wave-parallel' | 'fully-parallel' | 'pipeline';
104
+ /** Communication channels to establish */
105
+ channels: TeamChannelSpec[];
106
+ /** Key interaction patterns */
107
+ interactionPatterns: InteractionPattern[];
108
+ /** Task delegation strategy */
109
+ delegationStrategy: string;
110
+ /** Checkpoint protocol */
111
+ checkpoints?: string[];
112
+ }
113
+
114
+ /**
115
+ * Specification for a communication channel.
116
+ */
117
+ export interface TeamChannelSpec {
118
+ name: string;
119
+ signals: string[];
120
+ subscribers: string[]; // roles
121
+ emitters: string[]; // roles
122
+ }
123
+
124
+ /**
125
+ * A learned interaction pattern between roles.
126
+ */
127
+ export interface InteractionPattern {
128
+ /** Short name */
129
+ name: string;
130
+ /** Description of when/how this pattern occurs */
131
+ description: string;
132
+ /** Roles involved */
133
+ roles: string[];
134
+ /** Frequency: how often this pattern should occur */
135
+ frequency: 'once' | 'per-task' | 'continuous';
136
+ /** Whether this pattern was correlated with success */
137
+ correlatedWithSuccess: boolean;
138
+ }
139
+
140
+ /**
141
+ * How to verify the team pattern worked.
142
+ */
143
+ export interface TeamPlaybookVerification {
144
+ /** Metrics that indicate success */
145
+ successIndicators: string[];
146
+ /** Metrics that indicate failure */
147
+ failureIndicators: string[];
148
+ /** How to restructure if the pattern isn't working */
149
+ restructuringStrategy?: string;
150
+ }
151
+
152
+ /**
153
+ * Evolution tracking for team playbooks.
154
+ */
155
+ export interface TeamPlaybookEvolution {
156
+ version: string;
157
+ /** Source team trajectory IDs */
158
+ createdFrom: string[];
159
+ /** Refinements from experience */
160
+ refinements: TeamRefinement[];
161
+ successCount: number;
162
+ failureCount: number;
163
+ lastUsed?: Date;
164
+ /** Average metrics across successful uses */
165
+ avgMetrics?: {
166
+ coordinationOverhead: number;
167
+ parallelismRatio: number;
168
+ timeToFirstOutput: number;
169
+ };
170
+ }
171
+
172
+ /**
173
+ * Context-specific refinement to team coordination.
174
+ */
175
+ export interface TeamRefinement {
176
+ context: string;
177
+ adjustment: string;
178
+ source: 'failure' | 'success' | 'manual';
179
+ addedAt: Date;
180
+ }
181
+
182
+ /**
183
+ * Cross-reference from team playbook to individual playbooks for a role.
184
+ */
185
+ export interface RolePlaybookReference {
186
+ role: string;
187
+ suggestedPlaybookIds: string[];
188
+ }
189
+
190
+ // ============================================================
191
+ // Role-Specific Playbook
192
+ // ============================================================
193
+
194
+ /**
195
+ * RolePlaybook - How to be effective in a specific team role.
196
+ * Captures teamwork behavior from a single agent's perspective.
197
+ */
198
+ export interface RolePlaybook {
199
+ id: string;
200
+ name: string; // e.g., "effective-wave-planner"
201
+
202
+ // === APPLICABILITY ===
203
+ /** Which role this applies to */
204
+ role: string;
205
+ /** Team contexts where this guidance is relevant */
206
+ teamContext: RoleTeamContext;
207
+
208
+ // === ROLE GUIDANCE ===
209
+ guidance: RoleGuidance;
210
+
211
+ // === EVOLUTION ===
212
+ evolution: RolePlaybookEvolution;
213
+
214
+ // === METADATA ===
215
+ confidence: number; // 0-1
216
+ createdAt: Date;
217
+ updatedAt: Date;
218
+
219
+ // === CROSS-POLLINATION ===
220
+ /** Cross-references to individual task playbooks effective for this role */
221
+ relatedTaskPlaybooks?: RelatedTaskPlaybook[];
222
+ }
223
+
224
+ /**
225
+ * Team context where a role playbook applies.
226
+ */
227
+ export interface RoleTeamContext {
228
+ topologies: Array<'hierarchical' | 'flat' | 'wave' | 'custom'>;
229
+ teamSizeRange: { min: number; max: number };
230
+ taskTypes: string[];
231
+ domains: string[];
232
+ }
233
+
234
+ /**
235
+ * Guidance for a specific role.
236
+ */
237
+ export interface RoleGuidance {
238
+ /** Core responsibilities when playing this role */
239
+ responsibilities: string[];
240
+ /** How to interact with each other role */
241
+ interactionGuidance: RoleInteractionGuidance[];
242
+ /** Decision frameworks specific to this role */
243
+ decisionFrameworks: RoleDecisionFramework[];
244
+ /** Common mistakes in this role */
245
+ antiPatterns: string[];
246
+ }
247
+
248
+ /**
249
+ * How to interact with a specific other role.
250
+ */
251
+ export interface RoleInteractionGuidance {
252
+ /** Which other role */
253
+ withRole: string;
254
+ /** What type of interaction */
255
+ interactionType: string;
256
+ /** How to do it effectively */
257
+ guidance: string;
258
+ /** Concrete examples from successful executions */
259
+ examples: string[];
260
+ /** What NOT to do */
261
+ antiPatterns: string[];
262
+ }
263
+
264
+ /**
265
+ * Decision framework for a specific role context.
266
+ */
267
+ export interface RoleDecisionFramework {
268
+ name: string;
269
+ when: string;
270
+ guidance: string;
271
+ }
272
+
273
+ /**
274
+ * Evolution tracking for role playbooks.
275
+ */
276
+ export interface RolePlaybookEvolution {
277
+ version: string;
278
+ createdFrom: string[]; // team trajectory IDs
279
+ refinements: TeamRefinement[];
280
+ successCount: number;
281
+ failureCount: number;
282
+ lastUsed?: Date;
283
+ }
284
+
285
+ /**
286
+ * Cross-reference from role playbook to individual task playbooks.
287
+ */
288
+ export interface RelatedTaskPlaybook {
289
+ playbookId: string;
290
+ playbookName: string;
291
+ applicableToTask: string;
292
+ rationale: string;
293
+ }
294
+
295
+ // ============================================================
296
+ // Factory functions
297
+ // ============================================================
298
+
299
+ /**
300
+ * Create a new team playbook with defaults.
301
+ */
302
+ export function createTeamPlaybook(
303
+ input: Partial<TeamPlaybook> & {
304
+ name: string;
305
+ applicability: TeamPlaybookApplicability;
306
+ composition: TeamCompositionGuidance;
307
+ coordination: TeamCoordinationGuidance;
308
+ }
309
+ ): TeamPlaybook {
310
+ const now = new Date();
311
+ return {
312
+ id: input.id ?? `team-playbook-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
313
+ name: input.name,
314
+ applicability: input.applicability,
315
+ composition: input.composition,
316
+ coordination: input.coordination,
317
+ verification: input.verification ?? {
318
+ successIndicators: [],
319
+ failureIndicators: [],
320
+ },
321
+ evolution: input.evolution ?? {
322
+ version: '1.0.0',
323
+ createdFrom: [],
324
+ refinements: [],
325
+ successCount: 0,
326
+ failureCount: 0,
327
+ },
328
+ confidence: input.confidence ?? 0.3,
329
+ complexity: input.complexity ?? 'moderate',
330
+ createdAt: input.createdAt ?? now,
331
+ updatedAt: input.updatedAt ?? now,
332
+ rolePlaybookReferences: input.rolePlaybookReferences,
333
+ };
334
+ }
335
+
336
+ /**
337
+ * Create a new role playbook with defaults.
338
+ */
339
+ export function createRolePlaybook(
340
+ input: Partial<RolePlaybook> & {
341
+ name: string;
342
+ role: string;
343
+ teamContext: RoleTeamContext;
344
+ guidance: RoleGuidance;
345
+ }
346
+ ): RolePlaybook {
347
+ const now = new Date();
348
+ return {
349
+ id: input.id ?? `role-playbook-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
350
+ name: input.name,
351
+ role: input.role,
352
+ teamContext: input.teamContext,
353
+ guidance: input.guidance,
354
+ evolution: input.evolution ?? {
355
+ version: '1.0.0',
356
+ createdFrom: [],
357
+ refinements: [],
358
+ successCount: 0,
359
+ failureCount: 0,
360
+ },
361
+ confidence: input.confidence ?? 0.3,
362
+ createdAt: input.createdAt ?? now,
363
+ updatedAt: input.updatedAt ?? now,
364
+ relatedTaskPlaybooks: input.relatedTaskPlaybooks,
365
+ };
366
+ }
367
+
368
+ /**
369
+ * Get team playbook success rate.
370
+ */
371
+ export function getTeamPlaybookSuccessRate(playbook: TeamPlaybook): number {
372
+ const total = playbook.evolution.successCount + playbook.evolution.failureCount;
373
+ if (total === 0) return 0;
374
+ return playbook.evolution.successCount / total;
375
+ }
376
+
377
+ /**
378
+ * Get role playbook success rate.
379
+ */
380
+ export function getRolePlaybookSuccessRate(playbook: RolePlaybook): number {
381
+ const total = playbook.evolution.successCount + playbook.evolution.failureCount;
382
+ if (total === 0) return 0;
383
+ return playbook.evolution.successCount / total;
384
+ }