@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
@@ -1,13 +1,20 @@
1
1
  import { readFile, realpath } from "node:fs/promises";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
- import { buildOceanBootstrap } from "@ocean/context/context/resource-injection.js";
4
+ import { buildOceanBootstrap } from "@ocean/context/resource-injection.js";
5
5
  import { MEMORY_AUTHORITY_LINE } from "@ocean/core/domain/mcp/memory-contract.js";
6
+ import { fillProjectProfiles } from "@ocean/core/profiles/project-profile-fill.js";
7
+ import { baseProfileBody, profileBrief, profileCatalog, recordProfileSelection, sessionProfile, } from "@ocean/core/profiles/session-profile.js";
8
+ import { policyCatalog, readRules, rulesPointer, } from "@ocean/core/shared/charter.js";
6
9
  import { recordIssuedAck } from "@ocean/core/shared/context-ack.js";
7
10
  import { truncateUtf8 } from "@ocean/core/shared/fs-utils.js";
8
11
  import { oceanRoot, SYSTEM_DIR } from "@ocean/core/shared/paths.js";
9
- import { autoRegisterProject, gitChangedFiles, projectRules, readProjectManifest, resolveProject, scanProjectManifests, } from "@ocean/core/shared/project-resolution.js";
12
+ import { expandHome, listProjectManifests, matchProject, projectRules, readProjectManifest, scanProjectManifests, } from "@ocean/core/shared/project-manifest.js";
13
+ import { autoRegisterProject } from "@ocean/core/shared/project-register.js";
14
+ import { gitChangedFiles, resolveProject, } from "@ocean/core/shared/project-resolution.js";
10
15
  import { connectedLine, recordConnected, } from "@ocean/core/shared/visibility.js";
16
+ import { startBrief } from "./start-brief.js";
17
+ import { unlinkedFolderWarning } from "./unlinked-warning.js";
11
18
  const MAX_STDIN_BYTES = 65_536;
