@r_masseater/cc-effect-hooks 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,87 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 masseater
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.
22
+
23
+ ---
24
+
25
+ @tanstack/eslint-plugin-start
26
+
27
+ MIT License
28
+
29
+ Copyright (c) 2021-present Tanner Linsley
30
+
31
+ Permission is hereby granted, free of charge, to any person obtaining a copy
32
+ of this software and associated documentation files (the "Software"), to deal
33
+ in the Software without restriction, including without limitation the rights
34
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
35
+ copies of the Software, and to permit persons to whom the Software is
36
+ furnished to do so, subject to the following conditions:
37
+
38
+ The above copyright notice and this permission notice shall be included in all
39
+ copies or substantial portions of the Software.
40
+
41
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
44
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
46
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
47
+ SOFTWARE.
48
+
49
+ ---
50
+
51
+ @typescript-eslint/utils
52
+
53
+ MIT License
54
+
55
+ Copyright (c) 2019 typescript-eslint and other contributors
56
+
57
+ Permission is hereby granted, free of charge, to any person obtaining a copy
58
+ of this software and associated documentation files (the "Software"), to deal
59
+ in the Software without restriction, including without limitation the rights
60
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
61
+ copies of the Software, and to permit persons to whom the Software is
62
+ furnished to do so, subject to the following conditions:
63
+
64
+ The above copyright notice and this permission notice shall be included in all
65
+ copies or substantial portions of the Software.
66
+
67
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
68
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
69
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
70
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
71
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
72
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
73
+ SOFTWARE.
74
+
75
+ ---
76
+
77
+ globals
78
+
79
+ MIT License
80
+
81
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
82
+
83
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
84
+
85
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
86
+
87
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,69 @@
1
- # Temporary Holding Version
1
+ # @r_masseater/cc-effect-hooks
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
+ Write Claude Code plugin hooks with [Effect](https://effect.website), with each event's input decoded and typed and each answer typed. The same definitions generate the plugin's `plugin.json` and `hooks.json`, so the matchers never drift from the code.
4
+
5
+ It requires Node.js 26 or later and Effect 4.
6
+
7
+ ```sh
8
+ bun add @r_masseater/cc-effect-hooks effect @effect/platform-node
9
+ bun add -d @anthropic-ai/claude-agent-sdk
10
+ ```
11
+
12
+ The Agent SDK is an optional peer: the tool input types come from it, and a hook needs it only to type-check.
13
+
14
+ ## Write a hook
15
+
16
+ ```ts
17
+ // hooks/guard.ts
18
+ import { defineHook, deny, runHook } from "@r_masseater/cc-effect-hooks";
19
+ import { Effect } from "effect";
20
+
21
+ export const guard = defineHook({
22
+ entry: import.meta.url,
23
+ on: { PreToolUse: { tools: ["Bash"] } },
24
+ timeout: 10,
25
+ run: (input) =>
26
+ Effect.succeed(input.tool_input.command.startsWith("rm -rf") ? deny("Not here.") : {}),
27
+ });
28
+
29
+ if (import.meta.main) runHook(guard, "my-plugin");
30
+ ```
31
+
32
+ `on` takes any of the hook events. For the tool events (`PreToolUse`, `PostToolUse`, `PostToolUseFailure`, `PermissionRequest` and `PermissionDenied`), `tools` lists the tools and types `tool_input`; `matcher` takes a raw matcher instead. An event can set its own `timeout`. `node` passes options to node, such as `--use-env-proxy`.
33
+
34
+ `run` returns an Effect of the answer: `{}` to say nothing, `deny`, `allow` or `addContext`, or any answer the event accepts. Fail with `blockHook(reason)` to block with exit code 2. `runHook` provides the Node.js platform and OTLP tracing; use `runHookWithServices` to add services.
35
+
36
+ To type an MCP tool's input, augment `ToolInputs`:
37
+
38
+ ```ts
39
+ declare module "@r_masseater/cc-effect-hooks" {
40
+ interface ToolInputs {
41
+ mcp__github__push_files: { owner: string; repo: string };
42
+ }
43
+ }
44
+ ```
45
+
46
+ ## Describe the plugin
47
+
48
+ ```ts
49
+ // plugin.ts, at the plugin root
50
+ import { definePlugin } from "@r_masseater/cc-effect-hooks";
51
+
52
+ import { guard } from "./hooks/guard.ts";
53
+
54
+ export default definePlugin({
55
+ entry: import.meta.url,
56
+ hooks: [guard],
57
+ manifest: { license: "MIT" },
58
+ });
59
+ ```
60
+
61
+ `pluginFiles(plugin, { name, description })` returns the text of `.claude-plugin/plugin.json` and of the hooks file. The name and description come from the caller, usually the plugin's `package.json`. plugin.json gets no `version`, so Claude Code takes each commit as a new version. `@r_masseater/msch` writes both files and reports them when they are stale.
62
+
63
+ ## Agent skills
64
+
65
+ The package ships the agent skill `write-plugin-hooks` in `skills/`. Add `permissions: { "@r_masseater/cc-effect-hooks": { skills: true } }` to `pnpm-workspace.yaml` and `vp install` links it into the skill directories of your agents.
66
+
67
+ ## Published on
68
+
69
+ [npm](https://www.npmjs.com/package/@r_masseater/cc-effect-hooks). The source lives in [masseater/ecosystems](https://github.com/masseater/ecosystems/tree/main/libs/cc-effect-hooks).