capt-hook 0.2.0__py3-none-any.whl
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.
- capt_hook-0.2.0.dist-info/METADATA +113 -0
- capt_hook-0.2.0.dist-info/RECORD +57 -0
- capt_hook-0.2.0.dist-info/WHEEL +4 -0
- capt_hook-0.2.0.dist-info/entry_points.txt +3 -0
- capt_hook-0.2.0.dist-info/licenses/LICENSE +73 -0
- captain_hook/__init__.py +246 -0
- captain_hook/__main__.py +6 -0
- captain_hook/app.py +278 -0
- captain_hook/classifiers/__init__.py +30 -0
- captain_hook/classifiers/conductor.py +35 -0
- captain_hook/classifiers/droid.py +20 -0
- captain_hook/classifiers/native.py +19 -0
- captain_hook/cli.py +341 -0
- captain_hook/command.py +356 -0
- captain_hook/conditions.py +136 -0
- captain_hook/context.py +161 -0
- captain_hook/dispatch.py +107 -0
- captain_hook/events.py +318 -0
- captain_hook/file.py +120 -0
- captain_hook/llm/__init__.py +9 -0
- captain_hook/llm/backends.py +152 -0
- captain_hook/loader.py +62 -0
- captain_hook/log.py +60 -0
- captain_hook/primitives/__init__.py +51 -0
- captain_hook/primitives/audit.py +71 -0
- captain_hook/primitives/commands.py +61 -0
- captain_hook/primitives/lint.py +216 -0
- captain_hook/primitives/llm.py +376 -0
- captain_hook/primitives/nudge.py +95 -0
- captain_hook/prompt.py +103 -0
- captain_hook/py.typed +1 -0
- captain_hook/session.py +158 -0
- captain_hook/settings.py +120 -0
- captain_hook/signals/__init__.py +86 -0
- captain_hook/signals/nlp.py +105 -0
- captain_hook/state.py +221 -0
- captain_hook/styleguide/__init__.py +183 -0
- captain_hook/styleguide/query.py +238 -0
- captain_hook/styleguide/scope.py +46 -0
- captain_hook/styleguide/types.py +70 -0
- captain_hook/tasks.py +112 -0
- captain_hook/templates/example_hook.py.tmpl +85 -0
- captain_hook/testing/__init__.py +10 -0
- captain_hook/testing/helpers.py +392 -0
- captain_hook/testing/session_cache.py +50 -0
- captain_hook/testing/types.py +88 -0
- captain_hook/tests/__init__.py +27 -0
- captain_hook/tests/helpers.py +361 -0
- captain_hook/tools.py +59 -0
- captain_hook/transcript/__init__.py +572 -0
- captain_hook/transcript/inputs.py +226 -0
- captain_hook/transcript/models.py +186 -0
- captain_hook/types.py +381 -0
- captain_hook/util/__init__.py +0 -0
- captain_hook/util/model_cache.py +87 -0
- captain_hook/utils.py +27 -0
- captain_hook/workflow.py +119 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: capt-hook
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Declarative hook framework for Claude Code
|
|
5
|
+
Keywords: claude,claude-code,hooks,llm,agents,guardrails,cli
|
|
6
|
+
Author: Yasyf Mohamedali
|
|
7
|
+
Author-email: Yasyf Mohamedali <yasyfm@gmail.com>
|
|
8
|
+
License-Expression: PolyForm-Noncommercial-1.0.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
18
|
+
Classifier: Topic :: Software Development :: Testing
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Dist: pydantic>=2.0
|
|
21
|
+
Requires-Dist: pydantic-settings>=2.0
|
|
22
|
+
Requires-Dist: tree-sitter>=0.24
|
|
23
|
+
Requires-Dist: tree-sitter-bash>=0.23
|
|
24
|
+
Requires-Dist: funcy>=2.0
|
|
25
|
+
Requires-Dist: spacy>=3.7
|
|
26
|
+
Requires-Dist: click>=8
|
|
27
|
+
Requires-Dist: orjsonl>=1.0
|
|
28
|
+
Requires-Dist: wn>=1.1.0
|
|
29
|
+
Requires-Dist: lazy-object-proxy>=1.12.0
|
|
30
|
+
Requires-Dist: filelock>=3
|
|
31
|
+
Requires-Dist: loguru>=0.7.3
|
|
32
|
+
Requires-Dist: pytest>=8.0 ; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest-asyncio>=0.24 ; extra == 'dev'
|
|
34
|
+
Requires-Dist: pyright>=1.1 ; extra == 'dev'
|
|
35
|
+
Requires-Dist: ruff>=0.8 ; extra == 'dev'
|
|
36
|
+
Requires-Python: >=3.12
|
|
37
|
+
Project-URL: Homepage, https://github.com/yasyf/captain-hook
|
|
38
|
+
Project-URL: Documentation, https://captain-hook.readthedocs.io
|
|
39
|
+
Project-URL: Repository, https://github.com/yasyf/captain-hook
|
|
40
|
+
Project-URL: Issues, https://github.com/yasyf/captain-hook/issues
|
|
41
|
+
Project-URL: Changelog, https://github.com/yasyf/captain-hook/blob/main/CHANGELOG.md
|
|
42
|
+
Provides-Extra: dev
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
|
|
45
|
+
# captain-hook
|
|
46
|
+
|
|
47
|
+
[](https://pypi.org/project/capt-hook/)
|
|
48
|
+
[](https://pypi.org/project/capt-hook/)
|
|
49
|
+
[](https://captain-hook.readthedocs.io)
|
|
50
|
+
[](https://github.com/yasyf/captain-hook/blob/main/LICENSE)
|
|
51
|
+
|
|
52
|
+
Declarative hook framework for Claude Code. Write hooks as data, test them inline, and ship them to CI in the same shape they run in production.
|
|
53
|
+
|
|
54
|
+
## Install
|
|
55
|
+
|
|
56
|
+
No install needed — run everything through [uvx](https://docs.astral.sh/uv/):
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
uvx capt-hook init
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`uvx` fetches captain-hook into a throwaway environment and runs it, so you never add it to `pyproject.toml`. Every command below works the same way: prefix it with `uvx`.
|
|
63
|
+
|
|
64
|
+
## First hook
|
|
65
|
+
|
|
66
|
+
Scaffold a project and drop a hook into `.claude/hooks/`:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
uvx capt-hook init
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
# .claude/hooks/my_first.py
|
|
74
|
+
from captain_hook import Allow, Block, Input, block_command
|
|
75
|
+
|
|
76
|
+
block_command(
|
|
77
|
+
["git", "stash"],
|
|
78
|
+
reason="Use the team's VCS workflow for shelving changes",
|
|
79
|
+
hint="Commit a WIP change instead of stashing",
|
|
80
|
+
tests={
|
|
81
|
+
Input(command="git stash"): Block(),
|
|
82
|
+
Input(command="git stash pop"): Block(),
|
|
83
|
+
Input(command="git status"): Allow(),
|
|
84
|
+
},
|
|
85
|
+
)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Run the inline tests (from your project root, `--hooks` defaults to `.claude/hooks`):
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
capt-hook test
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Wire the hook into Claude Code's settings:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
capt-hook generate-settings > .claude/settings.local.json
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The next time Claude tries `git stash`, captain-hook returns a deny with your reason and hint.
|
|
101
|
+
|
|
102
|
+
## What problems does this solve?
|
|
103
|
+
|
|
104
|
+
- **Block dangerous tool calls** before they execute (`PreToolUse`) — force-push, package-manager footguns, raw `rm -rf`.
|
|
105
|
+
- **Drive the agent with feedback** that fires on patterns it actually emits — repeated failures, weakened tests, missed conventions.
|
|
106
|
+
- **Enforce multi-step workflows** with stop-gates and artifact validation, so the agent can't declare "done" without running tests / writing a report / completing a checklist.
|
|
107
|
+
- **Keep all of the above testable** — every hook ships with inline `tests = {...}` that `capt-hook test` runs in CI, so you catch broken hooks the same way you catch broken code.
|
|
108
|
+
|
|
109
|
+
## Docs
|
|
110
|
+
|
|
111
|
+
[Read the docs](https://captain-hook.readthedocs.io) for the full guide: conditions, primitives, LLM hooks, workflows, state, and real-world patterns.
|
|
112
|
+
|
|
113
|
+
Working on captain-hook itself? See the [development guide](https://captain-hook.readthedocs.io/en/latest/development/).
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
captain_hook/__init__.py,sha256=RL8jYrgmj2IytXDcahy5-7Fpltyb1Gn50N-Dqt4ITz4,5296
|
|
2
|
+
captain_hook/__main__.py,sha256=hEH9dZ-8Pjkvo_7R0CxrFhOqoIInJsQXBS8juX5njmA,109
|
|
3
|
+
captain_hook/app.py,sha256=MdVxSzsU4nbZKFSq5DmgygBK6djLL-F-Cv6fBT-aIVM,8280
|
|
4
|
+
captain_hook/classifiers/__init__.py,sha256=no9aueVb1xDrZm-K_m4f0nwVER1-yKcn5t39zVRxEC8,937
|
|
5
|
+
captain_hook/classifiers/conductor.py,sha256=eGLWZUVYZhBBNefGeRMyuWWYSiPjSF-957qn1boUkJw,935
|
|
6
|
+
captain_hook/classifiers/droid.py,sha256=ZOKMibF_dkz_aA0Dk6c2f-YEmNEFfkXwU7D6IrGjoKI,470
|
|
7
|
+
captain_hook/classifiers/native.py,sha256=m3BadgALOa5F27RbXfUev267vkikB-ILuhCpqlqjnQI,429
|
|
8
|
+
captain_hook/cli.py,sha256=7ab-55C1moBo4lmGRk3yuRynDOaxpI85f9UftqTH5f8,12719
|
|
9
|
+
captain_hook/command.py,sha256=VXA-nYV54TueUQHM8B360ixwldazUepl7ccFX7CnMDs,12062
|
|
10
|
+
captain_hook/conditions.py,sha256=I_YDuxar0BTIAUZf0xiE_fYQUSiL2nTUQyBtl4s8-rM,5147
|
|
11
|
+
captain_hook/context.py,sha256=eM33G-3cXy1ADM0WM0enLexfLeW6DoI86mpvmfy5-xM,5329
|
|
12
|
+
captain_hook/dispatch.py,sha256=ApA7lpfbHCjTBbwNmeAmL0kcC9UIQj5maM4qFa05IIg,3682
|
|
13
|
+
captain_hook/events.py,sha256=IO2qIw0x5egR9rKPmWtYCmrBbxQNXFU_6eK3SgJxcYI,9178
|
|
14
|
+
captain_hook/file.py,sha256=Ra5GIQAtX1E1SzJeL6MBSjCX1DvmOU7ElbeFYZ7_b-s,3703
|
|
15
|
+
captain_hook/llm/__init__.py,sha256=qP68o812YaLw9f7zuw6EzeqSoiMP260XsPX_xHNI58s,489
|
|
16
|
+
captain_hook/llm/backends.py,sha256=QVPuBbYqkgS4x7_iGY-dqR34Z2Ny1yXWROrb8RO_cCA,5153
|
|
17
|
+
captain_hook/loader.py,sha256=ARQg4QioeSM_qaMfIWJLCN4gn1Pkl8p7kU4JIDYYp-k,2050
|
|
18
|
+
captain_hook/log.py,sha256=K6zoMG4GlwZxSjUeFhzU7zcJD20cLogdGnSqT_HRo-4,2041
|
|
19
|
+
captain_hook/primitives/__init__.py,sha256=pHZJx8o76AcAFvbjD1RUyutHrJGWUes8YGVCZFikEH0,1452
|
|
20
|
+
captain_hook/primitives/audit.py,sha256=Am4QaRNAUltJmZDd5EYrUxpb-jgjJ3s2loSFUCjhwZg,2690
|
|
21
|
+
captain_hook/primitives/commands.py,sha256=tIrjj0ZP8mJDRlNLHGXPofWXdvWDdAz4D0T-wAYqiOA,1997
|
|
22
|
+
captain_hook/primitives/lint.py,sha256=j_-KSx1xdAz3jvCizLAm2REmvPYtYoyYUyCy9y-5uQo,6036
|
|
23
|
+
captain_hook/primitives/llm.py,sha256=3Sj1Y8ucHXWvgIGJ1AedMQh7M_-Tcg0_bwdMG7Z-04I,11630
|
|
24
|
+
captain_hook/primitives/nudge.py,sha256=kcNd21q33PtEsdo8dUVWlZIxYCcHM1H2xJg0TXbn1F0,3080
|
|
25
|
+
captain_hook/prompt.py,sha256=IWAiwO7p_gvqmSlyduO1zRDJ7U6ehuRx_V-9QQBeV2M,3856
|
|
26
|
+
captain_hook/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
27
|
+
captain_hook/session.py,sha256=TcKWUBgPCkL-7hjusj9gLP0vzM2kouG1QKhNwuWwPHE,5168
|
|
28
|
+
captain_hook/settings.py,sha256=X4gE2q_Pn3Pk6f23pN-N_jY9UJrpm5m7ZYzlLCfSZNA,4287
|
|
29
|
+
captain_hook/signals/__init__.py,sha256=5hnfY_JIJPSUCApaELgRv6xZglqoBDe3wGHujLKup_M,2627
|
|
30
|
+
captain_hook/signals/nlp.py,sha256=VG_j_wQWRqpaf8kMpKW7HkJriElvgF9hm3_yr4VNh_4,3101
|
|
31
|
+
captain_hook/state.py,sha256=YLlVufek_znf71JwlbD14Mc_mr4ZjNzU7hJvo0tVwTo,7784
|
|
32
|
+
captain_hook/styleguide/__init__.py,sha256=bp1nMY-VHDG8m1qWw3C4WN5uulGKHnr6Xdq3xMWVJoM,5743
|
|
33
|
+
captain_hook/styleguide/query.py,sha256=FG_NeEbEpTqxZHVP4QhJx8H2RV9T1Xmqa-nDwjgKVfE,9727
|
|
34
|
+
captain_hook/styleguide/scope.py,sha256=5w63viRLmrsZtzjShT80tAxFrHGHuoec73Z91eJwegc,1512
|
|
35
|
+
captain_hook/styleguide/types.py,sha256=rvWI_nJxt_kz-gVz-bWodT4LoIt4_vxzMJXAx8hvOhE,2208
|
|
36
|
+
captain_hook/tasks.py,sha256=DsA1fuLd0mA9ijaOFFE7tUhbEgNSvzrBWazdd7N888w,3823
|
|
37
|
+
captain_hook/templates/example_hook.py.tmpl,sha256=yZ2Sv5hyPj-ImJ4B7YdpBm2YWBQyDCo2auZT-0au8iU,2528
|
|
38
|
+
captain_hook/testing/__init__.py,sha256=KkhH4Ue6mG5T1GZWgX_KiejwFfRvv7dMmIm8yTaBQxU,207
|
|
39
|
+
captain_hook/testing/helpers.py,sha256=xnsE980beW5nNBefGweDKTJE3X2IpV-TzrgWNUkFx7Y,14369
|
|
40
|
+
captain_hook/testing/session_cache.py,sha256=lwJJiPpga7fFhjq42SFPb3ZAJuqfwQDfFFTmLDzT7vs,1670
|
|
41
|
+
captain_hook/testing/types.py,sha256=vW_XeBa3Jo-U-TCCRICmheasTpa5z7zOwZ_iCUmIDFQ,2693
|
|
42
|
+
captain_hook/tests/__init__.py,sha256=aHSeWHUg6RL-gOQ5oSSLTm9Ns6VzMNCbuHB-Y9xA3jQ,556
|
|
43
|
+
captain_hook/tests/helpers.py,sha256=IH1mToIPnn9WW-CXqW1rs-VDGlgZdqVIXoRXBmd7c7A,12035
|
|
44
|
+
captain_hook/tools.py,sha256=ApuR4J55arQLB8XkgwBRQZ4-VlgA_r0XYGsUrjHammU,1870
|
|
45
|
+
captain_hook/transcript/__init__.py,sha256=tCkUuosCweaRSwUmJ8ikY7KQn7nxWi5vNl0qOZt7nGI,18372
|
|
46
|
+
captain_hook/transcript/inputs.py,sha256=f-fqnr97NrbdMHhmvXLHRNxqFDNXR0gaNKb-MGLurJ4,5851
|
|
47
|
+
captain_hook/transcript/models.py,sha256=4e42sksQWX4-MR6NqZW6qdq3dS7ycFSWAjOGB3eRzhI,5562
|
|
48
|
+
captain_hook/types.py,sha256=CMjeb3lsX7ST5NrfW5xmMMLt0n-7QF5Dw8fEEBHW_5I,10402
|
|
49
|
+
captain_hook/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
50
|
+
captain_hook/util/model_cache.py,sha256=FKTwxDgCV79T1yGr4oNGP1JbEkK6k5_L8m6uFV3vh7U,3028
|
|
51
|
+
captain_hook/utils.py,sha256=075Nmbi6gjpiIVJV3Dy9hTW66fjh9ydAB5JyENo6OCg,806
|
|
52
|
+
captain_hook/workflow.py,sha256=hCtk_DfvIAgKYFnl-K1HxORh_vEuB3eAZ1hKtrLTbY0,3935
|
|
53
|
+
capt_hook-0.2.0.dist-info/licenses/LICENSE,sha256=wOpKiW0sjDlLKflCdYmZbbgmzVAcUSJ5_w7T70j6u-U,4563
|
|
54
|
+
capt_hook-0.2.0.dist-info/WHEEL,sha256=wXwAVsgVaOZ_pwDFqQm5Rd6PID-Fc74nkLc8X8gHiDo,81
|
|
55
|
+
capt_hook-0.2.0.dist-info/entry_points.txt,sha256=DdwVxxc-bC71FAijHjN8BSXVkgdU_So2DT8IPLZDcco,53
|
|
56
|
+
capt_hook-0.2.0.dist-info/METADATA,sha256=JE_0jd8L6vf1IHp0rRs4rgNesc3t_9pjzdV02cibNcs,4496
|
|
57
|
+
capt_hook-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# PolyForm Noncommercial License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/noncommercial/1.0.0>
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
|
|
8
|
+
|
|
9
|
+
## Copyright License
|
|
10
|
+
|
|
11
|
+
The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
|
|
12
|
+
|
|
13
|
+
## Distribution License
|
|
14
|
+
|
|
15
|
+
The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
|
|
16
|
+
|
|
17
|
+
## Notices
|
|
18
|
+
|
|
19
|
+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
|
|
20
|
+
|
|
21
|
+
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
22
|
+
|
|
23
|
+
## Changes and New Works License
|
|
24
|
+
|
|
25
|
+
The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
|
|
26
|
+
|
|
27
|
+
## Patent License
|
|
28
|
+
|
|
29
|
+
The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
|
|
30
|
+
|
|
31
|
+
## Noncommercial Purposes
|
|
32
|
+
|
|
33
|
+
Any noncommercial purpose is a permitted purpose.
|
|
34
|
+
|
|
35
|
+
## Personal Uses
|
|
36
|
+
|
|
37
|
+
Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
|
|
38
|
+
|
|
39
|
+
## Noncommercial Organizations
|
|
40
|
+
|
|
41
|
+
Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
|
|
42
|
+
|
|
43
|
+
## Fair Use
|
|
44
|
+
|
|
45
|
+
You may have "fair use" rights for the software under the law. These terms do not limit them.
|
|
46
|
+
|
|
47
|
+
## No Other Rights
|
|
48
|
+
|
|
49
|
+
These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
|
|
50
|
+
|
|
51
|
+
## Patent Defense
|
|
52
|
+
|
|
53
|
+
If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
54
|
+
|
|
55
|
+
## Violations
|
|
56
|
+
|
|
57
|
+
The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
|
|
58
|
+
|
|
59
|
+
## No Liability
|
|
60
|
+
|
|
61
|
+
***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
|
|
62
|
+
|
|
63
|
+
## Definitions
|
|
64
|
+
|
|
65
|
+
The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
|
|
66
|
+
|
|
67
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
68
|
+
|
|
69
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
70
|
+
|
|
71
|
+
**Your licenses** are all the licenses granted to you for the software under these terms.
|
|
72
|
+
|
|
73
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
captain_hook/__init__.py
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from captain_hook.app import hook, on, register
|
|
4
|
+
from captain_hook.cli import generate_settings, generate_settings_json
|
|
5
|
+
from captain_hook.command import Command, CommandLine, Redirect
|
|
6
|
+
from captain_hook.context import HookContext
|
|
7
|
+
from captain_hook.events import (
|
|
8
|
+
BaseHookEvent,
|
|
9
|
+
NotificationEvent,
|
|
10
|
+
PostToolUseEvent,
|
|
11
|
+
PostToolUseFailureEvent,
|
|
12
|
+
PreCompactEvent,
|
|
13
|
+
PreToolUseEvent,
|
|
14
|
+
StopEvent,
|
|
15
|
+
SubagentStartEvent,
|
|
16
|
+
SubagentStopEvent,
|
|
17
|
+
ToolHookEvent,
|
|
18
|
+
UserPromptSubmitEvent,
|
|
19
|
+
)
|
|
20
|
+
from captain_hook.file import File, PathMatcher, categorize_files
|
|
21
|
+
from captain_hook.primitives import (
|
|
22
|
+
GateVerdict,
|
|
23
|
+
NudgeVerdict,
|
|
24
|
+
PromptCheckVerdict,
|
|
25
|
+
audit,
|
|
26
|
+
block_command,
|
|
27
|
+
diff_lint,
|
|
28
|
+
gate,
|
|
29
|
+
lint,
|
|
30
|
+
llm_gate,
|
|
31
|
+
llm_nudge,
|
|
32
|
+
nudge,
|
|
33
|
+
prompt_check,
|
|
34
|
+
session_id_for,
|
|
35
|
+
styleguide,
|
|
36
|
+
warn_command,
|
|
37
|
+
)
|
|
38
|
+
from captain_hook.primitives.llm import llm_evaluate
|
|
39
|
+
from captain_hook.prompt import Prompt, PromptMessage
|
|
40
|
+
from captain_hook.session import SessionSlot, SessionStore, session_state
|
|
41
|
+
from captain_hook.settings import AutoConf, HooksSettings, build_settings
|
|
42
|
+
from captain_hook.signals import cite_message, extract_signal_context, resolve_signals, score_signals, transcript_texts
|
|
43
|
+
from captain_hook.signals.nlp import Clause, NlpSignal, Phrase
|
|
44
|
+
from captain_hook.state import EchoTracker, HookState, PrimitiveState, workflow_state
|
|
45
|
+
from captain_hook.styleguide import StyleDiffRule, StyleRule, Violation
|
|
46
|
+
from captain_hook.tasks import Task, Tasks
|
|
47
|
+
from captain_hook.testing import Allow, Block, InlineTests, Input, TranscriptFixture, Warn
|
|
48
|
+
from captain_hook.tools import EditOp, TaskOp, WriteOp
|
|
49
|
+
from captain_hook.transcript import (
|
|
50
|
+
ToolUse,
|
|
51
|
+
ToolUseQuery,
|
|
52
|
+
ToolUseSequence,
|
|
53
|
+
Transcript,
|
|
54
|
+
TranscriptMessage,
|
|
55
|
+
TranscriptSlice,
|
|
56
|
+
Turn,
|
|
57
|
+
)
|
|
58
|
+
from captain_hook.transcript.inputs import (
|
|
59
|
+
AgentInput,
|
|
60
|
+
BashInput,
|
|
61
|
+
EditInput,
|
|
62
|
+
FileInputBase,
|
|
63
|
+
GenericInput,
|
|
64
|
+
GlobInput,
|
|
65
|
+
GrepInput,
|
|
66
|
+
InputBase,
|
|
67
|
+
ReadInput,
|
|
68
|
+
SkillInput,
|
|
69
|
+
TaskCreateInput,
|
|
70
|
+
TaskUpdateInput,
|
|
71
|
+
WriteInput,
|
|
72
|
+
parse_tool_input,
|
|
73
|
+
)
|
|
74
|
+
from captain_hook.transcript.models import (
|
|
75
|
+
ContentBlock,
|
|
76
|
+
TextBlock,
|
|
77
|
+
ToolResult,
|
|
78
|
+
ToolUseBlock,
|
|
79
|
+
parse_content_block,
|
|
80
|
+
)
|
|
81
|
+
from captain_hook.types import (
|
|
82
|
+
Action,
|
|
83
|
+
Agent,
|
|
84
|
+
Content,
|
|
85
|
+
CustomCondition,
|
|
86
|
+
Event,
|
|
87
|
+
FilePath,
|
|
88
|
+
HookResult,
|
|
89
|
+
HookSpec,
|
|
90
|
+
InPlanMode,
|
|
91
|
+
RanCommand,
|
|
92
|
+
ReadFile,
|
|
93
|
+
Signal,
|
|
94
|
+
Signals,
|
|
95
|
+
SourceEdits,
|
|
96
|
+
TCondition,
|
|
97
|
+
TestFile,
|
|
98
|
+
Tool,
|
|
99
|
+
TouchedFile,
|
|
100
|
+
UsedSkill,
|
|
101
|
+
Waiting,
|
|
102
|
+
)
|
|
103
|
+
from captain_hook.utils import read_json
|
|
104
|
+
from captain_hook.workflow import Artifact, Step, Workflow, text_matches
|
|
105
|
+
from captain_hook.workflow import workflow as workflow
|
|
106
|
+
|
|
107
|
+
__all__ = [
|
|
108
|
+
# registration
|
|
109
|
+
"hook",
|
|
110
|
+
"on",
|
|
111
|
+
"register",
|
|
112
|
+
# events
|
|
113
|
+
"Action",
|
|
114
|
+
"Agent",
|
|
115
|
+
"BaseHookEvent",
|
|
116
|
+
"Content",
|
|
117
|
+
"CustomCondition",
|
|
118
|
+
"Event",
|
|
119
|
+
"FilePath",
|
|
120
|
+
"HookResult",
|
|
121
|
+
"HookSpec",
|
|
122
|
+
"InPlanMode",
|
|
123
|
+
"NotificationEvent",
|
|
124
|
+
"PostToolUseEvent",
|
|
125
|
+
"PostToolUseFailureEvent",
|
|
126
|
+
"PreCompactEvent",
|
|
127
|
+
"PreToolUseEvent",
|
|
128
|
+
"RanCommand",
|
|
129
|
+
"ReadFile",
|
|
130
|
+
"Signal",
|
|
131
|
+
"Signals",
|
|
132
|
+
"StopEvent",
|
|
133
|
+
"SubagentStartEvent",
|
|
134
|
+
"SubagentStopEvent",
|
|
135
|
+
"TCondition",
|
|
136
|
+
"TestFile",
|
|
137
|
+
"Tool",
|
|
138
|
+
"ToolHookEvent",
|
|
139
|
+
"TouchedFile",
|
|
140
|
+
"UsedSkill",
|
|
141
|
+
"UserPromptSubmitEvent",
|
|
142
|
+
"Waiting",
|
|
143
|
+
# context
|
|
144
|
+
"HookContext",
|
|
145
|
+
"SessionSlot",
|
|
146
|
+
"SessionStore",
|
|
147
|
+
"session_state",
|
|
148
|
+
"workflow_state",
|
|
149
|
+
"EchoTracker",
|
|
150
|
+
"HookState",
|
|
151
|
+
"PrimitiveState",
|
|
152
|
+
"SourceEdits",
|
|
153
|
+
# primitives
|
|
154
|
+
"audit",
|
|
155
|
+
"block_command",
|
|
156
|
+
"diff_lint",
|
|
157
|
+
"gate",
|
|
158
|
+
"GateVerdict",
|
|
159
|
+
"lint",
|
|
160
|
+
"llm_evaluate",
|
|
161
|
+
"llm_gate",
|
|
162
|
+
"llm_nudge",
|
|
163
|
+
"nudge",
|
|
164
|
+
"NudgeVerdict",
|
|
165
|
+
"prompt_check",
|
|
166
|
+
"PromptCheckVerdict",
|
|
167
|
+
"session_id_for",
|
|
168
|
+
"StyleDiffRule",
|
|
169
|
+
"StyleRule",
|
|
170
|
+
"styleguide",
|
|
171
|
+
"Violation",
|
|
172
|
+
"warn_command",
|
|
173
|
+
# signals
|
|
174
|
+
"cite_message",
|
|
175
|
+
"extract_signal_context",
|
|
176
|
+
"resolve_signals",
|
|
177
|
+
"score_signals",
|
|
178
|
+
"transcript_texts",
|
|
179
|
+
"Clause",
|
|
180
|
+
"NlpSignal",
|
|
181
|
+
"Phrase",
|
|
182
|
+
# commands / files
|
|
183
|
+
"Command",
|
|
184
|
+
"CommandLine",
|
|
185
|
+
"File",
|
|
186
|
+
"PathMatcher",
|
|
187
|
+
"categorize_files",
|
|
188
|
+
"Redirect",
|
|
189
|
+
# prompts
|
|
190
|
+
"Prompt",
|
|
191
|
+
"PromptMessage",
|
|
192
|
+
# settings / CLI
|
|
193
|
+
"AutoConf",
|
|
194
|
+
"HooksSettings",
|
|
195
|
+
"build_settings",
|
|
196
|
+
"generate_settings",
|
|
197
|
+
"generate_settings_json",
|
|
198
|
+
"read_json",
|
|
199
|
+
# tools
|
|
200
|
+
"EditOp",
|
|
201
|
+
"TaskOp",
|
|
202
|
+
"WriteOp",
|
|
203
|
+
# tasks (native task store)
|
|
204
|
+
"Task",
|
|
205
|
+
"Tasks",
|
|
206
|
+
# transcript
|
|
207
|
+
"Transcript",
|
|
208
|
+
"TranscriptMessage",
|
|
209
|
+
"TranscriptSlice",
|
|
210
|
+
"ToolUse",
|
|
211
|
+
"ToolUseQuery",
|
|
212
|
+
"ToolUseSequence",
|
|
213
|
+
"Turn",
|
|
214
|
+
"AgentInput",
|
|
215
|
+
"BashInput",
|
|
216
|
+
"ContentBlock",
|
|
217
|
+
"EditInput",
|
|
218
|
+
"FileInputBase",
|
|
219
|
+
"GenericInput",
|
|
220
|
+
"GlobInput",
|
|
221
|
+
"GrepInput",
|
|
222
|
+
"InputBase",
|
|
223
|
+
"ReadInput",
|
|
224
|
+
"SkillInput",
|
|
225
|
+
"TaskCreateInput",
|
|
226
|
+
"TaskUpdateInput",
|
|
227
|
+
"TextBlock",
|
|
228
|
+
"ToolResult",
|
|
229
|
+
"ToolUseBlock",
|
|
230
|
+
"WriteInput",
|
|
231
|
+
"parse_content_block",
|
|
232
|
+
"parse_tool_input",
|
|
233
|
+
# workflow
|
|
234
|
+
"Artifact",
|
|
235
|
+
"Step",
|
|
236
|
+
"Workflow",
|
|
237
|
+
"text_matches",
|
|
238
|
+
"workflow",
|
|
239
|
+
# testing
|
|
240
|
+
"Allow",
|
|
241
|
+
"Block",
|
|
242
|
+
"InlineTests",
|
|
243
|
+
"Input",
|
|
244
|
+
"TranscriptFixture",
|
|
245
|
+
"Warn",
|
|
246
|
+
]
|