context-brake 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +361 -2
- package/dist/assets/runtime/antigravity-cli-hook.mjs +19174 -0
- package/dist/assets/runtime/claude-code-hook.mjs +19302 -0
- package/dist/assets/runtime/claude-code-mod.mjs +18579 -0
- package/dist/assets/runtime/claude-code-statusline.mjs +18749 -0
- package/dist/assets/runtime/codex-cli-hook.mjs +19299 -0
- package/dist/assets/runtime/context-brake-runtime.mjs +6 -0
- package/dist/assets/runtime/cursor-hook.mjs +19181 -0
- package/dist/assets/runtime/github-copilot-cli-hook.mjs +19186 -0
- package/dist/assets/runtime/omp-extension.js +19237 -0
- package/dist/assets/runtime/omp-restart.js +18763 -0
- package/dist/assets/runtime/opencode-plugin.js +19200 -0
- package/dist/assets/runtime/pi-extension.js +19228 -0
- package/dist/assets/runtime/pi-restart.js +18758 -0
- package/dist/src/cli/argument-parser.d.ts +20 -0
- package/dist/src/cli/argument-parser.js +45 -0
- package/dist/src/cli/argument-validator.d.ts +8 -0
- package/dist/src/cli/argument-validator.js +24 -0
- package/dist/src/cli/assistant/ask.d.ts +10 -0
- package/dist/src/cli/assistant/ask.js +36 -0
- package/dist/src/cli/assistant/assistant-context.d.ts +9 -0
- package/dist/src/cli/assistant/assistant-context.js +18 -0
- package/dist/src/cli/assistant/assistant-questions.d.ts +3 -0
- package/dist/src/cli/assistant/assistant-questions.js +26 -0
- package/dist/src/cli/assistant/assistant-session.d.ts +5 -0
- package/dist/src/cli/assistant/assistant-session.js +25 -0
- package/dist/src/cli/assistant/clack-prompt-port.d.ts +14 -0
- package/dist/src/cli/assistant/clack-prompt-port.js +47 -0
- package/dist/src/cli/assistant/equivalent-command.d.ts +1 -0
- package/dist/src/cli/assistant/equivalent-command.js +16 -0
- package/dist/src/cli/assistant/prompt-factory.d.ts +3 -0
- package/dist/src/cli/assistant/prompt-factory.js +16 -0
- package/dist/src/cli/assistant/prompt-port.d.ts +14 -0
- package/dist/src/cli/assistant/prompt-port.js +28 -0
- package/dist/src/cli/assistant/questions-gitignore.d.ts +7 -0
- package/dist/src/cli/assistant/questions-gitignore.js +14 -0
- package/dist/src/cli/assistant/questions-harness.d.ts +9 -0
- package/dist/src/cli/assistant/questions-harness.js +52 -0
- package/dist/src/cli/assistant/questions-misc.d.ts +10 -0
- package/dist/src/cli/assistant/questions-misc.js +25 -0
- package/dist/src/cli/assistant/questions-restart.d.ts +15 -0
- package/dist/src/cli/assistant/questions-restart.js +51 -0
- package/dist/src/cli/assistant/questions-snapshot.d.ts +9 -0
- package/dist/src/cli/assistant/questions-snapshot.js +64 -0
- package/dist/src/cli/assistant/snapshot-specs.d.ts +4 -0
- package/dist/src/cli/assistant/snapshot-specs.js +22 -0
- package/dist/src/cli/assistant/summary.d.ts +2 -0
- package/dist/src/cli/assistant/summary.js +34 -0
- package/dist/src/cli/assistant/types.d.ts +37 -0
- package/dist/src/cli/assistant/types.js +1 -0
- package/dist/src/cli/assistant/ui-prompt.d.ts +29 -0
- package/dist/src/cli/assistant/ui-prompt.js +1 -0
- package/dist/src/cli/commands/doctor.d.ts +3 -0
- package/dist/src/cli/commands/doctor.js +56 -0
- package/dist/src/cli/commands/init.d.ts +4 -0
- package/dist/src/cli/commands/init.js +26 -0
- package/dist/src/cli/commands/remove.d.ts +3 -0
- package/dist/src/cli/commands/remove.js +62 -0
- package/dist/src/cli/composition-root.d.ts +3 -0
- package/dist/src/cli/composition-root.js +62 -0
- package/dist/src/cli/confirmation.d.ts +6 -0
- package/dist/src/cli/confirmation.js +22 -0
- package/dist/src/cli/detection-collector.d.ts +14 -0
- package/dist/src/cli/detection-collector.js +31 -0
- package/dist/src/cli/exit-codes.d.ts +8 -0
- package/dist/src/cli/exit-codes.js +8 -0
- package/dist/src/cli/gitignore-findings.d.ts +3 -0
- package/dist/src/cli/gitignore-findings.js +11 -0
- package/dist/src/cli/handoff-findings.d.ts +5 -0
- package/dist/src/cli/handoff-findings.js +15 -0
- package/dist/src/cli/init-arguments.d.ts +25 -0
- package/dist/src/cli/init-arguments.js +70 -0
- package/dist/src/cli/init-config-state.d.ts +14 -0
- package/dist/src/cli/init-config-state.js +19 -0
- package/dist/src/cli/init-config-updates.d.ts +13 -0
- package/dist/src/cli/init-config-updates.js +35 -0
- package/dist/src/cli/init-flow.d.ts +14 -0
- package/dist/src/cli/init-flow.js +72 -0
- package/dist/src/cli/init-option-rules.d.ts +11 -0
- package/dist/src/cli/init-option-rules.js +29 -0
- package/dist/src/cli/main.d.ts +3 -0
- package/dist/src/cli/main.js +62 -0
- package/dist/src/cli/output/detection-text.d.ts +2 -0
- package/dist/src/cli/output/detection-text.js +3 -0
- package/dist/src/cli/output/doctor-mode-text.d.ts +2 -0
- package/dist/src/cli/output/doctor-mode-text.js +12 -0
- package/dist/src/cli/output/doctor-sessions-text.d.ts +2 -0
- package/dist/src/cli/output/doctor-sessions-text.js +12 -0
- package/dist/src/cli/output/json.d.ts +1 -0
- package/dist/src/cli/output/json.js +3 -0
- package/dist/src/cli/output/text.d.ts +5 -0
- package/dist/src/cli/output/text.js +68 -0
- package/dist/src/cli/snapshot-helper.d.ts +3 -0
- package/dist/src/cli/snapshot-helper.js +25 -0
- package/dist/src/cli/terminal.d.ts +9 -0
- package/dist/src/cli/terminal.js +18 -0
- package/dist/src/core/contracts/adapter.d.ts +49 -0
- package/dist/src/core/contracts/adapter.js +1 -0
- package/dist/src/core/contracts/auto-restart.d.ts +10 -0
- package/dist/src/core/contracts/auto-restart.js +10 -0
- package/dist/src/core/contracts/changes.d.ts +219 -0
- package/dist/src/core/contracts/changes.js +13 -0
- package/dist/src/core/contracts/configuration.d.ts +81 -0
- package/dist/src/core/contracts/configuration.js +52 -0
- package/dist/src/core/contracts/context-window-report.d.ts +16 -0
- package/dist/src/core/contracts/context-window-report.js +8 -0
- package/dist/src/core/contracts/diagnostics.d.ts +546 -0
- package/dist/src/core/contracts/diagnostics.js +35 -0
- package/dist/src/core/contracts/handoff.d.ts +10 -0
- package/dist/src/core/contracts/handoff.js +3 -0
- package/dist/src/core/contracts/harness.d.ts +73 -0
- package/dist/src/core/contracts/harness.js +23 -0
- package/dist/src/core/contracts/hook-phase.d.ts +12 -0
- package/dist/src/core/contracts/hook-phase.js +1 -0
- package/dist/src/core/contracts/manifest.d.ts +69 -0
- package/dist/src/core/contracts/manifest.js +20 -0
- package/dist/src/core/contracts/processes.d.ts +24 -0
- package/dist/src/core/contracts/processes.js +1 -0
- package/dist/src/core/contracts/restart-host.d.ts +32 -0
- package/dist/src/core/contracts/restart-host.js +3 -0
- package/dist/src/core/contracts/restart-log.d.ts +52 -0
- package/dist/src/core/contracts/restart-log.js +15 -0
- package/dist/src/core/contracts/runtime.d.ts +50 -0
- package/dist/src/core/contracts/runtime.js +1 -0
- package/dist/src/core/contracts/session-ledger.d.ts +144 -0
- package/dist/src/core/contracts/session-ledger.js +38 -0
- package/dist/src/core/contracts/statusline-line.d.ts +20 -0
- package/dist/src/core/contracts/statusline-line.js +13 -0
- package/dist/src/core/contracts/zones.d.ts +18 -0
- package/dist/src/core/contracts/zones.js +4 -0
- package/dist/src/core/services/active-sessions.d.ts +17 -0
- package/dist/src/core/services/active-sessions.js +35 -0
- package/dist/src/core/services/asset-currency.d.ts +17 -0
- package/dist/src/core/services/asset-currency.js +72 -0
- package/dist/src/core/services/auto-restart-merge.d.ts +26 -0
- package/dist/src/core/services/auto-restart-merge.js +30 -0
- package/dist/src/core/services/auto-restart-notices.d.ts +6 -0
- package/dist/src/core/services/auto-restart-notices.js +27 -0
- package/dist/src/core/services/auto-restart-policy.d.ts +26 -0
- package/dist/src/core/services/auto-restart-policy.js +23 -0
- package/dist/src/core/services/brake-engine.d.ts +24 -0
- package/dist/src/core/services/brake-engine.js +61 -0
- package/dist/src/core/services/change-plan-service.d.ts +11 -0
- package/dist/src/core/services/change-plan-service.js +60 -0
- package/dist/src/core/services/config-legacy-checks.d.ts +6 -0
- package/dist/src/core/services/config-legacy-checks.js +28 -0
- package/dist/src/core/services/debug-mode-merge.d.ts +25 -0
- package/dist/src/core/services/debug-mode-merge.js +21 -0
- package/dist/src/core/services/detection-service.d.ts +6 -0
- package/dist/src/core/services/detection-service.js +54 -0
- package/dist/src/core/services/doctor-checks.d.ts +6 -0
- package/dist/src/core/services/doctor-checks.js +24 -0
- package/dist/src/core/services/doctor-report-extras.d.ts +11 -0
- package/dist/src/core/services/doctor-report-extras.js +23 -0
- package/dist/src/core/services/doctor-service.d.ts +24 -0
- package/dist/src/core/services/doctor-service.js +82 -0
- package/dist/src/core/services/failure-policy.d.ts +38 -0
- package/dist/src/core/services/failure-policy.js +63 -0
- package/dist/src/core/services/gitignore-block.d.ts +10 -0
- package/dist/src/core/services/gitignore-block.js +61 -0
- package/dist/src/core/services/gitignore-merge.d.ts +23 -0
- package/dist/src/core/services/gitignore-merge.js +21 -0
- package/dist/src/core/services/gitignore-plan.d.ts +34 -0
- package/dist/src/core/services/gitignore-plan.js +65 -0
- package/dist/src/core/services/harness-exclusion.d.ts +14 -0
- package/dist/src/core/services/harness-exclusion.js +19 -0
- package/dist/src/core/services/harness-removal.d.ts +23 -0
- package/dist/src/core/services/harness-removal.js +34 -0
- package/dist/src/core/services/injection-policy.d.ts +9 -0
- package/dist/src/core/services/injection-policy.js +5 -0
- package/dist/src/core/services/installation-adapters.d.ts +21 -0
- package/dist/src/core/services/installation-adapters.js +28 -0
- package/dist/src/core/services/installation-builder.d.ts +24 -0
- package/dist/src/core/services/installation-builder.js +66 -0
- package/dist/src/core/services/installation-findings.d.ts +5 -0
- package/dist/src/core/services/installation-findings.js +19 -0
- package/dist/src/core/services/installation-service.d.ts +36 -0
- package/dist/src/core/services/installation-service.js +50 -0
- package/dist/src/core/services/manifest-change.d.ts +11 -0
- package/dist/src/core/services/manifest-change.js +16 -0
- package/dist/src/core/services/no-harness-finding.d.ts +3 -0
- package/dist/src/core/services/no-harness-finding.js +9 -0
- package/dist/src/core/services/removal-helper.d.ts +10 -0
- package/dist/src/core/services/removal-helper.js +48 -0
- package/dist/src/core/services/removal-service.d.ts +19 -0
- package/dist/src/core/services/removal-service.js +45 -0
- package/dist/src/core/services/report-service.d.ts +30 -0
- package/dist/src/core/services/report-service.js +71 -0
- package/dist/src/core/services/reset-notice.d.ts +3 -0
- package/dist/src/core/services/reset-notice.js +8 -0
- package/dist/src/core/services/restart-doctor-findings.d.ts +10 -0
- package/dist/src/core/services/restart-doctor-findings.js +24 -0
- package/dist/src/core/services/restart-flow.d.ts +13 -0
- package/dist/src/core/services/restart-flow.js +50 -0
- package/dist/src/core/services/restart-guards.d.ts +6 -0
- package/dist/src/core/services/restart-guards.js +25 -0
- package/dist/src/core/services/restart-install-extras.d.ts +27 -0
- package/dist/src/core/services/restart-install-extras.js +39 -0
- package/dist/src/core/services/restart-mode.d.ts +4 -0
- package/dist/src/core/services/restart-mode.js +6 -0
- package/dist/src/core/services/runtime-error-checks.d.ts +11 -0
- package/dist/src/core/services/runtime-error-checks.js +20 -0
- package/dist/src/core/services/session-counters.d.ts +15 -0
- package/dist/src/core/services/session-counters.js +33 -0
- package/dist/src/core/services/session-reset-handler.d.ts +18 -0
- package/dist/src/core/services/session-reset-handler.js +24 -0
- package/dist/src/core/services/session-zone.d.ts +30 -0
- package/dist/src/core/services/session-zone.js +25 -0
- package/dist/src/core/services/snapshot-merge.d.ts +22 -0
- package/dist/src/core/services/snapshot-merge.js +25 -0
- package/dist/src/core/services/statusline-summary.d.ts +10 -0
- package/dist/src/core/services/statusline-summary.js +13 -0
- package/dist/src/core/services/support-service.d.ts +2 -0
- package/dist/src/core/services/support-service.js +57 -0
- package/dist/src/core/services/telemetry-block.d.ts +14 -0
- package/dist/src/core/services/telemetry-block.js +17 -0
- package/dist/src/core/services/usage-resolver.d.ts +20 -0
- package/dist/src/core/services/usage-resolver.js +23 -0
- package/dist/src/core/services/version-service.d.ts +14 -0
- package/dist/src/core/services/version-service.js +45 -0
- package/dist/src/core/services/window-trust.d.ts +2 -0
- package/dist/src/core/services/window-trust.js +3 -0
- package/dist/src/core/services/zone-classifier.d.ts +11 -0
- package/dist/src/core/services/zone-classifier.js +24 -0
- package/dist/src/core/services/zone-guidance.d.ts +6 -0
- package/dist/src/core/services/zone-guidance.js +32 -0
- package/dist/src/core/validation/configuration-sanitizer.d.ts +10 -0
- package/dist/src/core/validation/configuration-sanitizer.js +31 -0
- package/dist/src/core/validation/configuration-validator.d.ts +18 -0
- package/dist/src/core/validation/configuration-validator.js +45 -0
- package/dist/src/infrastructure/diagnostics/in-process-sampler.d.ts +18 -0
- package/dist/src/infrastructure/diagnostics/in-process-sampler.js +63 -0
- package/dist/src/infrastructure/diagnostics/overhead-measurer.d.ts +12 -0
- package/dist/src/infrastructure/diagnostics/overhead-measurer.js +77 -0
- package/dist/src/infrastructure/diagnostics/p95.d.ts +1 -0
- package/dist/src/infrastructure/diagnostics/p95.js +9 -0
- package/dist/src/infrastructure/diagnostics/process-sampler.d.ts +7 -0
- package/dist/src/infrastructure/diagnostics/process-sampler.js +69 -0
- package/dist/src/infrastructure/diagnostics/sample-failure.d.ts +10 -0
- package/dist/src/infrastructure/diagnostics/sample-failure.js +19 -0
- package/dist/src/infrastructure/git/git-context.d.ts +3 -0
- package/dist/src/infrastructure/git/git-context.js +25 -0
- package/dist/src/infrastructure/harnesses/antigravity-cli/adapter.d.ts +14 -0
- package/dist/src/infrastructure/harnesses/antigravity-cli/adapter.js +84 -0
- package/dist/src/infrastructure/harnesses/antigravity-cli/capabilities.d.ts +2 -0
- package/dist/src/infrastructure/harnesses/antigravity-cli/capabilities.js +6 -0
- package/dist/src/infrastructure/harnesses/antigravity-cli/detector.d.ts +4 -0
- package/dist/src/infrastructure/harnesses/antigravity-cli/detector.js +56 -0
- package/dist/src/infrastructure/harnesses/antigravity-cli/planner.d.ts +7 -0
- package/dist/src/infrastructure/harnesses/antigravity-cli/planner.js +62 -0
- package/dist/src/infrastructure/harnesses/antigravity-cli/runtime.d.ts +9 -0
- package/dist/src/infrastructure/harnesses/antigravity-cli/runtime.js +51 -0
- package/dist/src/infrastructure/harnesses/antigravity-cli/schemas.d.ts +31 -0
- package/dist/src/infrastructure/harnesses/antigravity-cli/schemas.js +19 -0
- package/dist/src/infrastructure/harnesses/claude-code/adapter.d.ts +14 -0
- package/dist/src/infrastructure/harnesses/claude-code/adapter.js +84 -0
- package/dist/src/infrastructure/harnesses/claude-code/auto-restart-diagnostics.d.ts +9 -0
- package/dist/src/infrastructure/harnesses/claude-code/auto-restart-diagnostics.js +60 -0
- package/dist/src/infrastructure/harnesses/claude-code/auto-restart-files.d.ts +12 -0
- package/dist/src/infrastructure/harnesses/claude-code/auto-restart-files.js +24 -0
- package/dist/src/infrastructure/harnesses/claude-code/auto-restart-ownership.d.ts +5 -0
- package/dist/src/infrastructure/harnesses/claude-code/auto-restart-ownership.js +41 -0
- package/dist/src/infrastructure/harnesses/claude-code/auto-restart-planner.d.ts +7 -0
- package/dist/src/infrastructure/harnesses/claude-code/auto-restart-planner.js +81 -0
- package/dist/src/infrastructure/harnesses/claude-code/auto-restart-settings.d.ts +4 -0
- package/dist/src/infrastructure/harnesses/claude-code/auto-restart-settings.js +29 -0
- package/dist/src/infrastructure/harnesses/claude-code/capabilities.d.ts +2 -0
- package/dist/src/infrastructure/harnesses/claude-code/capabilities.js +6 -0
- package/dist/src/infrastructure/harnesses/claude-code/claude-hooks-config.d.ts +1 -0
- package/dist/src/infrastructure/harnesses/claude-code/claude-hooks-config.js +25 -0
- package/dist/src/infrastructure/harnesses/claude-code/claude-merger.d.ts +14 -0
- package/dist/src/infrastructure/harnesses/claude-code/claude-merger.js +44 -0
- package/dist/src/infrastructure/harnesses/claude-code/detector.d.ts +6 -0
- package/dist/src/infrastructure/harnesses/claude-code/detector.js +14 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/hooks.d.ts +6 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/hooks.js +43 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/host.d.ts +56 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/host.js +1 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/mod-config.d.ts +8 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/mod-config.js +31 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/mod-guards.d.ts +3 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/mod-guards.js +13 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/mod-info.d.ts +4 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/mod-info.js +5 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/mod-log.d.ts +4 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/mod-log.js +34 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/register.d.ts +2 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/register.js +23 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/restart-facts.d.ts +3 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/restart-facts.js +12 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/restart-flow.d.ts +4 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/restart-flow.js +22 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/restart-host.d.ts +7 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/restart-host.js +35 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/turn-state.d.ts +7 -0
- package/dist/src/infrastructure/harnesses/claude-code/mod/turn-state.js +12 -0
- package/dist/src/infrastructure/harnesses/claude-code/planner.d.ts +7 -0
- package/dist/src/infrastructure/harnesses/claude-code/planner.js +72 -0
- package/dist/src/infrastructure/harnesses/claude-code/runtime.d.ts +10 -0
- package/dist/src/infrastructure/harnesses/claude-code/runtime.js +82 -0
- package/dist/src/infrastructure/harnesses/claude-code/schemas.d.ts +42 -0
- package/dist/src/infrastructure/harnesses/claude-code/schemas.js +30 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-bridge.d.ts +12 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-bridge.js +78 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-context-window.d.ts +5 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-context-window.js +50 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-default.d.ts +6 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-default.js +38 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-diagnostics.d.ts +3 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-diagnostics.js +70 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-output.d.ts +9 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-output.js +15 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-payload.d.ts +7 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-payload.js +36 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-planner.d.ts +4 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-planner.js +82 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-previous.d.ts +17 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-previous.js +41 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-restore.d.ts +9 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-restore.js +31 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-settings.d.ts +33 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-settings.js +63 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-shell.d.ts +13 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-shell.js +28 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-state.d.ts +21 -0
- package/dist/src/infrastructure/harnesses/claude-code/statusline-state.js +29 -0
- package/dist/src/infrastructure/harnesses/claude-code/transcript-usage.d.ts +6 -0
- package/dist/src/infrastructure/harnesses/claude-code/transcript-usage.js +24 -0
- package/dist/src/infrastructure/harnesses/codex-cli/adapter.d.ts +14 -0
- package/dist/src/infrastructure/harnesses/codex-cli/adapter.js +90 -0
- package/dist/src/infrastructure/harnesses/codex-cli/capabilities.d.ts +2 -0
- package/dist/src/infrastructure/harnesses/codex-cli/capabilities.js +6 -0
- package/dist/src/infrastructure/harnesses/codex-cli/detector.d.ts +6 -0
- package/dist/src/infrastructure/harnesses/codex-cli/detector.js +13 -0
- package/dist/src/infrastructure/harnesses/codex-cli/planner.d.ts +7 -0
- package/dist/src/infrastructure/harnesses/codex-cli/planner.js +75 -0
- package/dist/src/infrastructure/harnesses/codex-cli/rollout-usage.d.ts +6 -0
- package/dist/src/infrastructure/harnesses/codex-cli/rollout-usage.js +27 -0
- package/dist/src/infrastructure/harnesses/codex-cli/runtime.d.ts +10 -0
- package/dist/src/infrastructure/harnesses/codex-cli/runtime.js +85 -0
- package/dist/src/infrastructure/harnesses/codex-cli/schemas.d.ts +47 -0
- package/dist/src/infrastructure/harnesses/codex-cli/schemas.js +25 -0
- package/dist/src/infrastructure/harnesses/common/antigravity-hooks-updater.d.ts +4 -0
- package/dist/src/infrastructure/harnesses/common/antigravity-hooks-updater.js +57 -0
- package/dist/src/infrastructure/harnesses/common/change-target.d.ts +1 -0
- package/dist/src/infrastructure/harnesses/common/change-target.js +40 -0
- package/dist/src/infrastructure/harnesses/common/codex-hooks-updater.d.ts +13 -0
- package/dist/src/infrastructure/harnesses/common/codex-hooks-updater.js +79 -0
- package/dist/src/infrastructure/harnesses/common/cursor-hooks-updater.d.ts +3 -0
- package/dist/src/infrastructure/harnesses/common/cursor-hooks-updater.js +63 -0
- package/dist/src/infrastructure/harnesses/common/diagnostic-helpers.d.ts +7 -0
- package/dist/src/infrastructure/harnesses/common/diagnostic-helpers.js +60 -0
- package/dist/src/infrastructure/harnesses/common/hook-event-cleanup.d.ts +3 -0
- package/dist/src/infrastructure/harnesses/common/hook-event-cleanup.js +50 -0
- package/dist/src/infrastructure/harnesses/common/in-process-restart-log.d.ts +9 -0
- package/dist/src/infrastructure/harnesses/common/in-process-restart-log.js +36 -0
- package/dist/src/infrastructure/harnesses/common/in-process-restart-state.d.ts +11 -0
- package/dist/src/infrastructure/harnesses/common/in-process-restart-state.js +50 -0
- package/dist/src/infrastructure/harnesses/common/in-process-restart-support.d.ts +13 -0
- package/dist/src/infrastructure/harnesses/common/in-process-restart-support.js +15 -0
- package/dist/src/infrastructure/harnesses/common/in-process-support.d.ts +18 -0
- package/dist/src/infrastructure/harnesses/common/in-process-support.js +40 -0
- package/dist/src/infrastructure/harnesses/common/jsonl-tail-reader.d.ts +6 -0
- package/dist/src/infrastructure/harnesses/common/jsonl-tail-reader.js +76 -0
- package/dist/src/infrastructure/harnesses/common/path-helpers.d.ts +6 -0
- package/dist/src/infrastructure/harnesses/common/path-helpers.js +51 -0
- package/dist/src/infrastructure/harnesses/common/removal-config-validator.d.ts +2 -0
- package/dist/src/infrastructure/harnesses/common/removal-config-validator.js +14 -0
- package/dist/src/infrastructure/harnesses/common/restart-asset-plan.d.ts +12 -0
- package/dist/src/infrastructure/harnesses/common/restart-asset-plan.js +37 -0
- package/dist/src/infrastructure/harnesses/common/restart-diagnostics.d.ts +12 -0
- package/dist/src/infrastructure/harnesses/common/restart-diagnostics.js +49 -0
- package/dist/src/infrastructure/harnesses/common/runtime-assets.d.ts +1 -0
- package/dist/src/infrastructure/harnesses/common/runtime-assets.js +23 -0
- package/dist/src/infrastructure/harnesses/common/runtime-support.d.ts +8 -0
- package/dist/src/infrastructure/harnesses/common/runtime-support.js +44 -0
- package/dist/src/infrastructure/harnesses/common/version-probes.d.ts +3 -0
- package/dist/src/infrastructure/harnesses/common/version-probes.js +21 -0
- package/dist/src/infrastructure/harnesses/cursor/adapter.d.ts +14 -0
- package/dist/src/infrastructure/harnesses/cursor/adapter.js +70 -0
- package/dist/src/infrastructure/harnesses/cursor/capabilities.d.ts +2 -0
- package/dist/src/infrastructure/harnesses/cursor/capabilities.js +6 -0
- package/dist/src/infrastructure/harnesses/cursor/detector.d.ts +6 -0
- package/dist/src/infrastructure/harnesses/cursor/detector.js +13 -0
- package/dist/src/infrastructure/harnesses/cursor/planner.d.ts +7 -0
- package/dist/src/infrastructure/harnesses/cursor/planner.js +66 -0
- package/dist/src/infrastructure/harnesses/cursor/runtime.d.ts +9 -0
- package/dist/src/infrastructure/harnesses/cursor/runtime.js +49 -0
- package/dist/src/infrastructure/harnesses/cursor/schemas.d.ts +39 -0
- package/dist/src/infrastructure/harnesses/cursor/schemas.js +23 -0
- package/dist/src/infrastructure/harnesses/github-copilot-cli/adapter.d.ts +14 -0
- package/dist/src/infrastructure/harnesses/github-copilot-cli/adapter.js +69 -0
- package/dist/src/infrastructure/harnesses/github-copilot-cli/capabilities.d.ts +2 -0
- package/dist/src/infrastructure/harnesses/github-copilot-cli/capabilities.js +6 -0
- package/dist/src/infrastructure/harnesses/github-copilot-cli/detector.d.ts +6 -0
- package/dist/src/infrastructure/harnesses/github-copilot-cli/detector.js +15 -0
- package/dist/src/infrastructure/harnesses/github-copilot-cli/planner.d.ts +7 -0
- package/dist/src/infrastructure/harnesses/github-copilot-cli/planner.js +66 -0
- package/dist/src/infrastructure/harnesses/github-copilot-cli/runtime.d.ts +9 -0
- package/dist/src/infrastructure/harnesses/github-copilot-cli/runtime.js +67 -0
- package/dist/src/infrastructure/harnesses/github-copilot-cli/schemas.d.ts +35 -0
- package/dist/src/infrastructure/harnesses/github-copilot-cli/schemas.js +21 -0
- package/dist/src/infrastructure/harnesses/oh-my-pi/adapter.d.ts +14 -0
- package/dist/src/infrastructure/harnesses/oh-my-pi/adapter.js +64 -0
- package/dist/src/infrastructure/harnesses/oh-my-pi/capabilities.d.ts +2 -0
- package/dist/src/infrastructure/harnesses/oh-my-pi/capabilities.js +6 -0
- package/dist/src/infrastructure/harnesses/oh-my-pi/detector.d.ts +6 -0
- package/dist/src/infrastructure/harnesses/oh-my-pi/detector.js +13 -0
- package/dist/src/infrastructure/harnesses/oh-my-pi/events.d.ts +8 -0
- package/dist/src/infrastructure/harnesses/oh-my-pi/events.js +65 -0
- package/dist/src/infrastructure/harnesses/oh-my-pi/planner.d.ts +7 -0
- package/dist/src/infrastructure/harnesses/oh-my-pi/planner.js +32 -0
- package/dist/src/infrastructure/harnesses/oh-my-pi/restart.d.ts +28 -0
- package/dist/src/infrastructure/harnesses/oh-my-pi/restart.js +79 -0
- package/dist/src/infrastructure/harnesses/oh-my-pi/runtime.d.ts +17 -0
- package/dist/src/infrastructure/harnesses/oh-my-pi/runtime.js +69 -0
- package/dist/src/infrastructure/harnesses/oh-my-pi/schemas.d.ts +50 -0
- package/dist/src/infrastructure/harnesses/oh-my-pi/schemas.js +17 -0
- package/dist/src/infrastructure/harnesses/opencode/adapter.d.ts +14 -0
- package/dist/src/infrastructure/harnesses/opencode/adapter.js +64 -0
- package/dist/src/infrastructure/harnesses/opencode/capabilities.d.ts +2 -0
- package/dist/src/infrastructure/harnesses/opencode/capabilities.js +6 -0
- package/dist/src/infrastructure/harnesses/opencode/detector.d.ts +6 -0
- package/dist/src/infrastructure/harnesses/opencode/detector.js +16 -0
- package/dist/src/infrastructure/harnesses/opencode/events.d.ts +8 -0
- package/dist/src/infrastructure/harnesses/opencode/events.js +36 -0
- package/dist/src/infrastructure/harnesses/opencode/planner.d.ts +6 -0
- package/dist/src/infrastructure/harnesses/opencode/planner.js +23 -0
- package/dist/src/infrastructure/harnesses/opencode/runtime.d.ts +20 -0
- package/dist/src/infrastructure/harnesses/opencode/runtime.js +51 -0
- package/dist/src/infrastructure/harnesses/opencode/schemas.d.ts +51 -0
- package/dist/src/infrastructure/harnesses/opencode/schemas.js +32 -0
- package/dist/src/infrastructure/harnesses/pi/adapter.d.ts +14 -0
- package/dist/src/infrastructure/harnesses/pi/adapter.js +64 -0
- package/dist/src/infrastructure/harnesses/pi/capabilities.d.ts +2 -0
- package/dist/src/infrastructure/harnesses/pi/capabilities.js +6 -0
- package/dist/src/infrastructure/harnesses/pi/detector.d.ts +6 -0
- package/dist/src/infrastructure/harnesses/pi/detector.js +10 -0
- package/dist/src/infrastructure/harnesses/pi/events.d.ts +8 -0
- package/dist/src/infrastructure/harnesses/pi/events.js +65 -0
- package/dist/src/infrastructure/harnesses/pi/planner.d.ts +7 -0
- package/dist/src/infrastructure/harnesses/pi/planner.js +32 -0
- package/dist/src/infrastructure/harnesses/pi/restart.d.ts +33 -0
- package/dist/src/infrastructure/harnesses/pi/restart.js +69 -0
- package/dist/src/infrastructure/harnesses/pi/runtime.d.ts +17 -0
- package/dist/src/infrastructure/harnesses/pi/runtime.js +67 -0
- package/dist/src/infrastructure/harnesses/pi/schemas.d.ts +50 -0
- package/dist/src/infrastructure/harnesses/pi/schemas.js +17 -0
- package/dist/src/infrastructure/harnesses/registry.d.ts +6 -0
- package/dist/src/infrastructure/harnesses/registry.js +94 -0
- package/dist/src/infrastructure/process/node-process-runner.d.ts +8 -0
- package/dist/src/infrastructure/process/node-process-runner.js +66 -0
- package/dist/src/infrastructure/process/process-tree.d.ts +2 -0
- package/dist/src/infrastructure/process/process-tree.js +28 -0
- package/dist/src/infrastructure/runtime/hook-deadline.d.ts +26 -0
- package/dist/src/infrastructure/runtime/hook-deadline.js +55 -0
- package/dist/src/infrastructure/runtime/hook-failure.d.ts +14 -0
- package/dist/src/infrastructure/runtime/hook-failure.js +22 -0
- package/dist/src/infrastructure/runtime/in-process-host.d.ts +16 -0
- package/dist/src/infrastructure/runtime/in-process-host.js +75 -0
- package/dist/src/infrastructure/runtime/node-runtime-logs.d.ts +8 -0
- package/dist/src/infrastructure/runtime/node-runtime-logs.js +21 -0
- package/dist/src/infrastructure/runtime/node-session-ledger.d.ts +17 -0
- package/dist/src/infrastructure/runtime/node-session-ledger.js +68 -0
- package/dist/src/infrastructure/runtime/process-hook-host.d.ts +25 -0
- package/dist/src/infrastructure/runtime/process-hook-host.js +79 -0
- package/dist/src/infrastructure/runtime/runtime-composition.d.ts +29 -0
- package/dist/src/infrastructure/runtime/runtime-composition.js +41 -0
- package/dist/src/infrastructure/runtime/runtime-paths.d.ts +12 -0
- package/dist/src/infrastructure/runtime/runtime-paths.js +45 -0
- package/dist/src/infrastructure/runtime/runtime-state-reader.d.ts +9 -0
- package/dist/src/infrastructure/runtime/runtime-state-reader.js +82 -0
- package/dist/src/infrastructure/storage/atomic-writer.d.ts +2 -0
- package/dist/src/infrastructure/storage/atomic-writer.js +35 -0
- package/dist/src/infrastructure/storage/change-applier.d.ts +10 -0
- package/dist/src/infrastructure/storage/change-applier.js +80 -0
- package/dist/src/infrastructure/storage/directory-pruner.d.ts +8 -0
- package/dist/src/infrastructure/storage/directory-pruner.js +76 -0
- package/dist/src/infrastructure/storage/handoff-claim-lock.d.ts +3 -0
- package/dist/src/infrastructure/storage/handoff-claim-lock.js +32 -0
- package/dist/src/infrastructure/storage/json-document-editor.d.ts +5 -0
- package/dist/src/infrastructure/storage/json-document-editor.js +52 -0
- package/dist/src/infrastructure/storage/json-span-utils.d.ts +24 -0
- package/dist/src/infrastructure/storage/json-span-utils.js +104 -0
- package/dist/src/infrastructure/storage/json-validator.d.ts +13 -0
- package/dist/src/infrastructure/storage/json-validator.js +61 -0
- package/dist/src/infrastructure/storage/manifest-store.d.ts +11 -0
- package/dist/src/infrastructure/storage/manifest-store.js +45 -0
- package/dist/src/infrastructure/storage/node-file-system.d.ts +4 -0
- package/dist/src/infrastructure/storage/node-file-system.js +33 -0
- package/dist/src/infrastructure/storage/node-handoff-store.d.ts +11 -0
- package/dist/src/infrastructure/storage/node-handoff-store.js +96 -0
- package/dist/src/infrastructure/storage/package-metadata.d.ts +7 -0
- package/dist/src/infrastructure/storage/package-metadata.js +58 -0
- package/dist/src/infrastructure/storage/path-boundary.d.ts +11 -0
- package/dist/src/infrastructure/storage/path-boundary.js +73 -0
- package/dist/src/infrastructure/storage/project-config-store.d.ts +9 -0
- package/dist/src/infrastructure/storage/project-config-store.js +24 -0
- package/dist/src/infrastructure/storage/runtime-state-files.d.ts +12 -0
- package/dist/src/infrastructure/storage/runtime-state-files.js +22 -0
- package/docs/telemetry-block.md +149 -0
- package/package.json +65 -4
- package/schemas/context-brake.config.schema.json +177 -0
- package/schemas/doctor-report.schema.json +595 -0
- package/schemas/install-report.schema.json +458 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type Payload = Record<string, unknown>;
|
|
2
|
+
export type OmpRestartContext = {
|
|
3
|
+
readonly cwd?: string | undefined;
|
|
4
|
+
readonly mode?: string | undefined;
|
|
5
|
+
readonly hasUI?: boolean | undefined;
|
|
6
|
+
readonly sessionManager?: {
|
|
7
|
+
readonly getSessionId?: () => string;
|
|
8
|
+
} | undefined;
|
|
9
|
+
readonly ui?: {
|
|
10
|
+
readonly notify?: (message: string, level?: string) => void;
|
|
11
|
+
readonly getEditorText?: () => string;
|
|
12
|
+
readonly setEditorText?: (text: string) => void;
|
|
13
|
+
} | undefined;
|
|
14
|
+
readonly newSession?: () => Promise<{
|
|
15
|
+
cancelled: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
18
|
+
type Handler = (payload: Payload, context: OmpRestartContext) => Promise<unknown>;
|
|
19
|
+
export type OmpRestartApi = {
|
|
20
|
+
on(event: string, handler: Handler): void;
|
|
21
|
+
registerCommand(name: string, command: {
|
|
22
|
+
description: string;
|
|
23
|
+
handler(args: string, context: OmpRestartContext): Promise<void>;
|
|
24
|
+
}): void;
|
|
25
|
+
sendUserMessage(text: string): void;
|
|
26
|
+
};
|
|
27
|
+
export declare function createOmpRestartExtension(api: OmpRestartApi): void;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { foldToolCalls, resetConsecutive } from '../../../core/services/restart-guards.js';
|
|
2
|
+
import { handleTurnEnd } from '../../../core/services/restart-flow.js';
|
|
3
|
+
import { systemClock } from '../../runtime/runtime-composition.js';
|
|
4
|
+
import { NodeHandoffStore } from '../../storage/node-handoff-store.js';
|
|
5
|
+
import { recordInProcessDecision } from '../common/in-process-restart-log.js';
|
|
6
|
+
import { recordRestartLoaded, reportFailures } from '../common/in-process-restart-support.js';
|
|
7
|
+
import { countToolCall, inProcessStandDown, memoryGuardStore, readRestartSettings, RESTART_COMMAND, startTurn, takeToolCalls, turnStartedAt } from '../common/in-process-restart-state.js';
|
|
8
|
+
import { textValue } from '../common/runtime-support.js';
|
|
9
|
+
import { stopMessageText } from './events.js';
|
|
10
|
+
const HARNESS = 'oh-my-pi';
|
|
11
|
+
const INTERACTIVE_MODE = 'tui';
|
|
12
|
+
const INTERACTIVE_SOURCE = 'interactive';
|
|
13
|
+
const COMMAND_TEXT = `/${RESTART_COMMAND}`;
|
|
14
|
+
const pending = new Map();
|
|
15
|
+
function prefill(context, root, request) {
|
|
16
|
+
const editor = context.ui;
|
|
17
|
+
if (editor?.setEditorText === undefined || (editor.getEditorText?.() ?? '').trim() !== '') {
|
|
18
|
+
void request.onRejected();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
pending.set(root, request);
|
|
22
|
+
editor.setEditorText(COMMAND_TEXT);
|
|
23
|
+
}
|
|
24
|
+
function hostFor(context, root) {
|
|
25
|
+
const target = { root, harness: HARNESS, sessionId: context.sessionManager?.getSessionId?.() ?? 'unknown' };
|
|
26
|
+
return {
|
|
27
|
+
guards: memoryGuardStore(root),
|
|
28
|
+
handoff: new NodeHandoffStore(root, systemClock),
|
|
29
|
+
standDown: async () => inProcessStandDown(context.mode === INTERACTIVE_MODE && context.hasUI === true),
|
|
30
|
+
turnStartedAt: () => turnStartedAt(root),
|
|
31
|
+
resumeForSeed: async () => null,
|
|
32
|
+
openSession: (request) => prefill(context, root, request),
|
|
33
|
+
log: (code) => recordInProcessDecision(target, code, systemClock.now()),
|
|
34
|
+
notify: (text) => context.ui?.notify?.(text, 'info'),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
async function onSessionStop(payload, context) {
|
|
38
|
+
const root = textValue(context.cwd);
|
|
39
|
+
if (root === null)
|
|
40
|
+
return;
|
|
41
|
+
await foldToolCalls(memoryGuardStore(root), takeToolCalls(root));
|
|
42
|
+
const settings = await readRestartSettings(root);
|
|
43
|
+
if (settings === undefined)
|
|
44
|
+
return;
|
|
45
|
+
await handleTurnEnd(hostFor(context, root), { text: stopMessageText(payload['last_assistant_message']), settings });
|
|
46
|
+
}
|
|
47
|
+
async function runRestartCommand(api, context) {
|
|
48
|
+
const root = textValue(context.cwd);
|
|
49
|
+
const request = root === null ? undefined : pending.get(root);
|
|
50
|
+
if (root === null || request === undefined || context.newSession === undefined)
|
|
51
|
+
return;
|
|
52
|
+
pending.delete(root);
|
|
53
|
+
try {
|
|
54
|
+
if ((await context.newSession()).cancelled)
|
|
55
|
+
return request.onRejected();
|
|
56
|
+
await request.onOpened();
|
|
57
|
+
api.sendUserMessage(request.seed);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
await request.onRejected();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function onInput(payload, context) {
|
|
64
|
+
const root = textValue(context.cwd);
|
|
65
|
+
const typed = payload['source'] === INTERACTIVE_SOURCE && textValue(payload['text'])?.trim() !== COMMAND_TEXT;
|
|
66
|
+
if (root !== null && typed)
|
|
67
|
+
await resetConsecutive(memoryGuardStore(root));
|
|
68
|
+
}
|
|
69
|
+
export function createOmpRestartExtension(api) {
|
|
70
|
+
api.on('agent_start', async (_payload, context) => { const root = textValue(context.cwd); if (root !== null)
|
|
71
|
+
startTurn(root, systemClock.now().getTime()); });
|
|
72
|
+
api.on('tool_result', async (_payload, context) => { const root = textValue(context.cwd); if (root !== null)
|
|
73
|
+
countToolCall(root); });
|
|
74
|
+
api.on('input', (payload, context) => reportFailures(context, () => onInput(payload, context)));
|
|
75
|
+
api.on('session_start', (_payload, context) => reportFailures(context, () => recordRestartLoaded(context, HARNESS)));
|
|
76
|
+
api.on('session_switch', (_payload, context) => reportFailures(context, () => recordRestartLoaded(context, HARNESS)));
|
|
77
|
+
api.on('session_stop', (payload, context) => reportFailures(context, () => onSessionStop(payload, context)));
|
|
78
|
+
api.registerCommand(RESTART_COMMAND, { description: 'ContextBrake: open a new session and resume from the recorded state', handler: (_args, context) => reportFailures(context, () => runRestartCommand(api, context)) });
|
|
79
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RuntimeDescriptor } from '../../../core/contracts/runtime.js';
|
|
2
|
+
export { mapOmpEvent, mapOmpInput, renderOmpToolResult } from './events.js';
|
|
3
|
+
export declare const ompDescriptor: RuntimeDescriptor;
|
|
4
|
+
export type OmpContext = {
|
|
5
|
+
readonly cwd?: string | undefined;
|
|
6
|
+
readonly sessionManager?: {
|
|
7
|
+
readonly getSessionId?: () => string;
|
|
8
|
+
} | undefined;
|
|
9
|
+
readonly getContextUsage?: (() => unknown) | undefined;
|
|
10
|
+
readonly ui?: {
|
|
11
|
+
readonly notify?: (message: string, level?: string) => void;
|
|
12
|
+
} | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type OmpApi = {
|
|
15
|
+
on?: (event: string, handler: (payload: unknown, context: OmpContext) => Promise<unknown>) => void;
|
|
16
|
+
};
|
|
17
|
+
export declare function createOmpExtension(api: OmpApi): void;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createRuntimeResolver, measuredUsageFrom, runInProcessEvent } from '../common/in-process-support.js';
|
|
2
|
+
import { requireIdentifier, textValue } from '../common/runtime-support.js';
|
|
3
|
+
import { OMP_CAPABILITIES } from './capabilities.js';
|
|
4
|
+
import { mapOmpEvent, mapOmpInput, renderOmpToolResult } from './events.js';
|
|
5
|
+
export { mapOmpEvent, mapOmpInput, renderOmpToolResult } from './events.js';
|
|
6
|
+
const HARNESS = 'oh-my-pi';
|
|
7
|
+
const ESTIMATION = { baselineTokens: 15000, tokensPerTurn: 150 };
|
|
8
|
+
export const ompDescriptor = { harness: HARNESS, capabilities: OMP_CAPABILITIES, estimation: ESTIMATION, newSessionCommand: '/new' };
|
|
9
|
+
function rootOf(context) {
|
|
10
|
+
return textValue(context.cwd);
|
|
11
|
+
}
|
|
12
|
+
function sessionOf(context) {
|
|
13
|
+
return { harness: HARNESS, sessionId: requireIdentifier(context.sessionManager?.getSessionId?.()), agentId: null };
|
|
14
|
+
}
|
|
15
|
+
function measuredOf(context) {
|
|
16
|
+
return measuredUsageFrom(context.getContextUsage?.());
|
|
17
|
+
}
|
|
18
|
+
function eventOf(eventName, payload, context) {
|
|
19
|
+
try {
|
|
20
|
+
return mapOmpEvent(eventName, payload, sessionOf(context));
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async function handleToolResult(payload, context, resolver) {
|
|
27
|
+
const event = eventOf('tool_result', payload, context);
|
|
28
|
+
if (event === null)
|
|
29
|
+
return undefined;
|
|
30
|
+
const engineInput = { measured: measuredOf(context), ...mapOmpInput('tool_result', payload) };
|
|
31
|
+
const decision = await runInProcessEvent({ resolver, projectRoot: rootOf(context), event, engineInput });
|
|
32
|
+
return decision.kind === 'context' ? renderOmpToolResult(payload, decision.block) : undefined;
|
|
33
|
+
}
|
|
34
|
+
async function recordBoot(event, context, state) {
|
|
35
|
+
if (event === null)
|
|
36
|
+
return;
|
|
37
|
+
const decision = await runInProcessEvent({ resolver: state.resolver, projectRoot: rootOf(context), event });
|
|
38
|
+
if (decision.kind === 'context')
|
|
39
|
+
state.pendingBoots.set(event.session.sessionId, decision.block);
|
|
40
|
+
}
|
|
41
|
+
async function handleBeforeAgentStart(context, pendingBoots) {
|
|
42
|
+
const sessionId = context.sessionManager?.getSessionId?.();
|
|
43
|
+
if (!sessionId)
|
|
44
|
+
return undefined;
|
|
45
|
+
const message = pendingBoots.get(sessionId);
|
|
46
|
+
if (!message)
|
|
47
|
+
return undefined;
|
|
48
|
+
pendingBoots.delete(sessionId);
|
|
49
|
+
return { message };
|
|
50
|
+
}
|
|
51
|
+
async function handleSessionStop(payload, context, resolver) {
|
|
52
|
+
const event = eventOf('session_stop', payload, context);
|
|
53
|
+
if (event === null)
|
|
54
|
+
return;
|
|
55
|
+
const decision = await runInProcessEvent({ resolver, projectRoot: rootOf(context), event });
|
|
56
|
+
if (decision.kind === 'notify_user')
|
|
57
|
+
context.ui?.notify?.(decision.text, 'info');
|
|
58
|
+
}
|
|
59
|
+
export function createOmpExtension(api) {
|
|
60
|
+
const resolver = createRuntimeResolver(ompDescriptor);
|
|
61
|
+
const pendingBoots = new Map();
|
|
62
|
+
api.on?.('tool_result', (payload, context) => handleToolResult(payload, context, resolver));
|
|
63
|
+
api.on?.('session_start', (payload, context) => recordBoot(eventOf('session_start', payload, context), context, { resolver, pendingBoots }));
|
|
64
|
+
api.on?.('session_switch', (payload, context) => recordBoot(eventOf('session_switch', payload, context), context, { resolver, pendingBoots }));
|
|
65
|
+
api.on?.('session_compact', (payload, context) => recordBoot(eventOf('session_compact', payload, context), context, { resolver, pendingBoots }));
|
|
66
|
+
api.on?.('auto_compaction_end', (payload, context) => recordBoot(eventOf('auto_compaction_end', payload, context), context, { resolver, pendingBoots }));
|
|
67
|
+
api.on?.('before_agent_start', (_payload, context) => handleBeforeAgentStart(context, pendingBoots));
|
|
68
|
+
api.on?.('session_stop', (payload, context) => handleSessionStop(payload, context, resolver));
|
|
69
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod/mini';
|
|
2
|
+
export declare const ompSettingsFileSchema: z.ZodMiniObject<{
|
|
3
|
+
extensions: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
4
|
+
}, z.core.$loose>;
|
|
5
|
+
export declare const ompPayloadSchema: z.ZodMiniObject<{
|
|
6
|
+
toolName: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
7
|
+
toolCallId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
8
|
+
input: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
9
|
+
content: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
10
|
+
reason: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
11
|
+
message: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
12
|
+
last_assistant_message: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
13
|
+
}, z.core.$loose>;
|
|
14
|
+
export declare const ompToolResultPayloadSchema: z.ZodMiniObject<{
|
|
15
|
+
toolName: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
16
|
+
toolCallId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
17
|
+
input: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
18
|
+
content: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
19
|
+
reason: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
20
|
+
message: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
21
|
+
last_assistant_message: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
22
|
+
}, z.core.$loose>;
|
|
23
|
+
export declare const ompSessionStartPayloadSchema: z.ZodMiniObject<{
|
|
24
|
+
toolName: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
25
|
+
toolCallId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
26
|
+
input: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
27
|
+
content: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
28
|
+
reason: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
29
|
+
message: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
30
|
+
last_assistant_message: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
31
|
+
}, z.core.$loose>;
|
|
32
|
+
export declare const ompSessionCompactPayloadSchema: z.ZodMiniObject<{
|
|
33
|
+
toolName: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
34
|
+
toolCallId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
35
|
+
input: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
36
|
+
content: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
37
|
+
reason: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
38
|
+
message: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
39
|
+
last_assistant_message: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
40
|
+
}, z.core.$loose>;
|
|
41
|
+
export declare const ompSessionStopPayloadSchema: z.ZodMiniObject<{
|
|
42
|
+
toolName: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
43
|
+
toolCallId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
44
|
+
input: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
45
|
+
content: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
46
|
+
reason: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
47
|
+
message: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
48
|
+
last_assistant_message: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
49
|
+
}, z.core.$loose>;
|
|
50
|
+
export type OmpPayload = z.infer<typeof ompPayloadSchema>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod/mini';
|
|
2
|
+
export const ompSettingsFileSchema = z.looseObject({
|
|
3
|
+
extensions: z.optional(z.array(z.string())),
|
|
4
|
+
});
|
|
5
|
+
export const ompPayloadSchema = z.looseObject({
|
|
6
|
+
toolName: z.optional(z.string()),
|
|
7
|
+
toolCallId: z.optional(z.string()),
|
|
8
|
+
input: z.optional(z.unknown()),
|
|
9
|
+
content: z.optional(z.unknown()),
|
|
10
|
+
reason: z.optional(z.string()),
|
|
11
|
+
message: z.optional(z.unknown()),
|
|
12
|
+
last_assistant_message: z.optional(z.unknown()),
|
|
13
|
+
});
|
|
14
|
+
export const ompToolResultPayloadSchema = ompPayloadSchema;
|
|
15
|
+
export const ompSessionStartPayloadSchema = ompPayloadSchema;
|
|
16
|
+
export const ompSessionCompactPayloadSchema = ompPayloadSchema;
|
|
17
|
+
export const ompSessionStopPayloadSchema = ompPayloadSchema;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BenchmarkFixture, HarnessAdapter, HarnessContext } from '../../../core/contracts/adapter.js';
|
|
2
|
+
import type { DiagnosticFinding } from '../../../core/contracts/diagnostics.js';
|
|
3
|
+
import { type CapabilityProfile, type DetectionEvidence, type VersionProbe } from '../../../core/contracts/harness.js';
|
|
4
|
+
export declare class OpenCodeAdapter implements HarnessAdapter {
|
|
5
|
+
readonly id = "opencode";
|
|
6
|
+
readonly executionModel: "in_process";
|
|
7
|
+
capabilityProfile(version?: VersionProbe): CapabilityProfile;
|
|
8
|
+
detect(context: HarnessContext): Promise<readonly DetectionEvidence[]>;
|
|
9
|
+
probeVersion(context: HarnessContext): Promise<VersionProbe>;
|
|
10
|
+
planInstall(context: HarnessContext): Promise<import("../../../core/contracts/adapter.js").AdapterPlan>;
|
|
11
|
+
planRemove(context: HarnessContext): Promise<import("../../../core/contracts/adapter.js").AdapterPlan>;
|
|
12
|
+
diagnose(context: HarnessContext): Promise<readonly DiagnosticFinding[]>;
|
|
13
|
+
benchmarkFixture(): BenchmarkFixture;
|
|
14
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import {} from '../../../core/contracts/harness.js';
|
|
4
|
+
import { deriveSupportProfile } from '../../../core/services/support-service.js';
|
|
5
|
+
import { validateJsonDocument } from '../../storage/json-validator.js';
|
|
6
|
+
import { createIntegrationMissingFinding, createInvalidConfigFinding } from '../common/diagnostic-helpers.js';
|
|
7
|
+
import { pathExists } from '../common/path-helpers.js';
|
|
8
|
+
import { probeExecutableVersion } from '../common/version-probes.js';
|
|
9
|
+
import { detectOpenCode, OPENCODE_EXECUTABLES } from './detector.js';
|
|
10
|
+
import { OPENCODE_CAPABILITIES } from './capabilities.js';
|
|
11
|
+
import { OPENCODE_PLUGIN_FILE, planOpenCodeInstall, planOpenCodeRemove } from './planner.js';
|
|
12
|
+
export class OpenCodeAdapter {
|
|
13
|
+
id = 'opencode';
|
|
14
|
+
executionModel = 'in_process';
|
|
15
|
+
capabilityProfile(version) {
|
|
16
|
+
return deriveSupportProfile({ harness: this.id, capabilities: OPENCODE_CAPABILITIES, version });
|
|
17
|
+
}
|
|
18
|
+
detect(context) {
|
|
19
|
+
return detectOpenCode(context.projectRoot, context.userHome);
|
|
20
|
+
}
|
|
21
|
+
probeVersion(context) {
|
|
22
|
+
return probeExecutableVersion(context.runner, OPENCODE_EXECUTABLES);
|
|
23
|
+
}
|
|
24
|
+
planInstall(context) {
|
|
25
|
+
return planOpenCodeInstall(context.projectRoot);
|
|
26
|
+
}
|
|
27
|
+
planRemove(context) {
|
|
28
|
+
return planOpenCodeRemove(context.projectRoot);
|
|
29
|
+
}
|
|
30
|
+
async diagnose(context) {
|
|
31
|
+
const findings = [];
|
|
32
|
+
const pluginPath = resolve(context.projectRoot, OPENCODE_PLUGIN_FILE);
|
|
33
|
+
const jsonPath = resolve(context.projectRoot, 'opencode.json');
|
|
34
|
+
if (!(await pathExists(pluginPath))) {
|
|
35
|
+
findings.push(createIntegrationMissingFinding(this.id, OPENCODE_PLUGIN_FILE));
|
|
36
|
+
}
|
|
37
|
+
if (await pathExists(jsonPath)) {
|
|
38
|
+
try {
|
|
39
|
+
const raw = await readFile(jsonPath, 'utf8');
|
|
40
|
+
const validation = validateJsonDocument(raw);
|
|
41
|
+
if (!validation.valid) {
|
|
42
|
+
findings.push(createInvalidConfigFinding(this.id, 'opencode.json', validation.errors.join('; ')));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
47
|
+
findings.push(createInvalidConfigFinding(this.id, 'opencode.json', msg));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return findings;
|
|
51
|
+
}
|
|
52
|
+
benchmarkFixture() {
|
|
53
|
+
return {
|
|
54
|
+
harness: this.id,
|
|
55
|
+
executionModel: 'in_process',
|
|
56
|
+
event: 'tool.execute.after',
|
|
57
|
+
targetMilliseconds: 15,
|
|
58
|
+
samplePayload: {
|
|
59
|
+
input: { tool: 'bash', sessionID: 'bench-opencode', callID: 'call_bench' },
|
|
60
|
+
output: { args: { command: 'ls' }, output: 'file.txt' },
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const OPENCODE_CAPABILITIES = [
|
|
2
|
+
{ id: 'post_tool_telemetry', state: 'unsupported', impact: 'Model visibility of post-tool output modification is unconfirmed in OpenCode.' },
|
|
3
|
+
{ id: 'session_boot', state: 'unsupported', impact: 'Stable boot injection is experimental in OpenCode.' },
|
|
4
|
+
{ id: 'context_usage', state: 'unsupported', impact: 'No documented API exposes context usage to OpenCode plugins.' },
|
|
5
|
+
{ id: 'auto_restart', state: 'unsupported', impact: 'No restart: this harness cannot inject the resume instruction.' },
|
|
6
|
+
];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DetectionEvidence } from '../../../core/contracts/harness.js';
|
|
2
|
+
export declare const OPENCODE_PROJECT_FILES: readonly ["opencode.json", "opencode.jsonc"];
|
|
3
|
+
export declare const OPENCODE_PROJECT_DIRS: readonly [".opencode"];
|
|
4
|
+
export declare const OPENCODE_USER_FILES: readonly [".config/opencode/plugins", ".config/opencode/opencode.json"];
|
|
5
|
+
export declare const OPENCODE_EXECUTABLES: readonly ["opencode"];
|
|
6
|
+
export declare function detectOpenCode(projectRoot: string, userHome?: string): Promise<readonly DetectionEvidence[]>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { checkProjectEvidence, checkUserEvidence } from '../common/path-helpers.js';
|
|
2
|
+
export const OPENCODE_PROJECT_FILES = [
|
|
3
|
+
'opencode.json',
|
|
4
|
+
'opencode.jsonc',
|
|
5
|
+
];
|
|
6
|
+
export const OPENCODE_PROJECT_DIRS = ['.opencode'];
|
|
7
|
+
export const OPENCODE_USER_FILES = [
|
|
8
|
+
'.config/opencode/plugins',
|
|
9
|
+
'.config/opencode/opencode.json',
|
|
10
|
+
];
|
|
11
|
+
export const OPENCODE_EXECUTABLES = ['opencode'];
|
|
12
|
+
export async function detectOpenCode(projectRoot, userHome) {
|
|
13
|
+
const project = await checkProjectEvidence(projectRoot, OPENCODE_PROJECT_FILES, OPENCODE_PROJECT_DIRS);
|
|
14
|
+
const machine = await checkUserEvidence(OPENCODE_USER_FILES, userHome);
|
|
15
|
+
return [...project, ...machine];
|
|
16
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RuntimeEvent, SessionKey } from '../../../core/contracts/runtime.js';
|
|
2
|
+
export declare function mapOpenCodeToolResult(input: unknown, output: unknown, session: SessionKey): RuntimeEvent;
|
|
3
|
+
export declare function openCodeObservedCharacters(output: unknown): number;
|
|
4
|
+
export type OpenCodeSessionEvent = {
|
|
5
|
+
readonly type: 'session.created' | 'session.compacted';
|
|
6
|
+
readonly sessionId: string | null;
|
|
7
|
+
};
|
|
8
|
+
export declare function mapOpenCodeSessionEvent(payload: unknown): OpenCodeSessionEvent | null;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { asRecord, characterLength, parsePayload, textValue } from '../common/runtime-support.js';
|
|
2
|
+
import { opencodeEventPayloadSchema, opencodeToolAfterOutputSchema, opencodeToolExecuteInputSchema } from './schemas.js';
|
|
3
|
+
const SHELL_TOOLS = ['bash'];
|
|
4
|
+
const WRITE_TOOLS = ['write', 'edit'];
|
|
5
|
+
const READ_TOOLS = ['read'];
|
|
6
|
+
function toolOf(name, args) {
|
|
7
|
+
const tool = name ?? 'unknown';
|
|
8
|
+
const record = asRecord(args);
|
|
9
|
+
if (SHELL_TOOLS.includes(tool))
|
|
10
|
+
return { name: tool, category: 'shell', paths: [], command: textValue(record?.['command']) };
|
|
11
|
+
const path = textValue(record?.['filePath']);
|
|
12
|
+
if (path === null)
|
|
13
|
+
return { name: tool, category: 'other', paths: [], command: null };
|
|
14
|
+
if (WRITE_TOOLS.includes(tool))
|
|
15
|
+
return { name: tool, category: 'file_write', paths: [path], command: null };
|
|
16
|
+
if (READ_TOOLS.includes(tool))
|
|
17
|
+
return { name: tool, category: 'file_read', paths: [path], command: null };
|
|
18
|
+
return { name: tool, category: 'other', paths: [], command: null };
|
|
19
|
+
}
|
|
20
|
+
export function mapOpenCodeToolResult(input, output, session) {
|
|
21
|
+
const data = parsePayload(opencodeToolExecuteInputSchema, input);
|
|
22
|
+
const args = parsePayload(opencodeToolAfterOutputSchema, output ?? {}).args;
|
|
23
|
+
return { kind: 'post_tool', session, tool: toolOf(data.tool, args), toolUseId: data.callID ?? null };
|
|
24
|
+
}
|
|
25
|
+
export function openCodeObservedCharacters(output) {
|
|
26
|
+
return characterLength(parsePayload(opencodeToolAfterOutputSchema, output ?? {}).args);
|
|
27
|
+
}
|
|
28
|
+
export function mapOpenCodeSessionEvent(payload) {
|
|
29
|
+
const data = parsePayload(opencodeEventPayloadSchema, payload);
|
|
30
|
+
const type = data.event?.type;
|
|
31
|
+
if (type !== 'session.created' && type !== 'session.compacted')
|
|
32
|
+
return null;
|
|
33
|
+
const properties = data.event?.properties;
|
|
34
|
+
const sessionId = textValue(properties?.sessionID) ?? textValue(properties?.sessionId) ?? textValue(properties?.info?.id) ?? textValue(properties?.id);
|
|
35
|
+
return { type, sessionId };
|
|
36
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AdapterPlan } from '../../../core/contracts/adapter.js';
|
|
2
|
+
import type { ManagedEntry } from '../../../core/contracts/manifest.js';
|
|
3
|
+
export declare const OPENCODE_PLUGIN_FILE = ".opencode/plugins/context-brake.js";
|
|
4
|
+
export declare function buildOpenCodeEntries(): ManagedEntry[];
|
|
5
|
+
export declare function planOpenCodeInstall(projectRoot: string): Promise<AdapterPlan>;
|
|
6
|
+
export declare function planOpenCodeRemove(projectRoot: string): Promise<AdapterPlan>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { resolveChangeTarget } from '../common/change-target.js';
|
|
2
|
+
import { loadRuntimeAsset } from '../common/runtime-assets.js';
|
|
3
|
+
export const OPENCODE_PLUGIN_FILE = '.opencode/plugins/context-brake.js';
|
|
4
|
+
export function buildOpenCodeEntries() {
|
|
5
|
+
return [
|
|
6
|
+
{ harness: 'opencode', path: OPENCODE_PLUGIN_FILE, identity: `plugin|${OPENCODE_PLUGIN_FILE}` },
|
|
7
|
+
];
|
|
8
|
+
}
|
|
9
|
+
export async function planOpenCodeInstall(projectRoot) {
|
|
10
|
+
const realPlugin = await resolveChangeTarget(projectRoot, OPENCODE_PLUGIN_FILE);
|
|
11
|
+
const content = await loadRuntimeAsset('opencode-plugin.js');
|
|
12
|
+
const changes = [
|
|
13
|
+
{ path: OPENCODE_PLUGIN_FILE, realPath: realPlugin, kind: 'create', owner: 'runtime_asset', content, preview: { summary: 'Install OpenCode plugin' } },
|
|
14
|
+
];
|
|
15
|
+
return { harness: 'opencode', changes, conflicts: [], entries: buildOpenCodeEntries() };
|
|
16
|
+
}
|
|
17
|
+
export async function planOpenCodeRemove(projectRoot) {
|
|
18
|
+
const realPlugin = await resolveChangeTarget(projectRoot, OPENCODE_PLUGIN_FILE);
|
|
19
|
+
const changes = [
|
|
20
|
+
{ path: OPENCODE_PLUGIN_FILE, realPath: realPlugin, kind: 'delete', owner: 'runtime_asset', content: null, preview: { summary: 'Delete OpenCode plugin' } },
|
|
21
|
+
];
|
|
22
|
+
return { harness: 'opencode', changes, conflicts: [], entries: buildOpenCodeEntries() };
|
|
23
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RuntimeDescriptor } from '../../../core/contracts/runtime.js';
|
|
2
|
+
import { type InProcessRuntimeResolver } from '../common/in-process-support.js';
|
|
3
|
+
export { mapOpenCodeSessionEvent, mapOpenCodeToolResult, openCodeObservedCharacters } from './events.js';
|
|
4
|
+
export declare const openCodeDescriptor: RuntimeDescriptor;
|
|
5
|
+
export type OpenCodePluginHooks = {
|
|
6
|
+
readonly 'tool.execute.after'?: (input: unknown, output: unknown) => Promise<void>;
|
|
7
|
+
readonly event?: (payload: unknown) => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
export type OpenCodeHandlerInput = {
|
|
10
|
+
readonly input: unknown;
|
|
11
|
+
readonly output: unknown;
|
|
12
|
+
readonly projectRoot: string;
|
|
13
|
+
readonly resolver: InProcessRuntimeResolver;
|
|
14
|
+
};
|
|
15
|
+
export type OpenCodeEventHandlerInput = {
|
|
16
|
+
readonly payload: unknown;
|
|
17
|
+
readonly projectRoot: string;
|
|
18
|
+
readonly resolver: InProcessRuntimeResolver;
|
|
19
|
+
};
|
|
20
|
+
export declare function createOpenCodePlugin(context?: unknown): OpenCodePluginHooks;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createRuntimeResolver, runInProcessEvent } from '../common/in-process-support.js';
|
|
2
|
+
import { asRecord, parsePayload, textValue } from '../common/runtime-support.js';
|
|
3
|
+
import { OPENCODE_CAPABILITIES } from './capabilities.js';
|
|
4
|
+
import { mapOpenCodeSessionEvent, mapOpenCodeToolResult, openCodeObservedCharacters } from './events.js';
|
|
5
|
+
import { opencodeToolExecuteInputSchema } from './schemas.js';
|
|
6
|
+
export { mapOpenCodeSessionEvent, mapOpenCodeToolResult, openCodeObservedCharacters } from './events.js';
|
|
7
|
+
const HARNESS = 'opencode';
|
|
8
|
+
const ESTIMATION = { baselineTokens: 15000, tokensPerTurn: 150 };
|
|
9
|
+
const FALLBACK_SESSION_ID = 'project';
|
|
10
|
+
export const openCodeDescriptor = { harness: HARNESS, capabilities: OPENCODE_CAPABILITIES, estimation: ESTIMATION, newSessionCommand: null };
|
|
11
|
+
function resolveProjectRoot(context) {
|
|
12
|
+
const record = asRecord(context);
|
|
13
|
+
return textValue(record?.['directory']) ?? textValue(record?.['worktree']) ?? process.cwd();
|
|
14
|
+
}
|
|
15
|
+
function sessionKeyOf(input, fallbackSessionId) {
|
|
16
|
+
const data = parsePayload(opencodeToolExecuteInputSchema, input);
|
|
17
|
+
return { harness: HARNESS, sessionId: textValue(data.sessionID) ?? textValue(data.sessionId) ?? fallbackSessionId ?? FALLBACK_SESSION_ID, agentId: null };
|
|
18
|
+
}
|
|
19
|
+
async function handleAfter(args) {
|
|
20
|
+
let event;
|
|
21
|
+
try {
|
|
22
|
+
event = mapOpenCodeToolResult(args.input, args.output, sessionKeyOf(args.input, null));
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const engineInput = { observedCharacters: openCodeObservedCharacters(args.output) };
|
|
28
|
+
await runInProcessEvent({ resolver: args.resolver, projectRoot: args.projectRoot, event, engineInput });
|
|
29
|
+
}
|
|
30
|
+
async function handleEvent(args) {
|
|
31
|
+
let mapped;
|
|
32
|
+
try {
|
|
33
|
+
mapped = mapOpenCodeSessionEvent(args.payload);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (mapped === null)
|
|
39
|
+
return;
|
|
40
|
+
const reason = mapped.type === 'session.created' ? 'new' : 'compact';
|
|
41
|
+
const event = { kind: 'session_reset', session: sessionKeyOf({}, mapped.sessionId), reason };
|
|
42
|
+
await runInProcessEvent({ resolver: args.resolver, projectRoot: args.projectRoot, event });
|
|
43
|
+
}
|
|
44
|
+
export function createOpenCodePlugin(context) {
|
|
45
|
+
const resolver = createRuntimeResolver(openCodeDescriptor);
|
|
46
|
+
const projectRoot = resolveProjectRoot(context);
|
|
47
|
+
return {
|
|
48
|
+
'tool.execute.after': (input, output) => handleAfter({ input, output, projectRoot, resolver }),
|
|
49
|
+
event: (payload) => handleEvent({ payload, projectRoot, resolver }),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod/mini';
|
|
2
|
+
export declare const opencodeConfigFileSchema: z.ZodMiniObject<{
|
|
3
|
+
plugin: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
4
|
+
}, z.core.$loose>;
|
|
5
|
+
export declare const opencodeToolExecuteInputSchema: z.ZodMiniObject<{
|
|
6
|
+
tool: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
7
|
+
sessionID: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
8
|
+
sessionId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
9
|
+
callID: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
10
|
+
}, z.core.$loose>;
|
|
11
|
+
export declare const opencodeToolAfterOutputSchema: z.ZodMiniObject<{
|
|
12
|
+
args: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
13
|
+
output: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
14
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
15
|
+
metadata: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
16
|
+
}, z.core.$loose>;
|
|
17
|
+
export declare const opencodeSessionPropertiesSchema: z.ZodMiniObject<{
|
|
18
|
+
sessionID: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
19
|
+
sessionId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
20
|
+
id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
21
|
+
info: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
22
|
+
id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
23
|
+
}, z.core.$loose>>;
|
|
24
|
+
}, z.core.$loose>;
|
|
25
|
+
export declare const opencodeEventPayloadSchema: z.ZodMiniObject<{
|
|
26
|
+
event: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
27
|
+
type: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
28
|
+
properties: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
29
|
+
sessionID: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
30
|
+
sessionId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
31
|
+
id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
32
|
+
info: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
33
|
+
id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
34
|
+
}, z.core.$loose>>;
|
|
35
|
+
}, z.core.$loose>>;
|
|
36
|
+
}, z.core.$loose>>;
|
|
37
|
+
}, z.core.$loose>;
|
|
38
|
+
export declare const opencodeToolExecuteAfterPayloadSchema: z.ZodMiniObject<{
|
|
39
|
+
input: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
40
|
+
tool: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
41
|
+
sessionID: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
42
|
+
sessionId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
43
|
+
callID: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
44
|
+
}, z.core.$loose>>;
|
|
45
|
+
output: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
46
|
+
args: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
47
|
+
output: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
48
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
49
|
+
metadata: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
50
|
+
}, z.core.$loose>>;
|
|
51
|
+
}, z.core.$loose>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from 'zod/mini';
|
|
2
|
+
export const opencodeConfigFileSchema = z.looseObject({
|
|
3
|
+
plugin: z.optional(z.array(z.string())),
|
|
4
|
+
});
|
|
5
|
+
export const opencodeToolExecuteInputSchema = z.looseObject({
|
|
6
|
+
tool: z.optional(z.string()),
|
|
7
|
+
sessionID: z.optional(z.string()),
|
|
8
|
+
sessionId: z.optional(z.string()),
|
|
9
|
+
callID: z.optional(z.string()),
|
|
10
|
+
});
|
|
11
|
+
export const opencodeToolAfterOutputSchema = z.looseObject({
|
|
12
|
+
args: z.optional(z.unknown()),
|
|
13
|
+
output: z.optional(z.unknown()),
|
|
14
|
+
title: z.optional(z.string()),
|
|
15
|
+
metadata: z.optional(z.unknown()),
|
|
16
|
+
});
|
|
17
|
+
export const opencodeSessionPropertiesSchema = z.looseObject({
|
|
18
|
+
sessionID: z.optional(z.string()),
|
|
19
|
+
sessionId: z.optional(z.string()),
|
|
20
|
+
id: z.optional(z.string()),
|
|
21
|
+
info: z.optional(z.looseObject({ id: z.optional(z.string()) })),
|
|
22
|
+
});
|
|
23
|
+
export const opencodeEventPayloadSchema = z.looseObject({
|
|
24
|
+
event: z.optional(z.looseObject({
|
|
25
|
+
type: z.optional(z.string()),
|
|
26
|
+
properties: z.optional(opencodeSessionPropertiesSchema),
|
|
27
|
+
})),
|
|
28
|
+
});
|
|
29
|
+
export const opencodeToolExecuteAfterPayloadSchema = z.looseObject({
|
|
30
|
+
input: z.optional(opencodeToolExecuteInputSchema),
|
|
31
|
+
output: z.optional(opencodeToolAfterOutputSchema),
|
|
32
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BenchmarkFixture, HarnessAdapter, HarnessContext } from '../../../core/contracts/adapter.js';
|
|
2
|
+
import type { DiagnosticFinding } from '../../../core/contracts/diagnostics.js';
|
|
3
|
+
import { type CapabilityProfile, type DetectionEvidence, type VersionProbe } from '../../../core/contracts/harness.js';
|
|
4
|
+
export declare class PiAdapter implements HarnessAdapter {
|
|
5
|
+
readonly id = "pi";
|
|
6
|
+
readonly executionModel: "in_process";
|
|
7
|
+
capabilityProfile(version?: VersionProbe): CapabilityProfile;
|
|
8
|
+
detect(context: HarnessContext): Promise<readonly DetectionEvidence[]>;
|
|
9
|
+
probeVersion(context: HarnessContext): Promise<VersionProbe>;
|
|
10
|
+
planInstall(context: HarnessContext): Promise<import("../../../core/contracts/adapter.js").AdapterPlan>;
|
|
11
|
+
planRemove(context: HarnessContext): Promise<import("../../../core/contracts/adapter.js").AdapterPlan>;
|
|
12
|
+
diagnose(context: HarnessContext): Promise<readonly DiagnosticFinding[]>;
|
|
13
|
+
benchmarkFixture(): BenchmarkFixture;
|
|
14
|
+
}
|