capt-hook 12.83.2__tar.gz → 12.84.0__tar.gz

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 (256) hide show
  1. {capt_hook-12.83.2 → capt_hook-12.84.0}/PKG-INFO +1 -1
  2. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/.claude-plugin/plugin.json +1 -1
  3. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/__init__.py +3 -0
  4. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/__init__.pyi +3 -0
  5. capt_hook-12.84.0/captain_hook/builtin_packs/performance/hooks/resources.py +270 -0
  6. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/cli.py +7 -1
  7. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/context.py +65 -1
  8. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/daemon/context.py +7 -0
  9. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/dispatch.py +5 -1
  10. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/events.py +84 -0
  11. capt_hook-12.84.0/captain_hook/procwatch/identity.py +100 -0
  12. capt_hook-12.84.0/captain_hook/procwatch/judge.py +116 -0
  13. capt_hook-12.84.0/captain_hook/procwatch/ownership.py +68 -0
  14. capt_hook-12.84.0/captain_hook/procwatch/screen.py +399 -0
  15. capt_hook-12.84.0/captain_hook/procwatch/settings.py +37 -0
  16. capt_hook-12.84.0/captain_hook/procwatch/signal.py +94 -0
  17. capt_hook-12.84.0/captain_hook/procwatch/state.py +153 -0
  18. capt_hook-12.84.0/captain_hook/resource_defaults.py +17 -0
  19. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/skills/authoring-hooks/references/capt-hook-api.md +1 -0
  20. capt_hook-12.84.0/captain_hook/snapshots/__init__.py +0 -0
  21. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/testing/helpers.py +24 -0
  22. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/types.py +5 -0
  23. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/util/proc.py +136 -1
  24. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/util/reqenv.py +9 -1
  25. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/worker/protocol.py +17 -0
  26. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/worker/runtime.py +2 -0
  27. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/worker/service.py +23 -4
  28. {capt_hook-12.83.2 → capt_hook-12.84.0}/hatch_build.py +19 -0
  29. capt_hook-12.84.0/internal/wireproto/resource.json +15 -0
  30. {capt_hook-12.83.2 → capt_hook-12.84.0}/pyproject.toml +3 -2
  31. {capt_hook-12.83.2 → capt_hook-12.84.0}/.gitignore +0 -0
  32. {capt_hook-12.83.2 → capt_hook-12.84.0}/LICENSE +0 -0
  33. {capt_hook-12.83.2 → capt_hook-12.84.0}/README.md +0 -0
  34. {capt_hook-12.83.2 → capt_hook-12.84.0}/capt_hook_client/__init__.py +0 -0
  35. {capt_hook-12.83.2 → capt_hook-12.84.0}/capt_hook_client/__main__.py +0 -0
  36. {capt_hook-12.83.2 → capt_hook-12.84.0}/capt_hook_client/client.py +0 -0
  37. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/.mcp.json +0 -0
  38. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/__main__.py +0 -0
  39. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/annotations.py +0 -0
  40. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/app.py +0 -0
  41. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/ast_grep.py +0 -0
  42. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/bindings.py +0 -0
  43. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/__init__.py +0 -0
  44. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/fixes/__init__.py +0 -0
  45. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/fixes/hooks/__init__.py +0 -0
  46. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/fixes/hooks/_lib.py +0 -0
  47. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/fixes/hooks/scratch_writes.py +0 -0
  48. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/fixes/hooks/teammate_permissions.py +0 -0
  49. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/__init__.py +0 -0
  50. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/__init__.py +0 -0
  51. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/_lib.py +0 -0
  52. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/_sessions.py +0 -0
  53. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/commands.py +0 -0
  54. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/comments.py +0 -0
  55. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/deletions.py +0 -0
  56. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/detours.py +0 -0
  57. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/docs.py +0 -0
  58. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/grants.py +0 -0
  59. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/hook_files.py +0 -0
  60. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/models.py +0 -0
  61. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/plain_english.py +0 -0
  62. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/plans.py +0 -0
  63. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/prompts/fragments/deliverable_rubric.md +0 -0
  64. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/prompts/fragments/workflow_script_header.md +0 -0
  65. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/prompts/models/browser_delegation_nudge.md +0 -0
  66. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/prompts/models/implementation_spawn_nudge.md +0 -0
  67. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/prompts/models/inline_edit_nudge.md +0 -0
  68. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/prompts/models/prose_spawn_gate.md +0 -0
  69. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/prompts/models/prose_workflow_nudge.md +0 -0
  70. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/prompts/models/review_routing_spawn_nudge.md +0 -0
  71. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/prompts/models/review_routing_workflow_nudge.md +0 -0
  72. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/prompts/models/writing_docs_spawn_nudge.md +0 -0
  73. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/prompts/models/writing_docs_workflow_nudge.md +0 -0
  74. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/prompts/plain_english_rules.md +0 -0
  75. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/prompts/tools/preload_nudge.md +0 -0
  76. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/prompts.py +0 -0
  77. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/questions.py +0 -0
  78. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/review.py +0 -0
  79. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/sessions.py +0 -0
  80. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/stops.py +0 -0
  81. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/tasks.py +0 -0
  82. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/tombstones.py +0 -0
  83. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/tooling.py +0 -0
  84. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/hooks/tools.py +0 -0
  85. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/general/pack.toml +0 -0
  86. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/go/__init__.py +0 -0
  87. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/go/hooks/__init__.py +0 -0
  88. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/go/hooks/testing.py +0 -0
  89. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/go/hooks/toolchain.py +0 -0
  90. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/graphite/__init__.py +0 -0
  91. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/graphite/gitdir/.graphite_repo_config +0 -0
  92. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/graphite/hooks/__init__.py +0 -0
  93. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/graphite/hooks/_lib.py +0 -0
  94. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/graphite/hooks/queue.py +0 -0
  95. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/graphite/hooks/vcs.py +0 -0
  96. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/performance/__init__.py +0 -0
  97. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/performance/hooks/__init__.py +0 -0
  98. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/performance/hooks/filesystem.py +0 -0
  99. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/performance/hooks/pipelining.py +0 -0
  100. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/python/__init__.py +0 -0
  101. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/python/hooks/__init__.py +0 -0
  102. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/python/hooks/style.py +0 -0
  103. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/python/hooks/testing.py +0 -0
  104. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/python/hooks/toolchain.py +0 -0
  105. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/steering/__init__.py +0 -0
  106. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/steering/hooks/__init__.py +0 -0
  107. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/steering/hooks/steering.py +0 -0
  108. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/steering/hooks/teammates.py +0 -0
  109. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/steering/hooks/workarounds.py +0 -0
  110. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/builtin_packs/steering/pack.toml +0 -0
  111. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/classifiers/__init__.py +0 -0
  112. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/classifiers/conductor.py +0 -0
  113. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/classifiers/droid.py +0 -0
  114. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/classifiers/lane.py +0 -0
  115. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/classifiers/native.py +0 -0
  116. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/cmd.py +0 -0
  117. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/command_schema.py +0 -0
  118. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/command_schemas.py +0 -0
  119. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/conditions.py +0 -0
  120. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/confirm.py +0 -0
  121. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/contexts.py +0 -0
  122. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/daemon/__init__.py +0 -0
  123. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/daemon/decision_writer.py +0 -0
  124. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/daemon/logsink.py +0 -0
  125. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/daemon/registry.py +0 -0
  126. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/daemon/tree.py +0 -0
  127. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/decisions.py +0 -0
  128. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/desktop/__init__.py +0 -0
  129. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/desktop/cli.py +0 -0
  130. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/desktop/client.py +0 -0
  131. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/doc_conventions.py +0 -0
  132. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/durable.py +0 -0
  133. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/faults.py +0 -0
  134. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/fields.py +0 -0
  135. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/file.py +0 -0
  136. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/grants/__init__.py +0 -0
  137. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/grants/cli.py +0 -0
  138. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/grants/declare.py +0 -0
  139. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/grants/evidence.py +0 -0
  140. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/grants/judge.py +0 -0
  141. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/grants/orca.py +0 -0
  142. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/grants/records.py +0 -0
  143. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/grants/rules.py +0 -0
  144. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/grants/store.py +0 -0
  145. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/guard_literal.py +0 -0
  146. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/guard_literal.sh +0 -0
  147. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/heartbeat.py +0 -0
  148. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/hook_lint.py +0 -0
  149. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/hooks/hooks.json +0 -0
  150. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/loader.py +0 -0
  151. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/log.py +0 -0
  152. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/mcp_server.py +0 -0
  153. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/packs/__init__.py +0 -0
  154. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/packs/manager.py +0 -0
  155. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/packs/plugins.py +0 -0
  156. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/pause.py +0 -0
  157. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/primitives/__init__.py +0 -0
  158. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/primitives/commands.py +0 -0
  159. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/primitives/lint.py +0 -0
  160. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/primitives/llm.py +0 -0
  161. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/primitives/nudge.py +0 -0
  162. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/primitives/permissions.py +0 -0
  163. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/primitives/provision.py +0 -0
  164. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/primitives/rewrite.py +0 -0
  165. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/primitives/workflow.py +0 -0
  166. {capt_hook-12.83.2/captain_hook/snapshots → capt_hook-12.84.0/captain_hook/procwatch}/__init__.py +0 -0
  167. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/prompt.py +0 -0
  168. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/py.typed +0 -0
  169. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/review/__init__.py +0 -0
  170. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/review/announce.py +0 -0
  171. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/review/cli.py +0 -0
  172. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/review/dashboard.py +0 -0
  173. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/review/fix.py +0 -0
  174. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/review/formats.py +0 -0
  175. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/review/judge.py +0 -0
  176. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/review/notify.py +0 -0
  177. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/review/pipeline.py +0 -0
  178. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/review/prompts.py +0 -0
  179. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/review/repo.py +0 -0
  180. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/review/routing.py +0 -0
  181. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/review/scan.py +0 -0
  182. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/review/settings.py +0 -0
  183. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/review/snapshot.py +0 -0
  184. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/review/status.py +0 -0
  185. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/review/store.py +0 -0
  186. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/review/sync.py +0 -0
  187. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/review/triage.py +0 -0
  188. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/scripts/install-binary.sh +0 -0
  189. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/scripts/install-mcp.sh +0 -0
  190. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/session.py +0 -0
  191. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/settings.py +0 -0
  192. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/signals/__init__.py +0 -0
  193. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/signals/nlp.py +0 -0
  194. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/skills/authoring-hooks/SKILL.md +0 -0
  195. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/skills/authoring-hooks/references/pattern-catalog.md +0 -0
  196. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/skills/authoring-hooks/references/pitfalls.md +0 -0
  197. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/skills/authoring-hooks/references/testing-hooks.md +0 -0
  198. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/skills/bootstrapping-hooks/SKILL.md +0 -0
  199. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/skills/scanning-sessions/SKILL.md +0 -0
  200. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/skills/scanning-sessions/references/pr-workflow.md +0 -0
  201. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/skills/scanning-sessions/references/review-cli.md +0 -0
  202. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/skills/translating-styleguides/SKILL.md +0 -0
  203. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/skills/translating-styleguides/references/llm-rule-patterns.md +0 -0
  204. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/skills/translating-styleguides/references/matcher-reference.md +0 -0
  205. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/skills/translating-styleguides/references/tier-rubric.md +0 -0
  206. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/snapshots/client.py +0 -0
  207. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/snapshots/contracts.py +0 -0
  208. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/snapshots/review.py +0 -0
  209. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/snapshots/schema.py +0 -0
  210. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/snapshots/schemas/config.schema.json +0 -0
  211. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/snapshots/schemas/context.schema.json +0 -0
  212. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/snapshots/schemas/host-request.schema.json +0 -0
  213. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/snapshots/schemas/host-response.schema.json +0 -0
  214. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/snapshots/schemas/request.schema.json +0 -0
  215. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/snapshots/schemas/response.schema.json +0 -0
  216. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/snapshots/schemas/tool_registry.schema.json +0 -0
  217. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/snapshots/validation.py +0 -0
  218. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/snapshots/worker.py +0 -0
  219. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/state.py +0 -0
  220. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/style/__init__.py +0 -0
  221. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/style/ast_grep.py +0 -0
  222. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/style/matchers.py +0 -0
  223. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/style/scope.py +0 -0
  224. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/style/types.py +0 -0
  225. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/tasks.py +0 -0
  226. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/templates/example_hook.py.tmpl +0 -0
  227. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/testing/__init__.py +0 -0
  228. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/testing/fixtures.py +0 -0
  229. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/testing/session_cache.py +0 -0
  230. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/testing/snapshots.py +0 -0
  231. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/testing/types.py +0 -0
  232. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/transcripts.py +0 -0
  233. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/turn.py +0 -0
  234. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/update/__init__.py +0 -0
  235. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/update/cli.py +0 -0
  236. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/update/launchers.py +0 -0
  237. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/update/settings.py +0 -0
  238. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/update/updater.py +0 -0
  239. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/util/__init__.py +0 -0
  240. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/util/automode.py +0 -0
  241. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/util/caching.py +0 -0
  242. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/util/fs.py +0 -0
  243. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/util/globbing.py +0 -0
  244. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/util/http.py +0 -0
  245. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/util/model_cache.py +0 -0
  246. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/util/paths.py +0 -0
  247. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/util/payload.py +0 -0
  248. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/util/scratch.py +0 -0
  249. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/util/shell.py +0 -0
  250. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/util/text.py +0 -0
  251. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/util/userpath.py +0 -0
  252. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/util/vcs.py +0 -0
  253. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/worker/__init__.py +0 -0
  254. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/worker/__main__.py +0 -0
  255. {capt_hook-12.83.2 → capt_hook-12.84.0}/captain_hook/worker/fail_open.py +0 -0
  256. {capt_hook-12.83.2 → capt_hook-12.84.0}/internal/wireproto/guard.json +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: capt-hook
