@amoree-code/ocean 0.0.0-stage → 1.1.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 (304) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +284 -2
  3. package/dist/application/auth/auth-orchestrator.js +77 -0
  4. package/dist/application/clients/clients.js +646 -0
  5. package/dist/application/clients/editors.js +398 -0
  6. package/dist/application/clients/hooks.js +335 -0
  7. package/dist/application/clients/native.js +410 -0
  8. package/dist/application/clients/opencode-plugin.js +158 -0
  9. package/dist/application/clients/registry.js +188 -0
  10. package/dist/application/gateway/webhook-gateway.js +137 -0
  11. package/dist/application/install/provider-installer.js +184 -0
  12. package/dist/application/integrations/charter-copies.js +76 -0
  13. package/dist/application/integrations/claude-vscode.js +106 -0
  14. package/dist/application/integrations/engine-entry-repair.js +105 -0
  15. package/dist/application/integrations/skill-filter.js +254 -0
  16. package/dist/application/layout/layout-apply.js +443 -0
  17. package/dist/application/layout/layout-plan.js +236 -0
  18. package/dist/application/layout/workspace-template.js +34 -0
  19. package/dist/application/onboarding/state.js +23 -0
  20. package/dist/application/onboarding/steps.js +249 -0
  21. package/dist/application/profiles/profile-distribution.js +53 -0
  22. package/dist/application/profiles/profile-suggestion.js +39 -0
  23. package/dist/application/profiles/profile-upgrade-service.js +208 -0
  24. package/dist/application/pull/history-index.js +476 -0
  25. package/dist/application/pull/project-match.js +132 -0
  26. package/dist/application/pull/pull.js +202 -0
  27. package/dist/application/pull/server-capture.js +307 -0
  28. package/dist/application/scheduler/local-scheduler.js +210 -0
  29. package/dist/composition/runtime.js +64 -0
  30. package/dist/engine-root.js +9 -0
  31. package/dist/infrastructure/filesystem/profile-loader.js +46 -0
  32. package/dist/infrastructure/filesystem/runtime-config-loader.js +29 -0
  33. package/dist/infrastructure/filesystem/skill-loader.js +84 -0
  34. package/dist/infrastructure/filesystem/workspace-capability.js +37 -0
  35. package/dist/infrastructure/observability/runtime-logger.js +16 -0
  36. package/dist/infrastructure/process/agent-tool-executor.js +99 -0
  37. package/dist/infrastructure/process/cli-process.js +49 -0
  38. package/dist/infrastructure/process/interactive-process.js +145 -0
  39. package/dist/infrastructure/process/process-supervisor.js +194 -0
  40. package/dist/infrastructure/process/service.js +252 -0
  41. package/dist/infrastructure/providers/browser-provider.js +2 -0
  42. package/dist/infrastructure/providers/claude-sdk.js +137 -0
  43. package/dist/infrastructure/providers/client-home.js +14 -0
  44. package/dist/infrastructure/providers/fake-browser-provider.js +146 -0
  45. package/dist/infrastructure/providers/ollama-embedder.js +74 -0
  46. package/dist/infrastructure/providers/openai-compatible.js +268 -0
  47. package/dist/infrastructure/providers/playwright-browser-provider.js +380 -0
  48. package/dist/infrastructure/providers/provider-capabilities.js +50 -0
  49. package/dist/infrastructure/providers/provider-invocation.js +184 -0
  50. package/dist/infrastructure/providers/provider-registry.js +77 -0
  51. package/dist/infrastructure/providers/providers.js +134 -0
  52. package/dist/infrastructure/wrappers/wrapper-manager.js +374 -0
  53. package/dist/interfaces/cli/auth-command.js +54 -0
  54. package/dist/interfaces/cli/browser-bridge-command.js +93 -0
  55. package/dist/interfaces/cli/browser-command.js +119 -0
  56. package/dist/interfaces/cli/capture-command.js +125 -0
  57. package/dist/interfaces/cli/client-test-command.js +133 -0
  58. package/dist/interfaces/cli/clients-command.js +129 -0
  59. package/dist/interfaces/cli/command-registry.js +1211 -0
  60. package/dist/interfaces/cli/context-command.js +172 -0
  61. package/dist/interfaces/cli/daily-command.js +131 -0
  62. package/dist/interfaces/cli/governance-command.js +55 -0
  63. package/dist/interfaces/cli/handoff-command.js +35 -0
  64. package/dist/interfaces/cli/help-command.js +207 -0
  65. package/dist/interfaces/cli/idea-command.js +47 -0
  66. package/dist/interfaces/cli/intercept-command.js +317 -0
  67. package/dist/interfaces/cli/layout-command.js +27 -0
  68. package/dist/interfaces/cli/market-command.js +52 -0
  69. package/dist/interfaces/cli/mcp-gateway-command.js +30 -0
  70. package/dist/interfaces/cli/memory-command.js +317 -0
  71. package/dist/interfaces/cli/migrate-command.js +26 -0
  72. package/dist/interfaces/cli/observe-command.js +78 -0
  73. package/dist/interfaces/cli/onboard-command.js +123 -0
  74. package/dist/interfaces/cli/operate-command.js +59 -0
  75. package/dist/interfaces/cli/profiles-command.js +70 -0
  76. package/dist/interfaces/cli/pull-command.js +54 -0
  77. package/dist/interfaces/cli/setup-command.js +143 -0
  78. package/dist/interfaces/cli/tasks-command.js +249 -0
  79. package/dist/main.js +49 -0
  80. package/dist/node-warnings.js +17 -0
  81. package/dist/version.js +8 -0
  82. package/market/mcp/chrome-devtools/ocean.capability.json +28 -0
  83. package/market/mcp/gateway/ocean.capability.json +21 -0
  84. package/market/mcp/obsidian/ocean.capability.json +21 -0
  85. package/market/mcp/ocean/ocean.capability.json +21 -0
  86. package/market/mcp/playwright/ocean.capability.json +23 -0
  87. package/node_modules/@ocean/brain/dist/brain/brain-eval.js +29 -0
  88. package/node_modules/@ocean/brain/dist/brain/brain-markdown.js +226 -0
  89. package/node_modules/@ocean/brain/dist/brain/brain-reindex.js +247 -0
  90. package/node_modules/@ocean/brain/dist/brain/brain-service.js +320 -0
  91. package/node_modules/@ocean/brain/dist/capture/inbox-sync.js +22 -0
  92. package/node_modules/@ocean/brain/dist/evidence/verification-report.js +13 -0
  93. package/node_modules/@ocean/brain/dist/infrastructure/brain/brain-index.js +285 -0
  94. package/node_modules/@ocean/brain/dist/memory/brain-dump.js +145 -0
  95. package/node_modules/@ocean/brain/dist/memory/daily-narrative.js +142 -0
  96. package/node_modules/@ocean/brain/dist/memory/index-sync.js +124 -0
  97. package/node_modules/@ocean/brain/dist/memory/lesson-activation.js +93 -0
  98. package/node_modules/@ocean/brain/dist/memory/lesson-learning.js +188 -0
  99. package/node_modules/@ocean/brain/dist/memory/lessons.js +321 -0
  100. package/node_modules/@ocean/brain/dist/memory/memory-audit.js +100 -0
  101. package/node_modules/@ocean/brain/dist/memory/memory-digest.js +49 -0
  102. package/node_modules/@ocean/brain/dist/memory/memory-harvest.js +345 -0
  103. package/node_modules/@ocean/brain/dist/memory/memory-paths.js +174 -0
  104. package/node_modules/@ocean/brain/dist/memory/memory-review.js +278 -0
  105. package/node_modules/@ocean/brain/dist/memory/memory-trash.js +152 -0
  106. package/node_modules/@ocean/brain/dist/memory/memory-write.js +216 -0
  107. package/node_modules/@ocean/brain/dist/memory/model-narrative.js +129 -0
  108. package/node_modules/@ocean/brain/dist/memory/profile-facts.js +103 -0
  109. package/node_modules/@ocean/brain/dist/memory/session-promotion.js +61 -0
  110. package/node_modules/@ocean/brain/dist/memory/session-summary.js +113 -0
  111. package/node_modules/@ocean/brain/dist/memory/signal-detection.js +66 -0
  112. package/node_modules/@ocean/brain/package.json +11 -0
  113. package/node_modules/@ocean/context/dist/context/context-compression.js +66 -0
  114. package/node_modules/@ocean/context/dist/context/context-cost.js +587 -0
  115. package/node_modules/@ocean/context/dist/context/context-ladder.js +363 -0
  116. package/node_modules/@ocean/context/dist/context/context-packet.js +213 -0
  117. package/node_modules/@ocean/context/dist/context/context-references.js +255 -0
  118. package/node_modules/@ocean/context/dist/context/intent-router.js +259 -0
  119. package/node_modules/@ocean/context/dist/context/resource-injection.js +36 -0
  120. package/node_modules/@ocean/context/package.json +11 -0
  121. package/node_modules/@ocean/core/dist/domain/brain/brain-record.js +22 -0
  122. package/node_modules/@ocean/core/dist/domain/brain/record-scope.js +22 -0
  123. package/node_modules/@ocean/core/dist/domain/capabilities/browser-contract.js +64 -0
  124. package/node_modules/@ocean/core/dist/domain/capabilities/capability-contract.js +16 -0
  125. package/node_modules/@ocean/core/dist/domain/capabilities/capability-manifest.js +72 -0
  126. package/node_modules/@ocean/core/dist/domain/context/context-validator.js +5 -0
  127. package/node_modules/@ocean/core/dist/domain/context/context.js +34 -0
  128. package/node_modules/@ocean/core/dist/domain/context/project-id.js +30 -0
  129. package/node_modules/@ocean/core/dist/domain/evidence/evidence.js +16 -0
  130. package/node_modules/@ocean/core/dist/domain/mcp/mcp-contract.js +36 -0
  131. package/node_modules/@ocean/core/dist/domain/mcp/memory-contract.js +41 -0
  132. package/node_modules/@ocean/core/dist/domain/ports/brain-index-port.js +7 -0
  133. package/node_modules/@ocean/core/dist/domain/ports/browser-port.js +8 -0
  134. package/node_modules/@ocean/core/dist/domain/ports/embedder-port.js +2 -0
  135. package/node_modules/@ocean/core/dist/domain/ports/platform-ports.js +2 -0
  136. package/node_modules/@ocean/core/dist/domain/ports/runtime-ports.js +2 -0
  137. package/node_modules/@ocean/core/dist/domain/ports/session-store-port.js +2 -0
  138. package/node_modules/@ocean/core/dist/domain/process/process-events.js +5 -0
  139. package/node_modules/@ocean/core/dist/domain/profiles/profile-distribution.js +19 -0
  140. package/node_modules/@ocean/core/dist/domain/profiles/profile-policy.js +34 -0
  141. package/node_modules/@ocean/core/dist/domain/profiles/profile-selection.js +73 -0
  142. package/node_modules/@ocean/core/dist/domain/profiles/profile-upgrade.js +123 -0
  143. package/node_modules/@ocean/core/dist/domain/profiles/profile-validator.js +5 -0
  144. package/node_modules/@ocean/core/dist/domain/profiles/profile.js +218 -0
  145. package/node_modules/@ocean/core/dist/domain/profiles/runtime-config.js +30 -0
  146. package/node_modules/@ocean/core/dist/domain/providers/provider-capability.js +28 -0
  147. package/node_modules/@ocean/core/dist/domain/providers/provider.js +2 -0
  148. package/node_modules/@ocean/core/dist/domain/redaction/redaction.js +86 -0
  149. package/node_modules/@ocean/core/dist/domain/runs/agent-tools.js +92 -0
  150. package/node_modules/@ocean/core/dist/domain/runs/execution-plan.js +71 -0
  151. package/node_modules/@ocean/core/dist/domain/runs/run-contract.js +38 -0
  152. package/node_modules/@ocean/core/dist/domain/sessions/entry-contract.js +31 -0
  153. package/node_modules/@ocean/core/dist/domain/sessions/handoff.js +78 -0
  154. package/node_modules/@ocean/core/dist/domain/sessions/session.js +58 -0
  155. package/node_modules/@ocean/core/dist/domain/skills/default-skills.js +29 -0
  156. package/node_modules/@ocean/core/dist/domain/skills/skill-validator.js +5 -0
  157. package/node_modules/@ocean/core/dist/domain/skills/skill.js +11 -0
  158. package/node_modules/@ocean/core/dist/domain/tasks/task-id.js +85 -0
  159. package/node_modules/@ocean/core/dist/shared/fs-utils.js +212 -0
  160. package/node_modules/@ocean/core/dist/shared/local-date.js +16 -0
  161. package/node_modules/@ocean/core/dist/shared/paths.js +324 -0
  162. package/node_modules/@ocean/core/dist/shared/project-resolution.js +1065 -0
  163. package/node_modules/@ocean/core/dist/shared/task-reference.js +133 -0
  164. package/node_modules/@ocean/core/package.json +14 -0
  165. package/node_modules/@ocean/loop/dist/handoff/handoff-service.js +133 -0
  166. package/node_modules/@ocean/loop/dist/hooks/lifecycle-hooks.js +15 -0
  167. package/node_modules/@ocean/loop/dist/hooks/session-end-hook.js +183 -0
  168. package/node_modules/@ocean/loop/dist/hooks/session-start-hook.js +237 -0
  169. package/node_modules/@ocean/loop/dist/infrastructure/persistence/session-store.js +690 -0
  170. package/node_modules/@ocean/loop/dist/infrastructure/persistence/session-validator.js +5 -0
  171. package/node_modules/@ocean/loop/dist/loops/iteration-graph.js +147 -0
  172. package/node_modules/@ocean/loop/dist/loops/task-loop-record.js +2 -0
  173. package/node_modules/@ocean/loop/dist/loops/task-loop.js +281 -0
  174. package/node_modules/@ocean/loop/dist/operations/memory-knowledge-operations.js +263 -0
  175. package/node_modules/@ocean/loop/dist/operations/operation-contract.js +227 -0
  176. package/node_modules/@ocean/loop/dist/operations/operation-scope.js +28 -0
  177. package/node_modules/@ocean/loop/dist/operations/project-operations.js +93 -0
  178. package/node_modules/@ocean/loop/dist/operations/record-io.js +65 -0
  179. package/node_modules/@ocean/loop/dist/operations/record-operations.js +45 -0
  180. package/node_modules/@ocean/loop/dist/operations/task-linker.js +40 -0
  181. package/node_modules/@ocean/loop/dist/operations/task-operations.js +279 -0
  182. package/node_modules/@ocean/loop/dist/operations/write-guard.js +157 -0
  183. package/node_modules/@ocean/loop/dist/runs/prompt-assembly.js +112 -0
  184. package/node_modules/@ocean/loop/dist/runs/run-agent.js +425 -0
  185. package/node_modules/@ocean/loop/dist/runs/run-authorization.js +24 -0
  186. package/node_modules/@ocean/loop/dist/runs/tool-loop.js +173 -0
  187. package/node_modules/@ocean/loop/dist/sessions/session-closeout.js +150 -0
  188. package/node_modules/@ocean/loop/dist/sessions/session-pointer.js +133 -0
  189. package/node_modules/@ocean/loop/dist/sessions/session-projects.js +26 -0
  190. package/node_modules/@ocean/loop/dist/sessions/session-retention.js +132 -0
  191. package/node_modules/@ocean/loop/dist/tasks/archive-tasks.js +210 -0
  192. package/node_modules/@ocean/loop/dist/tasks/checkpoint-task.js +31 -0
  193. package/node_modules/@ocean/loop/dist/tasks/claim-task.js +126 -0
  194. package/node_modules/@ocean/loop/dist/tasks/list-tasks.js +113 -0
  195. package/node_modules/@ocean/loop/dist/tasks/new-task.js +42 -0
  196. package/node_modules/@ocean/loop/dist/tasks/renumber-tasks.js +134 -0
  197. package/node_modules/@ocean/loop/dist/tasks/verification-readiness.js +78 -0
  198. package/node_modules/@ocean/loop/dist/tasks/verify-task.js +234 -0
  199. package/node_modules/@ocean/loop/package.json +11 -0
  200. package/node_modules/@ocean/market/dist/adapters/mcp-adapter.js +64 -0
  201. package/node_modules/@ocean/market/dist/adapters/owned-directory.js +89 -0
  202. package/node_modules/@ocean/market/dist/adapters/plugin-adapter.js +39 -0
  203. package/node_modules/@ocean/market/dist/adapters/skill-adapter.js +32 -0
  204. package/node_modules/@ocean/market/dist/capability/adapter.js +2 -0
  205. package/node_modules/@ocean/market/dist/capability/catalog.js +63 -0
  206. package/node_modules/@ocean/market/dist/capability/content-digest.js +40 -0
  207. package/node_modules/@ocean/market/dist/capability/registry.js +81 -0
  208. package/node_modules/@ocean/market/dist/install/default-marketplace.js +47 -0
  209. package/node_modules/@ocean/market/dist/install/lock.js +34 -0
  210. package/node_modules/@ocean/market/dist/install/marketplace-service.js +165 -0
  211. package/node_modules/@ocean/market/dist/mcp/browser-bridge.js +263 -0
  212. package/node_modules/@ocean/market/dist/mcp/mcp-connection.js +67 -0
  213. package/node_modules/@ocean/market/dist/mcp/mcp-gateway.js +317 -0
  214. package/node_modules/@ocean/market/dist/mcp/mcp-launch.js +102 -0
  215. package/node_modules/@ocean/market/dist/mcp/mcp-runner.js +32 -0
  216. package/node_modules/@ocean/market/dist/security/description-scan.js +45 -0
  217. package/node_modules/@ocean/market/dist/security/permissions.js +57 -0
  218. package/node_modules/@ocean/market/dist/security/sandbox.js +74 -0
  219. package/node_modules/@ocean/market/dist/skills/core-skill-sync.js +113 -0
  220. package/node_modules/@ocean/market/dist/skills/signal-detection.js +84 -0
  221. package/node_modules/@ocean/market/dist/skills/skill-curation.js +123 -0
  222. package/node_modules/@ocean/market/dist/skills/skill-hub.js +220 -0
  223. package/node_modules/@ocean/market/dist/skills/task-observer.js +165 -0
  224. package/node_modules/@ocean/market/package.json +11 -0
  225. package/node_modules/@ocean/services/dist/browser/browser-service.js +124 -0
  226. package/node_modules/@ocean/services/dist/browser/browser-session.js +287 -0
  227. package/node_modules/@ocean/services/dist/browser/browser-task-runner.js +70 -0
  228. package/node_modules/@ocean/services/dist/doctor/workspace-doctor.js +547 -0
  229. package/node_modules/@ocean/services/dist/infrastructure/mcp/call-ledger.js +114 -0
  230. package/node_modules/@ocean/services/dist/infrastructure/mcp/mcp-client.js +162 -0
  231. package/node_modules/@ocean/services/dist/infrastructure/mcp/obsidian-server.js +251 -0
  232. package/node_modules/@ocean/services/dist/infrastructure/mcp/ocean-server.js +880 -0
  233. package/node_modules/@ocean/services/dist/infrastructure/mcp/server-version.js +20 -0
  234. package/node_modules/@ocean/services/dist/infrastructure/mcp/tool-registry.js +29 -0
  235. package/node_modules/@ocean/services/dist/obsidian/conflict-log.js +68 -0
  236. package/node_modules/@ocean/services/dist/obsidian/inbox-promotion.js +80 -0
  237. package/node_modules/@ocean/services/dist/obsidian/vault-discovery.js +113 -0
  238. package/node_modules/@ocean/services/dist/obsidian/vault-ingestion.js +77 -0
  239. package/node_modules/@ocean/services/dist/obsidian/vault-sync.js +73 -0
  240. package/node_modules/@ocean/services/dist/obsidian/vault-writer.js +75 -0
  241. package/node_modules/@ocean/services/package.json +11 -0
  242. package/ocean-marketplace.json +415 -0
  243. package/package.json +67 -4
  244. package/skills/core/business-logic/SKILL.md +22 -0
  245. package/skills/core/catch-up/SKILL.md +17 -0
  246. package/skills/core/core-thinking/SKILL.md +11 -0
  247. package/skills/core/design-thinking/SKILL.md +19 -0
  248. package/skills/core/graft/SKILL.md +156 -0
  249. package/skills/core/loop/SKILL.md +20 -0
  250. package/skills/core/session-handoff/SKILL.md +15 -0
  251. package/skills/core/use-browser/SKILL.md +69 -0
  252. package/skills/core/verification/SKILL.md +11 -0
  253. package/skills/index.json +56 -0
  254. package/templates/README.md +4 -0
  255. package/templates/profiles/default.json +51 -0
  256. package/templates/profiles/developer.json +51 -0
  257. package/templates/profiles/reviewer.json +51 -0
  258. package/templates/profiles/strategist.json +51 -0
  259. package/templates/workspace/00-inbox/INBOX.md +7 -0
  260. package/templates/workspace/00-inbox/candidates/.gitkeep +0 -0
  261. package/templates/workspace/00-inbox/native/.gitkeep +0 -0
  262. package/templates/workspace/01-daily/.gitkeep +0 -0
  263. package/templates/workspace/02-personal/CONFLICTS.md +7 -0
  264. package/templates/workspace/02-personal/MEMORY.md +15 -0
  265. package/templates/workspace/02-personal/goals/.gitkeep +0 -0
  266. package/templates/workspace/02-personal/identity/.gitkeep +0 -0
  267. package/templates/workspace/02-personal/preferences/.gitkeep +0 -0
  268. package/templates/workspace/03-professional/.gitkeep +0 -0
  269. package/templates/workspace/04-projects/PROJECTS.md +5 -0
  270. package/templates/workspace/04-projects/_template/docs/.gitkeep +0 -0
  271. package/templates/workspace/04-projects/_template/memory/.gitkeep +0 -0
  272. package/templates/workspace/04-projects/_template/tasks/.gitkeep +0 -0
  273. package/templates/workspace/05-knowledge/KNOWLEDGE.md +8 -0
  274. package/templates/workspace/05-knowledge/decisions/.gitkeep +0 -0
  275. package/templates/workspace/05-knowledge/lessons/.gitkeep +0 -0
  276. package/templates/workspace/06-templates/TEMPLATES.md +25 -0
  277. package/templates/workspace/06-templates/decision.md +8 -0
  278. package/templates/workspace/06-templates/intelligence.md +32 -0
  279. package/templates/workspace/06-templates/project-claude.md +48 -0
  280. package/templates/workspace/06-templates/session.md +38 -0
  281. package/templates/workspace/06-templates/task.md +42 -0
  282. package/templates/workspace/MANIFEST.json +51 -0
  283. package/templates/workspace/bridge/config/CONFIG.md +21 -0
  284. package/templates/workspace/bridge/config/runtime.json +4 -0
  285. package/templates/workspace/charter/core.md +104 -0
  286. package/templates/workspace/charter/policies/README.md +31 -0
  287. package/templates/workspace/charter/policies/claude-code-context.md +90 -0
  288. package/templates/workspace/charter/policies/concise-output.md +29 -0
  289. package/templates/workspace/charter/policies/context.md +91 -0
  290. package/templates/workspace/charter/policies/contracts/task.md +189 -0
  291. package/templates/workspace/charter/policies/git.md +60 -0
  292. package/templates/workspace/charter/policies/graph.md +47 -0
  293. package/templates/workspace/charter/policies/knowledge.md +33 -0
  294. package/templates/workspace/charter/policies/lifecycle.md +119 -0
  295. package/templates/workspace/charter/policies/memory.md +67 -0
  296. package/templates/workspace/charter/policies/minimal-change.md +43 -0
  297. package/templates/workspace/charter/policies/models.md +57 -0
  298. package/templates/workspace/charter/policies/privacy-terms.txt +3 -0
  299. package/templates/workspace/charter/policies/response.md +39 -0
  300. package/templates/workspace/charter/policies/skill-observer.md +44 -0
  301. package/templates/workspace/charter/policies/stack.md +23 -0
  302. package/templates/workspace/charter/policies/task.md +139 -0
  303. package/templates/workspace/charter/policies/verification.md +29 -0
  304. package/templates/workspace/sessions/.gitkeep +0 -0