12
19
  export async function readBoundedStdin(stream = process.stdin, maxBytes = MAX_STDIN_BYTES) {
13
20
  if (stream.isTTY)
@@ -53,8 +60,10 @@ async function registerIfUnbound(cwd, resolved) {
53
60
  if (resolved.status !== "unbound")
54
61
  return resolved;
55
62
  try {
56
- return (await autoRegisterProject(cwd, { resolution: resolved }))
57
- .resolution;
63
+ const registered = await autoRegisterProject(cwd, { resolution: resolved });
64
+ if (registered.status === "registered")
65
+ await fillProjectProfiles(registered.projectId, registered.path);
66
+ return registered.resolution;
58
67
  }
59
68
  catch {
60
69
  return resolved;
@@ -97,7 +106,7 @@ async function unreadableManifestsWarning() {
97
106
  }
98
107
  // Hard constraints must hold from turn one, so the rules themselves ride beside the bootstrap
99
108
  // (at most 10 lines of 200 bytes), not just a count.
100
- export function projectRulesBlock(projectId, rules) {
109
+ function projectRulesBlock(projectId, rules) {
101
110
  return `Project rules (${projectId}):\n${rules.map((rule) => `- ${rule}`).join("\n")}`;
102
111
  }
103
112
  export async function claudeSessionStartHook(payload) {
@@ -124,11 +133,25 @@ export async function claudeSessionStartHook(payload) {
124
133
  catch (error) {
125
134
  rulesProblem = error instanceof Error ? error.message : String(error);
126
135
  }
127
- const bootstrap = buildOceanBootstrap(project, { rules: rules.length });
136
+ const catalog = await profileCatalog().catch(() => undefined);
137
+ const profile = await sessionProfile({
138
+ projectId: project.status === "bound" ? project.projectId : undefined,
139
+ cwd,
140
+ catalog,
141
+ });
142
+ const bootstrap = buildOceanBootstrap(project, {
143
+ rules: rules.length,
144
+ profile: profile.primary,
145
+ });
128
146
  const shown = project.status === "bound" ? project.projectId : project.status;
129
147
  await Promise.all([
130
148
  recordIssuedAck(bootstrap.ack),
131
149
  recordConnected(cwd, shown),
150
+ recordProfileSelection({
151
+ source: "hook",
152
+ project: shown,
153
+ session: profile,
154
+ }),
132
155
  ]);
133
156
  // Beside the 256-byte bootstrap, never inside it: the authority claim is its own line.
134
157
  const parts = [bootstrap.content, MEMORY_AUTHORITY_LINE];
@@ -141,6 +164,29 @@ export async function claudeSessionStartHook(payload) {
141
164
  const unreadable = await unreadableManifestsWarning();
142
165
  if (unreadable)
143
166
  parts.push(unreadable);
167
+ const unlinked = await unlinkedFolderWarning(project);
168
+ if (unlinked)
169
+ parts.push(unlinked);
170
+ }
171
+ if (project.status === "bound") {
172
+ const brief = await startBrief(project.projectId);
173
+ if (brief)
174
+ parts.push(brief);
175
+ }
176
+ const briefLine = profileBrief(profile);
177
+ if (briefLine)
178
+ parts.push(briefLine);
179
+ const base = catalog ? baseProfileBody(catalog) : null;
180
+ if (base)
181
+ parts.push(base);
182
+ // The active profile's own policies, as digests (T-339 P1 §1.4); a prompt opens the rest.
183
+ if (profile.profile?.policies.length) {
184
+ const policies = await policyCatalog().catch(() => []);
185
+ for (const name of profile.profile.policies) {
186
+ const entry = policies.find((candidate) => candidate.name === name);
187
+ if (entry?.digest)
188
+ parts.push(`Policy ${name}: ${entry.digest}`);
189
+ }
144
190
  }
145
191
  if (warning)
146
192
  parts.push(warning);
@@ -153,17 +199,88 @@ export async function claudeSessionStartHook(payload) {
153
199
  };
154
200
  }
155
201
  // The same bounded bootstrap line a session-start hook gives, for clients without hooks (T-307).
156
- // Read-only: it never registers a project, and it carries no rules, records or warnings.
157
- export async function oceanContext(cwd) {
202
+ // Read-only: it never registers a project, and it carries no records or warnings, only a pointer
203
+ // to the rules.
204
+ // A project named outright (T-333: a Claude Desktop chat has no cwd that means anything), as the
205
+ // bound resolution the start line and brief take. A name no project answers to is an error.
206
+ async function namedProject(ref) {
207
+ const manifests = await listProjectManifests();
208
+ const id = matchProject(manifests, ref);
209
+ const manifest = manifests.find((candidate) => candidate.id === id);
210
+ if (!manifest)
211
+ throw new Error(`no project answers to '${ref}'`);
212
+ return {
213
+ status: "bound",
214
+ projectId: manifest.id,
215
+ name: manifest.name,
216
+ // project.json keeps paths portable (`~/…`); the repository signals need the real one.
217
+ path: expandHome(manifest.paths[0] ?? ""),
218
+ matchedOn: "path",
219
+ confidence: "high",
220
+ };
221
+ }
222
+ export async function oceanContext(cwd, projectRef, policy) {
223
+ // T-339 P2: `ocean_policy` folded in — a named policy (or "core") is returned as is.
224
+ if (policy)
225
+ return readRules(policy);
226
+ if (projectRef)
227
+ return contextFor(await namedProject(projectRef));
158
228
  const project = await resolveProject(cwd).catch(() => ({
159
229
  status: "unbound",
160
230
  cwd: path.resolve(cwd),
161
231
  gitRoot: null,
162
232
  confidence: "none",
163
233
  }));
164
- const bootstrap = buildOceanBootstrap(project);
165
- await recordIssuedAck(bootstrap.ack);
166
- return bootstrap.content;
234
+ return contextFor(project, cwd);
235
+ }
236
+ async function contextFor(project, cwd) {
237
+ // A named project (Desktop) has no cwd of its own: its signals come from its own folder.
238
+ const catalog = await profileCatalog().catch(() => undefined);
239
+ const profile = await sessionProfile({
240
+ projectId: project.status === "bound" ? project.projectId : undefined,
241
+ cwd: cwd ?? (project.status === "bound" ? project.path : undefined),
242
+ catalog,
243
+ });
244
+ const bootstrap = buildOceanBootstrap(project, { profile: profile.primary });
245
+ await Promise.all([
246
+ recordIssuedAck(bootstrap.ack),
247
+ recordProfileSelection({
248
+ source: "context",
249
+ project: project.status === "bound" ? project.projectId : project.status,
250
+ session: profile,
251
+ }),
252
+ ]);
253
+ // A hookless client never sees the rules a hook client gets as its CLAUDE.md copy: a pointer
254
+ // beside the bounded line, never inside it (T-328).
255
+ const rules = await rulesPointer();
256
+ // The same start brief a hook client gets, so a hookless client starts where the project stands.
257
+ const brief = project.status === "bound" ? await startBrief(project.projectId) : null;
258
+ // The base body and the policies a hook client would get per prompt (T-339 P1 §1.4): the
259
+ // active profile's own policy digests, and every policy with its first triggers.
260
+ const base = catalog ? baseProfileBody(catalog) : null;
261
+ const policies = rules ? await policyCatalog().catch(() => []) : [];
262
+ const own = (profile.profile?.policies ?? [])
263
+ .map((name) => policies.find((entry) => entry.name === name))
264
+ .filter((entry) => entry?.digest)
265
+ .map((entry) => `Policy ${entry?.name}: ${entry?.digest}`);
266
+ const index = policies.length
267
+ ? `Policies (ocean_context with policy=<name> when one applies): ${policies
268
+ .map((entry) => entry.triggers.length
269
+ ? `${entry.name} [${entry.triggers.slice(0, 3).join(", ")}]`
270
+ : entry.name)
271
+ .join("; ")}`
272
+ : null;
273
+ return [
274
+ bootstrap.content,
275
+ rules,
276
+ brief,
277
+ profileBrief(profile),
278
+ base,
279
+ ...own,
280
+ index,
281
+ ]
282
+ .filter(Boolean)
283
+ .join("\n");
167
284
  }
168
285
  // Clients that take the bootstrap through their own hooks instead of a same-name shim (T-266).
169
286
  // Codex and Gemini CLI (0.58: fireSessionStartEvent → getAdditionalContext, T-296) read Claude
@@ -185,7 +302,7 @@ export function isSessionStartClient(value) {
185
302
  return SESSION_START_CLIENTS.includes(value);
186
303
  }
187
304
  // Cursor names its folder in `workspace_roots`, not `cwd`. Nothing else in a payload is kept.
188
- export function payloadCwd(payload) {
305
+ function payloadCwd(payload) {
189
306
  if (payload.cwd)
190
307
  return payload.cwd;
191
308
  const roots = payload.workspace_roots;
@@ -0,0 +1,110 @@
1
+ import { readdir, readFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { readMetadata } from "@ocean/core/domain/sessions/session-metadata.js";
4
+ import { parseFrontmatter } from "@ocean/core/shared/fs-utils.js";
5
+ import { DAILY_DIR, oceanPath } from "@ocean/core/shared/paths.js";
6
+ import { listTasks } from "../../tasks/list-tasks.js";
7
+ // The start brief (T-329 phase 5): where the project stands, in a few pointer lines beside the
8
+ // bootstrap — its live tasks with their next action, and the last session's next step. Pointers
9
+ // only (ids, titles, one-line next steps), never a record's body: T-198 still holds.
10
+ export const START_BRIEF_MAX_BYTES = 600;
11
+ const ITEM_MAX_CHARS = 170;
12
+ const MAX_TASKS = 3;
13
+ // Session files read, newest first, before giving up on finding this project's last one.
14
+ const MAX_SESSION_FILES = 300;
15
+ const LIVE_STATES = new Set(["active", "in-qa", "blocked"]);
16
+ const clip = (text, max = ITEM_MAX_CHARS) => {
17
+ const flat = text.replace(/\s+/g, " ").trim();
18
+ return flat.length > max ? `${flat.slice(0, max - 1)}…` : flat;
19
+ };
20
+ // The newest session record of this project, by file name (records start with their date and
21
+ // time). The archive is left alone: an archived session is not where the project stands.
22
+ export async function lastProjectSession(projectId) {
23
+ const root = oceanPath(DAILY_DIR, "sessions");
24
+ let months;
25
+ try {
26
+ months = (await readdir(root, { withFileTypes: true }))
27
+ .filter((entry) => entry.isDirectory() && /^\d{4}-\d{2}$/.test(entry.name))
28
+ .map((entry) => entry.name)
29
+ .sort()
30
+ .reverse();
31
+ }
32
+ catch {
33
+ return null;
34
+ }
35
+ let read = 0;
36
+ for (const month of months) {
37
+ let files;
38
+ try {
39
+ files = (await readdir(path.join(root, month)))
40
+ .filter((name) => name.endsWith(".md"))
41
+ .sort()
42
+ .reverse();
43
+ }
44
+ catch {
45
+ continue;
46
+ }
47
+ for (const name of files) {
48
+ if (read++ >= MAX_SESSION_FILES)
49
+ return null;
50
+ let text;
51
+ try {
52
+ text = await readFile(path.join(root, month, name), "utf8");
53
+ }
54
+ catch {
55
+ continue;
56
+ }
57
+ const fields = parseFrontmatter(text);
58
+ if (fields.type !== "session")
59
+ continue;
60
+ if ((fields.project ?? "") !== projectId)
61
+ continue;
62
+ const meta = readMetadata(fields);
63
+ const next = /\n## Next\n\n([\s\S]*?)(?=\n## |$)/
64
+ .exec(text)?.[1]
65
+ ?.split("\n")
66
+ .map((line) => line.replace(/^[-*]\s+/, "").trim())
67
+ .find(Boolean) ?? "";
68
+ return {
69
+ date: fields.date ?? "",
70
+ title: /^# (.+)$/m.exec(text)?.[1]?.trim() ?? name,
71
+ next,
72
+ ...(meta.task ? { task: meta.task } : {}),
73
+ ...(meta.branch ? { branch: meta.branch } : {}),
74
+ };
75
+ }
76
+ }
77
+ return null;
78
+ }
79
+ // " (T-334, feat/x)": the task and branch the last session worked on, when its record says.
80
+ const lastWhere = (last) => {
81
+ const where = [last.task, last.branch].filter(Boolean).join(", ");
82
+ return where ? ` (${where})` : "";
83
+ };
84
+ // The brief for a project Ocean knows, or null when there is nothing to say. Never throws: a
85
+ // session must keep its bootstrap whatever state the workspace is in.
86
+ export async function startBrief(projectId) {
87
+ const [tasks, last] = await Promise.all([
88
+ listTasks(undefined, projectId).catch(() => []),
89
+ lastProjectSession(projectId).catch(() => null),
90
+ ]);
91
+ const live = tasks
92
+ .filter((task) => LIVE_STATES.has(task.state))
93
+ .sort((a, b) => b.updatedAt.localeCompare(a.updatedAt))
94
+ .slice(0, MAX_TASKS);
95
+ const items = live.map((task) => clip(`${task.id} ${task.state}: ${task.title}${task.next ? ` — next: ${task.next}` : ""}`));
96
+ if (last)
97
+ items.push(clip(`Last session${last.date ? ` ${last.date}` : ""}${lastWhere(last)}: ${last.title}${last.next ? ` — next: ${last.next}` : ""}`));
98
+ if (!items.length)
99
+ return null;
100
+ const lines = [`Start brief (${projectId}):`];
101
+ // Whole items only: one that would break the budget is left out, never cut mid-line.
102
+ for (const item of items) {
103
+ const candidate = [...lines, `- ${item}`].join("\n");
104
+ if (Buffer.byteLength(candidate, "utf8") > START_BRIEF_MAX_BYTES)
105
+ break;
106
+ lines.push(`- ${item}`);
107
+ }
108
+ return lines.length > 1 ? lines.join("\n") : null;
109
+ }
110
+ //# sourceMappingURL=start-brief.js.map
@@ -0,0 +1,68 @@
1
+ import { mkdir, readFile } from "node:fs/promises";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { atomicWrite, truncateUtf8 } from "@ocean/core/shared/fs-utils.js";
5
+ import { oceanPath, SYSTEM_DIR } from "@ocean/core/shared/paths.js";
6
+ import { listProjectManifests, suggestProjects, } from "@ocean/core/shared/project-manifest.js";
7
+ import { normalizeName } from "@ocean/core/shared/project-names.js";
8
+ // One line at session start when the folder (or, from P3, the Claude project) a session runs in
9
+ // is linked to no project (T-332): bounded, and said at most once per name per day, so it is a
10
+ // nudge and never noise. The full list, with every fix, is `ocean project doctor`.
11
+ export const UNLINKED_WARNING_MAX_BYTES = 120;
12
+ function unlinkedWarnedFile() {
13
+ return oceanPath(SYSTEM_DIR, "state", "projects", "unlinked-warned.json");
14
+ }
15
+ const day = (now) => now.toISOString().slice(0, 10);
16
+ // True the first time `name` is seen on this day, and records it; false after that. Only the
17
+ // current day's names are kept. An unreadable state file reads as empty: one repeat at worst.
18
+ export async function firstTodayFor(name, now = new Date()) {
19
+ const file = unlinkedWarnedFile();
20
+ const today = day(now);
21
+ let seen = {};
22
+ try {
23
+ const parsed = JSON.parse(await readFile(file, "utf8"));
24
+ if (parsed && typeof parsed === "object")
25
+ seen = Object.fromEntries(Object.entries(parsed).filter(([, value]) => value === today));
26
+ }
27
+ catch {
28
+ /* none yet */
29
+ }
30
+ const key = normalizeName(name);
31
+ if (seen[key])
32
+ return false;
33
+ seen[key] = today;
34
+ await mkdir(path.dirname(file), { recursive: true });
35
+ await atomicWrite(file, `${JSON.stringify(seen, null, 2)}\n`);
36
+ return true;
37
+ }
38
+ export function unlinkedLine(name, fix) {
39
+ return truncateUtf8(`Ocean: ${JSON.stringify(name)} is linked to no project → ${fix}`, UNLINKED_WARNING_MAX_BYTES);
40
+ }
41
+ const tilde = (dir) => {
42
+ const home = os.homedir();
43
+ return dir === home || dir.startsWith(`${home}${path.sep}`)
44
+ ? `~${dir.slice(home.length)}`
45
+ : dir;
46
+ };
47
+ // An unbound session in a git repo: name the repo and the bind that links it. A scratch folder
48
+ // or the home directory has no git root and gets nothing. Best-effort, never throws.
49
+ export async function unlinkedFolderWarning(project, now = new Date()) {
50
+ try {
51
+ if (project.status !== "unbound" || !project.gitRoot)
52
+ return null;
53
+ const name = path.basename(project.gitRoot);
54
+ if (!(await firstTodayFor(name, now)))
55
+ return null;
56
+ const ids = [
57
+ ...new Set(suggestProjects(await listProjectManifests(), name).map((s) => s.id)),
58
+ ];
59
+ const id = ids.length === 1 ? ids[0] : "<id>";
60
+ const full = unlinkedLine(name, `ocean project bind ${id} ${tilde(project.gitRoot)} --add`);
61
+ const fix = `ocean project bind ${id} . --add`;
62
+ return full.endsWith(" --add") ? full : unlinkedLine(name, fix);
63
+ }
64
+ catch {
65
+ return null;
66
+ }
67
+ }
68
+ //# sourceMappingURL=unlinked-warning.js.map
@@ -1,10 +1,10 @@
1
1
  import { writeBrainDump } from "@ocean/brain/memory/brain-dump.js";
2
2
  import { learnFromSession, } from "@ocean/brain/memory/lesson-learning.js";
3
3
  import { generateModelNarrative } from "@ocean/brain/memory/model-narrative.js";
4
- import { writeSessionSummary, } from "@ocean/brain/memory/session-summary.js";
4
+ import { writeSessionSummary, } from "@ocean/brain/sessions-capture/session-summary.js";
5
5
  import { safeJsonParse } from "@ocean/core/shared/fs-utils.js";
6
6
  import { gitChangedFiles } from "@ocean/core/shared/project-resolution.js";
7
- import { createHandoffWithStore } from "../handoff/handoff-service.js";
7
+ import { createHandoffWithStore } from "./handoff-service.js";
8
8
  async function changedFiles(workingDirectory) {
9
9
  return (await gitChangedFiles(workingDirectory)).slice(0, 100);
10
10
  }
@@ -38,8 +38,8 @@ export async function finalizeSession(store, sessionId, input = {}) {
38
38
  // (e.g. a caller's success path completes closeout, then a later step in that same
39
39
  // caller throws and its catch block calls finalizeSession again). The summary/handoff
40
40
  // work below is already idempotent (guarded by existing handoffId / session_summary
41
- // event checks), but the daily-narrative append is a pure side effect with no such
42
- // check, so a re-run would otherwise write a duplicate "Work log" line. closedAt is
41
+ // event checks), but the brain dump and learning writes are side effects with no such
42
+ // check, so a re-run would otherwise duplicate them. closedAt is
43
43
  // only ever set by the updateCloseout call further down, so its presence here means
44
44
  // this session has already been closed out once.
45
45
  const alreadyClosedOut = Boolean(session.closedAt);
@@ -1,14 +1,24 @@
1
- import { folderProject } from "@ocean/core/shared/project-resolution.js";
1
+ import { NO_PROJECT, PROJECT_IDENTITY_EVENT, } from "@ocean/core/domain/sessions/session-identity.js";
2
+ import { folderProject, projectDecision, resolveProject, } from "@ocean/core/shared/project-resolution.js";
2
3
  // The project to record on a new session. Recording a session must not fail on registry state,
3
4
  // so an unreadable registry yields null; the next `ocean migrate --apply` fills it.
4
5
  export async function sessionProjectId(cwd) {
6
+ return (await sessionProjectDecision(cwd)).projectId || null;
7
+ }
8
+ // The project and how it was decided, once, when the session is created (T-331).
9
+ export async function sessionProjectDecision(cwd) {
5
10
  try {
6
- return await folderProject(cwd);
11
+ return projectDecision(await resolveProject(cwd));
7
12
  }
8
13
  catch {
9
- return null;
14
+ return NO_PROJECT;
10
15
  }
11
16
  }
17
+ // Records how the session's project was decided, so writers read it instead of recomputing.
18
+ export function recordProjectDecision(store, sessionId, decision) {
19
+ if (decision.projectId)
20
+ store.appendEvent(sessionId, PROJECT_IDENTITY_EVENT, JSON.stringify(decision));
21
+ }
12
22
  // Fill project_id on sessions recorded before the column existed, then on the handoffs that
13
23
  // came from them. An unreadable registry throws and aborts: never guess a folder's project.
14
24
  export async function backfillSessionProjects(store) {