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,39 @@
|
|
|
1
|
+
import { z } from 'zod/mini';
|
|
2
|
+
export declare const cursorHookCommandSchema: z.ZodMiniObject<{
|
|
3
|
+
command: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
4
|
+
failClosed: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
5
|
+
}, z.core.$loose>;
|
|
6
|
+
export declare const cursorHooksFileSchema: z.ZodMiniObject<{
|
|
7
|
+
version: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
8
|
+
hooks: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniObject<{
|
|
9
|
+
command: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
10
|
+
failClosed: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
11
|
+
}, z.core.$loose>>>>;
|
|
12
|
+
}, z.core.$loose>;
|
|
13
|
+
export declare const cursorPayloadSchema: z.ZodMiniObject<{
|
|
14
|
+
conversation_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
15
|
+
session_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
16
|
+
tool_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
17
|
+
tool_input: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
18
|
+
tool_output: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
19
|
+
tool_use_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
20
|
+
trigger: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
21
|
+
context_usage_percent: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
22
|
+
context_tokens: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
23
|
+
context_window_size: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
24
|
+
is_first_compaction: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
25
|
+
}, z.core.$loose>;
|
|
26
|
+
export declare const cursorPostToolUsePayloadSchema: z.ZodMiniObject<{
|
|
27
|
+
conversation_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
28
|
+
session_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
29
|
+
tool_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
30
|
+
tool_input: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
31
|
+
tool_output: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
32
|
+
tool_use_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
33
|
+
trigger: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
34
|
+
context_usage_percent: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
35
|
+
context_tokens: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
36
|
+
context_window_size: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
37
|
+
is_first_compaction: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
38
|
+
}, z.core.$loose>;
|
|
39
|
+
export type CursorPayload = z.infer<typeof cursorPayloadSchema>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod/mini';
|
|
2
|
+
export const cursorHookCommandSchema = z.looseObject({
|
|
3
|
+
command: z.optional(z.string()),
|
|
4
|
+
failClosed: z.optional(z.boolean()),
|
|
5
|
+
});
|
|
6
|
+
export const cursorHooksFileSchema = z.looseObject({
|
|
7
|
+
version: z.optional(z.number()),
|
|
8
|
+
hooks: z.optional(z.record(z.string(), z.array(cursorHookCommandSchema))),
|
|
9
|
+
});
|
|
10
|
+
export const cursorPayloadSchema = z.looseObject({
|
|
11
|
+
conversation_id: z.optional(z.string()),
|
|
12
|
+
session_id: z.optional(z.string()),
|
|
13
|
+
tool_name: z.optional(z.string()),
|
|
14
|
+
tool_input: z.optional(z.unknown()),
|
|
15
|
+
tool_output: z.optional(z.unknown()),
|
|
16
|
+
tool_use_id: z.optional(z.string()),
|
|
17
|
+
trigger: z.optional(z.string()),
|
|
18
|
+
context_usage_percent: z.optional(z.number()),
|
|
19
|
+
context_tokens: z.optional(z.number()),
|
|
20
|
+
context_window_size: z.optional(z.number()),
|
|
21
|
+
is_first_compaction: z.optional(z.boolean()),
|
|
22
|
+
});
|
|
23
|
+
export const cursorPostToolUsePayloadSchema = cursorPayloadSchema;
|
|
@@ -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, DetectionEvidence, VersionProbe } from '../../../core/contracts/harness.js';
|
|
4
|
+
export declare class CopilotAdapter implements HarnessAdapter {
|
|
5
|
+
readonly id = "github-copilot-cli";
|
|
6
|
+
readonly executionModel: "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,69 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { deriveSupportProfile } from '../../../core/services/support-service.js';
|
|
4
|
+
import { validateJsonDocument } from '../../storage/json-validator.js';
|
|
5
|
+
import { createAssetMissingFinding, createIntegrationMissingFinding, createInvalidConfigFinding } from '../common/diagnostic-helpers.js';
|
|
6
|
+
import { pathExists } from '../common/path-helpers.js';
|
|
7
|
+
import { probeExecutableVersion } from '../common/version-probes.js';
|
|
8
|
+
import { COPILOT_CAPABILITIES } from './capabilities.js';
|
|
9
|
+
import { COPILOT_EXECUTABLES, detectCopilot } from './detector.js';
|
|
10
|
+
import { COPILOT_CONFIG_FILE, COPILOT_HOOK_FILE, planCopilotInstall, planCopilotRemove } from './planner.js';
|
|
11
|
+
export class CopilotAdapter {
|
|
12
|
+
id = 'github-copilot-cli';
|
|
13
|
+
executionModel = 'process';
|
|
14
|
+
capabilityProfile(version) {
|
|
15
|
+
return deriveSupportProfile({ harness: this.id, capabilities: COPILOT_CAPABILITIES, version });
|
|
16
|
+
}
|
|
17
|
+
detect(context) {
|
|
18
|
+
return detectCopilot(context.projectRoot, context.userHome);
|
|
19
|
+
}
|
|
20
|
+
probeVersion(context) {
|
|
21
|
+
return probeExecutableVersion(context.runner, COPILOT_EXECUTABLES);
|
|
22
|
+
}
|
|
23
|
+
planInstall(context) {
|
|
24
|
+
return planCopilotInstall(context.projectRoot);
|
|
25
|
+
}
|
|
26
|
+
planRemove(context) {
|
|
27
|
+
return planCopilotRemove(context.projectRoot);
|
|
28
|
+
}
|
|
29
|
+
async diagnose(context) {
|
|
30
|
+
const findings = [];
|
|
31
|
+
const configPath = resolve(context.projectRoot, COPILOT_CONFIG_FILE);
|
|
32
|
+
const hookPath = resolve(context.projectRoot, COPILOT_HOOK_FILE);
|
|
33
|
+
if (!(await pathExists(configPath))) {
|
|
34
|
+
findings.push(createIntegrationMissingFinding(this.id, COPILOT_CONFIG_FILE));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
try {
|
|
38
|
+
const raw = await readFile(configPath, 'utf8');
|
|
39
|
+
const validation = validateJsonDocument(raw);
|
|
40
|
+
if (!validation.valid) {
|
|
41
|
+
findings.push(createInvalidConfigFinding(this.id, COPILOT_CONFIG_FILE, validation.errors.join('; ')));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
46
|
+
findings.push(createInvalidConfigFinding(this.id, COPILOT_CONFIG_FILE, msg));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (!(await pathExists(hookPath)))
|
|
50
|
+
findings.push(createAssetMissingFinding(this.id, COPILOT_HOOK_FILE));
|
|
51
|
+
return findings;
|
|
52
|
+
}
|
|
53
|
+
benchmarkFixture() {
|
|
54
|
+
return {
|
|
55
|
+
harness: this.id,
|
|
56
|
+
executionModel: 'process',
|
|
57
|
+
event: 'postToolUse',
|
|
58
|
+
targetMilliseconds: 100,
|
|
59
|
+
samplePayload: {
|
|
60
|
+
sessionId: 'bench-copilot',
|
|
61
|
+
timestamp: 0,
|
|
62
|
+
cwd: '/repo',
|
|
63
|
+
toolName: 'bash',
|
|
64
|
+
toolArgs: { command: 'ls' },
|
|
65
|
+
toolResult: { resultType: 'success', textResultForLlm: 'file.txt' },
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const COPILOT_CAPABILITIES = [
|
|
2
|
+
{ id: 'post_tool_telemetry', state: 'supported' },
|
|
3
|
+
{ id: 'session_boot', state: 'supported' },
|
|
4
|
+
{ id: 'context_usage', state: 'unsupported', impact: 'Context usage is not exposed to GitHub Copilot CLI hooks.' },
|
|
5
|
+
{ id: 'auto_restart', state: 'unsupported', impact: 'Semi-automatic restart: start a new session; it resumes by itself.' },
|
|
6
|
+
];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DetectionEvidence } from '../../../core/contracts/harness.js';
|
|
2
|
+
export declare const COPILOT_PROJECT_FILES: readonly [".github/copilot/settings.json", ".github/copilot/settings.local.json", ".github/hooks/context-brake.json", "copilot-instructions.md"];
|
|
3
|
+
export declare const COPILOT_PROJECT_DIRS: readonly [".github/copilot", ".github/hooks"];
|
|
4
|
+
export declare const COPILOT_USER_FILES: readonly [".copilot/settings.json"];
|
|
5
|
+
export declare const COPILOT_EXECUTABLES: readonly ["copilot"];
|
|
6
|
+
export declare function detectCopilot(projectRoot: string, userHome?: string): Promise<readonly DetectionEvidence[]>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { checkProjectEvidence, checkUserEvidence } from '../common/path-helpers.js';
|
|
2
|
+
export const COPILOT_PROJECT_FILES = [
|
|
3
|
+
'.github/copilot/settings.json',
|
|
4
|
+
'.github/copilot/settings.local.json',
|
|
5
|
+
'.github/hooks/context-brake.json',
|
|
6
|
+
'copilot-instructions.md',
|
|
7
|
+
];
|
|
8
|
+
export const COPILOT_PROJECT_DIRS = ['.github/copilot', '.github/hooks'];
|
|
9
|
+
export const COPILOT_USER_FILES = ['.copilot/settings.json'];
|
|
10
|
+
export const COPILOT_EXECUTABLES = ['copilot'];
|
|
11
|
+
export async function detectCopilot(projectRoot, userHome) {
|
|
12
|
+
const project = await checkProjectEvidence(projectRoot, COPILOT_PROJECT_FILES, COPILOT_PROJECT_DIRS);
|
|
13
|
+
const machine = await checkUserEvidence(COPILOT_USER_FILES, userHome);
|
|
14
|
+
return [...project, ...machine];
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AdapterPlan } from '../../../core/contracts/adapter.js';
|
|
2
|
+
import type { ManagedEntry } from '../../../core/contracts/manifest.js';
|
|
3
|
+
export declare const COPILOT_CONFIG_FILE = ".github/hooks/context-brake.json";
|
|
4
|
+
export declare const COPILOT_HOOK_FILE = ".github/hooks/context-brake.mjs";
|
|
5
|
+
export declare function buildCopilotEntries(): ManagedEntry[];
|
|
6
|
+
export declare function planCopilotInstall(projectRoot: string): Promise<AdapterPlan>;
|
|
7
|
+
export declare function planCopilotRemove(projectRoot: string): Promise<AdapterPlan>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { validateJsonDocument } from '../../storage/json-validator.js';
|
|
3
|
+
import { resolveChangeTarget } from '../common/change-target.js';
|
|
4
|
+
import { loadRuntimeAsset } from '../common/runtime-assets.js';
|
|
5
|
+
export const COPILOT_CONFIG_FILE = '.github/hooks/context-brake.json';
|
|
6
|
+
export const COPILOT_HOOK_FILE = '.github/hooks/context-brake.mjs';
|
|
7
|
+
const REPOSITORY_ROOT = '.';
|
|
8
|
+
function buildHookEntry(event) {
|
|
9
|
+
return {
|
|
10
|
+
type: 'command',
|
|
11
|
+
exec: 'node',
|
|
12
|
+
args: [COPILOT_HOOK_FILE, event],
|
|
13
|
+
cwd: REPOSITORY_ROOT,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function buildCopilotEntries() {
|
|
17
|
+
return [
|
|
18
|
+
{ harness: 'github-copilot-cli', path: COPILOT_CONFIG_FILE, identity: `postToolUse|${COPILOT_HOOK_FILE}` },
|
|
19
|
+
{ harness: 'github-copilot-cli', path: COPILOT_CONFIG_FILE, identity: `sessionStart|${COPILOT_HOOK_FILE}` },
|
|
20
|
+
{ harness: 'github-copilot-cli', path: COPILOT_CONFIG_FILE, identity: `preCompact|${COPILOT_HOOK_FILE}` },
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
function buildConfigFile() {
|
|
24
|
+
const content = {
|
|
25
|
+
version: 1,
|
|
26
|
+
hooks: {
|
|
27
|
+
postToolUse: [buildHookEntry('postToolUse')],
|
|
28
|
+
sessionStart: [buildHookEntry('sessionStart')],
|
|
29
|
+
preCompact: [buildHookEntry('preCompact')],
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
return `${JSON.stringify(content, null, 2)}\n`;
|
|
33
|
+
}
|
|
34
|
+
export async function planCopilotInstall(projectRoot) {
|
|
35
|
+
const realConfig = await resolveChangeTarget(projectRoot, COPILOT_CONFIG_FILE);
|
|
36
|
+
try {
|
|
37
|
+
const raw = await readFile(realConfig, 'utf8');
|
|
38
|
+
const validation = validateJsonDocument(raw);
|
|
39
|
+
if (!validation.valid) {
|
|
40
|
+
const detail = validation.errors.join('; ');
|
|
41
|
+
return { harness: 'github-copilot-cli', changes: [], conflicts: [{ path: COPILOT_CONFIG_FILE, code: 'INVALID_HARNESS_CONFIG', detail }], entries: [] };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
if (error.code !== 'ENOENT') {
|
|
46
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
47
|
+
return { harness: 'github-copilot-cli', changes: [], conflicts: [{ path: COPILOT_CONFIG_FILE, code: 'INVALID_HARNESS_CONFIG', detail: msg }], entries: [] };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const assetContent = await loadRuntimeAsset('github-copilot-cli-hook.mjs');
|
|
51
|
+
const realHook = await resolveChangeTarget(projectRoot, COPILOT_HOOK_FILE);
|
|
52
|
+
const changes = [
|
|
53
|
+
{ path: COPILOT_CONFIG_FILE, realPath: realConfig, kind: 'create', owner: 'harness_entry', content: buildConfigFile(), preview: { summary: 'Create Copilot hooks config' } },
|
|
54
|
+
{ path: COPILOT_HOOK_FILE, realPath: realHook, kind: 'create', owner: 'runtime_asset', content: assetContent, preview: { summary: 'Install ContextBrake hook script' } },
|
|
55
|
+
];
|
|
56
|
+
return { harness: 'github-copilot-cli', changes, conflicts: [], entries: buildCopilotEntries() };
|
|
57
|
+
}
|
|
58
|
+
export async function planCopilotRemove(projectRoot) {
|
|
59
|
+
const realConfig = await resolveChangeTarget(projectRoot, COPILOT_CONFIG_FILE);
|
|
60
|
+
const realHook = await resolveChangeTarget(projectRoot, COPILOT_HOOK_FILE);
|
|
61
|
+
const changes = [
|
|
62
|
+
{ path: COPILOT_CONFIG_FILE, realPath: realConfig, kind: 'delete', owner: 'harness_entry', content: null, preview: { summary: 'Delete Copilot hooks config' } },
|
|
63
|
+
{ path: COPILOT_HOOK_FILE, realPath: realHook, kind: 'delete', owner: 'runtime_asset', content: null, preview: { summary: 'Delete ContextBrake hook script' } },
|
|
64
|
+
];
|
|
65
|
+
return { harness: 'github-copilot-cli', changes, conflicts: [], entries: buildCopilotEntries() };
|
|
66
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RuntimeDecision, RuntimeDescriptor, RuntimeEvent } from '../../../core/contracts/runtime.js';
|
|
2
|
+
import type { RuntimeInput } from '../../../core/services/brake-engine.js';
|
|
3
|
+
import { type ProcessHarnessAdapter } from '../../runtime/process-hook-host.js';
|
|
4
|
+
export declare const copilotDescriptor: RuntimeDescriptor;
|
|
5
|
+
export declare function mapCopilotEvent(eventName: string, payload: unknown): RuntimeEvent | null;
|
|
6
|
+
export declare function mapCopilotInput(eventName: string, payload: unknown): RuntimeInput;
|
|
7
|
+
export declare function renderCopilotDecision(decision: RuntimeDecision): string | null;
|
|
8
|
+
export declare const copilotAdapter: ProcessHarnessAdapter;
|
|
9
|
+
export declare function runCopilotHook(): Promise<number>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { asRecord, assetProjectRoot, characterLength, parsePayload, requireIdentifier, textValue } from '../common/runtime-support.js';
|
|
2
|
+
import { runProcessHook } from '../../runtime/process-hook-host.js';
|
|
3
|
+
import { COPILOT_CAPABILITIES } from './capabilities.js';
|
|
4
|
+
import { copilotPayloadSchema } from './schemas.js';
|
|
5
|
+
const HARNESS = 'github-copilot-cli';
|
|
6
|
+
const ESTIMATION = { baselineTokens: 15000, tokensPerTurn: 150 };
|
|
7
|
+
const READ_TOOLS = ['view'];
|
|
8
|
+
const WRITE_TOOLS = ['edit', 'create'];
|
|
9
|
+
const SHELL_TOOLS = ['bash', 'powershell'];
|
|
10
|
+
export const copilotDescriptor = { harness: HARNESS, capabilities: COPILOT_CAPABILITIES, estimation: ESTIMATION, newSessionCommand: null };
|
|
11
|
+
function sessionOf(payload) {
|
|
12
|
+
return { harness: HARNESS, sessionId: requireIdentifier(payload.sessionId), agentId: null };
|
|
13
|
+
}
|
|
14
|
+
function resultCharacters(payload) {
|
|
15
|
+
const result = asRecord(payload.toolResult);
|
|
16
|
+
return characterLength(result?.['textResultForLlm'] ?? payload.toolResult);
|
|
17
|
+
}
|
|
18
|
+
function toolOf(payload) {
|
|
19
|
+
const name = payload.toolName ?? 'unknown';
|
|
20
|
+
const input = asRecord(payload.toolArgs);
|
|
21
|
+
if (SHELL_TOOLS.includes(name))
|
|
22
|
+
return { name, category: 'shell', paths: [], command: textValue(input?.['command']) };
|
|
23
|
+
const path = textValue(input?.['path']);
|
|
24
|
+
if (path === null)
|
|
25
|
+
return { name, category: 'other', paths: [], command: null };
|
|
26
|
+
if (WRITE_TOOLS.includes(name))
|
|
27
|
+
return { name, category: 'file_write', paths: [path], command: null };
|
|
28
|
+
if (READ_TOOLS.includes(name))
|
|
29
|
+
return { name, category: 'file_read', paths: [path], command: null };
|
|
30
|
+
return { name, category: 'other', paths: [], command: null };
|
|
31
|
+
}
|
|
32
|
+
function resetEvent(session, source) {
|
|
33
|
+
if (source === 'startup' || source === 'new')
|
|
34
|
+
return { kind: 'session_reset', session, reason: 'new' };
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
export function mapCopilotEvent(eventName, payload) {
|
|
38
|
+
const data = parsePayload(copilotPayloadSchema, payload);
|
|
39
|
+
const session = sessionOf(data);
|
|
40
|
+
switch (eventName) {
|
|
41
|
+
case 'postToolUse': return { kind: 'post_tool', session, tool: toolOf(data), toolUseId: null };
|
|
42
|
+
case 'sessionStart': return resetEvent(session, data.source ?? null);
|
|
43
|
+
case 'preCompact': return { kind: 'session_reset', session, reason: 'compact' };
|
|
44
|
+
default: return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function mapCopilotInput(eventName, payload) {
|
|
48
|
+
if (eventName !== 'postToolUse')
|
|
49
|
+
return {};
|
|
50
|
+
const data = parsePayload(copilotPayloadSchema, payload);
|
|
51
|
+
return { observedCharacters: characterLength(data.toolArgs) + resultCharacters(data) };
|
|
52
|
+
}
|
|
53
|
+
export function renderCopilotDecision(decision) {
|
|
54
|
+
if (decision.kind === 'context')
|
|
55
|
+
return JSON.stringify({ additionalContext: decision.block });
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
export const copilotAdapter = {
|
|
59
|
+
descriptor: copilotDescriptor,
|
|
60
|
+
mapEvent: mapCopilotEvent,
|
|
61
|
+
mapInput: mapCopilotInput,
|
|
62
|
+
renderDecision: renderCopilotDecision,
|
|
63
|
+
resolveProjectRoot: async () => await assetProjectRoot(),
|
|
64
|
+
};
|
|
65
|
+
export function runCopilotHook() {
|
|
66
|
+
return runProcessHook(copilotAdapter);
|
|
67
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod/mini';
|
|
2
|
+
export declare const copilotHookItemSchema: z.ZodMiniObject<{
|
|
3
|
+
type: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
4
|
+
exec: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
5
|
+
args: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
6
|
+
command: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
7
|
+
cwd: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
8
|
+
}, z.core.$loose>;
|
|
9
|
+
export declare const copilotHooksFileSchema: z.ZodMiniObject<{
|
|
10
|
+
version: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
11
|
+
hooks: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniObject<{
|
|
12
|
+
type: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
13
|
+
exec: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
14
|
+
args: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
15
|
+
command: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
16
|
+
cwd: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
17
|
+
}, z.core.$loose>>>>;
|
|
18
|
+
}, z.core.$loose>;
|
|
19
|
+
export declare const copilotPayloadSchema: z.ZodMiniObject<{
|
|
20
|
+
sessionId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
21
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
22
|
+
toolName: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
23
|
+
toolArgs: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
24
|
+
toolResult: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
25
|
+
hookName: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
26
|
+
}, z.core.$loose>;
|
|
27
|
+
export declare const copilotPostToolUsePayloadSchema: z.ZodMiniObject<{
|
|
28
|
+
sessionId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
29
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
30
|
+
toolName: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
31
|
+
toolArgs: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
32
|
+
toolResult: z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
33
|
+
hookName: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
34
|
+
}, z.core.$loose>;
|
|
35
|
+
export type CopilotPayload = z.infer<typeof copilotPayloadSchema>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from 'zod/mini';
|
|
2
|
+
export const copilotHookItemSchema = z.looseObject({
|
|
3
|
+
type: z.optional(z.string()),
|
|
4
|
+
exec: z.optional(z.string()),
|
|
5
|
+
args: z.optional(z.array(z.string())),
|
|
6
|
+
command: z.optional(z.string()),
|
|
7
|
+
cwd: z.optional(z.string()),
|
|
8
|
+
});
|
|
9
|
+
export const copilotHooksFileSchema = z.looseObject({
|
|
10
|
+
version: z.optional(z.number()),
|
|
11
|
+
hooks: z.optional(z.record(z.string(), z.array(copilotHookItemSchema))),
|
|
12
|
+
});
|
|
13
|
+
export const copilotPayloadSchema = z.looseObject({
|
|
14
|
+
sessionId: z.optional(z.string()),
|
|
15
|
+
source: z.optional(z.string()),
|
|
16
|
+
toolName: z.optional(z.string()),
|
|
17
|
+
toolArgs: z.optional(z.unknown()),
|
|
18
|
+
toolResult: z.optional(z.unknown()),
|
|
19
|
+
hookName: z.optional(z.string()),
|
|
20
|
+
});
|
|
21
|
+
export const copilotPostToolUsePayloadSchema = copilotPayloadSchema;
|
|
@@ -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 OhMyPiAdapter implements HarnessAdapter {
|
|
5
|
+
readonly id = "oh-my-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
|
+
}
|
|
@@ -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 { detectOmp, OMP_EXECUTABLES } from './detector.js';
|
|
10
|
+
import { OMP_CAPABILITIES } from './capabilities.js';
|
|
11
|
+
import { diagnoseInProcessRestart } from '../common/restart-diagnostics.js';
|
|
12
|
+
import { harnessRestartMode } from '../../../core/services/restart-install-extras.js';
|
|
13
|
+
import { OMP_EXTENSION_FILE, OMP_RESTART_FILE, planOmpInstall, planOmpRemove } from './planner.js';
|
|
14
|
+
export class OhMyPiAdapter {
|
|
15
|
+
id = 'oh-my-pi';
|
|
16
|
+
executionModel = 'in_process';
|
|
17
|
+
capabilityProfile(version) {
|
|
18
|
+
return deriveSupportProfile({ harness: this.id, capabilities: OMP_CAPABILITIES, version });
|
|
19
|
+
}
|
|
20
|
+
detect(context) {
|
|
21
|
+
return detectOmp(context.projectRoot, context.userHome);
|
|
22
|
+
}
|
|
23
|
+
probeVersion(context) {
|
|
24
|
+
return probeExecutableVersion(context.runner, OMP_EXECUTABLES);
|
|
25
|
+
}
|
|
26
|
+
planInstall(context) {
|
|
27
|
+
return planOmpInstall(context);
|
|
28
|
+
}
|
|
29
|
+
planRemove(context) {
|
|
30
|
+
return planOmpRemove(context);
|
|
31
|
+
}
|
|
32
|
+
async diagnose(context) {
|
|
33
|
+
const findings = [];
|
|
34
|
+
const extensionPath = resolve(context.projectRoot, OMP_EXTENSION_FILE);
|
|
35
|
+
const settingsPath = resolve(context.projectRoot, '.omp/settings.json');
|
|
36
|
+
if (!(await pathExists(extensionPath))) {
|
|
37
|
+
findings.push(createIntegrationMissingFinding(this.id, OMP_EXTENSION_FILE));
|
|
38
|
+
}
|
|
39
|
+
if (await pathExists(settingsPath)) {
|
|
40
|
+
try {
|
|
41
|
+
const raw = await readFile(settingsPath, 'utf8');
|
|
42
|
+
const validation = validateJsonDocument(raw);
|
|
43
|
+
if (!validation.valid) {
|
|
44
|
+
findings.push(createInvalidConfigFinding(this.id, '.omp/settings.json', validation.errors.join('; ')));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
49
|
+
findings.push(createInvalidConfigFinding(this.id, '.omp/settings.json', msg));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
findings.push(...await diagnoseInProcessRestart(context, { harness: this.id, label: 'Oh-My-Pi', restartFile: OMP_RESTART_FILE, modeText: harnessRestartMode(this.capabilityProfile()).reason }));
|
|
53
|
+
return findings;
|
|
54
|
+
}
|
|
55
|
+
benchmarkFixture() {
|
|
56
|
+
return {
|
|
57
|
+
harness: this.id,
|
|
58
|
+
executionModel: 'in_process',
|
|
59
|
+
event: 'tool_result',
|
|
60
|
+
targetMilliseconds: 15,
|
|
61
|
+
samplePayload: { toolName: 'read', toolCallId: 'call_bench', input: { path: 'file.txt' }, content: [{ type: 'text', text: 'file.txt' }] },
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const OMP_CAPABILITIES = [
|
|
2
|
+
{ id: 'post_tool_telemetry', state: 'supported' },
|
|
3
|
+
{ id: 'session_boot', state: 'supported' },
|
|
4
|
+
{ id: 'context_usage', state: 'supported' },
|
|
5
|
+
{ id: 'auto_restart', state: 'unsupported', impact: 'Semi-automatic restart: press Enter on the prefilled /context-brake-restart; the new session resumes by itself.' },
|
|
6
|
+
];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DetectionEvidence } from '../../../core/contracts/harness.js';
|
|
2
|
+
export declare const OMP_PROJECT_FILES: readonly [".omp/config.yml", ".omp/settings.json"];
|
|
3
|
+
export declare const OMP_PROJECT_DIRS: readonly [".omp/extensions", ".omp"];
|
|
4
|
+
export declare const OMP_USER_FILES: readonly [".omp/agent/extensions", ".omp/settings.json"];
|
|
5
|
+
export declare const OMP_EXECUTABLES: readonly ["omp"];
|
|
6
|
+
export declare function detectOmp(projectRoot: string, userHome?: string): Promise<readonly DetectionEvidence[]>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { checkProjectEvidence, checkUserEvidence } from '../common/path-helpers.js';
|
|
2
|
+
export const OMP_PROJECT_FILES = [
|
|
3
|
+
'.omp/config.yml',
|
|
4
|
+
'.omp/settings.json',
|
|
5
|
+
];
|
|
6
|
+
export const OMP_PROJECT_DIRS = ['.omp/extensions', '.omp'];
|
|
7
|
+
export const OMP_USER_FILES = ['.omp/agent/extensions', '.omp/settings.json'];
|
|
8
|
+
export const OMP_EXECUTABLES = ['omp'];
|
|
9
|
+
export async function detectOmp(projectRoot, userHome) {
|
|
10
|
+
const project = await checkProjectEvidence(projectRoot, OMP_PROJECT_FILES, OMP_PROJECT_DIRS);
|
|
11
|
+
const machine = await checkUserEvidence(OMP_USER_FILES, userHome);
|
|
12
|
+
return [...project, ...machine];
|
|
13
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RuntimeEvent, SessionKey } from '../../../core/contracts/runtime.js';
|
|
2
|
+
import type { RuntimeInput } from '../../../core/services/brake-engine.js';
|
|
3
|
+
export declare function stopMessageText(message: unknown): string;
|
|
4
|
+
export declare function mapOmpEvent(eventName: string, payload: unknown, session: SessionKey): RuntimeEvent | null;
|
|
5
|
+
export declare function mapOmpInput(eventName: string, payload: unknown): RuntimeInput;
|
|
6
|
+
export declare function renderOmpToolResult(payload: unknown, block: string): {
|
|
7
|
+
content: unknown[];
|
|
8
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { asRecord, characterLength, parsePayload, textValue } from '../common/runtime-support.js';
|
|
2
|
+
import { ompPayloadSchema } from './schemas.js';
|
|
3
|
+
const SHELL_TOOLS = ['bash', 'run_command'];
|
|
4
|
+
const WRITE_TOOLS = ['write', 'edit'];
|
|
5
|
+
const READ_TOOLS = ['read'];
|
|
6
|
+
function toolOf(name, input) {
|
|
7
|
+
const tool = name ?? 'unknown';
|
|
8
|
+
const args = asRecord(input);
|
|
9
|
+
if (SHELL_TOOLS.includes(tool))
|
|
10
|
+
return { name: tool, category: 'shell', paths: [], command: textValue(args?.['command']) };
|
|
11
|
+
const path = textValue(args?.['path']);
|
|
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
|
+
function assistantText(message) {
|
|
21
|
+
const record = asRecord(message);
|
|
22
|
+
if (record?.['role'] !== 'assistant')
|
|
23
|
+
return '';
|
|
24
|
+
const content = record['content'];
|
|
25
|
+
if (typeof content === 'string')
|
|
26
|
+
return content;
|
|
27
|
+
if (!Array.isArray(content))
|
|
28
|
+
return '';
|
|
29
|
+
return content.flatMap((part) => {
|
|
30
|
+
const entry = asRecord(part);
|
|
31
|
+
return entry?.['type'] === 'text' && typeof entry['text'] === 'string' ? [entry['text']] : [];
|
|
32
|
+
}).join('\n');
|
|
33
|
+
}
|
|
34
|
+
export function stopMessageText(message) {
|
|
35
|
+
return typeof message === 'string' ? message : assistantText(message);
|
|
36
|
+
}
|
|
37
|
+
function resetOf(session, reason) {
|
|
38
|
+
if (reason === 'new' || reason === 'startup')
|
|
39
|
+
return { kind: 'session_reset', session, reason: 'new' };
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
export function mapOmpEvent(eventName, payload, session) {
|
|
43
|
+
const data = parsePayload(ompPayloadSchema, payload);
|
|
44
|
+
switch (eventName) {
|
|
45
|
+
case 'tool_result': return { kind: 'post_tool', session, tool: toolOf(data.toolName, data.input), toolUseId: data.toolCallId ?? null };
|
|
46
|
+
case 'session_start':
|
|
47
|
+
case 'session_switch': return resetOf(session, data.reason);
|
|
48
|
+
case 'session_compact':
|
|
49
|
+
case 'auto_compaction_end': return { kind: 'session_reset', session, reason: 'compact' };
|
|
50
|
+
case 'session_stop': return { kind: 'response_end', session, text: stopMessageText(data.last_assistant_message) };
|
|
51
|
+
case 'message_end': return asRecord(data.message)?.['role'] === 'assistant' ? { kind: 'response_end', session, text: assistantText(data.message) } : null;
|
|
52
|
+
default: return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function mapOmpInput(eventName, payload) {
|
|
56
|
+
if (eventName !== 'tool_result')
|
|
57
|
+
return {};
|
|
58
|
+
const data = parsePayload(ompPayloadSchema, payload);
|
|
59
|
+
return { observedCharacters: characterLength(data.input) + characterLength(data.content) };
|
|
60
|
+
}
|
|
61
|
+
export function renderOmpToolResult(payload, block) {
|
|
62
|
+
const data = parsePayload(ompPayloadSchema, payload);
|
|
63
|
+
const parts = Array.isArray(data.content) ? [...data.content] : typeof data.content === 'string' ? [{ type: 'text', text: data.content }] : [];
|
|
64
|
+
return { content: [...parts, { type: 'text', text: block }] };
|
|
65
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AdapterPlan, HarnessContext } from '../../../core/contracts/adapter.js';
|
|
2
|
+
import type { ManagedEntry } from '../../../core/contracts/manifest.js';
|
|
3
|
+
export declare const OMP_EXTENSION_FILE = ".omp/extensions/context-brake.js";
|
|
4
|
+
export declare function buildOmpEntries(): ManagedEntry[];
|
|
5
|
+
export declare const OMP_RESTART_FILE = ".omp/extensions/context-brake-restart.js";
|
|
6
|
+
export declare function planOmpInstall(context: HarnessContext): Promise<AdapterPlan>;
|
|
7
|
+
export declare function planOmpRemove(context: HarnessContext): Promise<AdapterPlan>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { resolveChangeTarget } from '../common/change-target.js';
|
|
2
|
+
import { mergeRestartPlan, planRestartAsset, planRestartRemoval } from '../common/restart-asset-plan.js';
|
|
3
|
+
import { loadRuntimeAsset } from '../common/runtime-assets.js';
|
|
4
|
+
export const OMP_EXTENSION_FILE = '.omp/extensions/context-brake.js';
|
|
5
|
+
export function buildOmpEntries() {
|
|
6
|
+
return [
|
|
7
|
+
{ harness: 'oh-my-pi', path: OMP_EXTENSION_FILE, identity: `extension|${OMP_EXTENSION_FILE}` },
|
|
8
|
+
];
|
|
9
|
+
}
|
|
10
|
+
export const OMP_RESTART_FILE = '.omp/extensions/context-brake-restart.js';
|
|
11
|
+
const RESTART_SPEC = { harness: 'oh-my-pi', path: OMP_RESTART_FILE, asset: 'omp-restart.js' };
|
|
12
|
+
export async function planOmpInstall(context) {
|
|
13
|
+
return mergeRestartPlan(await planBaseInstall(context.projectRoot), await planRestartAsset(context, RESTART_SPEC));
|
|
14
|
+
}
|
|
15
|
+
export async function planOmpRemove(context) {
|
|
16
|
+
return mergeRestartPlan(await planBaseRemove(context.projectRoot), await planRestartRemoval(context, RESTART_SPEC));
|
|
17
|
+
}
|
|
18
|
+
async function planBaseInstall(projectRoot) {
|
|
19
|
+
const realExt = await resolveChangeTarget(projectRoot, OMP_EXTENSION_FILE);
|
|
20
|
+
const content = await loadRuntimeAsset('omp-extension.js');
|
|
21
|
+
const changes = [
|
|
22
|
+
{ path: OMP_EXTENSION_FILE, realPath: realExt, kind: 'create', owner: 'runtime_asset', content, preview: { summary: 'Install Oh-My-Pi extension' } },
|
|
23
|
+
];
|
|
24
|
+
return { harness: 'oh-my-pi', changes, conflicts: [], entries: buildOmpEntries() };
|
|
25
|
+
}
|
|
26
|
+
async function planBaseRemove(projectRoot) {
|
|
27
|
+
const realExt = await resolveChangeTarget(projectRoot, OMP_EXTENSION_FILE);
|
|
28
|
+
const changes = [
|
|
29
|
+
{ path: OMP_EXTENSION_FILE, realPath: realExt, kind: 'delete', owner: 'runtime_asset', content: null, preview: { summary: 'Delete Oh-My-Pi extension' } },
|
|
30
|
+
];
|
|
31
|
+
return { harness: 'oh-my-pi', changes, conflicts: [], entries: buildOmpEntries() };
|
|
32
|
+
}
|