3
- Version: 12.83.2
3
+ Version: 12.84.0
4
4
  Summary: Stop repeating yourself to Claude.
5
5
  Project-URL: Homepage, https://github.com/yasyf/captain-hook
6
6
  Project-URL: Documentation, https://yasyf.github.io/captain-hook/
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "captain-hook",
3
- "version": "12.83.1",
3
+ "version": "12.83.2",
4
4
  "displayName": "Captain Hook",
5
5
  "description": "Skills for the capt-hook declarative hook framework: bootstrap gates and nudges from a repo's conventions, and translate style guides into enforced StyleRules.",
6
6
  "author": {
@@ -85,6 +85,7 @@ EXPORTS: dict[str, str] = {
85
85
  "PostToolUseFailureEvent": "captain_hook.events",
86
86
  "PreCompactEvent": "captain_hook.events",
87
87
  "PreToolUseEvent": "captain_hook.events",
88
+ "ResourcePressureEvent": "captain_hook.events",
88
89
  "SessionCron": "captain_hook.events",
89
90
  "SessionEndEvent": "captain_hook.events",
90
91
  "SessionStartEvent": "captain_hook.events",
@@ -167,6 +168,8 @@ EXPORTS: dict[str, str] = {
167
168
  "Rewrite": "captain_hook.testing.types",
168
169
  "TranscriptFixture": "captain_hook.testing.types",
169
170
  "Warn": "captain_hook.testing.types",
171
+ "CLAUDE_EVENTS": "captain_hook.types",
172
+ "HOST_EVENTS": "captain_hook.types",
170
173
  "Action": "captain_hook.types",
171
174
  "Agent": "captain_hook.types",
172
175
  "And": "captain_hook.types",
@@ -81,6 +81,7 @@ from captain_hook.events import PostToolUseEvent as PostToolUseEvent
81
81
  from captain_hook.events import PostToolUseFailureEvent as PostToolUseFailureEvent
82
82
  from captain_hook.events import PreCompactEvent as PreCompactEvent
83
83
  from captain_hook.events import PreToolUseEvent as PreToolUseEvent
84
+ from captain_hook.events import ResourcePressureEvent as ResourcePressureEvent
84
85
  from captain_hook.events import SessionCron as SessionCron
85
86
  from captain_hook.events import SessionEndEvent as SessionEndEvent
86
87
  from captain_hook.events import SessionStartEvent as SessionStartEvent
@@ -163,6 +164,8 @@ from captain_hook.testing.types import Warn as Warn
163
164
  from captain_hook.transcripts import register_transcript as register_transcript
164
165
  from captain_hook.transcripts import registered_paths as registered_paths
165
166
  from captain_hook.turn import Turn as Turn
167
+ from captain_hook.types import CLAUDE_EVENTS as CLAUDE_EVENTS
168
+ from captain_hook.types import HOST_EVENTS as HOST_EVENTS
166
169
  from captain_hook.types import Action as Action
167
170
  from captain_hook.types import Agent as Agent
168
171
  from captain_hook.types import And as And
@@ -0,0 +1,270 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ from itertools import takewhile
5
+ from pathlib import PurePath
6
+ from signal import SIGKILL, SIGTERM, Signals
7
+ from typing import TYPE_CHECKING, Any
8
+
9
+ from pydantic import ValidationError
10
+
11
+ from captain_hook import (
12
+ Allow,
13
+ BaseHookEvent,
14
+ Block,
15
+ Event,
16
+ HookResult,
17
+ Input,
18
+ LambdaCondition,
19
+ ResourcePressureEvent,
20
+ Warn,
21
+ on,
22
+ )
23
+ from captain_hook.procwatch import judge, screen
24
+ from captain_hook.procwatch.identity import ProcessIdentity
25
+ from captain_hook.procwatch.ownership import Owned, prove
26
+ from captain_hook.procwatch.settings import PerformanceSettings
27
+ from captain_hook.procwatch.signal import Outcome, terminate
28
+ from captain_hook.procwatch.state import (
29
+ Notice,
30
+ ProcwatchState,
31
+ StateUnavailable,
32
+ announce,
33
+ pending_notice,
34
+ record_notice,
35
+ record_refusal,
36
+ record_signal,
37
+ signaled,
38
+ take_pending,
39
+ )
40
+ from captain_hook.util import proc
41
+ from captain_hook.util.proc import Unreadable
42
+
43
+ if TYPE_CHECKING:
44
+ from collections.abc import Callable
45
+
46
+ UID = os.getuid()
47
+ CLAUDE_START = 1790845800
48
+ CHILD_START = 1790846401
49
+ TABLE = (
50
+ " 1 0 1 0 Thu Oct 1 09:00:00 2026 /sbin/launchd\n"
51
+ f" 500 1 500 {UID:>5} Thu Oct 1 09:10:00 2026 claude --effort xhigh\n"
52
+ f" 600 500 600 {UID:>5} Thu Oct 1 09:20:00 2026 /bin/zsh -c rg -n TODO .\n"
53
+ f" 601 600 600 {UID:>5} Thu Oct 1 09:20:01 2026 rg -n TODO .\n"
54
+ f" 700 500 700 {UID:>5} Thu Oct 1 09:20:00 2026 /bin/zsh -c ./deploy.sh production\n"
55
+ f" 701 700 700 {UID:>5} Thu Oct 1 09:20:01 2026 node build.js\n"
56
+ f" 800 500 800 {UID:>5} Thu Oct 1 09:20:00 2026 claude -p review\n"
57
+ f" 801 800 800 {UID:>5} Thu Oct 1 09:20:01 2026 rg -n TODO .\n"
58
+ f" 900 500 900 {UID:>5} Thu Oct 1 09:20:01 2026 /bin/zsh -c tmux new -d\n"
59
+ f" 901 900 901 {UID:>5} Thu Oct 1 09:20:01 2026 tmux new -d\n"
60
+ )
61
+ LIVE = {"ps -A -ww -o": TABLE}
62
+ FRESH = [ProcwatchState()]
63
+ NO_LIVE = {"CAPT_HOOK_TEST_NO_LIVE": "1"}
64
+ CHILDREN = {
65
+ 601: (600, 600, ["rg", "-n", "TODO", "."]),
66
+ 701: (700, 700, ["node", "build.js"]),
67
+ 801: (800, 800, ["rg", "-n", "TODO", "."]),
68
+ 900: (500, 900, ["/bin/zsh", "-c", "tmux", "new", "-d"]),
69
+ }
70
+ PENDING = Notice(id="n1", text="`rg` (pid 601) has run 3 min at 95% CPU.")
71
+
72
+
73
+ def pressure_payload(stage: str, pid: int, *, start_unix: int = CHILD_START) -> dict[str, Any]:
74
+ ppid, pgid, argv = CHILDREN[pid]
75
+ return {
76
+ "hook_event_name": "ResourcePressure",
77
+ "session_id": "fixture",
78
+ "stage": stage,
79
+ "claude_pid": 500,
80
+ "claude_start_unix": CLAUDE_START,
81
+ "process": {
82
+ "pid": pid,
83
+ "ppid": ppid,
84
+ "pgid": pgid,
85
+ "start_unix": start_unix,
86
+ "start_usec": 0,
87
+ "comm": argv[0],
88
+ "argv": argv,
89
+ "cwd": "/w",
90
+ "runtime_s": 180.0,
91
+ "cpu_fraction": 0.95,
92
+ "disk_bps": 0.0,
93
+ "ancestry": [],
94
+ },
95
+ "metrics": {"cpu": True, "disk": False},
96
+ }
97
+
98
+
99
+ def program(evt: ResourcePressureEvent, identity: ProcessIdentity) -> str:
100
+ return (PurePath(identity.argv[0]).name if identity.argv else evt.comm)[:40]
101
+
102
+
103
+ def refuse(evt: ResourcePressureEvent, identity: ProcessIdentity, reason: str) -> HookResult:
104
+ record_refusal(evt, identity.key, text := screen.redact(f"Resource monitor left pid {evt.pid} running: {reason}"))
105
+ return evt.block(text)
106
+
107
+
108
+ def vet(evt: ResourcePressureEvent, identity: ProcessIdentity) -> Owned | Unreadable:
109
+ if (table := proc.process_table()) is None:
110
+ return Unreadable("the process table is unreadable.")
111
+ match prove(table, identity, claude_pid=evt.claude_pid, claude_start_unix=evt.claude_start_unix):
112
+ case Owned(ancestry=ancestry) as owned:
113
+ parents = takewhile(lambda entry: entry.pid != evt.claude_pid, ancestry)
114
+ if (why := screen.excluded([identity.command, *(entry.command for entry in parents)])) is not None:
115
+ return Unreadable(f"its command line {why}.")
116
+ return owned
117
+ case refused:
118
+ return refused
119
+
120
+
121
+ def recheck(evt: ResourcePressureEvent, identity: ProcessIdentity) -> Callable[[], Unreadable | None]:
122
+ return lambda: verdict if isinstance(verdict := vet(evt, identity), Unreadable) else None
123
+
124
+
125
+ def warning(evt: ResourcePressureEvent, identity: ProcessIdentity, settings: PerformanceSettings) -> str:
126
+ usage = " and ".join(
127
+ [
128
+ *([f"{evt.cpu_fraction:.0%} CPU"] if evt.cpu_fraction is not None else []),
129
+ *([f"{evt.disk_bps / 1_048_576:.0f} MB/s disk"] if evt.disk_bps is not None else []),
130
+ ]
131
+ )
132
+ minutes = f"{evt.runtime_s / 60:.0f} min"
133
+ head = f"`{program(evt, identity)}` (pid {evt.pid}) has run {minutes} at {usage or 'heavy load'}."
134
+ if settings.terminate:
135
+ return (
136
+ f"{head} It is stopped in {settings.grace_seconds} s if a small model rates it disposable; "
137
+ "set `HOOKS_PERFORMANCE_TERMINATE=false` to only warn."
138
+ )
139
+ return f"{head} Termination is off, so it runs until it finishes or you stop it."
140
+
141
+
142
+ def report(evt: ResourcePressureEvent, identity: ProcessIdentity, sig: Signals, outcome: Outcome) -> HookResult:
143
+ if not outcome.signaled:
144
+ return refuse(evt, identity, f"{outcome.reason}.")
145
+ text = f"Resource monitor sent {sig.name} to `{program(evt, identity)}` (pid {evt.pid}) after its grace period."
146
+ record_signal(evt, identity.key, sig, text)
147
+ announce("Resource monitor stopped a process", text)
148
+ return evt.warn(screen.redact(text))
149
+
150
+
151
+ def send(evt: ResourcePressureEvent, identity: ProcessIdentity, sig: Signals) -> HookResult:
152
+ return report(evt, identity, sig, terminate(identity, sig, recheck=recheck(evt, identity)))
153
+
154
+
155
+ def warn_stage(evt: ResourcePressureEvent, identity: ProcessIdentity, settings: PerformanceSettings) -> HookResult:
156
+ if isinstance(verdict := vet(evt, identity), Unreadable):
157
+ return refuse(evt, identity, verdict.reason)
158
+ record_notice(evt, text := screen.redact(warning(evt, identity, settings)))
159
+ announce("Resource-heavy process", text)
160
+ return evt.warn(text)
161
+
162
+
163
+ def judge_stage(evt: ResourcePressureEvent, identity: ProcessIdentity, settings: PerformanceSettings) -> HookResult:
164
+ if isinstance(verdict := vet(evt, identity), Unreadable):
165
+ return refuse(evt, identity, verdict.reason)
166
+ if not settings.terminate:
167
+ return refuse(evt, identity, "termination is off.")
168
+ if signaled(evt, identity.key, SIGTERM):
169
+ return evt.block(f"Resource monitor already sent SIGTERM to pid {evt.pid}, so it does not judge it again.")
170
+ match judge.disposable(evt, settings, identity, judge.JudgeFacts.of(evt, identity, verdict)):
171
+ case Unreadable(reason=reason):
172
+ return refuse(evt, identity, reason)
173
+ case False:
174
+ return refuse(evt, identity, "a small model did not rate it disposable.")
175
+ case True:
176
+ return send(evt, identity, SIGTERM)
177
+
178
+
179
+ def escalate_stage(evt: ResourcePressureEvent, identity: ProcessIdentity, settings: PerformanceSettings) -> HookResult:
180
+ if not signaled(evt, identity.key, SIGTERM):
181
+ return evt.block(f"Resource monitor never sent SIGTERM to pid {evt.pid}, so it does not escalate.")
182
+ if settings.escalate_after_seconds <= 0:
183
+ return refuse(evt, identity, "escalation is off.")
184
+ if isinstance(verdict := vet(evt, identity), Unreadable):
185
+ return refuse(evt, identity, verdict.reason)
186
+ return send(evt, identity, SIGKILL)
187
+
188
+
189
+ STAGES = {"warn": warn_stage, "judge": judge_stage, "escalate": escalate_stage}
190
+
191
+
192
+ @on(
193
+ Event.ResourcePressure,
194
+ skip_planning_agents=False,
195
+ tests={
196
+ Input(tool_input=pressure_payload("warn", 601), commands=LIVE, env=NO_LIVE, state=FRESH): Warn(
197
+ pattern=r"pid 601\) has run 3 min at 95% CPU"
198
+ ),
199
+ Input(tool_input=pressure_payload("warn", 701), commands=LIVE, env=NO_LIVE, state=FRESH): Block(
200
+ pattern="deploy, release, or publish"
201
+ ),
202
+ Input(tool_input=pressure_payload("warn", 900), commands=LIVE, env=NO_LIVE, state=FRESH): Block(
203
+ pattern="terminal multiplexer"
204
+ ),
205
+ Input(tool_input=pressure_payload("warn", 801), commands=LIVE, env=NO_LIVE, state=FRESH): Block(
206
+ pattern="nested agent"
207
+ ),
208
+ Input(
209
+ tool_input=pressure_payload("warn", 601, start_unix=CHILD_START - 1),
210
+ commands=LIVE,
211
+ env=NO_LIVE,
212
+ state=FRESH,
213
+ ): Block(pattern="reused"),
214
+ Input(tool_input=pressure_payload("warn", 601), commands=LIVE, env=NO_LIVE): Block(
215
+ pattern="no state directory"
216
+ ),
217
+ Input(
218
+ tool_input=pressure_payload("judge", 601),
219
+ commands=LIVE,
220
+ env=NO_LIVE,
221
+ state=FRESH,
222
+ llm={"disposable": False},
223
+ ): Block(pattern="did not rate it disposable"),
224
+ Input(
225
+ tool_input=pressure_payload("judge", 601),
226
+ commands=LIVE,
227
+ env=NO_LIVE,
228
+ state=[ProcwatchState(judging=[f"601:{CHILD_START}"], judge_calls=1)],
229
+ llm={"disposable": True},
230
+ ): Block(pattern="already in flight"),
231
+ Input(
232
+ tool_input=pressure_payload("judge", 601),
233
+ commands=LIVE,
234
+ env=NO_LIVE,
235
+ state=FRESH,
236
+ llm={"disposable": True},
237
+ ): Block(pattern="disabled under test"),
238
+ Input(tool_input=pressure_payload("escalate", 601), commands=LIVE, env=NO_LIVE, state=FRESH): Block(
239
+ pattern="never sent SIGTERM"
240
+ ),
241
+ },
242
+ )
243
+ def pressure(evt: ResourcePressureEvent) -> HookResult:
244
+ try:
245
+ settings = PerformanceSettings()
246
+ except ValidationError:
247
+ return evt.block("Resource monitor settings are invalid; fix the `HOOKS_PERFORMANCE_*` values to re-enable it.")
248
+ if not settings.enabled:
249
+ return evt.block("Resource monitor is off; set `HOOKS_PERFORMANCE_ENABLED=true` to turn it on.")
250
+ identity = ProcessIdentity.from_payload(evt.process)
251
+ try:
252
+ return STAGES[evt.stage](evt, identity, settings)
253
+ except StateUnavailable as exc:
254
+ return evt.block(f"Resource monitor left pid {evt.pid} running: {exc.reason}")
255
+
256
+
257
+ @on(
258
+ Event.PreToolUse | Event.PostToolUse | Event.UserPromptSubmit,
259
+ only_if=[LambdaCondition(pending_notice)],
260
+ tests={
261
+ Input(command="ls", state=[ProcwatchState(pending=[PENDING])]): Warn(system_message="pid 601"),
262
+ Input(command="ls", state=[ProcwatchState(pending=[PENDING], delivered=["n1"])]): Allow(),
263
+ Input(command="ls"): Allow(),
264
+ },
265
+ )
266
+ def deliver(evt: BaseHookEvent) -> HookResult | None:
267
+ if not (notices := take_pending(evt)):
268
+ return None
269
+ text = "\n\n".join(notice.text for notice in notices)
270
+ return evt.context(text, system_message=text)
@@ -38,7 +38,7 @@ from captain_hook.pause import pause, resume
38
38
  from captain_hook.review.cli import review
39
39
  from captain_hook.review.pipeline import DISPATCH_EVENTS, dispatch_review
40
40
  from captain_hook.session import SessionStore, cleanup_stale, ensure_session
41
- from captain_hook.types import TOOL_EVENTS, Event
41
+ from captain_hook.types import HOST_EVENTS, TOOL_EVENTS, Event
42
42
  from captain_hook.update.cli import update
43
43
  from captain_hook.update.launchers import dispatch_launcher_check
44
44
  from captain_hook.update.updater import dispatch_update
@@ -367,6 +367,12 @@ def run_event(state: CliState, event_name: str) -> None:
367
367
  file=sys.stderr,
368
368
  )
369
369
  sys.exit(1)
370
+ if event in HOST_EVENTS:
371
+ print(
372
+ f"{event_name} is a host event: only the capt-hookd host raises it, so `capt-hook run` refuses it.",
373
+ file=sys.stderr,
374
+ )
375
+ sys.exit(1)
370
376
 
371
377
  raw_text = sys.stdin.read()
372
378
  if not raw_text.strip():
@@ -86,6 +86,36 @@ def remember_model_rejection(specialty: str, model: str, exc: BaseException, bac
86
86
  UNSUPPORTED_MODELS[(specialty, model)] = ModelRejection(backend.provider, resolved, str(exc))
87
87
 
88
88
 
89
+ def run_spec(
90
+ prompt: str,
91
+ backend: LlmBackend,
92
+ model: TModel,
93
+ response_model: type[BaseModel] | None,
94
+ *,
95
+ agent: bool,
96
+ cwd: str | None,
97
+ timeout: int,
98
+ attempts: int | None,
99
+ tools: tuple[str, ...] | None,
100
+ ) -> str | BaseModel:
101
+ from spawnllm import ClaudeConfig, RunSpec, run_sync
102
+
103
+ spec = RunSpec(
104
+ prompt=prompt,
105
+ model=backend.resolve_model(model),
106
+ response_model=response_model,
107
+ agent=agent,
108
+ cwd=cwd,
109
+ timeout=timeout,
110
+ provider_configs={} if tools is None else {"claude": ClaudeConfig(tools=tools)},
111
+ **({} if attempts is None else {"max_attempts": attempts}),
112
+ )
113
+ resp = run_sync(spec, backend=backend)
114
+ if resp.error is not None:
115
+ raise resp.error.ex
116
+ return resp.result.raw if response_model is None else resp.result.parsed
117
+
118
+
89
119
  def transcript_window(transcript: bool | int | Literal["recent", "full"]) -> int | None:
90
120
  match transcript:
91
121
  case "full":
@@ -409,6 +439,9 @@ class HookContext:
409
439
  diff: bool | str = False,
410
440
  agent: bool = False,
411
441
  backend: LlmBackend | None = None,
442
+ attempts: int | None = None,
443
+ tools: tuple[str, ...] | None = None,
444
+ evidence: bool = True,
412
445
  response_model: type[M],
413
446
  **kwargs: Any,
414
447
  ) -> M: ...
@@ -427,6 +460,9 @@ class HookContext:
427
460
  diff: bool | str = False,
428
461
  agent: bool = False,
429
462
  backend: LlmBackend | None = None,
463
+ attempts: int | None = None,
464
+ tools: tuple[str, ...] | None = None,
465
+ evidence: bool = True,
430
466
  response_model: None = None,
431
467
  **kwargs: Any,
432
468
  ) -> str: ...
@@ -444,13 +480,28 @@ class HookContext:
444
480
  diff: bool | str = False,
445
481
  agent: bool = False,
446
482
  backend: LlmBackend | None = None,
483
+ attempts: int | None = None,
484
+ tools: tuple[str, ...] | None = None,
485
+ evidence: bool = True,
447
486
  response_model: type[BaseModel] | None = None,
448
487
  **kwargs: Any,
449
488
  ) -> str | BaseModel:
