@amoree-code/ocean 2.22.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (382) hide show
  1. package/README.md +46 -53
  2. package/dist/application/clients/bundles.js +220 -0
  3. package/dist/application/clients/chat-plugin.js +4 -42
  4. package/dist/application/clients/client-detect.js +291 -0
  5. package/dist/application/clients/clients.js +104 -25
  6. package/dist/application/clients/desktop-link.js +40 -0
  7. package/dist/application/clients/desktop-watcher.js +6 -4
  8. package/dist/application/clients/hook-trust.js +106 -0
  9. package/dist/application/clients/hooks.js +7 -1
  10. package/dist/application/clients/mcp-schema-cost.js +74 -0
  11. package/dist/application/clients/native.js +38 -2
  12. package/dist/application/clients/registry.js +51 -9
  13. package/dist/application/clients/status.js +7 -2
  14. package/dist/application/clients/zip.js +44 -0
  15. package/dist/application/gateway/webhook-gateway.js +1 -1
  16. package/dist/application/integrations/charter-copies.js +1 -1
  17. package/dist/application/integrations/engine-entry-repair.js +4 -3
  18. package/dist/application/integrations/skill-auto-sync.js +2 -2
  19. package/dist/application/integrations/skill-filter.js +1 -1
  20. package/dist/application/integrations/skill-router.js +134 -90
  21. package/dist/application/layout/layout-apply.js +1 -1
  22. package/dist/application/layout/workspace-template.js +1 -1
  23. package/dist/application/onboarding/steps.js +121 -30
  24. package/dist/application/profiles/profile-doctor.js +118 -0
  25. package/dist/application/profiles/profile-migration-service.js +208 -0
  26. package/dist/application/profiles/profile-suggestion.js +3 -7
  27. package/dist/application/profiles/profile-upgrade-service.js +98 -86
  28. package/dist/application/pull/history-index.js +1 -1
  29. package/dist/application/pull/project-match.js +3 -3
  30. package/dist/application/pull/pull.js +1 -1
  31. package/dist/application/pull/server-capture.js +92 -9
  32. package/dist/application/scheduler/local-scheduler.js +2 -2
  33. package/dist/application/spend/claude-prices.js +55 -0
  34. package/dist/application/spend/claude-spend.js +365 -0
  35. package/dist/application/uninstall/uninstall.js +25 -3
  36. package/dist/application/upkeep/nightly-upkeep.js +4 -4
  37. package/dist/composition/runtime.js +2 -2
  38. package/dist/infrastructure/desktop/claude-export.js +1 -1
  39. package/dist/infrastructure/desktop/desktop-chat.js +60 -13
  40. package/dist/infrastructure/desktop/indexeddb.js +4 -4
  41. package/dist/infrastructure/desktop/leveldb.js +2 -2
  42. package/dist/infrastructure/filesystem/profile-loader.js +3 -45
  43. package/dist/infrastructure/filesystem/runtime-config-loader.js +1 -1
  44. package/dist/infrastructure/observability/runtime-logger.js +1 -1
  45. package/dist/infrastructure/process/agent-tool-executor.js +3 -3
  46. package/dist/infrastructure/process/process-supervisor.js +1 -1
  47. package/dist/infrastructure/process/service.js +8 -8
  48. package/dist/infrastructure/providers/openai-compatible.js +2 -2
  49. package/dist/infrastructure/providers/provider-invocation.js +1 -1
  50. package/dist/infrastructure/providers/session-facts-completer.js +78 -5
  51. package/dist/interfaces/cli/auth-command.js +2 -2
  52. package/dist/interfaces/cli/brief-command.js +1 -1
  53. package/dist/interfaces/cli/browser-command.js +6 -6
  54. package/dist/interfaces/cli/browser-findings.js +6 -9
  55. package/dist/interfaces/cli/browser-settings.js +10 -10
  56. package/dist/interfaces/cli/capture-command.js +6 -6
  57. package/dist/interfaces/cli/client-test-command.js +3 -3
  58. package/dist/interfaces/cli/clients-command.js +55 -6
  59. package/dist/interfaces/cli/command-aliases.js +56 -0
  60. package/dist/interfaces/cli/command-registry.js +48 -1414
  61. package/dist/interfaces/cli/commands/browser.js +5 -0
  62. package/dist/interfaces/cli/commands/capture.js +19 -0
  63. package/dist/interfaces/cli/commands/catalog.js +9 -0
  64. package/dist/interfaces/cli/commands/client.js +135 -0
  65. package/dist/interfaces/cli/commands/clients.js +33 -0
  66. package/dist/interfaces/cli/commands/connectors.js +14 -0
  67. package/dist/interfaces/cli/commands/context.js +9 -0
  68. package/dist/interfaces/cli/commands/cost.js +15 -0
  69. package/dist/interfaces/cli/commands/daily.js +11 -0
  70. package/dist/interfaces/cli/commands/day.js +25 -0
  71. package/dist/interfaces/cli/commands/dispatch.js +31 -0
  72. package/dist/interfaces/cli/commands/doctor.js +60 -0
  73. package/dist/interfaces/cli/commands/env.js +5 -0
  74. package/dist/interfaces/cli/commands/gateway.js +16 -0
  75. package/dist/interfaces/cli/commands/handoff.js +11 -0
  76. package/dist/interfaces/cli/commands/health.js +17 -0
  77. package/dist/interfaces/cli/commands/hook.js +142 -0
  78. package/dist/interfaces/cli/commands/idea.js +11 -0
  79. package/dist/interfaces/cli/commands/install.js +31 -0
  80. package/dist/interfaces/cli/commands/intent.js +14 -0
  81. package/dist/interfaces/cli/commands/intercept.js +22 -0
  82. package/dist/interfaces/cli/commands/layout.js +11 -0
  83. package/dist/interfaces/cli/commands/lifecycle.js +5 -0
  84. package/dist/interfaces/cli/commands/loop.js +73 -0
  85. package/dist/interfaces/cli/commands/market.js +11 -0
  86. package/dist/interfaces/cli/commands/mcp.js +57 -0
  87. package/dist/interfaces/cli/commands/memory.js +5 -0
  88. package/dist/interfaces/cli/commands/migrate.js +5 -0
  89. package/dist/interfaces/cli/commands/observe.js +11 -0
  90. package/dist/interfaces/cli/commands/obsidian.js +111 -0
  91. package/dist/interfaces/cli/commands/operate.js +7 -0
  92. package/dist/interfaces/cli/commands/policy.js +16 -0
  93. package/dist/interfaces/cli/commands/project.js +207 -0
  94. package/dist/interfaces/cli/commands/repair.js +20 -0
  95. package/dist/interfaces/cli/commands/run.js +52 -0
  96. package/dist/interfaces/cli/commands/schedule.js +58 -0
  97. package/dist/interfaces/cli/commands/service.js +21 -0
  98. package/dist/interfaces/cli/commands/session.js +182 -0
  99. package/dist/interfaces/cli/commands/sessions.js +12 -0
  100. package/dist/interfaces/cli/commands/setup.js +21 -0
  101. package/dist/interfaces/cli/commands/skill.js +159 -0
  102. package/dist/interfaces/cli/commands/tasks.js +10 -0
  103. package/dist/interfaces/cli/commands/update-remove.js +25 -0
  104. package/dist/interfaces/cli/connectors-command.js +150 -0
  105. package/dist/interfaces/cli/context-command.js +39 -3
  106. package/dist/interfaces/cli/cost-command.js +104 -0
  107. package/dist/interfaces/cli/curator-command.js +1 -1
  108. package/dist/interfaces/cli/daily-command.js +7 -1
  109. package/dist/interfaces/cli/desktop-command.js +43 -7
  110. package/dist/interfaces/cli/distill-command.js +7 -2
  111. package/dist/interfaces/cli/express-command.js +1 -1
  112. package/dist/interfaces/cli/failures-command.js +4 -4
  113. package/dist/interfaces/cli/gateway-findings.js +2 -2
  114. package/dist/interfaces/cli/governance-command.js +23 -16
  115. package/dist/interfaces/cli/handoff-command.js +1 -1
  116. package/dist/interfaces/cli/harvest-command.js +2 -2
  117. package/dist/interfaces/cli/help-command.js +53 -169
  118. package/dist/interfaces/cli/hygiene-command.js +1 -1
  119. package/dist/interfaces/cli/idea-command.js +1 -1
  120. package/dist/interfaces/cli/intercept-command.js +8 -7
  121. package/dist/interfaces/cli/interests-command.js +1 -1
  122. package/dist/interfaces/cli/layout-command.js +2 -0
  123. package/dist/interfaces/cli/market-command.js +9 -9
  124. package/dist/interfaces/cli/mcp-gateway-command.js +124 -7
  125. package/dist/interfaces/cli/mcp-probe-command.js +186 -0
  126. package/dist/interfaces/cli/mcp-status-command.js +5 -5
  127. package/dist/interfaces/cli/memory-command.js +41 -7
  128. package/dist/interfaces/cli/migrate-command.js +2 -2
  129. package/dist/interfaces/cli/note-command.js +1 -1
  130. package/dist/interfaces/cli/onboard-command.js +14 -0
  131. package/dist/interfaces/cli/operate-command.js +5 -5
  132. package/dist/interfaces/cli/profiles-command.js +61 -1
  133. package/dist/interfaces/cli/rhythm-command.js +11 -5
  134. package/dist/interfaces/cli/running-server-findings.js +1 -1
  135. package/dist/interfaces/cli/scorecard-command.js +8 -8
  136. package/dist/interfaces/cli/session-facts-command.js +2 -2
  137. package/dist/interfaces/cli/sessions-command.js +145 -0
  138. package/dist/interfaces/cli/setup-command.js +15 -2
  139. package/dist/interfaces/cli/tasks-command.js +63 -13
  140. package/dist/interfaces/cli/telemetry-command.js +4 -4
  141. package/dist/interfaces/cli/uninstall-command.js +1 -1
  142. package/dist/interfaces/cli/week-failures.js +32 -0
  143. package/dist/main.js +12 -0
  144. package/node_modules/@ocean/brain/dist/{infrastructure/brain/brain-index.js → brain-index.js} +2 -2
  145. package/node_modules/@ocean/brain/dist/{brain/brain-markdown.js → brain-markdown.js} +1 -1
  146. package/node_modules/@ocean/brain/dist/{brain/brain-service.js → brain-service.js} +12 -2
  147. package/node_modules/@ocean/brain/dist/memory/brain-dump.js +92 -16
  148. package/node_modules/@ocean/brain/dist/memory/extraction-log.js +125 -0
  149. package/node_modules/@ocean/brain/dist/memory/extraction-retry.js +54 -0
  150. package/node_modules/@ocean/brain/dist/memory/fact-routing.js +44 -1
  151. package/node_modules/@ocean/brain/dist/memory/lesson-activation.js +2 -2
  152. package/node_modules/@ocean/brain/dist/memory/lesson-learning.js +2 -2
  153. package/node_modules/@ocean/brain/dist/memory/lessons.js +1 -1
  154. package/node_modules/@ocean/brain/dist/memory/memory-audit.js +2 -2
  155. package/node_modules/@ocean/brain/dist/memory/memory-harvest.js +1 -1
  156. package/node_modules/@ocean/brain/dist/memory/memory-paths.js +8 -0
  157. package/node_modules/@ocean/brain/dist/memory/memory-review.js +31 -3
  158. package/node_modules/@ocean/brain/dist/memory/memory-trash.js +29 -0
  159. package/node_modules/@ocean/brain/dist/memory/memory-write.js +4 -2
  160. package/node_modules/@ocean/brain/dist/memory/model-narrative.js +2 -2
  161. package/node_modules/@ocean/brain/dist/memory/profile-facts.js +1 -1
  162. package/node_modules/@ocean/brain/dist/memory/routing.json +6 -6
  163. package/node_modules/@ocean/{market/dist/skills → brain/dist/memory}/signal-detection.js +1 -1
  164. package/node_modules/@ocean/brain/dist/{memory → people}/people.js +1 -1
  165. package/node_modules/@ocean/brain/dist/sessions-capture/session-facts.js +625 -0
  166. package/node_modules/@ocean/brain/dist/{memory → sessions-capture}/session-promotion.js +7 -15
  167. package/node_modules/@ocean/brain/dist/{memory → sessions-capture}/session-summary.js +1 -1
  168. package/node_modules/@ocean/brain/dist/sessions-capture/session-triage.js +52 -0
  169. package/node_modules/@ocean/brain/package.json +1 -1
  170. package/node_modules/@ocean/connect/dist/connectors/connector-hub.js +173 -0
  171. package/node_modules/@ocean/{market → connect}/dist/install/default-marketplace.js +6 -2
  172. package/node_modules/@ocean/{market → connect}/dist/install/marketplace-service.js +1 -1
  173. package/node_modules/@ocean/connect/dist/mcp/mcp-gateway.js +987 -0
  174. package/node_modules/@ocean/{market → connect}/dist/mcp/mcp-launch.js +102 -5
  175. package/node_modules/@ocean/{market → connect}/dist/registry/official-registry.js +1 -1
  176. package/node_modules/@ocean/{market → connect}/dist/security/permissions.js +1 -1
  177. package/node_modules/@ocean/{market → connect}/dist/skills/skill-hub.js +104 -6
  178. package/node_modules/@ocean/{market → connect}/package.json +2 -2
  179. package/node_modules/@ocean/context/dist/{context/context-ladder.js → context-ladder.js} +3 -3
  180. package/node_modules/@ocean/context/dist/{context/context-references.js → context-references.js} +5 -4
  181. package/node_modules/@ocean/context/dist/{context/context-cost.js → context-size.js} +6 -6
  182. package/node_modules/@ocean/context/dist/{context/intent-router.js → intent-router.js} +1 -1
  183. package/node_modules/@ocean/context/dist/{context/resource-injection.js → resource-injection.js} +3 -1
  184. package/node_modules/@ocean/context/package.json +1 -1
  185. package/node_modules/@ocean/core/dist/domain/brain/brain-record.js +1 -1
  186. package/node_modules/@ocean/core/dist/domain/capabilities/capability-manifest.js +5 -5
  187. package/node_modules/@ocean/core/dist/domain/connector-entry.js +86 -0
  188. package/node_modules/@ocean/core/dist/domain/context/context.js +1 -1
  189. package/node_modules/@ocean/core/dist/domain/context/project-id.js +8 -2
  190. package/node_modules/@ocean/core/dist/domain/{evidence/evidence.js → evidence.js} +1 -1
  191. package/node_modules/@ocean/core/dist/domain/mcp/memory-contract.js +4 -1
  192. package/node_modules/@ocean/core/dist/domain/ports/brain-index-port.js +1 -1
  193. package/node_modules/@ocean/core/dist/domain/profiles/profile-markdown.js +40 -0
  194. package/node_modules/@ocean/core/dist/domain/profiles/profile-resolution.js +276 -0
  195. package/node_modules/@ocean/core/dist/domain/profiles/profile-selection.js +23 -60
  196. package/node_modules/@ocean/core/dist/domain/profiles/profile-upgrade.js +2 -2
  197. package/node_modules/@ocean/core/dist/domain/profiles/profile.js +66 -6
  198. package/node_modules/@ocean/core/dist/domain/profiles/runtime-config.js +1 -1
  199. package/node_modules/@ocean/core/dist/domain/runs/agent-tools.js +2 -2
  200. package/node_modules/@ocean/core/dist/domain/sessions/session-identity.js +53 -0
  201. package/node_modules/@ocean/core/dist/domain/sessions/session-metadata.js +208 -0
  202. package/node_modules/@ocean/core/dist/domain/{tasks/task-id.js → task-id.js} +2 -2
  203. package/node_modules/@ocean/core/dist/profiles/profile-files.js +57 -0
  204. package/node_modules/@ocean/core/dist/profiles/profile-loader.js +97 -0
  205. package/node_modules/@ocean/core/dist/profiles/project-profile-fill.js +33 -0
  206. package/node_modules/@ocean/core/dist/profiles/session-profile.js +158 -0
  207. package/node_modules/@ocean/core/dist/shared/charter.js +110 -0
  208. package/node_modules/@ocean/core/dist/shared/context-ack.js +1 -1
  209. package/node_modules/@ocean/core/dist/shared/context-triggers.js +67 -0
  210. package/node_modules/@ocean/core/dist/shared/paths.js +6 -6
  211. package/node_modules/@ocean/core/dist/shared/project-legacy.js +232 -0
  212. package/node_modules/@ocean/core/dist/shared/project-manifest.js +308 -0
  213. package/node_modules/@ocean/core/dist/shared/project-names.js +87 -0
  214. package/node_modules/@ocean/core/dist/shared/project-register.js +560 -0
  215. package/node_modules/@ocean/core/dist/shared/project-resolution.js +83 -861
  216. package/node_modules/@ocean/core/dist/shared/repo-signals.js +45 -0
  217. package/node_modules/@ocean/core/dist/shared/task-reference.js +1 -1
  218. package/node_modules/@ocean/core/dist/shared/text-tokens.js +37 -0
  219. package/node_modules/@ocean/core/dist/shared/tool-groups.js +224 -0
  220. package/node_modules/@ocean/core/package.json +4 -1
  221. package/node_modules/@ocean/services/dist/day/day.js +45 -3
  222. package/node_modules/@ocean/services/dist/{distill → day}/distill.js +29 -3
  223. package/node_modules/@ocean/services/dist/{harvest → day}/harvest.js +54 -14
  224. package/node_modules/@ocean/services/dist/{brief → day}/interest-discovery.js +3 -3
  225. package/node_modules/@ocean/services/dist/day/note.js +2 -2
  226. package/node_modules/@ocean/services/dist/{onboarding → day}/onboarding.js +1 -1
  227. package/node_modules/@ocean/services/dist/day/patterns.js +68 -0
  228. package/node_modules/@ocean/services/dist/{curator → health}/curator.js +5 -5
  229. package/node_modules/@ocean/services/dist/{journey → health}/failures.js +7 -5
  230. package/node_modules/@ocean/services/dist/{hygiene → health}/hygiene.js +2 -2
  231. package/node_modules/@ocean/services/dist/{journey → health}/lesson-effect.js +1 -1
  232. package/node_modules/@ocean/services/dist/{scorecard → health}/scorecard.js +3 -3
  233. package/node_modules/@ocean/services/dist/{upkeep → health}/upkeep.js +2 -2
  234. package/node_modules/@ocean/services/dist/{doctor → health}/workspace-doctor.js +57 -17
  235. package/node_modules/@ocean/services/dist/{browser → integrations/browser}/browser-session.js +1 -1
  236. package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/call-ledger.js +3 -0
  237. package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/mcp-client.js +19 -3
  238. package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/obsidian-server.js +4 -4
  239. package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/ocean-server.js +423 -34
  240. package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/conflict-log.js +1 -1
  241. package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/folder-templates.js +8 -5
  242. package/node_modules/@ocean/services/dist/projects/project-doctor.js +173 -0
  243. package/node_modules/@ocean/services/dist/projects/project-snippet.js +9 -0
  244. package/node_modules/@ocean/services/dist/projects/projects-overview.js +2 -2
  245. package/node_modules/@ocean/services/package.json +1 -1
  246. package/node_modules/@ocean/{loop/dist/loops → work/dist/runs}/guard-runtime.js +3 -3
  247. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/memory-knowledge-operations.js +4 -12
  248. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/operation-contract.js +2 -2
  249. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/project-operations.js +2 -1
  250. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/task-operations.js +4 -4
  251. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/write-guard.js +1 -1
  252. package/node_modules/@ocean/{loop → work}/dist/runs/prompt-assembly.js +2 -2
  253. package/node_modules/@ocean/{loop → work}/dist/runs/run-agent.js +4 -4
  254. package/node_modules/@ocean/{loop → work}/dist/runs/tool-loop.js +4 -4
  255. package/node_modules/@ocean/work/dist/sessions/hooks/desktop-facts.js +309 -0
  256. package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/session-end-hook.js +36 -5
  257. package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/session-facts-hook.js +144 -14
  258. package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/session-start-hook.js +129 -12
  259. package/node_modules/@ocean/work/dist/sessions/hooks/start-brief.js +110 -0
  260. package/node_modules/@ocean/work/dist/sessions/hooks/unlinked-warning.js +68 -0
  261. package/node_modules/@ocean/{loop → work}/dist/sessions/session-closeout.js +4 -4
  262. package/node_modules/@ocean/{loop → work}/dist/sessions/session-projects.js +13 -3
  263. package/node_modules/@ocean/work/dist/sessions/session-relink.js +300 -0
  264. package/node_modules/@ocean/{loop → work}/dist/sessions/session-retention.js +1 -1
  265. package/node_modules/@ocean/{loop → work}/dist/tasks/list-tasks.js +7 -2
  266. package/node_modules/@ocean/{loop → work}/dist/tasks/renumber-tasks.js +4 -2
  267. package/node_modules/@ocean/{loop → work}/dist/tasks/session-task.js +2 -2
  268. package/node_modules/@ocean/{loop → work}/dist/tasks/sync-task-prs.js +77 -7
  269. package/node_modules/@ocean/work/dist/tasks/task-git.js +63 -0
  270. package/node_modules/@ocean/{loop/dist/loops → work/dist/tasks}/task-loop.js +4 -4
  271. package/node_modules/@ocean/{loop → work}/dist/tasks/verification-readiness.js +1 -1
  272. package/node_modules/@ocean/{loop → work}/dist/tasks/verify-task.js +1 -1
  273. package/node_modules/@ocean/{loop → work}/package.json +2 -2
  274. package/ocean-marketplace.json +41 -41
  275. package/package.json +12 -11
  276. package/skills/core/daily-harvest/SKILL.md +1 -1
  277. package/skills/core/ocean-memory/SKILL.md +4 -0
  278. package/skills/core/use-browser/SKILL.md +30 -7
  279. package/skills/index.json +1 -1
  280. package/templates/profiles/default.md +44 -0
  281. package/templates/profiles/developer.md +45 -0
  282. package/templates/profiles/reviewer.md +44 -0
  283. package/templates/profiles/strategist.md +44 -0
  284. package/templates/profiles-v3/analysis.md +16 -0
  285. package/templates/profiles-v3/backend.md +16 -0
  286. package/templates/profiles-v3/base.md +57 -0
  287. package/templates/profiles-v3/code-review.md +16 -0
  288. package/templates/profiles-v3/devops.md +16 -0
  289. package/templates/profiles-v3/docs-office.md +16 -0
  290. package/templates/profiles-v3/frontend.md +16 -0
  291. package/templates/profiles-v3/learning.md +16 -0
  292. package/templates/profiles-v3/marketing-ads.md +16 -0
  293. package/templates/profiles-v3/marketing-content-seo.md +16 -0
  294. package/templates/profiles-v3/ocean-ops.md +16 -0
  295. package/templates/profiles-v3/product-strategy.md +16 -0
  296. package/templates/profiles-v3/qa-testing.md +16 -0
  297. package/templates/profiles-v3/security.md +16 -0
  298. package/templates/workspace/MANIFEST.json +1 -0
  299. package/templates/workspace/charter/core.md +22 -90
  300. package/templates/workspace/charter/policies/README.md +7 -1
  301. package/templates/workspace/charter/policies/claude-code-context.md +6 -1
  302. package/templates/workspace/charter/policies/concise-output.md +5 -0
  303. package/templates/workspace/charter/policies/context.md +5 -0
  304. package/templates/workspace/charter/policies/contracts/task.md +2 -2
  305. package/templates/workspace/charter/policies/git.md +5 -0
  306. package/templates/workspace/charter/policies/graph.md +6 -1
  307. package/templates/workspace/charter/policies/knowledge.md +11 -4
  308. package/templates/workspace/charter/policies/layout.md +23 -0
  309. package/templates/workspace/charter/policies/lifecycle.md +5 -0
  310. package/templates/workspace/charter/policies/memory.md +5 -0
  311. package/templates/workspace/charter/policies/minimal-change.md +5 -0
  312. package/templates/workspace/charter/policies/models.md +5 -0
  313. package/templates/workspace/charter/policies/response.md +5 -0
  314. package/templates/workspace/charter/policies/skill-observer.md +12 -0
  315. package/templates/workspace/charter/policies/stack.md +5 -0
  316. package/templates/workspace/charter/policies/task.md +17 -3
  317. package/templates/workspace/charter/policies/verification.md +5 -0
  318. package/node_modules/@ocean/brain/dist/evidence/verification-report.js +0 -13
  319. package/node_modules/@ocean/brain/dist/memory/daily-narrative.js +0 -142
  320. package/node_modules/@ocean/brain/dist/memory/session-facts.js +0 -283
  321. package/node_modules/@ocean/context/dist/context/context-compression.js +0 -66
  322. package/node_modules/@ocean/loop/dist/hooks/desktop-facts.js +0 -174
  323. package/node_modules/@ocean/loop/dist/operations/task-linker.js +0 -40
  324. package/node_modules/@ocean/loop/dist/sessions/session-pointer.js +0 -133
  325. package/node_modules/@ocean/loop/dist/tasks/task-git.js +0 -28
  326. package/node_modules/@ocean/market/dist/mcp/mcp-gateway.js +0 -533
  327. package/templates/profiles/default.json +0 -51
  328. package/templates/profiles/developer.json +0 -51
  329. package/templates/profiles/reviewer.json +0 -51
  330. package/templates/profiles/strategist.json +0 -51
  331. /package/node_modules/@ocean/brain/dist/{brain/brain-eval.js → brain-eval.js} +0 -0
  332. /package/node_modules/@ocean/brain/dist/{brain/brain-reindex.js → brain-reindex.js} +0 -0
  333. /package/node_modules/@ocean/brain/dist/{capture → sessions-capture}/inbox-sync.js +0 -0
  334. /package/node_modules/@ocean/{market → connect}/dist/adapters/mcp-adapter.js +0 -0
  335. /package/node_modules/@ocean/{market → connect}/dist/adapters/owned-directory.js +0 -0
  336. /package/node_modules/@ocean/{market → connect}/dist/adapters/plugin-adapter.js +0 -0
  337. /package/node_modules/@ocean/{market → connect}/dist/adapters/skill-adapter.js +0 -0
  338. /package/node_modules/@ocean/{market → connect}/dist/capability/adapter.js +0 -0
  339. /package/node_modules/@ocean/{market → connect}/dist/capability/catalog.js +0 -0
  340. /package/node_modules/@ocean/{market → connect}/dist/capability/content-digest.js +0 -0
  341. /package/node_modules/@ocean/{market → connect}/dist/capability/registry.js +0 -0
  342. /package/node_modules/@ocean/{market → connect}/dist/install/lock.js +0 -0
  343. /package/node_modules/@ocean/{market → connect}/dist/install/own-server.js +0 -0
  344. /package/node_modules/@ocean/{market → connect}/dist/mcp/chrome-debugging.js +0 -0
  345. /package/node_modules/@ocean/{market → connect}/dist/mcp/mcp-connection.js +0 -0
  346. /package/node_modules/@ocean/{market → connect}/dist/mcp/mcp-runner.js +0 -0
  347. /package/node_modules/@ocean/{market → connect}/dist/security/description-scan.js +0 -0
  348. /package/node_modules/@ocean/{market → connect}/dist/security/secrets.js +0 -0
  349. /package/node_modules/@ocean/{market → connect}/dist/skills/core-skill-sync.js +0 -0
  350. /package/node_modules/@ocean/context/dist/{context/context-packet.js → context-packet.js} +0 -0
  351. /package/node_modules/@ocean/core/dist/domain/{process/process-events.js → process-events.js} +0 -0
  352. /package/node_modules/@ocean/core/dist/domain/{redaction/redaction.js → redaction.js} +0 -0
  353. /package/node_modules/@ocean/services/dist/{brief → day}/brief.js +0 -0
  354. /package/node_modules/@ocean/services/dist/{express → day}/express.js +0 -0
  355. /package/node_modules/@ocean/services/dist/{brief → day}/source-registry.json +0 -0
  356. /package/node_modules/@ocean/services/dist/{journey → health}/telemetry.js +0 -0
  357. /package/node_modules/@ocean/services/dist/{browser → integrations/browser}/browser-service.js +0 -0
  358. /package/node_modules/@ocean/services/dist/{browser → integrations/browser}/browser-task-runner.js +0 -0
  359. /package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/mcp-session.js +0 -0
  360. /package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/server-version.js +0 -0
  361. /package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/tool-registry.js +0 -0
  362. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/inbox-promotion.js +0 -0
  363. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-discovery.js +0 -0
  364. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-ingestion.js +0 -0
  365. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-sync.js +0 -0
  366. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-writer.js +0 -0
  367. /package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/operation-scope.js +0 -0
  368. /package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/record-io.js +0 -0
  369. /package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/record-operations.js +0 -0
  370. /package/node_modules/@ocean/{loop → work}/dist/runs/run-authorization.js +0 -0
  371. /package/node_modules/@ocean/{loop → work}/dist/runs/session-tokens.js +0 -0
  372. /package/node_modules/@ocean/{loop/dist/handoff → work/dist/sessions}/handoff-service.js +0 -0
  373. /package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/lifecycle-hooks.js +0 -0
  374. /package/node_modules/@ocean/{loop/dist/infrastructure/persistence → work/dist/sessions}/session-store.js +0 -0
  375. /package/node_modules/@ocean/{loop/dist/infrastructure/persistence → work/dist/sessions}/session-validator.js +0 -0
  376. /package/node_modules/@ocean/{loop → work}/dist/tasks/archive-tasks.js +0 -0
  377. /package/node_modules/@ocean/{loop → work}/dist/tasks/checkpoint-task.js +0 -0
  378. /package/node_modules/@ocean/{loop → work}/dist/tasks/claim-task.js +0 -0
  379. /package/node_modules/@ocean/{loop/dist/loops → work/dist/tasks}/iteration-graph.js +0 -0
  380. /package/node_modules/@ocean/{loop → work}/dist/tasks/new-task.js +0 -0
  381. /package/node_modules/@ocean/{loop/dist/loops → work/dist/tasks}/task-loop-record.js +0 -0
  382. /package/node_modules/@ocean/{loop → work}/dist/tasks/task-verification.js +0 -0
