@amoree-code/ocean 2.22.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (382) hide show
  1. package/README.md +46 -53
  2. package/dist/application/clients/bundles.js +220 -0
  3. package/dist/application/clients/chat-plugin.js +4 -42
  4. package/dist/application/clients/client-detect.js +291 -0
  5. package/dist/application/clients/clients.js +104 -25
  6. package/dist/application/clients/desktop-link.js +40 -0
  7. package/dist/application/clients/desktop-watcher.js +6 -4
  8. package/dist/application/clients/hook-trust.js +106 -0
  9. package/dist/application/clients/hooks.js +7 -1
  10. package/dist/application/clients/mcp-schema-cost.js +74 -0
  11. package/dist/application/clients/native.js +38 -2
  12. package/dist/application/clients/registry.js +51 -9
  13. package/dist/application/clients/status.js +7 -2
  14. package/dist/application/clients/zip.js +44 -0
  15. package/dist/application/gateway/webhook-gateway.js +1 -1
  16. package/dist/application/integrations/charter-copies.js +1 -1
  17. package/dist/application/integrations/engine-entry-repair.js +4 -3
  18. package/dist/application/integrations/skill-auto-sync.js +2 -2
  19. package/dist/application/integrations/skill-filter.js +1 -1
  20. package/dist/application/integrations/skill-router.js +134 -90
  21. package/dist/application/layout/layout-apply.js +1 -1
  22. package/dist/application/layout/workspace-template.js +1 -1
  23. package/dist/application/onboarding/steps.js +121 -30
  24. package/dist/application/profiles/profile-doctor.js +118 -0
  25. package/dist/application/profiles/profile-migration-service.js +208 -0
  26. package/dist/application/profiles/profile-suggestion.js +3 -7
  27. package/dist/application/profiles/profile-upgrade-service.js +98 -86
  28. package/dist/application/pull/history-index.js +1 -1
  29. package/dist/application/pull/project-match.js +3 -3
  30. package/dist/application/pull/pull.js +1 -1
  31. package/dist/application/pull/server-capture.js +92 -9
  32. package/dist/application/scheduler/local-scheduler.js +2 -2
  33. package/dist/application/spend/claude-prices.js +55 -0
  34. package/dist/application/spend/claude-spend.js +365 -0
  35. package/dist/application/uninstall/uninstall.js +25 -3
  36. package/dist/application/upkeep/nightly-upkeep.js +4 -4
  37. package/dist/composition/runtime.js +2 -2
  38. package/dist/infrastructure/desktop/claude-export.js +1 -1
  39. package/dist/infrastructure/desktop/desktop-chat.js +60 -13
  40. package/dist/infrastructure/desktop/indexeddb.js +4 -4
  41. package/dist/infrastructure/desktop/leveldb.js +2 -2
  42. package/dist/infrastructure/filesystem/profile-loader.js +3 -45
  43. package/dist/infrastructure/filesystem/runtime-config-loader.js +1 -1
  44. package/dist/infrastructure/observability/runtime-logger.js +1 -1
  45. package/dist/infrastructure/process/agent-tool-executor.js +3 -3
  46. package/dist/infrastructure/process/process-supervisor.js +1 -1
  47. package/dist/infrastructure/process/service.js +8 -8
  48. package/dist/infrastructure/providers/openai-compatible.js +2 -2
  49. package/dist/infrastructure/providers/provider-invocation.js +1 -1
  50. package/dist/infrastructure/providers/session-facts-completer.js +78 -5
  51. package/dist/interfaces/cli/auth-command.js +2 -2
  52. package/dist/interfaces/cli/brief-command.js +1 -1
  53. package/dist/interfaces/cli/browser-command.js +6 -6
  54. package/dist/interfaces/cli/browser-findings.js +6 -9
  55. package/dist/interfaces/cli/browser-settings.js +10 -10
  56. package/dist/interfaces/cli/capture-command.js +6 -6
  57. package/dist/interfaces/cli/client-test-command.js +3 -3
  58. package/dist/interfaces/cli/clients-command.js +55 -6
  59. package/dist/interfaces/cli/command-aliases.js +56 -0
  60. package/dist/interfaces/cli/command-registry.js +48 -1414
  61. package/dist/interfaces/cli/commands/browser.js +5 -0
  62. package/dist/interfaces/cli/commands/capture.js +19 -0
  63. package/dist/interfaces/cli/commands/catalog.js +9 -0
  64. package/dist/interfaces/cli/commands/client.js +135 -0
  65. package/dist/interfaces/cli/commands/clients.js +33 -0
  66. package/dist/interfaces/cli/commands/connectors.js +14 -0
  67. package/dist/interfaces/cli/commands/context.js +9 -0
  68. package/dist/interfaces/cli/commands/cost.js +15 -0
  69. package/dist/interfaces/cli/commands/daily.js +11 -0
  70. package/dist/interfaces/cli/commands/day.js +25 -0
  71. package/dist/interfaces/cli/commands/dispatch.js +31 -0
  72. package/dist/interfaces/cli/commands/doctor.js +60 -0
  73. package/dist/interfaces/cli/commands/env.js +5 -0
  74. package/dist/interfaces/cli/commands/gateway.js +16 -0
  75. package/dist/interfaces/cli/commands/handoff.js +11 -0
  76. package/dist/interfaces/cli/commands/health.js +17 -0
  77. package/dist/interfaces/cli/commands/hook.js +142 -0
  78. package/dist/interfaces/cli/commands/idea.js +11 -0
  79. package/dist/interfaces/cli/commands/install.js +31 -0
  80. package/dist/interfaces/cli/commands/intent.js +14 -0
  81. package/dist/interfaces/cli/commands/intercept.js +22 -0
  82. package/dist/interfaces/cli/commands/layout.js +11 -0
  83. package/dist/interfaces/cli/commands/lifecycle.js +5 -0
  84. package/dist/interfaces/cli/commands/loop.js +73 -0
  85. package/dist/interfaces/cli/commands/market.js +11 -0
  86. package/dist/interfaces/cli/commands/mcp.js +57 -0
  87. package/dist/interfaces/cli/commands/memory.js +5 -0
  88. package/dist/interfaces/cli/commands/migrate.js +5 -0
  89. package/dist/interfaces/cli/commands/observe.js +11 -0
  90. package/dist/interfaces/cli/commands/obsidian.js +111 -0
  91. package/dist/interfaces/cli/commands/operate.js +7 -0
  92. package/dist/interfaces/cli/commands/policy.js +16 -0
  93. package/dist/interfaces/cli/commands/project.js +207 -0
  94. package/dist/interfaces/cli/commands/repair.js +20 -0
  95. package/dist/interfaces/cli/commands/run.js +52 -0
  96. package/dist/interfaces/cli/commands/schedule.js +58 -0
  97. package/dist/interfaces/cli/commands/service.js +21 -0
  98. package/dist/interfaces/cli/commands/session.js +182 -0
  99. package/dist/interfaces/cli/commands/sessions.js +12 -0
  100. package/dist/interfaces/cli/commands/setup.js +21 -0
  101. package/dist/interfaces/cli/commands/skill.js +159 -0
  102. package/dist/interfaces/cli/commands/tasks.js +10 -0
  103. package/dist/interfaces/cli/commands/update-remove.js +25 -0
  104. package/dist/interfaces/cli/connectors-command.js +150 -0
  105. package/dist/interfaces/cli/context-command.js +39 -3
  106. package/dist/interfaces/cli/cost-command.js +104 -0
  107. package/dist/interfaces/cli/curator-command.js +1 -1
  108. package/dist/interfaces/cli/daily-command.js +7 -1
  109. package/dist/interfaces/cli/desktop-command.js +43 -7
  110. package/dist/interfaces/cli/distill-command.js +7 -2
  111. package/dist/interfaces/cli/express-command.js +1 -1
  112. package/dist/interfaces/cli/failures-command.js +4 -4
  113. package/dist/interfaces/cli/gateway-findings.js +2 -2
  114. package/dist/interfaces/cli/governance-command.js +23 -16
  115. package/dist/interfaces/cli/handoff-command.js +1 -1
  116. package/dist/interfaces/cli/harvest-command.js +2 -2
  117. package/dist/interfaces/cli/help-command.js +53 -169
  118. package/dist/interfaces/cli/hygiene-command.js +1 -1
  119. package/dist/interfaces/cli/idea-command.js +1 -1
  120. package/dist/interfaces/cli/intercept-command.js +8 -7
  121. package/dist/interfaces/cli/interests-command.js +1 -1
  122. package/dist/interfaces/cli/layout-command.js +2 -0
  123. package/dist/interfaces/cli/market-command.js +9 -9
  124. package/dist/interfaces/cli/mcp-gateway-command.js +124 -7
  125. package/dist/interfaces/cli/mcp-probe-command.js +186 -0
  126. package/dist/interfaces/cli/mcp-status-command.js +5 -5
  127. package/dist/interfaces/cli/memory-command.js +41 -7
  128. package/dist/interfaces/cli/migrate-command.js +2 -2
  129. package/dist/interfaces/cli/note-command.js +1 -1
  130. package/dist/interfaces/cli/onboard-command.js +14 -0
  131. package/dist/interfaces/cli/operate-command.js +5 -5
  132. package/dist/interfaces/cli/profiles-command.js +61 -1
  133. package/dist/interfaces/cli/rhythm-command.js +11 -5
  134. package/dist/interfaces/cli/running-server-findings.js +1 -1
  135. package/dist/interfaces/cli/scorecard-command.js +8 -8
  136. package/dist/interfaces/cli/session-facts-command.js +2 -2
  137. package/dist/interfaces/cli/sessions-command.js +145 -0
  138. package/dist/interfaces/cli/setup-command.js +15 -2
  139. package/dist/interfaces/cli/tasks-command.js +63 -13
  140. package/dist/interfaces/cli/telemetry-command.js +4 -4
  141. package/dist/interfaces/cli/uninstall-command.js +1 -1
  142. package/dist/interfaces/cli/week-failures.js +32 -0
  143. package/dist/main.js +12 -0
  144. package/node_modules/@ocean/brain/dist/{infrastructure/brain/brain-index.js → brain-index.js} +2 -2
  145. package/node_modules/@ocean/brain/dist/{brain/brain-markdown.js → brain-markdown.js} +1 -1
  146. package/node_modules/@ocean/brain/dist/{brain/brain-service.js → brain-service.js} +12 -2
  147. package/node_modules/@ocean/brain/dist/memory/brain-dump.js +92 -16
  148. package/node_modules/@ocean/brain/dist/memory/extraction-log.js +125 -0
  149. package/node_modules/@ocean/brain/dist/memory/extraction-retry.js +54 -0
  150. package/node_modules/@ocean/brain/dist/memory/fact-routing.js +44 -1
  151. package/node_modules/@ocean/brain/dist/memory/lesson-activation.js +2 -2
  152. package/node_modules/@ocean/brain/dist/memory/lesson-learning.js +2 -2
  153. package/node_modules/@ocean/brain/dist/memory/lessons.js +1 -1
  154. package/node_modules/@ocean/brain/dist/memory/memory-audit.js +2 -2
  155. package/node_modules/@ocean/brain/dist/memory/memory-harvest.js +1 -1
  156. package/node_modules/@ocean/brain/dist/memory/memory-paths.js +8 -0
  157. package/node_modules/@ocean/brain/dist/memory/memory-review.js +31 -3
  158. package/node_modules/@ocean/brain/dist/memory/memory-trash.js +29 -0
  159. package/node_modules/@ocean/brain/dist/memory/memory-write.js +4 -2
  160. package/node_modules/@ocean/brain/dist/memory/model-narrative.js +2 -2
  161. package/node_modules/@ocean/brain/dist/memory/profile-facts.js +1 -1
  162. package/node_modules/@ocean/brain/dist/memory/routing.json +6 -6
  163. package/node_modules/@ocean/{market/dist/skills → brain/dist/memory}/signal-detection.js +1 -1
  164. package/node_modules/@ocean/brain/dist/{memory → people}/people.js +1 -1
  165. package/node_modules/@ocean/brain/dist/sessions-capture/session-facts.js +625 -0
  166. package/node_modules/@ocean/brain/dist/{memory → sessions-capture}/session-promotion.js +7 -15
  167. package/node_modules/@ocean/brain/dist/{memory → sessions-capture}/session-summary.js +1 -1
  168. package/node_modules/@ocean/brain/dist/sessions-capture/session-triage.js +52 -0
  169. package/node_modules/@ocean/brain/package.json +1 -1
  170. package/node_modules/@ocean/connect/dist/connectors/connector-hub.js +173 -0
  171. package/node_modules/@ocean/{market → connect}/dist/install/default-marketplace.js +6 -2
  172. package/node_modules/@ocean/{market → connect}/dist/install/marketplace-service.js +1 -1
  173. package/node_modules/@ocean/connect/dist/mcp/mcp-gateway.js +987 -0
  174. package/node_modules/@ocean/{market → connect}/dist/mcp/mcp-launch.js +102 -5
  175. package/node_modules/@ocean/{market → connect}/dist/registry/official-registry.js +1 -1
  176. package/node_modules/@ocean/{market → connect}/dist/security/permissions.js +1 -1
  177. package/node_modules/@ocean/{market → connect}/dist/skills/skill-hub.js +104 -6
  178. package/node_modules/@ocean/{market → connect}/package.json +2 -2
  179. package/node_modules/@ocean/context/dist/{context/context-ladder.js → context-ladder.js} +3 -3
  180. package/node_modules/@ocean/context/dist/{context/context-references.js → context-references.js} +5 -4
  181. package/node_modules/@ocean/context/dist/{context/context-cost.js → context-size.js} +6 -6
  182. package/node_modules/@ocean/context/dist/{context/intent-router.js → intent-router.js} +1 -1
  183. package/node_modules/@ocean/context/dist/{context/resource-injection.js → resource-injection.js} +3 -1
  184. package/node_modules/@ocean/context/package.json +1 -1
  185. package/node_modules/@ocean/core/dist/domain/brain/brain-record.js +1 -1
  186. package/node_modules/@ocean/core/dist/domain/capabilities/capability-manifest.js +5 -5
  187. package/node_modules/@ocean/core/dist/domain/connector-entry.js +86 -0
  188. package/node_modules/@ocean/core/dist/domain/context/context.js +1 -1
  189. package/node_modules/@ocean/core/dist/domain/context/project-id.js +8 -2
  190. package/node_modules/@ocean/core/dist/domain/{evidence/evidence.js → evidence.js} +1 -1
  191. package/node_modules/@ocean/core/dist/domain/mcp/memory-contract.js +4 -1
  192. package/node_modules/@ocean/core/dist/domain/ports/brain-index-port.js +1 -1
  193. package/node_modules/@ocean/core/dist/domain/profiles/profile-markdown.js +40 -0
  194. package/node_modules/@ocean/core/dist/domain/profiles/profile-resolution.js +276 -0
  195. package/node_modules/@ocean/core/dist/domain/profiles/profile-selection.js +23 -60
  196. package/node_modules/@ocean/core/dist/domain/profiles/profile-upgrade.js +2 -2
  197. package/node_modules/@ocean/core/dist/domain/profiles/profile.js +66 -6
  198. package/node_modules/@ocean/core/dist/domain/profiles/runtime-config.js +1 -1
  199. package/node_modules/@ocean/core/dist/domain/runs/agent-tools.js +2 -2
  200. package/node_modules/@ocean/core/dist/domain/sessions/session-identity.js +53 -0
  201. package/node_modules/@ocean/core/dist/domain/sessions/session-metadata.js +208 -0
  202. package/node_modules/@ocean/core/dist/domain/{tasks/task-id.js → task-id.js} +2 -2
  203. package/node_modules/@ocean/core/dist/profiles/profile-files.js +57 -0
  204. package/node_modules/@ocean/core/dist/profiles/profile-loader.js +97 -0
  205. package/node_modules/@ocean/core/dist/profiles/project-profile-fill.js +33 -0
  206. package/node_modules/@ocean/core/dist/profiles/session-profile.js +158 -0
  207. package/node_modules/@ocean/core/dist/shared/charter.js +110 -0
  208. package/node_modules/@ocean/core/dist/shared/context-ack.js +1 -1
  209. package/node_modules/@ocean/core/dist/shared/context-triggers.js +67 -0
  210. package/node_modules/@ocean/core/dist/shared/paths.js +6 -6
  211. package/node_modules/@ocean/core/dist/shared/project-legacy.js +232 -0
  212. package/node_modules/@ocean/core/dist/shared/project-manifest.js +308 -0
  213. package/node_modules/@ocean/core/dist/shared/project-names.js +87 -0
  214. package/node_modules/@ocean/core/dist/shared/project-register.js +560 -0
  215. package/node_modules/@ocean/core/dist/shared/project-resolution.js +83 -861
  216. package/node_modules/@ocean/core/dist/shared/repo-signals.js +45 -0
  217. package/node_modules/@ocean/core/dist/shared/task-reference.js +1 -1
  218. package/node_modules/@ocean/core/dist/shared/text-tokens.js +37 -0
  219. package/node_modules/@ocean/core/dist/shared/tool-groups.js +224 -0
  220. package/node_modules/@ocean/core/package.json +4 -1
  221. package/node_modules/@ocean/services/dist/day/day.js +45 -3
  222. package/node_modules/@ocean/services/dist/{distill → day}/distill.js +29 -3
  223. package/node_modules/@ocean/services/dist/{harvest → day}/harvest.js +54 -14
  224. package/node_modules/@ocean/services/dist/{brief → day}/interest-discovery.js +3 -3
  225. package/node_modules/@ocean/services/dist/day/note.js +2 -2
  226. package/node_modules/@ocean/services/dist/{onboarding → day}/onboarding.js +1 -1
  227. package/node_modules/@ocean/services/dist/day/patterns.js +68 -0
  228. package/node_modules/@ocean/services/dist/{curator → health}/curator.js +5 -5
  229. package/node_modules/@ocean/services/dist/{journey → health}/failures.js +7 -5
  230. package/node_modules/@ocean/services/dist/{hygiene → health}/hygiene.js +2 -2
  231. package/node_modules/@ocean/services/dist/{journey → health}/lesson-effect.js +1 -1
  232. package/node_modules/@ocean/services/dist/{scorecard → health}/scorecard.js +3 -3
  233. package/node_modules/@ocean/services/dist/{upkeep → health}/upkeep.js +2 -2
  234. package/node_modules/@ocean/services/dist/{doctor → health}/workspace-doctor.js +57 -17
  235. package/node_modules/@ocean/services/dist/{browser → integrations/browser}/browser-session.js +1 -1
  236. package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/call-ledger.js +3 -0
  237. package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/mcp-client.js +19 -3
  238. package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/obsidian-server.js +4 -4
  239. package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/ocean-server.js +423 -34
  240. package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/conflict-log.js +1 -1
  241. package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/folder-templates.js +8 -5
  242. package/node_modules/@ocean/services/dist/projects/project-doctor.js +173 -0
  243. package/node_modules/@ocean/services/dist/projects/project-snippet.js +9 -0
  244. package/node_modules/@ocean/services/dist/projects/projects-overview.js +2 -2
  245. package/node_modules/@ocean/services/package.json +1 -1
  246. package/node_modules/@ocean/{loop/dist/loops → work/dist/runs}/guard-runtime.js +3 -3
  247. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/memory-knowledge-operations.js +4 -12
  248. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/operation-contract.js +2 -2
  249. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/project-operations.js +2 -1
  250. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/task-operations.js +4 -4
  251. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/write-guard.js +1 -1
  252. package/node_modules/@ocean/{loop → work}/dist/runs/prompt-assembly.js +2 -2
  253. package/node_modules/@ocean/{loop → work}/dist/runs/run-agent.js +4 -4
  254. package/node_modules/@ocean/{loop → work}/dist/runs/tool-loop.js +4 -4
  255. package/node_modules/@ocean/work/dist/sessions/hooks/desktop-facts.js +309 -0
  256. package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/session-end-hook.js +36 -5
  257. package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/session-facts-hook.js +144 -14
  258. package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/session-start-hook.js +129 -12
  259. package/node_modules/@ocean/work/dist/sessions/hooks/start-brief.js +110 -0
  260. package/node_modules/@ocean/work/dist/sessions/hooks/unlinked-warning.js +68 -0
  261. package/node_modules/@ocean/{loop → work}/dist/sessions/session-closeout.js +4 -4
  262. package/node_modules/@ocean/{loop → work}/dist/sessions/session-projects.js +13 -3
  263. package/node_modules/@ocean/work/dist/sessions/session-relink.js +300 -0
  264. package/node_modules/@ocean/{loop → work}/dist/sessions/session-retention.js +1 -1
  265. package/node_modules/@ocean/{loop → work}/dist/tasks/list-tasks.js +7 -2
  266. package/node_modules/@ocean/{loop → work}/dist/tasks/renumber-tasks.js +4 -2
  267. package/node_modules/@ocean/{loop → work}/dist/tasks/session-task.js +2 -2
  268. package/node_modules/@ocean/{loop → work}/dist/tasks/sync-task-prs.js +77 -7
  269. package/node_modules/@ocean/work/dist/tasks/task-git.js +63 -0
  270. package/node_modules/@ocean/{loop/dist/loops → work/dist/tasks}/task-loop.js +4 -4
  271. package/node_modules/@ocean/{loop → work}/dist/tasks/verification-readiness.js +1 -1
  272. package/node_modules/@ocean/{loop → work}/dist/tasks/verify-task.js +1 -1
  273. package/node_modules/@ocean/{loop → work}/package.json +2 -2
  274. package/ocean-marketplace.json +41 -41
  275. package/package.json +12 -11
  276. package/skills/core/daily-harvest/SKILL.md +1 -1
  277. package/skills/core/ocean-memory/SKILL.md +4 -0
  278. package/skills/core/use-browser/SKILL.md +30 -7
  279. package/skills/index.json +1 -1
  280. package/templates/profiles/default.md +44 -0
  281. package/templates/profiles/developer.md +45 -0
  282. package/templates/profiles/reviewer.md +44 -0
  283. package/templates/profiles/strategist.md +44 -0
  284. package/templates/profiles-v3/analysis.md +16 -0
  285. package/templates/profiles-v3/backend.md +16 -0
  286. package/templates/profiles-v3/base.md +57 -0
  287. package/templates/profiles-v3/code-review.md +16 -0
  288. package/templates/profiles-v3/devops.md +16 -0
  289. package/templates/profiles-v3/docs-office.md +16 -0
  290. package/templates/profiles-v3/frontend.md +16 -0
  291. package/templates/profiles-v3/learning.md +16 -0
  292. package/templates/profiles-v3/marketing-ads.md +16 -0
  293. package/templates/profiles-v3/marketing-content-seo.md +16 -0
  294. package/templates/profiles-v3/ocean-ops.md +16 -0
  295. package/templates/profiles-v3/product-strategy.md +16 -0
  296. package/templates/profiles-v3/qa-testing.md +16 -0
  297. package/templates/profiles-v3/security.md +16 -0
  298. package/templates/workspace/MANIFEST.json +1 -0
  299. package/templates/workspace/charter/core.md +22 -90
  300. package/templates/workspace/charter/policies/README.md +7 -1
  301. package/templates/workspace/charter/policies/claude-code-context.md +6 -1
  302. package/templates/workspace/charter/policies/concise-output.md +5 -0
  303. package/templates/workspace/charter/policies/context.md +5 -0
  304. package/templates/workspace/charter/policies/contracts/task.md +2 -2
  305. package/templates/workspace/charter/policies/git.md +5 -0
  306. package/templates/workspace/charter/policies/graph.md +6 -1
  307. package/templates/workspace/charter/policies/knowledge.md +11 -4
  308. package/templates/workspace/charter/policies/layout.md +23 -0
  309. package/templates/workspace/charter/policies/lifecycle.md +5 -0
  310. package/templates/workspace/charter/policies/memory.md +5 -0
  311. package/templates/workspace/charter/policies/minimal-change.md +5 -0
  312. package/templates/workspace/charter/policies/models.md +5 -0
  313. package/templates/workspace/charter/policies/response.md +5 -0
  314. package/templates/workspace/charter/policies/skill-observer.md +12 -0
  315. package/templates/workspace/charter/policies/stack.md +5 -0
  316. package/templates/workspace/charter/policies/task.md +17 -3
  317. package/templates/workspace/charter/policies/verification.md +5 -0
  318. package/node_modules/@ocean/brain/dist/evidence/verification-report.js +0 -13
  319. package/node_modules/@ocean/brain/dist/memory/daily-narrative.js +0 -142
  320. package/node_modules/@ocean/brain/dist/memory/session-facts.js +0 -283
  321. package/node_modules/@ocean/context/dist/context/context-compression.js +0 -66
  322. package/node_modules/@ocean/loop/dist/hooks/desktop-facts.js +0 -174
  323. package/node_modules/@ocean/loop/dist/operations/task-linker.js +0 -40
  324. package/node_modules/@ocean/loop/dist/sessions/session-pointer.js +0 -133
  325. package/node_modules/@ocean/loop/dist/tasks/task-git.js +0 -28
  326. package/node_modules/@ocean/market/dist/mcp/mcp-gateway.js +0 -533
  327. package/templates/profiles/default.json +0 -51
  328. package/templates/profiles/developer.json +0 -51
  329. package/templates/profiles/reviewer.json +0 -51
  330. package/templates/profiles/strategist.json +0 -51
  331. /package/node_modules/@ocean/brain/dist/{brain/brain-eval.js → brain-eval.js} +0 -0
  332. /package/node_modules/@ocean/brain/dist/{brain/brain-reindex.js → brain-reindex.js} +0 -0
  333. /package/node_modules/@ocean/brain/dist/{capture → sessions-capture}/inbox-sync.js +0 -0
  334. /package/node_modules/@ocean/{market → connect}/dist/adapters/mcp-adapter.js +0 -0
  335. /package/node_modules/@ocean/{market → connect}/dist/adapters/owned-directory.js +0 -0
  336. /package/node_modules/@ocean/{market → connect}/dist/adapters/plugin-adapter.js +0 -0
  337. /package/node_modules/@ocean/{market → connect}/dist/adapters/skill-adapter.js +0 -0
  338. /package/node_modules/@ocean/{market → connect}/dist/capability/adapter.js +0 -0
  339. /package/node_modules/@ocean/{market → connect}/dist/capability/catalog.js +0 -0
  340. /package/node_modules/@ocean/{market → connect}/dist/capability/content-digest.js +0 -0
  341. /package/node_modules/@ocean/{market → connect}/dist/capability/registry.js +0 -0
  342. /package/node_modules/@ocean/{market → connect}/dist/install/lock.js +0 -0
  343. /package/node_modules/@ocean/{market → connect}/dist/install/own-server.js +0 -0
  344. /package/node_modules/@ocean/{market → connect}/dist/mcp/chrome-debugging.js +0 -0
  345. /package/node_modules/@ocean/{market → connect}/dist/mcp/mcp-connection.js +0 -0
  346. /package/node_modules/@ocean/{market → connect}/dist/mcp/mcp-runner.js +0 -0
  347. /package/node_modules/@ocean/{market → connect}/dist/security/description-scan.js +0 -0
  348. /package/node_modules/@ocean/{market → connect}/dist/security/secrets.js +0 -0
  349. /package/node_modules/@ocean/{market → connect}/dist/skills/core-skill-sync.js +0 -0
  350. /package/node_modules/@ocean/context/dist/{context/context-packet.js → context-packet.js} +0 -0
  351. /package/node_modules/@ocean/core/dist/domain/{process/process-events.js → process-events.js} +0 -0
  352. /package/node_modules/@ocean/core/dist/domain/{redaction/redaction.js → redaction.js} +0 -0
  353. /package/node_modules/@ocean/services/dist/{brief → day}/brief.js +0 -0
  354. /package/node_modules/@ocean/services/dist/{express → day}/express.js +0 -0
  355. /package/node_modules/@ocean/services/dist/{brief → day}/source-registry.json +0 -0
  356. /package/node_modules/@ocean/services/dist/{journey → health}/telemetry.js +0 -0
  357. /package/node_modules/@ocean/services/dist/{browser → integrations/browser}/browser-service.js +0 -0
  358. /package/node_modules/@ocean/services/dist/{browser → integrations/browser}/browser-task-runner.js +0 -0
  359. /package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/mcp-session.js +0 -0
  360. /package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/server-version.js +0 -0
  361. /package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/tool-registry.js +0 -0
  362. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/inbox-promotion.js +0 -0
  363. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-discovery.js +0 -0
  364. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-ingestion.js +0 -0
  365. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-sync.js +0 -0
  366. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-writer.js +0 -0
  367. /package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/operation-scope.js +0 -0
  368. /package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/record-io.js +0 -0
  369. /package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/record-operations.js +0 -0
  370. /package/node_modules/@ocean/{loop → work}/dist/runs/run-authorization.js +0 -0
  371. /package/node_modules/@ocean/{loop → work}/dist/runs/session-tokens.js +0 -0
  372. /package/node_modules/@ocean/{loop/dist/handoff → work/dist/sessions}/handoff-service.js +0 -0
  373. /package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/lifecycle-hooks.js +0 -0
  374. /package/node_modules/@ocean/{loop/dist/infrastructure/persistence → work/dist/sessions}/session-store.js +0 -0
  375. /package/node_modules/@ocean/{loop/dist/infrastructure/persistence → work/dist/sessions}/session-validator.js +0 -0
  376. /package/node_modules/@ocean/{loop → work}/dist/tasks/archive-tasks.js +0 -0
  377. /package/node_modules/@ocean/{loop → work}/dist/tasks/checkpoint-task.js +0 -0
  378. /package/node_modules/@ocean/{loop → work}/dist/tasks/claim-task.js +0 -0
  379. /package/node_modules/@ocean/{loop/dist/loops → work/dist/tasks}/iteration-graph.js +0 -0
  380. /package/node_modules/@ocean/{loop → work}/dist/tasks/new-task.js +0 -0
  381. /package/node_modules/@ocean/{loop/dist/loops → work/dist/tasks}/task-loop-record.js +0 -0
  382. /package/node_modules/@ocean/{loop → work}/dist/tasks/task-verification.js +0 -0
