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.
Files changed (506) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +361 -2
  3. package/dist/assets/runtime/antigravity-cli-hook.mjs +19174 -0
  4. package/dist/assets/runtime/claude-code-hook.mjs +19302 -0
  5. package/dist/assets/runtime/claude-code-mod.mjs +18579 -0
  6. package/dist/assets/runtime/claude-code-statusline.mjs +18749 -0
  7. package/dist/assets/runtime/codex-cli-hook.mjs +19299 -0
  8. package/dist/assets/runtime/context-brake-runtime.mjs +6 -0
  9. package/dist/assets/runtime/cursor-hook.mjs +19181 -0
  10. package/dist/assets/runtime/github-copilot-cli-hook.mjs +19186 -0
  11. package/dist/assets/runtime/omp-extension.js +19237 -0
  12. package/dist/assets/runtime/omp-restart.js +18763 -0
  13. package/dist/assets/runtime/opencode-plugin.js +19200 -0
  14. package/dist/assets/runtime/pi-extension.js +19228 -0
  15. package/dist/assets/runtime/pi-restart.js +18758 -0
  16. package/dist/src/cli/argument-parser.d.ts +20 -0
  17. package/dist/src/cli/argument-parser.js +45 -0
  18. package/dist/src/cli/argument-validator.d.ts +8 -0
  19. package/dist/src/cli/argument-validator.js +24 -0
  20. package/dist/src/cli/assistant/ask.d.ts +10 -0
  21. package/dist/src/cli/assistant/ask.js +36 -0
  22. package/dist/src/cli/assistant/assistant-context.d.ts +9 -0
  23. package/dist/src/cli/assistant/assistant-context.js +18 -0
  24. package/dist/src/cli/assistant/assistant-questions.d.ts +3 -0
  25. package/dist/src/cli/assistant/assistant-questions.js +26 -0
  26. package/dist/src/cli/assistant/assistant-session.d.ts +5 -0
  27. package/dist/src/cli/assistant/assistant-session.js +25 -0
  28. package/dist/src/cli/assistant/clack-prompt-port.d.ts +14 -0
  29. package/dist/src/cli/assistant/clack-prompt-port.js +47 -0
  30. package/dist/src/cli/assistant/equivalent-command.d.ts +1 -0
  31. package/dist/src/cli/assistant/equivalent-command.js +16 -0
  32. package/dist/src/cli/assistant/prompt-factory.d.ts +3 -0
  33. package/dist/src/cli/assistant/prompt-factory.js +16 -0
  34. package/dist/src/cli/assistant/prompt-port.d.ts +14 -0
  35. package/dist/src/cli/assistant/prompt-port.js +28 -0
  36. package/dist/src/cli/assistant/questions-gitignore.d.ts +7 -0
  37. package/dist/src/cli/assistant/questions-gitignore.js +14 -0
  38. package/dist/src/cli/assistant/questions-harness.d.ts +9 -0
  39. package/dist/src/cli/assistant/questions-harness.js +52 -0
  40. package/dist/src/cli/assistant/questions-misc.d.ts +10 -0
  41. package/dist/src/cli/assistant/questions-misc.js +25 -0
  42. package/dist/src/cli/assistant/questions-restart.d.ts +15 -0
  43. package/dist/src/cli/assistant/questions-restart.js +51 -0
  44. package/dist/src/cli/assistant/questions-snapshot.d.ts +9 -0
  45. package/dist/src/cli/assistant/questions-snapshot.js +64 -0
  46. package/dist/src/cli/assistant/snapshot-specs.d.ts +4 -0
  47. package/dist/src/cli/assistant/snapshot-specs.js +22 -0
  48. package/dist/src/cli/assistant/summary.d.ts +2 -0
  49. package/dist/src/cli/assistant/summary.js +34 -0
  50. package/dist/src/cli/assistant/types.d.ts +37 -0
  51. package/dist/src/cli/assistant/types.js +1 -0
  52. package/dist/src/cli/assistant/ui-prompt.d.ts +29 -0
  53. package/dist/src/cli/assistant/ui-prompt.js +1 -0
  54. package/dist/src/cli/commands/doctor.d.ts +3 -0
  55. package/dist/src/cli/commands/doctor.js +56 -0
  56. package/dist/src/cli/commands/init.d.ts +4 -0
  57. package/dist/src/cli/commands/init.js +26 -0
  58. package/dist/src/cli/commands/remove.d.ts +3 -0
  59. package/dist/src/cli/commands/remove.js +62 -0
  60. package/dist/src/cli/composition-root.d.ts +3 -0
  61. package/dist/src/cli/composition-root.js +62 -0
  62. package/dist/src/cli/confirmation.d.ts +6 -0
  63. package/dist/src/cli/confirmation.js +22 -0
  64. package/dist/src/cli/detection-collector.d.ts +14 -0
  65. package/dist/src/cli/detection-collector.js +31 -0
  66. package/dist/src/cli/exit-codes.d.ts +8 -0
  67. package/dist/src/cli/exit-codes.js +8 -0
  68. package/dist/src/cli/gitignore-findings.d.ts +3 -0
  69. package/dist/src/cli/gitignore-findings.js +11 -0
  70. package/dist/src/cli/handoff-findings.d.ts +5 -0
  71. package/dist/src/cli/handoff-findings.js +15 -0
  72. package/dist/src/cli/init-arguments.d.ts +25 -0
  73. package/dist/src/cli/init-arguments.js +70 -0
  74. package/dist/src/cli/init-config-state.d.ts +14 -0
  75. package/dist/src/cli/init-config-state.js +19 -0
  76. package/dist/src/cli/init-config-updates.d.ts +13 -0
  77. package/dist/src/cli/init-config-updates.js +35 -0
  78. package/dist/src/cli/init-flow.d.ts +14 -0
  79. package/dist/src/cli/init-flow.js +72 -0
  80. package/dist/src/cli/init-option-rules.d.ts +11 -0
  81. package/dist/src/cli/init-option-rules.js +29 -0
  82. package/dist/src/cli/main.d.ts +3 -0
  83. package/dist/src/cli/main.js +62 -0
  84. package/dist/src/cli/output/detection-text.d.ts +2 -0
  85. package/dist/src/cli/output/detection-text.js +3 -0
  86. package/dist/src/cli/output/doctor-mode-text.d.ts +2 -0
  87. package/dist/src/cli/output/doctor-mode-text.js +12 -0
  88. package/dist/src/cli/output/doctor-sessions-text.d.ts +2 -0
  89. package/dist/src/cli/output/doctor-sessions-text.js +12 -0
  90. package/dist/src/cli/output/json.d.ts +1 -0
  91. package/dist/src/cli/output/json.js +3 -0
  92. package/dist/src/cli/output/text.d.ts +5 -0
  93. package/dist/src/cli/output/text.js +68 -0
  94. package/dist/src/cli/snapshot-helper.d.ts +3 -0
  95. package/dist/src/cli/snapshot-helper.js +25 -0
  96. package/dist/src/cli/terminal.d.ts +9 -0
  97. package/dist/src/cli/terminal.js +18 -0
  98. package/dist/src/core/contracts/adapter.d.ts +49 -0
  99. package/dist/src/core/contracts/adapter.js +1 -0
  100. package/dist/src/core/contracts/auto-restart.d.ts +10 -0
  101. package/dist/src/core/contracts/auto-restart.js +10 -0
  102. package/dist/src/core/contracts/changes.d.ts +219 -0
  103. package/dist/src/core/contracts/changes.js +13 -0
  104. package/dist/src/core/contracts/configuration.d.ts +81 -0
  105. package/dist/src/core/contracts/configuration.js +52 -0
  106. package/dist/src/core/contracts/context-window-report.d.ts +16 -0
  107. package/dist/src/core/contracts/context-window-report.js +8 -0
  108. package/dist/src/core/contracts/diagnostics.d.ts +546 -0
  109. package/dist/src/core/contracts/diagnostics.js +35 -0
  110. package/dist/src/core/contracts/handoff.d.ts +10 -0
  111. package/dist/src/core/contracts/handoff.js +3 -0
  112. package/dist/src/core/contracts/harness.d.ts +73 -0
  113. package/dist/src/core/contracts/harness.js +23 -0
  114. package/dist/src/core/contracts/hook-phase.d.ts +12 -0
  115. package/dist/src/core/contracts/hook-phase.js +1 -0
  116. package/dist/src/core/contracts/manifest.d.ts +69 -0
  117. package/dist/src/core/contracts/manifest.js +20 -0
  118. package/dist/src/core/contracts/processes.d.ts +24 -0
  119. package/dist/src/core/contracts/processes.js +1 -0
  120. package/dist/src/core/contracts/restart-host.d.ts +32 -0
  121. package/dist/src/core/contracts/restart-host.js +3 -0
  122. package/dist/src/core/contracts/restart-log.d.ts +52 -0
  123. package/dist/src/core/contracts/restart-log.js +15 -0
  124. package/dist/src/core/contracts/runtime.d.ts +50 -0
  125. package/dist/src/core/contracts/runtime.js +1 -0
  126. package/dist/src/core/contracts/session-ledger.d.ts +144 -0
  127. package/dist/src/core/contracts/session-ledger.js +38 -0
  128. package/dist/src/core/contracts/statusline-line.d.ts +20 -0
  129. package/dist/src/core/contracts/statusline-line.js +13 -0
  130. package/dist/src/core/contracts/zones.d.ts +18 -0
  131. package/dist/src/core/contracts/zones.js +4 -0
  132. package/dist/src/core/services/active-sessions.d.ts +17 -0
  133. package/dist/src/core/services/active-sessions.js +35 -0
  134. package/dist/src/core/services/asset-currency.d.ts +17 -0
  135. package/dist/src/core/services/asset-currency.js +72 -0
  136. package/dist/src/core/services/auto-restart-merge.d.ts +26 -0
  137. package/dist/src/core/services/auto-restart-merge.js +30 -0
  138. package/dist/src/core/services/auto-restart-notices.d.ts +6 -0
  139. package/dist/src/core/services/auto-restart-notices.js +27 -0
  140. package/dist/src/core/services/auto-restart-policy.d.ts +26 -0
  141. package/dist/src/core/services/auto-restart-policy.js +23 -0
  142. package/dist/src/core/services/brake-engine.d.ts +24 -0
  143. package/dist/src/core/services/brake-engine.js +61 -0
  144. package/dist/src/core/services/change-plan-service.d.ts +11 -0
  145. package/dist/src/core/services/change-plan-service.js +60 -0
  146. package/dist/src/core/services/config-legacy-checks.d.ts +6 -0
  147. package/dist/src/core/services/config-legacy-checks.js +28 -0
  148. package/dist/src/core/services/debug-mode-merge.d.ts +25 -0
  149. package/dist/src/core/services/debug-mode-merge.js +21 -0
  150. package/dist/src/core/services/detection-service.d.ts +6 -0
  151. package/dist/src/core/services/detection-service.js +54 -0
  152. package/dist/src/core/services/doctor-checks.d.ts +6 -0
  153. package/dist/src/core/services/doctor-checks.js +24 -0
  154. package/dist/src/core/services/doctor-report-extras.d.ts +11 -0
  155. package/dist/src/core/services/doctor-report-extras.js +23 -0
  156. package/dist/src/core/services/doctor-service.d.ts +24 -0
  157. package/dist/src/core/services/doctor-service.js +82 -0
  158. package/dist/src/core/services/failure-policy.d.ts +38 -0
  159. package/dist/src/core/services/failure-policy.js +63 -0
  160. package/dist/src/core/services/gitignore-block.d.ts +10 -0
  161. package/dist/src/core/services/gitignore-block.js +61 -0
  162. package/dist/src/core/services/gitignore-merge.d.ts +23 -0
  163. package/dist/src/core/services/gitignore-merge.js +21 -0
  164. package/dist/src/core/services/gitignore-plan.d.ts +34 -0
  165. package/dist/src/core/services/gitignore-plan.js +65 -0
  166. package/dist/src/core/services/harness-exclusion.d.ts +14 -0
  167. package/dist/src/core/services/harness-exclusion.js +19 -0
  168. package/dist/src/core/services/harness-removal.d.ts +23 -0
  169. package/dist/src/core/services/harness-removal.js +34 -0
  170. package/dist/src/core/services/injection-policy.d.ts +9 -0
  171. package/dist/src/core/services/injection-policy.js +5 -0
  172. package/dist/src/core/services/installation-adapters.d.ts +21 -0
  173. package/dist/src/core/services/installation-adapters.js +28 -0
  174. package/dist/src/core/services/installation-builder.d.ts +24 -0
  175. package/dist/src/core/services/installation-builder.js +66 -0
  176. package/dist/src/core/services/installation-findings.d.ts +5 -0
  177. package/dist/src/core/services/installation-findings.js +19 -0
  178. package/dist/src/core/services/installation-service.d.ts +36 -0
  179. package/dist/src/core/services/installation-service.js +50 -0
  180. package/dist/src/core/services/manifest-change.d.ts +11 -0
  181. package/dist/src/core/services/manifest-change.js +16 -0
  182. package/dist/src/core/services/no-harness-finding.d.ts +3 -0
  183. package/dist/src/core/services/no-harness-finding.js +9 -0
  184. package/dist/src/core/services/removal-helper.d.ts +10 -0
  185. package/dist/src/core/services/removal-helper.js +48 -0
  186. package/dist/src/core/services/removal-service.d.ts +19 -0
  187. package/dist/src/core/services/removal-service.js +45 -0
  188. package/dist/src/core/services/report-service.d.ts +30 -0
  189. package/dist/src/core/services/report-service.js +71 -0
  190. package/dist/src/core/services/reset-notice.d.ts +3 -0
  191. package/dist/src/core/services/reset-notice.js +8 -0
  192. package/dist/src/core/services/restart-doctor-findings.d.ts +10 -0
  193. package/dist/src/core/services/restart-doctor-findings.js +24 -0
  194. package/dist/src/core/services/restart-flow.d.ts +13 -0
  195. package/dist/src/core/services/restart-flow.js +50 -0
  196. package/dist/src/core/services/restart-guards.d.ts +6 -0
  197. package/dist/src/core/services/restart-guards.js +25 -0
  198. package/dist/src/core/services/restart-install-extras.d.ts +27 -0
  199. package/dist/src/core/services/restart-install-extras.js +39 -0
  200. package/dist/src/core/services/restart-mode.d.ts +4 -0
  201. package/dist/src/core/services/restart-mode.js +6 -0
  202. package/dist/src/core/services/runtime-error-checks.d.ts +11 -0
  203. package/dist/src/core/services/runtime-error-checks.js +20 -0
  204. package/dist/src/core/services/session-counters.d.ts +15 -0
  205. package/dist/src/core/services/session-counters.js +33 -0
  206. package/dist/src/core/services/session-reset-handler.d.ts +18 -0
  207. package/dist/src/core/services/session-reset-handler.js +24 -0
  208. package/dist/src/core/services/session-zone.d.ts +30 -0
  209. package/dist/src/core/services/session-zone.js +25 -0
  210. package/dist/src/core/services/snapshot-merge.d.ts +22 -0
  211. package/dist/src/core/services/snapshot-merge.js +25 -0
  212. package/dist/src/core/services/statusline-summary.d.ts +10 -0
  213. package/dist/src/core/services/statusline-summary.js +13 -0
  214. package/dist/src/core/services/support-service.d.ts +2 -0
  215. package/dist/src/core/services/support-service.js +57 -0
  216. package/dist/src/core/services/telemetry-block.d.ts +14 -0
  217. package/dist/src/core/services/telemetry-block.js +17 -0
  218. package/dist/src/core/services/usage-resolver.d.ts +20 -0
  219. package/dist/src/core/services/usage-resolver.js +23 -0
  220. package/dist/src/core/services/version-service.d.ts +14 -0
  221. package/dist/src/core/services/version-service.js +45 -0
  222. package/dist/src/core/services/window-trust.d.ts +2 -0
  223. package/dist/src/core/services/window-trust.js +3 -0
  224. package/dist/src/core/services/zone-classifier.d.ts +11 -0
  225. package/dist/src/core/services/zone-classifier.js +24 -0
  226. package/dist/src/core/services/zone-guidance.d.ts +6 -0
  227. package/dist/src/core/services/zone-guidance.js +32 -0
  228. package/dist/src/core/validation/configuration-sanitizer.d.ts +10 -0
  229. package/dist/src/core/validation/configuration-sanitizer.js +31 -0
  230. package/dist/src/core/validation/configuration-validator.d.ts +18 -0
  231. package/dist/src/core/validation/configuration-validator.js +45 -0
  232. package/dist/src/infrastructure/diagnostics/in-process-sampler.d.ts +18 -0
  233. package/dist/src/infrastructure/diagnostics/in-process-sampler.js +63 -0
  234. package/dist/src/infrastructure/diagnostics/overhead-measurer.d.ts +12 -0
  235. package/dist/src/infrastructure/diagnostics/overhead-measurer.js +77 -0
  236. package/dist/src/infrastructure/diagnostics/p95.d.ts +1 -0
  237. package/dist/src/infrastructure/diagnostics/p95.js +9 -0
  238. package/dist/src/infrastructure/diagnostics/process-sampler.d.ts +7 -0
  239. package/dist/src/infrastructure/diagnostics/process-sampler.js +69 -0
  240. package/dist/src/infrastructure/diagnostics/sample-failure.d.ts +10 -0
  241. package/dist/src/infrastructure/diagnostics/sample-failure.js +19 -0
  242. package/dist/src/infrastructure/git/git-context.d.ts +3 -0
  243. package/dist/src/infrastructure/git/git-context.js +25 -0
  244. package/dist/src/infrastructure/harnesses/antigravity-cli/adapter.d.ts +14 -0
  245. package/dist/src/infrastructure/harnesses/antigravity-cli/adapter.js +84 -0
  246. package/dist/src/infrastructure/harnesses/antigravity-cli/capabilities.d.ts +2 -0
  247. package/dist/src/infrastructure/harnesses/antigravity-cli/capabilities.js +6 -0
  248. package/dist/src/infrastructure/harnesses/antigravity-cli/detector.d.ts +4 -0
  249. package/dist/src/infrastructure/harnesses/antigravity-cli/detector.js +56 -0
  250. package/dist/src/infrastructure/harnesses/antigravity-cli/planner.d.ts +7 -0
  251. package/dist/src/infrastructure/harnesses/antigravity-cli/planner.js +62 -0
  252. package/dist/src/infrastructure/harnesses/antigravity-cli/runtime.d.ts +9 -0
  253. package/dist/src/infrastructure/harnesses/antigravity-cli/runtime.js +51 -0
  254. package/dist/src/infrastructure/harnesses/antigravity-cli/schemas.d.ts +31 -0
  255. package/dist/src/infrastructure/harnesses/antigravity-cli/schemas.js +19 -0
  256. package/dist/src/infrastructure/harnesses/claude-code/adapter.d.ts +14 -0
  257. package/dist/src/infrastructure/harnesses/claude-code/adapter.js +84 -0
  258. package/dist/src/infrastructure/harnesses/claude-code/auto-restart-diagnostics.d.ts +9 -0
  259. package/dist/src/infrastructure/harnesses/claude-code/auto-restart-diagnostics.js +60 -0
  260. package/dist/src/infrastructure/harnesses/claude-code/auto-restart-files.d.ts +12 -0
  261. package/dist/src/infrastructure/harnesses/claude-code/auto-restart-files.js +24 -0
  262. package/dist/src/infrastructure/harnesses/claude-code/auto-restart-ownership.d.ts +5 -0
  263. package/dist/src/infrastructure/harnesses/claude-code/auto-restart-ownership.js +41 -0
  264. package/dist/src/infrastructure/harnesses/claude-code/auto-restart-planner.d.ts +7 -0
  265. package/dist/src/infrastructure/harnesses/claude-code/auto-restart-planner.js +81 -0
  266. package/dist/src/infrastructure/harnesses/claude-code/auto-restart-settings.d.ts +4 -0
  267. package/dist/src/infrastructure/harnesses/claude-code/auto-restart-settings.js +29 -0
  268. package/dist/src/infrastructure/harnesses/claude-code/capabilities.d.ts +2 -0
  269. package/dist/src/infrastructure/harnesses/claude-code/capabilities.js +6 -0
  270. package/dist/src/infrastructure/harnesses/claude-code/claude-hooks-config.d.ts +1 -0
  271. package/dist/src/infrastructure/harnesses/claude-code/claude-hooks-config.js +25 -0
  272. package/dist/src/infrastructure/harnesses/claude-code/claude-merger.d.ts +14 -0
  273. package/dist/src/infrastructure/harnesses/claude-code/claude-merger.js +44 -0
  274. package/dist/src/infrastructure/harnesses/claude-code/detector.d.ts +6 -0
  275. package/dist/src/infrastructure/harnesses/claude-code/detector.js +14 -0
  276. package/dist/src/infrastructure/harnesses/claude-code/mod/hooks.d.ts +6 -0
  277. package/dist/src/infrastructure/harnesses/claude-code/mod/hooks.js +43 -0
  278. package/dist/src/infrastructure/harnesses/claude-code/mod/host.d.ts +56 -0
  279. package/dist/src/infrastructure/harnesses/claude-code/mod/host.js +1 -0
  280. package/dist/src/infrastructure/harnesses/claude-code/mod/mod-config.d.ts +8 -0
  281. package/dist/src/infrastructure/harnesses/claude-code/mod/mod-config.js +31 -0
  282. package/dist/src/infrastructure/harnesses/claude-code/mod/mod-guards.d.ts +3 -0
  283. package/dist/src/infrastructure/harnesses/claude-code/mod/mod-guards.js +13 -0
  284. package/dist/src/infrastructure/harnesses/claude-code/mod/mod-info.d.ts +4 -0
  285. package/dist/src/infrastructure/harnesses/claude-code/mod/mod-info.js +5 -0
  286. package/dist/src/infrastructure/harnesses/claude-code/mod/mod-log.d.ts +4 -0
  287. package/dist/src/infrastructure/harnesses/claude-code/mod/mod-log.js +34 -0
  288. package/dist/src/infrastructure/harnesses/claude-code/mod/register.d.ts +2 -0
  289. package/dist/src/infrastructure/harnesses/claude-code/mod/register.js +23 -0
  290. package/dist/src/infrastructure/harnesses/claude-code/mod/restart-facts.d.ts +3 -0
  291. package/dist/src/infrastructure/harnesses/claude-code/mod/restart-facts.js +12 -0
  292. package/dist/src/infrastructure/harnesses/claude-code/mod/restart-flow.d.ts +4 -0
  293. package/dist/src/infrastructure/harnesses/claude-code/mod/restart-flow.js +22 -0
  294. package/dist/src/infrastructure/harnesses/claude-code/mod/restart-host.d.ts +7 -0
  295. package/dist/src/infrastructure/harnesses/claude-code/mod/restart-host.js +35 -0
  296. package/dist/src/infrastructure/harnesses/claude-code/mod/turn-state.d.ts +7 -0
  297. package/dist/src/infrastructure/harnesses/claude-code/mod/turn-state.js +12 -0
  298. package/dist/src/infrastructure/harnesses/claude-code/planner.d.ts +7 -0
  299. package/dist/src/infrastructure/harnesses/claude-code/planner.js +72 -0
  300. package/dist/src/infrastructure/harnesses/claude-code/runtime.d.ts +10 -0
  301. package/dist/src/infrastructure/harnesses/claude-code/runtime.js +82 -0
  302. package/dist/src/infrastructure/harnesses/claude-code/schemas.d.ts +42 -0
  303. package/dist/src/infrastructure/harnesses/claude-code/schemas.js +30 -0
  304. package/dist/src/infrastructure/harnesses/claude-code/statusline-bridge.d.ts +12 -0
  305. package/dist/src/infrastructure/harnesses/claude-code/statusline-bridge.js +78 -0
  306. package/dist/src/infrastructure/harnesses/claude-code/statusline-context-window.d.ts +5 -0
  307. package/dist/src/infrastructure/harnesses/claude-code/statusline-context-window.js +50 -0
  308. package/dist/src/infrastructure/harnesses/claude-code/statusline-default.d.ts +6 -0
  309. package/dist/src/infrastructure/harnesses/claude-code/statusline-default.js +38 -0
  310. package/dist/src/infrastructure/harnesses/claude-code/statusline-diagnostics.d.ts +3 -0
  311. package/dist/src/infrastructure/harnesses/claude-code/statusline-diagnostics.js +70 -0
  312. package/dist/src/infrastructure/harnesses/claude-code/statusline-output.d.ts +9 -0
  313. package/dist/src/infrastructure/harnesses/claude-code/statusline-output.js +15 -0
  314. package/dist/src/infrastructure/harnesses/claude-code/statusline-payload.d.ts +7 -0
  315. package/dist/src/infrastructure/harnesses/claude-code/statusline-payload.js +36 -0
  316. package/dist/src/infrastructure/harnesses/claude-code/statusline-planner.d.ts +4 -0
  317. package/dist/src/infrastructure/harnesses/claude-code/statusline-planner.js +82 -0
  318. package/dist/src/infrastructure/harnesses/claude-code/statusline-previous.d.ts +17 -0
  319. package/dist/src/infrastructure/harnesses/claude-code/statusline-previous.js +41 -0
  320. package/dist/src/infrastructure/harnesses/claude-code/statusline-restore.d.ts +9 -0
  321. package/dist/src/infrastructure/harnesses/claude-code/statusline-restore.js +31 -0
  322. package/dist/src/infrastructure/harnesses/claude-code/statusline-settings.d.ts +33 -0
  323. package/dist/src/infrastructure/harnesses/claude-code/statusline-settings.js +63 -0
  324. package/dist/src/infrastructure/harnesses/claude-code/statusline-shell.d.ts +13 -0
  325. package/dist/src/infrastructure/harnesses/claude-code/statusline-shell.js +28 -0
  326. package/dist/src/infrastructure/harnesses/claude-code/statusline-state.d.ts +21 -0
  327. package/dist/src/infrastructure/harnesses/claude-code/statusline-state.js +29 -0
  328. package/dist/src/infrastructure/harnesses/claude-code/transcript-usage.d.ts +6 -0
  329. package/dist/src/infrastructure/harnesses/claude-code/transcript-usage.js +24 -0
  330. package/dist/src/infrastructure/harnesses/codex-cli/adapter.d.ts +14 -0
  331. package/dist/src/infrastructure/harnesses/codex-cli/adapter.js +90 -0
  332. package/dist/src/infrastructure/harnesses/codex-cli/capabilities.d.ts +2 -0
  333. package/dist/src/infrastructure/harnesses/codex-cli/capabilities.js +6 -0
  334. package/dist/src/infrastructure/harnesses/codex-cli/detector.d.ts +6 -0
  335. package/dist/src/infrastructure/harnesses/codex-cli/detector.js +13 -0
  336. package/dist/src/infrastructure/harnesses/codex-cli/planner.d.ts +7 -0
  337. package/dist/src/infrastructure/harnesses/codex-cli/planner.js +75 -0
  338. package/dist/src/infrastructure/harnesses/codex-cli/rollout-usage.d.ts +6 -0
  339. package/dist/src/infrastructure/harnesses/codex-cli/rollout-usage.js +27 -0
  340. package/dist/src/infrastructure/harnesses/codex-cli/runtime.d.ts +10 -0
  341. package/dist/src/infrastructure/harnesses/codex-cli/runtime.js +85 -0
  342. package/dist/src/infrastructure/harnesses/codex-cli/schemas.d.ts +47 -0
  343. package/dist/src/infrastructure/harnesses/codex-cli/schemas.js +25 -0
  344. package/dist/src/infrastructure/harnesses/common/antigravity-hooks-updater.d.ts +4 -0
  345. package/dist/src/infrastructure/harnesses/common/antigravity-hooks-updater.js +57 -0
  346. package/dist/src/infrastructure/harnesses/common/change-target.d.ts +1 -0
  347. package/dist/src/infrastructure/harnesses/common/change-target.js +40 -0
  348. package/dist/src/infrastructure/harnesses/common/codex-hooks-updater.d.ts +13 -0
  349. package/dist/src/infrastructure/harnesses/common/codex-hooks-updater.js +79 -0
  350. package/dist/src/infrastructure/harnesses/common/cursor-hooks-updater.d.ts +3 -0
  351. package/dist/src/infrastructure/harnesses/common/cursor-hooks-updater.js +63 -0
  352. package/dist/src/infrastructure/harnesses/common/diagnostic-helpers.d.ts +7 -0
  353. package/dist/src/infrastructure/harnesses/common/diagnostic-helpers.js +60 -0
  354. package/dist/src/infrastructure/harnesses/common/hook-event-cleanup.d.ts +3 -0
  355. package/dist/src/infrastructure/harnesses/common/hook-event-cleanup.js +50 -0
  356. package/dist/src/infrastructure/harnesses/common/in-process-restart-log.d.ts +9 -0
  357. package/dist/src/infrastructure/harnesses/common/in-process-restart-log.js +36 -0
  358. package/dist/src/infrastructure/harnesses/common/in-process-restart-state.d.ts +11 -0
  359. package/dist/src/infrastructure/harnesses/common/in-process-restart-state.js +50 -0
  360. package/dist/src/infrastructure/harnesses/common/in-process-restart-support.d.ts +13 -0
  361. package/dist/src/infrastructure/harnesses/common/in-process-restart-support.js +15 -0
  362. package/dist/src/infrastructure/harnesses/common/in-process-support.d.ts +18 -0
  363. package/dist/src/infrastructure/harnesses/common/in-process-support.js +40 -0
  364. package/dist/src/infrastructure/harnesses/common/jsonl-tail-reader.d.ts +6 -0
  365. package/dist/src/infrastructure/harnesses/common/jsonl-tail-reader.js +76 -0
  366. package/dist/src/infrastructure/harnesses/common/path-helpers.d.ts +6 -0
  367. package/dist/src/infrastructure/harnesses/common/path-helpers.js +51 -0
  368. package/dist/src/infrastructure/harnesses/common/removal-config-validator.d.ts +2 -0
  369. package/dist/src/infrastructure/harnesses/common/removal-config-validator.js +14 -0
  370. package/dist/src/infrastructure/harnesses/common/restart-asset-plan.d.ts +12 -0
  371. package/dist/src/infrastructure/harnesses/common/restart-asset-plan.js +37 -0
  372. package/dist/src/infrastructure/harnesses/common/restart-diagnostics.d.ts +12 -0
  373. package/dist/src/infrastructure/harnesses/common/restart-diagnostics.js +49 -0
  374. package/dist/src/infrastructure/harnesses/common/runtime-assets.d.ts +1 -0
  375. package/dist/src/infrastructure/harnesses/common/runtime-assets.js +23 -0
  376. package/dist/src/infrastructure/harnesses/common/runtime-support.d.ts +8 -0
  377. package/dist/src/infrastructure/harnesses/common/runtime-support.js +44 -0
  378. package/dist/src/infrastructure/harnesses/common/version-probes.d.ts +3 -0
  379. package/dist/src/infrastructure/harnesses/common/version-probes.js +21 -0
  380. package/dist/src/infrastructure/harnesses/cursor/adapter.d.ts +14 -0
  381. package/dist/src/infrastructure/harnesses/cursor/adapter.js +70 -0
  382. package/dist/src/infrastructure/harnesses/cursor/capabilities.d.ts +2 -0
  383. package/dist/src/infrastructure/harnesses/cursor/capabilities.js +6 -0
  384. package/dist/src/infrastructure/harnesses/cursor/detector.d.ts +6 -0
  385. package/dist/src/infrastructure/harnesses/cursor/detector.js +13 -0
  386. package/dist/src/infrastructure/harnesses/cursor/planner.d.ts +7 -0
  387. package/dist/src/infrastructure/harnesses/cursor/planner.js +66 -0
  388. package/dist/src/infrastructure/harnesses/cursor/runtime.d.ts +9 -0
  389. package/dist/src/infrastructure/harnesses/cursor/runtime.js +49 -0
  390. package/dist/src/infrastructure/harnesses/cursor/schemas.d.ts +39 -0
  391. package/dist/src/infrastructure/harnesses/cursor/schemas.js +23 -0
  392. package/dist/src/infrastructure/harnesses/github-copilot-cli/adapter.d.ts +14 -0
  393. package/dist/src/infrastructure/harnesses/github-copilot-cli/adapter.js +69 -0
  394. package/dist/src/infrastructure/harnesses/github-copilot-cli/capabilities.d.ts +2 -0
  395. package/dist/src/infrastructure/harnesses/github-copilot-cli/capabilities.js +6 -0
  396. package/dist/src/infrastructure/harnesses/github-copilot-cli/detector.d.ts +6 -0
  397. package/dist/src/infrastructure/harnesses/github-copilot-cli/detector.js +15 -0
  398. package/dist/src/infrastructure/harnesses/github-copilot-cli/planner.d.ts +7 -0
  399. package/dist/src/infrastructure/harnesses/github-copilot-cli/planner.js +66 -0
  400. package/dist/src/infrastructure/harnesses/github-copilot-cli/runtime.d.ts +9 -0
  401. package/dist/src/infrastructure/harnesses/github-copilot-cli/runtime.js +67 -0
  402. package/dist/src/infrastructure/harnesses/github-copilot-cli/schemas.d.ts +35 -0
  403. package/dist/src/infrastructure/harnesses/github-copilot-cli/schemas.js +21 -0
  404. package/dist/src/infrastructure/harnesses/oh-my-pi/adapter.d.ts +14 -0
  405. package/dist/src/infrastructure/harnesses/oh-my-pi/adapter.js +64 -0
  406. package/dist/src/infrastructure/harnesses/oh-my-pi/capabilities.d.ts +2 -0
  407. package/dist/src/infrastructure/harnesses/oh-my-pi/capabilities.js +6 -0
  408. package/dist/src/infrastructure/harnesses/oh-my-pi/detector.d.ts +6 -0
  409. package/dist/src/infrastructure/harnesses/oh-my-pi/detector.js +13 -0
  410. package/dist/src/infrastructure/harnesses/oh-my-pi/events.d.ts +8 -0
  411. package/dist/src/infrastructure/harnesses/oh-my-pi/events.js +65 -0
  412. package/dist/src/infrastructure/harnesses/oh-my-pi/planner.d.ts +7 -0
  413. package/dist/src/infrastructure/harnesses/oh-my-pi/planner.js +32 -0
  414. package/dist/src/infrastructure/harnesses/oh-my-pi/restart.d.ts +28 -0
  415. package/dist/src/infrastructure/harnesses/oh-my-pi/restart.js +79 -0
  416. package/dist/src/infrastructure/harnesses/oh-my-pi/runtime.d.ts +17 -0
  417. package/dist/src/infrastructure/harnesses/oh-my-pi/runtime.js +69 -0
  418. package/dist/src/infrastructure/harnesses/oh-my-pi/schemas.d.ts +50 -0
  419. package/dist/src/infrastructure/harnesses/oh-my-pi/schemas.js +17 -0
  420. package/dist/src/infrastructure/harnesses/opencode/adapter.d.ts +14 -0
  421. package/dist/src/infrastructure/harnesses/opencode/adapter.js +64 -0
  422. package/dist/src/infrastructure/harnesses/opencode/capabilities.d.ts +2 -0
  423. package/dist/src/infrastructure/harnesses/opencode/capabilities.js +6 -0
  424. package/dist/src/infrastructure/harnesses/opencode/detector.d.ts +6 -0
  425. package/dist/src/infrastructure/harnesses/opencode/detector.js +16 -0
  426. package/dist/src/infrastructure/harnesses/opencode/events.d.ts +8 -0
  427. package/dist/src/infrastructure/harnesses/opencode/events.js +36 -0
  428. package/dist/src/infrastructure/harnesses/opencode/planner.d.ts +6 -0
  429. package/dist/src/infrastructure/harnesses/opencode/planner.js +23 -0
  430. package/dist/src/infrastructure/harnesses/opencode/runtime.d.ts +20 -0
  431. package/dist/src/infrastructure/harnesses/opencode/runtime.js +51 -0
  432. package/dist/src/infrastructure/harnesses/opencode/schemas.d.ts +51 -0
  433. package/dist/src/infrastructure/harnesses/opencode/schemas.js +32 -0
  434. package/dist/src/infrastructure/harnesses/pi/adapter.d.ts +14 -0
  435. package/dist/src/infrastructure/harnesses/pi/adapter.js +64 -0
  436. package/dist/src/infrastructure/harnesses/pi/capabilities.d.ts +2 -0
  437. package/dist/src/infrastructure/harnesses/pi/capabilities.js +6 -0
  438. package/dist/src/infrastructure/harnesses/pi/detector.d.ts +6 -0
  439. package/dist/src/infrastructure/harnesses/pi/detector.js +10 -0
  440. package/dist/src/infrastructure/harnesses/pi/events.d.ts +8 -0
  441. package/dist/src/infrastructure/harnesses/pi/events.js +65 -0
  442. package/dist/src/infrastructure/harnesses/pi/planner.d.ts +7 -0
  443. package/dist/src/infrastructure/harnesses/pi/planner.js +32 -0
  444. package/dist/src/infrastructure/harnesses/pi/restart.d.ts +33 -0
  445. package/dist/src/infrastructure/harnesses/pi/restart.js +69 -0
  446. package/dist/src/infrastructure/harnesses/pi/runtime.d.ts +17 -0
  447. package/dist/src/infrastructure/harnesses/pi/runtime.js +67 -0
  448. package/dist/src/infrastructure/harnesses/pi/schemas.d.ts +50 -0
  449. package/dist/src/infrastructure/harnesses/pi/schemas.js +17 -0
  450. package/dist/src/infrastructure/harnesses/registry.d.ts +6 -0
  451. package/dist/src/infrastructure/harnesses/registry.js +94 -0
  452. package/dist/src/infrastructure/process/node-process-runner.d.ts +8 -0
  453. package/dist/src/infrastructure/process/node-process-runner.js +66 -0
  454. package/dist/src/infrastructure/process/process-tree.d.ts +2 -0
  455. package/dist/src/infrastructure/process/process-tree.js +28 -0
  456. package/dist/src/infrastructure/runtime/hook-deadline.d.ts +26 -0
  457. package/dist/src/infrastructure/runtime/hook-deadline.js +55 -0
  458. package/dist/src/infrastructure/runtime/hook-failure.d.ts +14 -0
  459. package/dist/src/infrastructure/runtime/hook-failure.js +22 -0
  460. package/dist/src/infrastructure/runtime/in-process-host.d.ts +16 -0
  461. package/dist/src/infrastructure/runtime/in-process-host.js +75 -0
  462. package/dist/src/infrastructure/runtime/node-runtime-logs.d.ts +8 -0
  463. package/dist/src/infrastructure/runtime/node-runtime-logs.js +21 -0
  464. package/dist/src/infrastructure/runtime/node-session-ledger.d.ts +17 -0
  465. package/dist/src/infrastructure/runtime/node-session-ledger.js +68 -0
  466. package/dist/src/infrastructure/runtime/process-hook-host.d.ts +25 -0
  467. package/dist/src/infrastructure/runtime/process-hook-host.js +79 -0
  468. package/dist/src/infrastructure/runtime/runtime-composition.d.ts +29 -0
  469. package/dist/src/infrastructure/runtime/runtime-composition.js +41 -0
  470. package/dist/src/infrastructure/runtime/runtime-paths.d.ts +12 -0
  471. package/dist/src/infrastructure/runtime/runtime-paths.js +45 -0
  472. package/dist/src/infrastructure/runtime/runtime-state-reader.d.ts +9 -0
  473. package/dist/src/infrastructure/runtime/runtime-state-reader.js +82 -0
  474. package/dist/src/infrastructure/storage/atomic-writer.d.ts +2 -0
  475. package/dist/src/infrastructure/storage/atomic-writer.js +35 -0
  476. package/dist/src/infrastructure/storage/change-applier.d.ts +10 -0
  477. package/dist/src/infrastructure/storage/change-applier.js +80 -0
  478. package/dist/src/infrastructure/storage/directory-pruner.d.ts +8 -0
  479. package/dist/src/infrastructure/storage/directory-pruner.js +76 -0
  480. package/dist/src/infrastructure/storage/handoff-claim-lock.d.ts +3 -0
  481. package/dist/src/infrastructure/storage/handoff-claim-lock.js +32 -0
  482. package/dist/src/infrastructure/storage/json-document-editor.d.ts +5 -0
  483. package/dist/src/infrastructure/storage/json-document-editor.js +52 -0
  484. package/dist/src/infrastructure/storage/json-span-utils.d.ts +24 -0
  485. package/dist/src/infrastructure/storage/json-span-utils.js +104 -0
  486. package/dist/src/infrastructure/storage/json-validator.d.ts +13 -0
  487. package/dist/src/infrastructure/storage/json-validator.js +61 -0
  488. package/dist/src/infrastructure/storage/manifest-store.d.ts +11 -0
  489. package/dist/src/infrastructure/storage/manifest-store.js +45 -0
  490. package/dist/src/infrastructure/storage/node-file-system.d.ts +4 -0
  491. package/dist/src/infrastructure/storage/node-file-system.js +33 -0
  492. package/dist/src/infrastructure/storage/node-handoff-store.d.ts +11 -0
  493. package/dist/src/infrastructure/storage/node-handoff-store.js +96 -0
  494. package/dist/src/infrastructure/storage/package-metadata.d.ts +7 -0
  495. package/dist/src/infrastructure/storage/package-metadata.js +58 -0
  496. package/dist/src/infrastructure/storage/path-boundary.d.ts +11 -0
  497. package/dist/src/infrastructure/storage/path-boundary.js +73 -0
  498. package/dist/src/infrastructure/storage/project-config-store.d.ts +9 -0
  499. package/dist/src/infrastructure/storage/project-config-store.js +24 -0
  500. package/dist/src/infrastructure/storage/runtime-state-files.d.ts +12 -0
  501. package/dist/src/infrastructure/storage/runtime-state-files.js +22 -0
  502. package/docs/telemetry-block.md +149 -0
  503. package/package.json +65 -4
  504. package/schemas/context-brake.config.schema.json +177 -0
  505. package/schemas/doctor-report.schema.json +595 -0
  506. 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
- # Temporary Holding Version
1
+ # ContextBrake ๐Ÿ›‘
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue.svg)](https://www.typescriptlang.org/)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Node.js Version](https://img.shields.io/badge/node-%3E%3D20.0.0-brightgreen.svg)](https://nodejs.org/)
6
+ [![Spec-Driven Development](https://img.shields.io/badge/Paradigm-Spec--Driven%20Development-purple.svg)](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)