489
+ """Ask the selected backend once the request's deadline still has room, clamping the call's timeout to it.
490
+
491
+ ``attempts`` caps the provider attempts spawnllm makes for one call and ``tools`` names the
492
+ built-in tools the model may use (``()`` for none); either one routes the call through a
493
+ :class:`spawnllm.RunSpec` of its own, and ``None`` keeps spawnllm's defaults. A deadline
494
+ already passed once the backend is selected raises ``TimeoutError`` without a provider call.
495
+ ``evidence=False`` records no transcript evidence for the call, so the session transcript is
496
+ never resolved: the lane for a prompt built from no transcript at all, such as a host event's.
497
+ """
450
498
  from spawnllm import BackendCallError, call_sync, extract_sync
451
499
 
452
500
  reqenv.checkpoint()
453
501
  serving = backend or ready_backend(specialty, model)
502
+ reqenv.checkpoint()
503
+ if reqenv.deadline_within(0):
504
+ raise TimeoutError("the caller deadline passed before the model call")
454
505
  with UNSUPPORTED_MODELS_LOCK:
455
506
  rejection = UNSUPPORTED_MODELS.get((specialty, model))
456
507
  if rejection is not None:
@@ -462,10 +513,23 @@ class HookContext:
462
513
  prompt = self.assemble_prompt(
463
514
  template, args, kwargs, transcript=transcript, tool_results=tool_results, budget=budget, diff_text=diff_text
464
515
  )