@@ -0,0 +1,300 @@
1
+ import { copyFile, mkdir, readdir, readFile, stat } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { factTarget } from "@ocean/brain/memory/fact-routing.js";
4
+ import { PROJECT_IDENTITY_EVENT, sessionIdentity, } from "@ocean/core/domain/sessions/session-identity.js";
5
+ import { metadataLines, readMetadata, } from "@ocean/core/domain/sessions/session-metadata.js";
6
+ import { atomicWrite, parseFrontmatter, safeJsonParse, } from "@ocean/core/shared/fs-utils.js";
7
+ import { DAILY_DIR, INBOX_DIR, oceanPath, oceanRoot, SYSTEM_DIR, } from "@ocean/core/shared/paths.js";
8
+ import { readClaudeConversations, } from "@ocean/core/shared/project-legacy.js";
9
+ import { listProjectManifests, matchProject, } from "@ocean/core/shared/project-manifest.js";
10
+ import { TRANSCRIPT_CLIENTS, } from "./hooks/session-end-hook.js";
11
+ import { FACTS_CLAIM_EVENT, readTranscriptSlice, recordActivity, transcriptStart, } from "./hooks/session-facts-hook.js";
12
+ // The keys relink owns. Every other frontmatter line is left as it was.
13
+ const HEAD_KEYS = ["project", "task"];
14
+ const BLOCK_KEYS = [
15
+ "conversation_title",
16
+ "claude_project",
17
+ "project_how",
18
+ "project_confidence",
19
+ "branch",
20
+ "started",
21
+ "ended",
22
+ "duration_min",
23
+ "turns_user",
24
+ "turns_assistant",
25
+ "tools",
26
+ "files",
27
+ "model",
28
+ "extraction",
29
+ ];
30
+ const MAX_WHOLE_TRANSCRIPT = 4 * 1024 * 1024;
31
+ const quote = (value) => JSON.stringify(value);
32
+ const tidy = (value, max = 200) => value.replace(/\s+/g, " ").trim().slice(0, max);
33
+ async function markdownIn(dir) {
34
+ const entries = await readdir(dir, { withFileTypes: true }).catch(() => []);
35
+ const files = [];
36
+ for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
37
+ if (entry.name.startsWith("."))
38
+ continue;
39
+ const file = path.join(dir, entry.name);
40
+ if (entry.isDirectory())
41
+ files.push(...(await markdownIn(file)));
42
+ else if (entry.name.endsWith(".md"))
43
+ files.push(file);
44
+ }
45
+ return files;
46
+ }
47
+ const relative = (file) => path.relative(oceanRoot(), file).split(path.sep).join("/");
48
+ function splitFrontmatter(text) {
49
+ if (!text.startsWith("---\n"))
50
+ return null;
51
+ const end = text.indexOf("\n---", 3);
52
+ if (end < 0)
53
+ return null;
54
+ return {
55
+ head: text.slice(4, end).split("\n"),
56
+ rest: text.slice(end + 1),
57
+ };
58
+ }
59
+ const lineKey = (line) => /^([A-Za-z_][\w-]*):/.exec(line)?.[1];
60
+ // The record's frontmatter with relink's keys replaced: project and task after `type:`, the
61
+ // rest after `session_id:`, so a record written twice comes out the same.
62
+ function rewriteRecord(text, head, block) {
63
+ const parts = splitFrontmatter(text);
64
+ if (!parts)
65
+ return null;
66
+ const owned = new Set([...HEAD_KEYS, ...BLOCK_KEYS]);
67
+ const kept = parts.head.filter((line) => {
68
+ const key = lineKey(line);
69
+ return !key || !owned.has(key);
70
+ });
71
+ const out = [];
72
+ for (const line of kept) {
73
+ out.push(line);
74
+ if (lineKey(line) === "type")
75
+ out.push(...head);
76
+ if (lineKey(line) === "session_id")
77
+ out.push(...block);
78
+ }
79
+ return `---\n${out.join("\n")}\n${parts.rest}`;
80
+ }
81
+ // Frontmatter fields with a quoted value decoded as the JSON string it was written as, so a
82
+ // value with escapes reads back the same as it was written.
83
+ function readFields(text) {
84
+ const fields = parseFrontmatter(text);
85
+ for (const line of splitFrontmatter(text)?.head ?? []) {
86
+ const match = /^([A-Za-z_][\w-]*): (".*")$/.exec(line);
87
+ if (!match)
88
+ continue;
89
+ try {
90
+ const value = JSON.parse(match[2]);
91
+ if (typeof value === "string")
92
+ fields[match[1]] = value;
93
+ }
94
+ catch {
95
+ /* kept as parseFrontmatter read it */
96
+ }
97
+ }
98
+ return fields;
99
+ }
100
+ function fieldChanges(before, after) {
101
+ const a = readFields(before);
102
+ const b = readFields(after);
103
+ const keys = [...new Set([...Object.keys(a), ...Object.keys(b)])];
104
+ return keys
105
+ .filter((key) => (a[key] ?? "") !== (b[key] ?? ""))
106
+ .map((key) => ({ key, from: a[key] ?? "", to: b[key] ?? "" }));
107
+ }
108
+ // The newest transcript the store saw this session claimed from.
109
+ function transcriptOf(events) {
110
+ let found = "";
111
+ for (const event of events) {
112
+ if (event.type !== FACTS_CLAIM_EVENT)
113
+ continue;
114
+ const claim = safeJsonParse(event.data);
115
+ if (typeof claim?.transcript === "string")
116
+ found = claim.transcript;
117
+ }
118
+ return found;
119
+ }
120
+ async function readTranscript(file, client, cwd) {
121
+ let size;
122
+ try {
123
+ size = (await stat(file)).size;
124
+ }
125
+ catch {
126
+ return {};
127
+ }
128
+ const started = await transcriptStart(file);
129
+ const slice = await readTranscriptSlice(file, client, 0);
130
+ const ended = slice.last && started && slice.last < started ? started : slice.last;
131
+ return {
132
+ ...((started ?? slice.first) ? { started: started ?? slice.first } : {}),
133
+ ...(ended ? { ended } : {}),
134
+ // Counts only from a transcript read whole: a tail would undercount.
135
+ ...(size <= MAX_WHOLE_TRANSCRIPT && slice.activity
136
+ ? { activity: recordActivity(slice.activity, slice.cwd ?? cwd) }
137
+ : {}),
138
+ };
139
+ }
140
+ async function planRecord(file, text, context) {
141
+ const fields = readFields(text);
142
+ if (fields.type !== "session" || !fields.session_id)
143
+ return null;
144
+ const known = (value) => value ? (matchProject(context.manifests, value) ?? "") : "";
145
+ const before = readMetadata(fields);
146
+ const current = {
147
+ project: known(fields.project),
148
+ how: fields.project_how ?? undefined,
149
+ confidence: fields.project_confidence ?? undefined,
150
+ };
151
+ // Kept unless something better is derived.
152
+ const keep = (project) => ({
153
+ project,
154
+ task: fields.task ?? "",
155
+ ...(project && current.how && project === fields.project
156
+ ? { how: current.how, confidence: current.confidence ?? "medium" }
157
+ : project
158
+ ? { how: "backfill", confidence: "medium" }
159
+ : { how: "none", confidence: "none" }),
160
+ });
161
+ let decision;
162
+ let title = fields.conversation_title ?? "";
163
+ let claudeProject = fields.claude_project ?? "";
164
+ let times = {};
165
+ const uuid = /^desktop:(.+)$/.exec(fields.session_id)?.[1];
166
+ if (fields.provider === "claude-desktop" && uuid) {
167
+ const conversation = context.conversations[uuid];
168
+ if (conversation?.title)
169
+ title = tidy(conversation.title);
170
+ if (conversation?.projectName)
171
+ claudeProject = tidy(conversation.projectName);
172
+ const linked = known(claudeProject);
173
+ decision = linked
174
+ ? {
175
+ project: linked,
176
+ task: fields.task ?? "",
177
+ how: "claude-project",
178
+ confidence: "high",
179
+ }
180
+ : keep(current.project);
181
+ }
182
+ else {
183
+ const row = context.store.get(fields.session_id);
184
+ const events = row ? context.store.listEvents(fields.session_id) : [];
185
+ const identity = row ? sessionIdentity(row, events) : null;
186
+ const fromStore = known(identity?.projectId);
187
+ const recorded = events.some((event) => event.type === PROJECT_IDENTITY_EVENT &&
188
+ safeJsonParse(event.data)?.projectId === identity?.projectId);
189
+ const project = fromStore || current.project;
190
+ decision = {
191
+ ...(identity && recorded && fromStore
192
+ ? { project, how: identity.how, confidence: identity.confidence }
193
+ : keep(project)),
194
+ task: identity?.taskId || fields.task || "",
195
+ };
196
+ const client = fields.provider;
197
+ const transcript = transcriptOf(events);
198
+ if (transcript && TRANSCRIPT_CLIENTS.includes(client))
199
+ times = await readTranscript(transcript, client, row?.workingDirectory ?? undefined);
200
+ }
201
+ const started = times.started ?? before.started;
202
+ const ended = times.ended ?? before.ended;
203
+ const activity = before.activity ?? times.activity;
204
+ const block = [
205
+ ...(title ? [`conversation_title: ${quote(title)}`] : []),
206
+ ...(claudeProject ? [`claude_project: ${quote(claudeProject)}`] : []),
207
+ ...metadataLines({
208
+ projectHow: decision.how,
209
+ projectConfidence: decision.confidence,
210
+ ...(before.branch ? { branch: before.branch } : {}),
211
+ ...(started ? { started } : {}),
212
+ ...(ended ? { ended } : {}),
213
+ ...(activity ? { activity } : {}),
214
+ ...(before.extraction ? { extraction: before.extraction } : {}),
215
+ }),
216
+ ];
217
+ const after = rewriteRecord(text, [`project: ${quote(decision.project)}`, `task: ${quote(decision.task)}`], block);
218
+ if (!after)
219
+ return null;
220
+ const changes = fieldChanges(text, after);
221
+ return changes.length
222
+ ? { file: relative(file), kind: "record", changes, before: text, after }
223
+ : null;
224
+ }
225
+ // A pending project fact that was proposed with no target because its project was unknown
226
+ // then, and is known now.
227
+ async function planCandidate(file, text) {
228
+ const fields = readFields(text);
229
+ if (fields.type !== "project" || fields.target || !fields.project)
230
+ return null;
231
+ const body = splitFrontmatter(text)?.rest ?? "";
232
+ const title = /^# (.+)$/m.exec(body)?.[1]?.trim() ?? "";
233
+ if (!title)
234
+ return null;
235
+ const target = await factTarget({
236
+ type: "project",
237
+ title,
238
+ project: fields.project,
239
+ });
240
+ if (!target)
241
+ return null;
242
+ const after = text.replace(/^target: .*$/m, `target: ${quote(target)}`);
243
+ if (after === text)
244
+ return null;
245
+ return {
246
+ file: relative(file),
247
+ kind: "candidate",
248
+ changes: fieldChanges(text, after),
249
+ before: text,
250
+ after,
251
+ };
252
+ }
253
+ export async function planRelink(store) {
254
+ const context = {
255
+ store,
256
+ manifests: await listProjectManifests(),
257
+ conversations: await readClaudeConversations(),
258
+ };
259
+ const changes = [];
260
+ let scanned = 0;
261
+ for (const file of await markdownIn(oceanPath(DAILY_DIR, "sessions"))) {
262
+ const text = await readFile(file, "utf8").catch(() => "");
263
+ if (!/^type: session$/m.test(text.slice(0, 4096)))
264
+ continue;
265
+ scanned++;
266
+ const change = await planRecord(file, text, context);
267
+ if (change)
268
+ changes.push(change);
269
+ }
270
+ for (const file of await markdownIn(oceanPath(INBOX_DIR, "candidates"))) {
271
+ const text = await readFile(file, "utf8").catch(() => "");
272
+ scanned++;
273
+ const change = await planCandidate(file, text);
274
+ if (change)
275
+ changes.push(change);
276
+ }
277
+ return { scanned, changes };
278
+ }
279
+ // Writes the plan: every file is copied, at its workspace path, under one backup folder first.
280
+ // A file that changed since it was planned is left alone and reported.
281
+ export async function applyRelink(plan, now = new Date()) {
282
+ const stamp = now.toISOString().replace(/[:.]/g, "-");
283
+ const backup = oceanPath(SYSTEM_DIR, "state", "backups", `relink-${stamp}`);
284
+ const written = [];
285
+ const stale = [];
286
+ for (const change of plan.changes) {
287
+ const file = oceanPath(change.file);
288
+ if ((await readFile(file, "utf8").catch(() => "")) !== change.before) {
289
+ stale.push(change.file);
290
+ continue;
291
+ }
292
+ const copy = path.join(backup, change.file);
293
+ await mkdir(path.dirname(copy), { recursive: true, mode: 0o700 });
294
+ await copyFile(file, copy);
295
+ await atomicWrite(file, change.after);
296
+ written.push(change.file);
297
+ }
298
+ return { written, stale, backup: relative(backup) };
299
+ }
300
+ //# sourceMappingURL=session-relink.js.map
@@ -1,7 +1,7 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { mkdir, rm, stat } from "node:fs/promises";
3
3
  import path from "node:path";
