@amoree-code/ocean 2.23.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 (380) hide show
  1. package/README.md +46 -53
  2. package/dist/application/clients/bundles.js +1 -1
  3. package/dist/application/clients/client-detect.js +291 -0
  4. package/dist/application/clients/clients.js +104 -25
  5. package/dist/application/clients/desktop-link.js +40 -0
  6. package/dist/application/clients/desktop-watcher.js +6 -4
  7. package/dist/application/clients/hook-trust.js +106 -0
  8. package/dist/application/clients/hooks.js +7 -1
  9. package/dist/application/clients/mcp-schema-cost.js +74 -0
  10. package/dist/application/clients/native.js +38 -2
  11. package/dist/application/clients/registry.js +51 -9
  12. package/dist/application/clients/status.js +7 -2
  13. package/dist/application/gateway/webhook-gateway.js +1 -1
  14. package/dist/application/integrations/charter-copies.js +1 -1
  15. package/dist/application/integrations/engine-entry-repair.js +4 -3
  16. package/dist/application/integrations/skill-auto-sync.js +2 -2
  17. package/dist/application/integrations/skill-filter.js +1 -1
  18. package/dist/application/integrations/skill-router.js +134 -90
  19. package/dist/application/layout/layout-apply.js +1 -1
  20. package/dist/application/layout/workspace-template.js +1 -1
  21. package/dist/application/onboarding/steps.js +121 -30
  22. package/dist/application/profiles/profile-doctor.js +118 -0
  23. package/dist/application/profiles/profile-migration-service.js +208 -0
  24. package/dist/application/profiles/profile-suggestion.js +3 -7
  25. package/dist/application/profiles/profile-upgrade-service.js +98 -86
  26. package/dist/application/pull/history-index.js +1 -1
  27. package/dist/application/pull/project-match.js +3 -3
  28. package/dist/application/pull/pull.js +1 -1
  29. package/dist/application/pull/server-capture.js +92 -9
  30. package/dist/application/scheduler/local-scheduler.js +2 -2
  31. package/dist/application/spend/claude-prices.js +55 -0
  32. package/dist/application/spend/claude-spend.js +365 -0
  33. package/dist/application/uninstall/uninstall.js +25 -3
  34. package/dist/application/upkeep/nightly-upkeep.js +4 -4
  35. package/dist/composition/runtime.js +2 -2
  36. package/dist/infrastructure/desktop/claude-export.js +1 -1
  37. package/dist/infrastructure/desktop/desktop-chat.js +60 -13
  38. package/dist/infrastructure/desktop/indexeddb.js +4 -4
  39. package/dist/infrastructure/desktop/leveldb.js +2 -2
  40. package/dist/infrastructure/filesystem/profile-loader.js +3 -45
  41. package/dist/infrastructure/filesystem/runtime-config-loader.js +1 -1
  42. package/dist/infrastructure/observability/runtime-logger.js +1 -1
  43. package/dist/infrastructure/process/agent-tool-executor.js +3 -3
  44. package/dist/infrastructure/process/process-supervisor.js +1 -1
  45. package/dist/infrastructure/process/service.js +8 -8
  46. package/dist/infrastructure/providers/openai-compatible.js +2 -2
  47. package/dist/infrastructure/providers/provider-invocation.js +1 -1
  48. package/dist/infrastructure/providers/session-facts-completer.js +78 -5
  49. package/dist/interfaces/cli/auth-command.js +2 -2
  50. package/dist/interfaces/cli/brief-command.js +1 -1
  51. package/dist/interfaces/cli/browser-command.js +6 -6
  52. package/dist/interfaces/cli/browser-findings.js +6 -9
  53. package/dist/interfaces/cli/browser-settings.js +10 -10
  54. package/dist/interfaces/cli/capture-command.js +6 -6
  55. package/dist/interfaces/cli/client-test-command.js +3 -3
  56. package/dist/interfaces/cli/clients-command.js +33 -6
  57. package/dist/interfaces/cli/command-aliases.js +56 -0
  58. package/dist/interfaces/cli/command-registry.js +48 -1414
  59. package/dist/interfaces/cli/commands/browser.js +5 -0
  60. package/dist/interfaces/cli/commands/capture.js +19 -0
  61. package/dist/interfaces/cli/commands/catalog.js +9 -0
  62. package/dist/interfaces/cli/commands/client.js +135 -0
  63. package/dist/interfaces/cli/commands/clients.js +33 -0
  64. package/dist/interfaces/cli/commands/connectors.js +14 -0
  65. package/dist/interfaces/cli/commands/context.js +9 -0
  66. package/dist/interfaces/cli/commands/cost.js +15 -0
  67. package/dist/interfaces/cli/commands/daily.js +11 -0
  68. package/dist/interfaces/cli/commands/day.js +25 -0
  69. package/dist/interfaces/cli/commands/dispatch.js +31 -0
  70. package/dist/interfaces/cli/commands/doctor.js +60 -0
  71. package/dist/interfaces/cli/commands/env.js +5 -0
  72. package/dist/interfaces/cli/commands/gateway.js +16 -0
  73. package/dist/interfaces/cli/commands/handoff.js +11 -0
  74. package/dist/interfaces/cli/commands/health.js +17 -0
  75. package/dist/interfaces/cli/commands/hook.js +142 -0
  76. package/dist/interfaces/cli/commands/idea.js +11 -0
  77. package/dist/interfaces/cli/commands/install.js +31 -0
  78. package/dist/interfaces/cli/commands/intent.js +14 -0
  79. package/dist/interfaces/cli/commands/intercept.js +22 -0
  80. package/dist/interfaces/cli/commands/layout.js +11 -0
  81. package/dist/interfaces/cli/commands/lifecycle.js +5 -0
  82. package/dist/interfaces/cli/commands/loop.js +73 -0
  83. package/dist/interfaces/cli/commands/market.js +11 -0
  84. package/dist/interfaces/cli/commands/mcp.js +57 -0
  85. package/dist/interfaces/cli/commands/memory.js +5 -0
  86. package/dist/interfaces/cli/commands/migrate.js +5 -0
  87. package/dist/interfaces/cli/commands/observe.js +11 -0
  88. package/dist/interfaces/cli/commands/obsidian.js +111 -0
  89. package/dist/interfaces/cli/commands/operate.js +7 -0
  90. package/dist/interfaces/cli/commands/policy.js +16 -0
  91. package/dist/interfaces/cli/commands/project.js +207 -0
  92. package/dist/interfaces/cli/commands/repair.js +20 -0
  93. package/dist/interfaces/cli/commands/run.js +52 -0
  94. package/dist/interfaces/cli/commands/schedule.js +58 -0
  95. package/dist/interfaces/cli/commands/service.js +21 -0
  96. package/dist/interfaces/cli/commands/session.js +182 -0
  97. package/dist/interfaces/cli/commands/sessions.js +12 -0
  98. package/dist/interfaces/cli/commands/setup.js +21 -0
  99. package/dist/interfaces/cli/commands/skill.js +159 -0
  100. package/dist/interfaces/cli/commands/tasks.js +10 -0
  101. package/dist/interfaces/cli/commands/update-remove.js +25 -0
  102. package/dist/interfaces/cli/connectors-command.js +150 -0
  103. package/dist/interfaces/cli/context-command.js +39 -3
  104. package/dist/interfaces/cli/cost-command.js +104 -0
  105. package/dist/interfaces/cli/curator-command.js +1 -1
  106. package/dist/interfaces/cli/daily-command.js +7 -1
  107. package/dist/interfaces/cli/desktop-command.js +43 -7
  108. package/dist/interfaces/cli/distill-command.js +7 -2
  109. package/dist/interfaces/cli/express-command.js +1 -1
  110. package/dist/interfaces/cli/failures-command.js +4 -4
  111. package/dist/interfaces/cli/gateway-findings.js +2 -2
  112. package/dist/interfaces/cli/governance-command.js +23 -16
  113. package/dist/interfaces/cli/handoff-command.js +1 -1
  114. package/dist/interfaces/cli/harvest-command.js +2 -2
  115. package/dist/interfaces/cli/help-command.js +53 -169
  116. package/dist/interfaces/cli/hygiene-command.js +1 -1
  117. package/dist/interfaces/cli/idea-command.js +1 -1
  118. package/dist/interfaces/cli/intercept-command.js +8 -7
  119. package/dist/interfaces/cli/interests-command.js +1 -1
  120. package/dist/interfaces/cli/layout-command.js +2 -0
  121. package/dist/interfaces/cli/market-command.js +9 -9
  122. package/dist/interfaces/cli/mcp-gateway-command.js +124 -7
  123. package/dist/interfaces/cli/mcp-probe-command.js +186 -0
  124. package/dist/interfaces/cli/mcp-status-command.js +5 -5
  125. package/dist/interfaces/cli/memory-command.js +41 -7
  126. package/dist/interfaces/cli/migrate-command.js +2 -2
  127. package/dist/interfaces/cli/note-command.js +1 -1
  128. package/dist/interfaces/cli/onboard-command.js +14 -0
  129. package/dist/interfaces/cli/operate-command.js +5 -5
  130. package/dist/interfaces/cli/profiles-command.js +61 -1
  131. package/dist/interfaces/cli/rhythm-command.js +11 -5
  132. package/dist/interfaces/cli/running-server-findings.js +1 -1
  133. package/dist/interfaces/cli/scorecard-command.js +8 -8
  134. package/dist/interfaces/cli/session-facts-command.js +2 -2
  135. package/dist/interfaces/cli/sessions-command.js +145 -0
  136. package/dist/interfaces/cli/setup-command.js +15 -2
  137. package/dist/interfaces/cli/tasks-command.js +63 -13
  138. package/dist/interfaces/cli/telemetry-command.js +4 -4
  139. package/dist/interfaces/cli/uninstall-command.js +1 -1
  140. package/dist/interfaces/cli/week-failures.js +32 -0
  141. package/dist/main.js +12 -0
  142. package/node_modules/@ocean/brain/dist/{infrastructure/brain/brain-index.js → brain-index.js} +2 -2
  143. package/node_modules/@ocean/brain/dist/{brain/brain-markdown.js → brain-markdown.js} +1 -1
  144. package/node_modules/@ocean/brain/dist/{brain/brain-service.js → brain-service.js} +12 -2
  145. package/node_modules/@ocean/brain/dist/memory/brain-dump.js +92 -16
  146. package/node_modules/@ocean/brain/dist/memory/extraction-log.js +125 -0
  147. package/node_modules/@ocean/brain/dist/memory/extraction-retry.js +54 -0
  148. package/node_modules/@ocean/brain/dist/memory/fact-routing.js +44 -1
  149. package/node_modules/@ocean/brain/dist/memory/lesson-activation.js +2 -2
  150. package/node_modules/@ocean/brain/dist/memory/lesson-learning.js +2 -2
  151. package/node_modules/@ocean/brain/dist/memory/lessons.js +1 -1
  152. package/node_modules/@ocean/brain/dist/memory/memory-audit.js +2 -2
  153. package/node_modules/@ocean/brain/dist/memory/memory-harvest.js +1 -1
  154. package/node_modules/@ocean/brain/dist/memory/memory-paths.js +8 -0
  155. package/node_modules/@ocean/brain/dist/memory/memory-review.js +31 -3
  156. package/node_modules/@ocean/brain/dist/memory/memory-trash.js +29 -0
  157. package/node_modules/@ocean/brain/dist/memory/memory-write.js +4 -2
  158. package/node_modules/@ocean/brain/dist/memory/model-narrative.js +2 -2
  159. package/node_modules/@ocean/brain/dist/memory/profile-facts.js +1 -1
  160. package/node_modules/@ocean/brain/dist/memory/routing.json +6 -6
  161. package/node_modules/@ocean/{market/dist/skills → brain/dist/memory}/signal-detection.js +1 -1
  162. package/node_modules/@ocean/brain/dist/{memory → people}/people.js +1 -1
  163. package/node_modules/@ocean/brain/dist/sessions-capture/session-facts.js +625 -0
  164. package/node_modules/@ocean/brain/dist/{memory → sessions-capture}/session-promotion.js +7 -15
  165. package/node_modules/@ocean/brain/dist/{memory → sessions-capture}/session-summary.js +1 -1
  166. package/node_modules/@ocean/brain/dist/sessions-capture/session-triage.js +52 -0
  167. package/node_modules/@ocean/brain/package.json +1 -1
  168. package/node_modules/@ocean/connect/dist/connectors/connector-hub.js +173 -0
  169. package/node_modules/@ocean/{market → connect}/dist/install/default-marketplace.js +6 -2
  170. package/node_modules/@ocean/{market → connect}/dist/install/marketplace-service.js +1 -1
  171. package/node_modules/@ocean/connect/dist/mcp/mcp-gateway.js +987 -0
  172. package/node_modules/@ocean/{market → connect}/dist/mcp/mcp-launch.js +102 -5
  173. package/node_modules/@ocean/{market → connect}/dist/registry/official-registry.js +1 -1
  174. package/node_modules/@ocean/{market → connect}/dist/security/permissions.js +1 -1
  175. package/node_modules/@ocean/{market → connect}/dist/skills/skill-hub.js +104 -6
  176. package/node_modules/@ocean/{market → connect}/package.json +2 -2
  177. package/node_modules/@ocean/context/dist/{context/context-ladder.js → context-ladder.js} +3 -3
  178. package/node_modules/@ocean/context/dist/{context/context-references.js → context-references.js} +5 -4
  179. package/node_modules/@ocean/context/dist/{context/context-cost.js → context-size.js} +6 -6
  180. package/node_modules/@ocean/context/dist/{context/intent-router.js → intent-router.js} +1 -1
  181. package/node_modules/@ocean/context/dist/{context/resource-injection.js → resource-injection.js} +3 -1
  182. package/node_modules/@ocean/context/package.json +1 -1
  183. package/node_modules/@ocean/core/dist/domain/brain/brain-record.js +1 -1
  184. package/node_modules/@ocean/core/dist/domain/capabilities/capability-manifest.js +5 -5
  185. package/node_modules/@ocean/core/dist/domain/connector-entry.js +86 -0
  186. package/node_modules/@ocean/core/dist/domain/context/context.js +1 -1
  187. package/node_modules/@ocean/core/dist/domain/context/project-id.js +8 -2
  188. package/node_modules/@ocean/core/dist/domain/{evidence/evidence.js → evidence.js} +1 -1
  189. package/node_modules/@ocean/core/dist/domain/mcp/memory-contract.js +4 -1
  190. package/node_modules/@ocean/core/dist/domain/ports/brain-index-port.js +1 -1
  191. package/node_modules/@ocean/core/dist/domain/profiles/profile-markdown.js +40 -0
  192. package/node_modules/@ocean/core/dist/domain/profiles/profile-resolution.js +276 -0
  193. package/node_modules/@ocean/core/dist/domain/profiles/profile-selection.js +23 -60
  194. package/node_modules/@ocean/core/dist/domain/profiles/profile-upgrade.js +2 -2
  195. package/node_modules/@ocean/core/dist/domain/profiles/profile.js +66 -6
  196. package/node_modules/@ocean/core/dist/domain/profiles/runtime-config.js +1 -1
  197. package/node_modules/@ocean/core/dist/domain/runs/agent-tools.js +2 -2
  198. package/node_modules/@ocean/core/dist/domain/sessions/session-identity.js +53 -0
  199. package/node_modules/@ocean/core/dist/domain/sessions/session-metadata.js +208 -0
  200. package/node_modules/@ocean/core/dist/domain/{tasks/task-id.js → task-id.js} +2 -2
  201. package/node_modules/@ocean/core/dist/profiles/profile-files.js +57 -0
  202. package/node_modules/@ocean/core/dist/profiles/profile-loader.js +97 -0
  203. package/node_modules/@ocean/core/dist/profiles/project-profile-fill.js +33 -0
  204. package/node_modules/@ocean/core/dist/profiles/session-profile.js +158 -0
  205. package/node_modules/@ocean/core/dist/shared/charter.js +110 -0
  206. package/node_modules/@ocean/core/dist/shared/context-ack.js +1 -1
  207. package/node_modules/@ocean/core/dist/shared/context-triggers.js +67 -0
  208. package/node_modules/@ocean/core/dist/shared/paths.js +6 -6
  209. package/node_modules/@ocean/core/dist/shared/project-legacy.js +232 -0
  210. package/node_modules/@ocean/core/dist/shared/project-manifest.js +308 -0
  211. package/node_modules/@ocean/core/dist/shared/project-names.js +87 -0
  212. package/node_modules/@ocean/core/dist/shared/project-register.js +560 -0
  213. package/node_modules/@ocean/core/dist/shared/project-resolution.js +83 -861
  214. package/node_modules/@ocean/core/dist/shared/repo-signals.js +45 -0
  215. package/node_modules/@ocean/core/dist/shared/task-reference.js +1 -1
  216. package/node_modules/@ocean/core/dist/shared/text-tokens.js +37 -0
  217. package/node_modules/@ocean/core/dist/shared/tool-groups.js +224 -0
  218. package/node_modules/@ocean/core/package.json +4 -1
  219. package/node_modules/@ocean/services/dist/day/day.js +45 -3
  220. package/node_modules/@ocean/services/dist/{distill → day}/distill.js +29 -3
  221. package/node_modules/@ocean/services/dist/{harvest → day}/harvest.js +54 -14
  222. package/node_modules/@ocean/services/dist/{brief → day}/interest-discovery.js +3 -3
  223. package/node_modules/@ocean/services/dist/day/note.js +2 -2
  224. package/node_modules/@ocean/services/dist/{onboarding → day}/onboarding.js +1 -1
  225. package/node_modules/@ocean/services/dist/day/patterns.js +68 -0
  226. package/node_modules/@ocean/services/dist/{curator → health}/curator.js +5 -5
  227. package/node_modules/@ocean/services/dist/{journey → health}/failures.js +7 -5
  228. package/node_modules/@ocean/services/dist/{hygiene → health}/hygiene.js +2 -2
  229. package/node_modules/@ocean/services/dist/{journey → health}/lesson-effect.js +1 -1
  230. package/node_modules/@ocean/services/dist/{scorecard → health}/scorecard.js +3 -3
  231. package/node_modules/@ocean/services/dist/{upkeep → health}/upkeep.js +2 -2
  232. package/node_modules/@ocean/services/dist/{doctor → health}/workspace-doctor.js +57 -17
  233. package/node_modules/@ocean/services/dist/{browser → integrations/browser}/browser-session.js +1 -1
  234. package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/call-ledger.js +3 -0
  235. package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/mcp-client.js +19 -3
  236. package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/obsidian-server.js +4 -4
  237. package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/ocean-server.js +423 -34
  238. package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/conflict-log.js +1 -1
  239. package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/folder-templates.js +8 -5
  240. package/node_modules/@ocean/services/dist/projects/project-doctor.js +173 -0
  241. package/node_modules/@ocean/services/dist/projects/project-snippet.js +9 -0
  242. package/node_modules/@ocean/services/dist/projects/projects-overview.js +2 -2
  243. package/node_modules/@ocean/services/package.json +1 -1
  244. package/node_modules/@ocean/{loop/dist/loops → work/dist/runs}/guard-runtime.js +3 -3
  245. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/memory-knowledge-operations.js +4 -12
  246. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/operation-contract.js +2 -2
  247. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/project-operations.js +2 -1
  248. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/task-operations.js +4 -4
  249. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/write-guard.js +1 -1
  250. package/node_modules/@ocean/{loop → work}/dist/runs/prompt-assembly.js +2 -2
  251. package/node_modules/@ocean/{loop → work}/dist/runs/run-agent.js +4 -4
  252. package/node_modules/@ocean/{loop → work}/dist/runs/tool-loop.js +4 -4
  253. package/node_modules/@ocean/work/dist/sessions/hooks/desktop-facts.js +309 -0
  254. package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/session-end-hook.js +36 -5
  255. package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/session-facts-hook.js +144 -14
  256. package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/session-start-hook.js +129 -12
  257. package/node_modules/@ocean/work/dist/sessions/hooks/start-brief.js +110 -0
  258. package/node_modules/@ocean/work/dist/sessions/hooks/unlinked-warning.js +68 -0
  259. package/node_modules/@ocean/{loop → work}/dist/sessions/session-closeout.js +4 -4
  260. package/node_modules/@ocean/{loop → work}/dist/sessions/session-projects.js +13 -3
  261. package/node_modules/@ocean/work/dist/sessions/session-relink.js +300 -0
  262. package/node_modules/@ocean/{loop → work}/dist/sessions/session-retention.js +1 -1
  263. package/node_modules/@ocean/{loop → work}/dist/tasks/list-tasks.js +7 -2
  264. package/node_modules/@ocean/{loop → work}/dist/tasks/renumber-tasks.js +4 -2
  265. package/node_modules/@ocean/{loop → work}/dist/tasks/session-task.js +2 -2
  266. package/node_modules/@ocean/{loop → work}/dist/tasks/sync-task-prs.js +77 -7
  267. package/node_modules/@ocean/work/dist/tasks/task-git.js +63 -0
  268. package/node_modules/@ocean/{loop/dist/loops → work/dist/tasks}/task-loop.js +4 -4
  269. package/node_modules/@ocean/{loop → work}/dist/tasks/verification-readiness.js +1 -1
  270. package/node_modules/@ocean/{loop → work}/dist/tasks/verify-task.js +1 -1
  271. package/node_modules/@ocean/{loop → work}/package.json +2 -2
  272. package/ocean-marketplace.json +41 -41
  273. package/package.json +12 -11
  274. package/skills/core/daily-harvest/SKILL.md +1 -1
  275. package/skills/core/ocean-memory/SKILL.md +4 -0
  276. package/skills/core/use-browser/SKILL.md +30 -7
  277. package/skills/index.json +1 -1
  278. package/templates/profiles/default.md +44 -0
  279. package/templates/profiles/developer.md +45 -0
  280. package/templates/profiles/reviewer.md +44 -0
  281. package/templates/profiles/strategist.md +44 -0
  282. package/templates/profiles-v3/analysis.md +16 -0
  283. package/templates/profiles-v3/backend.md +16 -0
  284. package/templates/profiles-v3/base.md +57 -0
  285. package/templates/profiles-v3/code-review.md +16 -0
  286. package/templates/profiles-v3/devops.md +16 -0
  287. package/templates/profiles-v3/docs-office.md +16 -0
  288. package/templates/profiles-v3/frontend.md +16 -0
  289. package/templates/profiles-v3/learning.md +16 -0
  290. package/templates/profiles-v3/marketing-ads.md +16 -0
  291. package/templates/profiles-v3/marketing-content-seo.md +16 -0
  292. package/templates/profiles-v3/ocean-ops.md +16 -0
  293. package/templates/profiles-v3/product-strategy.md +16 -0
  294. package/templates/profiles-v3/qa-testing.md +16 -0
  295. package/templates/profiles-v3/security.md +16 -0
  296. package/templates/workspace/MANIFEST.json +1 -0
  297. package/templates/workspace/charter/core.md +22 -90
  298. package/templates/workspace/charter/policies/README.md +7 -1
  299. package/templates/workspace/charter/policies/claude-code-context.md +6 -1
  300. package/templates/workspace/charter/policies/concise-output.md +5 -0
  301. package/templates/workspace/charter/policies/context.md +5 -0
  302. package/templates/workspace/charter/policies/contracts/task.md +2 -2
  303. package/templates/workspace/charter/policies/git.md +5 -0
  304. package/templates/workspace/charter/policies/graph.md +6 -1
  305. package/templates/workspace/charter/policies/knowledge.md +11 -4
  306. package/templates/workspace/charter/policies/layout.md +23 -0
  307. package/templates/workspace/charter/policies/lifecycle.md +5 -0
  308. package/templates/workspace/charter/policies/memory.md +5 -0
  309. package/templates/workspace/charter/policies/minimal-change.md +5 -0
  310. package/templates/workspace/charter/policies/models.md +5 -0
  311. package/templates/workspace/charter/policies/response.md +5 -0
  312. package/templates/workspace/charter/policies/skill-observer.md +12 -0
  313. package/templates/workspace/charter/policies/stack.md +5 -0
  314. package/templates/workspace/charter/policies/task.md +17 -3
  315. package/templates/workspace/charter/policies/verification.md +5 -0
  316. package/node_modules/@ocean/brain/dist/evidence/verification-report.js +0 -13
  317. package/node_modules/@ocean/brain/dist/memory/daily-narrative.js +0 -142
  318. package/node_modules/@ocean/brain/dist/memory/session-facts.js +0 -283
  319. package/node_modules/@ocean/context/dist/context/context-compression.js +0 -66
  320. package/node_modules/@ocean/loop/dist/hooks/desktop-facts.js +0 -174
  321. package/node_modules/@ocean/loop/dist/operations/task-linker.js +0 -40
  322. package/node_modules/@ocean/loop/dist/sessions/session-pointer.js +0 -133
  323. package/node_modules/@ocean/loop/dist/tasks/task-git.js +0 -28
  324. package/node_modules/@ocean/market/dist/mcp/mcp-gateway.js +0 -533
  325. package/templates/profiles/default.json +0 -51
  326. package/templates/profiles/developer.json +0 -51
  327. package/templates/profiles/reviewer.json +0 -51
  328. package/templates/profiles/strategist.json +0 -51
  329. /package/node_modules/@ocean/brain/dist/{brain/brain-eval.js → brain-eval.js} +0 -0
  330. /package/node_modules/@ocean/brain/dist/{brain/brain-reindex.js → brain-reindex.js} +0 -0
  331. /package/node_modules/@ocean/brain/dist/{capture → sessions-capture}/inbox-sync.js +0 -0
  332. /package/node_modules/@ocean/{market → connect}/dist/adapters/mcp-adapter.js +0 -0
  333. /package/node_modules/@ocean/{market → connect}/dist/adapters/owned-directory.js +0 -0
  334. /package/node_modules/@ocean/{market → connect}/dist/adapters/plugin-adapter.js +0 -0
  335. /package/node_modules/@ocean/{market → connect}/dist/adapters/skill-adapter.js +0 -0
  336. /package/node_modules/@ocean/{market → connect}/dist/capability/adapter.js +0 -0
  337. /package/node_modules/@ocean/{market → connect}/dist/capability/catalog.js +0 -0
  338. /package/node_modules/@ocean/{market → connect}/dist/capability/content-digest.js +0 -0
  339. /package/node_modules/@ocean/{market → connect}/dist/capability/registry.js +0 -0
  340. /package/node_modules/@ocean/{market → connect}/dist/install/lock.js +0 -0
  341. /package/node_modules/@ocean/{market → connect}/dist/install/own-server.js +0 -0
  342. /package/node_modules/@ocean/{market → connect}/dist/mcp/chrome-debugging.js +0 -0
  343. /package/node_modules/@ocean/{market → connect}/dist/mcp/mcp-connection.js +0 -0
  344. /package/node_modules/@ocean/{market → connect}/dist/mcp/mcp-runner.js +0 -0
  345. /package/node_modules/@ocean/{market → connect}/dist/security/description-scan.js +0 -0
  346. /package/node_modules/@ocean/{market → connect}/dist/security/secrets.js +0 -0
  347. /package/node_modules/@ocean/{market → connect}/dist/skills/core-skill-sync.js +0 -0
  348. /package/node_modules/@ocean/context/dist/{context/context-packet.js → context-packet.js} +0 -0
  349. /package/node_modules/@ocean/core/dist/domain/{process/process-events.js → process-events.js} +0 -0
  350. /package/node_modules/@ocean/core/dist/domain/{redaction/redaction.js → redaction.js} +0 -0
  351. /package/node_modules/@ocean/services/dist/{brief → day}/brief.js +0 -0
  352. /package/node_modules/@ocean/services/dist/{express → day}/express.js +0 -0
  353. /package/node_modules/@ocean/services/dist/{brief → day}/source-registry.json +0 -0
  354. /package/node_modules/@ocean/services/dist/{journey → health}/telemetry.js +0 -0
  355. /package/node_modules/@ocean/services/dist/{browser → integrations/browser}/browser-service.js +0 -0
  356. /package/node_modules/@ocean/services/dist/{browser → integrations/browser}/browser-task-runner.js +0 -0
  357. /package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/mcp-session.js +0 -0
  358. /package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/server-version.js +0 -0
  359. /package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/tool-registry.js +0 -0
  360. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/inbox-promotion.js +0 -0
  361. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-discovery.js +0 -0
  362. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-ingestion.js +0 -0
  363. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-sync.js +0 -0
  364. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-writer.js +0 -0
  365. /package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/operation-scope.js +0 -0
  366. /package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/record-io.js +0 -0
  367. /package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/record-operations.js +0 -0
  368. /package/node_modules/@ocean/{loop → work}/dist/runs/run-authorization.js +0 -0
  369. /package/node_modules/@ocean/{loop → work}/dist/runs/session-tokens.js +0 -0
  370. /package/node_modules/@ocean/{loop/dist/handoff → work/dist/sessions}/handoff-service.js +0 -0
  371. /package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/lifecycle-hooks.js +0 -0
  372. /package/node_modules/@ocean/{loop/dist/infrastructure/persistence → work/dist/sessions}/session-store.js +0 -0
  373. /package/node_modules/@ocean/{loop/dist/infrastructure/persistence → work/dist/sessions}/session-validator.js +0 -0
  374. /package/node_modules/@ocean/{loop → work}/dist/tasks/archive-tasks.js +0 -0
  375. /package/node_modules/@ocean/{loop → work}/dist/tasks/checkpoint-task.js +0 -0
  376. /package/node_modules/@ocean/{loop → work}/dist/tasks/claim-task.js +0 -0
  377. /package/node_modules/@ocean/{loop/dist/loops → work/dist/tasks}/iteration-graph.js +0 -0
  378. /package/node_modules/@ocean/{loop → work}/dist/tasks/new-task.js +0 -0
  379. /package/node_modules/@ocean/{loop/dist/loops → work/dist/tasks}/task-loop-record.js +0 -0
  380. /package/node_modules/@ocean/{loop → work}/dist/tasks/task-verification.js +0 -0
