@amoree-code/ocean 2.22.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -53
- package/dist/application/clients/bundles.js +220 -0
- package/dist/application/clients/chat-plugin.js +4 -42
- 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/clients/zip.js +44 -0
- 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 +55 -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
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { mkdir, readFile, rm } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { isDeepStrictEqual } from "node:util";
|
|
5
|
+
import { profileIdentity } from "@ocean/core/domain/profiles/profile.js";
|
|
6
|
+
import { parseProfileMarkdown, renderProfileMarkdown, } from "@ocean/core/domain/profiles/profile-markdown.js";
|
|
7
|
+
import { validateProfile } from "@ocean/core/domain/profiles/profile-validator.js";
|
|
8
|
+
import { listProfileEntries, profileCollisions, profilesDir, } from "@ocean/core/profiles/profile-files.js";
|
|
9
|
+
import { atomicWrite, withFileLock } from "@ocean/core/shared/fs-utils.js";
|
|
10
|
+
const sha256 = (text) => createHash("sha256").update(text).digest("hex");
|
|
11
|
+
function migrateDir() {
|
|
12
|
+
return path.join(profilesDir(), ".migrate");
|
|
13
|
+
}
|
|
14
|
+
function manifestFile() {
|
|
15
|
+
return path.join(migrateDir(), "manifest.json");
|
|
16
|
+
}
|
|
17
|
+
async function readManifest() {
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(await readFile(manifestFile(), "utf8"));
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
if (error.code === "ENOENT")
|
|
23
|
+
return null;
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// An empty body and a missing `instructions` field are the same profile.
|
|
28
|
+
function comparable(raw) {
|
|
29
|
+
const { instructions, ...rest } = raw;
|
|
30
|
+
return instructions === "" || instructions === undefined
|
|
31
|
+
? rest
|
|
32
|
+
: { ...rest, instructions };
|
|
33
|
+
}
|
|
34
|
+
// Messages name fields, never values: a validation error says which field, and a parse error
|
|
35
|
+
// is not repeated because the parser quotes the file around it.
|
|
36
|
+
function convert(name, source) {
|
|
37
|
+
let raw;
|
|
38
|
+
try {
|
|
39
|
+
raw = JSON.parse(source);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return { issues: ["invalid JSON"] };
|
|
43
|
+
}
|
|
44
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
45
|
+
return { issues: ["profile must be an object"] };
|
|
46
|
+
const record = raw;
|
|
47
|
+
if (record.name !== name)
|
|
48
|
+
return {
|
|
49
|
+
issues: [`declares name "${String(record.name)}", expected "${name}"`],
|
|
50
|
+
};
|
|
51
|
+
const next = renderProfileMarkdown(record);
|
|
52
|
+
// The Markdown must read back as exactly the same fields, not only the same identity: the
|
|
53
|
+
// loader merges these fields (with a parent's, for `extends`) before validating them.
|
|
54
|
+
let back;
|
|
55
|
+
try {
|
|
56
|
+
back = parseProfileMarkdown(next, `${name}.md`);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return { issues: ["the Markdown form does not read back; edit by hand"] };
|
|
60
|
+
}
|
|
61
|
+
if (!isDeepStrictEqual(comparable(back), comparable(record)))
|
|
62
|
+
return {
|
|
63
|
+
issues: [
|
|
64
|
+
"the Markdown form would change the profile (instructions with surrounding whitespace?); edit by hand",
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
// A profile that extends another is only complete once merged, so it is not validated alone.
|
|
68
|
+
if (record.extends === undefined)
|
|
69
|
+
try {
|
|
70
|
+
const before = profileIdentity(validateProfile(record));
|
|
71
|
+
if (profileIdentity(validateProfile(back)) !== before)
|
|
72
|
+
return { issues: ["identity would change; edit by hand"] };
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
return { issues: [error.message] };
|
|
76
|
+
}
|
|
77
|
+
return { next };
|
|
78
|
+
}
|
|
79
|
+
export async function planProfileMigration() {
|
|
80
|
+
const listed = await listProfileEntries();
|
|
81
|
+
const collisions = new Set(profileCollisions(listed));
|
|
82
|
+
const entries = [];
|
|
83
|
+
for (const item of listed) {
|
|
84
|
+
const { name, file } = item;
|
|
85
|
+
if (collisions.has(name)) {
|
|
86
|
+
if (!entries.some((entry) => entry.name === name))
|
|
87
|
+
entries.push({
|
|
88
|
+
name,
|
|
89
|
+
file,
|
|
90
|
+
status: "collision",
|
|
91
|
+
issues: ["the profile exists in more than one form; keep one"],
|
|
92
|
+
});
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (item.format === "md") {
|
|
96
|
+
entries.push({ name, file, status: "markdown" });
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (item.format === "directory") {
|
|
100
|
+
entries.push({
|
|
101
|
+
name,
|
|
102
|
+
file: path.dirname(file),
|
|
103
|
+
status: "legacy-directory",
|
|
104
|
+
issues: ["legacy directory profiles are not migrated; convert by hand"],
|
|
105
|
+
});
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const source = await readFile(file, "utf8");
|
|
109
|
+
const result = convert(name, source);
|
|
110
|
+
if ("issues" in result)
|
|
111
|
+
entries.push({ name, file, status: "rejected", issues: result.issues });
|
|
112
|
+
else
|
|
113
|
+
entries.push({
|
|
114
|
+
name,
|
|
115
|
+
file,
|
|
116
|
+
status: "migrate",
|
|
117
|
+
jsonSha256: sha256(source),
|
|
118
|
+
markdownSha256: sha256(result.next),
|
|
119
|
+
next: result.next,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return entries;
|
|
123
|
+
}
|
|
124
|
+
// All or nothing, like the upgrade: one rejected file or collision blocks every write. Every
|
|
125
|
+
// JSON copy is written and verified before any Markdown file is written or JSON removed.
|
|
126
|
+
export async function applyProfileMigration() {
|
|
127
|
+
return withFileLock(manifestFile(), async () => {
|
|
128
|
+
const plan = await planProfileMigration();
|
|
129
|
+
const blocked = plan.filter((entry) => entry.status === "rejected" || entry.status === "collision");
|
|
130
|
+
if (blocked.length)
|
|
131
|
+
return { migrated: [], blocked };
|
|
132
|
+
const pending = plan.filter((entry) => entry.status === "migrate");
|
|
133
|
+
if (!pending.length)
|
|
134
|
+
return { migrated: [], blocked: [] };
|
|
135
|
+
await mkdir(migrateDir(), { recursive: true, mode: 0o700 });
|
|
136
|
+
const previous = await readManifest();
|
|
137
|
+
const manifest = {
|
|
138
|
+
appliedAt: new Date().toISOString(),
|
|
139
|
+
entries: (previous?.entries ?? []).filter((entry) => !pending.some((item) => item.name === entry.name)),
|
|
140
|
+
};
|
|
141
|
+
for (const entry of pending) {
|
|
142
|
+
const source = await readFile(entry.file, "utf8");
|
|
143
|
+
if (sha256(source) !== entry.jsonSha256)
|
|
144
|
+
throw new Error(`${entry.name} changed during the migration; nothing applied`);
|
|
145
|
+
const backup = path.join(migrateDir(), `${entry.name}.${entry.jsonSha256?.slice(0, 12)}.json`);
|
|
146
|
+
await atomicWrite(backup, source, 0o600);
|
|
147
|
+
if (sha256(await readFile(backup, "utf8")) !== entry.jsonSha256)
|
|
148
|
+
throw new Error(`backup of ${entry.name} did not verify; nothing applied`);
|
|
149
|
+
manifest.entries.push({
|
|
150
|
+
name: entry.name,
|
|
151
|
+
jsonSha256: entry.jsonSha256,
|
|
152
|
+
markdownSha256: entry.markdownSha256,
|
|
153
|
+
backup: path.basename(backup),
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
await atomicWrite(manifestFile(), `${JSON.stringify(manifest, null, 2)}\n`, 0o600);
|
|
157
|
+
for (const entry of pending) {
|
|
158
|
+
await atomicWrite(path.join(profilesDir(), `${entry.name}.md`), entry.next, 0o600);
|
|
159
|
+
await rm(entry.file);
|
|
160
|
+
}
|
|
161
|
+
return { migrated: pending.map((entry) => entry.name), blocked: [] };
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
// Restores each JSON copy, but only while the Markdown file is still exactly as the migration
|
|
165
|
+
// wrote it; a profile edited since is reported and left alone.
|
|
166
|
+
export async function rollbackProfileMigration() {
|
|
167
|
+
return withFileLock(manifestFile(), async () => {
|
|
168
|
+
const manifest = await readManifest();
|
|
169
|
+
if (!manifest)
|
|
170
|
+
throw new Error("No profile migration to roll back");
|
|
171
|
+
const restored = [];
|
|
172
|
+
const skipped = [];
|
|
173
|
+
for (const entry of manifest.entries) {
|
|
174
|
+
const markdownFile = path.join(profilesDir(), `${entry.name}.md`);
|
|
175
|
+
const jsonFile = path.join(profilesDir(), `${entry.name}.json`);
|
|
176
|
+
const markdown = await readFile(markdownFile, "utf8").catch(() => null);
|
|
177
|
+
const json = await readFile(jsonFile, "utf8").catch(() => null);
|
|
178
|
+
if (markdown === null) {
|
|
179
|
+
if (json !== null && sha256(json) === entry.jsonSha256)
|
|
180
|
+
restored.push(entry.name);
|
|
181
|
+
else
|
|
182
|
+
skipped.push({ name: entry.name, reason: "profile file is missing" });
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (json !== null) {
|
|
186
|
+
skipped.push({ name: entry.name, reason: "a JSON file exists again" });
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
if (sha256(markdown) !== entry.markdownSha256) {
|
|
190
|
+
skipped.push({
|
|
191
|
+
name: entry.name,
|
|
192
|
+
reason: "edited since the migration",
|
|
193
|
+
});
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
const backup = await readFile(path.join(migrateDir(), entry.backup), "utf8");
|
|
197
|
+
if (sha256(backup) !== entry.jsonSha256) {
|
|
198
|
+
skipped.push({ name: entry.name, reason: "backup does not verify" });
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
await atomicWrite(jsonFile, backup, 0o600);
|
|
202
|
+
await rm(markdownFile);
|
|
203
|
+
restored.push(entry.name);
|
|
204
|
+
}
|
|
205
|
+
return { restored, skipped };
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=profile-migration-service.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { appendFile, mkdir,
|
|
1
|
+
import { appendFile, mkdir, readFile } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { suggestProfile, } from "@ocean/core/domain/profiles/profile-selection.js";
|
|
4
|
+
import { listProfileNames } from "@ocean/core/profiles/profile-files.js";
|
|
4
5
|
import { parseFrontmatter } from "@ocean/core/shared/fs-utils.js";
|
|
5
6
|
import { oceanPath, SYSTEM_DIR } from "@ocean/core/shared/paths.js";
|
|
6
7
|
import { resolveTaskReference } from "@ocean/core/shared/task-reference.js";
|
|
@@ -8,11 +9,6 @@ function objective(body) {
|
|
|
8
9
|
const match = /^## Objective\s*\n([\s\S]*?)(?=^## |$(?![\s\S]))/m.exec(body);
|
|
9
10
|
return match ? match[1].trim() : "";
|
|
10
11
|
}
|
|
11
|
-
async function installedProfiles() {
|
|
12
|
-
return (await readdir(oceanPath(SYSTEM_DIR, "profiles")).catch(() => []))
|
|
13
|
-
.filter((name) => name.endsWith(".json"))
|
|
14
|
-
.map((name) => name.slice(0, -".json".length));
|
|
15
|
-
}
|
|
16
12
|
export async function selectProfileForTask(ref, options = {}) {
|
|
17
13
|
const location = await resolveTaskReference(ref, { cwd: options.cwd });
|
|
18
14
|
const source = await readFile(location.file, "utf8");
|
|
@@ -24,7 +20,7 @@ export async function selectProfileForTask(ref, options = {}) {
|
|
|
24
20
|
class: fields.class,
|
|
25
21
|
risk: fields.risk,
|
|
26
22
|
objective: objective(source),
|
|
27
|
-
}, await
|
|
23
|
+
}, await listProfileNames());
|
|
28
24
|
const selection = {
|
|
29
25
|
task: location.id,
|
|
30
26
|
profile: options.override ?? suggested.profile,
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { mkdir,
|
|
2
|
+
import { mkdir, readFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { parseProfileMarkdown, renderProfileMarkdown, } from "@ocean/core/domain/profiles/profile-markdown.js";
|
|
4
5
|
import { upgradeProfile } from "@ocean/core/domain/profiles/profile-upgrade.js";
|
|
6
|
+
import { listProfileEntries, listProfileNames, profileCollisions, profilesDir, } from "@ocean/core/profiles/profile-files.js";
|
|
5
7
|
import { atomicWrite, withFileLock } from "@ocean/core/shared/fs-utils.js";
|
|
6
|
-
import { oceanPath, SYSTEM_DIR } from "@ocean/core/shared/paths.js";
|
|
7
8
|
const sha256 = (text) => createHash("sha256").update(text).digest("hex");
|
|
8
|
-
export function profilesDir() {
|
|
9
|
-
return oceanPath(SYSTEM_DIR, "profiles");
|
|
10
|
-
}
|
|
11
9
|
// Backups and the manifest live beside the profiles, under a name no profile can have.
|
|
12
10
|
function upgradeDir() {
|
|
13
11
|
return path.join(profilesDir(), ".upgrade");
|
|
@@ -25,83 +23,106 @@ async function readManifest() {
|
|
|
25
23
|
throw error;
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
// How each form is named in a collision message, `.json` first as it always was.
|
|
27
|
+
const formOrder = { json: 0, md: 1, directory: 2 };
|
|
28
|
+
function describeForm(entry) {
|
|
29
|
+
return entry.format === "directory"
|
|
30
|
+
? `the legacy directory ${entry.name}/`
|
|
31
|
+
: path.basename(entry.file);
|
|
30
32
|
}
|
|
31
33
|
export async function planProfileUpgrade() {
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
+
const listed = await listProfileEntries();
|
|
35
|
+
const collisions = new Set(profileCollisions(listed));
|
|
34
36
|
const entries = [];
|
|
35
|
-
for (const
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
if (entry.endsWith(".json")) {
|
|
40
|
-
const name = entry.slice(0, -".json".length);
|
|
41
|
-
if (await isDirectory(path.join(dir, name))) {
|
|
42
|
-
entries.push({
|
|
43
|
-
name,
|
|
44
|
-
file: full,
|
|
45
|
-
status: "collision",
|
|
46
|
-
issues: [`both ${entry} and the legacy directory ${name}/ exist`],
|
|
47
|
-
});
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
const source = await readFile(full, "utf8");
|
|
51
|
-
let raw;
|
|
52
|
-
try {
|
|
53
|
-
raw = JSON.parse(source);
|
|
54
|
-
}
|
|
55
|
-
catch {
|
|
56
|
-
// The parser's message quotes the file around the error; it is not repeated.
|
|
57
|
-
entries.push({
|
|
58
|
-
name,
|
|
59
|
-
file: full,
|
|
60
|
-
status: "rejected",
|
|
61
|
-
issues: ["invalid JSON"],
|
|
62
|
-
});
|
|
37
|
+
for (const item of listed) {
|
|
38
|
+
const { name } = item;
|
|
39
|
+
if (collisions.has(name)) {
|
|
40
|
+
if (entries.some((entry) => entry.name === name))
|
|
63
41
|
continue;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
if (result.status === "upgrade") {
|
|
77
|
-
const next = `${JSON.stringify(result.profile, null, 2)}\n`;
|
|
78
|
-
entries.push({
|
|
79
|
-
name,
|
|
80
|
-
file: full,
|
|
81
|
-
status: "upgrade",
|
|
82
|
-
changes: result.changes,
|
|
83
|
-
v1Sha256: sha256(source),
|
|
84
|
-
v2Sha256: sha256(next),
|
|
85
|
-
next,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
else if (result.status === "rejected")
|
|
89
|
-
entries.push({
|
|
90
|
-
name,
|
|
91
|
-
file: full,
|
|
92
|
-
status: "rejected",
|
|
93
|
-
issues: result.issues,
|
|
94
|
-
});
|
|
95
|
-
else
|
|
96
|
-
entries.push({ name, file: full, status: "current" });
|
|
42
|
+
const forms = listed
|
|
43
|
+
.filter((entry) => entry.name === name)
|
|
44
|
+
.sort((a, b) => formOrder[a.format] - formOrder[b.format])
|
|
45
|
+
.map(describeForm);
|
|
46
|
+
entries.push({
|
|
47
|
+
name,
|
|
48
|
+
file: item.file,
|
|
49
|
+
status: "collision",
|
|
50
|
+
issues: [`both ${forms.join(" and ")} exist`],
|
|
51
|
+
});
|
|
52
|
+
continue;
|
|
97
53
|
}
|
|
98
|
-
|
|
54
|
+
if (item.format === "directory") {
|
|
99
55
|
entries.push({
|
|
100
|
-
name
|
|
101
|
-
file:
|
|
56
|
+
name,
|
|
57
|
+
file: path.dirname(item.file),
|
|
102
58
|
status: "legacy-directory",
|
|
103
59
|
issues: ["legacy directory profiles are not upgraded; convert by hand"],
|
|
104
60
|
});
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const full = item.file;
|
|
64
|
+
const markdown = item.format === "md";
|
|
65
|
+
const source = await readFile(full, "utf8");
|
|
66
|
+
let raw;
|
|
67
|
+
try {
|
|
68
|
+
raw = markdown ? parseProfileMarkdown(source, full) : JSON.parse(source);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
// The parser's message quotes the file around the error; it is not repeated.
|
|
72
|
+
entries.push({
|
|
73
|
+
name,
|
|
74
|
+
file: full,
|
|
75
|
+
status: "rejected",
|
|
76
|
+
issues: [markdown ? "invalid frontmatter" : "invalid JSON"],
|
|
77
|
+
});
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
// A profile that extends another holds only what it changes, so alone it is not a whole
|
|
81
|
+
// profile to upgrade; the upgrade is the parent's (T-338).
|
|
82
|
+
const parent = raw?.extends;
|
|
83
|
+
if (parent !== undefined) {
|
|
84
|
+
entries.push({
|
|
85
|
+
name,
|
|
86
|
+
file: full,
|
|
87
|
+
status: "inherits",
|
|
88
|
+
issues: [`extends ${String(parent)}; upgrade that profile instead`],
|
|
89
|
+
});
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const result = upgradeProfile(raw);
|
|
93
|
+
const declared = raw?.name;
|
|
94
|
+
if (result.status !== "rejected" && declared !== name) {
|
|
95
|
+
entries.push({
|
|
96
|
+
name,
|
|
97
|
+
file: full,
|
|
98
|
+
status: "rejected",
|
|
99
|
+
issues: [`declares name "${String(declared)}", expected "${name}"`],
|
|
100
|
+
});
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (result.status === "upgrade") {
|
|
104
|
+
const next = markdown
|
|
105
|
+
? renderProfileMarkdown(result.profile)
|
|
106
|
+
: `${JSON.stringify(result.profile, null, 2)}\n`;
|
|
107
|
+
entries.push({
|
|
108
|
+
name,
|
|
109
|
+
file: full,
|
|
110
|
+
status: "upgrade",
|
|
111
|
+
changes: result.changes,
|
|
112
|
+
v1Sha256: sha256(source),
|
|
113
|
+
v2Sha256: sha256(next),
|
|
114
|
+
next,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
else if (result.status === "rejected")
|
|
118
|
+
entries.push({
|
|
119
|
+
name,
|
|
120
|
+
file: full,
|
|
121
|
+
status: "rejected",
|
|
122
|
+
issues: result.issues,
|
|
123
|
+
});
|
|
124
|
+
else
|
|
125
|
+
entries.push({ name, file: full, status: "current" });
|
|
105
126
|
}
|
|
106
127
|
return entries;
|
|
107
128
|
}
|
|
@@ -129,7 +150,7 @@ export async function applyProfileUpgrade() {
|
|
|
129
150
|
const source = await readFile(entry.file, "utf8");
|
|
130
151
|
if (sha256(source) !== entry.v1Sha256)
|
|
131
152
|
throw new Error(`${entry.name} changed during the upgrade; nothing applied`);
|
|
132
|
-
const backup = path.join(upgradeDir(), `${entry.name}.${entry.v1Sha256?.slice(0, 12)}.v1.
|
|
153
|
+
const backup = path.join(upgradeDir(), `${entry.name}.${entry.v1Sha256?.slice(0, 12)}.v1${path.extname(entry.file)}`);
|
|
133
154
|
await atomicWrite(backup, source, 0o600);
|
|
134
155
|
if (sha256(await readFile(backup, "utf8")) !== entry.v1Sha256)
|
|
135
156
|
throw new Error(`backup of ${entry.name} did not verify; nothing applied`);
|
|
@@ -138,6 +159,7 @@ export async function applyProfileUpgrade() {
|
|
|
138
159
|
v1Sha256: entry.v1Sha256,
|
|
139
160
|
v2Sha256: entry.v2Sha256,
|
|
140
161
|
backup: path.basename(backup),
|
|
162
|
+
file: path.basename(entry.file),
|
|
141
163
|
});
|
|
142
164
|
}
|
|
143
165
|
await atomicWrite(manifestFile(), `${JSON.stringify(manifest, null, 2)}\n`, 0o600);
|
|
@@ -156,7 +178,7 @@ export async function rollbackProfileUpgrade() {
|
|
|
156
178
|
const restored = [];
|
|
157
179
|
const skipped = [];
|
|
158
180
|
for (const entry of manifest.entries) {
|
|
159
|
-
const file = path.join(profilesDir(), `${entry.name}.json`);
|
|
181
|
+
const file = path.join(profilesDir(), entry.file ?? `${entry.name}.json`);
|
|
160
182
|
const current = await readFile(file, "utf8").catch(() => null);
|
|
161
183
|
if (current === null || sha256(current) === entry.v1Sha256) {
|
|
162
184
|
if (current !== null)
|
|
@@ -183,18 +205,8 @@ export async function rollbackProfileUpgrade() {
|
|
|
183
205
|
// Loads every profile the way a run would and reports each failure by name. Messages are
|
|
184
206
|
// validation errors, which name fields, never values from a credential check.
|
|
185
207
|
export async function validateProfiles(load) {
|
|
186
|
-
const dir = profilesDir();
|
|
187
|
-
const names = new Set();
|
|
188
|
-
for (const entry of await readdir(dir).catch(() => [])) {
|
|
189
|
-
if (entry.startsWith("."))
|
|
190
|
-
continue;
|
|
191
|
-
if (entry.endsWith(".json"))
|
|
192
|
-
names.add(entry.slice(0, -".json".length));
|
|
193
|
-
else if (await isDirectory(path.join(dir, entry)))
|
|
194
|
-
names.add(entry);
|
|
195
|
-
}
|
|
196
208
|
const results = [];
|
|
197
|
-
for (const name of
|
|
209
|
+
for (const name of await listProfileNames()) {
|
|
198
210
|
try {
|
|
199
211
|
const profile = await load(name);
|
|
200
212
|
results.push({ name, ok: true, schemaVersion: profile.schemaVersion });
|
|
@@ -5,7 +5,7 @@ import path from "node:path";
|
|
|
5
5
|
import { DatabaseSync } from "node:sqlite";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import zlib from "node:zlib";
|
|
8
|
-
import { redactSecrets } from "@ocean/core/domain/redaction
|
|
8
|
+
import { redactSecrets } from "@ocean/core/domain/redaction.js";
|
|
9
9
|
import { atomicWrite } from "@ocean/core/shared/fs-utils.js";
|
|
10
10
|
import { oceanPath, SYSTEM_DIR } from "@ocean/core/shared/paths.js";
|
|
11
11
|
import { loadProjectIndex, placeFolder } from "./project-match.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import os from "node:os";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { expandHome, listProjectManifests, projectFormerPaths, projectTags, } from "@ocean/core/shared/project-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { expandHome, listProjectManifests, projectFormerPaths, projectTags, } from "@ocean/core/shared/project-manifest.js";
|
|
4
|
+
const UNASSIGNED = "unassigned";
|
|
5
|
+
const SCRATCH = "scratch";
|
|
6
6
|
const lower = (value) => value.toLowerCase();
|
|
7
7
|
export async function loadProjectIndex(home = os.homedir()) {
|
|
8
8
|
const projects = [];
|
|
@@ -23,7 +23,7 @@ import { captureServerHistory } from "./server-capture.js";
|
|
|
23
23
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
24
24
|
const stampFile = () => oceanPath(SYSTEM_DIR, "state", "pull", "last.json");
|
|
25
25
|
const importsDir = () => oceanPath(SYSTEM_DIR, "state", "imports");
|
|
26
|
-
|
|
26
|
+
const runsDir = () => oceanPath(SYSTEM_DIR, "state", "pull", "runs");
|
|
27
27
|
// With `pullAutoApprove: "on"` in bridge/config/memory.json, what this run proposed goes through
|
|
28
28
|
// the same validated write path as an owner's approval, but only as a new record: no target, an
|
|
29
29
|
// existing record to add to, a similar record or a refusal leaves the candidate for review.
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
1
2
|
import { mkdir, open, readdir, readFile } from "node:fs/promises";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import zlib from "node:zlib";
|
|
4
5
|
import { proposeImported, } from "@ocean/brain/memory/memory-harvest.js";
|
|
5
6
|
import { atomicWrite } from "@ocean/core/shared/fs-utils.js";
|
|
6
|
-
import { claudeProjectsFile } from "@ocean/core/shared/project-
|
|
7
|
+
import { claudeProjectsFile, mergeClaudeConversations, readClaudeProjects, } from "@ocean/core/shared/project-legacy.js";
|
|
8
|
+
import { linkClaudeProjectName, } from "@ocean/core/shared/project-register.js";
|
|
7
9
|
import { serverHistoryDir } from "./history-index.js";
|
|
8
10
|
// claude.ai and ChatGPT keep their conversations, projects and memory on their servers (T-305).
|
|
9
11
|
// Claude Desktop and the browsers keep what they fetched of those pages in a Chromium HTTP cache;
|
|
@@ -118,32 +120,113 @@ const iso = (value) => {
|
|
|
118
120
|
};
|
|
119
121
|
// Project uuid → name, from the claude.ai project responses Claude Desktop and the browsers
|
|
120
122
|
// cached.
|
|
121
|
-
function projectNames(entries) {
|
|
123
|
+
function projectNames(entries, keep = () => true) {
|
|
122
124
|
const names = new Map();
|
|
123
125
|
for (const { url, json } of entries) {
|
|
124
126
|
if (/\/projects(_v2)?(\?|$)/.test(url))
|
|
125
127
|
for (const project of list(json))
|
|
126
|
-
if (text(project.uuid))
|
|
128
|
+
if (text(project.uuid) && keep(project))
|
|
127
129
|
names.set(text(project.uuid), text(project.name));
|
|
128
130
|
const one = new RegExp(`/projects/(${UUID})(\\?|$)`).exec(url)?.[1];
|
|
129
|
-
if (one && text(object(json).name))
|
|
131
|
+
if (one && text(object(json).name) && keep(object(json)))
|
|
130
132
|
names.set(one, text(object(json).name));
|
|
131
133
|
}
|
|
132
134
|
return names;
|
|
133
135
|
}
|
|
136
|
+
// A project the owner can delete is his own; one shared with him in a team organization (view
|
|
137
|
+
// only) is not his to rename or to file under, so its name is not one of his. A response without
|
|
138
|
+
// permissions says nothing either way, and the project is kept.
|
|
139
|
+
function isOwned(project) {
|
|
140
|
+
const permissions = project.permissions;
|
|
141
|
+
return (!Array.isArray(permissions) || permissions.includes("chat_project:delete"));
|
|
142
|
+
}
|
|
143
|
+
async function claudeEntries(home) {
|
|
144
|
+
return (await readCaches(home)).filter((entry) => entry.url.includes("claude.ai/"));
|
|
145
|
+
}
|
|
134
146
|
// The names of the owner's Claude projects that this machine has seen (T-307): what lets Ocean
|
|
135
147
|
// tell a real Claude project from a topic a client calls a project. Read-only, from the caches.
|
|
136
148
|
export async function claudeProjectNames(home) {
|
|
137
|
-
|
|
138
|
-
|
|
149
|
+
return namesIn(await claudeEntries(home));
|
|
150
|
+
}
|
|
151
|
+
// An account whose newest list is this much older than the newest list of any account is one
|
|
152
|
+
// this machine no longer uses: its cached names are not the owner's projects today.
|
|
153
|
+
const STALE_ACCOUNT_MS = 30 * 24 * 60 * 60 * 1000;
|
|
154
|
+
const PROJECT_LIST = /\/projects(_v2)?(\?|$)/;
|
|
155
|
+
// A list of every project the account has: not a lookup by uuid, not starred, not filtered by
|
|
156
|
+
// creator, type or search, not the archive, and not a page cut short by its limit.
|
|
157
|
+
function isFullList({ url, json }) {
|
|
158
|
+
const query = new URL(url, "https://claude.ai").searchParams;
|
|
159
|
+
if (["uuids", "starred", "filter", "creator_filter", "type"].some((key) => query.has(key)))
|
|
160
|
+
return false;
|
|
161
|
+
if (query.get("is_archived") === "true" || query.get("searchQuery"))
|
|
162
|
+
return false;
|
|
163
|
+
const limit = Number(query.get("limit"));
|
|
164
|
+
return !(limit && list(json).length >= limit);
|
|
139
165
|
}
|
|
140
|
-
//
|
|
166
|
+
// The names of the projects the owner has now. A cache keeps every response it was ever sent, so
|
|
167
|
+
// a project since deleted or renamed is still named by an older one (T-330): for each account the
|
|
168
|
+
// newest full list is what it has, plus any project named in a response newer than that list. An
|
|
169
|
+
// account with no full list keeps every name it was sent; an account not seen for a month is
|
|
170
|
+
// dropped; a project someone else made and only shared with the owner is left out.
|
|
171
|
+
function currentProjectNames(entries) {
|
|
172
|
+
const byOrg = new Map();
|
|
173
|
+
for (const entry of entries) {
|
|
174
|
+
if (!entry.url.includes("/projects"))
|
|
175
|
+
continue;
|
|
176
|
+
const org = /\/organizations\/([^/?]+)/.exec(entry.url)?.[1] ?? "";
|
|
177
|
+
byOrg.set(org, [...(byOrg.get(org) ?? []), entry]);
|
|
178
|
+
}
|
|
179
|
+
const newestList = (items) => Math.max(0, ...items
|
|
180
|
+
.filter((each) => PROJECT_LIST.test(each.url))
|
|
181
|
+
.map((each) => each.at));
|
|
182
|
+
const latest = Math.max(0, ...[...byOrg.values()].map(newestList));
|
|
183
|
+
const names = [];
|
|
184
|
+
for (const items of byOrg.values()) {
|
|
185
|
+
const newest = newestList(items);
|
|
186
|
+
if (newest && latest - newest > STALE_ACCOUNT_MS)
|
|
187
|
+
continue;
|
|
188
|
+
const full = items
|
|
189
|
+
.filter((each) => PROJECT_LIST.test(each.url) && isFullList(each))
|
|
190
|
+
.sort((a, b) => b.at - a.at)[0];
|
|
191
|
+
const kept = full
|
|
192
|
+
? items.filter((each) => each === full || each.at > full.at)
|
|
193
|
+
: items;
|
|
194
|
+
names.push(...projectNames(kept, isOwned).values());
|
|
195
|
+
}
|
|
196
|
+
return [...new Set(names)].filter(Boolean);
|
|
197
|
+
}
|
|
198
|
+
function namesIn(entries) {
|
|
199
|
+
return currentProjectNames(entries);
|
|
200
|
+
}
|
|
201
|
+
// Writes those names (names only, owner-only file) where a tool call can read them at once, and
|
|
202
|
+
// each conversation's title and Claude project (T-333). A name not in the last list is seen for
|
|
203
|
+
// the first time and linked to its project; the very first list only records, so a new machine
|
|
204
|
+
// never registers every Claude project it finds at once.
|
|
141
205
|
export async function refreshClaudeProjects(home) {
|
|
142
|
-
const
|
|
206
|
+
const entries = await claudeEntries(home);
|
|
207
|
+
const names = namesIn(entries);
|
|
208
|
+
const previous = existsSync(claudeProjectsFile())
|
|
209
|
+
? new Set(await readClaudeProjects())
|
|
210
|
+
: undefined;
|
|
143
211
|
const file = claudeProjectsFile();
|
|
144
212
|
await mkdir(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
145
213
|
await atomicWrite(file, `${JSON.stringify({ at: new Date().toISOString(), names }, null, 2)}\n`, 0o600);
|
|
146
|
-
|
|
214
|
+
const found = {};
|
|
215
|
+
for (const row of claudeAi(entries).conversations.values())
|
|
216
|
+
found[row.id] = {
|
|
217
|
+
title: row.title,
|
|
218
|
+
...(row.projectName ? { projectName: row.projectName } : {}),
|
|
219
|
+
...(row.updated ? { updated: row.updated } : {}),
|
|
220
|
+
};
|
|
221
|
+
const conversations = await mergeClaudeConversations(found);
|
|
222
|
+
const linked = [];
|
|
223
|
+
// A name that cannot become a project (its folder is taken) is left to `ocean project doctor`.
|
|
224
|
+
for (const name of previous ? names.filter((n) => !previous.has(n)) : []) {
|
|
225
|
+
const link = await linkClaudeProjectName(name).catch(() => undefined);
|
|
226
|
+
if (link)
|
|
227
|
+
linked.push(link);
|
|
228
|
+
}
|
|
229
|
+
return { names: names.length, conversations, linked };
|
|
147
230
|
}
|
|
148
231
|
function claudeAi(entries) {
|
|
149
232
|
const names = projectNames(entries);
|
|
@@ -2,8 +2,8 @@ import { mkdir, open, readFile, rename, unlink, writeFile, } from "node:fs/promi
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { assertGuard, guardProblems, } from "@ocean/core/domain/runs/loop-guard.js";
|
|
4
4
|
import { oceanPath, SYSTEM_DIR } from "@ocean/core/shared/paths.js";
|
|
5
|
-
import { afterGuardedRun, emptyUsage, writeEscalation, } from "@ocean/
|
|
6
|
-
import { runAgent } from "@ocean/
|
|
5
|
+
import { afterGuardedRun, emptyUsage, writeEscalation, } from "@ocean/work/runs/guard-runtime.js";
|
|
6
|
+
import { runAgent } from "@ocean/work/runs/run-agent.js";
|
|
7
7
|
const file = () => oceanPath(SYSTEM_DIR, "schedules.json");
|
|
8
8
|
const running = new Set();
|
|
9
9
|
export async function listSchedules() {
|