@@ -0,0 +1,125 @@
1
+ import { appendFile, mkdir, readFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { localDate } from "@ocean/core/shared/local-date.js";
4
+ import { oceanPath, SYSTEM_DIR } from "@ocean/core/shared/paths.js";
5
+ export function extractionLogFile() {
6
+ return oceanPath(SYSTEM_DIR, "state", "extraction-log.jsonl");
7
+ }
8
+ const OUTCOMES = new Set(["ok", "failed", "repeat"]);
9
+ function isEntry(value) {
10
+ if (!value || typeof value !== "object")
11
+ return false;
12
+ const entry = value;
13
+ return (typeof entry.at === "string" &&
14
+ typeof entry.hash === "string" &&
15
+ typeof entry.input_chars === "number" &&
16
+ typeof entry.ms === "number" &&
17
+ OUTCOMES.has(entry.outcome));
18
+ }
19
+ // Every readable line; a torn or foreign line is skipped, never fatal.
20
+ export async function readExtractionLog() {
21
+ let text;
22
+ try {
23
+ text = await readFile(extractionLogFile(), "utf8");
24
+ }
25
+ catch {
26
+ return [];
27
+ }
28
+ const entries = [];
29
+ for (const line of text.split("\n")) {
30
+ if (!line.trim())
31
+ continue;
32
+ try {
33
+ const value = JSON.parse(line);
34
+ if (isEntry(value))
35
+ entries.push(value);
36
+ }
37
+ catch {
38
+ // skipped
39
+ }
40
+ }
41
+ return entries;
42
+ }
43
+ export async function appendExtractionLog(entry) {
44
+ const file = extractionLogFile();
45
+ await mkdir(path.dirname(file), { recursive: true, mode: 0o700 });
46
+ await appendFile(file, `${JSON.stringify(entry)}\n`, { mode: 0o600 });
47
+ }
48
+ // Whether these exact turns were already extracted with a readable answer.
49
+ export async function extractedBefore(hash) {
50
+ return (await readExtractionLog()).some((entry) => entry.hash === hash && entry.outcome === "ok");
51
+ }
52
+ // The Monday that starts the local week a date falls in.
53
+ function weekOf(date) {
54
+ const monday = new Date(date);
55
+ monday.setDate(monday.getDate() - ((monday.getDay() + 6) % 7));
56
+ return localDate(monday);
57
+ }
58
+ const emptyRow = (period) => ({
59
+ period,
60
+ calls: 0,
61
+ failed: 0,
62
+ repeats: 0,
63
+ input_chars: 0,
64
+ est_tokens: 0,
65
+ output_tokens: 0,
66
+ measured: 0,
67
+ ms: 0,
68
+ });
69
+ const n = (value) => (typeof value === "number" ? value : 0);
70
+ // Input tokens a line reported, or null when it reported none.
71
+ function reportedInput(entry) {
72
+ if (entry.input_tokens === undefined)
73
+ return null;
74
+ return (n(entry.input_tokens) +
75
+ n(entry.cache_read_tokens) +
76
+ n(entry.cache_write_tokens));
77
+ }
78
+ function add(row, entry) {
79
+ if (entry.outcome === "repeat") {
80
+ row.repeats += 1;
81
+ return;
82
+ }
83
+ row.calls += 1;
84
+ if (entry.outcome === "failed")
85
+ row.failed += 1;
86
+ row.input_chars += entry.input_chars;
87
+ const reported = reportedInput(entry);
88
+ if (reported === null)
89
+ row.est_tokens += Math.ceil(entry.input_chars / 4);
90
+ else {
91
+ row.est_tokens += reported;
92
+ row.output_tokens += n(entry.output_tokens);
93
+ row.measured += 1;
94
+ }
95
+ row.ms += entry.ms;
96
+ }
97
+ // The last `days` local days and `weeks` local weeks, newest first, each listed even when empty.
98
+ export function summarizeCost(entries, options = {}) {
99
+ const now = options.now ?? new Date();
100
+ const days = new Map();
101
+ for (let i = 0; i < (options.days ?? 7); i++) {
102
+ const day = new Date(now);
103
+ day.setDate(day.getDate() - i);
104
+ days.set(localDate(day), emptyRow(localDate(day)));
105
+ }
106
+ const weeks = new Map();
107
+ for (let i = 0; i < (options.weeks ?? 4); i++) {
108
+ const week = new Date(now);
109
+ week.setDate(week.getDate() - 7 * i);
110
+ weeks.set(weekOf(week), emptyRow(weekOf(week)));
111
+ }
112
+ for (const entry of entries) {
113
+ const at = new Date(entry.at);
114
+ if (Number.isNaN(at.getTime()))
115
+ continue;
116
+ const day = days.get(localDate(at));
117
+ if (day)
118
+ add(day, entry);
119
+ const week = weeks.get(weekOf(at));
120
+ if (week)
121
+ add(week, entry);
122
+ }
123
+ return { days: [...days.values()], weeks: [...weeks.values()] };
124
+ }
125
+ //# sourceMappingURL=extraction-log.js.map
@@ -0,0 +1,54 @@
1
+ import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { oceanPath, SYSTEM_DIR } from "@ocean/core/shared/paths.js";
4
+ export const BACKOFF_MS = [60 * 60_000, 6 * 60 * 60_000, 24 * 60 * 60_000];
5
+ export const MAX_FAILURES = BACKOFF_MS.length;
6
+ const PAUSE_MS = 30 * 60_000;
7
+ export function retryGate(retry, key, now) {
8
+ if (!retry || retry.key !== key)
9
+ return "go";
10
+ if (retry.failures >= MAX_FAILURES)
11
+ return "parked";
12
+ return now < Date.parse(retry.nextAt) ? "wait" : "go";
13
+ }
14
+ export function bumpRetry(prev, key, reason, now) {
15
+ const failures = prev && prev.key === key ? prev.failures + 1 : 1;
16
+ const wait = BACKOFF_MS[Math.min(failures, BACKOFF_MS.length) - 1];
17
+ return {
18
+ failures,
19
+ nextAt: new Date(now + wait).toISOString(),
20
+ reason,
21
+ key,
22
+ };
23
+ }
24
+ function extractionPauseFile() {
25
+ return oceanPath(SYSTEM_DIR, "state", "memory", "extraction-pause.json");
26
+ }
27
+ // The active pause, or null when there is none or it has run out.
28
+ export async function readExtractionPause(now = Date.now()) {
29
+ try {
30
+ const parsed = JSON.parse(await readFile(extractionPauseFile(), "utf8"));
31
+ if (typeof parsed?.until === "string" &&
32
+ typeof parsed?.reason === "string" &&
33
+ Date.parse(parsed.until) > now)
34
+ return parsed;
35
+ }
36
+ catch {
37
+ // no pause file, or unreadable: no pause
38
+ }
39
+ return null;
40
+ }
41
+ export async function setExtractionPause(reason, now = Date.now()) {
42
+ const pause = {
43
+ until: new Date(now + PAUSE_MS).toISOString(),
44
+ reason,
45
+ };
46
+ const file = extractionPauseFile();
47
+ await mkdir(path.dirname(file), { recursive: true, mode: 0o700 });
48
+ await writeFile(file, `${JSON.stringify(pause)}\n`, { mode: 0o600 });
49
+ return pause;
50
+ }
51
+ export async function clearExtractionPause() {
52
+ await rm(extractionPauseFile(), { force: true });
53
+ }
54
+ //# sourceMappingURL=extraction-retry.js.map
@@ -1,5 +1,6 @@
1
1
  import { projectDir } from "@ocean/core/shared/paths.js";
2
- import { findProject, projectSlug, } from "@ocean/core/shared/project-resolution.js";
2
+ import { projectAliases, projectSlug, scanProjectManifests, } from "@ocean/core/shared/project-manifest.js";
3
+ import { findProject } from "@ocean/core/shared/project-register.js";
3
4
  import { permanentRecord } from "./memory-paths.js";
4
5
  import routing from "./routing.json" with { type: "json" };
5
6
  // Where a fact lives, decided by one table (T-314): the model names a fact's type, code turns it
@@ -51,4 +52,46 @@ export function inTypeLocation(relative, type) {
51
52
  return true;
52
53
  return relative.startsWith(folder);
53
54
  }
55
+ export const MAX_PROJECT_LIST_BYTES = 1024;
56
+ export async function projectScope(projectId) {
57
+ if (projectId)
58
+ return { kind: "bound", project: projectId };
59
+ const { manifests } = await scanProjectManifests();
60
+ return {
61
+ kind: "list",
62
+ projects: manifests.map((manifest) => {
63
+ let aliases = [];
64
+ try {
65
+ aliases = projectAliases(manifest);
66
+ }
67
+ catch {
68
+ // a malformed alias list only drops the aliases
69
+ }
70
+ return { id: manifest.id, aliases };
71
+ }),
72
+ };
73
+ }
74
+ // The list as the prompt carries it, "id (alias, alias); id", cut at whole entries to stay
75
+ // within MAX_PROJECT_LIST_BYTES.
76
+ export function projectListLine(projects) {
77
+ let line = "";
78
+ for (const project of projects) {
79
+ const entry = project.aliases.length
80
+ ? `${project.id} (${project.aliases.join(", ")})`
81
+ : project.id;
82
+ const next = line ? `${line}; ${entry}` : entry;
83
+ if (Buffer.byteLength(next) > MAX_PROJECT_LIST_BYTES)
84
+ break;
85
+ line = next;
86
+ }
87
+ return line;
88
+ }
89
+ // The project id a model's answer names within a list scope: an id or an alias, any case.
90
+ export function listedProject(projects, answer) {
91
+ const name = answer.trim().toLowerCase();
92
+ if (!name)
93
+ return undefined;
94
+ return projects.find((project) => project.id.toLowerCase() === name ||
95
+ project.aliases.some((alias) => alias.toLowerCase() === name))?.id;
96
+ }
54
97
  //# sourceMappingURL=fact-routing.js.map
@@ -1,10 +1,10 @@
1
1
  import { truncateUtf8 } from "@ocean/core/shared/fs-utils.js";
2
- import { brainSearch } from "../brain/brain-service.js";
2
+ import { brainSearch } from "../brain-service.js";
3
3
  import { effectiveConfidence, readLesson } from "./lessons.js";
4
4
  // Which lessons a run starts with (T-230 P3). Candidates come from the brain index, not a
5
5
  // substring match on the lesson's name; the lesson file then has the last word, so a lesson
6
6
  // retired or decayed since the index was built never activates.
7
- export const MIN_ACTIVE_CONFIDENCE = 0.2;
7
+ const MIN_ACTIVE_CONFIDENCE = 0.2;
8
8
  const LESSONS_PATH_PREFIX = "knowledge/lessons/";
9
9
  const MAX_QUERY_TOKENS = 8;
10
10
  const HITS_PER_TOKEN = 5;
@@ -1,14 +1,14 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { safeJsonParse } from "@ocean/core/shared/fs-utils.js";
3
- import { detectSessionSignals, hasUserCorrection, } from "@ocean/market/skills/signal-detection.js";
4
3
  import { addLesson, confirmLesson, contradictLesson, LessonRejectedError, readLesson, setLessonStatus, } from "./lessons.js";
4
+ import { detectSessionSignals, hasUserCorrection, } from "./signal-detection.js";
5
5
  // What a closed session teaches the lessons store (T-230 P2). Scoring reads only signals a
6
6
  // session recorded itself — its exit, its evidence events — never the model's own claims.
7
7
  export const PROMOTION_HITS = 3;
8
8
  const MAX_NEW_LESSONS = 4;
9
9
  // Evidence that checked an outcome (T-320): a task's verify commands, or a test run. A provider
10
10
  // exiting 0 says the CLI finished, not that the work is right, so `provider_exit` never proves.
11
- export const PROVING_EVIDENCE_TYPES = new Set([
11
+ const PROVING_EVIDENCE_TYPES = new Set([
12
12
  "task_verify",
13
13
  "test",
14
14
  ]);
@@ -3,7 +3,7 @@ import { mkdir, readdir, readFile, rename } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { atomicWrite, parseFrontmatter, withFileLock, } from "@ocean/core/shared/fs-utils.js";
5
5
  import { KNOWLEDGE_DIR, oceanPath, SYSTEM_DIR, } from "@ocean/core/shared/paths.js";
6
- export const LESSON_HALF_LIFE_DAYS = 30;
6
+ const LESSON_HALF_LIFE_DAYS = 30;
7
7
  const CONFIRM_STEP = 0.1;
8
8
  const CONTRADICT_FACTOR = 0.5;
9
9
  const RETIRE_BELOW = 0.1;
@@ -4,7 +4,7 @@ import path from "node:path";
4
4
  import { atomicWrite, withFileLock } from "@ocean/core/shared/fs-utils.js";
5
5
  import { oceanEnv, oceanPath, SYSTEM_DIR } from "@ocean/core/shared/paths.js";
6
6
  import { auditFile } from "./memory-paths.js";
7
- export const DEFAULT_RETENTION_DAYS = 90;
7
+ const DEFAULT_RETENTION_DAYS = 90;
8
8
  export function sha256(content) {
9
9
  return createHash("sha256").update(content).digest("hex");
10
10
  }
@@ -70,7 +70,7 @@ export async function readAudit() {
70
70
  .filter(Boolean)
71
71
  .map((line) => JSON.parse(line));
72
72
  }
73
- export function auditClient(entry) {
73
+ function auditClient(entry) {
74
74
  return entry.source.split(":")[0] || "unknown";
75
75
  }
76
76
  export async function auditSummary(options = {}) {
@@ -17,7 +17,7 @@ export const HARVEST_SOURCES = [
17
17
  // The same text with other spacing or letter case is the same memory.
18
18
  const normalizedKey = (text) => `n:${sha256(text.toLowerCase().replace(/\s+/g, " ").trim())}`;
19
19
  // A short label: the first heading, else a frontmatter name, else the first line.
20
- export function textTitle(text) {
20
+ function textTitle(text) {
21
21
  const heading = /^#{1,6}\s+(.+)$/m.exec(text)?.[1];
22
22
  const name = /^name:\s*["']?(.+?)["']?\s*$/m.exec(text)?.[1];
23
23
  const first = text
@@ -131,6 +131,10 @@ function stateDir(...parts) {
131
131
  export function candidatesRoot() {
132
132
  return oceanPath(INBOX_DIR, "candidates");
133
133
  }
134
+ // Where the review queue went when auto-filing replaced it (T-329 phase 3). Never purged.
135
+ export function candidatesArchiveRoot() {
136
+ return oceanPath(INBOX_DIR, "archive", "candidates");
137
+ }
134
138
  // Server-named only: <candidates>/<yyyy-mm-dd>/<id>.md.
135
139
  export function candidateFile(day, id) {
136
140
  if (!/^\d{4}-\d{2}-\d{2}$/.test(day) || !/^[0-9a-z-]{8,64}$/.test(id))
@@ -170,6 +174,10 @@ export function harvestLedgerFile() {
170
174
  export function sessionFactsLedgerFile() {
171
175
  return stateDir("memory", "session-facts.json");
172
176
  }
177
+ // Project facts whose project Ocean does not know (T-335), one note each, for the owner to place.
178
+ export function unroutedFile(name) {
179
+ return oceanPath(INBOX_DIR, "unrouted", name);
180
+ }
173
181
  export function auditFile() {
174
182
  return stateDir("memory", "audit.jsonl");
175
183
  }
@@ -4,12 +4,13 @@ import { MemoryContractError } from "@ocean/core/domain/mcp/memory-contract.js";
4
4
  import { atomicWrite, withFileLock } from "@ocean/core/shared/fs-utils.js";
5
5
  import { localDate } from "@ocean/core/shared/local-date.js";
6
6
  import { oceanPath, PROJECTS_DIR, projectDir, } from "@ocean/core/shared/paths.js";
7
- import { findProject, readClaudeProjects, registerNamedProject, } from "@ocean/core/shared/project-resolution.js";
7
+ import { readClaudeProjects } from "@ocean/core/shared/project-legacy.js";
8
+ import { findProject, registerNamedProject, } from "@ocean/core/shared/project-register.js";
9
+ import { isSessionFactSource } from "../sessions-capture/session-facts.js";
8
10
  import { FACT_TYPES, factTarget, isFactType } from "./fact-routing.js";
9
11
  import { appendAudit, memorySettings, newId, sha256, writeDurable, } from "./memory-audit.js";
10
- import { assertNoLinks, candidatesRoot, storedCopy } from "./memory-paths.js";
12
+ import { assertNoLinks, candidatesArchiveRoot, candidatesRoot, storedCopy, } from "./memory-paths.js";
11
13
  import { checkContent, proposeMemory, readMemoryRecord, writeMemoryRecord, } from "./memory-write.js";
12
- import { isSessionFactSource } from "./session-facts.js";
13
14
  function parse(text) {
14
15
  const match = /^---\n([\s\S]*?)\n---\n\n?/.exec(text);
15
16
  if (!match)
@@ -297,4 +298,31 @@ export async function fileProposal(options) {
297
298
  export async function rejectCandidate(id) {
298
299
  return { id, auditId: await retire(await candidate(id), "reject") };
299
300
  }
301
+ // Retires the review queue (T-329 phase 3): every pending candidate moves, unreviewed, to
302
+ // 00-inbox/archive/candidates/<day>/<id>.md with an audit entry. Nothing is promoted and nothing
303
+ // is deleted; the archive is never purged. Lists what it would move until `apply`.
304
+ export async function archiveCandidates(options = {}) {
305
+ const moved = [];
306
+ for (const item of await listCandidates()) {
307
+ const target = path.join(candidatesArchiveRoot(), item.day, `${item.id}.md`);
308
+ const to = path.relative(oceanPath(), target).split(path.sep).join("/");
309
+ moved.push({ id: item.id, from: item.file, to });
310
+ if (!options.apply)
311
+ continue;
312
+ await mkdir(path.dirname(target), { recursive: true, mode: 0o700 });
313
+ const text = await readFile(oceanPath(item.file), "utf8");
314
+ await rename(oceanPath(item.file), target);
315
+ await appendAudit({
316
+ id: newId(),
317
+ action: "archive",
318
+ path: item.file,
319
+ source: "archive",
320
+ origin: item.origin === "imported" ? "imported" : "inferred",
321
+ beforeSha: sha256(text),
322
+ afterSha: null,
323
+ copy: to,
324
+ });
325
+ }
326
+ return { applied: Boolean(options.apply), moved };
327
+ }
300
328
  //# sourceMappingURL=memory-review.js.map
@@ -149,4 +149,33 @@ export async function purgeMemoryCopies(options) {
149
149
  }
150
150
  return { cutoff: cutoff.toISOString(), copies, applied: options.apply };
151
151
  }
152
+ // Undoes one write by its audit id (T-329 phase 3: what was filed on its own): a created record
153
+ // is soft-deleted, an updated one gets its earlier version back. Only while the record is as
154
+ // that write left it; a record changed since is restored by hand from its history.
155
+ export async function undoMemoryWrite(options) {
156
+ const entry = (await readAudit()).find((item) => item.id === options.id);
157
+ if (!entry || (entry.action !== "create" && entry.action !== "update"))
158
+ throw new MemoryContractError("MISSING", `no create or update with audit id ${options.id}`);
159
+ const record = permanentRecord(entry.path);
160
+ const current = await readFile(record.file, "utf8").catch(() => null);
161
+ if (current === null)
162
+ throw new MemoryContractError("MISSING", `${record.relative} is gone already`);
163
+ if (sha256(current) !== entry.afterSha)
164
+ throw new MemoryContractError("CONFLICT", `${record.relative} changed after that write; restore it from \`ocean memory history ${record.relative}\``);
165
+ const source = options.source ?? "undo";
166
+ if (entry.action === "create") {
167
+ const removed = await deleteMemoryRecord({
168
+ path: entry.path,
169
+ expectedHash: sha256(current),
170
+ source,
171
+ });
172
+ return { path: removed.path, auditId: removed.auditId, undone: "create" };
173
+ }
174
+ const restored = await restoreMemory({
175
+ id: entry.id,
176
+ expectedHash: sha256(current),
177
+ source,
178
+ });
179
+ return { path: restored.path, auditId: restored.auditId, undone: "update" };
180
+ }
152
181
  //# sourceMappingURL=memory-trash.js.map
@@ -1,7 +1,7 @@
1
1
  import { mkdir, readdir, readFile } from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { MemoryContractError } from "@ocean/core/domain/mcp/memory-contract.js";
4
- import { containsKnownSecret } from "@ocean/core/domain/redaction/redaction.js";
4
+ import { containsKnownSecret } from "@ocean/core/domain/redaction.js";
5
5
  import { atomicWrite, withFileLock } from "@ocean/core/shared/fs-utils.js";
6
6
  import { localDate } from "@ocean/core/shared/local-date.js";
7
7
  import { isUnderNotes, listProjectDirs, NOTES_DIR, oceanPath, PERSONAL_DIR, } from "@ocean/core/shared/paths.js";
@@ -142,7 +142,9 @@ export async function writeMemoryRecord(options) {
142
142
  path: record.relative,
143
143
  source: options.source ?? "unknown",
144
144
  origin: options.provenance?.origin ?? "explicit",
145
- ...(options.provenance ? { candidate: options.provenance.candidate } : {}),
145
+ ...(options.provenance?.candidate
146
+ ? { candidate: options.provenance.candidate }
147
+ : {}),
146
148
  beforeSha: before === null ? null : sha256(before),
147
149
  afterSha: sha256(content),
148
150
  copy,
@@ -1,6 +1,6 @@
1
1
  import { execFile as execFileCallback } from "node:child_process";
2
2
  import { promisify } from "node:util";
3
- import { redactRuntimeText } from "@ocean/core/domain/redaction/redaction.js";
3
+ import { redactRuntimeText } from "@ocean/core/domain/redaction.js";
4
4
  import { oceanEnv, oceanEnvPair } from "@ocean/core/shared/paths.js";
5
5
  const execFile = promisify(execFileCallback);
6
6
  const SYSTEM_PROMPT = 'You are a terse session summarizer. Read the evidence and reply with ONLY a JSON object, no prose, no markdown fences: {"workLog":"one line, what happened","decision":"one line or omit","problem":"one line or omit","next":"one line or omit"}. Omit a key entirely if the evidence gives nothing for it. Never invent facts not present in the evidence.';
@@ -85,7 +85,7 @@ export function parseResult(stdout) {
85
85
  /**
86
86
  * Best-effort, cost-conscious human narrative via a cheap headless model call.
87
87
  * Returns null on any failure (auth, timeout, parse error) so the caller falls
88
- * back to the deterministic heuristic in daily-narrative.ts. Never throws.
88
+ * back to the deterministic heuristic. Never throws.
89
89
  *
90
90
  * Guarded against recursion: the spawned call carries OCEAN_NARRATIVE_CALL=1,
91
91
  * and session-closeout.ts skips calling this again when that flag is already
@@ -58,7 +58,7 @@ export async function deleteProfileFact(profile, key) {
58
58
  });
59
59
  return deleted;
60
60
  }
61
- export const PROFILE_FACTS_DIGEST_MAX_BYTES = 2_048;
61
+ const PROFILE_FACTS_DIGEST_MAX_BYTES = 2_048;
62
62
  // A bounded digest of the profile's durable facts for a headless prompt: newest first (by
63
63
  // updatedAt, since hand-edited files may not be ordered), whole `- key: value` lines while
64
64
  // they fit, and always a pointer to the full set. The whole section stays <= maxBytes; if
@@ -20,12 +20,12 @@
20
20
  "note": "02-personal/notes/",
21
21
  "decision": "05-knowledge/decisions/",
22
22
  "lesson": "05-knowledge/lessons/",
23
- "solution": "05-knowledge/solutions/",
24
- "failure": "05-knowledge/failures/",
25
- "discovery": "05-knowledge/discoveries/",
26
- "architecture": "05-knowledge/architecture/",
27
- "research": "05-knowledge/research/",
28
- "result": "05-knowledge/results/",
23
+ "solution": "05-knowledge/lessons/",
24
+ "failure": "05-knowledge/lessons/",
25
+ "discovery": "05-knowledge/lessons/",
26
+ "architecture": "05-knowledge/decisions/",
27
+ "research": "05-knowledge/lessons/",
28
+ "result": "05-knowledge/lessons/",
29
29
  "person": "02-personal/people/",
30
30
  "interest": "02-personal/interests/",
31
31
  "milestone": "02-personal/milestones/",
@@ -1,4 +1,4 @@
1
- import { redactRuntimeText } from "@ocean/core/domain/redaction/redaction.js";
1
+ import { redactRuntimeText } from "@ocean/core/domain/redaction.js";
2
2
  const CORRECTION_PATTERN = /\bno,|\bactually,|\bnot that\b|\binstead of\b|\bshould use\b|\bthat'?s wrong\b/i;
3
3
  // biome-ignore lint/suspicious/noControlCharactersInRegex: matching terminal escape sequences
4
4
  const ANSI_PATTERN = /\u001b\[[0-?]*[ -/]*[@-~]/g;
@@ -34,7 +34,7 @@ function listField(source, key) {
34
34
  }
35
35
  return items.filter(Boolean);
36
36
  }
37
- export async function listPeople() {
37
+ async function listPeople() {
38
38
  const dir = oceanPath(PEOPLE_DIR);
39
39
  const names = await readdir(dir).catch(() => []);
40
40
  const people = [];