465
- self.release_preparation(prompt)
516
+ if evidence:
517
+ self.release_preparation(prompt)
466
518
  cwd = resolve_project_dir()
467
519
  timeout = reqenv.clamp_timeout(timeout)
468
520
  try:
521
+ if attempts is not None or tools is not None:
522
+ return run_spec(
523
+ prompt,
524
+ serving,
525
+ model,
526
+ response_model,
527
+ agent=agent,
528
+ cwd=cwd,
529
+ timeout=timeout,
530
+ attempts=attempts,
531
+ tools=tools,
532
+ )
469
533
  if response_model is not None:
470
534
  return extract_sync(
471
535
  prompt,
@@ -19,6 +19,9 @@ from contextvars import ContextVar
19
19
  from dataclasses import dataclass, field
20
20
  from typing import TYPE_CHECKING, Protocol
21
21
 
22
+ if TYPE_CHECKING:
23
+ import threading
24
+
22
25
  from loguru import logger
23
26
 
24
27
  from captain_hook.util import reqenv
@@ -47,6 +50,9 @@ class RequestContext(Protocol):
47
50
  @property
48
51
  def deadline_unix_ms(self) -> int: ...
49
52
 
53
+ @property
54
+ def abandon(self) -> threading.Event: ...
55
+
50
56
 
51
57
  @dataclass(slots=True)
52
58
  class RequestBuffers:
@@ -70,6 +76,7 @@ def request_scope(req: RequestContext, session_id: str | None) -> Generator[Requ
70
76
  client_ppid=req.client.ppid,
71
77
  session_id=sid,
72
78
  deadline_unix_ms=req.deadline_unix_ms,
79
+ abandon=req.abandon,
73
80
  )
74
81
  with reqenv.use_request(overrides):
75
82
  session_log_path = str(resolve_log_dir() / f"{sid}.log")
@@ -457,8 +457,12 @@ def format_output(event: Event, result: HookResult) -> Envelope | None:
457
457
 
458
458
  Every event takes a JSON envelope except ``PreCompact``, whose schema has no
459
459
  ``hookSpecificOutput``: Claude Code appends each successful hook's raw trimmed stdout to the
460
- compaction's custom instructions, so a non-block result renders as its plain message.
460
+ compaction's custom instructions, so a non-block result renders as its plain message. The host-fired
461
+ ``ResourcePressure`` takes only the proceed acknowledgement capt-hookd parses: a warn or allow renders it,
462
+ anything else renders nothing.
461
463
  """
464
+ if event is Event.ResourcePressure:
465
+ return {"decision": "proceed"} if result.action in (Action.warn, Action.allow) else None
462
466
  if event in (Event.Stop | Event.SubagentStop):
463
467
  return {"decision": "block", "reason": result.message} if result.action is not Action.allow else None
464
468
  if event is Event.PreCompact:
@@ -932,3 +932,87 @@ class SessionEndEvent(BaseHookEvent):
932
932
  @property
933
933
  def reason(self) -> str:
934
934
  return self._raw["reason"]
935
+
936
+
937
+ @dataclass
938
+ class ResourcePressureEvent(BaseHookEvent):
939
+ """Fired by the capt-hookd host, not Claude Code, when a session's child process stays resource-heavy.
940
+
941
+ ``stage`` is ``"warn"`` on the first sustained sample, ``"judge"`` once the grace period lapses with the
942
+ child still heavy, and ``"escalate"`` when the child outlives a ``SIGTERM``. ``process`` carries the
943
+ child's identity (``pid``, ``start_unix``, ``argv``, ``cwd``) and usage; ``metrics`` marks which usage
944
+ readings were available. Only the warn stage's reply is read: a warn or allow acknowledges it, and any
945
+ other result makes the host stop tracking the child. The judge and escalate replies are not read.
946
+
947
+ The host tracks the child by its pid and sub-second start time at every tick and reads the argv vector it
948
+ sends fresh at each stage dispatch. The worker verifies again right before a signal with what ``ps``
949
+ exposes: the parent and group ids, the whole-second start time, the working directory, and the
950
+ whitespace-normalized joined command text, which is not the argv vector, so two argument vectors that
951
+ join to the same text compare equal there.
952
+ """
953
+
954
+ event_name: ClassVar[Event] = Event.ResourcePressure
955
+
956
+ @property
957
+ def stage(self) -> Literal["warn", "judge", "escalate"]:
958
+ return self._raw["stage"]
959
+
960
+ @property
961
+ def process(self) -> Mapping[str, object]:
962
+ return self._raw["process"]
963
+
964
+ @property
965
+ def pid(self) -> int:
966
+ return self._raw["process"]["pid"]
967
+
968
+ @property
969
+ def ppid(self) -> int:
970
+ return self._raw["process"]["ppid"]
971
+
972
+ @property
973
+ def pgid(self) -> int:
974
+ return self._raw["process"]["pgid"]
975
+
976
+ @property
977
+ def start_unix(self) -> int:
978
+ return self._raw["process"]["start_unix"]
979
+
980
+ @property
981
+ def start_usec(self) -> int:
982
+ return self._raw["process"]["start_usec"]
983
+
984
+ @property
985
+ def comm(self) -> str:
986
+ return self._raw["process"]["comm"]
987
+
988
+ @property
989
+ def argv(self) -> tuple[str, ...]:
990
+ return tuple(self._raw["process"]["argv"])
991
+
992
+ @property
993
+ def process_cwd(self) -> str | None:
994
+ return self._raw["process"].get("cwd")
995
+
996
+ @property
997
+ def runtime_s(self) -> float:
998
+ return self._raw["process"]["runtime_s"]
999
+
1000
+ @property
1001
+ def cpu_fraction(self) -> float | None:
1002
+ return self._raw["process"]["cpu_fraction"] if self.metrics["cpu"] else None
1003
+
1004
+ @property
1005
+ def disk_bps(self) -> float | None:
1006
+ return self._raw["process"]["disk_bps"] if self.metrics["disk"] else None
1007
+
1008
+ @property
1009
+ def metrics(self) -> Mapping[str, bool]:
1010
+ return self._raw["metrics"]
1011
+
1012
+ @property
1013
+ def claude_pid(self) -> int:
1014
+ return self._raw["claude_pid"]
1015
+
1016
+ @property
1017
+ def claude_start_unix(self) -> int:
1018
+ return self._raw["claude_start_unix"]