@@ -0,0 +1,317 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { evaluateRecall, } from "@ocean/brain/brain/brain-eval.js";
3
+ import { brainIndexPath, computeCorpusHash, reindexBrain, } from "@ocean/brain/brain/brain-reindex.js";
4
+ import { brainNeighbors, brainRead, brainSearch, } from "@ocean/brain/brain/brain-service.js";
5
+ import { doctorMemoryIndexes, syncMemoryIndexes, } from "@ocean/brain/memory/index-sync.js";
6
+ import { memoryDigest } from "@ocean/brain/memory/memory-digest.js";
7
+ import { HARVEST_SOURCES, harvestMemory, importClaudeExport, } from "@ocean/brain/memory/memory-harvest.js";
8
+ import { approveCandidate, listCandidates, rejectCandidate, } from "@ocean/brain/memory/memory-review.js";
9
+ import { deleteMemoryRecord, memoryHistory, purgeMemoryCopies, restoreMemory, } from "@ocean/brain/memory/memory-trash.js";
10
+ import { deleteProfileFact, readProfileFacts, writeProfileFact, } from "@ocean/brain/memory/profile-facts.js";
11
+ import { isValidProjectId } from "@ocean/core/domain/context/project-id.js";
12
+ import { folderProject } from "@ocean/core/shared/project-resolution.js";
13
+ import { defaultBrainIndexPort } from "../../composition/runtime.js";
14
+ import { createOllamaEmbedder } from "../../infrastructure/providers/ollama-embedder.js";
15
+ async function runReindex(args) {
16
+ const noVectors = args.includes("--no-vectors");
17
+ let embedder = null;
18
+ if (!noVectors) {
19
+ try {
20
+ embedder = await createOllamaEmbedder();
21
+ }
22
+ catch (error) {
23
+ console.error(`reindex refused: embedder unavailable (${error instanceof Error ? error.message : String(error)}). Pass --no-vectors to index without vectors.`);
24
+ process.exitCode = 1;
25
+ return;
26
+ }
27
+ }
28
+ const result = await reindexBrain({
29
+ embedder,
30
+ indexPort: defaultBrainIndexPort,
31
+ });
32
+ console.log(JSON.stringify(result, null, 2));
33
+ }
34
+ const searchUsage = "Usage: ocean memory search <query> [--project <id> | --all] [--json]";
35
+ const neighborsUsage = "Usage: ocean memory neighbors <id|path> [--depth N] [--project <id> | --all]";
36
+ // --project <id> / --all, shared by search and neighbors. Default: the cwd's project plus
37
+ // global records; --all is the explicit unscoped view. null means the flags are malformed.
38
+ function parseScopeFlags(args) {
39
+ let all = false;
40
+ let project;
41
+ const rest = [];
42
+ for (let index = 0; index < args.length; index += 1) {
43
+ const arg = args[index];
44
+ if (arg === "--all")
45
+ all = true;
46
+ else if (arg === "--project") {
47
+ project = args[index + 1] ?? "";
48
+ index += 1;
49
+ }
50
+ else
51
+ rest.push(arg);
52
+ }
53
+ if (project !== undefined && (all || !isValidProjectId(project)))
54
+ return null;
55
+ return { all, project, rest };
56
+ }
57
+ async function scopeFrom(flags) {
58
+ return flags.all
59
+ ? undefined
60
+ : { project: flags.project ?? (await folderProject(process.cwd())) };
61
+ }
62
+ async function runSearch(args) {
63
+ const flags = parseScopeFlags(args);
64
+ const json = args.includes("--json");
65
+ const query = (flags?.rest ?? [])
66
+ .filter((arg) => !arg.startsWith("--"))
67
+ .join(" ");
68
+ if (!flags || !query) {
69
+ console.error(searchUsage);
70
+ process.exitCode = 1;
71
+ return;
72
+ }
73
+ try {
74
+ const result = await brainSearch({
75
+ query,
76
+ scope: await scopeFrom(flags),
77
+ indexPort: defaultBrainIndexPort,
78
+ });
79
+ console.log(json ? JSON.stringify(result) : JSON.stringify(result, null, 2));
80
+ }
81
+ catch (error) {
82
+ console.error(error instanceof Error ? error.message : String(error));
83
+ process.exitCode = 1;
84
+ }
85
+ }
86
+ async function runRead(args) {
87
+ const idOrPath = args[0];
88
+ if (!idOrPath) {
89
+ console.error("Usage: ocean memory read <id|path>");
90
+ process.exitCode = 1;
91
+ return;
92
+ }
93
+ try {
94
+ console.log(JSON.stringify(await brainRead({ idOrPath, indexPort: defaultBrainIndexPort }), null, 2));
95
+ }
96
+ catch (error) {
97
+ console.error(error instanceof Error ? error.message : String(error));
98
+ process.exitCode = 1;
99
+ }
100
+ }
101
+ async function runNeighbors(args) {
102
+ const flags = parseScopeFlags(args);
103
+ const rest = flags?.rest ?? [];
104
+ const depthIndex = rest.indexOf("--depth");
105
+ const depth = depthIndex >= 0 ? Number(rest[depthIndex + 1]) : 1;
106
+ const idOrPath = rest[0];
107
+ if (!flags || !idOrPath || idOrPath.startsWith("--")) {
108
+ console.error(neighborsUsage);
109
+ process.exitCode = 1;
110
+ return;
111
+ }
112
+ try {
113
+ console.log(JSON.stringify(await brainNeighbors({
114
+ idOrPath,
115
+ depth: depth === 2 ? 2 : 1,
116
+ scope: await scopeFrom(flags),
117
+ indexPort: defaultBrainIndexPort,
118
+ }), null, 2));
119
+ }
120
+ catch (error) {
121
+ console.error(error instanceof Error ? error.message : String(error));
122
+ process.exitCode = 1;
123
+ }
124
+ }
125
+ async function runFacts(args) {
126
+ const profile = args[0];
127
+ if (!profile) {
128
+ console.error("Usage: ocean memory facts <profile> [key] [value]");
129
+ process.exitCode = 1;
130
+ return;
131
+ }
132
+ try {
133
+ if (args[1] === "delete" && args[2])
134
+ console.log(JSON.stringify({ deleted: await deleteProfileFact(profile, args[2]) }, null, 2));
135
+ else if (args.length >= 3)
136
+ console.log(JSON.stringify(await writeProfileFact(profile, args[1], args.slice(2).join(" ")), null, 2));
137
+ else
138
+ console.log(JSON.stringify(await readProfileFacts(profile), null, 2));
139
+ }
140
+ catch (error) {
141
+ console.error(error instanceof Error ? error.message : String(error));
142
+ process.exitCode = 1;
143
+ }
144
+ }
145
+ // The value after a flag, or undefined.
146
+ function flagValue(args, flag) {
147
+ const index = args.indexOf(flag);
148
+ return index >= 0 ? args[index + 1] : undefined;
149
+ }
150
+ // Soft delete, history, restore and purge of memory records (T-296). Purge is CLI-only and
151
+ // lists what it would drop until --yes confirms it.
152
+ async function runRecordCommand(action, args) {
153
+ const positional = args.filter((arg, index) => !arg.startsWith("--") && !args[index - 1]?.startsWith("--"));
154
+ let result;
155
+ if (action === "history") {
156
+ const limit = Number(flagValue(args, "--limit") ?? 20);
157
+ result = await memoryHistory({ path: positional[0], limit });
158
+ }
159
+ else if (action === "restore") {
160
+ if (!positional[0])
161
+ throw new Error("Usage: ocean memory restore <audit-id> [--hash <sha256>]");
162
+ result = await restoreMemory({
163
+ id: positional[0],
164
+ expectedHash: flagValue(args, "--hash"),
165
+ source: "cli",
166
+ });
167
+ }
168
+ else if (action === "delete") {
169
+ const hash = flagValue(args, "--hash");
170
+ if (!positional[0] || !hash)
171
+ throw new Error("Usage: ocean memory delete <path> --hash <sha256>");
172
+ result = await deleteMemoryRecord({
173
+ path: positional[0],
174
+ expectedHash: hash,
175
+ source: "cli",
176
+ });
177
+ }
178
+ else {
179
+ const days = flagValue(args, "--days");
180
+ result = await purgeMemoryCopies({
181
+ apply: args.includes("--yes"),
182
+ days: days === undefined ? undefined : Number(days),
183
+ });
184
+ if (!args.includes("--yes"))
185
+ console.error("Dry run: pass --yes to remove these copies for good.");
186
+ }
187
+ console.log(JSON.stringify(result, null, 2));
188
+ }
189
+ // Candidate review (T-296 P5): list, approve into a record, or reject. Edit = edit the candidate
190
+ // file, then approve it.
191
+ async function runReview(args) {
192
+ const [verb = "list", id] = args;
193
+ if (verb === "list") {
194
+ // `--project <id>`: the candidates `ocean pull` filed under that project (T-305).
195
+ const project = flagValue(args, "--project");
196
+ const candidates = (await listCandidates()).filter((item) => !project || item.meta.project === project);
197
+ if (args.includes("--json")) {
198
+ console.log(JSON.stringify(candidates, null, 2));
199
+ return;
200
+ }
201
+ if (!candidates.length)
202
+ console.log("No memory candidates to review.");
203
+ for (const item of candidates)
204
+ console.log(`${item.id} ${item.origin.padEnd(8)} ${typeof item.meta.project === "string" ? `[${item.meta.project}] ` : ""}${item.target || "(no target)"} ${item.file}${item.reason ? ` — ${item.reason}` : ""}`);
205
+ return;
206
+ }
207
+ if ((verb === "approve" || verb === "reject") && id) {
208
+ const result = verb === "approve"
209
+ ? await approveCandidate({ id, to: flagValue(args, "--to") })
210
+ : await rejectCandidate(id);
211
+ console.log(JSON.stringify(result, null, 2));
212
+ return;
213
+ }
214
+ console.error("Usage: ocean memory review [list] [--project <id>] [--json] | approve <id> [--to <record path>] | reject <id>");
215
+ process.exitCode = 1;
216
+ }
217
+ // Recall@k over a JSON list of {question, expect, project?}; fails below --min.
218
+ async function runEval(args) {
219
+ const file = args.find((arg, index) => !arg.startsWith("--") && !args[index - 1]?.startsWith("--"));
220
+ if (!file) {
221
+ console.error("Usage: ocean memory eval <questions.json> [--k N] [--min 0.9] [--vectors]");
222
+ process.exitCode = 1;
223
+ return;
224
+ }
225
+ const cases = JSON.parse(await readFile(file, "utf8"));
226
+ const result = await evaluateRecall(cases, {
227
+ indexPort: defaultBrainIndexPort,
228
+ embedder: args.includes("--vectors") ? await createOllamaEmbedder() : null,
229
+ k: Number(flagValue(args, "--k") ?? 5),
230
+ });
231
+ console.log(JSON.stringify(result, null, 2));
232
+ if (result.recall < Number(flagValue(args, "--min") ?? 0.9))
233
+ process.exitCode = 1;
234
+ }
235
+ async function indexIsStale() {
236
+ try {
237
+ const reader = defaultBrainIndexPort.openIndexReadOnly(brainIndexPath());
238
+ try {
239
+ return reader.meta.corpusHash !== (await computeCorpusHash());
240
+ }
241
+ finally {
242
+ reader.close();
243
+ }
244
+ }
245
+ catch {
246
+ return null;
247
+ }
248
+ }
249
+ export async function runMemoryCommand(action, args) {
250
+ if (action === "history" ||
251
+ action === "restore" ||
252
+ action === "delete" ||
253
+ action === "purge")
254
+ return runRecordCommand(action, args);
255
+ if (action === "reindex")
256
+ return runReindex(args);
257
+ if (action === "review")
258
+ return runReview(args);
259
+ if (action === "harvest") {
260
+ const source = flagValue(args, "--source");
261
+ if (source && !HARVEST_SOURCES.includes(source))
262
+ throw new Error(`--source must be one of ${HARVEST_SOURCES.join(", ")}`);
263
+ const items = await harvestMemory({
264
+ sources: source ? [source] : undefined,
265
+ apply: args.includes("--yes"),
266
+ });
267
+ console.log(JSON.stringify(items, null, 2));
268
+ if (!args.includes("--yes"))
269
+ console.error("Dry run: pass --yes to propose the new ones as candidates.");
270
+ return;
271
+ }
272
+ if (action === "import-claude") {
273
+ const directory = args.find((arg) => !arg.startsWith("--"));
274
+ if (!directory)
275
+ throw new Error("Usage: ocean memory import-claude <export-dir> [--yes]");
276
+ console.log(JSON.stringify(await importClaudeExport(directory, { apply: args.includes("--yes") }), null, 2));
277
+ if (!args.includes("--yes"))
278
+ console.error("Dry run: pass --yes to propose them as candidates.");
279
+ return;
280
+ }
281
+ if (action === "eval")
282
+ return runEval(args);
283
+ if (action === "digest") {
284
+ const lines = await memoryDigest({ stale: await indexIsStale() });
285
+ console.log(lines.length ? lines.join("\n") : "memory: nothing to review");
286
+ return;
287
+ }
288
+ if (action === "search")
289
+ return runSearch(args);
290
+ if (action === "read")
291
+ return runRead(args);
292
+ if (action === "neighbors")
293
+ return runNeighbors(args);
294
+ if (action === "facts")
295
+ return runFacts(args);
296
+ if (action === "doctor") {
297
+ const result = await doctorMemoryIndexes();
298
+ if (!result.ok) {
299
+ if (result.missing.length)
300
+ console.error(`NOT READY: unindexed records: ${result.missing.join(", ")}`);
301
+ if (result.broken.length)
302
+ console.error(`NOT READY: broken index links: ${result.broken.join(", ")}`);
303
+ process.exitCode = 1;
304
+ }
305
+ else
306
+ console.log("PROVEN: memory and knowledge indexes are synchronized.");
307
+ return;
308
+ }
309
+ if (action === "sync") {
310
+ const result = await syncMemoryIndexes(args.includes("--apply"));
311
+ console.log(JSON.stringify({ dryRun: !args.includes("--apply"), stores: result }, null, 2));
312
+ return;
313
+ }
314
+ console.error("Usage: ocean memory doctor|sync [--apply]|review [list|approve <id> [--to <path>]|reject <id>]|eval <questions.json> [--k N] [--min R]|digest|harvest [--source <id>] [--yes]|import-claude <export-dir> [--yes]|history [path] [--limit N]|restore <id> [--hash <sha256>]|delete <path> --hash <sha256>|purge [--days N] [--yes]|facts <profile> [key] [value]|facts <profile> delete <key>|reindex [--no-vectors]|search <q> [--project <id>|--all] [--json]|read <id|path>|neighbors <id|path> [--depth N] [--project <id>|--all]");
315
+ process.exitCode = 1;
316
+ }
317
+ //# sourceMappingURL=memory-command.js.map
@@ -0,0 +1,26 @@
1
+ import { access } from "node:fs/promises";
2
+ import { oceanPath, SYSTEM_DIR } from "@ocean/core/shared/paths.js";
3
+ import { openSessionStore } from "@ocean/loop/infrastructure/persistence/session-store.js";
4
+ import { backfillSessionProjects } from "@ocean/loop/sessions/session-projects.js";
5
+ export async function runMigrateCommand(apply) {
6
+ const database = oceanPath(SYSTEM_DIR, "sessions", "sessions.sqlite");
7
+ const exists = await access(database).then(() => true, () => false);
8
+ if (!apply) {
9
+ console.log(JSON.stringify({
10
+ applyRequired: true,
11
+ databaseExists: exists,
12
+ action: "ocean migrate --apply",
13
+ note: "Applying opens the session database and runs idempotent schema migrations.",
14
+ }, null, 2));
15
+ return;
16
+ }
17
+ const store = await openSessionStore();
18
+ try {
19
+ const projects = await backfillSessionProjects(store);
20
+ console.log(JSON.stringify({ migrated: true, integrity: store.integrityCheck(), projects }, null, 2));
21
+ }
22
+ finally {
23
+ store.close();
24
+ }
25
+ }
26
+ //# sourceMappingURL=migrate-command.js.map
@@ -0,0 +1,78 @@
1
+ import { spawn } from "node:child_process";
2
+ import { randomUUID } from "node:crypto";
3
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
4
+ import { oceanPath, resolveWithin, SYSTEM_DIR, } from "@ocean/core/shared/paths.js";
5
+ import { redactSecrets } from "../../infrastructure/observability/runtime-logger.js";
6
+ const observationsRoot = () => oceanPath(SYSTEM_DIR, "observations");
7
+ export async function runObserveCommand(args) {
8
+ if (args[0] === "show") {
9
+ const id = args[1];
10
+ if (!id || !/^[a-f0-9-]+$/i.test(id))
11
+ throw new Error("Usage: ocean observe show <id> [--grep <pattern>]");
12
+ const observation = JSON.parse(await readFile(resolveWithin(observationsRoot(), `${id}.json`), "utf8"));
13
+ const grepIndex = args.indexOf("--grep");
14
+ if (grepIndex >= 0) {
15
+ const pattern = args[grepIndex + 1];
16
+ if (!pattern)
17
+ throw new Error("--grep requires a pattern");
18
+ const matcher = new RegExp(pattern, "i");
19
+ process.stdout.write(`${[observation.stdout, observation.stderr]
20
+ .join("\n")
21
+ .split("\n")
22
+ .filter((line) => matcher.test(line))
23
+ .join("\n")}\n`);
24
+ }
25
+ else
26
+ console.log(JSON.stringify(observation, null, 2));
27
+ return;
28
+ }
29
+ const separator = args.indexOf("--");
30
+ const command = separator >= 0 ? args.slice(separator + 1) : args;
31
+ if (!command.length)
32
+ throw new Error("Usage: ocean observe -- <command> [args]");
33
+ const result = await capture(command);
34
+ await mkdir(observationsRoot(), { recursive: true });
35
+ await writeFile(resolveWithin(observationsRoot(), `${result.id}.json`), `${JSON.stringify(result, null, 2)}\n`, { mode: 0o600 });
36
+ const decisive = result.exitCode === 0
37
+ ? lastLines(result.stdout, 8)
38
+ : lastLines(`${result.stderr}\n${result.stdout}`, 16);
39
+ console.log(JSON.stringify({ id: result.id, exitCode: result.exitCode, decisive }, null, 2));
40
+ process.exitCode = result.exitCode;
41
+ }
42
+ async function capture(command) {
43
+ return new Promise((resolve, reject) => {
44
+ const child = spawn(command[0], command.slice(1), {
45
+ cwd: process.cwd(),
46
+ env: process.env,
47
+ stdio: ["ignore", "pipe", "pipe"],
48
+ });
49
+ let stdout = "";
50
+ let stderr = "";
51
+ child.stdout.on("data", (chunk) => {
52
+ stdout = boundedAppend(stdout, chunk.toString());
53
+ });
54
+ child.stderr.on("data", (chunk) => {
55
+ stderr = boundedAppend(stderr, chunk.toString());
56
+ });
57
+ child.once("error", reject);
58
+ child.once("close", (code) => resolve({
59
+ id: randomUUID(),
60
+ command,
61
+ cwd: process.cwd(),
62
+ exitCode: code ?? 1,
63
+ stdout: redactSecrets(stdout),
64
+ stderr: redactSecrets(stderr),
65
+ createdAt: new Date().toISOString(),
66
+ }));
67
+ });
68
+ }
69
+ function boundedAppend(current, chunk) {
70
+ const combined = current + chunk;
71
+ return combined.length <= 1_000_000
72
+ ? combined
73
+ : combined.slice(combined.length - 1_000_000);
74
+ }
75
+ function lastLines(value, count) {
76
+ return value.trim().split("\n").filter(Boolean).slice(-count);
77
+ }
78
+ //# sourceMappingURL=observe-command.js.map
@@ -0,0 +1,123 @@
1
+ import { createInterface } from "node:readline/promises";
2
+ import { applyClients, planClients, readClientState, recordVerification, verifyClient, } from "../../application/clients/clients.js";
3
+ import { applyHooks, planHooks } from "../../application/clients/hooks.js";
4
+ import { applyNative, planNative } from "../../application/clients/native.js";
5
+ import { loadOnboardingState, saveOnboardingState, } from "../../application/onboarding/state.js";
6
+ import { buildSteps, ONBOARDING_VERSION, } from "../../application/onboarding/steps.js";
7
+ import { installShellIntegration, setProviderEnabled, syncProviderWrappers, wrapperDoctor, wrapperStatus, } from "../../infrastructure/wrappers/wrapper-manager.js";
8
+ import { setup } from "./setup-command.js";
9
+ const stepDependencies = () => ({
10
+ setup: () => setup(),
11
+ wrappers: {
12
+ wrapperStatus,
13
+ setProviderEnabled,
14
+ syncProviderWrappers,
15
+ installShellIntegration,
16
+ wrapperDoctor: () => wrapperDoctor(),
17
+ },
18
+ clients: {
19
+ plan: () => planClients(),
20
+ apply: (clients) => applyClients({ clients }),
21
+ verify: async (client) => {
22
+ const check = await verifyClient(client);
23
+ await recordVerification(client, check.ok);
24
+ return check;
25
+ },
26
+ approved: async () => Object.keys((await readClientState()).approved),
27
+ hooks: () => planHooks(),
28
+ applyHooks: async (batch) => (await applyHooks({ batch })).results,
29
+ native: () => planNative(),
30
+ applyNative: async (batch) => (await applyNative({ batch })).results,
31
+ },
32
+ });
33
+ function terminalIO(interactive) {
34
+ const prompt = interactive
35
+ ? createInterface({ input: process.stdin, output: process.stdout })
36
+ : undefined;
37
+ return {
38
+ io: {
39
+ interactive,
40
+ say: (line) => console.log(line),
41
+ ask: async (question, fallback) => prompt ? await prompt.question(question) : fallback,
42
+ },
43
+ close: () => prompt?.close(),
44
+ };
45
+ }
46
+ // Runs every step that is not already done/skipped, saving after each one so an
47
+ // interrupted run resumes at the first pending step. A completed state is a no-op.
48
+ export async function onboard(options = {}) {
49
+ const interactive = !options.yes && Boolean(process.stdin.isTTY && process.stdout.isTTY);
50
+ const terminal = options.io ? undefined : terminalIO(interactive);
51
+ const io = options.io ?? terminal.io;
52
+ const steps = options.steps ?? buildSteps(stepDependencies());
53
+ try {
54
+ const state = await loadOnboardingState();
55
+ if (options.reset) {
56
+ if (!steps.some((step) => step.id === options.reset))
57
+ throw new Error(`Unknown onboarding step '${options.reset}'`);
58
+ delete state.steps[options.reset];
59
+ }
60
+ for (const step of steps) {
61
+ if (!state.steps[step.id] || !step.reopen)
62
+ continue;
63
+ const reason = await step.reopen();
64
+ if (!reason)
65
+ continue;
66
+ io.say(`Reopening ${step.id}: ${reason}`);
67
+ delete state.steps[step.id];
68
+ }
69
+ const pending = steps.filter((step) => !state.steps[step.id]);
70
+ if (pending.length === 0) {
71
+ io.say("Ocean onboarding is complete. Use `ocean onboard --reset <step>` to redo a step, or `ocean doctor` for health.");
72
+ return;
73
+ }
74
+ io.say(`Ocean onboarding: ${pending.length} of ${steps.length} steps to go.`);
75
+ for (const [index, step] of pending.entries()) {
76
+ io.say(`\n[${index + 1}/${pending.length}] ${step.title}`);
77
+ state.steps[step.id] =
78
+ !io.interactive && step.optional ? "skipped" : await step.run(io);
79
+ state.version = ONBOARDING_VERSION;
80
+ await saveOnboardingState(state);
81
+ }
82
+ await onboardStatus(steps, io.say);
83
+ const skipped = Object.entries(state.steps)
84
+ .filter(([, status]) => status === "skipped")
85
+ .map(([id]) => id);
86
+ io.say(`\nOnboarding finished.${skipped.length ? ` Skipped: ${skipped.join(", ")} (redo with ocean onboard --reset <step>).` : ""}`);
87
+ }
88
+ finally {
89
+ terminal?.close();
90
+ }
91
+ }
92
+ // Read-only: shows each step as done, skipped or pending, without running anything.
93
+ export async function onboardStatus(steps, say = console.log) {
94
+ const state = await loadOnboardingState();
95
+ for (const step of steps)
96
+ say(`${(state.steps[step.id] ?? "pending").padEnd(8)} ${step.id.padEnd(10)} ${step.title}`);
97
+ }
98
+ // Re-runs just the clients step (enable/disable + sync), independent of onboarding state.
99
+ export async function manageClients() {
100
+ const step = buildSteps(stepDependencies()).find((candidate) => candidate.id === "clients");
101
+ const terminal = terminalIO(Boolean(process.stdin.isTTY && process.stdout.isTTY));
102
+ try {
103
+ await step?.run(terminal.io);
104
+ }
105
+ finally {
106
+ terminal.close();
107
+ }
108
+ }
109
+ export async function runOnboardCommand(argv) {
110
+ if (argv.includes("--status")) {
111
+ await onboardStatus(buildSteps(stepDependencies()));
112
+ return;
113
+ }
114
+ const resetIndex = argv.indexOf("--reset");
115
+ const reset = resetIndex >= 0 ? argv[resetIndex + 1] : undefined;
116
+ if (resetIndex >= 0 && !reset) {
117
+ console.error("Usage: ocean onboard [--yes] [--status] [--reset <step>]");
118
+ process.exitCode = 1;
119
+ return;
120
+ }
121
+ await onboard({ yes: argv.includes("--yes"), reset });
122
+ }
123
+ //# sourceMappingURL=onboard-command.js.map
@@ -0,0 +1,59 @@
1
+ import { classifyIntent } from "@ocean/context/context/intent-router.js";
2
+ import { oceanRoot } from "@ocean/core/shared/paths.js";
3
+ import { knownTaskPrefixes } from "@ocean/core/shared/project-resolution.js";
4
+ import { operationForIntent, } from "@ocean/loop/operations/operation-contract.js";
5
+ import { runOperation } from "@ocean/loop/operations/record-operations.js";
6
+ import { guardedRunOperation, } from "@ocean/loop/operations/write-guard.js";
7
+ import { defaultBrainIndexPort } from "../../composition/runtime.js";
8
+ const OPERATION_BUDGET = {
9
+ maxFiles: 20,
10
+ maxBytes: 200_000,
11
+ maxChars: 50_000,
12
+ maxOperationCost: 10,
13
+ };
14
+ export async function runOperateCommand(text) {
15
+ const classification = classifyIntent(text, await knownTaskPrefixes());
16
+ const mapped = operationForIntent(classification);
17
+ if (!mapped.operation) {
18
+ console.log(JSON.stringify({
19
+ classification,
20
+ operation: null,
21
+ ok: false,
22
+ reason: mapped.reason,
23
+ }));
24
+ return;
25
+ }
26
+ const operation = mapped.operation;
27
+ const scope = {
28
+ action: operation,
29
+ target: oceanRoot(),
30
+ identifier: classification.identifier ?? null,
31
+ projectId: null,
32
+ };
33
+ const { decision, result } = await guardedRunOperation({
34
+ sessionId: "cli-operate",
35
+ classification,
36
+ scope,
37
+ budget: OPERATION_BUDGET,
38
+ }, async (approval) => runOperation(operation, classification, OPERATION_BUDGET, {
39
+ cwd: process.cwd(),
40
+ query: text,
41
+ approval: approval ?? undefined,
42
+ indexPort: defaultBrainIndexPort,
43
+ }));
44
+ console.log(JSON.stringify({
45
+ classification,
46
+ operation,
47
+ decision,
48
+ ...(result ?? { ok: false, reason: decision.reason }),
49
+ }));
50
+ if (!decision.allowed ||
51
+ (result &&
52
+ typeof result === "object" &&
53
+ "ok" in result &&
54
+ result.ok === false &&
55
+ operation.endsWith(".write"))) {
56
+ process.exitCode = 2;
57
+ }
58
+ }
59
+ //# sourceMappingURL=operate-command.js.map
@@ -0,0 +1,70 @@
1
+ import { selectProfileForTask } from "../../application/profiles/profile-suggestion.js";
2
+ import { applyProfileUpgrade, planProfileUpgrade, rollbackProfileUpgrade, validateProfiles, } from "../../application/profiles/profile-upgrade-service.js";
3
+ import { loadProfile } from "../../infrastructure/filesystem/profile-loader.js";
4
+ const usage = "Usage: ocean profiles validate | upgrade --check | --apply | --rollback | suggest --task <id> [--profile <name>]";
5
+ function print(value) {
6
+ console.log(JSON.stringify(value, null, 2));
7
+ }
8
+ export async function runProfilesCommand(args) {
9
+ const [action, mode] = args;
10
+ try {
11
+ if (action === "suggest") {
12
+ const value = (flag) => {
13
+ const index = args.indexOf(flag);
14
+ return index >= 0 ? args[index + 1] : undefined;
15
+ };
16
+ const task = value("--task");
17
+ if (!task)
18
+ throw new Error(usage);
19
+ print(await selectProfileForTask(task, {
20
+ cwd: process.cwd(),
21
+ override: value("--profile"),
22
+ }));
23
+ return;
24
+ }
25
+ if (action === "validate") {
26
+ const results = await validateProfiles(loadProfile);
27
+ print(results);
28
+ if (results.some((result) => !result.ok))
29
+ process.exitCode = 1;
30
+ return;
31
+ }
32
+ if (action === "upgrade" && mode === "--check") {
33
+ const plan = await planProfileUpgrade();
34
+ // The manifest shows what would change; the new file contents are not printed.
35
+ print(plan.map(({ next: _next, ...entry }) => entry));
36
+ if (plan.some((e) => e.status === "rejected" || e.status === "collision"))
37
+ process.exitCode = 1;
38
+ return;
39
+ }
40
+ if (action === "upgrade" && mode === "--apply") {
41
+ const result = await applyProfileUpgrade();
42
+ print({
43
+ applied: result.applied,
44
+ blocked: result.blocked.map(({ next: _next, ...entry }) => entry),
45
+ ...(result.applied.length
46
+ ? {
47
+ note: "Upgraded profiles have a new identity: sessions created before the upgrade cannot be resumed. `ocean profiles upgrade --rollback` restores the v1 files.",
48
+ }
49
+ : {}),
50
+ });
51
+ if (result.blocked.length)
52
+ process.exitCode = 1;
53
+ return;
54
+ }
55
+ if (action === "upgrade" && mode === "--rollback") {
56
+ const result = await rollbackProfileUpgrade();
57
+ print(result);
58
+ if (result.skipped.length)
59
+ process.exitCode = 1;
60
+ return;
61
+ }
62
+ console.error(usage);
63
+ process.exitCode = 1;
64
+ }
65
+ catch (error) {
66
+ console.error(error instanceof Error ? error.message : String(error));
67
+ process.exitCode = 1;
68
+ }
69
+ }
70
+ //# sourceMappingURL=profiles-command.js.map