4
- import { writeSessionSummary } from "@ocean/brain/memory/session-summary.js";
4
+ import { writeSessionSummary } from "@ocean/brain/sessions-capture/session-summary.js";
5
5
  import { oceanPath, SYSTEM_DIR } from "@ocean/core/shared/paths.js";
6
6
  // Session retention (T-228): summarize finished, unsummarized sessions to markdown, then
7
7
  // prune their raw provider_output/terminal_input events (never a session row, a handoff, an
@@ -1,6 +1,6 @@
1
1
  import { readdir, readFile, stat } from "node:fs/promises";
2
2
  import path from "node:path";
3
- import { parseTaskId, taskIdSpellings, } from "@ocean/core/domain/tasks/task-id.js";
3
+ import { parseTaskId, taskIdSpellings } from "@ocean/core/domain/task-id.js";
4
4
  import { oceanPath, PROJECTS_DIR, projectSubdir, resolveWithin, WORKSPACE_PROJECT_ID, } from "@ocean/core/shared/paths.js";
5
5
  import { folderProject, projectsWithTasks, } from "@ocean/core/shared/project-resolution.js";
6
6
  /**
@@ -43,19 +43,24 @@ export async function listTasks(state, projectId = WORKSPACE_PROJECT_ID) {
43
43
  continue;
44
44
  const objective = source.match(/\n## Objective\n\n([\s\S]*?)(?=\n## |$)/)?.[1]?.trim() ??
45
45
  "";
46
+ const next = source
47
+ .match(/\n## Next action\n\n([\s\S]*?)(?=\n\n|\n## |$)/)?.[1]
48
+ ?.replace(/\s+/g, " ")
49
+ .trim() ?? "";
46
50
  records.push({
47
51
  id: fields.id ?? entry.name,
48
52
  title: fields.title ?? "",
49
53
  state: fields.state ?? "",
50
54
  goal: objective || fields.goal || fields.requirement || "",
51
55
  updatedAt: fields.updated ?? fields.updated_at ?? "",
56
+ next,
52
57
  });
53
58
  }
54
59
  return records.sort((a, b) => a.id.localeCompare(b.id));
55
60
  }
56
61
  // Projects whose live tasks/ holds this id (T-3 and T-003 are one task). Ids are unique per
57
62
  // project, not across projects.
58
- export async function projectsHoldingTask(id) {
63
+ async function _projectsHoldingTask(id) {
59
64
  if (!parseTaskId(id))
60
65
  return [];
61
66
  const holders = [];
@@ -1,9 +1,11 @@
1
1
  import { access, readFile, rename } from "node:fs/promises";
2
2
  import path from "node:path";
3
- import { formatTaskId, isValidPrefix, LEGACY_PREFIX, parseTaskId, } from "@ocean/core/domain/tasks/task-id.js";
3
+ import { formatTaskId, isValidPrefix, LEGACY_PREFIX, parseTaskId, } from "@ocean/core/domain/task-id.js";
4
4
  import { atomicWrite } from "@ocean/core/shared/fs-utils.js";
5
5
  import { isWorkspaceProject, oceanRoot, PROJECTS_DIR, WORKSPACE_PROJECT_ID, } from "@ocean/core/shared/paths.js";
6
- import { highestTaskNumber, listProjectManifests, withProjectsLock, writeManifest, } from "@ocean/core/shared/project-resolution.js";
6
+ import { withProjectsLock } from "@ocean/core/shared/project-legacy.js";
7
+ import { listProjectManifests, writeManifest, } from "@ocean/core/shared/project-manifest.js";
8
+ import { highestTaskNumber } from "@ocean/core/shared/project-resolution.js";
7
9
  import { taskFolders } from "@ocean/core/shared/task-reference.js";
8
10
  // Moves a project's tasks from the shared T namespace to its own prefix (T-256): T-300 becomes
9
11
  // OL-001, and the record keeps `legacyId: T-300` so every old reference still resolves. Dry run
@@ -1,6 +1,6 @@
1
1
  import { readdir, readFile } from "node:fs/promises";
2
2
  import path from "node:path";
3
- import { parseTaskId, taskIdSpellings, } from "@ocean/core/domain/tasks/task-id.js";
3
+ import { parseTaskId, taskIdSpellings } from "@ocean/core/domain/task-id.js";
4
4
  import { parseFrontmatter } from "@ocean/core/shared/fs-utils.js";
5
5
  import { BRAIN_RECORD_DIRS, CHARTER_DIR, listProjectDirs, oceanPath, oceanRoot, SYSTEM_DIR, } from "@ocean/core/shared/paths.js";
6
6
  import { CLAIM_TTL_MS } from "./claim-task.js";
@@ -75,7 +75,7 @@ export async function gitBranchAt(cwd) {
75
75
  }
76
76
  }
77
77
  // Every task folder in every project (archive/ excluded), with its state and claim.
78
- export async function sessionTaskCandidates() {
78
+ async function sessionTaskCandidates() {
79
79
  const candidates = [];
80
80
  for (const { id: project, dir } of listProjectDirs()) {
81
81
  const root = oceanPath(dir, "tasks");
@@ -1,9 +1,33 @@
1
1
  import { readdir, readFile, writeFile } from "node:fs/promises";
2
2
  import { resolveWithin } from "@ocean/core/shared/paths.js";
3
3
  import { completionIssues } from "./archive-tasks.js";
4
+ // Phases (owner, 2026-11-29): a task with several pieces of work lists them under `## Phases` as
5
+ // checkboxes and lands them all on one branch in one PR. An open PR moves it to `in-qa` only once
6
+ // every phase is ticked; until then the task stays `active` (a `todo` or `in-qa` one is moved there).
7
+ export function openPhases(source) {
8
+ const section = /^## Phases[ \t]*\r?\n([\s\S]*?)(?=^## |(?![\s\S]))/m.exec(source);
9
+ return section ? (section[1].match(/^\s*[-*] \[ \]/gm) ?? []).length : 0;
10
+ }
4
11
  // States the sync may move. `blocked`, `done` and `cancelled` are the owner's or the gate's.
5
12
  const SYNCED = new Set(["todo", "active", "paused", "in-qa"]);
6
13
  const PR_URL = /https:\/\/github\.com\/([\w.-]+\/[\w.-]+)\/pull\/(\d+)/g;
14
+ // The strings that name a task in a PR title or a branch: its id (also hyphenless; padded tracker ids such
15
+ // as STPL-005 also as STPL-5) and every Jira key in a /browse/ URL of the task.
16
+ export function taskTokens(source, id) {
17
+ // Branches are often named without the hyphen (`feat/t328-onboarding`).
18
+ const tokens = new Set([id, id.replace("-", "")]);
19
+ const padded = id.match(/^([A-Za-z][A-Za-z0-9]*)-0+(\d+)$/);
20
+ if (padded)
21
+ tokens.add(`${padded[1]}-${padded[2]}`);
22
+ for (const match of source.matchAll(/\/browse\/([A-Z][A-Z0-9]+-\d+)/g))
23
+ tokens.add(match[1]);
24
+ return [...tokens];
25
+ }
26
+ // Whether `text` names one of the tokens as a whole key: `t-327` in `feat/t-327-sync` matches,
27
+ // `T-32` in `T-327` does not.
28
+ export function mentionsToken(text, tokens) {
29
+ return tokens.some((token) => new RegExp(`(?<![A-Za-z0-9])${token.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![A-Za-z0-9])`, "i").test(text));
30
+ }
7
31
  export function prLinks(source) {
8
32
  const seen = new Map();
9
33
  for (const match of source.matchAll(PR_URL)) {
@@ -65,12 +89,25 @@ export async function syncTaskPrs(root, options) {
65
89
  const from = field(source, "state") ?? "";
66
90
  if (!SYNCED.has(from))
67
91
  continue;
68
- const links = prLinks(source);
69
- if (!links.length)
70
- continue;
71
- let states;
92
+ const tokens = taskTokens(source, id);
93
+ const links = new Map(prLinks(source).map((link) => [link.url, link]));
94
+ if (options.discoverPrs) {
95
+ try {
96
+ for (const link of await options.discoverPrs(tokens))
97
+ if (!links.has(link.url))
98
+ links.set(link.url, link);
99
+ }
100
+ catch (error) {
101
+ result.skipped.push({
102
+ id,
103
+ reason: `PR discovery failed: ${error instanceof Error ? error.message : String(error)}`,
104
+ });
105
+ }
106
+ }
107
+ const linked = [...links.values()];
108
+ let states = [];
72
109
  try {
73
- states = await Promise.all(links.map((link) => options.fetchPr(link)));
110
+ states = await Promise.all(linked.map((link) => options.fetchPr(link)));
74
111
  }
75
112
  catch (error) {
76
113
  result.skipped.push({
@@ -79,10 +116,43 @@ export async function syncTaskPrs(root, options) {
79
116
  });
80
117
  continue;
81
118
  }
82
- const to = targetState(states);
119
+ let to = targetState(states);
120
+ const unfinished = openPhases(source);
121
+ if (to === "in-qa" && unfinished) {
122
+ // First phase done is not QA: keep working until every phase is ticked.
123
+ if (from === "active" || from === "paused")
124
+ continue;
125
+ to = "active";
126
+ result.changed.push({
127
+ id,
128
+ from,
129
+ to,
130
+ prs: linked.map((link, index) => `${link.url} (${states[index]})`),
131
+ reason: `${unfinished} phase${unfinished === 1 ? "" : "s"} still open`,
132
+ });
133
+ if (options.apply)
134
+ await writeFile(file, withState(source, "active", `${from} → active (sync): PR open, ${unfinished} phase${unfinished === 1 ? "" : "s"} still open.`, day));
135
+ continue;
136
+ }
137
+ if (!to && from === "todo" && options.branchAhead) {
138
+ // No PR yet: work has started once a branch for the task is ahead of its base.
139
+ const branch = await options.branchAhead(tokens);
140
+ if (branch) {
141
+ result.changed.push({
142
+ id,
143
+ from,
144
+ to: "active",
145
+ prs: [],
146
+ reason: branch,
147
+ });
148
+ if (options.apply)
149
+ await writeFile(file, withState(source, "active", `todo → active (sync): ${branch}.`, day));
150
+ }
151
+ continue;
152
+ }
83
153
  if (!to || to === from)
84
154
  continue;
85
- const prs = links.map((link, index) => `${link.url} (${states[index]})`);
155
+ const prs = linked.map((link, index) => `${link.url} (${states[index]})`);
86
156
  if (to === "in-qa") {
87
157
  result.changed.push({ id, from, to, prs });
88
158
  if (options.apply)
@@ -0,0 +1,63 @@
1
+ import { execFile as execFileCallback } from "node:child_process";
2
+ import { promisify } from "node:util";
3
+ const execFile = promisify(execFileCallback);
4
+ // The commit checked out at `cwd`, or null outside a repository (T-320 F1).
5
+ export async function headCommit(cwd) {
6
+ try {
7
+ const { stdout } = await execFile("git", ["rev-parse", "HEAD"], { cwd });
8
+ return stdout.trim() || null;
9
+ }
10
+ catch {
11
+ return null;
12
+ }
13
+ }
14
+ // Whether anything under `paths` differs from `base`: committed since, staged, unstaged or
15
+ // untracked. null when git cannot answer (no repository, unknown commit).
16
+ export async function changedSince(cwd, base, paths) {
17
+ try {
18
+ const { stdout: diff } = await execFile("git", ["diff", "--name-only", base, "--", ...paths], { cwd, maxBuffer: 16 * 1024 * 1024 });
19
+ if (diff.trim())
20
+ return true;
21
+ const { stdout: untracked } = await execFile("git", ["ls-files", "--others", "--exclude-standard", "--", ...paths], { cwd, maxBuffer: 16 * 1024 * 1024 });
22
+ return Boolean(untracked.trim());
23
+ }
24
+ catch {
25
+ return null;
26
+ }
27
+ }
28
+ // A local branch of the repo at `cwd` whose name carries one of `matches`'s tokens and that has
29
+ // commits its base does not (T-327): the signal that work on a task has started. The base is the
30
+ // remote's default branch (`origin/HEAD`), else `main`, else `master`. Returns "branch X is N
31
+ // commits ahead of <base>", or null when there is none or git cannot answer.
32
+ export async function branchAheadOfBase(cwd, matches) {
33
+ const git = async (...args) => (await execFile("git", args, { cwd })).stdout.trim();
34
+ try {
35
+ let base = "";
36
+ for (const candidate of [
37
+ await git("symbolic-ref", "--short", "refs/remotes/origin/HEAD").catch(() => ""),
38
+ "main",
39
+ "master",
40
+ ]) {
41
+ if (candidate &&
42
+ (await git("rev-parse", "--verify", candidate).catch(() => ""))) {
43
+ base = candidate;
44
+ break;
45
+ }
46
+ }
47
+ if (!base)
48
+ return null;
49
+ const branches = (await git("for-each-ref", "--format=%(refname:short)", "refs/heads"))
50
+ .split("\n")
51
+ .filter((branch) => branch && branch !== base && matches(branch));
52
+ for (const branch of branches) {
53
+ const ahead = Number(await git("rev-list", "--count", `${base}..${branch}`));
54
+ if (ahead > 0)
55
+ return `branch ${branch} is ${ahead} commit${ahead === 1 ? "" : "s"} ahead of ${base}`;
56
+ }
57
+ return null;
58
+ }
59
+ catch {
60
+ return null;
61
+ }
62
+ }
63
+ //# sourceMappingURL=task-git.js.map
@@ -2,14 +2,14 @@ import { randomUUID } from "node:crypto";
2
2
  import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { assertGuard, guardProblems, } from "@ocean/core/domain/runs/loop-guard.js";
5
- import { TASK_ID } from "@ocean/core/domain/tasks/task-id.js";
5
+ import { TASK_ID } from "@ocean/core/domain/task-id.js";
6
6
  import { oceanPath, projectDir, resolveWithin, SYSTEM_DIR, } from "@ocean/core/shared/paths.js";
7
7
  import { folderProject } from "@ocean/core/shared/project-resolution.js";
8
8
  import { resolveTaskReference, } from "@ocean/core/shared/task-reference.js";
9
+ import { afterGuardedRun, writeEscalation } from "../runs/guard-runtime.js";
9
10
  import { runAgent } from "../runs/run-agent.js";
10
- import { checkpointTask } from "../tasks/checkpoint-task.js";
11
- import { verifyTask } from "../tasks/verify-task.js";
12
- import { afterGuardedRun, writeEscalation } from "./guard-runtime.js";
11
+ import { checkpointTask } from "./checkpoint-task.js";
12
+ import { verifyTask } from "./verify-task.js";
13
13
  const loopsFile = () => oceanPath(SYSTEM_DIR, "loops.json");
14
14
  const checkpointsDir = () => oceanPath(SYSTEM_DIR, "loop-checkpoints");
15
15
  export async function listTaskLoops() {
@@ -2,7 +2,7 @@ import { existsSync, readdirSync, readFileSync } from "node:fs";
2
2
  import { readFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { isWorkspaceProject, projectOfTasksRoot, repoRoot, resolveWithin, workspaceTasksRoot, } from "@ocean/core/shared/paths.js";
5
- import { expandHome, projectVerify, readProjectManifest, } from "@ocean/core/shared/project-resolution.js";
5
+ import { expandHome, projectVerify, readProjectManifest, } from "@ocean/core/shared/project-manifest.js";
6
6
  import { declaredVerificationCommands } from "./verify-task.js";
7
7
  // Whether `ocean tasks complete` will be able to verify this task, checked early and without
8
8
  // running anything (T-291): T-283 named a test file that did not exist, which surfaced only at
@@ -4,7 +4,7 @@ import { readFile } from "node:fs/promises";
4
4
  import path from "node:path";
5
5
  import { promisify } from "node:util";
6
6
  import { isWorkspaceProject, projectOfTasksRoot, repoRoot, resolveWithin, workspaceTasksRoot, } from "@ocean/core/shared/paths.js";
7
- import { expandHome, hasControlCharacters, projectVerify, readProjectManifest, } from "@ocean/core/shared/project-resolution.js";
7
+ import { expandHome, hasControlCharacters, projectVerify, readProjectManifest, } from "@ocean/core/shared/project-manifest.js";
8
8
  const execFile = promisify(execFileCallback);
9
9
  // Only commands whose first token is on this list are ever executed by the
10
10
  // verifier — including every link of a `&&`/`||`/`;`/`|` chain, since each
@@ -1,6 +1,6 @@
1
1
  {
2
- "name": "@ocean/loop",
3
- "version": "2.22.0",
2
+ "name": "@ocean/work",
3
+ "version": "3.0.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {