cc-hooks-ts 2.1.1 → 2.1.2
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/README.md +16 -16
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +9 -6
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -59,15 +59,15 @@ import { defineHook } from "cc-hooks-ts";
|
|
|
59
59
|
const hook = defineHook({
|
|
60
60
|
// Specify the event(s) that trigger this hook.
|
|
61
61
|
trigger: {
|
|
62
|
-
SessionStart: true
|
|
62
|
+
SessionStart: true,
|
|
63
63
|
},
|
|
64
64
|
// Implement what you want to do.
|
|
65
65
|
run: (context) => {
|
|
66
66
|
// Do something great here
|
|
67
67
|
return context.success({
|
|
68
|
-
messageForUser: "Welcome to your coding session!"
|
|
68
|
+
messageForUser: "Welcome to your coding session!",
|
|
69
69
|
});
|
|
70
|
-
}
|
|
70
|
+
},
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
// import.meta.main is available in Node.js 24.2+ and Bun and Deno
|
|
@@ -111,12 +111,12 @@ const preReadHook = defineHook({
|
|
|
111
111
|
// context.input.tool_input is typed as { file_path: string; limit?: number; offset?: number; }
|
|
112
112
|
const { file_path } = context.input.tool_input;
|
|
113
113
|
|
|
114
|
-
if (file_path.includes(
|
|
115
|
-
return context.blockingError(
|
|
114
|
+
if (file_path.includes(".env")) {
|
|
115
|
+
return context.blockingError("Cannot read environment files");
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
return context.success();
|
|
119
|
-
}
|
|
119
|
+
},
|
|
120
120
|
});
|
|
121
121
|
|
|
122
122
|
if (import.meta.main) {
|
|
@@ -174,11 +174,11 @@ const deepWikiHook = defineHook({
|
|
|
174
174
|
const { question, repoName } = context.input.tool_input;
|
|
175
175
|
|
|
176
176
|
if (question.length > 500) {
|
|
177
|
-
return context.blockingError(
|
|
177
|
+
return context.blockingError("Question is too long");
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
return context.success();
|
|
181
|
-
}
|
|
181
|
+
},
|
|
182
182
|
});
|
|
183
183
|
```
|
|
184
184
|
|
|
@@ -194,14 +194,14 @@ import { defineHook } from "cc-hooks-ts";
|
|
|
194
194
|
|
|
195
195
|
const hook = defineHook({
|
|
196
196
|
trigger: {
|
|
197
|
-
Notification: true
|
|
197
|
+
Notification: true,
|
|
198
198
|
},
|
|
199
199
|
// Only run this hook on macOS
|
|
200
200
|
shouldRun: () => process.platform === "darwin",
|
|
201
201
|
run: (context) => {
|
|
202
202
|
// Some macOS-specific logic like sending a notification using AppleScript
|
|
203
|
-
return context.success()
|
|
204
|
-
}
|
|
203
|
+
return context.success();
|
|
204
|
+
},
|
|
205
205
|
});
|
|
206
206
|
```
|
|
207
207
|
|
|
@@ -241,14 +241,14 @@ const hook = defineHook({
|
|
|
241
241
|
return {
|
|
242
242
|
event: "PostToolUse",
|
|
243
243
|
output: {
|
|
244
|
-
systemMessage: "Read tool used successfully after async processing!"
|
|
245
|
-
}
|
|
244
|
+
systemMessage: "Read tool used successfully after async processing!",
|
|
245
|
+
},
|
|
246
246
|
};
|
|
247
247
|
},
|
|
248
248
|
{
|
|
249
|
-
timeoutMs: 5000 // Optional timeout for the async operation.
|
|
250
|
-
}
|
|
251
|
-
)
|
|
249
|
+
timeoutMs: 5000, // Optional timeout for the async operation.
|
|
250
|
+
},
|
|
251
|
+
),
|
|
252
252
|
});
|
|
253
253
|
```
|
|
254
254
|
|
package/dist/index.d.mts
CHANGED
|
@@ -113,6 +113,7 @@ declare const HookInputSchemas: {
|
|
|
113
113
|
readonly transcript_path: v.StringSchema<undefined>;
|
|
114
114
|
readonly hook_event_name: v.LiteralSchema<"SessionStart", undefined>;
|
|
115
115
|
} & {
|
|
116
|
+
agent_type: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
116
117
|
source: v.PicklistSchema<["startup", "resume", "clear", "compact"], undefined>;
|
|
117
118
|
}, undefined>;
|
|
118
119
|
readonly SessionEnd: v.ObjectSchema<{
|
package/dist/index.mjs
CHANGED
|
@@ -143,12 +143,15 @@ const HookInputSchemas = {
|
|
|
143
143
|
custom_instructions: v.nullable(v.string()),
|
|
144
144
|
trigger: v.picklist(["manual", "auto"])
|
|
145
145
|
}),
|
|
146
|
-
SessionStart: buildHookInputSchema("SessionStart", {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
146
|
+
SessionStart: buildHookInputSchema("SessionStart", {
|
|
147
|
+
agent_type: v.exactOptional(v.string()),
|
|
148
|
+
source: v.picklist([
|
|
149
|
+
"startup",
|
|
150
|
+
"resume",
|
|
151
|
+
"clear",
|
|
152
|
+
"compact"
|
|
153
|
+
])
|
|
154
|
+
}),
|
|
152
155
|
SessionEnd: buildHookInputSchema("SessionEnd", { reason: v.picklist([
|
|
153
156
|
"clear",
|
|
154
157
|
"logout",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-hooks-ts",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Write claude code hooks with type safety",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@virtual-live-lab/tsconfig": "2.1.21",
|
|
50
50
|
"eslint": "9.39.2",
|
|
51
51
|
"eslint-plugin-import-access": "3.1.0",
|
|
52
|
-
"oxfmt": "0.
|
|
52
|
+
"oxfmt": "0.22.0",
|
|
53
53
|
"pkg-pr-new": "0.0.62",
|
|
54
54
|
"publint": "0.3.16",
|
|
55
55
|
"release-it": "19.2.2",
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
"tsdown": "0.18.4",
|
|
58
58
|
"type-fest": "5.3.1",
|
|
59
59
|
"typescript": "5.9.3",
|
|
60
|
-
"typescript-eslint": "8.
|
|
60
|
+
"typescript-eslint": "8.52.0",
|
|
61
61
|
"unplugin-unused": "0.5.6",
|
|
62
62
|
"vitest": "4.0.16"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@anthropic-ai/claude-agent-sdk": "0.2.
|
|
65
|
+
"@anthropic-ai/claude-agent-sdk": "0.2.2",
|
|
66
66
|
"valibot": "^1.1.0"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|