oh-my-codex 0.20.0 → 0.20.2
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/Cargo.lock +6 -6
- package/Cargo.toml +1 -1
- package/README.md +10 -1
- package/dist/adapt/__tests__/hermes.test.js.map +1 -1
- package/dist/adapt/contracts.d.ts.map +1 -1
- package/dist/agents/native-config.js.map +1 -1
- package/dist/auth/__tests__/hotswap.test.d.ts +2 -0
- package/dist/auth/__tests__/hotswap.test.d.ts.map +1 -0
- package/dist/auth/__tests__/hotswap.test.js +183 -0
- package/dist/auth/__tests__/hotswap.test.js.map +1 -0
- package/dist/auth/hotswap.d.ts.map +1 -1
- package/dist/auth/hotswap.js +17 -4
- package/dist/auth/hotswap.js.map +1 -1
- package/dist/auth/paths.js.map +1 -1
- package/dist/auth/storage.js.map +1 -1
- package/dist/autopilot/__tests__/ralplan-gate.test.js +4 -4
- package/dist/autopilot/__tests__/ralplan-gate.test.js.map +1 -1
- package/dist/autopilot/completion-gate.js.map +1 -1
- package/dist/autopilot/fsm.d.ts +1 -1
- package/dist/autopilot/fsm.d.ts.map +1 -1
- package/dist/autoresearch/goal.js.map +1 -1
- package/dist/autoresearch/runtime.js.map +1 -1
- package/dist/capabilities/lockfile.js.map +1 -1
- package/dist/catalog/reader.js.map +1 -1
- package/dist/catalog/skill-mirror.js.map +1 -1
- package/dist/cli/__tests__/adapt-help.test.js.map +1 -1
- package/dist/cli/__tests__/agents-init.test.js.map +1 -1
- package/dist/cli/__tests__/agents.test.js.map +1 -1
- package/dist/cli/__tests__/api.test.js.map +1 -1
- package/dist/cli/__tests__/ask.test.js.map +1 -1
- package/dist/cli/__tests__/auth.test.js.map +1 -1
- package/dist/cli/__tests__/autoresearch-guided.test.js.map +1 -1
- package/dist/cli/__tests__/autoresearch.test.js.map +1 -1
- package/dist/cli/__tests__/capabilities.test.js.map +1 -1
- package/dist/cli/__tests__/codex-plugin-layout.test.js +27 -0
- package/dist/cli/__tests__/codex-plugin-layout.test.js.map +1 -1
- package/dist/cli/__tests__/doctor-context-window-warning.test.js +83 -78
- package/dist/cli/__tests__/doctor-context-window-warning.test.js.map +1 -1
- package/dist/cli/__tests__/doctor-invalid-config.test.js +56 -4
- package/dist/cli/__tests__/doctor-invalid-config.test.js.map +1 -1
- package/dist/cli/__tests__/doctor-team.test.js.map +1 -1
- package/dist/cli/__tests__/doctor-warning-copy.test.js +735 -14
- package/dist/cli/__tests__/doctor-warning-copy.test.js.map +1 -1
- package/dist/cli/__tests__/exec.test.js.map +1 -1
- package/dist/cli/__tests__/imagegen-continuation.test.js.map +1 -1
- package/dist/cli/__tests__/index.test.js +216 -11
- package/dist/cli/__tests__/index.test.js.map +1 -1
- package/dist/cli/__tests__/launch-fallback.test.js +49 -3
- package/dist/cli/__tests__/launch-fallback.test.js.map +1 -1
- package/dist/cli/__tests__/mcp-parity.test.js +84 -12
- package/dist/cli/__tests__/mcp-parity.test.js.map +1 -1
- package/dist/cli/__tests__/native-hook-claim-journal.test.d.ts +2 -0
- package/dist/cli/__tests__/native-hook-claim-journal.test.d.ts.map +1 -0
- package/dist/cli/__tests__/native-hook-claim-journal.test.js +128 -0
- package/dist/cli/__tests__/native-hook-claim-journal.test.js.map +1 -0
- package/dist/cli/__tests__/nested-help-routing.test.js.map +1 -1
- package/dist/cli/__tests__/question.test.js.map +1 -1
- package/dist/cli/__tests__/ralph-deslop-contract.test.js.map +1 -1
- package/dist/cli/__tests__/ralph-goal-mode-contract.test.js +6 -0
- package/dist/cli/__tests__/ralph-goal-mode-contract.test.js.map +1 -1
- package/dist/cli/__tests__/ralph-prd-deep-interview.test.js.map +1 -1
- package/dist/cli/__tests__/ralph-prd-smoke.test.js.map +1 -1
- package/dist/cli/__tests__/ralph.test.js +8 -3
- package/dist/cli/__tests__/ralph.test.js.map +1 -1
- package/dist/cli/__tests__/ralplan-bootstrap-3181.test.d.ts +2 -0
- package/dist/cli/__tests__/ralplan-bootstrap-3181.test.d.ts.map +1 -0
- package/dist/cli/__tests__/ralplan-bootstrap-3181.test.js +187 -0
- package/dist/cli/__tests__/ralplan-bootstrap-3181.test.js.map +1 -0
- package/dist/cli/__tests__/ralplan.test.d.ts +2 -0
- package/dist/cli/__tests__/ralplan.test.d.ts.map +1 -0
- package/dist/cli/__tests__/ralplan.test.js +129 -0
- package/dist/cli/__tests__/ralplan.test.js.map +1 -0
- package/dist/cli/__tests__/resume.test.js +6 -1
- package/dist/cli/__tests__/resume.test.js.map +1 -1
- package/dist/cli/__tests__/session-scoped-runtime.test.js +25 -0
- package/dist/cli/__tests__/session-scoped-runtime.test.js.map +1 -1
- package/dist/cli/__tests__/session-search-help.test.js.map +1 -1
- package/dist/cli/__tests__/session-search.test.js.map +1 -1
- package/dist/cli/__tests__/setup-agents-overwrite.test.js +79 -0
- package/dist/cli/__tests__/setup-agents-overwrite.test.js.map +1 -1
- package/dist/cli/__tests__/setup-gh-star.test.js.map +1 -1
- package/dist/cli/__tests__/setup-hooks-shared-ownership.test.js +131 -5
- package/dist/cli/__tests__/setup-hooks-shared-ownership.test.js.map +1 -1
- package/dist/cli/__tests__/setup-hooks-trust-e2e.test.d.ts +2 -0
- package/dist/cli/__tests__/setup-hooks-trust-e2e.test.d.ts.map +1 -0
- package/dist/cli/__tests__/setup-hooks-trust-e2e.test.js +285 -0
- package/dist/cli/__tests__/setup-hooks-trust-e2e.test.js.map +1 -0
- package/dist/cli/__tests__/setup-install-mode.test.js +2264 -17
- package/dist/cli/__tests__/setup-install-mode.test.js.map +1 -1
- package/dist/cli/__tests__/setup-preferences.test.d.ts +2 -0
- package/dist/cli/__tests__/setup-preferences.test.d.ts.map +1 -0
- package/dist/cli/__tests__/setup-preferences.test.js +79 -0
- package/dist/cli/__tests__/setup-preferences.test.js.map +1 -0
- package/dist/cli/__tests__/setup-refresh.test.js +168 -5
- package/dist/cli/__tests__/setup-refresh.test.js.map +1 -1
- package/dist/cli/__tests__/setup-scope.test.js +73 -6
- package/dist/cli/__tests__/setup-scope.test.js.map +1 -1
- package/dist/cli/__tests__/sparkshell-cli.test.js.map +1 -1
- package/dist/cli/__tests__/state.test.js +37 -0
- package/dist/cli/__tests__/state.test.js.map +1 -1
- package/dist/cli/__tests__/team.test.js.map +1 -1
- package/dist/cli/__tests__/ultragoal.test.js +61 -1
- package/dist/cli/__tests__/ultragoal.test.js.map +1 -1
- package/dist/cli/__tests__/uninstall.test.js +2067 -26
- package/dist/cli/__tests__/uninstall.test.js.map +1 -1
- package/dist/cli/__tests__/update.test.js +58 -0
- package/dist/cli/__tests__/update.test.js.map +1 -1
- package/dist/cli/__tests__/url.test.js.map +1 -1
- package/dist/cli/__tests__/windows-popup-loop-contract.test.js.map +1 -1
- package/dist/cli/adapt.js.map +1 -1
- package/dist/cli/agents-init.js.map +1 -1
- package/dist/cli/agents.js.map +1 -1
- package/dist/cli/api.js.map +1 -1
- package/dist/cli/ask.d.ts +1 -1
- package/dist/cli/ask.d.ts.map +1 -1
- package/dist/cli/ask.js.map +1 -1
- package/dist/cli/auth.js.map +1 -1
- package/dist/cli/autoresearch-guided.js.map +1 -1
- package/dist/cli/autoresearch-intake.js.map +1 -1
- package/dist/cli/capabilities.js.map +1 -1
- package/dist/cli/cleanup.js.map +1 -1
- package/dist/cli/codex-feature-probe.js.map +1 -1
- package/dist/cli/codex-home.js.map +1 -1
- package/dist/cli/doctor.d.ts +20 -0
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +636 -161
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/explore.js.map +1 -1
- package/dist/cli/index.d.ts +11 -3
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +108 -20
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/mcp-serve.js.map +1 -1
- package/dist/cli/mission.js.map +1 -1
- package/dist/cli/native-assets.js.map +1 -1
- package/dist/cli/native-hook-claim-journal.d.ts +18 -0
- package/dist/cli/native-hook-claim-journal.d.ts.map +1 -0
- package/dist/cli/native-hook-claim-journal.js +239 -0
- package/dist/cli/native-hook-claim-journal.js.map +1 -0
- package/dist/cli/omx.js.map +1 -1
- package/dist/cli/plugin-marketplace.js.map +1 -1
- package/dist/cli/project-runtime-codex-homes.js.map +1 -1
- package/dist/cli/question.js.map +1 -1
- package/dist/cli/ralph.d.ts.map +1 -1
- package/dist/cli/ralph.js +3 -2
- package/dist/cli/ralph.js.map +1 -1
- package/dist/cli/ralplan.d.ts +14 -0
- package/dist/cli/ralplan.d.ts.map +1 -0
- package/dist/cli/ralplan.js +203 -0
- package/dist/cli/ralplan.js.map +1 -0
- package/dist/cli/setup-preferences.d.ts +11 -0
- package/dist/cli/setup-preferences.d.ts.map +1 -1
- package/dist/cli/setup-preferences.js +32 -0
- package/dist/cli/setup-preferences.js.map +1 -1
- package/dist/cli/setup.d.ts +53 -0
- package/dist/cli/setup.d.ts.map +1 -1
- package/dist/cli/setup.js +1403 -400
- package/dist/cli/setup.js.map +1 -1
- package/dist/cli/sparkshell.js.map +1 -1
- package/dist/cli/star-prompt.js.map +1 -1
- package/dist/cli/state.d.ts.map +1 -1
- package/dist/cli/state.js +2 -1
- package/dist/cli/state.js.map +1 -1
- package/dist/cli/team.js.map +1 -1
- package/dist/cli/ultragoal.d.ts +5 -1
- package/dist/cli/ultragoal.d.ts.map +1 -1
- package/dist/cli/ultragoal.js +34 -2
- package/dist/cli/ultragoal.js.map +1 -1
- package/dist/cli/uninstall.d.ts +8 -0
- package/dist/cli/uninstall.d.ts.map +1 -1
- package/dist/cli/uninstall.js +947 -99
- package/dist/cli/uninstall.js.map +1 -1
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +8 -1
- package/dist/cli/update.js.map +1 -1
- package/dist/cli/url.js.map +1 -1
- package/dist/compat/__tests__/doctor-contract.test.js +5 -1
- package/dist/compat/__tests__/doctor-contract.test.js.map +1 -1
- package/dist/compat/__tests__/rust-runtime-compat.test.js.map +1 -1
- package/dist/config/__tests__/codex-hooks.test.js +1287 -11
- package/dist/config/__tests__/codex-hooks.test.js.map +1 -1
- package/dist/config/__tests__/generator-idempotent.test.js +1049 -135
- package/dist/config/__tests__/generator-idempotent.test.js.map +1 -1
- package/dist/config/__tests__/generator-notify.test.js +28 -49
- package/dist/config/__tests__/generator-notify.test.js.map +1 -1
- package/dist/config/codex-feature-flags.d.ts.map +1 -1
- package/dist/config/codex-feature-flags.js.map +1 -1
- package/dist/config/codex-hooks.d.ts +124 -1
- package/dist/config/codex-hooks.d.ts.map +1 -1
- package/dist/config/codex-hooks.js +2142 -265
- package/dist/config/codex-hooks.js.map +1 -1
- package/dist/config/commit-lore-guard.js.map +1 -1
- package/dist/config/generator.d.ts +40 -26
- package/dist/config/generator.d.ts.map +1 -1
- package/dist/config/generator.js +1159 -288
- package/dist/config/generator.js.map +1 -1
- package/dist/config/mcp-registry.js.map +1 -1
- package/dist/config/models.d.ts +2 -2
- package/dist/config/models.d.ts.map +1 -1
- package/dist/config/models.js.map +1 -1
- package/dist/config/omx-first-party-mcp.js.map +1 -1
- package/dist/config/team-mode.d.ts.map +1 -1
- package/dist/document-refresh/__tests__/enforcer.test.js.map +1 -1
- package/dist/document-refresh/enforcer.js.map +1 -1
- package/dist/exec/followup.js.map +1 -1
- package/dist/goal-workflows/artifacts.js.map +1 -1
- package/dist/hooks/__tests__/agents-overlay.test.js +7 -4
- package/dist/hooks/__tests__/agents-overlay.test.js.map +1 -1
- package/dist/hooks/__tests__/analyze-routing-contract.test.js.map +1 -1
- package/dist/hooks/__tests__/analyze-skill-contract.test.js.map +1 -1
- package/dist/hooks/__tests__/anti-slop-workflow.test.js.map +1 -1
- package/dist/hooks/__tests__/autopilot-skill-contract.test.js +9 -3
- package/dist/hooks/__tests__/autopilot-skill-contract.test.js.map +1 -1
- package/dist/hooks/__tests__/code-review-skill-contract.test.js.map +1 -1
- package/dist/hooks/__tests__/consensus-execution-handoff.test.js.map +1 -1
- package/dist/hooks/__tests__/deep-interview-contract.test.js.map +1 -1
- package/dist/hooks/__tests__/design-skill.test.js.map +1 -1
- package/dist/hooks/__tests__/keyword-detector.test.js +1372 -2
- package/dist/hooks/__tests__/keyword-detector.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-fallback-watcher.test.js +14 -0
- package/dist/hooks/__tests__/notify-fallback-watcher.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-all-workers-idle.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-auto-nudge.test.js +669 -1
- package/dist/hooks/__tests__/notify-hook-auto-nudge.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-cross-worktree-heartbeat.test.js +2 -0
- package/dist/hooks/__tests__/notify-hook-cross-worktree-heartbeat.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-managed-tmux.test.js +142 -1
- package/dist/hooks/__tests__/notify-hook-managed-tmux.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-modules.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-non-omx-guard.test.js +48 -2
- package/dist/hooks/__tests__/notify-hook-non-omx-guard.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-ralph-resume.test.js +61 -44
- package/dist/hooks/__tests__/notify-hook-ralph-resume.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-regression-205.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-session-idle-dedupe.test.js +3 -2
- package/dist/hooks/__tests__/notify-hook-session-idle-dedupe.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-session-scope.test.js +243 -4
- package/dist/hooks/__tests__/notify-hook-session-scope.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-team-dispatch.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-team-leader-nudge.test.js +8 -1
- package/dist/hooks/__tests__/notify-hook-team-leader-nudge.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-team-tmux-guard.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-tmux-heal.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-tmux-scrollback.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-visual-verdict.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-worker-idle.test.js.map +1 -1
- package/dist/hooks/__tests__/openclaw-setup-contract.test.js.map +1 -1
- package/dist/hooks/__tests__/pre-context-gate-skills.test.js.map +1 -1
- package/dist/hooks/__tests__/prometheus-strict-contract.test.js.map +1 -1
- package/dist/hooks/__tests__/prompt-guidance-fragments.test.js.map +1 -1
- package/dist/hooks/__tests__/prompt-guidance-test-helpers.js.map +1 -1
- package/dist/hooks/__tests__/prompt-session-provenance.test.d.ts +2 -0
- package/dist/hooks/__tests__/prompt-session-provenance.test.d.ts.map +1 -0
- package/dist/hooks/__tests__/prompt-session-provenance.test.js +82 -0
- package/dist/hooks/__tests__/prompt-session-provenance.test.js.map +1 -0
- package/dist/hooks/__tests__/session.test.js +532 -11
- package/dist/hooks/__tests__/session.test.js.map +1 -1
- package/dist/hooks/__tests__/skill-catalog-hygiene.test.js.map +1 -1
- package/dist/hooks/__tests__/team-runtime-gating-docs-contract.test.js.map +1 -1
- package/dist/hooks/__tests__/visual-ralph-skill.test.js.map +1 -1
- package/dist/hooks/__tests__/visual-verdict-loop.test.js.map +1 -1
- package/dist/hooks/agents-overlay.js +5 -5
- package/dist/hooks/agents-overlay.js.map +1 -1
- package/dist/hooks/code-simplifier/index.js.map +1 -1
- package/dist/hooks/explore-routing.js.map +1 -1
- package/dist/hooks/extensibility/dispatcher.js.map +1 -1
- package/dist/hooks/extensibility/events.js.map +1 -1
- package/dist/hooks/extensibility/loader.js.map +1 -1
- package/dist/hooks/extensibility/plugin-runner-stdin.js.map +1 -1
- package/dist/hooks/extensibility/sdk/logging.js.map +1 -1
- package/dist/hooks/keyword-detector.d.ts +33 -7
- package/dist/hooks/keyword-detector.d.ts.map +1 -1
- package/dist/hooks/keyword-detector.js +2228 -119
- package/dist/hooks/keyword-detector.js.map +1 -1
- package/dist/hooks/keyword-registry.d.ts +12 -0
- package/dist/hooks/keyword-registry.d.ts.map +1 -1
- package/dist/hooks/keyword-registry.js +41 -0
- package/dist/hooks/keyword-registry.js.map +1 -1
- package/dist/hooks/prompt-session-provenance.d.ts +87 -0
- package/dist/hooks/prompt-session-provenance.d.ts.map +1 -0
- package/dist/hooks/prompt-session-provenance.js +180 -0
- package/dist/hooks/prompt-session-provenance.js.map +1 -0
- package/dist/hooks/session.d.ts +139 -34
- package/dist/hooks/session.d.ts.map +1 -1
- package/dist/hooks/session.js +1239 -317
- package/dist/hooks/session.js.map +1 -1
- package/dist/hooks/task-size-detector.js.map +1 -1
- package/dist/hud/__tests__/state.test.js.map +1 -1
- package/dist/hud/authority.js.map +1 -1
- package/dist/hud/constants.js.map +1 -1
- package/dist/hud/index.js.map +1 -1
- package/dist/hud/reconcile.js.map +1 -1
- package/dist/hud/render.js.map +1 -1
- package/dist/hud/state.js.map +1 -1
- package/dist/hud/tmux.js.map +1 -1
- package/dist/leader/__tests__/contract.test.js +146 -2
- package/dist/leader/__tests__/contract.test.js.map +1 -1
- package/dist/leader/contract.d.ts +26 -5
- package/dist/leader/contract.d.ts.map +1 -1
- package/dist/leader/contract.js +131 -7
- package/dist/leader/contract.js.map +1 -1
- package/dist/mcp/__tests__/bootstrap.test.js.map +1 -1
- package/dist/mcp/__tests__/server-lifecycle.test.js +15 -2
- package/dist/mcp/__tests__/server-lifecycle.test.js.map +1 -1
- package/dist/mcp/__tests__/state-paths.test.js +98 -1
- package/dist/mcp/__tests__/state-paths.test.js.map +1 -1
- package/dist/mcp/bootstrap.js.map +1 -1
- package/dist/mcp/code-intel-server.d.ts +58 -58
- package/dist/mcp/code-intel-server.d.ts.map +1 -1
- package/dist/mcp/code-intel-server.js.map +1 -1
- package/dist/mcp/hermes-bridge.js.map +1 -1
- package/dist/mcp/hermes-server.d.ts +70 -70
- package/dist/mcp/hermes-server.d.ts.map +1 -1
- package/dist/mcp/lifecycle-telemetry.js.map +1 -1
- package/dist/mcp/memory-server.d.ts +34 -34
- package/dist/mcp/memory-server.d.ts.map +1 -1
- package/dist/mcp/memory-server.js.map +1 -1
- package/dist/mcp/state-paths.d.ts +14 -0
- package/dist/mcp/state-paths.d.ts.map +1 -1
- package/dist/mcp/state-paths.js +96 -20
- package/dist/mcp/state-paths.js.map +1 -1
- package/dist/mcp/state-server.d.ts +47 -47
- package/dist/mcp/state-server.d.ts.map +1 -1
- package/dist/mcp/trace-server.d.ts +4 -4
- package/dist/mcp/trace-server.d.ts.map +1 -1
- package/dist/mcp/trace-server.js.map +1 -1
- package/dist/mcp/wiki-server.d.ts +23 -23
- package/dist/mcp/wiki-server.d.ts.map +1 -1
- package/dist/mcp/wiki-server.js.map +1 -1
- package/dist/modes/__tests__/base-session-scope.test.js +53 -1
- package/dist/modes/__tests__/base-session-scope.test.js.map +1 -1
- package/dist/modes/base.d.ts.map +1 -1
- package/dist/modes/base.js +5 -5
- package/dist/modes/base.js.map +1 -1
- package/dist/notifications/__tests__/lifecycle-dedupe.test.js.map +1 -1
- package/dist/notifications/__tests__/reply-listener.test.js.map +1 -1
- package/dist/notifications/__tests__/session-idle-tail-dedupe.test.js +177 -85
- package/dist/notifications/__tests__/session-idle-tail-dedupe.test.js.map +1 -1
- package/dist/notifications/__tests__/session-registry.test.js.map +1 -1
- package/dist/notifications/__tests__/template-engine.test.js.map +1 -1
- package/dist/notifications/__tests__/verbosity.test.js.map +1 -1
- package/dist/notifications/http-client.js.map +1 -1
- package/dist/notifications/index.d.ts +4 -1
- package/dist/notifications/index.d.ts.map +1 -1
- package/dist/notifications/index.js +3 -9
- package/dist/notifications/index.js.map +1 -1
- package/dist/notifications/lifecycle-dedupe.js.map +1 -1
- package/dist/notifications/reply-listener.d.ts.map +1 -1
- package/dist/notifications/reply-listener.js.map +1 -1
- package/dist/notifications/session-registry.js.map +1 -1
- package/dist/notifications/session-status.js.map +1 -1
- package/dist/notifications/temp-contract.js.map +1 -1
- package/dist/notifications/tmux-detector.js.map +1 -1
- package/dist/notifications/tmux.js.map +1 -1
- package/dist/openclaw/config.js.map +1 -1
- package/dist/openclaw/dispatcher.js.map +1 -1
- package/dist/pipeline/__tests__/orchestrator.test.js.map +1 -1
- package/dist/pipeline/__tests__/stages.test.js +8 -5
- package/dist/pipeline/__tests__/stages.test.js.map +1 -1
- package/dist/pipeline/stages/code-review.js.map +1 -1
- package/dist/pipeline/stages/ralph-verify.js.map +1 -1
- package/dist/pipeline/stages/ralplan.js.map +1 -1
- package/dist/pipeline/stages/team-exec.js.map +1 -1
- package/dist/pipeline/stages/ultragoal.js.map +1 -1
- package/dist/pipeline/stages/ultraqa.js.map +1 -1
- package/dist/planning/__tests__/approved-execution-lifecycle-matrix.test.js.map +1 -1
- package/dist/planning/artifact-names.js.map +1 -1
- package/dist/planning/artifacts.js.map +1 -1
- package/dist/question/__tests__/state.test.js.map +1 -1
- package/dist/question/__tests__/ui.test.js.map +1 -1
- package/dist/question/autopilot-wait.js.map +1 -1
- package/dist/question/client.d.ts.map +1 -1
- package/dist/question/client.js.map +1 -1
- package/dist/question/deep-interview.js.map +1 -1
- package/dist/question/events.js.map +1 -1
- package/dist/question/renderer.js.map +1 -1
- package/dist/question/state.d.ts.map +1 -1
- package/dist/question/state.js.map +1 -1
- package/dist/question/ui.js.map +1 -1
- package/dist/ralph/contract.d.ts +1 -1
- package/dist/ralph/contract.d.ts.map +1 -1
- package/dist/ralplan/__tests__/consensus-gate.test.js +403 -8
- package/dist/ralplan/__tests__/consensus-gate.test.js.map +1 -1
- package/dist/ralplan/__tests__/runtime.test.js +112 -14
- package/dist/ralplan/__tests__/runtime.test.js.map +1 -1
- package/dist/ralplan/consensus-gate.d.ts +3 -3
- package/dist/ralplan/consensus-gate.d.ts.map +1 -1
- package/dist/ralplan/consensus-gate.js +155 -60
- package/dist/ralplan/consensus-gate.js.map +1 -1
- package/dist/ralplan/runtime.d.ts +2 -2
- package/dist/ralplan/runtime.d.ts.map +1 -1
- package/dist/ralplan/runtime.js +1 -2
- package/dist/ralplan/runtime.js.map +1 -1
- package/dist/runtime/bridge.d.ts.map +1 -1
- package/dist/runtime/bridge.js.map +1 -1
- package/dist/runtime/process-tree.js.map +1 -1
- package/dist/runtime/run-loop.js.map +1 -1
- package/dist/runtime/run-outcome.d.ts +3 -3
- package/dist/runtime/run-outcome.d.ts.map +1 -1
- package/dist/runtime/run-outcome.js.map +1 -1
- package/dist/runtime/run-state.js.map +1 -1
- package/dist/scripts/__tests__/codex-native-hook.test.js +5414 -801
- package/dist/scripts/__tests__/codex-native-hook.test.js.map +1 -1
- package/dist/scripts/__tests__/fixtures/issue-3138-installed-smoke.d.ts +2 -0
- package/dist/scripts/__tests__/fixtures/issue-3138-installed-smoke.d.ts.map +1 -0
- package/dist/scripts/__tests__/fixtures/issue-3138-installed-smoke.js +634 -0
- package/dist/scripts/__tests__/fixtures/issue-3138-installed-smoke.js.map +1 -0
- package/dist/scripts/__tests__/generate-release-body.test.js.map +1 -1
- package/dist/scripts/__tests__/hook-derived-watcher.test.js.map +1 -1
- package/dist/scripts/__tests__/notify-dispatcher.test.js.map +1 -1
- package/dist/scripts/__tests__/notify-fallback-delivery.test.d.ts +2 -0
- package/dist/scripts/__tests__/notify-fallback-delivery.test.d.ts.map +1 -0
- package/dist/scripts/__tests__/notify-fallback-delivery.test.js +174 -0
- package/dist/scripts/__tests__/notify-fallback-delivery.test.js.map +1 -0
- package/dist/scripts/__tests__/notify-state-io.test.js +57 -1
- package/dist/scripts/__tests__/notify-state-io.test.js.map +1 -1
- package/dist/scripts/__tests__/role-intent-bootstrap-e2e-3181.test.d.ts +2 -0
- package/dist/scripts/__tests__/role-intent-bootstrap-e2e-3181.test.d.ts.map +1 -0
- package/dist/scripts/__tests__/role-intent-bootstrap-e2e-3181.test.js +205 -0
- package/dist/scripts/__tests__/role-intent-bootstrap-e2e-3181.test.js.map +1 -0
- package/dist/scripts/__tests__/role-intent-durable-recovery-3181.test.d.ts +2 -0
- package/dist/scripts/__tests__/role-intent-durable-recovery-3181.test.d.ts.map +1 -0
- package/dist/scripts/__tests__/role-intent-durable-recovery-3181.test.js +175 -0
- package/dist/scripts/__tests__/role-intent-durable-recovery-3181.test.js.map +1 -0
- package/dist/scripts/__tests__/run-test-files.test.js.map +1 -1
- package/dist/scripts/__tests__/smoke-packed-install.test.js +848 -4
- package/dist/scripts/__tests__/smoke-packed-install.test.js.map +1 -1
- package/dist/scripts/__tests__/test-reply-listener-live.test.js.map +1 -1
- package/dist/scripts/build-api.js.map +1 -1
- package/dist/scripts/build-explore-harness.js.map +1 -1
- package/dist/scripts/build-sparkshell.js.map +1 -1
- package/dist/scripts/cleanup-explore-harness.js.map +1 -1
- package/dist/scripts/codex-execution-surface.js.map +1 -1
- package/dist/scripts/codex-native-hook.d.ts.map +1 -1
- package/dist/scripts/codex-native-hook.js +825 -172
- package/dist/scripts/codex-native-hook.js.map +1 -1
- package/dist/scripts/generate-native-release-manifest.js.map +1 -1
- package/dist/scripts/generate-release-body.js.map +1 -1
- package/dist/scripts/hook-payload-guard.d.ts.map +1 -1
- package/dist/scripts/hook-payload-guard.js.map +1 -1
- package/dist/scripts/notify-fallback-delivery.d.ts +48 -0
- package/dist/scripts/notify-fallback-delivery.d.ts.map +1 -0
- package/dist/scripts/notify-fallback-delivery.js +419 -0
- package/dist/scripts/notify-fallback-delivery.js.map +1 -0
- package/dist/scripts/notify-fallback-watcher.js +136 -30
- package/dist/scripts/notify-fallback-watcher.js.map +1 -1
- package/dist/scripts/notify-hook/auto-nudge.d.ts +18 -9
- package/dist/scripts/notify-hook/auto-nudge.d.ts.map +1 -1
- package/dist/scripts/notify-hook/auto-nudge.js +39 -13
- package/dist/scripts/notify-hook/auto-nudge.js.map +1 -1
- package/dist/scripts/notify-hook/managed-tmux.d.ts +23 -0
- package/dist/scripts/notify-hook/managed-tmux.d.ts.map +1 -1
- package/dist/scripts/notify-hook/managed-tmux.js +122 -12
- package/dist/scripts/notify-hook/managed-tmux.js.map +1 -1
- package/dist/scripts/notify-hook/orchestration-intent.d.ts +7 -7
- package/dist/scripts/notify-hook/orchestration-intent.d.ts.map +1 -1
- package/dist/scripts/notify-hook/ralph-session-resume.d.ts +5 -2
- package/dist/scripts/notify-hook/ralph-session-resume.d.ts.map +1 -1
- package/dist/scripts/notify-hook/ralph-session-resume.js +33 -37
- package/dist/scripts/notify-hook/ralph-session-resume.js.map +1 -1
- package/dist/scripts/notify-hook/state-io.d.ts +17 -0
- package/dist/scripts/notify-hook/state-io.d.ts.map +1 -1
- package/dist/scripts/notify-hook/state-io.js +73 -11
- package/dist/scripts/notify-hook/state-io.js.map +1 -1
- package/dist/scripts/notify-hook/team-dispatch.d.ts +1 -1
- package/dist/scripts/notify-hook/team-dispatch.js.map +1 -1
- package/dist/scripts/notify-hook/team-leader-nudge.d.ts +2 -2
- package/dist/scripts/notify-hook/team-tmux-guard.d.ts +4 -4
- package/dist/scripts/notify-hook/team-worker-posttooluse.js.map +1 -1
- package/dist/scripts/notify-hook/team-worker-stop.d.ts +1 -1
- package/dist/scripts/notify-hook/team-worker.d.ts +2 -2
- package/dist/scripts/notify-hook/tmux-injection.d.ts +8 -1
- package/dist/scripts/notify-hook/tmux-injection.d.ts.map +1 -1
- package/dist/scripts/notify-hook/tmux-injection.js +25 -16
- package/dist/scripts/notify-hook/tmux-injection.js.map +1 -1
- package/dist/scripts/notify-hook/visual-verdict.d.ts +1 -1
- package/dist/scripts/notify-hook/visual-verdict.d.ts.map +1 -1
- package/dist/scripts/notify-hook/visual-verdict.js +15 -13
- package/dist/scripts/notify-hook/visual-verdict.js.map +1 -1
- package/dist/scripts/notify-hook.d.ts +24 -1
- package/dist/scripts/notify-hook.d.ts.map +1 -1
- package/dist/scripts/notify-hook.js +266 -90
- package/dist/scripts/notify-hook.js.map +1 -1
- package/dist/scripts/postinstall.js.map +1 -1
- package/dist/scripts/prompt-inventory.js.map +1 -1
- package/dist/scripts/smoke-packed-install.d.ts +879 -2
- package/dist/scripts/smoke-packed-install.d.ts.map +1 -1
- package/dist/scripts/smoke-packed-install.js +1528 -7
- package/dist/scripts/smoke-packed-install.js.map +1 -1
- package/dist/scripts/sync-plugin-mirror.js.map +1 -1
- package/dist/scripts/test-reply-listener-live.js.map +1 -1
- package/dist/scripts/test-sparkshell.js.map +1 -1
- package/dist/scripts/verify-native-agents.js.map +1 -1
- package/dist/session-history/friction.js.map +1 -1
- package/dist/session-history/search.js.map +1 -1
- package/dist/sidecar/__tests__/boundary.test.js.map +1 -1
- package/dist/sidecar/collector.js.map +1 -1
- package/dist/sidecar/index.js.map +1 -1
- package/dist/sidecar/render.js.map +1 -1
- package/dist/sidecar/tmux.js.map +1 -1
- package/dist/state/__tests__/operations.test.js +64 -15
- package/dist/state/__tests__/operations.test.js.map +1 -1
- package/dist/state/__tests__/skill-active.test.js +19 -1
- package/dist/state/__tests__/skill-active.test.js.map +1 -1
- package/dist/state/__tests__/workflow-transition.test.js +61 -0
- package/dist/state/__tests__/workflow-transition.test.js.map +1 -1
- package/dist/state/mode-state-context.js.map +1 -1
- package/dist/state/operations.d.ts +1 -1
- package/dist/state/operations.d.ts.map +1 -1
- package/dist/state/operations.js +49 -55
- package/dist/state/operations.js.map +1 -1
- package/dist/state/paths.d.ts +1 -1
- package/dist/state/paths.d.ts.map +1 -1
- package/dist/state/paths.js +1 -1
- package/dist/state/paths.js.map +1 -1
- package/dist/state/skill-active.d.ts +13 -1
- package/dist/state/skill-active.d.ts.map +1 -1
- package/dist/state/skill-active.js +43 -4
- package/dist/state/skill-active.js.map +1 -1
- package/dist/state/terminal-normalization.js.map +1 -1
- package/dist/state/workflow-transition-reconcile.d.ts.map +1 -1
- package/dist/state/workflow-transition-reconcile.js +20 -4
- package/dist/state/workflow-transition-reconcile.js.map +1 -1
- package/dist/state/workflow-transition.d.ts +1 -1
- package/dist/state/workflow-transition.d.ts.map +1 -1
- package/dist/state/workflow-transition.js.map +1 -1
- package/dist/subagents/__tests__/adapted-role-binding.test.d.ts +2 -0
- package/dist/subagents/__tests__/adapted-role-binding.test.d.ts.map +1 -0
- package/dist/subagents/__tests__/adapted-role-binding.test.js +988 -0
- package/dist/subagents/__tests__/adapted-role-binding.test.js.map +1 -0
- package/dist/subagents/__tests__/leader-bootstrap-3181.test.d.ts +2 -0
- package/dist/subagents/__tests__/leader-bootstrap-3181.test.d.ts.map +1 -0
- package/dist/subagents/__tests__/leader-bootstrap-3181.test.js +273 -0
- package/dist/subagents/__tests__/leader-bootstrap-3181.test.js.map +1 -0
- package/dist/subagents/__tests__/tracker.test.js +1550 -10
- package/dist/subagents/__tests__/tracker.test.js.map +1 -1
- package/dist/subagents/adapted-role-binding.d.ts +17 -0
- package/dist/subagents/adapted-role-binding.d.ts.map +1 -0
- package/dist/subagents/adapted-role-binding.js +75 -0
- package/dist/subagents/adapted-role-binding.js.map +1 -0
- package/dist/subagents/role-routing-marker.d.ts +10 -0
- package/dist/subagents/role-routing-marker.d.ts.map +1 -0
- package/dist/subagents/role-routing-marker.js +136 -0
- package/dist/subagents/role-routing-marker.js.map +1 -0
- package/dist/subagents/tracker.d.ts +172 -0
- package/dist/subagents/tracker.d.ts.map +1 -1
- package/dist/subagents/tracker.js +1077 -61
- package/dist/subagents/tracker.js.map +1 -1
- package/dist/team/__tests__/approved-execution.test.js.map +1 -1
- package/dist/team/__tests__/delivery-e2e-smoke.test.js.map +1 -1
- package/dist/team/__tests__/model-contract.test.js +231 -1
- package/dist/team/__tests__/model-contract.test.js.map +1 -1
- package/dist/team/__tests__/role-router.test.js.map +1 -1
- package/dist/team/__tests__/runtime.test.js +401 -1
- package/dist/team/__tests__/runtime.test.js.map +1 -1
- package/dist/team/__tests__/scaling.test.js +181 -0
- package/dist/team/__tests__/scaling.test.js.map +1 -1
- package/dist/team/__tests__/state-root.test.js.map +1 -1
- package/dist/team/__tests__/tmux-session.test.js +434 -4
- package/dist/team/__tests__/tmux-session.test.js.map +1 -1
- package/dist/team/__tests__/tmux-test-fixture.js.map +1 -1
- package/dist/team/api-interop.d.ts +2 -2
- package/dist/team/api-interop.d.ts.map +1 -1
- package/dist/team/api-interop.js.map +1 -1
- package/dist/team/commit-hygiene.js.map +1 -1
- package/dist/team/contracts.d.ts +5 -5
- package/dist/team/contracts.d.ts.map +1 -1
- package/dist/team/delivery-log.js.map +1 -1
- package/dist/team/followup-planner.js.map +1 -1
- package/dist/team/goal-workflow.js.map +1 -1
- package/dist/team/idle-nudge.d.ts.map +1 -1
- package/dist/team/model-contract.d.ts +20 -1
- package/dist/team/model-contract.d.ts.map +1 -1
- package/dist/team/model-contract.js +267 -30
- package/dist/team/model-contract.js.map +1 -1
- package/dist/team/orchestrator.js.map +1 -1
- package/dist/team/pane-status.js.map +1 -1
- package/dist/team/phase-controller.js.map +1 -1
- package/dist/team/reminder-intents.d.ts +1 -1
- package/dist/team/reminder-intents.d.ts.map +1 -1
- package/dist/team/reminder-intents.js.map +1 -1
- package/dist/team/runtime-cli.js.map +1 -1
- package/dist/team/runtime.d.ts.map +1 -1
- package/dist/team/runtime.js +83 -52
- package/dist/team/runtime.js.map +1 -1
- package/dist/team/scaling.d.ts +9 -7
- package/dist/team/scaling.d.ts.map +1 -1
- package/dist/team/scaling.js +69 -28
- package/dist/team/scaling.js.map +1 -1
- package/dist/team/state/dispatch-lock.js.map +1 -1
- package/dist/team/state/dispatch.js.map +1 -1
- package/dist/team/state/events.js.map +1 -1
- package/dist/team/state/tasks.js.map +1 -1
- package/dist/team/state-root.js.map +1 -1
- package/dist/team/state.js.map +1 -1
- package/dist/team/team-identity.d.ts.map +1 -1
- package/dist/team/team-identity.js.map +1 -1
- package/dist/team/tmux-session.d.ts +2 -0
- package/dist/team/tmux-session.d.ts.map +1 -1
- package/dist/team/tmux-session.js +90 -42
- package/dist/team/tmux-session.js.map +1 -1
- package/dist/team/worker-bootstrap.js.map +1 -1
- package/dist/team/worktree.js.map +1 -1
- package/dist/ultragoal/__tests__/artifacts.test.js.map +1 -1
- package/dist/ultragoal/__tests__/docs-contract.test.js.map +1 -1
- package/dist/ultragoal/artifacts.d.ts.map +1 -1
- package/dist/ultragoal/artifacts.js +4 -1
- package/dist/ultragoal/artifacts.js.map +1 -1
- package/dist/url-reader/index.js.map +1 -1
- package/dist/utils/__tests__/agents-md.test.js +16 -0
- package/dist/utils/__tests__/agents-md.test.js.map +1 -1
- package/dist/utils/agents-md.d.ts.map +1 -1
- package/dist/utils/agents-md.js +4 -3
- package/dist/utils/agents-md.js.map +1 -1
- package/dist/utils/agents-model-table.js.map +1 -1
- package/dist/utils/package.js.map +1 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/platform-command.js.map +1 -1
- package/dist/utils/repo-deps.js.map +1 -1
- package/dist/utils/version.js.map +1 -1
- package/dist/verification/__tests__/ci-rust-gates.test.js +1 -1
- package/dist/verification/__tests__/dev-merge-issue-close-workflow.test.js.map +1 -1
- package/dist/verification/verifier.js.map +1 -1
- package/dist/visual/constants.d.ts +1 -1
- package/dist/visual/constants.d.ts.map +1 -1
- package/dist/vscode/__tests__/index.test.js.map +1 -1
- package/dist/vscode/index.js.map +1 -1
- package/dist/wiki/__tests__/cjk-tokenize.test.js.map +1 -1
- package/dist/wiki/__tests__/lint.test.js.map +1 -1
- package/dist/wiki/__tests__/query.test.js.map +1 -1
- package/dist/wiki/__tests__/storage.test.js.map +1 -1
- package/dist/wiki/__tests__/test-helpers.d.ts.map +1 -1
- package/dist/wiki/lint.js.map +1 -1
- package/dist/wiki/query.js.map +1 -1
- package/dist/wiki/storage.js.map +1 -1
- package/package.json +2 -2
- package/plugins/oh-my-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/oh-my-codex/skills/omx-setup/SKILL.md +10 -5
- package/plugins/oh-my-codex/skills/ralph/SKILL.md +4 -2
- package/plugins/oh-my-codex/skills/ralplan/SKILL.md +5 -2
- package/skills/omx-setup/SKILL.md +10 -5
- package/skills/ralph/SKILL.md +4 -2
- package/skills/ralplan/SKILL.md +5 -2
- package/src/scripts/__tests__/codex-native-hook.test.ts +20497 -12377
- package/src/scripts/__tests__/fixtures/issue-3138-installed-smoke.ts +734 -0
- package/src/scripts/__tests__/notify-fallback-delivery.test.ts +177 -0
- package/src/scripts/__tests__/notify-state-io.test.ts +73 -0
- package/src/scripts/__tests__/role-intent-bootstrap-e2e-3181.test.ts +215 -0
- package/src/scripts/__tests__/role-intent-durable-recovery-3181.test.ts +193 -0
- package/src/scripts/__tests__/smoke-packed-install.test.ts +991 -4
- package/src/scripts/codex-native-hook.ts +918 -172
- package/src/scripts/notify-fallback-delivery.ts +416 -0
- package/src/scripts/notify-fallback-watcher.ts +132 -40
- package/src/scripts/notify-hook/auto-nudge.ts +43 -12
- package/src/scripts/notify-hook/managed-tmux.ts +149 -12
- package/src/scripts/notify-hook/ralph-session-resume.ts +37 -36
- package/src/scripts/notify-hook/state-io.ts +100 -13
- package/src/scripts/notify-hook/tmux-injection.ts +38 -21
- package/src/scripts/notify-hook/visual-verdict.ts +22 -12
- package/src/scripts/notify-hook.ts +335 -90
- package/src/scripts/smoke-packed-install.ts +1829 -6
package/dist/cli/uninstall.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* omx uninstall - Remove oh-my-codex configuration and installed artifacts
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import { existsSync } from "fs";
|
|
6
|
-
import { join, basename, dirname } from "path";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
4
|
+
import { chmod, copyFile, lstat, open, readFile, readdir, rename, rm, writeFile } from "fs/promises";
|
|
5
|
+
import { constants, existsSync } from "fs";
|
|
6
|
+
import { join, basename, dirname, isAbsolute, relative } from "path";
|
|
7
|
+
import { randomUUID } from "crypto";
|
|
8
|
+
import { clearNativeHookClaimJournal, persistNativeHookClaimJournal, recoverNativeHookClaimJournal, syncNativeHookClaimParent, restoreNativeHookClaimNoClobber, } from "./native-hook-claim-journal.js";
|
|
9
|
+
import { formatTomlStringArray, getRootTomlArray, isOmxManagedNotifyCommand, sanitizePreviousNotifyCommand, stripExistingOmxBlocks, stripManagedCodexHookTrustState, stripOmxEnvSettings, stripOmxTopLevelKeys, stripOmxFeatureFlags, upsertCodexHooksFeatureFlag, stripOmxSeededBehavioralDefaults, } from "../config/generator.js";
|
|
10
|
+
import { buildManagedCodexNativeHookWindowsShimContent, buildManagedCodexNativeHookWindowsShimPath, classifyManagedCodexNativeHookWindowsShimOwnership, planManagedCodexHooksRemoval, ManagedCodexHooksPlanError, } from "../config/codex-hooks.js";
|
|
9
11
|
import { getPackageRoot } from "../utils/package.js";
|
|
10
12
|
import { AGENT_DEFINITIONS } from "../agents/definitions.js";
|
|
11
13
|
import { detectLegacySkillRootOverlap } from "../utils/paths.js";
|
|
12
|
-
import { resolveScopeDirectories } from "./setup.js";
|
|
14
|
+
import { decideWindowsNativeHookShimReference, resolveScopeDirectories, } from "./setup.js";
|
|
13
15
|
import { resolveCodexHookFeatureFlagForCli } from "./codex-feature-probe.js";
|
|
14
16
|
import { readPersistedSetupScope } from "./index.js";
|
|
15
|
-
import { isOmxGeneratedAgentsMd } from "../utils/agents-md.js";
|
|
17
|
+
import { isOmxGeneratedAgentsMd, OMX_MANAGED_AGENTS_END_MARKER, OMX_MANAGED_AGENTS_START_MARKER, } from "../utils/agents-md.js";
|
|
16
18
|
import { OMX_FIRST_PARTY_MCP_SERVER_NAMES } from "../config/omx-first-party-mcp.js";
|
|
19
|
+
import TOML from "@iarna/toml";
|
|
17
20
|
function detectOmxConfigArtifacts(config) {
|
|
18
21
|
const hasMcpServers = OMX_FIRST_PARTY_MCP_SERVER_NAMES.filter((name) => new RegExp(`\\[mcp_servers\\.${name}\\]`).test(config));
|
|
19
22
|
const agentNames = Object.keys(AGENT_DEFINITIONS);
|
|
@@ -29,20 +32,17 @@ function detectOmxConfigArtifacts(config) {
|
|
|
29
32
|
const hasTopLevelKeys = /^\s*notify\s*=.*node/m.test(config) ||
|
|
30
33
|
/^\s*model_reasoning_effort\s*=/m.test(config) ||
|
|
31
34
|
/^\s*developer_instructions\s*=.*oh-my-codex/m.test(config);
|
|
32
|
-
const hasFeatureFlags = /^\s*
|
|
33
|
-
/^\s*child_agents_md\s*=\s*true/m.test(config) ||
|
|
35
|
+
const hasFeatureFlags = /^\s*child_agents_md\s*=\s*true/m.test(config) ||
|
|
34
36
|
/^\s*hooks\s*=\s*true/m.test(config) ||
|
|
35
37
|
/^\s*codex_hooks\s*=\s*true/m.test(config) ||
|
|
36
38
|
/^\s*goals\s*=\s*true/m.test(config) ||
|
|
37
39
|
/^\s*goal\s*=\s*true/m.test(config);
|
|
38
|
-
const hasExploreRoutingEnv = /^\s*USE_OMX_EXPLORE_CMD\s*=/m.test(config);
|
|
39
40
|
return {
|
|
40
41
|
hasMcpServers,
|
|
41
42
|
hasAgentEntries,
|
|
42
43
|
hasTuiSection,
|
|
43
44
|
hasTopLevelKeys,
|
|
44
45
|
hasFeatureFlags,
|
|
45
|
-
hasExploreRoutingEnv,
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
function hasNativeHooksFeatureFlag(config) {
|
|
@@ -61,17 +61,176 @@ function hasNativeHooksFeatureFlag(config) {
|
|
|
61
61
|
.slice(featuresStart + 1, sectionEnd)
|
|
62
62
|
.some((line) => /^\s*(?:hooks|codex_hooks)\s*=\s*true/.test(line));
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
function fileIdentity(stat) {
|
|
65
|
+
return {
|
|
66
|
+
dev: stat.dev,
|
|
67
|
+
ino: stat.ino,
|
|
68
|
+
size: stat.size,
|
|
69
|
+
mode: stat.mode,
|
|
70
|
+
mtimeMs: stat.mtimeMs,
|
|
71
|
+
ctimeMs: stat.ctimeMs,
|
|
72
|
+
links: stat.nlink,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function hasSameFileIdentity(left, right) {
|
|
76
|
+
return left.dev === right.dev &&
|
|
77
|
+
left.ino === right.ino &&
|
|
78
|
+
left.size === right.size &&
|
|
79
|
+
left.mode === right.mode &&
|
|
80
|
+
left.mtimeMs === right.mtimeMs &&
|
|
81
|
+
left.ctimeMs === right.ctimeMs &&
|
|
82
|
+
left.links === right.links;
|
|
83
|
+
}
|
|
84
|
+
function isMissingPathError(error) {
|
|
85
|
+
return (typeof error === "object" &&
|
|
86
|
+
error !== null &&
|
|
87
|
+
"code" in error &&
|
|
88
|
+
error.code === "ENOENT");
|
|
89
|
+
}
|
|
90
|
+
async function captureControlledTopology(root, path) {
|
|
91
|
+
const parentPath = dirname(path);
|
|
92
|
+
const relativeParent = relative(root, parentPath);
|
|
93
|
+
if (isAbsolute(relativeParent) ||
|
|
94
|
+
relativeParent === ".." ||
|
|
95
|
+
relativeParent.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) ||
|
|
96
|
+
relativeParent.startsWith("/")) {
|
|
97
|
+
throw new Error(`Refusing to process ${path}: it is outside controlled Codex scope ${root}.`);
|
|
98
|
+
}
|
|
99
|
+
const ancestors = [];
|
|
100
|
+
let currentPath = root;
|
|
101
|
+
for (const segment of ["", ...relativeParent.split(/[\\/]/).filter(Boolean)]) {
|
|
102
|
+
if (segment)
|
|
103
|
+
currentPath = join(currentPath, segment);
|
|
104
|
+
try {
|
|
105
|
+
const stat = await lstat(currentPath);
|
|
106
|
+
if (stat.isSymbolicLink() || !stat.isDirectory()) {
|
|
107
|
+
throw new Error(`Refusing to process ${path}: controlled ancestor ${currentPath} must be a non-symbolic-link directory.`);
|
|
108
|
+
}
|
|
109
|
+
ancestors.push({
|
|
110
|
+
path: currentPath,
|
|
111
|
+
identity: { dev: stat.dev, ino: stat.ino },
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (!isMissingPathError(error))
|
|
116
|
+
throw error;
|
|
117
|
+
ancestors.push({ path: currentPath, identity: null });
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return { root, ancestors };
|
|
122
|
+
}
|
|
123
|
+
async function assertControlledTopologyCurrent(topology) {
|
|
124
|
+
if (!topology)
|
|
125
|
+
return;
|
|
126
|
+
for (const ancestor of topology.ancestors) {
|
|
127
|
+
try {
|
|
128
|
+
const stat = await lstat(ancestor.path);
|
|
129
|
+
if (ancestor.identity === null ||
|
|
130
|
+
stat.isSymbolicLink() ||
|
|
131
|
+
!stat.isDirectory() ||
|
|
132
|
+
stat.dev !== ancestor.identity.dev ||
|
|
133
|
+
stat.ino !== ancestor.identity.ino) {
|
|
134
|
+
throw new Error(`Refusing uninstall because controlled ancestor ${ancestor.path} changed topology after planning.`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
if (error instanceof Error && error.message.includes("changed topology")) {
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
if (isMissingPathError(error) && ancestor.identity === null)
|
|
142
|
+
continue;
|
|
143
|
+
if (isMissingPathError(error)) {
|
|
144
|
+
throw new Error(`Refusing uninstall because controlled ancestor ${ancestor.path} changed topology after planning.`);
|
|
145
|
+
}
|
|
146
|
+
throw error;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function decodeStrictUtf8(path, bytes) {
|
|
67
151
|
try {
|
|
68
|
-
const
|
|
69
|
-
|
|
152
|
+
const content = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
|
|
153
|
+
if (!Buffer.from(content, "utf-8").equals(bytes)) {
|
|
154
|
+
throw new Error("decoded text did not round-trip to the original bytes");
|
|
155
|
+
}
|
|
156
|
+
return content;
|
|
70
157
|
}
|
|
71
158
|
catch {
|
|
72
|
-
|
|
159
|
+
throw new ManagedCodexHooksPlanError("invalid_document", `Refusing to process ${path}: it is not valid UTF-8.`, { path });
|
|
73
160
|
}
|
|
74
161
|
}
|
|
162
|
+
async function readFileSnapshot(path, options = {}) {
|
|
163
|
+
const topology = options.controlledRoot
|
|
164
|
+
? await captureControlledTopology(options.controlledRoot, path)
|
|
165
|
+
: null;
|
|
166
|
+
let before;
|
|
167
|
+
try {
|
|
168
|
+
before = await lstat(path);
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
if (isMissingPathError(error)) {
|
|
172
|
+
await assertControlledTopologyCurrent(topology);
|
|
173
|
+
return {
|
|
174
|
+
path,
|
|
175
|
+
content: null,
|
|
176
|
+
bytes: null,
|
|
177
|
+
mode: null,
|
|
178
|
+
identity: null,
|
|
179
|
+
topology,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
throw error;
|
|
183
|
+
}
|
|
184
|
+
if (before.isSymbolicLink() || !before.isFile() || before.nlink !== 1) {
|
|
185
|
+
throw new Error(`Refusing to process ${path}: expected a regular file, not a symbolic link or other filesystem object.`);
|
|
186
|
+
}
|
|
187
|
+
const bytes = await readFile(path);
|
|
188
|
+
const after = await lstat(path);
|
|
189
|
+
await assertControlledTopologyCurrent(topology);
|
|
190
|
+
if (after.isSymbolicLink() || !after.isFile() || after.nlink !== 1 || !hasSameFileIdentity(fileIdentity(before), fileIdentity(after))) {
|
|
191
|
+
throw new Error(`Refusing to process ${path}: it changed while uninstall was planning.`);
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
path,
|
|
195
|
+
content: options.strictUtf8 === false ? bytes.toString("utf-8") : decodeStrictUtf8(path, bytes),
|
|
196
|
+
bytes,
|
|
197
|
+
mode: after.mode & 0o7777,
|
|
198
|
+
identity: fileIdentity(after),
|
|
199
|
+
topology,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
async function planHooksRemoval(hooks, pkgRoot, platform, controlledRoot) {
|
|
203
|
+
let plan;
|
|
204
|
+
if (hooks.content !== null) {
|
|
205
|
+
const result = planManagedCodexHooksRemoval(hooks.content, hooks.path, {
|
|
206
|
+
platform,
|
|
207
|
+
codexHomeDir: dirname(hooks.path),
|
|
208
|
+
});
|
|
209
|
+
if (!result.ok)
|
|
210
|
+
throw result.error;
|
|
211
|
+
plan = result;
|
|
212
|
+
}
|
|
213
|
+
if (platform !== "win32")
|
|
214
|
+
return { hooks, plan };
|
|
215
|
+
const shimPath = buildManagedCodexNativeHookWindowsShimPath(dirname(hooks.path));
|
|
216
|
+
const shim = await readFileSnapshot(shimPath, {
|
|
217
|
+
strictUtf8: false,
|
|
218
|
+
// On non-Windows hosts the test-only platform seam intentionally produces
|
|
219
|
+
// a win32 path that the host filesystem cannot place under this root.
|
|
220
|
+
controlledRoot: platform === process.platform ? controlledRoot : undefined,
|
|
221
|
+
});
|
|
222
|
+
if (shim.bytes !== null) {
|
|
223
|
+
const expectedShim = Buffer.from(buildManagedCodexNativeHookWindowsShimContent(pkgRoot), "utf-8");
|
|
224
|
+
if (classifyManagedCodexNativeHookWindowsShimOwnership(shim.bytes, expectedShim) === "modified") {
|
|
225
|
+
throw new Error(`Refusing to remove modified native hook Windows shim at ${shim.path}.`);
|
|
226
|
+
}
|
|
227
|
+
const shimReference = decideWindowsNativeHookShimReference(plan?.finalContent ?? null, shim.path);
|
|
228
|
+
if (shimReference !== "not_referenced") {
|
|
229
|
+
return { hooks, plan, preservedShimPrecondition: shim };
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return { hooks, plan, shim };
|
|
233
|
+
}
|
|
75
234
|
function insertRootTomlKey(config, line) {
|
|
76
235
|
const lines = config.split(/\r?\n/);
|
|
77
236
|
const firstTableIndex = lines.findIndex((candidate) => /^\s*\[/.test(candidate));
|
|
@@ -79,30 +238,90 @@ function insertRootTomlKey(config, line) {
|
|
|
79
238
|
lines.splice(insertAt, 0, line);
|
|
80
239
|
return lines.join("\n").replace(/\n{3,}/g, "\n\n");
|
|
81
240
|
}
|
|
82
|
-
|
|
83
|
-
const currentNotify = getRootTomlArray(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
241
|
+
function isManagedDispatcherNotify(config) {
|
|
242
|
+
const currentNotify = getRootTomlArray(config, "notify");
|
|
243
|
+
return Boolean(isOmxManagedNotifyCommand(currentNotify, getPackageRoot()) &&
|
|
244
|
+
currentNotify?.some((part) => /(?:^|[\\/])notify-dispatcher\.js$/.test(part)));
|
|
245
|
+
}
|
|
246
|
+
function invalidNotifyMetadata(path, reason) {
|
|
247
|
+
return new ManagedCodexHooksPlanError("invalid_document", `Refusing to use notification metadata ${path}: ${reason}.`, { path });
|
|
248
|
+
}
|
|
249
|
+
function parseNotifyMetadata(snapshot, currentNotify) {
|
|
250
|
+
if (snapshot.content === null) {
|
|
251
|
+
throw invalidNotifyMetadata(snapshot.path, "the managed dispatcher metadata is missing");
|
|
87
252
|
}
|
|
88
|
-
|
|
253
|
+
if (!currentNotify.includes(snapshot.path)) {
|
|
254
|
+
throw invalidNotifyMetadata(snapshot.path, "the managed dispatcher does not reference the controlled metadata path");
|
|
255
|
+
}
|
|
256
|
+
let parsed;
|
|
89
257
|
try {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
258
|
+
parsed = JSON.parse(snapshot.content);
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
throw invalidNotifyMetadata(snapshot.path, `invalid JSON (${error instanceof Error ? error.message : String(error)})`);
|
|
262
|
+
}
|
|
263
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
264
|
+
throw invalidNotifyMetadata(snapshot.path, "expected a JSON object");
|
|
265
|
+
}
|
|
266
|
+
const metadata = parsed;
|
|
267
|
+
if (metadata.managedBy !== "oh-my-codex" || metadata.version !== 1) {
|
|
268
|
+
throw invalidNotifyMetadata(snapshot.path, "expected OMX ownership and version 1");
|
|
269
|
+
}
|
|
270
|
+
const validateStringArray = (value, name) => {
|
|
271
|
+
if (!Array.isArray(value) || !value.every((item) => typeof item === "string")) {
|
|
272
|
+
throw invalidNotifyMetadata(snapshot.path, `${name} must be an array of strings`);
|
|
98
273
|
}
|
|
274
|
+
return [...value];
|
|
275
|
+
};
|
|
276
|
+
const previousNotify = metadata.previousNotify;
|
|
277
|
+
if (!Object.hasOwn(metadata, "previousNotify") ||
|
|
278
|
+
(previousNotify !== null &&
|
|
279
|
+
(!Array.isArray(previousNotify) ||
|
|
280
|
+
!previousNotify.every((item) => typeof item === "string")))) {
|
|
281
|
+
throw invalidNotifyMetadata(snapshot.path, "previousNotify must be null or an array of strings");
|
|
99
282
|
}
|
|
100
|
-
|
|
101
|
-
|
|
283
|
+
validateStringArray(metadata.omxNotify, "omxNotify");
|
|
284
|
+
const dispatcherNotify = validateStringArray(metadata.dispatcherNotify, "dispatcherNotify");
|
|
285
|
+
if (dispatcherNotify.length !== currentNotify.length ||
|
|
286
|
+
dispatcherNotify.some((part, index) => part !== currentNotify[index])) {
|
|
287
|
+
throw invalidNotifyMetadata(snapshot.path, "dispatcherNotify does not match the managed dispatcher command");
|
|
102
288
|
}
|
|
103
|
-
return
|
|
289
|
+
return {
|
|
290
|
+
snapshot,
|
|
291
|
+
previousNotify: Array.isArray(previousNotify) ? [...previousNotify] : null,
|
|
292
|
+
};
|
|
104
293
|
}
|
|
105
|
-
async function
|
|
294
|
+
async function planNotifyMetadata(configSnapshot, codexHomeDir) {
|
|
295
|
+
if (configSnapshot.content === null || !isManagedDispatcherNotify(configSnapshot.content)) {
|
|
296
|
+
return undefined;
|
|
297
|
+
}
|
|
298
|
+
const currentNotify = getRootTomlArray(configSnapshot.content, "notify");
|
|
299
|
+
if (!currentNotify) {
|
|
300
|
+
throw invalidNotifyMetadata(join(codexHomeDir, ".omx", "notify-dispatch.json"), "the managed dispatcher command is invalid");
|
|
301
|
+
}
|
|
302
|
+
let snapshot;
|
|
303
|
+
try {
|
|
304
|
+
snapshot = await readFileSnapshot(join(codexHomeDir, ".omx", "notify-dispatch.json"), { controlledRoot: codexHomeDir });
|
|
305
|
+
}
|
|
306
|
+
catch (error) {
|
|
307
|
+
if (error instanceof ManagedCodexHooksPlanError)
|
|
308
|
+
throw error;
|
|
309
|
+
throw invalidNotifyMetadata(join(codexHomeDir, ".omx", "notify-dispatch.json"), `unreadable (${error instanceof Error ? error.message : String(error)})`);
|
|
310
|
+
}
|
|
311
|
+
return parseNotifyMetadata(snapshot, currentNotify);
|
|
312
|
+
}
|
|
313
|
+
function restorePreviousNotifyIfDispatcher(strippedConfig, originalConfig, metadataPlan) {
|
|
314
|
+
if (!isManagedDispatcherNotify(originalConfig))
|
|
315
|
+
return strippedConfig;
|
|
316
|
+
if (!metadataPlan) {
|
|
317
|
+
throw new Error("Missing planned notification metadata for a managed dispatcher.");
|
|
318
|
+
}
|
|
319
|
+
const sanitizedPreviousNotify = sanitizePreviousNotifyCommand(metadataPlan.previousNotify, getPackageRoot());
|
|
320
|
+
return sanitizedPreviousNotify
|
|
321
|
+
? insertRootTomlKey(strippedConfig, `notify = ${formatTomlStringArray(sanitizedPreviousNotify)}`)
|
|
322
|
+
: strippedConfig;
|
|
323
|
+
}
|
|
324
|
+
async function planConfigCleanup(configSnapshot, options) {
|
|
106
325
|
const result = {
|
|
107
326
|
configCleaned: false,
|
|
108
327
|
mcpServersRemoved: [],
|
|
@@ -111,12 +330,10 @@ async function cleanConfig(configPath, options) {
|
|
|
111
330
|
topLevelKeysRemoved: false,
|
|
112
331
|
featureFlagsRemoved: false,
|
|
113
332
|
};
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return result;
|
|
333
|
+
const original = configSnapshot.content;
|
|
334
|
+
if (original === null) {
|
|
335
|
+
return { config: configSnapshot, finalContent: null, result };
|
|
118
336
|
}
|
|
119
|
-
const original = await readFile(configPath, "utf-8");
|
|
120
337
|
const detected = detectOmxConfigArtifacts(original);
|
|
121
338
|
const shouldRestoreHooksFeatureFlag = options.preserveHooksFeatureFlag && hasNativeHooksFeatureFlag(original);
|
|
122
339
|
result.mcpServersRemoved = detected.hasMcpServers;
|
|
@@ -124,18 +341,33 @@ async function cleanConfig(configPath, options) {
|
|
|
124
341
|
result.tuiSectionRemoved = detected.hasTuiSection;
|
|
125
342
|
result.topLevelKeysRemoved = detected.hasTopLevelKeys;
|
|
126
343
|
result.featureFlagsRemoved = detected.hasFeatureFlags;
|
|
344
|
+
// Verify proof ownership against the untouched source before marker stripping
|
|
345
|
+
// can hide a foreign sibling in an otherwise OMX-looking trust declaration.
|
|
346
|
+
stripManagedCodexHookTrustState(original, {
|
|
347
|
+
priorManagedHookTrustState: options.priorHookTrustState,
|
|
348
|
+
managedTrustState: options.finalHookTrustState,
|
|
349
|
+
});
|
|
127
350
|
// Strip OMX tables block (MCP servers, agents, tui)
|
|
128
351
|
let config = original;
|
|
129
|
-
const { cleaned } = stripExistingOmxBlocks(config
|
|
352
|
+
const { cleaned } = stripExistingOmxBlocks(config, {
|
|
353
|
+
managedTrustState: options.finalHookTrustState,
|
|
354
|
+
priorManagedHookTrustState: options.priorHookTrustState,
|
|
355
|
+
});
|
|
130
356
|
config = cleaned;
|
|
131
357
|
// Strip OMX top-level keys, then restore a pre-existing user notify when
|
|
132
358
|
// setup had wrapped it in the OMX dispatcher.
|
|
133
359
|
config = stripOmxTopLevelKeys(config);
|
|
134
|
-
config =
|
|
360
|
+
config = restorePreviousNotifyIfDispatcher(config, original, options.notifyMetadata);
|
|
135
361
|
// Strip OMX-seeded behavioral defaults only when the seeded pair is unchanged.
|
|
136
362
|
config = stripOmxSeededBehavioralDefaults(config);
|
|
363
|
+
// Remove only trust tables whose hashes and coordinates match the planned
|
|
364
|
+
// managed hooks before their removal. User-owned conflicts remain intact.
|
|
365
|
+
config = stripManagedCodexHookTrustState(config, {
|
|
366
|
+
priorManagedHookTrustState: options.priorHookTrustState,
|
|
367
|
+
managedTrustState: options.finalHookTrustState,
|
|
368
|
+
});
|
|
137
369
|
// Strip feature flags
|
|
138
|
-
config = stripOmxFeatureFlags(config);
|
|
370
|
+
config = stripOmxFeatureFlags(config, { preserveMultiAgent: true });
|
|
139
371
|
if (shouldRestoreHooksFeatureFlag) {
|
|
140
372
|
config = upsertCodexHooksFeatureFlag(config, resolveCodexHookFeatureFlagForCli({
|
|
141
373
|
codexFeaturesProbe: options.codexFeaturesProbe,
|
|
@@ -146,20 +378,8 @@ async function cleanConfig(configPath, options) {
|
|
|
146
378
|
config = stripOmxEnvSettings(config);
|
|
147
379
|
// Normalize trailing whitespace
|
|
148
380
|
config = config.trimEnd() + "\n";
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (!options.dryRun) {
|
|
152
|
-
await writeFile(configPath, config);
|
|
153
|
-
}
|
|
154
|
-
if (options.verbose) {
|
|
155
|
-
console.log(` ${options.dryRun ? "Would clean" : "Cleaned"} ${configPath}`);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
if (options.verbose)
|
|
160
|
-
console.log(" No OMX config entries found.");
|
|
161
|
-
}
|
|
162
|
-
return result;
|
|
381
|
+
result.configCleaned = config !== original;
|
|
382
|
+
return { config: configSnapshot, finalContent: config, result };
|
|
163
383
|
}
|
|
164
384
|
async function removeInstalledPrompts(promptsDir, pkgRoot, options) {
|
|
165
385
|
const srcPromptsDir = join(pkgRoot, "prompts");
|
|
@@ -240,6 +460,19 @@ async function removeAgentsMd(agentsMdPath, options) {
|
|
|
240
460
|
return false;
|
|
241
461
|
try {
|
|
242
462
|
const content = await readFile(agentsMdPath, "utf-8");
|
|
463
|
+
const startIndex = content.indexOf(OMX_MANAGED_AGENTS_START_MARKER);
|
|
464
|
+
const endIndex = content.indexOf(OMX_MANAGED_AGENTS_END_MARKER);
|
|
465
|
+
if (startIndex >= 0 && endIndex > startIndex) {
|
|
466
|
+
const blockEnd = endIndex + OMX_MANAGED_AGENTS_END_MARKER.length;
|
|
467
|
+
const preserved = `${content.slice(0, startIndex).trimEnd()}\n${content.slice(blockEnd).trimStart()}`.trim();
|
|
468
|
+
if (preserved) {
|
|
469
|
+
if (!options.dryRun)
|
|
470
|
+
await writeFile(agentsMdPath, `${preserved}\n`, "utf-8");
|
|
471
|
+
if (options.verbose)
|
|
472
|
+
console.log(" Removed OMX-managed AGENTS.md sections and preserved user guidance.");
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
243
476
|
if (!isOmxGeneratedAgentsMd(content)) {
|
|
244
477
|
if (options.verbose)
|
|
245
478
|
console.log(" AGENTS.md is not OMX-generated, skipping.");
|
|
@@ -256,29 +489,561 @@ async function removeAgentsMd(agentsMdPath, options) {
|
|
|
256
489
|
console.log(` ${options.dryRun ? "Would remove" : "Removed"} AGENTS.md`);
|
|
257
490
|
return true;
|
|
258
491
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
492
|
+
function assertValidHooksJson(content) {
|
|
493
|
+
JSON.parse(content);
|
|
494
|
+
}
|
|
495
|
+
function assertValidToml(content) {
|
|
496
|
+
TOML.parse(content);
|
|
497
|
+
}
|
|
498
|
+
function transactionTemporaryPath(path, purpose, options) {
|
|
499
|
+
return options.transactionTemporaryPath?.(path, purpose) ?? join(dirname(path), `.${basename(path)}.omx-uninstall-${purpose}-${process.pid}-${randomUUID()}.tmp`);
|
|
500
|
+
}
|
|
501
|
+
function transactionClaimPath(path) {
|
|
502
|
+
return join(dirname(path), `.${basename(path)}.omx-uninstall-claim-${process.pid}-${randomUUID()}.tmp`);
|
|
503
|
+
}
|
|
504
|
+
async function restoreUninstallClaim(claimPath, destinationPath) {
|
|
505
|
+
await restoreNativeHookClaimNoClobber(claimPath, destinationPath);
|
|
506
|
+
}
|
|
507
|
+
function snapshotReadOptions(snapshot) {
|
|
508
|
+
return {
|
|
509
|
+
strictUtf8: false,
|
|
510
|
+
controlledRoot: snapshot.topology?.root,
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
async function captureCurrentSnapshot(reference) {
|
|
514
|
+
return readFileSnapshot(reference.path, snapshotReadOptions(reference));
|
|
515
|
+
}
|
|
516
|
+
function renamedDestinationOwnership(snapshot, destinationPath, topology) {
|
|
517
|
+
if (snapshot.bytes === null || snapshot.mode === null || snapshot.identity === null) {
|
|
518
|
+
throw new Error(`Replacement temporary ${snapshot.path} was not fully captured before rename.`);
|
|
519
|
+
}
|
|
520
|
+
return {
|
|
521
|
+
path: destinationPath,
|
|
522
|
+
bytes: snapshot.bytes,
|
|
523
|
+
mode: snapshot.mode,
|
|
524
|
+
identity: { dev: snapshot.identity.dev, ino: snapshot.identity.ino },
|
|
525
|
+
topology,
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
async function captureRenamedDestinationOwnership(ownership) {
|
|
529
|
+
await assertControlledTopologyCurrent(ownership.topology);
|
|
530
|
+
const current = await readFileSnapshot(ownership.path, {
|
|
531
|
+
strictUtf8: false,
|
|
532
|
+
controlledRoot: ownership.topology?.root,
|
|
533
|
+
});
|
|
534
|
+
if (current.bytes === null ||
|
|
535
|
+
current.mode !== ownership.mode ||
|
|
536
|
+
!current.bytes.equals(ownership.bytes) ||
|
|
537
|
+
current.identity === null ||
|
|
538
|
+
current.identity.dev !== ownership.identity.dev ||
|
|
539
|
+
current.identity.ino !== ownership.identity.ino) {
|
|
540
|
+
throw new Error(`Uninstall replacement ownership changed for ${ownership.path}.`);
|
|
541
|
+
}
|
|
542
|
+
return current;
|
|
543
|
+
}
|
|
544
|
+
async function assertSnapshotCurrent(snapshot) {
|
|
545
|
+
await assertControlledTopologyCurrent(snapshot.topology);
|
|
546
|
+
const current = await captureCurrentSnapshot(snapshot);
|
|
547
|
+
if (snapshot.bytes === null && current.bytes === null)
|
|
548
|
+
return;
|
|
549
|
+
if (snapshot.bytes !== null &&
|
|
550
|
+
current.bytes !== null &&
|
|
551
|
+
snapshot.identity !== null &&
|
|
552
|
+
current.identity !== null &&
|
|
553
|
+
snapshot.bytes.equals(current.bytes) &&
|
|
554
|
+
hasSameFileIdentity(snapshot.identity, current.identity)) {
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
throw new Error(`Refusing uninstall because planned artifact ${snapshot.path} changed, was created, or was removed after planning.`);
|
|
558
|
+
}
|
|
559
|
+
async function assertSnapshotAtPath(path, expected, context) {
|
|
560
|
+
await assertControlledTopologyCurrent(expected.topology);
|
|
561
|
+
const actual = await readFileSnapshot(path, snapshotReadOptions(expected));
|
|
562
|
+
if (expected.bytes === null ||
|
|
563
|
+
actual.bytes === null ||
|
|
564
|
+
expected.identity === null ||
|
|
565
|
+
actual.identity === null ||
|
|
566
|
+
!expected.bytes.equals(actual.bytes) ||
|
|
567
|
+
actual.mode !== expected.mode ||
|
|
568
|
+
actual.identity.dev !== expected.identity.dev ||
|
|
569
|
+
actual.identity.ino !== expected.identity.ino) {
|
|
570
|
+
throw new Error(`Refusing uninstall because ${context} ${path} is not the planned artifact.`);
|
|
571
|
+
}
|
|
572
|
+
return actual;
|
|
573
|
+
}
|
|
574
|
+
async function assertSnapshotMatchesPlannedContent(actual, expected, context) {
|
|
575
|
+
await assertControlledTopologyCurrent(expected.topology);
|
|
576
|
+
if (actual.bytes === null ||
|
|
577
|
+
expected.bytes === null ||
|
|
578
|
+
actual.mode !== expected.mode ||
|
|
579
|
+
!actual.bytes.equals(expected.bytes)) {
|
|
580
|
+
throw new Error(`Uninstall ${context} mismatch for ${expected.path}.`);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
async function assertSnapshotsCurrent(snapshots) {
|
|
584
|
+
for (const snapshot of snapshots)
|
|
585
|
+
await assertSnapshotCurrent(snapshot);
|
|
586
|
+
}
|
|
587
|
+
async function removeOwnedTemporary(path, snapshot, originalError, description) {
|
|
588
|
+
try {
|
|
589
|
+
if (!snapshot) {
|
|
590
|
+
throw new Error(`${description} path was not fully captured after writing.`);
|
|
273
591
|
}
|
|
274
|
-
|
|
275
|
-
|
|
592
|
+
await assertSnapshotCurrent(snapshot);
|
|
593
|
+
const claimPath = transactionClaimPath(path);
|
|
594
|
+
await rename(path, claimPath);
|
|
595
|
+
try {
|
|
596
|
+
await assertSnapshotAtPath(claimPath, snapshot, `${description} cleanup claim`);
|
|
597
|
+
}
|
|
598
|
+
catch (error) {
|
|
599
|
+
try {
|
|
600
|
+
await restoreUninstallClaim(claimPath, path);
|
|
601
|
+
}
|
|
602
|
+
catch (recoveryError) {
|
|
603
|
+
throw new Error(`${error instanceof Error ? error.message : String(error)}; preserved claim ${claimPath} for manual recovery: ${recoveryError instanceof Error ? recoveryError.message : String(recoveryError)}`);
|
|
604
|
+
}
|
|
605
|
+
throw error;
|
|
276
606
|
}
|
|
607
|
+
await rm(claimPath);
|
|
277
608
|
}
|
|
278
|
-
|
|
279
|
-
|
|
609
|
+
catch (cleanupError) {
|
|
610
|
+
const message = originalError instanceof Error
|
|
611
|
+
? originalError.message
|
|
612
|
+
: String(originalError);
|
|
613
|
+
throw new Error(`Uninstall artifact transaction failed (${message}) and preserved ${description} ${path} for manual recovery after cleanup verification failed: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
async function atomicReplaceFile(mutation, expectedCurrent, content, options, stage, onRename, assertApplied) {
|
|
617
|
+
if (mutation.snapshot.mode === null) {
|
|
618
|
+
throw new Error(`Refusing to replace ${mutation.snapshot.path}: uninstall did not plan a regular-file mode.`);
|
|
619
|
+
}
|
|
620
|
+
const temporaryPath = transactionTemporaryPath(mutation.snapshot.path, "write", options);
|
|
621
|
+
let handle;
|
|
622
|
+
let temporaryCreated = false;
|
|
623
|
+
let temporarySnapshot;
|
|
624
|
+
let claimPath;
|
|
625
|
+
let claimCreated = false;
|
|
626
|
+
let journaledClaim = false;
|
|
627
|
+
try {
|
|
628
|
+
await options.transactionFailureInjector?.(stage === "write" ? "before-temp-write" : "before-rollback");
|
|
629
|
+
await assertApplied?.();
|
|
630
|
+
await assertSnapshotCurrent(expectedCurrent);
|
|
631
|
+
handle = await open(temporaryPath, "wx", mutation.snapshot.mode);
|
|
632
|
+
temporaryCreated = true;
|
|
633
|
+
await handle.writeFile(content);
|
|
634
|
+
await chmod(temporaryPath, mutation.snapshot.mode);
|
|
635
|
+
await handle.sync();
|
|
636
|
+
await handle.close();
|
|
637
|
+
handle = undefined;
|
|
638
|
+
temporarySnapshot = await readFileSnapshot(temporaryPath, snapshotReadOptions(mutation.snapshot));
|
|
639
|
+
if (temporarySnapshot.bytes === null ||
|
|
640
|
+
temporarySnapshot.mode !== mutation.snapshot.mode ||
|
|
641
|
+
!temporarySnapshot.bytes.equals(content)) {
|
|
642
|
+
throw new Error(`Read-back verification failed for replacement temporary ${temporaryPath}.`);
|
|
643
|
+
}
|
|
644
|
+
await options.transactionFailureInjector?.(stage === "write" ? "before-rename" : "before-rollback-rename");
|
|
645
|
+
await assertApplied?.();
|
|
646
|
+
await assertControlledTopologyCurrent(mutation.snapshot.topology);
|
|
647
|
+
await assertSnapshotCurrent(expectedCurrent);
|
|
648
|
+
await assertSnapshotCurrent(temporarySnapshot);
|
|
649
|
+
await options.transactionFailureInjector?.(stage === "write"
|
|
650
|
+
? "after-final-rename-validation"
|
|
651
|
+
: "after-final-restore-validation");
|
|
652
|
+
if (!temporarySnapshot) {
|
|
653
|
+
throw new Error(`Replacement temporary ${temporaryPath} was not fully captured before install.`);
|
|
654
|
+
}
|
|
655
|
+
claimPath = transactionClaimPath(mutation.snapshot.path);
|
|
656
|
+
const controlledRoot = mutation.snapshot.topology?.root;
|
|
657
|
+
if (expectedCurrent.bytes !== null && controlledRoot) {
|
|
658
|
+
await persistNativeHookClaimJournal(controlledRoot, {
|
|
659
|
+
canonicalPath: mutation.snapshot.path,
|
|
660
|
+
claimPath,
|
|
661
|
+
before: expectedCurrent.bytes,
|
|
662
|
+
after: content,
|
|
663
|
+
});
|
|
664
|
+
journaledClaim = true;
|
|
665
|
+
await rename(mutation.snapshot.path, claimPath);
|
|
666
|
+
claimCreated = true;
|
|
667
|
+
await syncNativeHookClaimParent(claimPath);
|
|
668
|
+
await assertSnapshotAtPath(claimPath, expectedCurrent, "replacement claim");
|
|
669
|
+
}
|
|
670
|
+
await copyFile(temporaryPath, mutation.snapshot.path, constants.COPYFILE_EXCL);
|
|
671
|
+
await chmod(mutation.snapshot.path, mutation.snapshot.mode);
|
|
672
|
+
const installedHandle = await open(mutation.snapshot.path, "r");
|
|
673
|
+
try {
|
|
674
|
+
await installedHandle.sync();
|
|
675
|
+
}
|
|
676
|
+
finally {
|
|
677
|
+
await installedHandle.close();
|
|
678
|
+
}
|
|
679
|
+
await syncNativeHookClaimParent(mutation.snapshot.path);
|
|
680
|
+
const actual = await captureCurrentSnapshot(mutation.snapshot);
|
|
681
|
+
if (actual.bytes === null || actual.mode !== mutation.snapshot.mode || !actual.bytes.equals(content)) {
|
|
682
|
+
throw new Error(`Read-back verification failed for replacement ${mutation.snapshot.path}.`);
|
|
683
|
+
}
|
|
684
|
+
if (claimCreated && claimPath) {
|
|
685
|
+
await rm(claimPath);
|
|
686
|
+
await syncNativeHookClaimParent(claimPath);
|
|
687
|
+
claimCreated = false;
|
|
688
|
+
}
|
|
689
|
+
if (journaledClaim && controlledRoot) {
|
|
690
|
+
await clearNativeHookClaimJournal(controlledRoot);
|
|
691
|
+
journaledClaim = false;
|
|
692
|
+
}
|
|
693
|
+
await rm(temporaryPath);
|
|
694
|
+
temporaryCreated = false;
|
|
695
|
+
const ownership = renamedDestinationOwnership(actual, mutation.snapshot.path, mutation.snapshot.topology);
|
|
696
|
+
onRename(ownership);
|
|
697
|
+
if (stage === "write") {
|
|
698
|
+
await options.transactionFailureInjector?.("after-rename");
|
|
699
|
+
}
|
|
700
|
+
const verified = await captureRenamedDestinationOwnership(ownership);
|
|
701
|
+
if (stage === "write" && mutation.validate) {
|
|
702
|
+
mutation.validate(decodeStrictUtf8(mutation.snapshot.path, verified.bytes));
|
|
703
|
+
}
|
|
704
|
+
return verified;
|
|
705
|
+
}
|
|
706
|
+
catch (error) {
|
|
707
|
+
await handle?.close().catch(() => undefined);
|
|
708
|
+
if (claimCreated && claimPath) {
|
|
709
|
+
try {
|
|
710
|
+
await restoreUninstallClaim(claimPath, mutation.snapshot.path);
|
|
711
|
+
await syncNativeHookClaimParent(mutation.snapshot.path);
|
|
712
|
+
claimCreated = false;
|
|
713
|
+
const controlledRoot = mutation.snapshot.topology?.root;
|
|
714
|
+
if (journaledClaim && controlledRoot) {
|
|
715
|
+
await clearNativeHookClaimJournal(controlledRoot);
|
|
716
|
+
journaledClaim = false;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
catch (recoveryError) {
|
|
720
|
+
throw new Error(`Uninstall replacement failed (${error instanceof Error ? error.message : String(error)}) and preserved ${claimPath} for manual recovery: ${recoveryError instanceof Error ? recoveryError.message : String(recoveryError)}`);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
if (temporaryCreated) {
|
|
724
|
+
await removeOwnedTemporary(temporaryPath, temporarySnapshot, error, "temporary");
|
|
725
|
+
}
|
|
726
|
+
throw error;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
async function stageAndRemoveFile(mutation, execution, options, assertApplied) {
|
|
730
|
+
if (mutation.snapshot.bytes === null || mutation.snapshot.mode === null) {
|
|
731
|
+
throw new Error(`Refusing to remove ${mutation.snapshot.path}: uninstall did not plan a regular-file snapshot.`);
|
|
732
|
+
}
|
|
733
|
+
const stagedPath = transactionTemporaryPath(mutation.snapshot.path, "delete", options);
|
|
734
|
+
let handle;
|
|
735
|
+
let stagedCreated = false;
|
|
736
|
+
try {
|
|
737
|
+
await options.transactionFailureInjector?.("before-temp-write");
|
|
738
|
+
await assertApplied();
|
|
739
|
+
await assertSnapshotCurrent(mutation.snapshot);
|
|
740
|
+
handle = await open(stagedPath, "wx", mutation.snapshot.mode);
|
|
741
|
+
stagedCreated = true;
|
|
742
|
+
await handle.writeFile(mutation.snapshot.bytes);
|
|
743
|
+
await chmod(stagedPath, mutation.snapshot.mode);
|
|
744
|
+
await handle.sync();
|
|
745
|
+
await handle.close();
|
|
746
|
+
handle = undefined;
|
|
747
|
+
const stagedDeletion = await readFileSnapshot(stagedPath, snapshotReadOptions(mutation.snapshot));
|
|
748
|
+
await assertSnapshotMatchesPlannedContent(stagedDeletion, mutation.snapshot, "staged deletion");
|
|
749
|
+
execution.stagedDeletion = stagedDeletion;
|
|
750
|
+
await options.transactionFailureInjector?.("before-remove");
|
|
751
|
+
await assertControlledTopologyCurrent(mutation.snapshot.topology);
|
|
752
|
+
await assertSnapshotCurrent(mutation.snapshot);
|
|
753
|
+
await assertSnapshotCurrent(stagedDeletion);
|
|
754
|
+
await assertApplied();
|
|
755
|
+
await options.transactionFailureInjector?.("after-final-remove-validation");
|
|
756
|
+
await assertSnapshotCurrent(stagedDeletion);
|
|
757
|
+
const claimPath = transactionClaimPath(mutation.snapshot.path);
|
|
758
|
+
const controlledRoot = mutation.snapshot.topology?.root;
|
|
759
|
+
if (controlledRoot && mutation.snapshot.bytes !== null) {
|
|
760
|
+
await persistNativeHookClaimJournal(controlledRoot, {
|
|
761
|
+
canonicalPath: mutation.snapshot.path,
|
|
762
|
+
claimPath,
|
|
763
|
+
before: mutation.snapshot.bytes,
|
|
764
|
+
after: null,
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
await rename(mutation.snapshot.path, claimPath);
|
|
768
|
+
if (controlledRoot)
|
|
769
|
+
await syncNativeHookClaimParent(claimPath);
|
|
770
|
+
execution.appliedSnapshot = {
|
|
771
|
+
path: mutation.snapshot.path,
|
|
772
|
+
content: null,
|
|
773
|
+
bytes: null,
|
|
774
|
+
mode: null,
|
|
775
|
+
identity: null,
|
|
776
|
+
topology: mutation.snapshot.topology,
|
|
777
|
+
};
|
|
778
|
+
execution.phase = "destructive";
|
|
779
|
+
try {
|
|
780
|
+
await assertSnapshotAtPath(claimPath, mutation.snapshot, "removal claim");
|
|
781
|
+
}
|
|
782
|
+
catch (error) {
|
|
783
|
+
try {
|
|
784
|
+
await restoreUninstallClaim(claimPath, mutation.snapshot.path);
|
|
785
|
+
if (controlledRoot)
|
|
786
|
+
await syncNativeHookClaimParent(mutation.snapshot.path);
|
|
787
|
+
if (controlledRoot)
|
|
788
|
+
await clearNativeHookClaimJournal(controlledRoot);
|
|
789
|
+
execution.appliedSnapshot = undefined;
|
|
790
|
+
execution.phase = "prepared";
|
|
791
|
+
}
|
|
792
|
+
catch (recoveryError) {
|
|
793
|
+
throw new Error(`Uninstall removal claim failed (${error instanceof Error ? error.message : String(error)}) and preserved ${claimPath} for manual recovery: ${recoveryError instanceof Error ? recoveryError.message : String(recoveryError)}`);
|
|
794
|
+
}
|
|
795
|
+
throw error;
|
|
796
|
+
}
|
|
797
|
+
await rm(claimPath);
|
|
798
|
+
if (controlledRoot)
|
|
799
|
+
await syncNativeHookClaimParent(claimPath);
|
|
800
|
+
if (controlledRoot)
|
|
801
|
+
await clearNativeHookClaimJournal(controlledRoot);
|
|
802
|
+
await options.transactionFailureInjector?.("after-remove");
|
|
803
|
+
await assertControlledTopologyCurrent(mutation.snapshot.topology);
|
|
804
|
+
const absent = await captureCurrentSnapshot(mutation.snapshot);
|
|
805
|
+
if (absent.bytes !== null) {
|
|
806
|
+
throw new Error(`Read-back verification failed for ${mutation.snapshot.path}: expected absence.`);
|
|
807
|
+
}
|
|
808
|
+
execution.phase = "verified";
|
|
809
|
+
}
|
|
810
|
+
catch (error) {
|
|
811
|
+
await handle?.close().catch(() => undefined);
|
|
812
|
+
if (stagedCreated && execution.phase === "prepared") {
|
|
813
|
+
await removeOwnedTemporary(stagedPath, execution.stagedDeletion, error, "staged deletion");
|
|
814
|
+
}
|
|
815
|
+
throw error;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
async function applyFileMutation(execution, executions, options) {
|
|
819
|
+
const { mutation } = execution;
|
|
820
|
+
if (mutation.finalContent === null) {
|
|
821
|
+
await stageAndRemoveFile(mutation, execution, options, () => assertAppliedTransactionSnapshots(executions));
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
const appliedSnapshot = await atomicReplaceFile(mutation, mutation.snapshot, Buffer.from(mutation.finalContent, "utf-8"), options, "write", (ownership) => {
|
|
825
|
+
execution.renamedOwnership = ownership;
|
|
826
|
+
execution.phase = "destructive";
|
|
827
|
+
}, () => assertAppliedTransactionSnapshots(executions));
|
|
828
|
+
execution.appliedSnapshot = appliedSnapshot;
|
|
829
|
+
execution.renamedOwnership = undefined;
|
|
830
|
+
execution.phase = "verified";
|
|
831
|
+
}
|
|
832
|
+
function mutationStage(kind) {
|
|
833
|
+
switch (kind) {
|
|
834
|
+
case "hooks":
|
|
835
|
+
return "before-hooks-commit";
|
|
836
|
+
case "shim":
|
|
837
|
+
return "before-shim-removal";
|
|
838
|
+
case "config":
|
|
839
|
+
return "before-config-commit";
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
async function captureRollbackOwnedSnapshot(execution) {
|
|
843
|
+
if (execution.appliedSnapshot) {
|
|
844
|
+
await assertSnapshotCurrent(execution.appliedSnapshot);
|
|
845
|
+
return execution.appliedSnapshot;
|
|
846
|
+
}
|
|
847
|
+
if (execution.renamedOwnership) {
|
|
848
|
+
return captureRenamedDestinationOwnership(execution.renamedOwnership);
|
|
849
|
+
}
|
|
850
|
+
throw new Error(`Refusing stale rollback for ${execution.mutation.snapshot.path}: the mutation did not produce a verifiable state.`);
|
|
851
|
+
}
|
|
852
|
+
async function restoreFileSnapshot(execution, options, assertRollbackState) {
|
|
853
|
+
const { mutation } = execution;
|
|
854
|
+
const appliedSnapshot = await captureRollbackOwnedSnapshot(execution);
|
|
855
|
+
if (execution.stagedDeletion && !execution.stagedDeletionCleaned) {
|
|
856
|
+
await assertSnapshotCurrent(execution.stagedDeletion);
|
|
857
|
+
}
|
|
858
|
+
if (mutation.snapshot.bytes === null) {
|
|
859
|
+
await options.transactionFailureInjector?.("before-rollback");
|
|
860
|
+
await options.transactionFailureInjector?.("before-rollback-remove");
|
|
861
|
+
await assertRollbackState();
|
|
862
|
+
await assertControlledTopologyCurrent(mutation.snapshot.topology);
|
|
863
|
+
await assertSnapshotCurrent(appliedSnapshot);
|
|
864
|
+
await options.transactionFailureInjector?.("after-final-restore-validation");
|
|
865
|
+
const claimPath = transactionClaimPath(mutation.snapshot.path);
|
|
866
|
+
await rename(mutation.snapshot.path, claimPath);
|
|
867
|
+
execution.appliedSnapshot = {
|
|
868
|
+
path: mutation.snapshot.path,
|
|
869
|
+
content: null,
|
|
870
|
+
bytes: null,
|
|
871
|
+
mode: null,
|
|
872
|
+
identity: null,
|
|
873
|
+
topology: mutation.snapshot.topology,
|
|
874
|
+
};
|
|
875
|
+
execution.renamedOwnership = undefined;
|
|
876
|
+
try {
|
|
877
|
+
await assertSnapshotAtPath(claimPath, appliedSnapshot, "rollback removal claim");
|
|
878
|
+
}
|
|
879
|
+
catch (error) {
|
|
880
|
+
try {
|
|
881
|
+
await restoreUninstallClaim(claimPath, mutation.snapshot.path);
|
|
882
|
+
}
|
|
883
|
+
catch (recoveryError) {
|
|
884
|
+
throw new Error(`Uninstall rollback removal claim failed (${error instanceof Error ? error.message : String(error)}) and preserved ${claimPath} for manual recovery: ${recoveryError instanceof Error ? recoveryError.message : String(recoveryError)}`);
|
|
885
|
+
}
|
|
886
|
+
throw error;
|
|
887
|
+
}
|
|
888
|
+
await rm(claimPath);
|
|
889
|
+
const absent = await captureCurrentSnapshot(mutation.snapshot);
|
|
890
|
+
if (absent.bytes !== null) {
|
|
891
|
+
throw new Error(`Uninstall rollback mismatch for ${mutation.snapshot.path}: expected absence.`);
|
|
892
|
+
}
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
const restored = await atomicReplaceFile(mutation, appliedSnapshot, mutation.snapshot.bytes, options, "rollback", (ownership) => {
|
|
896
|
+
execution.renamedOwnership = ownership;
|
|
897
|
+
}, assertRollbackState);
|
|
898
|
+
execution.appliedSnapshot = restored;
|
|
899
|
+
execution.renamedOwnership = undefined;
|
|
900
|
+
await assertSnapshotMatchesPlannedContent(restored, mutation.snapshot, "rollback");
|
|
901
|
+
}
|
|
902
|
+
async function cleanupStagedDeletions(executions, options, stage, transaction, assertRollbackState) {
|
|
903
|
+
for (const execution of executions) {
|
|
904
|
+
if (!execution.stagedDeletion || execution.stagedDeletionCleaned)
|
|
905
|
+
continue;
|
|
906
|
+
if (stage === "rollback") {
|
|
907
|
+
await options.transactionFailureInjector?.("before-rollback-remove");
|
|
908
|
+
}
|
|
909
|
+
await options.transactionFailureInjector?.("before-staged-cleanup");
|
|
910
|
+
if (transaction) {
|
|
911
|
+
await assertUnmutatedTransactionPreconditions(transaction, executions);
|
|
912
|
+
await assertAppliedTransactionSnapshots(executions);
|
|
913
|
+
}
|
|
914
|
+
await assertRollbackState?.();
|
|
915
|
+
const stagedDeletion = execution.stagedDeletion;
|
|
916
|
+
await assertSnapshotCurrent(stagedDeletion);
|
|
917
|
+
const claimPath = transactionClaimPath(stagedDeletion.path);
|
|
918
|
+
await rename(stagedDeletion.path, claimPath);
|
|
919
|
+
try {
|
|
920
|
+
await assertSnapshotAtPath(claimPath, stagedDeletion, "staged deletion cleanup claim");
|
|
921
|
+
}
|
|
922
|
+
catch (error) {
|
|
923
|
+
try {
|
|
924
|
+
await restoreUninstallClaim(claimPath, stagedDeletion.path);
|
|
925
|
+
}
|
|
926
|
+
catch (recoveryError) {
|
|
927
|
+
throw new Error(`Uninstall staged deletion cleanup claim failed (${error instanceof Error ? error.message : String(error)}) and preserved ${claimPath} for manual recovery: ${recoveryError instanceof Error ? recoveryError.message : String(recoveryError)}`);
|
|
928
|
+
}
|
|
929
|
+
throw error;
|
|
930
|
+
}
|
|
931
|
+
await rm(claimPath);
|
|
932
|
+
execution.stagedDeletionCleaned = true;
|
|
933
|
+
await assertRollbackState?.();
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
async function assertRollbackTransactionState(executions) {
|
|
937
|
+
for (const execution of executions) {
|
|
938
|
+
if (execution.phase === "prepared")
|
|
939
|
+
continue;
|
|
940
|
+
if (execution.stagedDeletion && !execution.stagedDeletionCleaned) {
|
|
941
|
+
await assertSnapshotCurrent(execution.stagedDeletion);
|
|
942
|
+
}
|
|
943
|
+
await captureRollbackOwnedSnapshot(execution);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
async function rollbackArtifactMutations(executions, options) {
|
|
947
|
+
const failures = [];
|
|
948
|
+
const restored = [];
|
|
949
|
+
try {
|
|
950
|
+
await assertRollbackTransactionState(executions);
|
|
951
|
+
}
|
|
952
|
+
catch (error) {
|
|
953
|
+
failures.push(`recovery preflight: ${String(error)}`);
|
|
954
|
+
}
|
|
955
|
+
if (failures.length === 0) {
|
|
956
|
+
for (const execution of [...executions].reverse()) {
|
|
957
|
+
if (execution.phase === "prepared")
|
|
958
|
+
continue;
|
|
959
|
+
try {
|
|
960
|
+
await assertRollbackTransactionState(executions);
|
|
961
|
+
await restoreFileSnapshot(execution, options, () => assertRollbackTransactionState(executions));
|
|
962
|
+
restored.push(execution);
|
|
963
|
+
await assertRollbackTransactionState(executions);
|
|
964
|
+
}
|
|
965
|
+
catch (error) {
|
|
966
|
+
failures.push(`${execution.mutation.kind}: ${String(error)}`);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
if (failures.length === 0) {
|
|
971
|
+
try {
|
|
972
|
+
await assertRollbackTransactionState(executions);
|
|
973
|
+
await cleanupStagedDeletions(restored, options, "rollback", undefined, () => assertRollbackTransactionState(executions));
|
|
974
|
+
await assertRollbackTransactionState(executions);
|
|
975
|
+
}
|
|
976
|
+
catch (error) {
|
|
977
|
+
failures.push(`staged deletion cleanup: ${String(error)}`);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
if (failures.length > 0) {
|
|
981
|
+
throw new Error(`Uninstall artifact rollback failed; manual recovery is required: ${failures.join("; ")}`);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
async function assertUnmutatedTransactionPreconditions(transaction, executions) {
|
|
985
|
+
const mutatedPaths = new Set(executions
|
|
986
|
+
.filter((execution) => execution.phase !== "prepared")
|
|
987
|
+
.map((execution) => execution.mutation.snapshot.path));
|
|
988
|
+
await assertSnapshotsCurrent(transaction.preconditions.filter((snapshot) => !mutatedPaths.has(snapshot.path)));
|
|
989
|
+
}
|
|
990
|
+
async function assertAppliedTransactionSnapshots(executions) {
|
|
991
|
+
for (const execution of executions) {
|
|
992
|
+
if (execution.phase === "prepared")
|
|
993
|
+
continue;
|
|
994
|
+
if (!execution.appliedSnapshot) {
|
|
995
|
+
throw new Error(`Refusing uninstall because ${execution.mutation.snapshot.path} did not register an applied snapshot.`);
|
|
996
|
+
}
|
|
997
|
+
await assertSnapshotCurrent(execution.appliedSnapshot);
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
async function commitUninstallArtifactTransaction(transaction, options) {
|
|
1001
|
+
const mutations = [transaction.hooks, transaction.shim, transaction.config]
|
|
1002
|
+
.filter((mutation) => mutation !== undefined);
|
|
1003
|
+
for (const mutation of mutations) {
|
|
1004
|
+
if (mutation.finalContent !== null)
|
|
1005
|
+
mutation.validate?.(mutation.finalContent);
|
|
1006
|
+
}
|
|
1007
|
+
await assertSnapshotsCurrent(transaction.preconditions);
|
|
1008
|
+
if (mutations.length === 0)
|
|
1009
|
+
return;
|
|
1010
|
+
const executions = [];
|
|
1011
|
+
let stagedCleanupStarted = false;
|
|
1012
|
+
try {
|
|
1013
|
+
for (const mutation of mutations) {
|
|
1014
|
+
await options.transactionFailureInjector?.(mutationStage(mutation.kind));
|
|
1015
|
+
await assertUnmutatedTransactionPreconditions(transaction, executions);
|
|
1016
|
+
await assertAppliedTransactionSnapshots(executions);
|
|
1017
|
+
const execution = { mutation, phase: "prepared" };
|
|
1018
|
+
executions.push(execution);
|
|
1019
|
+
await applyFileMutation(execution, executions, options);
|
|
1020
|
+
if (mutation.kind === "config") {
|
|
1021
|
+
await options.transactionFailureInjector?.("after-config-commit");
|
|
1022
|
+
}
|
|
1023
|
+
await assertUnmutatedTransactionPreconditions(transaction, executions);
|
|
1024
|
+
await assertAppliedTransactionSnapshots(executions);
|
|
1025
|
+
}
|
|
1026
|
+
await assertUnmutatedTransactionPreconditions(transaction, executions);
|
|
1027
|
+
await assertAppliedTransactionSnapshots(executions);
|
|
1028
|
+
stagedCleanupStarted = true;
|
|
1029
|
+
await cleanupStagedDeletions(executions, options, "commit", transaction);
|
|
1030
|
+
await options.transactionFailureInjector?.("after-staged-cleanup");
|
|
1031
|
+
await assertUnmutatedTransactionPreconditions(transaction, executions);
|
|
1032
|
+
await assertAppliedTransactionSnapshots(executions);
|
|
1033
|
+
}
|
|
1034
|
+
catch (error) {
|
|
1035
|
+
if (stagedCleanupStarted &&
|
|
1036
|
+
executions.some((execution) => execution.stagedDeletionCleaned)) {
|
|
1037
|
+
throw new Error(`Uninstall artifact transaction committed but staged deletion cleanup failed during finalization: ${String(error)}`);
|
|
1038
|
+
}
|
|
1039
|
+
try {
|
|
1040
|
+
await rollbackArtifactMutations(executions, options);
|
|
1041
|
+
}
|
|
1042
|
+
catch (rollbackError) {
|
|
1043
|
+
throw new Error(`Uninstall artifact transaction failed (${String(error)}); ${String(rollbackError)}`);
|
|
1044
|
+
}
|
|
1045
|
+
throw error;
|
|
280
1046
|
}
|
|
281
|
-
return true;
|
|
282
1047
|
}
|
|
283
1048
|
async function removeCacheDirectory(projectRoot, options) {
|
|
284
1049
|
const omxDir = join(projectRoot, ".omx");
|
|
@@ -329,10 +1094,10 @@ function printSummary(summary, dryRun) {
|
|
|
329
1094
|
console.log(" Top-level keys (notify, model_reasoning_effort, developer_instructions)");
|
|
330
1095
|
}
|
|
331
1096
|
if (summary.featureFlagsRemoved) {
|
|
332
|
-
console.log(" Feature flags (
|
|
1097
|
+
console.log(" Feature flags (child_agents_md, goals; multi_agent and hooks are preserved when user-owned)");
|
|
333
1098
|
}
|
|
334
1099
|
}
|
|
335
|
-
else if (
|
|
1100
|
+
else if (summary.mcpServersRemoved.length === 0) {
|
|
336
1101
|
console.log(" config.toml: no OMX entries found (or --keep-config used)");
|
|
337
1102
|
}
|
|
338
1103
|
if (summary.hooksFileRemoved) {
|
|
@@ -374,6 +1139,73 @@ export async function uninstall(options = {}) {
|
|
|
374
1139
|
// Resolve scope (explicit --scope overrides persisted scope)
|
|
375
1140
|
const scope = options.scope ?? readPersistedSetupScope(projectRoot) ?? "user";
|
|
376
1141
|
const scopeDirs = resolveScopeDirectories(scope, projectRoot);
|
|
1142
|
+
if (!dryRun) {
|
|
1143
|
+
await recoverNativeHookClaimJournal(scopeDirs.codexHomeDir);
|
|
1144
|
+
}
|
|
1145
|
+
const transactionPlatform = options.transactionPlatform ?? process.platform;
|
|
1146
|
+
// Precompute and validate every artifact before the first uninstall write.
|
|
1147
|
+
const hooksSnapshot = await readFileSnapshot(scopeDirs.codexHooksFile, {
|
|
1148
|
+
controlledRoot: scopeDirs.codexHomeDir,
|
|
1149
|
+
});
|
|
1150
|
+
const configSnapshot = await readFileSnapshot(scopeDirs.codexConfigFile, {
|
|
1151
|
+
controlledRoot: scopeDirs.codexHomeDir,
|
|
1152
|
+
});
|
|
1153
|
+
const hooksRemoval = await planHooksRemoval(hooksSnapshot, pkgRoot, transactionPlatform, scopeDirs.codexHomeDir);
|
|
1154
|
+
const notifyMetadata = keepConfig
|
|
1155
|
+
? undefined
|
|
1156
|
+
: await planNotifyMetadata(configSnapshot, scopeDirs.codexHomeDir);
|
|
1157
|
+
const preserveHooksFeatureFlag = hooksRemoval.plan?.hasForeignHooks ?? false;
|
|
1158
|
+
const configCleanup = keepConfig
|
|
1159
|
+
? undefined
|
|
1160
|
+
: await planConfigCleanup(configSnapshot, {
|
|
1161
|
+
preserveHooksFeatureFlag,
|
|
1162
|
+
priorHookTrustState: hooksRemoval.plan?.priorTrustState,
|
|
1163
|
+
finalHookTrustState: hooksRemoval.plan?.finalTrustState,
|
|
1164
|
+
notifyMetadata,
|
|
1165
|
+
codexFeaturesProbe: options.codexFeaturesProbe,
|
|
1166
|
+
codexVersionProbe: options.codexVersionProbe,
|
|
1167
|
+
});
|
|
1168
|
+
const artifactTransaction = {
|
|
1169
|
+
preconditions: [
|
|
1170
|
+
hooksRemoval.hooks,
|
|
1171
|
+
...(hooksRemoval.shim
|
|
1172
|
+
? [hooksRemoval.shim]
|
|
1173
|
+
: hooksRemoval.preservedShimPrecondition
|
|
1174
|
+
? [hooksRemoval.preservedShimPrecondition]
|
|
1175
|
+
: []),
|
|
1176
|
+
configSnapshot,
|
|
1177
|
+
...(notifyMetadata ? [notifyMetadata.snapshot] : []),
|
|
1178
|
+
],
|
|
1179
|
+
...(hooksRemoval.plan?.changed
|
|
1180
|
+
? {
|
|
1181
|
+
hooks: {
|
|
1182
|
+
kind: "hooks",
|
|
1183
|
+
snapshot: hooksRemoval.hooks,
|
|
1184
|
+
finalContent: hooksRemoval.plan.finalContent,
|
|
1185
|
+
validate: assertValidHooksJson,
|
|
1186
|
+
},
|
|
1187
|
+
}
|
|
1188
|
+
: {}),
|
|
1189
|
+
...(hooksRemoval.shim !== undefined && hooksRemoval.shim.bytes !== null
|
|
1190
|
+
? {
|
|
1191
|
+
shim: {
|
|
1192
|
+
kind: "shim",
|
|
1193
|
+
snapshot: hooksRemoval.shim,
|
|
1194
|
+
finalContent: null,
|
|
1195
|
+
},
|
|
1196
|
+
}
|
|
1197
|
+
: {}),
|
|
1198
|
+
...(configCleanup?.result.configCleaned && configCleanup.finalContent !== null
|
|
1199
|
+
? {
|
|
1200
|
+
config: {
|
|
1201
|
+
kind: "config",
|
|
1202
|
+
snapshot: configCleanup.config,
|
|
1203
|
+
finalContent: configCleanup.finalContent,
|
|
1204
|
+
validate: assertValidToml,
|
|
1205
|
+
},
|
|
1206
|
+
}
|
|
1207
|
+
: {}),
|
|
1208
|
+
};
|
|
377
1209
|
console.log("oh-my-codex uninstall");
|
|
378
1210
|
console.log("=====================\n");
|
|
379
1211
|
if (dryRun) {
|
|
@@ -396,31 +1228,47 @@ export async function uninstall(options = {}) {
|
|
|
396
1228
|
legacySkillRootWarning: null,
|
|
397
1229
|
};
|
|
398
1230
|
summary.legacySkillRootWarning = await detectLegacySkillRootWarning(scope);
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
if (
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
1231
|
+
summary.hooksFileRemoved =
|
|
1232
|
+
artifactTransaction.hooks !== undefined || artifactTransaction.shim !== undefined;
|
|
1233
|
+
if (configCleanup)
|
|
1234
|
+
Object.assign(summary, configCleanup.result);
|
|
1235
|
+
// Hooks, proof-owned shim, and config are one compensating transaction. The
|
|
1236
|
+
// config mutation is intentionally last so hooks never reference unwritten trust.
|
|
1237
|
+
console.log("[1/6] Removing native hooks artifact...");
|
|
1238
|
+
if (!keepConfig)
|
|
1239
|
+
console.log("[2/6] Cleaning config.toml...");
|
|
1240
|
+
if (!dryRun) {
|
|
1241
|
+
await commitUninstallArtifactTransaction(artifactTransaction, {
|
|
1242
|
+
transactionFailureInjector: options.transactionFailureInjector,
|
|
1243
|
+
transactionTemporaryPath: options.transactionTemporaryPath,
|
|
412
1244
|
});
|
|
413
|
-
Object.assign(summary, configResult);
|
|
414
1245
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
1246
|
+
if (verbose) {
|
|
1247
|
+
if (artifactTransaction.hooks) {
|
|
1248
|
+
console.log(` ${dryRun ? "Would clean" : artifactTransaction.hooks.finalContent === null ? "Removed" : "Cleaned"} ${basename(scopeDirs.codexHooksFile)}`);
|
|
1249
|
+
}
|
|
1250
|
+
if (artifactTransaction.shim) {
|
|
1251
|
+
console.log(` ${dryRun ? "Would remove" : "Removed"} ${basename(artifactTransaction.shim.snapshot.path)}`);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
422
1254
|
console.log(` ${dryRun ? "Would clean" : "Cleaned"} ${summary.hooksFileRemoved ? 1 : 0} hooks artifact(s).`);
|
|
423
1255
|
console.log();
|
|
1256
|
+
// Step 2: config cleanup is calculated before Step 1 and committed last.
|
|
1257
|
+
if (keepConfig) {
|
|
1258
|
+
console.log("[2/6] Skipping config.toml cleanup (--keep-config).");
|
|
1259
|
+
}
|
|
1260
|
+
else if (verbose) {
|
|
1261
|
+
if (configCleanup?.config.content === null) {
|
|
1262
|
+
console.log(" config.toml not found, skipping.");
|
|
1263
|
+
}
|
|
1264
|
+
else if (configCleanup?.result.configCleaned) {
|
|
1265
|
+
console.log(` ${dryRun ? "Would clean" : "Cleaned"} ${scopeDirs.codexConfigFile}`);
|
|
1266
|
+
}
|
|
1267
|
+
else {
|
|
1268
|
+
console.log(" No OMX config entries found.");
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
console.log();
|
|
424
1272
|
// Step 3: Remove installed prompts
|
|
425
1273
|
console.log("[3/6] Removing agent prompts...");
|
|
426
1274
|
summary.promptsRemoved = await removeInstalledPrompts(scopeDirs.promptsDir, pkgRoot, { dryRun, verbose });
|