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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Douglas Cunha
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,362 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ContextBrake ๐
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.typescriptlang.org/)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
[](https://github.com/context-brake/context-brake)
|
|
7
|
+
|
|
8
|
+
> **Context telemetry and an advisory brake for coding agents.**
|
|
9
|
+
> Show the agent how full its context window is, and at the zone you choose, ask it to run your snapshot command and request a fresh session.
|
|
10
|
+
|
|
11
|
+
> [!NOTE]
|
|
12
|
+
> ContextBrake has one mode: zone telemetry with an optional snapshot command and resume command. It never blocks a tool call. Installation and diagnostics, measured usage in Claude Code, the status line bridge, debug mode, and automatic restart in Claude Code are implemented. CI runs on Linux, macOS, and Windows. Commands and configuration below reflect the current CLI.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## ๐ก The Problem
|
|
17
|
+
|
|
18
|
+
Long-horizon tasks run by coding agents degrade as the session grows:
|
|
19
|
+
|
|
20
|
+
1. **Context bloat:** tool outputs such as build logs, test runs, and file reads pile up in the context window.
|
|
21
|
+
2. **Attention decay:** as the window fills, instructions and constraints buried in the middle of the context are followed less reliably.
|
|
22
|
+
3. **Repeated cost:** every turn re-sends the accumulated history.
|
|
23
|
+
4. **No sense of budget:** the model cannot see how much context it has used or how many tools it has called, so it often keeps going until the session is cut off without saving progress.
|
|
24
|
+
|
|
25
|
+
## ๐ก๏ธ The Solution
|
|
26
|
+
|
|
27
|
+
ContextBrake plugs into the extension mechanism each harness already documents, hooks or plugins, and adds:
|
|
28
|
+
|
|
29
|
+
- ๐ **Detection and setup:** `context-brake init` finds the harnesses a project uses, registers the integration in each one's own configuration, and reports the support level it can guarantee. It writes only its configuration, its manifest, and the harness integration, plus one marked block in the project `.gitignore` that keeps those files out of Git; it never edits instruction files.
|
|
30
|
+
- ๐ฆ **Telemetry:** as soon as the session leaves `GREEN`, or context usage reaches the activation threshold, tool results reach the agent with the session turn, context usage (measured by the harness or estimated), zone, and recommended action.
|
|
31
|
+
- ๐ช **Advisory brake:** from the trigger zone on, the action names your snapshot command, such as a skill that saves the session's state, and asks the agent to end its reply with `[REQUEST_SESSION_RESET]`. Without a snapshot command, the action only tells the agent to wrap up. Tool calls always run.
|
|
32
|
+
- ๐ **Resume:** after `/clear`, `/new`, or compaction, harnesses that inject context at session start tell the new session to run your resume command. In interactive Claude Code, the [automatic restart](#automatic-restart-in-claude-code) can clear the session for you.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## ๐ฆ Zones
|
|
37
|
+
|
|
38
|
+
Zones follow context usage. Default limits:
|
|
39
|
+
|
|
40
|
+
| Zone | Context usage | Action without a snapshot command | Action with `snapshot.command` (default trigger `RED`) |
|
|
41
|
+
| :--- | :--- | :--- | :--- |
|
|
42
|
+
| ๐ข `GREEN` | below 50% | Work normally. No telemetry is injected in the default mode. | Work normally. |
|
|
43
|
+
| ๐ก `YELLOW` | 50% to 65% | Keep working; finish the current unit before large new explorations. | Same, unless the trigger is `YELLOW`: then as in `RED`. |
|
|
44
|
+
| ๐ด `RED` | above 65% | Finish or pause the current unit and tell the user what remains. | Run the snapshot command, then end the reply with `[REQUEST_SESSION_RESET]`. |
|
|
45
|
+
| โ `CRITICAL` | 75% or more | Stop starting new work; tell the user what remains. | Run the snapshot command now, then end the reply with `[REQUEST_SESSION_RESET]`. |
|
|
46
|
+
|
|
47
|
+
A turn is one completed tool call. Turn limits are optional and off by default: with `zones.greenMaxTurn` and `zones.yellowMaxTurn` set, a long session can move up to `RED` by turns, and when several conditions match, the highest zone applies. Turns never reach `CRITICAL`.
|
|
48
|
+
|
|
49
|
+
The block format and the exact action texts are specified in `docs/telemetry-block.md`. To customize the limits, change `telemetry.zones` in `context-brake.config.json`.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## ๐งฉ Supported Harnesses
|
|
54
|
+
|
|
55
|
+
Support levels come from each vendor's documentation, checked in September 2026. **Full** means the harness delivers telemetry alongside tool results and injects context at session start. **Partial** means one of these is missing, indirect, or unconfirmed. ContextBrake never blocks a tool call on any harness: zones only add telemetry and advice.
|
|
56
|
+
|
|
57
|
+
| Harness | Integration point | Support level | Main limitation |
|
|
58
|
+
| :--- | :--- | :--- | :--- |
|
|
59
|
+
| Claude Code (`claude-code`) | Hooks in `.claude/settings.json` | Full | Context usage is read from the session transcript, whose format is undocumented, with an estimate as fallback; the context window comes from the status line bridge, which `init` installs by default |
|
|
60
|
+
| Codex CLI (`codex-cli`) | Hooks in `.codex/hooks.json` | Full | Context usage and window are read from the session rollout file, whose format is undocumented; falls back to an estimate |
|
|
61
|
+
| Cursor (`cursor`) | Hooks in `.cursor/hooks.json` | Full | Context usage is only sent before compaction |
|
|
62
|
+
| GitHub Copilot CLI (`github-copilot-cli`) | Hooks in `.github/hooks/*.json` | Full | Context usage is not exposed to hooks, so ContextBrake estimates it |
|
|
63
|
+
| OpenCode (`opencode`) | Plugins in `.opencode/plugins/` | Partial | Post-tool output visibility and session-start injection are unconfirmed; OpenCode 2.x does not load this plugin format yet |
|
|
64
|
+
| Pi (`pi`) | Extensions in `.pi/extensions/` | Full | Automatic restart runs through an extension command |
|
|
65
|
+
| Oh-My-Pi (`oh-my-pi`) | Extensions in `.omp/extensions/` | Full | Restart takes one Enter on the prefilled `/context-brake-restart` |
|
|
66
|
+
| Antigravity CLI (`antigravity-cli`) | Hooks in `.agents/hooks.json` | Partial | Telemetry is injected through `PreInvocation`, and `PostToolUse` accepts only empty output |
|
|
67
|
+
|
|
68
|
+
Aider is not supported because it has no hook mechanism. The full capability matrix and its sources are in the [installation PRD](./tasks/prd-01-instalacao-deteccao-diagnostico/prd.md).
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## ๐ฆ Installation
|
|
73
|
+
|
|
74
|
+
ContextBrake requires **Node.js 20 or later**. You can run or install it in three ways:
|
|
75
|
+
|
|
76
|
+
### Option 1: Zero-Install via `npx` (Recommended)
|
|
77
|
+
Best for repositories of any tech stack (Python, Rust, Go, TypeScript, etc.) without polluting local dependencies:
|
|
78
|
+
```bash
|
|
79
|
+
npx context-brake init --yes
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Option 2: Global Installation
|
|
83
|
+
Best if you use ContextBrake across multiple repositories and prefer a persistent global CLI:
|
|
84
|
+
```bash
|
|
85
|
+
npm install -g context-brake
|
|
86
|
+
context-brake init --yes
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Option 3: Local Dev Dependency
|
|
90
|
+
Best for Node.js projects where your team wants to lock the exact version in `package.json`:
|
|
91
|
+
```bash
|
|
92
|
+
npm install -D context-brake
|
|
93
|
+
npx context-brake init --yes
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## ๐ Quick Start & Project Setup
|
|
99
|
+
|
|
100
|
+
Reaches an error-free diagnosis within two minutes on any supported repository:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# 1. Preview every planned file change before writing to disk
|
|
104
|
+
npx context-brake init --dry-run
|
|
105
|
+
|
|
106
|
+
# 2. Detect harnesses, register integrations, and initialize configuration
|
|
107
|
+
npx context-brake init --yes
|
|
108
|
+
|
|
109
|
+
# 3. Diagnose integrations, configurations, versions, and overhead
|
|
110
|
+
npx context-brake doctor
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
To have the agent save its state before a reset, pass your snapshot command, and optionally the command that resumes the work in the new session:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
npx context-brake init --yes --snapshot-command "/sdd-snapshot" --resume-command "/sdd-orchestrate-flow"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### What `context-brake init` does:
|
|
120
|
+
|
|
121
|
+
1. **Detects coding-agent harnesses:** Identifies Claude Code, Cursor, Codex CLI, GitHub Copilot CLI, Antigravity CLI, OpenCode, Pi, and Oh-My-Pi from repository signals and machine configuration.
|
|
122
|
+
2. **Registers integrations safely:** Injects the appropriate hooks/plugins in each harness's own configuration, preserving user settings and comments, and installs the [status line bridge](#claude-code-status-line-bridge) for Claude Code.
|
|
123
|
+
3. **Initializes config:** Creates `context-brake.config.json` with the telemetry limits and the `snapshot` section, and records the installed files in `.context-brake/manifest.json`.
|
|
124
|
+
|
|
125
|
+
It does not touch instruction files such as `CLAUDE.md` and `AGENTS.md`. The only change it makes to your `.gitignore` is the marked block described in [Keeping ContextBrake Out of Git](#keeping-contextbrake-out-of-git). Runtime state lives in `.context-brake/runtime/`, which carries its own `.gitignore`.
|
|
126
|
+
|
|
127
|
+
### Interactive Setup
|
|
128
|
+
|
|
129
|
+
Run `context-brake init` in a terminal with no other option and it asks what to configure instead of requiring flags. `init --interactive` starts the same questions on purpose.
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
npx context-brake init
|
|
133
|
+
npx context-brake init --interactive --dry-run
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
- **When it starts:** only when both stdin and stdout are terminals and none of `--yes`, `--json`, or a configuration flag (`--harness`, `--exclude-harness`, any snapshot flag, `--debug`, `--statusline-bridge`, `--auto-restart`, `--max-restarts`, and their `--no-` forms) is given. Scripts, CI, and `--json` runs never see a prompt and behave exactly as before. `--interactive` without a terminal exits with code 64 and names the flags to use instead; combined with `--yes` or `--json` it is an argument error.
|
|
137
|
+
- **Questions, in order:** the harnesses to configure (detected ones are marked with their support level; turning off a detected one excludes it, as `--exclude-harness` does), the snapshot command, its trigger zone and resume command (only when a command is set), restart on or off with the restart mode of each selected harness (only when one can restart), the consecutive-restart limit (only when restart is on), the Claude Code status line bridge (only when Claude Code is selected), and debug mode. Enter keeps the value shown in brackets, which is the current configuration or the default. An invalid answer prints its rule and asks again.
|
|
138
|
+
- **Prompts:** on a terminal the questions use arrow keys, Space to mark, and Enter to confirm (a checkbox list for harnesses, yes or no for the switches, a list for the trigger zone and the restart limit, text fields for the commands). Set `CONTEXT_BRAKE_PLAIN_PROMPTS=1`, or run in a terminal with `TERM=dumb`, to get plain line-by-line questions instead; the questions and the resulting flags are the same.
|
|
139
|
+
- **Summary and equivalent command:** before the plan, the assistant prints what you chose and the `context-brake init ...` command that reproduces it. Values with spaces or shell characters are single-quoted, and a value that contains a single quote is printed once for POSIX shells and once for PowerShell. Add `--yes` to repeat the setup without prompts; a command with no flags means nothing changes and starts the questions again on a terminal.
|
|
140
|
+
- **Confirming and cancelling:** the assistant shows the usual plan and asks the usual single confirmation. Ctrl+C or the end of input at any prompt prints `Nothing was written.` and exits with code 0, like a declined confirmation. With `--dry-run` it shows the plan and writes nothing. Typed configuration flags passed together with `--interactive` are not used; only `--dry-run` is.
|
|
141
|
+
- **Git Bash on Windows:** Git Bash in mintty can report that stdin or stdout is not a terminal. Then a plain `init` keeps its non-interactive behavior and `--interactive` explains that the terminal is not interactive. [docs/research/terminal-tty.md](./docs/research/terminal-tty.md) holds the probe and the results per terminal.
|
|
142
|
+
|
|
143
|
+
### Keeping ContextBrake Out of Git
|
|
144
|
+
|
|
145
|
+
The files `init` creates belong to your machine and `init` can regenerate them, so inside a Git working tree it keeps them out of `git status`: it maintains one marked block in the `.gitignore` at the project root, with one line per file ContextBrake owns in full.
|
|
146
|
+
|
|
147
|
+
```gitignore
|
|
148
|
+
# >>> context-brake (managed by `context-brake init`; do not edit) >>>
|
|
149
|
+
/.context-brake/manifest.json
|
|
150
|
+
/context-brake.config.json
|
|
151
|
+
# <<< context-brake <<<
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
- **What is listed:** the configuration file, the manifest, every asset in the manifest (hook scripts, the Claude Code mod, `.context-brake/.gitignore`), and the state files `init` writes under `.context-brake/runtime/` (`claude-mod-install.json`, `claude-statusline.json`, and `claude-statusline-opt-out.json` when the status line bridge is off). Files `init` only edits, such as `.claude/settings.json` and `.codex/hooks.json`, are never listed, and neither are folders. When a harness folder is a link inside the repository (a symbolic link or a Windows junction), the block lists both the link path and the target path, so Git ignores the file through either path.
|
|
155
|
+
- **Always current:** every `init` rebuilds the list from the manifest, so turning automatic restart or a harness on or off adds or removes the matching lines. Everything outside the markers stays byte for byte as it was, and the block appears in `--dry-run` and `--json` like any other change. If the markers are damaged, `init` reports `GITIGNORE_MARKERS_MALFORMED` and leaves the file alone.
|
|
156
|
+
- **Opting out:** a team that wants to version the configuration and the hooks runs `context-brake init --no-gitignore`. It removes the block, and the choice is stored (`"gitIgnore": false` in the configuration), so a plain `init` keeps it. `init --gitignore` turns it back on. The interactive setup asks the same question.
|
|
157
|
+
- **Files Git already tracks:** an ignore rule does not hide a tracked file. `init` reports `GITIGNORE_TRACKED_FILES` with the exact `git rm --cached -- <files>` command, and never changes the Git index.
|
|
158
|
+
- **Outside Git:** with no `.git` in the project or a parent folder, `init` creates no `.gitignore` and reports `GITIGNORE_NO_GIT`.
|
|
159
|
+
- **Removal:** `context-brake remove` deletes the block and leaves the rest of the file; a `.gitignore` that held only the block is deleted. A file that ended without a line break keeps the one `init` added.
|
|
160
|
+
|
|
161
|
+
### Updating and Removal
|
|
162
|
+
|
|
163
|
+
- **Updating:** Running `npx context-brake init --yes` is idempotent. Run it again after upgrading ContextBrake to refresh runtime assets without touching your custom settings.
|
|
164
|
+
- **Upgrading from turn-based limits:** earlier versions blocked tool calls after 12 turns and wrote `turnCeiling`, `criticalTurn`, `greenMaxTurn`, and `yellowMaxTurn` into the config. Those configs stay valid, but `doctor` reports `LEGACY_TURN_LIMITS`. Run `npx context-brake init --yes` once: it removes `turnCeiling` and `criticalTurn`, removes `greenMaxTurn` and `yellowMaxTurn` when they are the retired defaults 7 and 10, and keeps custom values as optional turn limits.
|
|
165
|
+
- **Upgrading an installation from before the single mode:** the configuration keys `stateStorage`, `instructionFiles`, `brake`, `runner`, and the earlier mode keys are no longer recognized, and `init` and `doctor` report an invalid configuration that names each one. Delete those keys and run `npx context-brake init --yes` again. ContextBrake no longer manages the protocol file, the old `CONTEXTBRAKE` marker blocks in instruction files and `.gitignore` (the current block has different markers), or the plan and checkpoint files, so remove them by hand if you no longer want them.
|
|
166
|
+
- **Downgrading:** a version older than this one rejects the `snapshot` section and expects the keys listed above. Run `context-brake remove` before installing an older package, then run its own `init`.
|
|
167
|
+
- **Diagnostics:** Run `npx context-brake doctor` anytime to verify integration integrity, measure latency overhead, and check version compatibility.
|
|
168
|
+
- **Uninstallation:** Run `npx context-brake remove` to delete the registered hooks, the installed assets, the configuration, the manifest, and the runtime files under `.context-brake/runtime/`. Harness settings you wrote, instruction files, and anything else under `.context-brake/` stay in place, and an installed file you edited is reported instead of deleted.
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## โ๏ธ Configuration
|
|
173
|
+
|
|
174
|
+
`context-brake.config.json` lives at the repository root and conforms to the published JSON Schema:
|
|
175
|
+
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"$schema": "https://unpkg.com/context-brake@1/schemas/context-brake.config.schema.json",
|
|
179
|
+
"schemaVersion": 1,
|
|
180
|
+
"activeHarnesses": ["claude-code"],
|
|
181
|
+
"telemetry": {
|
|
182
|
+
"injectionMode": "threshold_only",
|
|
183
|
+
"activationThresholdPercentage": 50,
|
|
184
|
+
"contextWindowCeiling": 128000,
|
|
185
|
+
"zones": {
|
|
186
|
+
"greenMaxPercentage": 49,
|
|
187
|
+
"yellowMaxPercentage": 65,
|
|
188
|
+
"criticalPercentage": 75
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
"snapshot": {
|
|
192
|
+
"triggerZone": "RED"
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
`contextWindowCeiling` is the session's context budget: when the harness does not report the active model's window, zone percentages are computed against it, and the telemetry block shows `window=config`. A more accurate window comes from the harness (`window=harness`: Pi and Oh-My-Pi, Codex through the session rollout file, and Claude Code through the [status line bridge](#claude-code-status-line-bridge), which `init` installs by default) or, for the harnesses that report none (Cursor, GitHub Copilot, Antigravity, OpenCode), from a window you declare in `telemetry.declaredContextWindow` (`window=declared`). A declared window is ignored by Claude Code, Codex, Pi, and Oh-My-Pi, whose window comes from the harness. The optional `zones.greenMaxTurn` and `zones.yellowMaxTurn` must be set together, with `greenMaxTurn` lower; they raise the zone up to `RED` by turns.
|
|
198
|
+
|
|
199
|
+
### Excluding a Harness
|
|
200
|
+
|
|
201
|
+
`init --exclude-harness <id>` turns a detected harness off for the project: the id moves from `activeHarnesses` to `excludedHarnesses` in `context-brake.config.json`, the harness's hook entries, assets, and manifest entries are deleted, and a later plain `init` keeps it off (`doctor` lists it as `excluded by configuration`). `init --harness <id>` turns it back on. `remove` deletes the configuration, so the exclusion goes with it.
|
|
202
|
+
|
|
203
|
+
### Upgrading From an Earlier Build
|
|
204
|
+
|
|
205
|
+
A configuration that still carries keys ContextBrake no longer reads (for example `stateStorage`, `instructionFiles`, `brake`, `lightMode`, or `runner`) is repaired by `init`: the preview lists every key it will drop, and `--yes` applies it. `doctor` names the keys and the fix, and `remove` ignores them. `init` and `remove` also delete ContextBrake hook entries for events it no longer registers, such as `PreToolUse`, and leave every other hook as it was.
|
|
206
|
+
|
|
207
|
+
### Snapshot and Resume Commands
|
|
208
|
+
|
|
209
|
+
If your workflow saves session state with its own skill or command, as the SDD skills in this repository do, name it in the `snapshot` section:
|
|
210
|
+
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"snapshot": {
|
|
214
|
+
"triggerZone": "RED",
|
|
215
|
+
"command": "/sdd-snapshot",
|
|
216
|
+
"resumeCommand": "/sdd-orchestrate-flow"
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
- **`command`:** from `triggerZone` on (`RED` by default, or `YELLOW`), the telemetry action becomes `run "<command>", then end reply with [REQUEST_SESSION_RESET]`, and in `CRITICAL` it says `now`. ContextBrake never runs the command; it only passes the text to the agent, so the command can be a skill, a slash command, or a short instruction.
|
|
222
|
+
- **`resumeCommand`:** after `/clear`, `/new`, or compaction, harnesses that inject context at session start add `[ContextBrake resume v1] Run "<resumeCommand>" before continuing.` A resume command requires a snapshot command.
|
|
223
|
+
- **Without a command:** the telemetry block only carries the generic actions in the [zone table](#-zones), with no reset request, and nothing is injected at session start.
|
|
224
|
+
|
|
225
|
+
Set them with `init`: `--snapshot-command <text>`, `--resume-command <text>`, and `--snapshot-trigger <YELLOW|RED>`. `--no-snapshot-command` clears both commands and keeps the trigger zone. Each command is one line of at most 200 characters. In Git Bash on Windows, run `MSYS_NO_PATHCONV=1 npx context-brake init ...`, because Git Bash rewrites an argument that starts with `/`, such as `/sdd-snapshot`, into a Windows path. `context-brake doctor` shows the settings in effect, and `doctor --json` reports them under `snapshot`.
|
|
226
|
+
|
|
227
|
+
### Debug Mode
|
|
228
|
+
|
|
229
|
+
To check ContextBrake's usage reading against the real value from the harness (`/context` or the Claude Code status line), turn on debug mode:
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
npx context-brake init --debug
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
This writes `"debug": true` to the configuration and adds one field to every telemetry block:
|
|
236
|
+
|
|
237
|
+
```text
|
|
238
|
+
debug_line="๐ ContextBrake: 42% ยท 53760/128000 (harness) ยท measured ยท GREEN" (end your reply with this line)
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
The agent copies that line instead of composing it. Nothing is written to instruction files.
|
|
242
|
+
|
|
243
|
+
- **Injects on every call:** while debug mode is on, ContextBrake adds the telemetry block to every tool result, in every zone, as if `injectionMode` were `always`. This costs up to 60 tokens per tool call, plus at most 40 more for the debug line. The `injectionMode` saved in the configuration does not change.
|
|
244
|
+
- **Relies on the agent:** the agent prints the line because the block asks it to. ContextBrake does not check that the line was printed.
|
|
245
|
+
|
|
246
|
+
`context-brake doctor` shows `debug mode: on`, and `doctor --json` reports `debugMode: true`. Debug mode does not change the `doctor` status or exit code. To turn it off, run `context-brake init --no-debug`, which drops the field from the next block and the key from the configuration.
|
|
247
|
+
|
|
248
|
+
### Active Sessions in `doctor`
|
|
249
|
+
|
|
250
|
+
`context-brake doctor` lists the repository's active sessions with their current context usage: percentage, tokens, window, zone, and whether the reading was measured or estimated. It also shows the time of each session's last activity. The data comes from the session ledger ContextBrake already keeps under `.context-brake/runtime/sessions/`, using the newest reading after the last reset, from the status line bridge or from the last tool call. ContextBrake cannot tell whether a harness process is still running. A session counts as active when its last recorded activity is within 30 minutes, and at most 10 sessions are listed. `doctor --json` reports them under `activeSessions`, and the list is omitted when no session is active.
|
|
251
|
+
|
|
252
|
+
### Claude Code Status Line Bridge
|
|
253
|
+
|
|
254
|
+
Claude Code sends the active model's context window only to the status line command, never to hooks. The bridge reads it there, so zones in Claude Code use the real window instead of `contextWindowCeiling`. `init` installs it by default. To turn it back on after an opt-out:
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
npx context-brake init --statusline-bridge
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
- **Local scope, per developer:** the option writes `statusLine` into `.claude/settings.local.json`, the local, unversioned settings file, with the absolute path of `.claude/hooks/context-brake-statusline.mjs`, as a single command: `node "<root>/.claude/hooks/context-brake-statusline.mjs"`, with no pipe, subshell, or separator. The versioned `.claude/settings.json` does not change, and a later `init` without the option keeps the bridge. Keep `.claude/settings.local.json` ignored by Git; `doctor` warns when it is not.
|
|
261
|
+
- **Your status line stays the same:** the bridge runs the status line that was in effect before (local, then project, then user settings) itself, with the same input, and prints its output unchanged, keeping `padding` and `refreshInterval`. It uses the shell that launched it: `sh` on macOS and Linux, Git Bash on Windows when the bridge was started by Git Bash, otherwise PowerShell. If you had no status line, it prints nothing. Note that Claude Code hides most footer keyboard hints (such as `esc to interrupt` and `? for shortcuts`) whenever a status line is configured, even an empty one. To keep the footer, opt out with `context-brake init --no-statusline-bridge`: later plain `init` runs remember the choice, and Claude Code zones then use `contextWindowCeiling`.
|
|
262
|
+
- **When the previous line fails:** a previous command that cannot start, exits non-zero, prints nothing, or takes longer than 5 seconds makes the bridge print one line with ContextBrake's own reading and say that `context-brake doctor` explains why, still exiting 0. An installation written by an older version, with the pipeline form of the command, keeps working until the next `init` rewrites it; `doctor` reports it as `STATUSLINE_BRIDGE_OUTDATED`.
|
|
263
|
+
- **Zones on 1M models:** after the status line first runs in a session, the telemetry block shows `tokens=<used>/<window>` with the model's `context_window_size`. With a 1,000,000-token model, `RED` starts above 650,000 tokens, and `contextWindowCeiling` no longer limits Claude Code sessions. After `/model`, the window changes with the next assistant response. When the transcript has no usage reading, the bridge's input tokens are used, following the same reset rule.
|
|
264
|
+
- **Non-interactive sessions:** Claude Code runs the status line only in interactive sessions, so `claude -p` sessions keep using `contextWindowCeiling`, and so do the first tool calls of a new session, before the status line first runs, and Claude Code subagents.
|
|
265
|
+
- **Windows without Git Bash:** Claude Code falls back to PowerShell when it does not find Git Bash. ContextBrake never changes your environment: set `CLAUDE_CODE_GIT_BASH_PATH` to the `bash.exe` of Git for Windows and restart the harness to get the Bash tool back. Until then, `doctor` warns with `STATUSLINE_POWERSHELL_FALLBACK` on Windows, after a bridge run that recorded PowerShell.
|
|
266
|
+
|
|
267
|
+
The bridge records only the window, the input tokens, the used percentage, the model id, the shell that ran it, and the time, per session, in the session ledger. `context-brake doctor` shows where the window comes from under `contextWindow`, warns with `STATUSLINE_BRIDGE_ABSENT` when Claude Code has no bridge, and warns when the local status line no longer runs the bridge, when the script is missing, or when the project or user status line changed after installation. `context-brake init --no-statusline-bridge` or `context-brake remove` restores the previous local status line, or removes the key and the file when the bridge created them.
|
|
268
|
+
|
|
269
|
+
### Automatic Restart in Claude Code
|
|
270
|
+
|
|
271
|
+
When the agent ends a reply with `[REQUEST_SESSION_RESET]`, interactive Claude Code can clear the session and resume by itself, with no keystroke. The feature is off by default; the next section covers the other harnesses:
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
npx context-brake init --auto-restart # turn it on
|
|
275
|
+
npx context-brake init --no-auto-restart # turn it off and remove its files
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
- **How it works:** `init --auto-restart` writes a Claude Code mod (a plugin of function hooks) under `.context-brake/claude-mod/`, registers it for you in `.claude/settings.local.json` (`extraKnownMarketplaces` and `enabledPlugins`), and adds an `autoRestart` block to `context-brake.config.json`. When a turn ends with the signal, the mod shows a one-line notice, queues `/clear`, and sends the new session one short generic seed prompt to resume. Only the signal triggers it, never a zone alone.
|
|
279
|
+
- **Resume text:** the mod trusts the signal and reads no state file. With `snapshot.resumeCommand` set, the new session also receives the resume text from the session start hook.
|
|
280
|
+
- **Loop guards and kill switches:** at most `autoRestart.maxConsecutiveRestarts` restarts (default 2; set it with `init --max-restarts <1-10>`, which needs automatic restart on) without a prompt you typed, and none when no tool call happened since the last seed. `CONTEXT_BRAKE_AUTO_RESTART=0` stands it down for one session; `claude -p` sessions and sessions with `DISABLE_AUTO_COMPACT` set are skipped.
|
|
281
|
+
- **Requirements:** Claude Code 2.1.287 or later, where mods are on by default (verified on 2.1.289, 4 October 2026). Mods stay off under `disableAllHooks`, `--safe-mode`, `--bare`, an organization managed policy, and in Desktop WSL sessions. The first interactive launch asks you to trust the folder.
|
|
282
|
+
- **`doctor`:** reports `AUTO_RESTART_OFF` or `AUTO_RESTART_READY` without a warning, and warns with `AUTO_RESTART_NOT_LOADED` (no session loaded the mod yet, with the causes above), `AUTO_RESTART_OUTDATED_MOD`, or `AUTO_RESTART_CLAUDE_TOO_OLD`. `AUTO_RESTART_LAST_SKIP` names the reason code of the last request that did not restart. The mod records only reason codes and versions, per session, in `.context-brake/runtime/restart/claude-code/`; never prompt, reply, or tool text.
|
|
283
|
+
|
|
284
|
+
`context-brake remove` deletes the mod files, the two settings keys, and the config block; a file you edited inside the mod folder is reported, not deleted.
|
|
285
|
+
|
|
286
|
+
### Restart on Other Harnesses and the Markdown Handoff
|
|
287
|
+
|
|
288
|
+
`init --auto-restart` also sets up every other active harness that can resume:
|
|
289
|
+
|
|
290
|
+
| Harness | Restart |
|
|
291
|
+
| :--- | :--- |
|
|
292
|
+
| Pi | Automatic: an extension opens the new session and seeds it |
|
|
293
|
+
| Oh-My-Pi | One Enter: the editor is prefilled with `/context-brake-restart` |
|
|
294
|
+
| Codex CLI | Semi-automatic: a notice asks for `/new`; the new session resumes by itself |
|
|
295
|
+
| Cursor, GitHub Copilot CLI | Semi-automatic: start a new session; it resumes by itself |
|
|
296
|
+
| OpenCode, Antigravity CLI | Not available: they cannot inject the resume instruction |
|
|
297
|
+
|
|
298
|
+
`init` reports the mode per harness with `AUTO_RESTART_MODE`.
|
|
299
|
+
|
|
300
|
+
Without a snapshot command, automatic restart uses a markdown handoff. From the trigger zone, the action asks the agent to save a handoff to `.context-brake/handoff.md` and end its reply with `[REQUEST_SESSION_RESET]`. An automatic restart needs a handoff written during that turn. The next session start moves it to `.context-brake/handoffs/` (the last 10 are kept) and tells the agent to read it and continue. `init` adds `.context-brake/.gitignore` so handoffs stay out of Git; `remove` keeps them.
|
|
301
|
+
|
|
302
|
+
### Hook Timeouts
|
|
303
|
+
|
|
304
|
+
Each hook call has an internal deadline of 1.5 seconds; the session start event gets 5 seconds. When a deadline elapses, the hook stops waiting, the tool call proceeds, and the failure is recorded in `.context-brake/runtime/errors.jsonl` with the phase that was running (`ledger`, for example) and the elapsed milliseconds. `doctor` lists recent entries.
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## ๐ CLI Commands
|
|
309
|
+
|
|
310
|
+
| Command | Options | Description |
|
|
311
|
+
| :--- | :--- | :--- |
|
|
312
|
+
| `context-brake init` | `--dry-run`, `--yes` (`-y`), `--json`, `--harness <id>`, `--exclude-harness <id>`, `--snapshot-command <text>`, `--snapshot-trigger <YELLOW\|RED>`, `--resume-command <text>`, `--no-snapshot-command`, `--debug`, `--no-debug`, `--statusline-bridge`, `--no-statusline-bridge`, `--auto-restart`, `--no-auto-restart`, `--max-restarts <1-10>`, `--interactive`, `--gitignore`, `--no-gitignore` | Detects harnesses, registers integrations, and creates or updates the configuration and the manifest. `--exclude-harness` turns a harness off persistently and `--harness` turns it back on. In a terminal with no other option, or with `--interactive`, it asks the [setup questions](#interactive-setup). |
|
|
313
|
+
| `context-brake doctor` | `--json`, `--harness <id>` | Inspects integrations, configuration integrity, versions, support levels, missing capabilities, snapshot settings, and active sessions with their context usage, and measures overhead p95. |
|
|
314
|
+
| `context-brake remove` | `--dry-run`, `--yes` (`-y`), `--json` | Uninstalls the integrations and deletes the configuration, the manifest, and the runtime files. |
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## ๐งญ Roadmap
|
|
319
|
+
|
|
320
|
+
| PRD | Scope | Status |
|
|
321
|
+
| :--- | :--- | :--- |
|
|
322
|
+
| [Installation, detection, and diagnostics](./tasks/prd-01-instalacao-deteccao-diagnostico/prd.md) | `init`, `doctor`, `remove`, harness support levels | Implemented |
|
|
323
|
+
| [Installation follow-ups](./tasks/prd-01.1-pendencias-da-instalacao/prd.md) | Capabilities, overhead measurement, manifest, and installed assets | Implemented |
|
|
324
|
+
| [Telemetry, zones, and brake](./tasks/prd-02-telemetria-zonas-e-freio/prd.md) | Turn counting, context measurement, zones | Implemented; the tool-call deny was removed by the single mode |
|
|
325
|
+
| [Brake by measured usage](./tasks/prd-02.1-freio-por-uso-medido/prd.md) | Usage-only `CRITICAL`, optional turn limits, measured usage in Claude Code | Implemented |
|
|
326
|
+
| [Claude Code context window](./tasks/prd-02.2-janela-de-contexto-do-claude-code/prd.md) | Status line bridge | Implemented |
|
|
327
|
+
| [Plan, checkpoint, and boot](./tasks/prd-03-plano-checkpoint-e-boot/prd.md) | State files and boot summary | Superseded by the single mode |
|
|
328
|
+
| [Automatic reset runner](./tasks/prd-04-runner-de-reinicio-automatico/prd.md) | Post-MVP runner | Superseded by the single mode |
|
|
329
|
+
| [Release automation](./tasks/prd-05-automacao-de-release-e-publicacao/prd.md) | Automated release and npm publishing | Implemented |
|
|
330
|
+
| [Delegated snapshot mode](./tasks/prd-06-modo-snapshot-delegado/prd.md) | Snapshot command without a task plan | Superseded by the single mode |
|
|
331
|
+
| [Light mode](./tasks/prd-07-modo-leve/prd.md) | Telemetry only, and active-session usage in `doctor` | Superseded by the single mode |
|
|
332
|
+
| [Debug mode](./tasks/prd-08-modo-debug/prd.md) | Usage line printed by the agent | Implemented |
|
|
333
|
+
| [Brake with a trusted window](./tasks/prd-09-freio-com-janela-confiavel/prd.md) | Window origin and declared window | Implemented |
|
|
334
|
+
| [Status line under PowerShell](./tasks/prd-10-statusline-powershell-e-modo-light/prd.md) | Shell-neutral bridge and debug line | Implemented |
|
|
335
|
+
| [Automatic restart in Claude Code](./tasks/prd-11-reinicio-automatico-no-claude-code/prd.md) | Claude Code mod that clears and resumes the session | Implemented |
|
|
336
|
+
| [Single mode](./tasks/prd-12-refatoracao-modo-leve-modo-unico/prd.md) | One mode with optional snapshot and resume commands, advisory brake | In progress |
|
|
337
|
+
| [Fast test suite](./tasks/prd-13-refatoracao-modo-leve-testes-rapidos/prd.md) | Test budget | Planned |
|
|
338
|
+
| [Restart and handoff across harnesses](./tasks/prd-14-refatoracao-modo-leve-reinicio-multi-harness/prd.md) | Automatic restart and markdown handoff beyond Claude Code | In progress |
|
|
339
|
+
|
|
340
|
+
The PRDs are written in Portuguese, except the later ones.
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
## ๐ค Contributing
|
|
345
|
+
|
|
346
|
+
This project follows Spec-Driven Development. Read [AGENTS.md](./AGENTS.md) and the PRD of the feature you are changing before opening a pull request.
|
|
347
|
+
|
|
348
|
+
Project skills and coding rules live in `.agents/`. Claude Code reads them from `.claude/`, which is git-ignored, so link it once after cloning:
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
# macOS and Linux
|
|
352
|
+
ln -s .agents .claude
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
```powershell
|
|
356
|
+
# Windows (PowerShell, no administrator rights needed)
|
|
357
|
+
New-Item -ItemType Junction -Path .claude -Target .agents
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
## ๐ License
|
|
361
|
+
|
|
362
|
+
[MIT](./LICENSE) ยฉ [Douglas Cunha](https://github.com/dougcunha)
|