@@ -17,12 +17,17 @@ function connectedOf(plan) {
17
17
  return "no";
18
18
  return "partial";
19
19
  }
20
- function capturedOf(plan, native) {
20
+ // A client whose own memory is out of reach still counts as partly captured when its session
21
+ // end hook is wired, since every session then reaches Ocean (T-328 P6, Cursor).
22
+ function capturedOf(plan, native, hooks) {
21
23
  if (native) {
22
24
  if (["current", "capture", "harvest"].includes(native.status))
23
25
  return "yes";
24
26
  if (native.status === "manual")
25
27
  return "partial";
28
+ const sessionsHooked = hooks.some((hook) => hook.event === "SessionEnd" && hook.status === "current");
29
+ if (native.status === "uncaptured" && sessionsHooked)
30
+ return "partial";
26
31
  return "no";
27
32
  }
28
33
  if (plan.nativeMemory === "none")
@@ -111,7 +116,7 @@ export function buildClientStatus(input) {
111
116
  triggered = plan.tier === "supported" ? "no" : "n/a";
112
117
  }
113
118
  const native = input.native.find((item) => item.client === plan.client);
114
- const captured = capturedOf(plan, native);
119
+ const captured = capturedOf(plan, native, hooks);
115
120
  if (native?.status === "uncaptured" && native.reason)
116
121
  notes.push(native.reason);
117
122
  const watcher = input.watcher.find((item) => item.client === plan.client);
@@ -1,7 +1,7 @@
1
1
  import { timingSafeEqual } from "node:crypto";
2
2
  import { createServer, } from "node:http";
3
3
  import { actionFingerprint } from "@ocean/core/domain/mcp/mcp-contract.js";
4
- import { runAgent } from "@ocean/loop/runs/run-agent.js";
4
+ import { runAgent } from "@ocean/work/runs/run-agent.js";
5
5
  function sameSecret(expected, actual) {
6
6
  if (actual === undefined)
7
7
  return false;
@@ -10,7 +10,7 @@ import { CHARTER_DIR, oceanPath } from "@ocean/core/shared/paths.js";
10
10
  const BEGIN = "<!-- ai-sync:generated -->";
11
11
  const END = "<!-- ai-sync:end -->";
12
12
  // Relative to HOME.
13
- export const CHARTER_COPIES = [
13
+ const CHARTER_COPIES = [
14
14
  { client: "codex", file: ".codex/AGENTS.md" },
15
15
  { client: "gemini", file: ".gemini/GEMINI.md" },
16
16
  ];
@@ -5,14 +5,15 @@ import path from "node:path";
5
5
  import { atomicWrite } from "@ocean/core/shared/fs-utils.js";
6
6
  import { liveEngineEntry, oceanPath, repoRoot, SYSTEM_DIR, } from "@ocean/core/shared/paths.js";
7
7
  // Client configs that may launch Ocean by an absolute path into the kernel (an MCP server entry).
8
- // When the engine's entry moved (packages/core → packages/harness), an entry written earlier kept
8
+ // When the engine's entry moved (packages/core → packages/harness → packages/cli), an entry written earlier kept
9
9
  // the old path and the client's Ocean server failed to start without a word (T-293). Only the
10
10
  // engine entry's former locations are rewritten, and only while they no longer exist — another
11
11
  // kernel package's server that is merely not built yet is never touched; the files are otherwise
12
12
  // left byte for byte. The release build's entry (T-294, removed in T-306) is repointed to the
13
13
  // checkout even while it still exists, so no client keeps running a release.
14
- // Where the engine's `dist/main.js` lived before it moved to packages/harness.
15
- const FORMER_ENGINE_PACKAGES = ["core"];
14
+ // Where the engine's `dist/main.js` lived before it moved to packages/cli
15
+ // (`core` first, then `harness`, renamed in T-343).
16
+ const FORMER_ENGINE_PACKAGES = ["core", "harness"];
16
17
  const CLIENT_CONFIGS = [
17
18
  ".gemini/settings.json",
18
19
  ".hermes/config.yaml",
@@ -1,5 +1,5 @@
1
- import { syncCoreSkills } from "@ocean/market/skills/core-skill-sync.js";
2
- import { copyClientSkills, retireCoreFromHub, } from "@ocean/market/skills/skill-hub.js";
1
+ import { syncCoreSkills } from "@ocean/connect/skills/core-skill-sync.js";
2
+ import { copyClientSkills, retireCoreFromHub, } from "@ocean/connect/skills/skill-hub.js";
3
3
  import { buildSkillIndex } from "./skill-router.js";
4
4
  // Keeps every client's skills current with no command run: the session-start sync and
5
5
  // `ocean market install|update` call it. Hub skills (installed from the market or made there)
@@ -1,7 +1,7 @@
1
1
  import { mkdir, readdir, readFile } from "node:fs/promises";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
- import { claudeHiddenSkills, readHermesDisabled, } from "@ocean/context/context/context-cost.js";
4
+ import { claudeHiddenSkills, readHermesDisabled, } from "@ocean/context/context-size.js";
5
5
  import { atomicWrite } from "@ocean/core/shared/fs-utils.js";
6
6
  import { oceanPath, SYSTEM_DIR } from "@ocean/core/shared/paths.js";
7
7
  // The owner hides skills from Claude's model with `skillOverrides` (`off`,
@@ -1,11 +1,22 @@
1
1
  import { mkdir, readdir, readFile, stat } from "node:fs/promises";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
+ import { clientSkillRoots } from "@ocean/connect/skills/core-skill-sync.js";
5
+ import { profileCatalog, sessionProfile, } from "@ocean/core/profiles/session-profile.js";
6
+ import { policyCatalog, policyLine, routePolicies, } from "@ocean/core/shared/charter.js";
7
+ import { matchTriggers } from "@ocean/core/shared/context-triggers.js";
4
8
  import { atomicWrite } from "@ocean/core/shared/fs-utils.js";
5
9
  import { oceanPath, SYSTEM_DIR } from "@ocean/core/shared/paths.js";
6
- import { clientSkillRoots } from "@ocean/market/skills/core-skill-sync.js";
10
+ import { resolveProject } from "@ocean/core/shared/project-resolution.js";
11
+ import { projectSignals } from "@ocean/core/shared/repo-signals.js";
12
+ import { isContentWord, normalizeText, stem, tokenize, } from "@ocean/core/shared/text-tokens.js";
13
+ import { PROFILE_DEFAULT_GROUPS, TOOL_GROUPS, writeToolSelection, } from "@ocean/core/shared/tool-groups.js";
7
14
  // Below this a match is noise; tuned on the owner's installed skills (`ocean skill route`).
8
15
  export const ROUTE_THRESHOLD = 7;
16
+ // What being in the session's primary profile adds to a skill that already matched, and being
17
+ // in a profile the prompt itself triggered (T-338 P3). Neither makes a match from nothing.
18
+ const PRIMARY_BOOST = 4;
19
+ const SECONDARY_BOOST = 3;
9
20
  // A runner-up within this share of the top score counts as close (named, or ambiguous).
10
21
  const SECOND_RATIO = 0.8;
11
22
  // What a word found in only one skill is worth (≈ its raw IDF across ~150 skills).
@@ -167,39 +178,6 @@ export async function loadSkillIndex(home = os.homedir()) {
167
178
  }
168
179
  return buildSkillIndex(home);
169
180
  }
170
- const STOP_WORDS = new Set(("a an the and or but if of to in on at by for with from as is are was were be been being " +
171
- "it its this that these those i me my we our us you your he she they them their what which " +
172
- "who whom how when where why can could should would will shall do does did done doing have " +
173
- "has had not no yes so than then there here about into over under up down out any all some " +
174
- "each every more most other such only own same too very just also use used using user users " +
175
- "owner says say said ask asks asked want wants need needs please let lets get got make made " +
176
- "via per etc skill skills like one two new now way well really thing things help").split(" "));
177
- const isContentWord = (word) => word.length >= 2 && !STOP_WORDS.has(word);
178
- function normalizeText(text) {
179
- return (text
180
- .toLowerCase()
181
- .normalize("NFKC")
182
- .match(/[\p{L}\p{N}]+/gu)
183
- ?.join(" ") ?? "");
184
- }
185
- // Light suffix stripping so "writing tests" meets "write a test"; the same on both sides.
186
- function stem(word) {
187
- let out = word;
188
- if (out.length > 5 && out.endsWith("ing"))
189
- out = out.slice(0, -3);
190
- else if (out.length > 4 && out.endsWith("ed"))
191
- out = out.slice(0, -2);
192
- else if (out.length > 4 && out.endsWith("es"))
193
- out = out.slice(0, -2);
194
- else if (out.length > 3 && out.endsWith("s") && !out.endsWith("ss"))
195
- out = out.slice(0, -1);
196
- if (out.length > 3 && out.endsWith("e"))
197
- out = out.slice(0, -1);
198
- return out;
199
- }
200
- export function tokenize(text) {
201
- return normalizeText(text).split(" ").filter(isContentWord).map(stem);
202
- }
203
181
  // Message shapes that carry intent no single word does: "Zustand or Redux?" is a comparison.
204
182
  function expansions(message) {
205
183
  const words = [];
@@ -209,48 +187,6 @@ function expansions(message) {
209
187
  words.push("compare");
210
188
  return words;
211
189
  }
212
- // Words the working directory names: its package.json dependencies and its top-level file
213
- // names (`vitest.config.ts` → vitest, `graphify-out` → graphify).
214
- export async function projectSignals(cwd) {
215
- const terms = new Set();
216
- const dirs = [cwd];
217
- let current = cwd;
218
- for (let depth = 0; depth < 5; depth++) {
219
- const marker = await stat(path.join(current, "package.json")).catch(() => stat(path.join(current, ".git")).catch(() => null));
220
- if (marker) {
221
- if (current !== cwd)
222
- dirs.push(current);
223
- break;
224
- }
225
- const parent = path.dirname(current);
226
- if (parent === current)
227
- break;
228
- current = parent;
229
- }
230
- for (const dir of dirs) {
231
- try {
232
- for (const entry of await readdir(dir))
233
- terms.add(entry.toLowerCase().split(/[.\-_]/)[0]);
234
- }
235
- catch { }
236
- try {
237
- const pkg = JSON.parse(await readFile(path.join(dir, "package.json"), "utf8"));
238
- for (const deps of [pkg?.dependencies, pkg?.devDependencies])
239
- if (deps && typeof deps === "object")
240
- for (const dep of Object.keys(deps)) {
241
- const [scope, name] = dep.startsWith("@")
242
- ? dep.slice(1).split("/")
243
- : [dep, ""];
244
- terms.add(`dep:${scope.toLowerCase()}`);
245
- if (name)
246
- terms.add(`dep:${name.toLowerCase()}`);
247
- }
248
- }
249
- catch { }
250
- }
251
- terms.delete("");
252
- return terms;
253
- }
254
190
  // Whether the working directory points at this skill: a file named like it, or a dependency
255
191
  // named like it (or like its first word: `next` → next-best-practices).
256
192
  function projectHit(name, signals) {
@@ -273,8 +209,50 @@ function fileFor(skill, client) {
273
209
  return skill.files[root];
274
210
  return Object.values(skill.files)[0] ?? "";
275
211
  }
276
- // BM25 over each description (the name counts double), plus trigger-phrase hits and the
277
- // working-directory signal. Pure: the same index, message and signals give the same answer.
212
+ // The primary comes from the project, task and repository, as at session start, so it holds
213
+ // for the session; the prompt only adds secondaries. Never throws: no profiles, no boost.
214
+ async function promptProfiles(cwd, prompt) {
215
+ try {
216
+ const catalog = await profileCatalog();
217
+ const project = await resolveProject(cwd).catch(() => null);
218
+ const session = await sessionProfile({
219
+ projectId: project?.status === "bound" ? project.projectId : undefined,
220
+ cwd,
221
+ prompt,
222
+ catalog,
223
+ });
224
+ const of = (name) => catalog.profiles.find((profile) => profile.name === name);
225
+ const all = [session.primary, ...session.secondary];
226
+ return {
227
+ skills: {
228
+ primary: new Set(of(session.primary)?.skills ?? []),
229
+ secondary: new Set(session.secondary.flatMap((name) => of(name)?.skills ?? [])),
230
+ },
231
+ primary: session.primary,
232
+ secondary: session.secondary,
233
+ policies: [...new Set(all.flatMap((name) => of(name)?.policies ?? []))],
234
+ groups: [
235
+ ...new Set(all.flatMap((name) => [
236
+ ...(of(name)?.tools ?? []),
237
+ ...(PROFILE_DEFAULT_GROUPS[name] ?? []),
238
+ ])),
239
+ ],
240
+ };
241
+ }
242
+ catch {
243
+ return undefined;
244
+ }
245
+ }
246
+ // The Ocean tool groups this prompt's words open.
247
+ function promptGroups(prompt) {
248
+ if (!prompt.trim() || prompt.trimStart().startsWith("/"))
249
+ return [];
250
+ return Object.entries(TOOL_GROUPS)
251
+ .filter(([, group]) => matchTriggers(group.triggers, prompt).score > 0)
252
+ .map(([name]) => name);
253
+ }
254
+ // BM25 over each description (the name counts double), plus trigger-phrase hits, the
255
+ // working-directory signal and the session's profiles. Pure: the same index, message and signals give the same answer.
278
256
  export function routeSkills(index, message, options = {}) {
279
257
  const empty = { matches: [], candidates: [] };
280
258
  const text = message.slice(0, MESSAGE_CHARS);
@@ -308,6 +286,9 @@ export function routeSkills(index, message, options = {}) {
308
286
  const b = 0.75;
309
287
  const signals = options.signals ?? new Set();
310
288
  const scored = [];
289
+ // The profile boost each match got: a boost shared by the top skill and a runner-up must
290
+ // not make them look closer than their own words do.
291
+ const boostOf = new Map();
311
292
  for (const item of prepared) {
312
293
  let score = 0;
313
294
  const why = [];
@@ -339,6 +320,16 @@ export function routeSkills(index, message, options = {}) {
339
320
  score += 4;
340
321
  why.push("project");
341
322
  }
323
+ if (score > 0 && options.profiles?.primary.has(item.skill.name)) {
324
+ score += PRIMARY_BOOST;
325
+ boostOf.set(item.skill.name, PRIMARY_BOOST);
326
+ why.push("profile");
327
+ }
328
+ else if (score > 0 && options.profiles?.secondary.has(item.skill.name)) {
329
+ score += SECONDARY_BOOST;
330
+ boostOf.set(item.skill.name, SECONDARY_BOOST);
331
+ why.push("secondary profile");
332
+ }
342
333
  if (score <= 0)
343
334
  continue;
344
335
  scored.push({
@@ -356,9 +347,10 @@ export function routeSkills(index, message, options = {}) {
356
347
  // Close runners-up: one is named alongside the top skill; two or more mean the message is
357
348
  // generic ("write tests" with three test skills and nothing in the project to choose), so
358
349
  // nothing is named.
350
+ const shared = (item) => Math.min(boostOf.get(item.name) ?? 0, boostOf.get(top.name) ?? 0);
359
351
  const close = scored
360
352
  .slice(1)
361
- .filter((item) => item.score >= top.score * SECOND_RATIO);
353
+ .filter((item) => item.score - shared(item) >= (top.score - shared(item)) * SECOND_RATIO);
362
354
  if (close.length >= 2)
363
355
  return { matches: [], candidates };
364
356
  const matches = [top, ...close];
@@ -392,46 +384,98 @@ const HOOK_EVENT = {
392
384
  gemini: "BeforeAgent",
393
385
  };
394
386
  export const PROMPT_HOOK_CLIENTS = Object.keys(HOOK_EVENT);
387
+ // One line naming the groups this prompt opened, so a client that never re-lists still knows
388
+ // the tools exist and how to reach them.
389
+ function groupsLine(groups) {
390
+ const named = groups
391
+ .map((name) => `${name} (${TOOL_GROUPS[name]?.tools.join(", ")})`)
392
+ .join("; ");
393
+ return `Ocean tools opened: ${named}. If they are not listed, run one through ocean_call.`;
394
+ }
395
395
  // `ocean hook prompt --client <c>`: the hook payload in, the client's additional-context
396
396
  // output (or nothing) out. Never throws on a bad payload: a prompt hook must not block a prompt.
397
+ // Names at most one skill line, two policy digests and the tool groups the prompt opened, each
398
+ // once per session; writes the folder's tool selection the MCP servers follow (T-339).
397
399
  export async function skillRouterHook(payload, client, home = os.homedir()) {
398
400
  const prompt = typeof payload.prompt === "string" ? payload.prompt : "";
399
401
  if (!prompt.trim())
400
402
  return null;
401
403
  const cwd = typeof payload.cwd === "string" ? payload.cwd : process.cwd();
402
404
  const session = typeof payload.session_id === "string" ? payload.session_id : "";
403
- const index = await loadSkillIndex(home);
405
+ const [index, signals, profiles, policies] = await Promise.all([
406
+ loadSkillIndex(home),
407
+ projectSignals(cwd),
408
+ promptProfiles(cwd, prompt),
409
+ policyCatalog().catch(() => []),
410
+ ]);
404
411
  const { matches } = routeSkills(index, prompt, {
405
- signals: await projectSignals(cwd),
412
+ signals,
406
413
  client,
414
+ profiles: profiles?.skills,
407
415
  });
408
- if (!matches.length)
409
- return null;
410
416
  const state = await readState();
411
- const seen = new Set(session ? (state.sessions[session]?.skills ?? []) : []);
412
- const fresh = matches.filter((match) => !seen.has(match.name));
413
- if (!fresh.length)
417
+ const entry = session ? state.sessions[session] : undefined;
418
+ const seenSkills = new Set(entry?.skills ?? []);
419
+ // The profile's own policies arrived with the start brief; a prompt never repeats them.
420
+ const seenPolicies = new Set([
421
+ ...(entry?.policies ?? []),
422
+ ...(profiles?.policies ?? []),
423
+ ]);
424
+ const seenGroups = new Set(entry?.groups ?? []);
425
+ const fresh = matches.filter((match) => !seenSkills.has(match.name));
426
+ const policyMatches = routePolicies(policies, prompt, {
427
+ max: Number.POSITIVE_INFINITY,
428
+ })
429
+ .filter((match) => !seenPolicies.has(match.name))
430
+ .slice(0, 2);
431
+ const groups = [
432
+ ...new Set([...(profiles?.groups ?? []), ...promptGroups(prompt)]),
433
+ ];
434
+ const newGroups = groups.filter((name) => !seenGroups.has(name));
435
+ try {
436
+ await writeToolSelection(cwd, {
437
+ primary: profiles?.primary ?? "base",
438
+ secondary: profiles?.secondary ?? [],
439
+ groups,
440
+ });
441
+ }
442
+ catch { }
443
+ // Profile groups are listed from the start; only the ones this prompt's words opened are said.
444
+ const spoken = newGroups.filter((name) => !(profiles?.groups ?? []).includes(name));
445
+ if (!fresh.length && !policyMatches.length && !newGroups.length)
414
446
  return null;
415
447
  const now = Date.now();
416
- for (const [id, entry] of Object.entries(state.sessions))
417
- if (!entry || now - entry.at > SESSION_TTL_MS)
448
+ for (const [id, item] of Object.entries(state.sessions))
449
+ if (!item || now - item.at > SESSION_TTL_MS)
418
450
  delete state.sessions[id];
419
451
  if (session)
420
452
  state.sessions[session] = {
421
453
  at: now,
422
- skills: [...seen, ...fresh.map((match) => match.name)],
454
+ skills: [...seenSkills, ...fresh.map((match) => match.name)],
455
+ policies: [...seenPolicies, ...policyMatches.map((match) => match.name)],
456
+ groups: [...seenGroups, ...newGroups],
423
457
  };
424
458
  for (const match of fresh)
425
459
  state.hits[match.name] = (state.hits[match.name] ?? 0) + 1;
460
+ for (const match of policyMatches)
461
+ state.hits[`policy:${match.name}`] =
462
+ (state.hits[`policy:${match.name}`] ?? 0) + 1;
426
463
  try {
427
464
  await mkdir(path.dirname(statePath()), { recursive: true });
428
465
  await atomicWrite(statePath(), `${JSON.stringify(state, null, 2)}\n`);
429
466
  }
430
467
  catch { }
468
+ const lines = [
469
+ ...(fresh.length ? [routerLine(fresh)] : []),
470
+ ...policyMatches.map(policyLine),
471
+ ...(spoken.length ? [groupsLine(spoken)] : []),
472
+ ];
473
+ if (!lines.length)
474
+ return null;
431
475
  return {
432
476
  hookSpecificOutput: {
433
477
  hookEventName: HOOK_EVENT[client] ?? "UserPromptSubmit",
434
- additionalContext: routerLine(fresh),
478
+ additionalContext: lines.join("\n"),
435
479
  },
436
480
  };
437
481
  }
@@ -74,7 +74,7 @@ async function pointerState(pointer) {
74
74
  : readFile(pointer.target).then(sha256, () => "");
75
75
  }
76
76
  // `<p>/brain/x` → `<p>/x` and `<p>/kernel/bridge/x` → `<p>/bridge/x`, by the plan's own pattern.
77
- export function repoint(text, root, home, areas) {
77
+ function repoint(text, root, home, areas) {
78
78
  return text.replace(oldPathPattern(root, home, areas), (_, prefix, area) => area === "brain" ? prefix : `${prefix}/bridge`);
79
79
  }
80
80
  // The old areas a set of moves empties, i.e. the only ones whose paths go stale.
@@ -5,7 +5,7 @@ import { oceanRoot } from "@ocean/core/shared/paths.js";
5
5
  // The workspace template shipped in the package (T-296 §3.9): generic charter, policies,
6
6
  // templates and indexes, empty private files, and the required empty directories. Its classes
7
7
  // live in MANIFEST.json and are checked by scripts/check-template-purity.mjs.
8
- export const WORKSPACE_TEMPLATE = fileURLToPath(new URL("../../../templates/workspace/", import.meta.url));
8
+ const WORKSPACE_TEMPLATE = fileURLToPath(new URL("../../../templates/workspace/", import.meta.url));
9
9
  // Copies every template file the workspace does not have yet and creates the required
10
10
  // directories. A file that already exists is never replaced, so a rerun on a populated
11
11
  // workspace changes nothing. `.gitkeep` files are not copied: they only keep the template's
@@ -1,12 +1,13 @@
1
1
  import { writeFile } from "node:fs/promises";
2
+ import { syncCoreSkills } from "@ocean/connect/skills/core-skill-sync.js";
3
+ import { copyClientSkills } from "@ocean/connect/skills/skill-hub.js";
2
4
  import { oceanPath, PERSONAL_DIR } from "@ocean/core/shared/paths.js";
3
- import { syncCoreSkills } from "@ocean/market/skills/core-skill-sync.js";
4
- import { copyClientSkills } from "@ocean/market/skills/skill-hub.js";
5
- import { connectObsidianVault } from "@ocean/services/obsidian/vault-discovery.js";
6
- import { ONBOARDING_QUESTIONS, onboard, } from "@ocean/services/onboarding/onboarding.js";
5
+ import { ONBOARDING_QUESTIONS, onboard, } from "@ocean/services/day/onboarding.js";
6
+ import { connectObsidianVault } from "@ocean/services/integrations/obsidian/vault-discovery.js";
7
7
  import { CHAT_PLUGIN_STEPS, CHAT_SKILL_ZIP, chatPluginAdded, openChatPluginSetup, } from "../clients/chat-plugin.js";
8
8
  // Bump when a step is added; completed steps stay completed, only new ids run.
9
9
  export const ONBOARDING_VERSION = 5;
10
+ export const DETECTOR_QUESTION = " Watch for AI clients you install later and offer to connect each one? (a macOS notification; nothing is edited without your yes)";
10
11
  async function yes(io, question) {
11
12
  return (await io.ask(`${question} [Y/n] `, "y")).trim().toLowerCase() !== "n";
12
13
  }
@@ -21,9 +22,101 @@ function describeClient(plan) {
21
22
  return `unknown: ${plan.reason}`;
22
23
  return `${plan.status}: ${plan.reason}; fallback: ${plan.fallback}`;
23
24
  }
24
- // T-296 §3.7: one consolidated review of every detected client (MCP entry and session hook), one
25
- // confirmation for all of them. Without a terminal nothing is written: client configs change
26
- // only on an explicit yes.
25
+ // What each hook event does for the owner: the first two make the client call Ocean, the
26
+ // last two put what happened in a session into Ocean.
27
+ const HOOK_ROLE = {
28
+ SessionStart: {
29
+ pillar: "trigger",
30
+ does: "session-start hook loads Ocean's context",
31
+ },
32
+ UserPromptSubmit: {
33
+ pillar: "trigger",
34
+ does: "prompt hook routes each prompt to a skill",
35
+ },
36
+ SessionEnd: {
37
+ pillar: "capture",
38
+ does: "session-end hook records each finished session",
39
+ },
40
+ PreCompact: {
41
+ pillar: "capture",
42
+ does: "pre-compact hook keeps facts before a long chat is compacted",
43
+ },
44
+ };
45
+ function hookLine(hook) {
46
+ const role = HOOK_ROLE[hook.event].does;
47
+ if (hook.status === "current")
48
+ return role;
49
+ if (hook.status === "change")
50
+ return `${role} (will add in ${hook.file})`;
51
+ return `${role} (hand edit needed: ${hook.reason}${hook.snippet ? `; add ${hook.snippet}` : ""})`;
52
+ }
53
+ function nativeLine(item) {
54
+ if (item.status === "current")
55
+ return `own memory governed: ${item.setting}`;
56
+ if (item.status === "change")
57
+ return `own memory: will set ${item.setting} in ${item.file}`;
58
+ if (item.status === "manual")
59
+ return `own memory: hand edit ${item.setting} in ${item.file} (${item.reason})`;
60
+ if (item.status === "capture")
61
+ return `own memory captured: ${item.reason}`;
62
+ if (item.status === "harvest")
63
+ return `own memory harvested: ${item.reason}`;
64
+ return `own memory NOT captured (${item.reason})`;
65
+ }
66
+ function ago(ts, now = Date.now()) {
67
+ const minutes = Math.max(0, Math.round((now - Date.parse(ts)) / 60_000));
68
+ if (minutes < 60)
69
+ return `${minutes}m`;
70
+ if (minutes < 48 * 60)
71
+ return `${Math.round(minutes / 60)}h`;
72
+ return `${Math.round(minutes / 1440)}d`;
73
+ }
74
+ // T-328 P5: one card per detected client — connect → trigger → capture → live. The capture
75
+ // lines are the consent: they say what flows into Ocean before the one question that allows it.
76
+ function clientCards(plans, hooks, native, lastCalls) {
77
+ const ids = [
78
+ ...new Set([
79
+ ...plans.map((plan) => plan.client),
80
+ ...hooks.map((hook) => hook.client),
81
+ ...native.map((item) => item.client),
82
+ ]),
83
+ ];
84
+ const lines = [];
85
+ const row = (pillar, items) => items.forEach((item, index) => {
86
+ lines.push(` ${(index ? "" : pillar).padEnd(8)} ${item}`);
87
+ });
88
+ for (const id of ids) {
89
+ const plan = plans.find((item) => item.client === id);
90
+ const own = hooks.filter((hook) => hook.client === id);
91
+ const memory = native.filter((item) => item.client === id);
92
+ lines.push(` ${plan?.label ?? id}`);
93
+ row("connect", [plan ? describeClient(plan) : "n/a"]);
94
+ const triggers = own
95
+ .filter((hook) => HOOK_ROLE[hook.event].pillar === "trigger")
96
+ .map(hookLine);
97
+ if (!triggers.length && plan && ["current", "change"].includes(plan.status))
98
+ triggers.push("server instructions: the model calls Ocean when your work comes up");
99
+ row("trigger", triggers.length ? triggers : ["none"]);
100
+ const captures = [
101
+ ...own
102
+ .filter((hook) => HOOK_ROLE[hook.event].pillar === "capture")
103
+ .map(hookLine),
104
+ ...memory.map(nativeLine),
105
+ ];
106
+ if (!memory.length && plan?.nativeMemory === "none")
107
+ captures.push("it keeps no memory of its own");
108
+ row("capture", captures.length ? captures : ["nothing"]);
109
+ row("live", [
110
+ lastCalls[id]
111
+ ? `last Ocean call ${ago(lastCalls[id])} ago`
112
+ : "no Ocean call recorded yet",
113
+ ]);
114
+ }
115
+ return lines;
116
+ }
117
+ // T-296 §3.7: one consolidated review of every detected client (MCP entry, session hooks and
118
+ // native memory), one confirmation for all of them. Without a terminal nothing is written:
119
+ // client configs change only on an explicit yes.
27
120
  function connectStep(clients) {
28
121
  return {
29
122
  id: "connect",
@@ -43,46 +136,44 @@ function connectStep(clients) {
43
136
  },
44
137
  async run(io) {
45
138
  const plans = (await clients.plan()).filter((plan) => plan.installed);
46
- for (const plan of plans)
47
- io.say(` ${plan.label.padEnd(34)} ${describeClient(plan)}`);
48
- for (const plan of plans.filter((item) => item.status === "manual"))
49
- io.say(` Hand edit for ${plan.label} (${plan.file}): add ${plan.snippet}`);
50
139
  const hooks = await clients.hooks();
51
- for (const hook of hooks)
52
- io.say(` ${`${hook.client} ${hook.event} hook`.padEnd(34)} ${hook.status === "current"
53
- ? "present"
54
- : hook.status === "change"
55
- ? `will add a ${hook.event} hook in ${hook.file}`
56
- : `hand edit needed (${hook.reason})${hook.snippet ? `; add ${hook.snippet}` : ""}`}`);
57
140
  const native = await clients.native();
58
- for (const item of native)
59
- io.say(` ${`${item.client} native memory`.padEnd(34)} ${item.status === "current"
60
- ? "governed"
61
- : item.status === "change"
62
- ? `will set ${item.setting} in ${item.file}`
63
- : item.status === "manual"
64
- ? `hand edit: ${item.setting} in ${item.file} (${item.reason})`
65
- : item.status === "capture"
66
- ? `captured: ${item.reason}`
67
- : `you: ${item.reason}`}`);
141
+ io.say(" Per client: connect → trigger → capture → live. What is captured stays in ~/ocean on this machine.");
142
+ for (const line of clientCards(plans, hooks, native, (await clients.lastCalls?.()) ?? {}))
143
+ io.say(line);
144
+ for (const plan of plans.filter((item) => item.status === "manual"))
145
+ io.say(` Hand edit for ${plan.label} (${plan.file}): add ${plan.snippet}`);
68
146
  const pending = plans.filter((plan) => plan.status === "change");
69
147
  const pendingHooks = hooks.filter((hook) => hook.status === "change");
70
148
  const pendingNative = native.filter((item) => item.status === "change");
149
+ const detectorPending = (await clients.detector?.())?.some((plan) => plan.status === "change");
150
+ // Asked on its own, after the client changes, so declining it never blocks them.
151
+ const offerDetector = async (batch) => {
152
+ if (!detectorPending || !clients.applyDetector)
153
+ return;
154
+ if (!io.interactive || !(await yes(io, DETECTOR_QUESTION)))
155
+ return;
156
+ for (const { result } of await clients.applyDetector(batch))
157
+ io.say(` client detector: ${result}`);
158
+ };
71
159
  if (pending.length + pendingHooks.length + pendingNative.length === 0) {
72
160
  io.say(" Every client Ocean can wire is already connected.");
161
+ await offerDetector();
73
162
  return "done";
74
163
  }
75
164
  if (!io.interactive) {
76
165
  io.say(" Review: ocean clients plan Apply: ocean clients apply --yes");
77
166
  return "skipped";
78
167
  }
79
- if (!(await yes(io, ` Apply these changes (${pending.length} MCP entries, ${pendingHooks.length} session hooks, ${pendingNative.length} native-memory settings)?`)))
168
+ io.say(" Before each edit the whole config is saved next to it as <file>.ocean-backup-<batch>; `ocean uninstall` puts everything back.");
169
+ if (!(await yes(io, ` Apply these changes and allow the capture above (${pending.length} MCP entries, ${pendingHooks.length} session hooks, ${pendingNative.length} native-memory settings)?`)))
80
170
  return "skipped";
81
171
  const { batch, results } = await clients.apply(pending.map((plan) => plan.client));
82
172
  for (const { client, event, result } of await clients.applyHooks(batch))
83
173
  io.say(` ${client} ${event} hook: ${result}`);
84
174
  for (const { client, result } of await clients.applyNative(batch))
85
175
  io.say(` ${client} native memory: ${result}`);
176
+ await offerDetector(batch);
86
177
  io.say(` Undo with: ocean clients restore --batch ${batch}`);
87
178
  for (const { client, result } of results) {
88
179
  if (result !== "written") {
@@ -100,7 +191,7 @@ function connectStep(clients) {
100
191
  // Claude chat (Desktop, claude.ai, phone) runs no hooks and drops MCP instructions, so Ocean's
101
192
  // rule reaches it as a skill uploaded to the account (T-328). Uploading has no API: the one step
102
193
  // left to the owner is an upload and a few clicks, set up here.
103
- export function chatPluginStep(chat = {
194
+ function chatPluginStep(chat = {
104
195
  added: () => chatPluginAdded(),
105
196
  open: () => openChatPluginSetup(),
106
197
  }) {
@@ -278,7 +369,7 @@ export function buildSteps(deps) {
278
369
  },
279
370
  guided("hooks", "SessionStart auto-sync hook", [
280
371
  "Add before the exec in your session-bootstrap hook:",
281
- 'node "$HOME/ocean/kernel/packages/harness/dist/main.js" client sync >/dev/null 2>&1 &',
372
+ 'node "$HOME/ocean/kernel/packages/cli/dist/main.js" client sync >/dev/null 2>&1 &',
282
373
  ]),
283
374
  guided("service", "Background service and schedules", [
284
375
  "Run: ocean service (and ocean schedule for recurring jobs)",