@amoree-code/ocean 2.23.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -53
- package/dist/application/clients/bundles.js +1 -1
- package/dist/application/clients/client-detect.js +291 -0
- package/dist/application/clients/clients.js +104 -25
- package/dist/application/clients/desktop-link.js +40 -0
- package/dist/application/clients/desktop-watcher.js +6 -4
- package/dist/application/clients/hook-trust.js +106 -0
- package/dist/application/clients/hooks.js +7 -1
- package/dist/application/clients/mcp-schema-cost.js +74 -0
- package/dist/application/clients/native.js +38 -2
- package/dist/application/clients/registry.js +51 -9
- package/dist/application/clients/status.js +7 -2
- package/dist/application/gateway/webhook-gateway.js +1 -1
- package/dist/application/integrations/charter-copies.js +1 -1
- package/dist/application/integrations/engine-entry-repair.js +4 -3
- package/dist/application/integrations/skill-auto-sync.js +2 -2
- package/dist/application/integrations/skill-filter.js +1 -1
- package/dist/application/integrations/skill-router.js +134 -90
- package/dist/application/layout/layout-apply.js +1 -1
- package/dist/application/layout/workspace-template.js +1 -1
- package/dist/application/onboarding/steps.js +121 -30
- package/dist/application/profiles/profile-doctor.js +118 -0
- package/dist/application/profiles/profile-migration-service.js +208 -0
- package/dist/application/profiles/profile-suggestion.js +3 -7
- package/dist/application/profiles/profile-upgrade-service.js +98 -86
- package/dist/application/pull/history-index.js +1 -1
- package/dist/application/pull/project-match.js +3 -3
- package/dist/application/pull/pull.js +1 -1
- package/dist/application/pull/server-capture.js +92 -9
- package/dist/application/scheduler/local-scheduler.js +2 -2
- package/dist/application/spend/claude-prices.js +55 -0
- package/dist/application/spend/claude-spend.js +365 -0
- package/dist/application/uninstall/uninstall.js +25 -3
- package/dist/application/upkeep/nightly-upkeep.js +4 -4
- package/dist/composition/runtime.js +2 -2
- package/dist/infrastructure/desktop/claude-export.js +1 -1
- package/dist/infrastructure/desktop/desktop-chat.js +60 -13
- package/dist/infrastructure/desktop/indexeddb.js +4 -4
- package/dist/infrastructure/desktop/leveldb.js +2 -2
- package/dist/infrastructure/filesystem/profile-loader.js +3 -45
- package/dist/infrastructure/filesystem/runtime-config-loader.js +1 -1
- package/dist/infrastructure/observability/runtime-logger.js +1 -1
- package/dist/infrastructure/process/agent-tool-executor.js +3 -3
- package/dist/infrastructure/process/process-supervisor.js +1 -1
- package/dist/infrastructure/process/service.js +8 -8
- package/dist/infrastructure/providers/openai-compatible.js +2 -2
- package/dist/infrastructure/providers/provider-invocation.js +1 -1
- package/dist/infrastructure/providers/session-facts-completer.js +78 -5
- package/dist/interfaces/cli/auth-command.js +2 -2
- package/dist/interfaces/cli/brief-command.js +1 -1
- package/dist/interfaces/cli/browser-command.js +6 -6
- package/dist/interfaces/cli/browser-findings.js +6 -9
- package/dist/interfaces/cli/browser-settings.js +10 -10
- package/dist/interfaces/cli/capture-command.js +6 -6
- package/dist/interfaces/cli/client-test-command.js +3 -3
- package/dist/interfaces/cli/clients-command.js +33 -6
- package/dist/interfaces/cli/command-aliases.js +56 -0
- package/dist/interfaces/cli/command-registry.js +48 -1414
- package/dist/interfaces/cli/commands/browser.js +5 -0
- package/dist/interfaces/cli/commands/capture.js +19 -0
- package/dist/interfaces/cli/commands/catalog.js +9 -0
- package/dist/interfaces/cli/commands/client.js +135 -0
- package/dist/interfaces/cli/commands/clients.js +33 -0
- package/dist/interfaces/cli/commands/connectors.js +14 -0
- package/dist/interfaces/cli/commands/context.js +9 -0
- package/dist/interfaces/cli/commands/cost.js +15 -0
- package/dist/interfaces/cli/commands/daily.js +11 -0
- package/dist/interfaces/cli/commands/day.js +25 -0
- package/dist/interfaces/cli/commands/dispatch.js +31 -0
- package/dist/interfaces/cli/commands/doctor.js +60 -0
- package/dist/interfaces/cli/commands/env.js +5 -0
- package/dist/interfaces/cli/commands/gateway.js +16 -0
- package/dist/interfaces/cli/commands/handoff.js +11 -0
- package/dist/interfaces/cli/commands/health.js +17 -0
- package/dist/interfaces/cli/commands/hook.js +142 -0
- package/dist/interfaces/cli/commands/idea.js +11 -0
- package/dist/interfaces/cli/commands/install.js +31 -0
- package/dist/interfaces/cli/commands/intent.js +14 -0
- package/dist/interfaces/cli/commands/intercept.js +22 -0
- package/dist/interfaces/cli/commands/layout.js +11 -0
- package/dist/interfaces/cli/commands/lifecycle.js +5 -0
- package/dist/interfaces/cli/commands/loop.js +73 -0
- package/dist/interfaces/cli/commands/market.js +11 -0
- package/dist/interfaces/cli/commands/mcp.js +57 -0
- package/dist/interfaces/cli/commands/memory.js +5 -0
- package/dist/interfaces/cli/commands/migrate.js +5 -0
- package/dist/interfaces/cli/commands/observe.js +11 -0
- package/dist/interfaces/cli/commands/obsidian.js +111 -0
- package/dist/interfaces/cli/commands/operate.js +7 -0
- package/dist/interfaces/cli/commands/policy.js +16 -0
- package/dist/interfaces/cli/commands/project.js +207 -0
- package/dist/interfaces/cli/commands/repair.js +20 -0
- package/dist/interfaces/cli/commands/run.js +52 -0
- package/dist/interfaces/cli/commands/schedule.js +58 -0
- package/dist/interfaces/cli/commands/service.js +21 -0
- package/dist/interfaces/cli/commands/session.js +182 -0
- package/dist/interfaces/cli/commands/sessions.js +12 -0
- package/dist/interfaces/cli/commands/setup.js +21 -0
- package/dist/interfaces/cli/commands/skill.js +159 -0
- package/dist/interfaces/cli/commands/tasks.js +10 -0
- package/dist/interfaces/cli/commands/update-remove.js +25 -0
- package/dist/interfaces/cli/connectors-command.js +150 -0
- package/dist/interfaces/cli/context-command.js +39 -3
- package/dist/interfaces/cli/cost-command.js +104 -0
- package/dist/interfaces/cli/curator-command.js +1 -1
- package/dist/interfaces/cli/daily-command.js +7 -1
- package/dist/interfaces/cli/desktop-command.js +43 -7
- package/dist/interfaces/cli/distill-command.js +7 -2
- package/dist/interfaces/cli/express-command.js +1 -1
- package/dist/interfaces/cli/failures-command.js +4 -4
- package/dist/interfaces/cli/gateway-findings.js +2 -2
- package/dist/interfaces/cli/governance-command.js +23 -16
- package/dist/interfaces/cli/handoff-command.js +1 -1
- package/dist/interfaces/cli/harvest-command.js +2 -2
- package/dist/interfaces/cli/help-command.js +53 -169
- package/dist/interfaces/cli/hygiene-command.js +1 -1
- package/dist/interfaces/cli/idea-command.js +1 -1
- package/dist/interfaces/cli/intercept-command.js +8 -7
- package/dist/interfaces/cli/interests-command.js +1 -1
- package/dist/interfaces/cli/layout-command.js +2 -0
- package/dist/interfaces/cli/market-command.js +9 -9
- package/dist/interfaces/cli/mcp-gateway-command.js +124 -7
- package/dist/interfaces/cli/mcp-probe-command.js +186 -0
- package/dist/interfaces/cli/mcp-status-command.js +5 -5
- package/dist/interfaces/cli/memory-command.js +41 -7
- package/dist/interfaces/cli/migrate-command.js +2 -2
- package/dist/interfaces/cli/note-command.js +1 -1
- package/dist/interfaces/cli/onboard-command.js +14 -0
- package/dist/interfaces/cli/operate-command.js +5 -5
- package/dist/interfaces/cli/profiles-command.js +61 -1
- package/dist/interfaces/cli/rhythm-command.js +11 -5
- package/dist/interfaces/cli/running-server-findings.js +1 -1
- package/dist/interfaces/cli/scorecard-command.js +8 -8
- package/dist/interfaces/cli/session-facts-command.js +2 -2
- package/dist/interfaces/cli/sessions-command.js +145 -0
- package/dist/interfaces/cli/setup-command.js +15 -2
- package/dist/interfaces/cli/tasks-command.js +63 -13
- package/dist/interfaces/cli/telemetry-command.js +4 -4
- package/dist/interfaces/cli/uninstall-command.js +1 -1
- package/dist/interfaces/cli/week-failures.js +32 -0
- package/dist/main.js +12 -0
- package/node_modules/@ocean/brain/dist/{infrastructure/brain/brain-index.js → brain-index.js} +2 -2
- package/node_modules/@ocean/brain/dist/{brain/brain-markdown.js → brain-markdown.js} +1 -1
- package/node_modules/@ocean/brain/dist/{brain/brain-service.js → brain-service.js} +12 -2
- package/node_modules/@ocean/brain/dist/memory/brain-dump.js +92 -16
- package/node_modules/@ocean/brain/dist/memory/extraction-log.js +125 -0
- package/node_modules/@ocean/brain/dist/memory/extraction-retry.js +54 -0
- package/node_modules/@ocean/brain/dist/memory/fact-routing.js +44 -1
- package/node_modules/@ocean/brain/dist/memory/lesson-activation.js +2 -2
- package/node_modules/@ocean/brain/dist/memory/lesson-learning.js +2 -2
- package/node_modules/@ocean/brain/dist/memory/lessons.js +1 -1
- package/node_modules/@ocean/brain/dist/memory/memory-audit.js +2 -2
- package/node_modules/@ocean/brain/dist/memory/memory-harvest.js +1 -1
- package/node_modules/@ocean/brain/dist/memory/memory-paths.js +8 -0
- package/node_modules/@ocean/brain/dist/memory/memory-review.js +31 -3
- package/node_modules/@ocean/brain/dist/memory/memory-trash.js +29 -0
- package/node_modules/@ocean/brain/dist/memory/memory-write.js +4 -2
- package/node_modules/@ocean/brain/dist/memory/model-narrative.js +2 -2
- package/node_modules/@ocean/brain/dist/memory/profile-facts.js +1 -1
- package/node_modules/@ocean/brain/dist/memory/routing.json +6 -6
- package/node_modules/@ocean/{market/dist/skills → brain/dist/memory}/signal-detection.js +1 -1
- package/node_modules/@ocean/brain/dist/{memory → people}/people.js +1 -1
- package/node_modules/@ocean/brain/dist/sessions-capture/session-facts.js +625 -0
- package/node_modules/@ocean/brain/dist/{memory → sessions-capture}/session-promotion.js +7 -15
- package/node_modules/@ocean/brain/dist/{memory → sessions-capture}/session-summary.js +1 -1
- package/node_modules/@ocean/brain/dist/sessions-capture/session-triage.js +52 -0
- package/node_modules/@ocean/brain/package.json +1 -1
- package/node_modules/@ocean/connect/dist/connectors/connector-hub.js +173 -0
- package/node_modules/@ocean/{market → connect}/dist/install/default-marketplace.js +6 -2
- package/node_modules/@ocean/{market → connect}/dist/install/marketplace-service.js +1 -1
- package/node_modules/@ocean/connect/dist/mcp/mcp-gateway.js +987 -0
- package/node_modules/@ocean/{market → connect}/dist/mcp/mcp-launch.js +102 -5
- package/node_modules/@ocean/{market → connect}/dist/registry/official-registry.js +1 -1
- package/node_modules/@ocean/{market → connect}/dist/security/permissions.js +1 -1
- package/node_modules/@ocean/{market → connect}/dist/skills/skill-hub.js +104 -6
- package/node_modules/@ocean/{market → connect}/package.json +2 -2
- package/node_modules/@ocean/context/dist/{context/context-ladder.js → context-ladder.js} +3 -3
- package/node_modules/@ocean/context/dist/{context/context-references.js → context-references.js} +5 -4
- package/node_modules/@ocean/context/dist/{context/context-cost.js → context-size.js} +6 -6
- package/node_modules/@ocean/context/dist/{context/intent-router.js → intent-router.js} +1 -1
- package/node_modules/@ocean/context/dist/{context/resource-injection.js → resource-injection.js} +3 -1
- package/node_modules/@ocean/context/package.json +1 -1
- package/node_modules/@ocean/core/dist/domain/brain/brain-record.js +1 -1
- package/node_modules/@ocean/core/dist/domain/capabilities/capability-manifest.js +5 -5
- package/node_modules/@ocean/core/dist/domain/connector-entry.js +86 -0
- package/node_modules/@ocean/core/dist/domain/context/context.js +1 -1
- package/node_modules/@ocean/core/dist/domain/context/project-id.js +8 -2
- package/node_modules/@ocean/core/dist/domain/{evidence/evidence.js → evidence.js} +1 -1
- package/node_modules/@ocean/core/dist/domain/mcp/memory-contract.js +4 -1
- package/node_modules/@ocean/core/dist/domain/ports/brain-index-port.js +1 -1
- package/node_modules/@ocean/core/dist/domain/profiles/profile-markdown.js +40 -0
- package/node_modules/@ocean/core/dist/domain/profiles/profile-resolution.js +276 -0
- package/node_modules/@ocean/core/dist/domain/profiles/profile-selection.js +23 -60
- package/node_modules/@ocean/core/dist/domain/profiles/profile-upgrade.js +2 -2
- package/node_modules/@ocean/core/dist/domain/profiles/profile.js +66 -6
- package/node_modules/@ocean/core/dist/domain/profiles/runtime-config.js +1 -1
- package/node_modules/@ocean/core/dist/domain/runs/agent-tools.js +2 -2
- package/node_modules/@ocean/core/dist/domain/sessions/session-identity.js +53 -0
- package/node_modules/@ocean/core/dist/domain/sessions/session-metadata.js +208 -0
- package/node_modules/@ocean/core/dist/domain/{tasks/task-id.js → task-id.js} +2 -2
- package/node_modules/@ocean/core/dist/profiles/profile-files.js +57 -0
- package/node_modules/@ocean/core/dist/profiles/profile-loader.js +97 -0
- package/node_modules/@ocean/core/dist/profiles/project-profile-fill.js +33 -0
- package/node_modules/@ocean/core/dist/profiles/session-profile.js +158 -0
- package/node_modules/@ocean/core/dist/shared/charter.js +110 -0
- package/node_modules/@ocean/core/dist/shared/context-ack.js +1 -1
- package/node_modules/@ocean/core/dist/shared/context-triggers.js +67 -0
- package/node_modules/@ocean/core/dist/shared/paths.js +6 -6
- package/node_modules/@ocean/core/dist/shared/project-legacy.js +232 -0
- package/node_modules/@ocean/core/dist/shared/project-manifest.js +308 -0
- package/node_modules/@ocean/core/dist/shared/project-names.js +87 -0
- package/node_modules/@ocean/core/dist/shared/project-register.js +560 -0
- package/node_modules/@ocean/core/dist/shared/project-resolution.js +83 -861
- package/node_modules/@ocean/core/dist/shared/repo-signals.js +45 -0
- package/node_modules/@ocean/core/dist/shared/task-reference.js +1 -1
- package/node_modules/@ocean/core/dist/shared/text-tokens.js +37 -0
- package/node_modules/@ocean/core/dist/shared/tool-groups.js +224 -0
- package/node_modules/@ocean/core/package.json +4 -1
- package/node_modules/@ocean/services/dist/day/day.js +45 -3
- package/node_modules/@ocean/services/dist/{distill → day}/distill.js +29 -3
- package/node_modules/@ocean/services/dist/{harvest → day}/harvest.js +54 -14
- package/node_modules/@ocean/services/dist/{brief → day}/interest-discovery.js +3 -3
- package/node_modules/@ocean/services/dist/day/note.js +2 -2
- package/node_modules/@ocean/services/dist/{onboarding → day}/onboarding.js +1 -1
- package/node_modules/@ocean/services/dist/day/patterns.js +68 -0
- package/node_modules/@ocean/services/dist/{curator → health}/curator.js +5 -5
- package/node_modules/@ocean/services/dist/{journey → health}/failures.js +7 -5
- package/node_modules/@ocean/services/dist/{hygiene → health}/hygiene.js +2 -2
- package/node_modules/@ocean/services/dist/{journey → health}/lesson-effect.js +1 -1
- package/node_modules/@ocean/services/dist/{scorecard → health}/scorecard.js +3 -3
- package/node_modules/@ocean/services/dist/{upkeep → health}/upkeep.js +2 -2
- package/node_modules/@ocean/services/dist/{doctor → health}/workspace-doctor.js +57 -17
- package/node_modules/@ocean/services/dist/{browser → integrations/browser}/browser-session.js +1 -1
- package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/call-ledger.js +3 -0
- package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/mcp-client.js +19 -3
- package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/obsidian-server.js +4 -4
- package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/ocean-server.js +423 -34
- package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/conflict-log.js +1 -1
- package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/folder-templates.js +8 -5
- package/node_modules/@ocean/services/dist/projects/project-doctor.js +173 -0
- package/node_modules/@ocean/services/dist/projects/project-snippet.js +9 -0
- package/node_modules/@ocean/services/dist/projects/projects-overview.js +2 -2
- package/node_modules/@ocean/services/package.json +1 -1
- package/node_modules/@ocean/{loop/dist/loops → work/dist/runs}/guard-runtime.js +3 -3
- package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/memory-knowledge-operations.js +4 -12
- package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/operation-contract.js +2 -2
- package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/project-operations.js +2 -1
- package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/task-operations.js +4 -4
- package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/write-guard.js +1 -1
- package/node_modules/@ocean/{loop → work}/dist/runs/prompt-assembly.js +2 -2
- package/node_modules/@ocean/{loop → work}/dist/runs/run-agent.js +4 -4
- package/node_modules/@ocean/{loop → work}/dist/runs/tool-loop.js +4 -4
- package/node_modules/@ocean/work/dist/sessions/hooks/desktop-facts.js +309 -0
- package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/session-end-hook.js +36 -5
- package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/session-facts-hook.js +144 -14
- package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/session-start-hook.js +129 -12
- package/node_modules/@ocean/work/dist/sessions/hooks/start-brief.js +110 -0
- package/node_modules/@ocean/work/dist/sessions/hooks/unlinked-warning.js +68 -0
- package/node_modules/@ocean/{loop → work}/dist/sessions/session-closeout.js +4 -4
- package/node_modules/@ocean/{loop → work}/dist/sessions/session-projects.js +13 -3
- package/node_modules/@ocean/work/dist/sessions/session-relink.js +300 -0
- package/node_modules/@ocean/{loop → work}/dist/sessions/session-retention.js +1 -1
- package/node_modules/@ocean/{loop → work}/dist/tasks/list-tasks.js +7 -2
- package/node_modules/@ocean/{loop → work}/dist/tasks/renumber-tasks.js +4 -2
- package/node_modules/@ocean/{loop → work}/dist/tasks/session-task.js +2 -2
- package/node_modules/@ocean/{loop → work}/dist/tasks/sync-task-prs.js +77 -7
- package/node_modules/@ocean/work/dist/tasks/task-git.js +63 -0
- package/node_modules/@ocean/{loop/dist/loops → work/dist/tasks}/task-loop.js +4 -4
- package/node_modules/@ocean/{loop → work}/dist/tasks/verification-readiness.js +1 -1
- package/node_modules/@ocean/{loop → work}/dist/tasks/verify-task.js +1 -1
- package/node_modules/@ocean/{loop → work}/package.json +2 -2
- package/ocean-marketplace.json +41 -41
- package/package.json +12 -11
- package/skills/core/daily-harvest/SKILL.md +1 -1
- package/skills/core/ocean-memory/SKILL.md +4 -0
- package/skills/core/use-browser/SKILL.md +30 -7
- package/skills/index.json +1 -1
- package/templates/profiles/default.md +44 -0
- package/templates/profiles/developer.md +45 -0
- package/templates/profiles/reviewer.md +44 -0
- package/templates/profiles/strategist.md +44 -0
- package/templates/profiles-v3/analysis.md +16 -0
- package/templates/profiles-v3/backend.md +16 -0
- package/templates/profiles-v3/base.md +57 -0
- package/templates/profiles-v3/code-review.md +16 -0
- package/templates/profiles-v3/devops.md +16 -0
- package/templates/profiles-v3/docs-office.md +16 -0
- package/templates/profiles-v3/frontend.md +16 -0
- package/templates/profiles-v3/learning.md +16 -0
- package/templates/profiles-v3/marketing-ads.md +16 -0
- package/templates/profiles-v3/marketing-content-seo.md +16 -0
- package/templates/profiles-v3/ocean-ops.md +16 -0
- package/templates/profiles-v3/product-strategy.md +16 -0
- package/templates/profiles-v3/qa-testing.md +16 -0
- package/templates/profiles-v3/security.md +16 -0
- package/templates/workspace/MANIFEST.json +1 -0
- package/templates/workspace/charter/core.md +22 -90
- package/templates/workspace/charter/policies/README.md +7 -1
- package/templates/workspace/charter/policies/claude-code-context.md +6 -1
- package/templates/workspace/charter/policies/concise-output.md +5 -0
- package/templates/workspace/charter/policies/context.md +5 -0
- package/templates/workspace/charter/policies/contracts/task.md +2 -2
- package/templates/workspace/charter/policies/git.md +5 -0
- package/templates/workspace/charter/policies/graph.md +6 -1
- package/templates/workspace/charter/policies/knowledge.md +11 -4
- package/templates/workspace/charter/policies/layout.md +23 -0
- package/templates/workspace/charter/policies/lifecycle.md +5 -0
- package/templates/workspace/charter/policies/memory.md +5 -0
- package/templates/workspace/charter/policies/minimal-change.md +5 -0
- package/templates/workspace/charter/policies/models.md +5 -0
- package/templates/workspace/charter/policies/response.md +5 -0
- package/templates/workspace/charter/policies/skill-observer.md +12 -0
- package/templates/workspace/charter/policies/stack.md +5 -0
- package/templates/workspace/charter/policies/task.md +17 -3
- package/templates/workspace/charter/policies/verification.md +5 -0
- package/node_modules/@ocean/brain/dist/evidence/verification-report.js +0 -13
- package/node_modules/@ocean/brain/dist/memory/daily-narrative.js +0 -142
- package/node_modules/@ocean/brain/dist/memory/session-facts.js +0 -283
- package/node_modules/@ocean/context/dist/context/context-compression.js +0 -66
- package/node_modules/@ocean/loop/dist/hooks/desktop-facts.js +0 -174
- package/node_modules/@ocean/loop/dist/operations/task-linker.js +0 -40
- package/node_modules/@ocean/loop/dist/sessions/session-pointer.js +0 -133
- package/node_modules/@ocean/loop/dist/tasks/task-git.js +0 -28
- package/node_modules/@ocean/market/dist/mcp/mcp-gateway.js +0 -533
- package/templates/profiles/default.json +0 -51
- package/templates/profiles/developer.json +0 -51
- package/templates/profiles/reviewer.json +0 -51
- package/templates/profiles/strategist.json +0 -51
- /package/node_modules/@ocean/brain/dist/{brain/brain-eval.js → brain-eval.js} +0 -0
- /package/node_modules/@ocean/brain/dist/{brain/brain-reindex.js → brain-reindex.js} +0 -0
- /package/node_modules/@ocean/brain/dist/{capture → sessions-capture}/inbox-sync.js +0 -0
- /package/node_modules/@ocean/{market → connect}/dist/adapters/mcp-adapter.js +0 -0
- /package/node_modules/@ocean/{market → connect}/dist/adapters/owned-directory.js +0 -0
- /package/node_modules/@ocean/{market → connect}/dist/adapters/plugin-adapter.js +0 -0
- /package/node_modules/@ocean/{market → connect}/dist/adapters/skill-adapter.js +0 -0
- /package/node_modules/@ocean/{market → connect}/dist/capability/adapter.js +0 -0
- /package/node_modules/@ocean/{market → connect}/dist/capability/catalog.js +0 -0
- /package/node_modules/@ocean/{market → connect}/dist/capability/content-digest.js +0 -0
- /package/node_modules/@ocean/{market → connect}/dist/capability/registry.js +0 -0
- /package/node_modules/@ocean/{market → connect}/dist/install/lock.js +0 -0
- /package/node_modules/@ocean/{market → connect}/dist/install/own-server.js +0 -0
- /package/node_modules/@ocean/{market → connect}/dist/mcp/chrome-debugging.js +0 -0
- /package/node_modules/@ocean/{market → connect}/dist/mcp/mcp-connection.js +0 -0
- /package/node_modules/@ocean/{market → connect}/dist/mcp/mcp-runner.js +0 -0
- /package/node_modules/@ocean/{market → connect}/dist/security/description-scan.js +0 -0
- /package/node_modules/@ocean/{market → connect}/dist/security/secrets.js +0 -0
- /package/node_modules/@ocean/{market → connect}/dist/skills/core-skill-sync.js +0 -0
- /package/node_modules/@ocean/context/dist/{context/context-packet.js → context-packet.js} +0 -0
- /package/node_modules/@ocean/core/dist/domain/{process/process-events.js → process-events.js} +0 -0
- /package/node_modules/@ocean/core/dist/domain/{redaction/redaction.js → redaction.js} +0 -0
- /package/node_modules/@ocean/services/dist/{brief → day}/brief.js +0 -0
- /package/node_modules/@ocean/services/dist/{express → day}/express.js +0 -0
- /package/node_modules/@ocean/services/dist/{brief → day}/source-registry.json +0 -0
- /package/node_modules/@ocean/services/dist/{journey → health}/telemetry.js +0 -0
- /package/node_modules/@ocean/services/dist/{browser → integrations/browser}/browser-service.js +0 -0
- /package/node_modules/@ocean/services/dist/{browser → integrations/browser}/browser-task-runner.js +0 -0
- /package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/mcp-session.js +0 -0
- /package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/server-version.js +0 -0
- /package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/tool-registry.js +0 -0
- /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/inbox-promotion.js +0 -0
- /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-discovery.js +0 -0
- /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-ingestion.js +0 -0
- /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-sync.js +0 -0
- /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-writer.js +0 -0
- /package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/operation-scope.js +0 -0
- /package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/record-io.js +0 -0
- /package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/record-operations.js +0 -0
- /package/node_modules/@ocean/{loop → work}/dist/runs/run-authorization.js +0 -0
- /package/node_modules/@ocean/{loop → work}/dist/runs/session-tokens.js +0 -0
- /package/node_modules/@ocean/{loop/dist/handoff → work/dist/sessions}/handoff-service.js +0 -0
- /package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/lifecycle-hooks.js +0 -0
- /package/node_modules/@ocean/{loop/dist/infrastructure/persistence → work/dist/sessions}/session-store.js +0 -0
- /package/node_modules/@ocean/{loop/dist/infrastructure/persistence → work/dist/sessions}/session-validator.js +0 -0
- /package/node_modules/@ocean/{loop → work}/dist/tasks/archive-tasks.js +0 -0
- /package/node_modules/@ocean/{loop → work}/dist/tasks/checkpoint-task.js +0 -0
- /package/node_modules/@ocean/{loop → work}/dist/tasks/claim-task.js +0 -0
- /package/node_modules/@ocean/{loop/dist/loops → work/dist/tasks}/iteration-graph.js +0 -0
- /package/node_modules/@ocean/{loop → work}/dist/tasks/new-task.js +0 -0
- /package/node_modules/@ocean/{loop/dist/loops → work/dist/tasks}/task-loop-record.js +0 -0
- /package/node_modules/@ocean/{loop → work}/dist/tasks/task-verification.js +0 -0
|
@@ -1,1426 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import { runOceanMcpServer } from "@ocean/services/infrastructure/mcp/ocean-server.js";
|
|
27
|
-
import { parseConflictSide, resolveConflict, } from "@ocean/services/obsidian/conflict-log.js";
|
|
28
|
-
import { syncFolderTemplates, syncQuickAddChoices, } from "@ocean/services/obsidian/folder-templates.js";
|
|
29
|
-
import { listInboxCandidates, promoteInboxNote, } from "@ocean/services/obsidian/inbox-promotion.js";
|
|
30
|
-
import { connectObsidianVault, discoverObsidianVault, loadObsidianConnection, } from "@ocean/services/obsidian/vault-discovery.js";
|
|
31
|
-
import { syncObsidianVault, watchObsidianVault, } from "@ocean/services/obsidian/vault-sync.js";
|
|
32
|
-
import { writeObsidianNote } from "@ocean/services/obsidian/vault-writer.js";
|
|
33
|
-
import { overviewTable, projectsOverview, writeRegistryBlock, } from "@ocean/services/projects/projects-overview.js";
|
|
34
|
-
import { clientFindings, repairClients, } from "../../application/clients/clients.js";
|
|
35
|
-
import { desktopWatcherFindings } from "../../application/clients/desktop-watcher.js";
|
|
36
|
-
import { nativeFindings } from "../../application/clients/native.js";
|
|
37
|
-
import { MCP_ONLY_CLIENTS, mcpClientOf, } from "../../application/clients/registry.js";
|
|
38
|
-
import { createWebhookGateway } from "../../application/gateway/webhook-gateway.js";
|
|
39
|
-
import { findInstallSpec, installPlan, installProvider, listInstallSpecs, removeInstalledProvider, updateProvider, } from "../../application/install/provider-installer.js";
|
|
40
|
-
import { syncCharterCopies } from "../../application/integrations/charter-copies.js";
|
|
41
|
-
import { configureClaudeCodeWrapper } from "../../application/integrations/claude-vscode.js";
|
|
42
|
-
import { repairEngineEntries } from "../../application/integrations/engine-entry-repair.js";
|
|
43
|
-
import { autoSyncSkills } from "../../application/integrations/skill-auto-sync.js";
|
|
44
|
-
import { syncSkillFilter } from "../../application/integrations/skill-filter.js";
|
|
45
|
-
import { buildSkillIndex, loadSkillIndex, PROMPT_HOOK_CLIENTS, projectSignals, ROUTE_THRESHOLD, routerLine, routeSkills, skillRouterHook, } from "../../application/integrations/skill-router.js";
|
|
46
|
-
import { selectProfileForTask } from "../../application/profiles/profile-suggestion.js";
|
|
47
|
-
import { listSchedules, runDueSchedules, runSchedule, runSchedulerWorker, runSchedulerWorkerOnce, saveSchedule, setScheduleEnabled, } from "../../application/scheduler/local-scheduler.js";
|
|
48
|
-
import { defaultAgentRuntime, defaultBrainIndexPort, defaultProviderRegistry, defaultSessionStoreFactory, defaultSessionStoreOpener, defaultWrapperManager, } from "../../composition/runtime.js";
|
|
49
|
-
import { loadRuntimeConfig } from "../../infrastructure/filesystem/runtime-config-loader.js";
|
|
50
|
-
import { ensureService, restartService, runService, startBackgroundPull, startBackgroundRhythm, startBackgroundTaskSync, } from "../../infrastructure/process/service.js";
|
|
51
|
-
import { createOllamaEmbedder } from "../../infrastructure/providers/ollama-embedder.js";
|
|
52
|
-
import { loadProviderRegistry } from "../../infrastructure/providers/provider-registry.js";
|
|
53
|
-
import { installShellPath, registerProvider, setProviderEnabled, syncProviderWrappers, wrapperDoctor, wrapperStatus, } from "../../infrastructure/wrappers/wrapper-manager.js";
|
|
54
|
-
import { runAuthCommand } from "./auth-command.js";
|
|
55
|
-
import { runBriefCommand } from "./brief-command.js";
|
|
56
|
-
import { runBrowserCommand } from "./browser-command.js";
|
|
57
|
-
import { browserFindings } from "./browser-findings.js";
|
|
58
|
-
import { runBrowserServiceCommand } from "./browser-service-command.js";
|
|
59
|
-
import { runCaptureCommand } from "./capture-command.js";
|
|
60
|
-
import { runClientTestCommand } from "./client-test-command.js";
|
|
61
|
-
import { runClientsCommand } from "./clients-command.js";
|
|
62
|
-
import { runContextCommand, runContextCostCommand } from "./context-command.js";
|
|
63
|
-
import { runCuratorCommand } from "./curator-command.js";
|
|
64
|
-
import { runDailyCommand } from "./daily-command.js";
|
|
65
|
-
import { runDesktopCommand } from "./desktop-command.js";
|
|
66
|
-
import { runDistillCommand } from "./distill-command.js";
|
|
67
|
-
import { runExpressCommand } from "./express-command.js";
|
|
68
|
-
import { runFailuresCommand } from "./failures-command.js";
|
|
69
|
-
import { gatewayFindings } from "./gateway-findings.js";
|
|
70
|
-
import { runLifecycleCommand, runPolicyCommand } from "./governance-command.js";
|
|
71
|
-
import { runHandoffCommand } from "./handoff-command.js";
|
|
72
|
-
import { runHarvestCommand } from "./harvest-command.js";
|
|
73
|
-
import { runIdeaCommand } from "./idea-command.js";
|
|
74
|
-
import { intercept } from "./intercept-command.js";
|
|
75
|
-
import { runInterestsCommand } from "./interests-command.js";
|
|
76
|
-
import { runLayoutCommand } from "./layout-command.js";
|
|
77
|
-
import { runMarketCommand } from "./market-command.js";
|
|
78
|
-
import { runMcpGatewayCommand } from "./mcp-gateway-command.js";
|
|
79
|
-
import { runMcpStatusCommand } from "./mcp-status-command.js";
|
|
80
|
-
import { runMemoryCommand } from "./memory-command.js";
|
|
81
|
-
import { runMigrateCommand } from "./migrate-command.js";
|
|
82
|
-
import { runNoteCommand } from "./note-command.js";
|
|
83
|
-
import { runObserveCommand } from "./observe-command.js";
|
|
84
|
-
import { manageClients, runOnboardCommand } from "./onboard-command.js";
|
|
85
|
-
import { runOperateCommand } from "./operate-command.js";
|
|
1
|
+
import { commandBrowser } from "./commands/browser.js";
|
|
2
|
+
import { commandCapture } from "./commands/capture.js";
|
|
3
|
+
import { commandClients } from "./commands/clients.js";
|
|
4
|
+
import { commandConnectors } from "./commands/connectors.js";
|
|
5
|
+
import { commandContext } from "./commands/context.js";
|
|
6
|
+
import { commandCost } from "./commands/cost.js";
|
|
7
|
+
import { commandDay } from "./commands/day.js";
|
|
8
|
+
import { commandDoctor } from "./commands/doctor.js";
|
|
9
|
+
import { commandHealth } from "./commands/health.js";
|
|
10
|
+
import { commandHook } from "./commands/hook.js";
|
|
11
|
+
import { commandIntercept } from "./commands/intercept.js";
|
|
12
|
+
import { commandLayout } from "./commands/layout.js";
|
|
13
|
+
import { commandMcp } from "./commands/mcp.js";
|
|
14
|
+
import { commandMemory } from "./commands/memory.js";
|
|
15
|
+
import { commandMigrate } from "./commands/migrate.js";
|
|
16
|
+
import { commandObsidian } from "./commands/obsidian.js";
|
|
17
|
+
import { commandPolicy } from "./commands/policy.js";
|
|
18
|
+
import { commandProject } from "./commands/project.js";
|
|
19
|
+
import { commandRun } from "./commands/run.js";
|
|
20
|
+
import { commandSchedule } from "./commands/schedule.js";
|
|
21
|
+
import { commandService } from "./commands/service.js";
|
|
22
|
+
import { commandSessions } from "./commands/sessions.js";
|
|
23
|
+
import { commandSetup } from "./commands/setup.js";
|
|
24
|
+
import { commandSkill } from "./commands/skill.js";
|
|
25
|
+
import { commandTasks } from "./commands/tasks.js";
|
|
86
26
|
import { runProfilesCommand } from "./profiles-command.js";
|
|
87
|
-
import { runPullCommand } from "./pull-command.js";
|
|
88
|
-
import { runRhythmCommand } from "./rhythm-command.js";
|
|
89
|
-
import { runningServerFindings } from "./running-server-findings.js";
|
|
90
|
-
import { runScorecardCommand } from "./scorecard-command.js";
|
|
91
|
-
import { insideFactsCall, runSessionFactsCommand, startSessionFacts, } from "./session-facts-command.js";
|
|
92
|
-
import { parseSetupArgs, SETUP_USAGE, setup } from "./setup-command.js";
|
|
93
|
-
import { runTasksCommand } from "./tasks-command.js";
|
|
94
|
-
import { runTelemetryCommand } from "./telemetry-command.js";
|
|
95
27
|
import { runUninstallCommand } from "./uninstall-command.js";
|
|
96
|
-
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
function mcpEmbedder() {
|
|
100
|
-
let ready = null;
|
|
101
|
-
return async () => {
|
|
102
|
-
if (!ready)
|
|
103
|
-
ready = await createOllamaEmbedder().catch(() => null);
|
|
104
|
-
return ready;
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
async function commandSetup() {
|
|
108
|
-
const parsed = parseSetupArgs(process.argv.slice(3));
|
|
109
|
-
if (parsed.kind === "help")
|
|
110
|
-
console.log(SETUP_USAGE);
|
|
111
|
-
else if (parsed.kind === "error") {
|
|
112
|
-
console.error(`${parsed.message}\n${SETUP_USAGE}`);
|
|
113
|
-
process.exitCode = 1;
|
|
114
|
-
}
|
|
115
|
-
else
|
|
116
|
-
await setup(parsed.options);
|
|
117
|
-
}
|
|
118
|
-
async function commandService() {
|
|
119
|
-
// `ocean service restart` (T-307): a new build reaches the service without unloading it.
|
|
120
|
-
if (process.argv[3] === "restart") {
|
|
121
|
-
const restarted = await restartService({ reload: false });
|
|
122
|
-
console.log(JSON.stringify({ service: restarted }, null, 2));
|
|
123
|
-
if (typeof restarted === "object")
|
|
124
|
-
process.exitCode = 1;
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const shutdownAfterMs = Number(oceanEnv("SERVICE_TEST_SHUTDOWN_MS"));
|
|
128
|
-
await runService(Number.isFinite(shutdownAfterMs) && shutdownAfterMs > 0
|
|
129
|
-
? shutdownAfterMs
|
|
130
|
-
: undefined);
|
|
131
|
-
}
|
|
132
|
-
async function commandIntercept() {
|
|
133
|
-
const clientIndex = process.argv.indexOf("--client");
|
|
134
|
-
const executableIndex = process.argv.indexOf("--executable");
|
|
135
|
-
const separatorIndex = process.argv.indexOf("--");
|
|
136
|
-
const client = clientIndex >= 0 ? process.argv[clientIndex + 1] : "";
|
|
137
|
-
const args = separatorIndex >= 0 ? process.argv.slice(separatorIndex + 1) : [];
|
|
138
|
-
if (!client) {
|
|
139
|
-
console.error("Usage: ocean intercept --client <provider> -- [args]");
|
|
140
|
-
process.exitCode = 1;
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
process.exitCode = await intercept(client, args, executableIndex >= 0
|
|
144
|
-
? {
|
|
145
|
-
originalExecutable: process.argv[executableIndex + 1],
|
|
146
|
-
entryPoint: "desktop-wrapper",
|
|
147
|
-
controlLevel: "managed-partial",
|
|
148
|
-
}
|
|
149
|
-
: undefined);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
async function commandClient() {
|
|
153
|
-
const action = process.argv[3] ?? "list";
|
|
154
|
-
if (action === "list") {
|
|
155
|
-
console.log(JSON.stringify(loadProviderRegistry(), null, 2));
|
|
156
|
-
}
|
|
157
|
-
else if (action === "open") {
|
|
158
|
-
const provider = process.argv[4];
|
|
159
|
-
if (!provider) {
|
|
160
|
-
console.error("Usage: ocean client open <provider> [provider-args]");
|
|
161
|
-
process.exitCode = 1;
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
// After `--`, arguments go to the provider untouched (a help flag before it is Ocean's).
|
|
165
|
-
const rest = process.argv.slice(5);
|
|
166
|
-
const separator = rest.indexOf("--");
|
|
167
|
-
const providerArgs = separator >= 0 ? rest.slice(0, separator) : rest;
|
|
168
|
-
const passed = separator >= 0 ? rest.slice(separator + 1) : [];
|
|
169
|
-
const taskIndex = providerArgs.indexOf("--task");
|
|
170
|
-
const handoffIndex = providerArgs.indexOf("--handoff");
|
|
171
|
-
const taskId = taskIndex >= 0 ? providerArgs[taskIndex + 1] : undefined;
|
|
172
|
-
const handoffId = handoffIndex >= 0 ? providerArgs[handoffIndex + 1] : undefined;
|
|
173
|
-
const metadataFlags = new Set();
|
|
174
|
-
if (taskIndex >= 0) {
|
|
175
|
-
metadataFlags.add(taskIndex);
|
|
176
|
-
metadataFlags.add(taskIndex + 1);
|
|
177
|
-
}
|
|
178
|
-
if (handoffIndex >= 0) {
|
|
179
|
-
metadataFlags.add(handoffIndex);
|
|
180
|
-
metadataFlags.add(handoffIndex + 1);
|
|
181
|
-
}
|
|
182
|
-
process.exitCode = await intercept(provider, [
|
|
183
|
-
...providerArgs.filter((_, index) => !metadataFlags.has(index)),
|
|
184
|
-
...passed,
|
|
185
|
-
], {
|
|
186
|
-
entryPoint: "interactive-managed",
|
|
187
|
-
controlLevel: "managed-partial",
|
|
188
|
-
taskId,
|
|
189
|
-
handoffId,
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
else if (action === "sync") {
|
|
194
|
-
const result = await syncProviderWrappers();
|
|
195
|
-
// Runs at every session start (the SessionStart hook calls `client sync`), so an edit
|
|
196
|
-
// to core.md reaches the clients that carry a copy without a manual step.
|
|
197
|
-
const charter = await syncCharterCopies();
|
|
198
|
-
const skillFilter = await syncSkillFilter();
|
|
199
|
-
// A skill made or installed reaches every client at the next session start.
|
|
200
|
-
const skills = await autoSyncSkills();
|
|
201
|
-
const engineEntries = await repairEngineEntries();
|
|
202
|
-
// T-305: a repointed service start file only takes effect once the service restarts.
|
|
203
|
-
const service = engineEntries.some((repair) => repair.kind === "service" && repair.status === "updated")
|
|
204
|
-
? await restartService()
|
|
205
|
-
: await ensureService();
|
|
206
|
-
// T-296: re-applies the `ocean` entry only for clients the owner approved with
|
|
207
|
-
// `ocean clients apply --yes`; never a client that was not approved.
|
|
208
|
-
const clients = await repairClients().catch((error) => ({
|
|
209
|
-
error: error instanceof Error ? error.message : String(error),
|
|
210
|
-
}));
|
|
211
|
-
// T-328 phase 3: status lines show `synced <age>` from this stamp.
|
|
212
|
-
await recordSynced();
|
|
213
|
-
console.log(JSON.stringify({
|
|
214
|
-
directory: result.directory,
|
|
215
|
-
providers: result.providers,
|
|
216
|
-
charter,
|
|
217
|
-
skillFilter,
|
|
218
|
-
skills,
|
|
219
|
-
engineEntries,
|
|
220
|
-
service,
|
|
221
|
-
clients,
|
|
222
|
-
}, null, 2));
|
|
223
|
-
}
|
|
224
|
-
else if (action === "register") {
|
|
225
|
-
const id = process.argv[4];
|
|
226
|
-
const provider = await registerProvider(id ?? "", process.argv[5] ?? id ?? "");
|
|
227
|
-
console.log(JSON.stringify(provider, null, 2));
|
|
228
|
-
}
|
|
229
|
-
else if (action === "enable" || action === "disable") {
|
|
230
|
-
const id = process.argv[4];
|
|
231
|
-
if (!id) {
|
|
232
|
-
console.error(`Usage: ocean client ${action} <provider>`);
|
|
233
|
-
process.exitCode = 1;
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
const provider = await setProviderEnabled(id, action === "enable");
|
|
237
|
-
console.log(JSON.stringify(provider, null, 2));
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
else if (action === "manage") {
|
|
241
|
-
await manageClients();
|
|
242
|
-
}
|
|
243
|
-
else if (action === "doctor") {
|
|
244
|
-
const findings = await wrapperDoctor(process.argv[4]);
|
|
245
|
-
if (findings.length) {
|
|
246
|
-
findings.forEach((finding) => {
|
|
247
|
-
console.error(`NOT READY: ${finding}`);
|
|
248
|
-
});
|
|
249
|
-
process.exitCode = 1;
|
|
250
|
-
}
|
|
251
|
-
else {
|
|
252
|
-
console.log("PROVEN: Ocean wrappers are configured and provider binaries resolve outside the shim directory.");
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
else if (action === "status") {
|
|
256
|
-
console.log(JSON.stringify(await wrapperStatus(), null, 2));
|
|
257
|
-
}
|
|
258
|
-
else if (action === "vscode-wrapper") {
|
|
259
|
-
const settingsIndex = process.argv.indexOf("--settings");
|
|
260
|
-
const settingsPath = settingsIndex >= 0 ? process.argv[settingsIndex + 1] : undefined;
|
|
261
|
-
console.log(JSON.stringify(await configureClaudeCodeWrapper(defaultWrapperManager, settingsPath, process.argv.includes("--apply")), null, 2));
|
|
262
|
-
}
|
|
263
|
-
else if (action === "test") {
|
|
264
|
-
const provider = process.argv[4] === "--json" ? "" : (process.argv[4] ?? "");
|
|
265
|
-
await runClientTestCommand(provider, process.argv.includes("--json"));
|
|
266
|
-
}
|
|
267
|
-
else {
|
|
268
|
-
console.error("Usage: ocean client list|status|test [provider] [--json]|open <provider> [provider-args]|vscode-wrapper [--settings <path>] [--apply]|sync|register <id> [command]|enable <id>|disable <id>|manage|doctor [absolute-provider-path]");
|
|
269
|
-
process.exitCode = 1;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
async function commandInstall() {
|
|
273
|
-
const id = process.argv[3];
|
|
274
|
-
if (!id) {
|
|
275
|
-
console.error("Usage: ocean install <client> [--yes]");
|
|
276
|
-
process.exitCode = 1;
|
|
277
|
-
}
|
|
278
|
-
else {
|
|
279
|
-
try {
|
|
280
|
-
const spec = findInstallSpec(id);
|
|
281
|
-
if (!process.argv.includes("--yes")) {
|
|
282
|
-
console.log(JSON.stringify({ approvalRequired: true, plan: installPlan(spec.provider.id) }, null, 2));
|
|
283
|
-
process.exitCode = 2;
|
|
284
|
-
}
|
|
285
|
-
else {
|
|
286
|
-
const result = await installProvider(spec.provider.id, true, defaultWrapperManager, defaultProviderRegistry);
|
|
287
|
-
console.log(JSON.stringify({
|
|
288
|
-
installed: true,
|
|
289
|
-
provider: result.provider,
|
|
290
|
-
executable: result.executable,
|
|
291
|
-
}, null, 2));
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
catch (error) {
|
|
295
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
296
|
-
process.exitCode = 1;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
async function commandAuth() {
|
|
301
|
-
await runAuthCommand(process.argv[3] ?? "", process.argv[4] ?? "");
|
|
302
|
-
}
|
|
303
|
-
async function commandTasks() {
|
|
304
|
-
await runTasksCommand(process.argv[3] ?? "", process.argv.slice(4));
|
|
305
|
-
}
|
|
306
|
-
async function commandPolicy() {
|
|
307
|
-
try {
|
|
308
|
-
await runPolicyCommand(process.argv[3] ?? "list");
|
|
309
|
-
}
|
|
310
|
-
catch (error) {
|
|
311
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
312
|
-
process.exitCode = 1;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
async function commandMarket() {
|
|
316
|
-
try {
|
|
317
|
-
await runMarketCommand(process.argv[3] ?? "", process.argv.slice(4));
|
|
318
|
-
}
|
|
319
|
-
catch (error) {
|
|
320
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
321
|
-
process.exitCode = 1;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
async function commandLifecycle() {
|
|
325
|
-
await runLifecycleCommand(process.argv.slice(3));
|
|
326
|
-
}
|
|
327
|
-
async function commandObserve() {
|
|
328
|
-
try {
|
|
329
|
-
await runObserveCommand(process.argv.slice(3));
|
|
330
|
-
}
|
|
331
|
-
catch (error) {
|
|
332
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
333
|
-
process.exitCode = 1;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
async function commandLayout() {
|
|
337
|
-
try {
|
|
338
|
-
await runLayoutCommand(process.argv.slice(3));
|
|
339
|
-
}
|
|
340
|
-
catch (error) {
|
|
341
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
342
|
-
process.exitCode = 1;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
async function commandMigrate() {
|
|
346
|
-
await runMigrateCommand(process.argv.includes("--apply"));
|
|
347
|
-
}
|
|
348
|
-
async function commandMemory() {
|
|
349
|
-
await runMemoryCommand(process.argv[3] ?? "", process.argv.slice(4));
|
|
350
|
-
}
|
|
351
|
-
async function commandMcp() {
|
|
352
|
-
const action = process.argv[3] ?? "config";
|
|
353
|
-
if (action === "config")
|
|
354
|
-
console.log(JSON.stringify(oceanMcpConfig(), null, 2));
|
|
355
|
-
else if (action === "playwright-config")
|
|
356
|
-
console.log(JSON.stringify(playwrightMcpConfig(), null, 2));
|
|
357
|
-
else if (action === "gateway-config")
|
|
358
|
-
console.log(JSON.stringify(mcpClientConfig(GATEWAY_CAPABILITY), null, 2));
|
|
359
|
-
else if (action === "serve")
|
|
360
|
-
await runOceanMcpServer({
|
|
361
|
-
brainIndex: defaultBrainIndexPort,
|
|
362
|
-
sessionStoreFactory: defaultSessionStoreFactory,
|
|
363
|
-
wrapperManager: defaultWrapperManager,
|
|
364
|
-
embedder: mcpEmbedder(),
|
|
365
|
-
mcpSessions: createMcpSessionRecorder({
|
|
366
|
-
openStore: defaultSessionStoreFactory,
|
|
367
|
-
providerOf: (name) => {
|
|
368
|
-
const id = mcpClientOf(name)?.id;
|
|
369
|
-
return id && MCP_ONLY_CLIENTS.has(id) ? id : null;
|
|
370
|
-
},
|
|
371
|
-
}),
|
|
372
|
-
});
|
|
373
|
-
else if (action === "gateway")
|
|
374
|
-
await runMcpGatewayCommand(process.argv.slice(4));
|
|
375
|
-
else if (action === "status")
|
|
376
|
-
await runMcpStatusCommand(process.argv.slice(4));
|
|
377
|
-
else if (action === "browser-service")
|
|
378
|
-
await runBrowserServiceCommand(process.argv[4] ?? "");
|
|
379
|
-
else {
|
|
380
|
-
console.error("Usage: ocean mcp config|playwright-config|gateway-config|serve|gateway|status [--check] [--json]|browser-service uninstall");
|
|
381
|
-
process.exitCode = 1;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
async function commandObsidian() {
|
|
385
|
-
const action = process.argv[3] ?? "discover";
|
|
386
|
-
if (action === "mcp")
|
|
387
|
-
await runObsidianMcpServer();
|
|
388
|
-
else if (![
|
|
389
|
-
"connect",
|
|
390
|
-
"discover",
|
|
391
|
-
"sync",
|
|
392
|
-
"templates",
|
|
393
|
-
"watch",
|
|
394
|
-
"inbox",
|
|
395
|
-
"write",
|
|
396
|
-
"conflicts",
|
|
397
|
-
].includes(action)) {
|
|
398
|
-
console.error("Usage: ocean obsidian connect <vault-path> [--read-write]|discover|sync|templates [--yes]|watch|inbox|write|conflicts resolve <id> --keep=vault|ocean");
|
|
399
|
-
process.exitCode = 1;
|
|
400
|
-
}
|
|
401
|
-
else {
|
|
402
|
-
try {
|
|
403
|
-
if (action === "templates") {
|
|
404
|
-
// T-314: Templater folder templates and QuickAdd choices generated from routing.json; a dry run
|
|
405
|
-
// until --yes.
|
|
406
|
-
const apply = process.argv.includes("--yes");
|
|
407
|
-
const result = await syncFolderTemplates({ apply });
|
|
408
|
-
const quickadd = await syncQuickAddChoices({ apply });
|
|
409
|
-
console.log(JSON.stringify({ ...result, quickadd }, null, 2));
|
|
410
|
-
if (!result.written)
|
|
411
|
-
console.error("Dry run: pass --yes to write the Templater and QuickAdd config.");
|
|
412
|
-
return;
|
|
413
|
-
}
|
|
414
|
-
if (action === "connect") {
|
|
415
|
-
const vaultPath = process.argv[4];
|
|
416
|
-
if (!vaultPath)
|
|
417
|
-
throw new Error("Usage: ocean obsidian connect <vault-path> [--read-write]");
|
|
418
|
-
const readWrite = process.argv.includes("--read-write");
|
|
419
|
-
const mode = readWrite
|
|
420
|
-
? "read-write"
|
|
421
|
-
: "read-only";
|
|
422
|
-
const result = await connectObsidianVault(vaultPath, mode);
|
|
423
|
-
const synced = await syncObsidianVault(await loadObsidianConnection());
|
|
424
|
-
console.log(JSON.stringify({
|
|
425
|
-
connected: true,
|
|
426
|
-
mode,
|
|
427
|
-
vaultPath: result.vaultPath,
|
|
428
|
-
noteCount: synced.noteCount,
|
|
429
|
-
added: synced.added,
|
|
430
|
-
changed: synced.changed,
|
|
431
|
-
removed: synced.removed,
|
|
432
|
-
issues: synced.issues,
|
|
433
|
-
}, null, 2));
|
|
434
|
-
}
|
|
435
|
-
else {
|
|
436
|
-
const connection = await loadObsidianConnection();
|
|
437
|
-
if (action === "conflicts") {
|
|
438
|
-
if (process.argv[4] !== "resolve")
|
|
439
|
-
throw new Error("Usage: ocean obsidian conflicts resolve <id> --keep=vault|ocean");
|
|
440
|
-
const id = process.argv[5];
|
|
441
|
-
const keepArg = process.argv.find((arg) => arg.startsWith("--keep="));
|
|
442
|
-
const keep = keepArg?.slice("--keep=".length);
|
|
443
|
-
if (!id || !keep || !parseConflictSide(keep))
|
|
444
|
-
throw new Error("Usage: ocean obsidian conflicts resolve <id> --keep=vault|ocean");
|
|
445
|
-
console.log(JSON.stringify(await resolveConflict(id, keep), null, 2));
|
|
446
|
-
}
|
|
447
|
-
else if (action === "write") {
|
|
448
|
-
const relative = process.argv[4];
|
|
449
|
-
const content = process.argv[5];
|
|
450
|
-
const expectedSha256 = process.argv[6] ?? null;
|
|
451
|
-
if (!relative || content === undefined)
|
|
452
|
-
throw new Error("Usage: ocean obsidian write <relative.md> <content> [expected-sha256] [--apply]");
|
|
453
|
-
console.log(JSON.stringify(await writeObsidianNote(connection, relative, content, expectedSha256 === "-" ? null : expectedSha256, process.argv.includes("--apply")), null, 2));
|
|
454
|
-
}
|
|
455
|
-
else if (action === "inbox") {
|
|
456
|
-
const inboxAction = process.argv[4] ?? "list";
|
|
457
|
-
if (inboxAction === "list")
|
|
458
|
-
console.log(JSON.stringify(await listInboxCandidates(connection), null, 2));
|
|
459
|
-
else if (inboxAction === "promote") {
|
|
460
|
-
const source = process.argv[5];
|
|
461
|
-
const target = process.argv[6];
|
|
462
|
-
if (!source || !target)
|
|
463
|
-
throw new Error("Usage: ocean obsidian inbox promote <source.md> <target-directory> [--apply]");
|
|
464
|
-
console.log(JSON.stringify(await promoteInboxNote(connection, source, target, process.argv.includes("--apply")), null, 2));
|
|
465
|
-
}
|
|
466
|
-
else
|
|
467
|
-
throw new Error("Usage: ocean obsidian inbox list|promote <source.md> <target-directory> [--apply]");
|
|
468
|
-
}
|
|
469
|
-
else if (action === "discover")
|
|
470
|
-
console.log(JSON.stringify(await discoverObsidianVault(connection), null, 2));
|
|
471
|
-
else if (action === "sync")
|
|
472
|
-
console.log(JSON.stringify(await syncObsidianVault(connection), null, 2));
|
|
473
|
-
else {
|
|
474
|
-
const controller = new AbortController();
|
|
475
|
-
process.once("SIGINT", () => controller.abort());
|
|
476
|
-
process.once("SIGTERM", () => controller.abort());
|
|
477
|
-
await watchObsidianVault(connection, undefined, controller.signal);
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
catch (error) {
|
|
482
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
483
|
-
process.exitCode = 1;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
async function commandCapture() {
|
|
488
|
-
await runCaptureCommand(process.argv[3] ?? "", process.argv.slice(4));
|
|
489
|
-
}
|
|
490
|
-
async function commandHandoff() {
|
|
491
|
-
try {
|
|
492
|
-
await runHandoffCommand(process.argv[3] ?? "list", process.argv.slice(4));
|
|
493
|
-
}
|
|
494
|
-
catch (error) {
|
|
495
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
496
|
-
process.exitCode = 1;
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
async function commandContext() {
|
|
500
|
-
if (process.argv[3] === "cost") {
|
|
501
|
-
await runContextCostCommand(process.argv.slice(4));
|
|
502
|
-
return;
|
|
503
|
-
}
|
|
504
|
-
await runContextCommand(process.argv.includes("--json"));
|
|
505
|
-
}
|
|
506
|
-
async function commandProject() {
|
|
507
|
-
const action = process.argv[3] ?? "resolve";
|
|
508
|
-
if (action === "resolve") {
|
|
509
|
-
console.log(JSON.stringify(await resolveProject(process.argv[4] ?? process.cwd()), null, 2));
|
|
510
|
-
}
|
|
511
|
-
else if (action === "bind") {
|
|
512
|
-
const args = process.argv.slice(4);
|
|
513
|
-
const addPath = args.includes("--add");
|
|
514
|
-
const [name, targetPath] = args.filter((arg) => arg !== "--add");
|
|
515
|
-
if (!name || !targetPath) {
|
|
516
|
-
console.error("Usage: ocean project bind <name> <path> [--add]");
|
|
517
|
-
process.exitCode = 1;
|
|
518
|
-
}
|
|
519
|
-
else {
|
|
520
|
-
const result = await bindProject(name, targetPath, { addPath });
|
|
521
|
-
console.log(JSON.stringify(result, null, 2));
|
|
522
|
-
if (result.conflict)
|
|
523
|
-
process.exitCode = 2;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
else if (action === "list") {
|
|
527
|
-
const flag = process.argv.indexOf("--category");
|
|
528
|
-
const wanted = flag >= 0 ? process.argv[flag + 1] : undefined;
|
|
529
|
-
if (flag >= 0 &&
|
|
530
|
-
!PROJECT_CATEGORIES.includes(wanted ?? "")) {
|
|
531
|
-
console.error(`Usage: ocean project list [--category ${PROJECT_CATEGORIES.join("|")}]`);
|
|
532
|
-
process.exitCode = 1;
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
const { manifests, errors } = await scanProjectManifests();
|
|
536
|
-
for (const { file, error } of errors)
|
|
537
|
-
console.error(`skipped invalid ${file}: ${error}`);
|
|
538
|
-
const categories = new Map();
|
|
539
|
-
for (const manifest of manifests) {
|
|
540
|
-
try {
|
|
541
|
-
const category = projectCategory(manifest);
|
|
542
|
-
if (category)
|
|
543
|
-
categories.set(manifest.id, category);
|
|
544
|
-
}
|
|
545
|
-
catch (error) {
|
|
546
|
-
console.error(`${manifest.id}: ${error instanceof Error ? error.message : String(error)}`);
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
const bindings = (await listProjectBindings())
|
|
550
|
-
.map((binding) => ({
|
|
551
|
-
...binding,
|
|
552
|
-
gitRoot: binding.gitRoot ?? findGitRoot(binding.path),
|
|
553
|
-
...(categories.has(binding.id)
|
|
554
|
-
? { category: categories.get(binding.id) }
|
|
555
|
-
: {}),
|
|
556
|
-
}))
|
|
557
|
-
.filter((binding) => !wanted || binding.category === wanted);
|
|
558
|
-
console.log(JSON.stringify(bindings, null, 2));
|
|
559
|
-
if (errors.length)
|
|
560
|
-
process.exitCode = 2;
|
|
561
|
-
}
|
|
562
|
-
else if (action === "register") {
|
|
563
|
-
const result = await autoRegisterProject(process.argv[4] ?? process.cwd(), {
|
|
564
|
-
explicit: true,
|
|
565
|
-
});
|
|
566
|
-
console.log(JSON.stringify(result, null, 2));
|
|
567
|
-
if (result.status !== "registered")
|
|
568
|
-
process.exitCode = 2;
|
|
569
|
-
}
|
|
570
|
-
else if (action === "unbind") {
|
|
571
|
-
const target = process.argv[4];
|
|
572
|
-
if (!target) {
|
|
573
|
-
console.error("Usage: ocean project unbind <path>");
|
|
574
|
-
process.exitCode = 1;
|
|
575
|
-
}
|
|
576
|
-
else {
|
|
577
|
-
const result = await unbindProjectPath(target);
|
|
578
|
-
console.log(JSON.stringify(result, null, 2));
|
|
579
|
-
if (!result.removed)
|
|
580
|
-
process.exitCode = 2;
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
else if (action === "rename") {
|
|
584
|
-
const [from, to] = process.argv.slice(4);
|
|
585
|
-
if (!from || !to) {
|
|
586
|
-
console.error("Usage: ocean project rename <id> <new-id>");
|
|
587
|
-
process.exitCode = 1;
|
|
588
|
-
}
|
|
589
|
-
else {
|
|
590
|
-
try {
|
|
591
|
-
console.log(JSON.stringify(await renameProject(from, to), null, 2));
|
|
592
|
-
}
|
|
593
|
-
catch (error) {
|
|
594
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
595
|
-
process.exitCode = 2;
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
else if (action === "move") {
|
|
600
|
-
const args = process.argv.slice(4);
|
|
601
|
-
const [id, category] = args.filter((arg) => arg !== "--write");
|
|
602
|
-
if (!id || !category) {
|
|
603
|
-
console.error(`Usage: ocean project move <id> <${PROJECT_CATEGORIES.join("|")}> [--write]`);
|
|
604
|
-
process.exitCode = 1;
|
|
605
|
-
}
|
|
606
|
-
else {
|
|
607
|
-
try {
|
|
608
|
-
console.log(JSON.stringify(await moveProject(id, category, args.includes("--write")), null, 2));
|
|
609
|
-
}
|
|
610
|
-
catch (error) {
|
|
611
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
612
|
-
process.exitCode = 2;
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
else if (action === "new") {
|
|
617
|
-
// A project with no code yet (one grown from a note); `bind` adds a path later.
|
|
618
|
-
const [id, category, ...name] = process.argv.slice(4);
|
|
619
|
-
if (!id || !category) {
|
|
620
|
-
console.error(`Usage: ocean project new <id> <${PROJECT_CATEGORIES.join("|")}> [display name]`);
|
|
621
|
-
process.exitCode = 1;
|
|
622
|
-
}
|
|
623
|
-
else {
|
|
624
|
-
try {
|
|
625
|
-
const result = await createProject(id, category, name.join(" ") || id);
|
|
626
|
-
console.log(JSON.stringify(result, null, 2));
|
|
627
|
-
}
|
|
628
|
-
catch (error) {
|
|
629
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
630
|
-
process.exitCode = 2;
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
else if (action === "migrate") {
|
|
635
|
-
const result = await migrateProjectBindings(process.argv.includes("--write"));
|
|
636
|
-
console.log(JSON.stringify(result, null, 2));
|
|
637
|
-
}
|
|
638
|
-
else if (action === "status") {
|
|
639
|
-
// Every project's git state, open tasks, last session and next action, derived now (T-317).
|
|
640
|
-
const rows = await projectsOverview();
|
|
641
|
-
if (process.argv.includes("--write"))
|
|
642
|
-
console.log(`updated ${await writeRegistryBlock(rows)}`);
|
|
643
|
-
else if (process.argv.includes("--json"))
|
|
644
|
-
console.log(JSON.stringify(rows, null, 2));
|
|
645
|
-
else
|
|
646
|
-
console.log(overviewTable(rows));
|
|
647
|
-
}
|
|
648
|
-
else if (action === "index") {
|
|
649
|
-
if (process.argv.includes("--write"))
|
|
650
|
-
console.log(JSON.stringify(await writeProjectIndex(), null, 2));
|
|
651
|
-
else
|
|
652
|
-
console.log(await renderProjectIndex());
|
|
653
|
-
}
|
|
654
|
-
else {
|
|
655
|
-
console.error("Usage: ocean project resolve [path]|bind <name> <path> [--add]|register [path]|unbind <path>|rename <id> <new-id>|new <id> <category> [name]|move <id> <category> [--write]|list [--category <name>]|status [--json] [--write]|migrate [--write]|index [--write]");
|
|
656
|
-
process.exitCode = 1;
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
// `--repair` (the hook entries `ocean clients` writes, T-296): `client sync` in the background,
|
|
660
|
-
// as the Claude Code bootstrap script does; it never delays or fails the session.
|
|
661
|
-
function startBackgroundSync() {
|
|
662
|
-
try {
|
|
663
|
-
spawn(process.execPath, [process.argv[1], "client", "sync"], {
|
|
664
|
-
detached: true,
|
|
665
|
-
stdio: "ignore",
|
|
666
|
-
})
|
|
667
|
-
.on("error", () => { })
|
|
668
|
-
.unref();
|
|
669
|
-
}
|
|
670
|
-
catch {
|
|
671
|
-
// no repair this time; the next session start tries again
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
async function commandHook() {
|
|
675
|
-
const action = process.argv[3] ?? "";
|
|
676
|
-
// The model call fact capture makes is a client session too: its hooks do nothing (T-313).
|
|
677
|
-
if (insideFactsCall())
|
|
678
|
-
return;
|
|
679
|
-
if (action === "session-facts") {
|
|
680
|
-
await runSessionFactsCommand(process.argv.slice(4));
|
|
681
|
-
return;
|
|
682
|
-
}
|
|
683
|
-
if (action === "pre-compact") {
|
|
684
|
-
// Claude Code's PreCompact: capture the turns about to be compacted, in the background.
|
|
685
|
-
try {
|
|
686
|
-
const raw = await readBoundedStdin();
|
|
687
|
-
const payload = raw.trim() ? JSON.parse(raw) : {};
|
|
688
|
-
await startSessionFacts(payload, "claude");
|
|
689
|
-
}
|
|
690
|
-
catch (error) {
|
|
691
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
692
|
-
process.exitCode = 1;
|
|
693
|
-
}
|
|
694
|
-
return;
|
|
695
|
-
}
|
|
696
|
-
if (action === "prompt") {
|
|
697
|
-
// Per-prompt skill router (T-325): names the skill the message calls for, or prints nothing.
|
|
698
|
-
// A failure is silent and exits 0, so a broken index never blocks the owner's prompt.
|
|
699
|
-
const flags = process.argv.slice(4);
|
|
700
|
-
const inline = flags.find((arg) => arg.startsWith("--client="));
|
|
701
|
-
const clientIndex = flags.indexOf("--client");
|
|
702
|
-
const client = inline
|
|
703
|
-
? inline.slice("--client=".length)
|
|
704
|
-
: clientIndex >= 0
|
|
705
|
-
? (flags[clientIndex + 1] ?? "")
|
|
706
|
-
: "claude";
|
|
707
|
-
if (!PROMPT_HOOK_CLIENTS.includes(client)) {
|
|
708
|
-
console.error(promptUsage);
|
|
709
|
-
process.exitCode = 1;
|
|
710
|
-
return;
|
|
711
|
-
}
|
|
712
|
-
try {
|
|
713
|
-
const raw = await readBoundedStdin();
|
|
714
|
-
const parsed = raw.trim() ? JSON.parse(raw) : {};
|
|
715
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
716
|
-
const output = await skillRouterHook(parsed, client);
|
|
717
|
-
if (output)
|
|
718
|
-
console.log(JSON.stringify(output));
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
catch (error) {
|
|
722
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
723
|
-
}
|
|
724
|
-
return;
|
|
725
|
-
}
|
|
726
|
-
if (action === "session-start") {
|
|
727
|
-
const flags = process.argv.slice(4);
|
|
728
|
-
if (flags.includes("--repair"))
|
|
729
|
-
startBackgroundSync();
|
|
730
|
-
startBackgroundPull();
|
|
731
|
-
startBackgroundRhythm();
|
|
732
|
-
startBackgroundTaskSync();
|
|
733
|
-
const inline = flags.find((arg) => arg.startsWith("--client="));
|
|
734
|
-
const clientIndex = flags.indexOf("--client");
|
|
735
|
-
const client = inline
|
|
736
|
-
? inline.slice("--client=".length)
|
|
737
|
-
: clientIndex >= 0
|
|
738
|
-
? (flags[clientIndex + 1] ?? "")
|
|
739
|
-
: "claude";
|
|
740
|
-
if (!isSessionStartClient(client)) {
|
|
741
|
-
console.error(sessionStartUsage);
|
|
742
|
-
process.exitCode = 1;
|
|
743
|
-
return;
|
|
744
|
-
}
|
|
745
|
-
try {
|
|
746
|
-
const raw = await readBoundedStdin();
|
|
747
|
-
const parsed = raw.trim() ? JSON.parse(raw) : {};
|
|
748
|
-
const payload = parsed && typeof parsed === "object" && !Array.isArray(parsed)
|
|
749
|
-
? parsed
|
|
750
|
-
: {};
|
|
751
|
-
console.log(JSON.stringify(await sessionStartHookForClient(client, payload)));
|
|
752
|
-
}
|
|
753
|
-
catch (error) {
|
|
754
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
755
|
-
process.exitCode = 1;
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
else if (action === "session-end") {
|
|
759
|
-
const flags = process.argv.slice(4);
|
|
760
|
-
const inline = flags.find((arg) => arg.startsWith("--client="));
|
|
761
|
-
const clientIndex = flags.indexOf("--client");
|
|
762
|
-
const client = inline
|
|
763
|
-
? inline.slice("--client=".length)
|
|
764
|
-
: clientIndex >= 0
|
|
765
|
-
? (flags[clientIndex + 1] ?? "")
|
|
766
|
-
: "claude";
|
|
767
|
-
if (!isSessionEndClient(client)) {
|
|
768
|
-
console.error(sessionEndUsage);
|
|
769
|
-
process.exitCode = 1;
|
|
770
|
-
return;
|
|
771
|
-
}
|
|
772
|
-
try {
|
|
773
|
-
const raw = await readBoundedStdin();
|
|
774
|
-
const payload = raw.trim() ? JSON.parse(raw) : {};
|
|
775
|
-
await claudeSessionEndHook(payload, defaultSessionStoreFactory, client);
|
|
776
|
-
await startSessionFacts(payload, client);
|
|
777
|
-
// The day's account picks up the session just closed (T-314), in the background.
|
|
778
|
-
startBackgroundRhythm();
|
|
779
|
-
}
|
|
780
|
-
catch (error) {
|
|
781
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
782
|
-
process.exitCode = 1;
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
else {
|
|
786
|
-
console.error(`${sessionStartUsage}|${sessionEndUsage.slice("Usage: ocean hook ".length)}`);
|
|
787
|
-
process.exitCode = 1;
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
const promptUsage = `Usage: ocean hook prompt [--client ${PROMPT_HOOK_CLIENTS.join("|")}] (reads a hook payload from stdin)`;
|
|
791
|
-
const sessionEndUsage = `Usage: ocean hook session-end [--client ${SESSION_END_CLIENTS.join("|")}] (reads a hook payload from stdin)`;
|
|
792
|
-
const sessionStartUsage = `Usage: ocean hook session-start [--client ${SESSION_START_CLIENTS.join("|")}] [--repair]|pre-compact (reads a hook payload from stdin)|session-facts --client claude|codex --session <id> --transcript <path>`;
|
|
793
|
-
async function commandIntent() {
|
|
794
|
-
const action = process.argv[3] ?? "classify";
|
|
795
|
-
if (action !== "classify") {
|
|
796
|
-
console.error("Usage: ocean intent classify <text>");
|
|
797
|
-
process.exitCode = 1;
|
|
798
|
-
}
|
|
799
|
-
else {
|
|
800
|
-
const text = process.argv.slice(4).join(" ");
|
|
801
|
-
console.log(JSON.stringify(classifyIntent(text, await knownTaskPrefixes())));
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
async function commandOperate() {
|
|
805
|
-
const args = process.argv.slice(3);
|
|
806
|
-
const text = (args[0] === "--" ? args.slice(1) : args).join(" ");
|
|
807
|
-
await runOperateCommand(text);
|
|
808
|
-
}
|
|
809
|
-
async function commandIdea() {
|
|
810
|
-
try {
|
|
811
|
-
await runIdeaCommand(process.argv[3] ?? "list", process.argv.slice(4));
|
|
812
|
-
}
|
|
813
|
-
catch (error) {
|
|
814
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
815
|
-
process.exitCode = 1;
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
async function commandDaily() {
|
|
819
|
-
try {
|
|
820
|
-
await runDailyCommand(process.argv[3] ?? "start", process.argv.slice(4));
|
|
821
|
-
}
|
|
822
|
-
catch (error) {
|
|
823
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
824
|
-
process.exitCode = 1;
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
async function commandSchedule() {
|
|
828
|
-
const action = process.argv[3] ?? "list";
|
|
829
|
-
if (action === "list")
|
|
830
|
-
console.log(JSON.stringify(await listSchedules(), null, 2));
|
|
831
|
-
else if (action === "add") {
|
|
832
|
-
const { guard, rest } = parseGuardFlags(process.argv.slice(4));
|
|
833
|
-
const [id, profile, intervalMs, ...prompt] = rest;
|
|
834
|
-
if (!id || !profile || !intervalMs || !prompt.length) {
|
|
835
|
-
console.error(`Usage: ocean schedule add <id> <profile> <interval-ms> ${GUARD_FLAGS} <prompt>`);
|
|
836
|
-
process.exitCode = 1;
|
|
837
|
-
}
|
|
838
|
-
else
|
|
839
|
-
try {
|
|
840
|
-
await saveSchedule({
|
|
841
|
-
id,
|
|
842
|
-
profile,
|
|
843
|
-
prompt: prompt.join(" "),
|
|
844
|
-
intervalMs: Number(intervalMs),
|
|
845
|
-
nextRunAt: new Date().toISOString(),
|
|
846
|
-
enabled: true,
|
|
847
|
-
guard: guard,
|
|
848
|
-
});
|
|
849
|
-
}
|
|
850
|
-
catch (error) {
|
|
851
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
852
|
-
process.exitCode = 1;
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
else if (action === "run-due")
|
|
856
|
-
console.log(JSON.stringify({ ran: await runDueSchedules(oceanRoot(), defaultAgentRuntime) }, null, 2));
|
|
857
|
-
else if (action === "worker-once")
|
|
858
|
-
console.log(JSON.stringify({ ran: await runSchedulerWorkerOnce(oceanRoot(), defaultAgentRuntime) }, null, 2));
|
|
859
|
-
else if (action === "worker") {
|
|
860
|
-
const controller = new AbortController();
|
|
861
|
-
const stop = () => controller.abort();
|
|
862
|
-
process.once("SIGINT", stop);
|
|
863
|
-
process.once("SIGTERM", stop);
|
|
864
|
-
await runSchedulerWorker(oceanRoot(), defaultAgentRuntime, {
|
|
865
|
-
signal: controller.signal,
|
|
866
|
-
pollMs: Number(oceanEnv("SCHEDULER_POLL_MS") ?? 30_000),
|
|
867
|
-
});
|
|
868
|
-
process.off("SIGINT", stop);
|
|
869
|
-
process.off("SIGTERM", stop);
|
|
870
|
-
}
|
|
871
|
-
else if (action === "enable" || action === "disable")
|
|
872
|
-
console.log(JSON.stringify(await setScheduleEnabled(process.argv[4] ?? "", action === "enable"), null, 2));
|
|
873
|
-
else if (action === "run-now")
|
|
874
|
-
await runSchedule(process.argv[4] ?? "", oceanRoot(), defaultAgentRuntime);
|
|
875
|
-
else {
|
|
876
|
-
console.error("Usage: ocean schedule list|add|enable|disable|run-due|run-now|worker-once|worker");
|
|
877
|
-
process.exitCode = 1;
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
async function commandLoop() {
|
|
881
|
-
const action = process.argv[3] ?? "status";
|
|
882
|
-
if (action === "status")
|
|
883
|
-
console.log(JSON.stringify(await listTaskLoops(), null, 2));
|
|
884
|
-
else if (action === "start") {
|
|
885
|
-
// The prompt is everything after --prompt, so the guard flags come before it.
|
|
886
|
-
const promptIndex = process.argv.indexOf("--prompt");
|
|
887
|
-
const head = promptIndex >= 0 ? process.argv.slice(0, promptIndex) : process.argv;
|
|
888
|
-
const { guard, rest } = parseGuardFlags(head.slice(4));
|
|
889
|
-
const [taskId, profile = "developer"] = rest.filter((arg, index, all) => !arg.startsWith("--") &&
|
|
890
|
-
!["--interval-ms", "--max-attempts"].includes(all[index - 1] ?? ""));
|
|
891
|
-
const prompt = promptIndex >= 0 ? process.argv.slice(promptIndex + 1).join(" ") : "";
|
|
892
|
-
if (!taskId || !prompt || !head.includes("--approve")) {
|
|
893
|
-
console.error(`Usage: ocean loop start <task-id> <profile> --approve ${GUARD_FLAGS} [--interval-ms N] [--max-attempts N] --prompt <text>`);
|
|
894
|
-
process.exitCode = 1;
|
|
895
|
-
}
|
|
896
|
-
else {
|
|
897
|
-
const value = (flag, fallback) => {
|
|
898
|
-
const index = head.indexOf(flag);
|
|
899
|
-
return index >= 0 ? Number(head[index + 1]) : fallback;
|
|
900
|
-
};
|
|
901
|
-
try {
|
|
902
|
-
console.log(JSON.stringify(await startTaskLoop({
|
|
903
|
-
taskId,
|
|
904
|
-
profile,
|
|
905
|
-
prompt,
|
|
906
|
-
cwd: oceanRoot(),
|
|
907
|
-
approved: true,
|
|
908
|
-
guard,
|
|
909
|
-
intervalMs: value("--interval-ms", 60_000),
|
|
910
|
-
maxAttempts: value("--max-attempts", 2),
|
|
911
|
-
}), null, 2));
|
|
912
|
-
}
|
|
913
|
-
catch (error) {
|
|
914
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
915
|
-
process.exitCode = 1;
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
else if (action === "worker-once") {
|
|
920
|
-
console.log(JSON.stringify({ ran: await runTaskLoopsOnce(oceanRoot(), defaultAgentRuntime) }, null, 2));
|
|
921
|
-
}
|
|
922
|
-
else if (action === "worker") {
|
|
923
|
-
const controller = new AbortController();
|
|
924
|
-
const stop = () => controller.abort();
|
|
925
|
-
process.once("SIGINT", stop);
|
|
926
|
-
process.once("SIGTERM", stop);
|
|
927
|
-
await runTaskLoopWorker(oceanRoot(), defaultAgentRuntime, {
|
|
928
|
-
signal: controller.signal,
|
|
929
|
-
pollMs: Number(oceanEnv("LOOP_POLL_MS") ?? 30_000),
|
|
930
|
-
});
|
|
931
|
-
process.off("SIGINT", stop);
|
|
932
|
-
process.off("SIGTERM", stop);
|
|
933
|
-
}
|
|
934
|
-
else if (action === "stop") {
|
|
935
|
-
const id = process.argv[4];
|
|
936
|
-
if (!id) {
|
|
937
|
-
console.error("Usage: ocean loop stop <loop-id>");
|
|
938
|
-
process.exitCode = 1;
|
|
939
|
-
}
|
|
940
|
-
else
|
|
941
|
-
console.log(JSON.stringify(await stopTaskLoop(id), null, 2));
|
|
942
|
-
}
|
|
943
|
-
else {
|
|
944
|
-
console.error("Usage: ocean loop start|status|stop|worker-once|worker");
|
|
945
|
-
process.exitCode = 1;
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
async function commandGateway() {
|
|
949
|
-
const port = Number(oceanEnv("GATEWAY_PORT") ?? 8787);
|
|
950
|
-
const token = oceanEnv("GATEWAY_TOKEN");
|
|
951
|
-
if (!token) {
|
|
952
|
-
console.error("OCEAN_GATEWAY_TOKEN is required");
|
|
953
|
-
process.exitCode = 1;
|
|
954
|
-
}
|
|
955
|
-
else {
|
|
956
|
-
const server = createWebhookGateway(oceanRoot(), token, defaultAgentRuntime);
|
|
957
|
-
server.listen(port, "127.0.0.1", () => console.log(`Ocean webhook gateway listening on 127.0.0.1:${port}`));
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
async function commandSkill() {
|
|
961
|
-
const action = process.argv[3] ?? "list";
|
|
962
|
-
if (action === "sync")
|
|
963
|
-
console.log(JSON.stringify(await syncCoreSkills(), null, 2));
|
|
964
|
-
else if (action === "hub") {
|
|
965
|
-
const sources = process.argv
|
|
966
|
-
.slice(4)
|
|
967
|
-
.filter((arg) => !arg.startsWith("--"));
|
|
968
|
-
console.log(JSON.stringify(await populateSkillHub(sources), null, 2));
|
|
969
|
-
}
|
|
970
|
-
else if (action === "copy") {
|
|
971
|
-
console.log(JSON.stringify(await copyClientSkills({ apply: process.argv.includes("--apply") }), null, 2));
|
|
972
|
-
}
|
|
973
|
-
else if (action === "link") {
|
|
974
|
-
console.log(JSON.stringify(await linkClientSkills({
|
|
975
|
-
apply: process.argv.includes("--apply"),
|
|
976
|
-
all: process.argv.includes("--all"),
|
|
977
|
-
}), null, 2));
|
|
978
|
-
}
|
|
979
|
-
else if (action === "doctor") {
|
|
980
|
-
// Core skills per client, then the surface check: every installed client holds the
|
|
981
|
-
// skills Ocean keeps for it (T-319 C5). A gap fails the command.
|
|
982
|
-
const surface = await skillSurfaceReport();
|
|
983
|
-
console.log(JSON.stringify({ core: await coreSkillReports(), surface }, null, 2));
|
|
984
|
-
if (!surface.consistent) {
|
|
985
|
-
for (const row of surface.clients)
|
|
986
|
-
if (row.missing.length)
|
|
987
|
-
console.error(`NOT CONSISTENT: ${row.client} lacks ${row.missing.join(", ")} (${row.root})`);
|
|
988
|
-
process.exitCode = 1;
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
else if (action === "list") {
|
|
992
|
-
// [status] filters; any other argument is a lesson id (what a truncated lesson points at).
|
|
993
|
-
const filter = process.argv[4];
|
|
994
|
-
const isStatus = filter === "candidate" || filter === "active" || filter === "retired";
|
|
995
|
-
const lessons = filter && !isStatus
|
|
996
|
-
? [await readLesson(filter)].filter((lesson) => lesson !== null)
|
|
997
|
-
: await listLessons(isStatus ? { status: filter } : {});
|
|
998
|
-
if (filter && !isStatus && !lessons.length) {
|
|
999
|
-
console.error(`Lesson not found: ${filter}`);
|
|
1000
|
-
process.exitCode = 1;
|
|
1001
|
-
}
|
|
1002
|
-
else
|
|
1003
|
-
console.log(JSON.stringify(lessons.map((lesson) => ({
|
|
1004
|
-
...lesson,
|
|
1005
|
-
effectiveConfidence: Number(effectiveConfidence(lesson).toFixed(4)),
|
|
1006
|
-
})), null, 2));
|
|
1007
|
-
}
|
|
1008
|
-
else if (action === "observe" || action === "learn") {
|
|
1009
|
-
// Scores one closed session into the lessons store (the same step closeout runs).
|
|
1010
|
-
const sessionId = process.argv[4];
|
|
1011
|
-
if (!sessionId && action === "observe")
|
|
1012
|
-
console.log(JSON.stringify(await listLessons({ status: "candidate" }), null, 2));
|
|
1013
|
-
else if (!sessionId) {
|
|
1014
|
-
console.error("Usage: ocean skill learn <session-id>");
|
|
1015
|
-
process.exitCode = 1;
|
|
1016
|
-
}
|
|
1017
|
-
else {
|
|
1018
|
-
const store = await defaultSessionStoreFactory();
|
|
1019
|
-
try {
|
|
1020
|
-
const learning = await learnFromSession(store, sessionId);
|
|
1021
|
-
console.log(JSON.stringify(learning, null, 2));
|
|
1022
|
-
// Lessons come only from verified sessions (T-323); say so instead of silently learning nothing.
|
|
1023
|
-
if (!learning.score.verified)
|
|
1024
|
-
console.error(`Session ${sessionId} is not verified: no lessons were learned from it.`);
|
|
1025
|
-
}
|
|
1026
|
-
finally {
|
|
1027
|
-
store.close();
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
else if (action === "add") {
|
|
1032
|
-
const [id, name, ...instructions] = process.argv.slice(4);
|
|
1033
|
-
if (!id || !name || !instructions.length) {
|
|
1034
|
-
console.error("Usage: ocean skill add <id> <name> <instructions>");
|
|
1035
|
-
process.exitCode = 1;
|
|
1036
|
-
}
|
|
1037
|
-
else
|
|
1038
|
-
console.log(JSON.stringify(await addLesson({ id, title: name, body: instructions.join(" ") }), null, 2));
|
|
1039
|
-
}
|
|
1040
|
-
else if (action === "review") {
|
|
1041
|
-
// The owner's call: promoted activates a lesson without waiting for the replay eval,
|
|
1042
|
-
// rejected retires it. Run `ocean memory reindex` afterwards so runs can find it.
|
|
1043
|
-
const [id, status] = process.argv.slice(4);
|
|
1044
|
-
if (!id || (status !== "promoted" && status !== "rejected")) {
|
|
1045
|
-
console.error("Usage: ocean skill review <id> promoted|rejected");
|
|
1046
|
-
process.exitCode = 1;
|
|
1047
|
-
}
|
|
1048
|
-
else
|
|
1049
|
-
console.log(JSON.stringify(await setLessonStatus(id, status === "promoted" ? "active" : "retired"), null, 2));
|
|
1050
|
-
}
|
|
1051
|
-
else if (action === "migrate") {
|
|
1052
|
-
console.log(JSON.stringify(await migrateLegacyLessons(), null, 2));
|
|
1053
|
-
}
|
|
1054
|
-
else if (action === "route") {
|
|
1055
|
-
// What the prompt hook would name for a message, with the near misses (T-325).
|
|
1056
|
-
const args = process.argv.slice(4);
|
|
1057
|
-
const value = (flag) => {
|
|
1058
|
-
const at = args.indexOf(flag);
|
|
1059
|
-
return at >= 0 ? args[at + 1] : undefined;
|
|
1060
|
-
};
|
|
1061
|
-
const valued = new Set(["--client", "--cwd"]);
|
|
1062
|
-
const message = args
|
|
1063
|
-
.filter((arg, i) => !arg.startsWith("--") && !valued.has(args[i - 1]))
|
|
1064
|
-
.join(" ");
|
|
1065
|
-
if (!message.trim()) {
|
|
1066
|
-
console.error("Usage: ocean skill route <message> [--client claude|codex|gemini|qwen] [--cwd <dir>] [--rebuild] [--json]");
|
|
1067
|
-
process.exitCode = 1;
|
|
1068
|
-
return;
|
|
1069
|
-
}
|
|
1070
|
-
const index = args.includes("--rebuild")
|
|
1071
|
-
? await buildSkillIndex()
|
|
1072
|
-
: await loadSkillIndex();
|
|
1073
|
-
const result = routeSkills(index, message, {
|
|
1074
|
-
signals: await projectSignals(value("--cwd") ?? process.cwd()),
|
|
1075
|
-
client: value("--client") ?? "claude",
|
|
1076
|
-
});
|
|
1077
|
-
if (args.includes("--json"))
|
|
1078
|
-
console.log(JSON.stringify({
|
|
1079
|
-
threshold: ROUTE_THRESHOLD,
|
|
1080
|
-
skills: index.skills.length,
|
|
1081
|
-
...result,
|
|
1082
|
-
}, null, 2));
|
|
1083
|
-
else {
|
|
1084
|
-
console.log(result.matches.length
|
|
1085
|
-
? routerLine(result.matches)
|
|
1086
|
-
: `No skill above the threshold (${ROUTE_THRESHOLD}).`);
|
|
1087
|
-
for (const item of result.candidates)
|
|
1088
|
-
console.log(` ${item.score.toFixed(1).padStart(5)} ${item.name} [${item.why.join(", ")}]`);
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
else {
|
|
1092
|
-
console.error("Usage: ocean skill sync|doctor|list [status|id]|observe [session-id]|add|review <id> promoted|rejected|migrate|route <message>");
|
|
1093
|
-
process.exitCode = 1;
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
async function commandCatalog() {
|
|
1097
|
-
console.log(JSON.stringify(listInstallSpecs().map((spec) => ({
|
|
1098
|
-
id: spec.provider.id,
|
|
1099
|
-
command: spec.provider.command,
|
|
1100
|
-
installer: installPlan(spec.provider.id),
|
|
1101
|
-
})), null, 2));
|
|
1102
|
-
}
|
|
1103
|
-
async function commandEnv() {
|
|
1104
|
-
console.log(await installShellPath());
|
|
1105
|
-
}
|
|
1106
|
-
async function commandUpdateOrRemove(command) {
|
|
1107
|
-
const id = process.argv[3];
|
|
1108
|
-
if (!id || !process.argv.includes("--yes")) {
|
|
1109
|
-
console.error(`Usage: ocean ${command} <client> --yes`);
|
|
1110
|
-
process.exitCode = 2;
|
|
1111
|
-
}
|
|
1112
|
-
else {
|
|
1113
|
-
try {
|
|
1114
|
-
const result = command === "update"
|
|
1115
|
-
? await updateProvider(id, true, defaultWrapperManager, defaultProviderRegistry)
|
|
1116
|
-
: await removeInstalledProvider(id, true, defaultWrapperManager);
|
|
1117
|
-
console.log(JSON.stringify({
|
|
1118
|
-
[command === "update" ? "updated" : "removed"]: true,
|
|
1119
|
-
provider: result,
|
|
1120
|
-
}, null, 2));
|
|
1121
|
-
}
|
|
1122
|
-
catch (error) {
|
|
1123
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
1124
|
-
process.exitCode = 1;
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
async function commandDoctor() {
|
|
1129
|
-
const report = await workspaceReport(defaultWrapperManager);
|
|
1130
|
-
// T-296: every installed AI client's `ocean` entry (supported fail, unknown warn).
|
|
1131
|
-
report.findings.push(...(await clientFindings()), ...(await desktopWatcherFindings()), ...(await nativeFindings()), ...(await browserFindings()), ...(await gatewayFindings()), ...(await runningServerFindings()));
|
|
1132
|
-
if (process.argv.includes("--json"))
|
|
1133
|
-
console.log(JSON.stringify(report, null, 2));
|
|
1134
|
-
else
|
|
1135
|
-
report.findings.forEach((finding) => {
|
|
1136
|
-
console.log(`${finding.severity}: ${finding.code} — ${finding.message}`);
|
|
1137
|
-
});
|
|
1138
|
-
if (hasFailures(report.findings))
|
|
1139
|
-
process.exitCode = 1;
|
|
1140
|
-
}
|
|
1141
|
-
async function commandRepair() {
|
|
1142
|
-
const apply = process.argv.includes("--apply");
|
|
1143
|
-
if (!apply) {
|
|
1144
|
-
const report = await workspaceReport(defaultWrapperManager);
|
|
1145
|
-
console.log(JSON.stringify({
|
|
1146
|
-
dryRun: true,
|
|
1147
|
-
fixable: report.findings.filter((finding) => finding.fixable),
|
|
1148
|
-
findings: report.findings,
|
|
1149
|
-
}, null, 2));
|
|
1150
|
-
}
|
|
1151
|
-
else {
|
|
1152
|
-
const result = await repairWorkspace(defaultWrapperManager);
|
|
1153
|
-
console.log(JSON.stringify({ applied: result.changes, findings: result.findings }, null, 2));
|
|
1154
|
-
if (hasFailures(result.findings))
|
|
1155
|
-
process.exitCode = 1;
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
async function commandBrowser() {
|
|
1159
|
-
await runBrowserCommand(process.argv[3] ?? "", process.argv.slice(4));
|
|
1160
|
-
}
|
|
1161
|
-
async function commandRun() {
|
|
1162
|
-
const profileIndex = process.argv.indexOf("--profile");
|
|
1163
|
-
const promptIndex = process.argv.indexOf("--prompt");
|
|
1164
|
-
const clientIndex = process.argv.indexOf("--client");
|
|
1165
|
-
const taskIndex = process.argv.indexOf("--task");
|
|
1166
|
-
const handoffIndex = process.argv.indexOf("--handoff");
|
|
1167
|
-
// --profile, then runtime.json's defaultProfile, then the historical "default" while no
|
|
1168
|
-
// runtime.json exists. A named profile that does not exist fails; nothing falls back.
|
|
1169
|
-
const explicitProfile = profileIndex >= 0 ? process.argv[profileIndex + 1] : undefined;
|
|
1170
|
-
if (profileIndex >= 0 &&
|
|
1171
|
-
(!explicitProfile || explicitProfile.startsWith("--"))) {
|
|
1172
|
-
console.error("Usage: ocean run --profile <name> ... --prompt <text>");
|
|
1173
|
-
process.exitCode = 1;
|
|
1174
|
-
return;
|
|
1175
|
-
}
|
|
1176
|
-
// runtime.json is read only when it is needed, so a broken one cannot block an explicit run.
|
|
1177
|
-
const runtimeConfig = explicitProfile ? null : await loadRuntimeConfig();
|
|
1178
|
-
const client = clientIndex >= 0 ? process.argv[clientIndex + 1] : undefined;
|
|
1179
|
-
const taskId = taskIndex >= 0 ? process.argv[taskIndex + 1] : undefined;
|
|
1180
|
-
// T-296: with `autoProfile` on, a run for a task without --profile takes the suggested one.
|
|
1181
|
-
const profileName = runtimeConfig?.autoProfile && taskId
|
|
1182
|
-
? (await selectProfileForTask(taskId, { cwd: process.cwd() })).profile
|
|
1183
|
-
: resolveProfileName(explicitProfile, runtimeConfig);
|
|
1184
|
-
const handoffId = handoffIndex >= 0 ? process.argv[handoffIndex + 1] : undefined;
|
|
1185
|
-
const prompt = promptIndex >= 0 ? process.argv.slice(promptIndex + 1).join(" ") : "";
|
|
1186
|
-
if (!profileName || !prompt) {
|
|
1187
|
-
console.error("Usage: ocean run --profile <name> [--client <client>] [--task <id>] [--handoff <id>] --prompt <text>");
|
|
1188
|
-
process.exitCode = 1;
|
|
1189
|
-
}
|
|
1190
|
-
else {
|
|
1191
|
-
const session = await runAgent({ profileName, client, taskId, handoffId, prompt, cwd: oceanRoot() }, defaultAgentRuntime);
|
|
1192
|
-
console.log(JSON.stringify({ sessionId: session.sessionId, status: session.status }));
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
async function commandSession() {
|
|
1196
|
-
const action = process.argv[3] ?? "list";
|
|
1197
|
-
const store = await openSessionStore();
|
|
1198
|
-
if (action === "list") {
|
|
1199
|
-
console.log(JSON.stringify(store.list()));
|
|
1200
|
-
store.close();
|
|
1201
|
-
}
|
|
1202
|
-
else if (action === "show") {
|
|
1203
|
-
const sessionId = process.argv[4] ?? "";
|
|
1204
|
-
const session = store.get(sessionId);
|
|
1205
|
-
const entryEvent = session
|
|
1206
|
-
? store
|
|
1207
|
-
.listEvents(sessionId)
|
|
1208
|
-
.find((event) => event.type === "session_entry_contract")
|
|
1209
|
-
: undefined;
|
|
1210
|
-
store.close();
|
|
1211
|
-
if (!session) {
|
|
1212
|
-
console.error("Session not found");
|
|
1213
|
-
process.exitCode = 1;
|
|
1214
|
-
}
|
|
1215
|
-
else
|
|
1216
|
-
console.log(JSON.stringify({
|
|
1217
|
-
...session,
|
|
1218
|
-
entryContract: entryEvent ? JSON.parse(entryEvent.data) : null,
|
|
1219
|
-
}));
|
|
1220
|
-
}
|
|
1221
|
-
else if (action === "summary") {
|
|
1222
|
-
const sessionId = process.argv[4] ?? "";
|
|
1223
|
-
const session = store.get(sessionId);
|
|
1224
|
-
store.close();
|
|
1225
|
-
if (!session) {
|
|
1226
|
-
console.error("Session not found");
|
|
1227
|
-
process.exitCode = 1;
|
|
1228
|
-
}
|
|
1229
|
-
else if (!session.summaryPath) {
|
|
1230
|
-
console.error("Session summary not available");
|
|
1231
|
-
process.exitCode = 1;
|
|
1232
|
-
}
|
|
1233
|
-
else {
|
|
1234
|
-
try {
|
|
1235
|
-
console.log(await readFile(path.resolve(oceanRoot(), session.summaryPath), "utf8"));
|
|
1236
|
-
}
|
|
1237
|
-
catch {
|
|
1238
|
-
console.error("Session summary file is missing");
|
|
1239
|
-
process.exitCode = 1;
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
else if (action === "events") {
|
|
1244
|
-
const sessionId = process.argv[4] ?? "";
|
|
1245
|
-
const session = store.get(sessionId);
|
|
1246
|
-
const events = session ? store.listEvents(sessionId) : [];
|
|
1247
|
-
store.close();
|
|
1248
|
-
if (!session) {
|
|
1249
|
-
console.error("Session not found");
|
|
1250
|
-
process.exitCode = 1;
|
|
1251
|
-
}
|
|
1252
|
-
else
|
|
1253
|
-
console.log(JSON.stringify(events, null, 2));
|
|
1254
|
-
}
|
|
1255
|
-
else if (action === "resume") {
|
|
1256
|
-
const sessionId = process.argv[4];
|
|
1257
|
-
const prompt = process.argv.slice(5).join(" ");
|
|
1258
|
-
store.close();
|
|
1259
|
-
if (!sessionId || !prompt) {
|
|
1260
|
-
console.error("Usage: ocean session resume <session-id> <prompt>");
|
|
1261
|
-
process.exitCode = 1;
|
|
1262
|
-
}
|
|
1263
|
-
else {
|
|
1264
|
-
const session = await resumeAgent(sessionId, prompt, defaultAgentRuntime);
|
|
1265
|
-
console.log(JSON.stringify({
|
|
1266
|
-
sessionId: session.sessionId,
|
|
1267
|
-
status: session.status,
|
|
1268
|
-
}));
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
else if (action === "promote") {
|
|
1272
|
-
const sessionId = process.argv[4];
|
|
1273
|
-
const target = process.argv[5] ?? "knowledge/results";
|
|
1274
|
-
store.close();
|
|
1275
|
-
if (!sessionId) {
|
|
1276
|
-
console.error("Usage: ocean session promote <session-id> [knowledge/<kind>] --approve");
|
|
1277
|
-
process.exitCode = 1;
|
|
1278
|
-
}
|
|
1279
|
-
else {
|
|
1280
|
-
try {
|
|
1281
|
-
console.log(JSON.stringify(await promoteSessionToKnowledge(sessionId, defaultSessionStoreFactory, target, process.argv.includes("--approve")), null, 2));
|
|
1282
|
-
}
|
|
1283
|
-
catch (error) {
|
|
1284
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
1285
|
-
process.exitCode = 1;
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
else if (action === "doctor") {
|
|
1290
|
-
const thresholdHours = Number(process.argv[4] ?? "24");
|
|
1291
|
-
const apply = process.argv.includes("--apply");
|
|
1292
|
-
if (!Number.isFinite(thresholdHours) || thresholdHours <= 0) {
|
|
1293
|
-
store.close();
|
|
1294
|
-
console.error("Usage: ocean session doctor [hours] [--apply]");
|
|
1295
|
-
process.exitCode = 1;
|
|
1296
|
-
}
|
|
1297
|
-
else {
|
|
1298
|
-
const thresholdMs = thresholdHours * 60 * 60 * 1000;
|
|
1299
|
-
const stale = apply
|
|
1300
|
-
? store.reconcileStaleRunning(thresholdMs)
|
|
1301
|
-
: store.listStaleRunning(thresholdMs);
|
|
1302
|
-
console.log(JSON.stringify({
|
|
1303
|
-
apply,
|
|
1304
|
-
thresholdHours,
|
|
1305
|
-
stale: stale.map((session) => ({
|
|
1306
|
-
sessionId: session.sessionId,
|
|
1307
|
-
provider: session.provider,
|
|
1308
|
-
updatedAt: session.updatedAt,
|
|
1309
|
-
})),
|
|
1310
|
-
integrity: store.integrityCheck(),
|
|
1311
|
-
}));
|
|
1312
|
-
store.close();
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
else if (action === "compact") {
|
|
1316
|
-
const keepDaysIndex = process.argv.indexOf("--keep-days");
|
|
1317
|
-
const keepDays = keepDaysIndex >= 0
|
|
1318
|
-
? Number(process.argv[keepDaysIndex + 1])
|
|
1319
|
-
: DEFAULT_KEEP_DAYS;
|
|
1320
|
-
const simulate = process.argv.includes("--simulate");
|
|
1321
|
-
const apply = process.argv.includes("--apply");
|
|
1322
|
-
const beforeIndex = process.argv.indexOf("--before");
|
|
1323
|
-
const before = beforeIndex >= 0 ? process.argv[beforeIndex + 1] : undefined;
|
|
1324
|
-
const planIndex = process.argv.indexOf("--plan");
|
|
1325
|
-
const fingerprint = planIndex >= 0 ? process.argv[planIndex + 1] : undefined;
|
|
1326
|
-
if (!Number.isFinite(keepDays) || keepDays <= 0) {
|
|
1327
|
-
store.close();
|
|
1328
|
-
console.error("Usage: ocean session compact [--keep-days N] [--simulate|--apply --before <iso> --plan <fingerprint>] [--json]");
|
|
1329
|
-
process.exitCode = 1;
|
|
1330
|
-
return;
|
|
1331
|
-
}
|
|
1332
|
-
const plan = planRetention(store, { keepDays, before });
|
|
1333
|
-
if (apply) {
|
|
1334
|
-
if (!before || !fingerprint) {
|
|
1335
|
-
store.close();
|
|
1336
|
-
console.error("ocean session compact --apply requires --before <iso> and --plan <fingerprint> from a prior plan/--simulate run");
|
|
1337
|
-
process.exitCode = 1;
|
|
1338
|
-
return;
|
|
1339
|
-
}
|
|
1340
|
-
try {
|
|
1341
|
-
const result = await applyRetention(store, oceanPath(SYSTEM_DIR, "sessions", "sessions.sqlite"), plan, fingerprint);
|
|
1342
|
-
console.log(JSON.stringify({ apply: true, plan, result }, null, 2));
|
|
1343
|
-
}
|
|
1344
|
-
catch (error) {
|
|
1345
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
1346
|
-
process.exitCode = 1;
|
|
1347
|
-
}
|
|
1348
|
-
finally {
|
|
1349
|
-
store.close();
|
|
1350
|
-
}
|
|
1351
|
-
return;
|
|
1352
|
-
}
|
|
1353
|
-
if (simulate) {
|
|
1354
|
-
const result = await simulateRetention(store, oceanPath(SYSTEM_DIR, "sessions", "sessions.sqlite"), plan, defaultSessionStoreOpener);
|
|
1355
|
-
store.close();
|
|
1356
|
-
console.log(JSON.stringify({ simulate: true, plan, result }, null, 2));
|
|
1357
|
-
return;
|
|
1358
|
-
}
|
|
1359
|
-
store.close();
|
|
1360
|
-
console.log(JSON.stringify({ dryRun: true, plan }, null, 2));
|
|
1361
|
-
}
|
|
1362
|
-
else {
|
|
1363
|
-
store.close();
|
|
1364
|
-
console.error("Usage: ocean session list|show <session-id>|summary <session-id>|events <session-id>|resume <session-id> <prompt>|promote <session-id> [knowledge/<kind>] --approve|doctor [hours] [--apply]|compact [--keep-days N] [--simulate]|compact --apply --before <iso> --plan <fingerprint>");
|
|
1365
|
-
process.exitCode = 1;
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
28
|
+
// The commands `ocean --help` lists, one noun each (T-343), then the hidden ones the AI clients,
|
|
29
|
+
// shims and migrations call. The names that used to be commands of their own are in
|
|
30
|
+
// command-aliases.ts and still work.
|
|
1368
31
|
export const commandRegistry = {
|
|
1369
32
|
setup: commandSetup,
|
|
1370
33
|
uninstall: () => runUninstallCommand(process.argv.slice(3)),
|
|
1371
|
-
|
|
1372
|
-
service: commandService,
|
|
1373
|
-
intercept: commandIntercept,
|
|
1374
|
-
client: commandClient,
|
|
1375
|
-
clients: () => runClientsCommand(process.argv.slice(3)),
|
|
1376
|
-
install: commandInstall,
|
|
1377
|
-
auth: commandAuth,
|
|
1378
|
-
tasks: commandTasks,
|
|
34
|
+
doctor: commandDoctor,
|
|
1379
35
|
policy: commandPolicy,
|
|
1380
|
-
lifecycle: commandLifecycle,
|
|
1381
|
-
observe: commandObserve,
|
|
1382
|
-
migrate: commandMigrate,
|
|
1383
|
-
layout: commandLayout,
|
|
1384
|
-
memory: commandMemory,
|
|
1385
|
-
pull: () => runPullCommand(process.argv.slice(3)),
|
|
1386
|
-
desktop: () => runDesktopCommand(process.argv.slice(3)),
|
|
1387
|
-
mcp: commandMcp,
|
|
1388
|
-
market: commandMarket,
|
|
1389
|
-
obsidian: commandObsidian,
|
|
1390
|
-
capture: commandCapture,
|
|
1391
|
-
handoff: commandHandoff,
|
|
1392
36
|
context: commandContext,
|
|
1393
37
|
project: commandProject,
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
operate: commandOperate,
|
|
1397
|
-
idea: commandIdea,
|
|
1398
|
-
note: () => runNoteCommand(process.argv.slice(3)),
|
|
1399
|
-
brief: () => runBriefCommand(process.argv.slice(3)),
|
|
1400
|
-
interests: () => runInterestsCommand(process.argv.slice(3)),
|
|
1401
|
-
distill: () => runDistillCommand(process.argv.slice(3)),
|
|
1402
|
-
harvest: () => runHarvestCommand(process.argv.slice(3)),
|
|
1403
|
-
rhythm: () => runRhythmCommand(process.argv.slice(3)),
|
|
1404
|
-
telemetry: () => runTelemetryCommand(process.argv.slice(3)),
|
|
1405
|
-
failures: () => runFailuresCommand(process.argv.slice(3)),
|
|
1406
|
-
scorecard: () => runScorecardCommand(process.argv.slice(3)),
|
|
1407
|
-
upkeep: () => runUpkeepCommand(process.argv.slice(3)),
|
|
1408
|
-
curator: () => runCuratorCommand(process.argv.slice(3)),
|
|
1409
|
-
express: () => runExpressCommand(process.argv.slice(3)),
|
|
1410
|
-
daily: commandDaily,
|
|
1411
|
-
schedule: commandSchedule,
|
|
1412
|
-
loop: commandLoop,
|
|
1413
|
-
gateway: commandGateway,
|
|
1414
|
-
skill: commandSkill,
|
|
1415
|
-
catalog: commandCatalog,
|
|
1416
|
-
env: commandEnv,
|
|
1417
|
-
update: () => commandUpdateOrRemove("update"),
|
|
1418
|
-
remove: () => commandUpdateOrRemove("remove"),
|
|
1419
|
-
doctor: commandDoctor,
|
|
1420
|
-
repair: commandRepair,
|
|
1421
|
-
browser: commandBrowser,
|
|
38
|
+
tasks: commandTasks,
|
|
39
|
+
sessions: commandSessions,
|
|
1422
40
|
run: commandRun,
|
|
1423
41
|
profiles: () => runProfilesCommand(process.argv.slice(3)),
|
|
1424
|
-
|
|
42
|
+
schedule: commandSchedule,
|
|
43
|
+
service: commandService,
|
|
44
|
+
cost: commandCost,
|
|
45
|
+
clients: commandClients,
|
|
46
|
+
connectors: commandConnectors,
|
|
47
|
+
mcp: commandMcp,
|
|
48
|
+
skills: commandSkill,
|
|
49
|
+
browser: commandBrowser,
|
|
50
|
+
memory: commandMemory,
|
|
51
|
+
capture: commandCapture,
|
|
52
|
+
day: commandDay,
|
|
53
|
+
health: commandHealth,
|
|
54
|
+
obsidian: commandObsidian,
|
|
55
|
+
hook: commandHook,
|
|
56
|
+
migrate: commandMigrate,
|
|
57
|
+
intercept: commandIntercept,
|
|
58
|
+
layout: commandLayout,
|
|
1425
59
|
};
|
|
1426
60
|
//# sourceMappingURL=command-registry.js.map
|