cc-hooks-ts 2.1.49 → 2.1.63
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/dist/index.d.mts +64 -1
- package/dist/index.mjs +24 -3
- package/package.json +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -218,6 +218,51 @@ declare const HookInputSchemas: {
|
|
|
218
218
|
file_path: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
219
219
|
source: v.PicklistSchema<["local_settings", "policy_settings", "project_settings", "skills", "user_settings"], undefined>;
|
|
220
220
|
}, undefined>;
|
|
221
|
+
readonly WorktreeCreate: v.ObjectSchema<{
|
|
222
|
+
readonly cwd: v.StringSchema<undefined>;
|
|
223
|
+
readonly permission_mode: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
224
|
+
readonly session_id: v.StringSchema<undefined>;
|
|
225
|
+
readonly transcript_path: v.StringSchema<undefined>;
|
|
226
|
+
readonly hook_event_name: v.LiteralSchema<"WorktreeCreate", undefined>;
|
|
227
|
+
} & {
|
|
228
|
+
name: v.StringSchema<undefined>;
|
|
229
|
+
}, undefined>;
|
|
230
|
+
readonly WorktreeRemove: v.ObjectSchema<{
|
|
231
|
+
readonly cwd: v.StringSchema<undefined>;
|
|
232
|
+
readonly permission_mode: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
233
|
+
readonly session_id: v.StringSchema<undefined>;
|
|
234
|
+
readonly transcript_path: v.StringSchema<undefined>;
|
|
235
|
+
readonly hook_event_name: v.LiteralSchema<"WorktreeRemove", undefined>;
|
|
236
|
+
} & {
|
|
237
|
+
worktree_path: v.StringSchema<undefined>;
|
|
238
|
+
}, undefined>;
|
|
239
|
+
readonly Elicitation: v.ObjectSchema<{
|
|
240
|
+
readonly cwd: v.StringSchema<undefined>;
|
|
241
|
+
readonly permission_mode: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
242
|
+
readonly session_id: v.StringSchema<undefined>;
|
|
243
|
+
readonly transcript_path: v.StringSchema<undefined>;
|
|
244
|
+
readonly hook_event_name: v.LiteralSchema<"Elicitation", undefined>;
|
|
245
|
+
} & {
|
|
246
|
+
elicitation_id: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
247
|
+
mcp_server_name: v.StringSchema<undefined>;
|
|
248
|
+
message: v.StringSchema<undefined>;
|
|
249
|
+
mode: v.ExactOptionalSchema<v.PicklistSchema<["form", "url"], undefined>, undefined>;
|
|
250
|
+
requested_schema: v.ExactOptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
251
|
+
url: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
252
|
+
}, undefined>;
|
|
253
|
+
readonly ElicitationResult: v.ObjectSchema<{
|
|
254
|
+
readonly cwd: v.StringSchema<undefined>;
|
|
255
|
+
readonly permission_mode: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
256
|
+
readonly session_id: v.StringSchema<undefined>;
|
|
257
|
+
readonly transcript_path: v.StringSchema<undefined>;
|
|
258
|
+
readonly hook_event_name: v.LiteralSchema<"ElicitationResult", undefined>;
|
|
259
|
+
} & {
|
|
260
|
+
action: v.PicklistSchema<["accept", "decline", "cancel"], undefined>;
|
|
261
|
+
content: v.ExactOptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
262
|
+
elicitation_id: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
263
|
+
mcp_server_name: v.StringSchema<undefined>;
|
|
264
|
+
mode: v.ExactOptionalSchema<v.PicklistSchema<["form", "url"], undefined>, undefined>;
|
|
265
|
+
}, undefined>;
|
|
221
266
|
};
|
|
222
267
|
//#endregion
|
|
223
268
|
//#region src/hooks/event.d.ts
|
|
@@ -226,7 +271,7 @@ declare const HookInputSchemas: {
|
|
|
226
271
|
*
|
|
227
272
|
* @package
|
|
228
273
|
*/
|
|
229
|
-
type SupportedHookEvent = "PreToolUse" | "PostToolUse" | "PostToolUseFailure" | "Notification" | "UserPromptSubmit" | "SessionStart" | "SessionEnd" | "Stop" | "SubagentStart" | "SubagentStop" | "PreCompact" | "PermissionRequest" | "Setup" | "TeammateIdle" | "TaskCompleted" | "ConfigChange";
|
|
274
|
+
type SupportedHookEvent = "PreToolUse" | "PostToolUse" | "PostToolUseFailure" | "Notification" | "UserPromptSubmit" | "SessionStart" | "SessionEnd" | "Stop" | "SubagentStart" | "SubagentStop" | "PreCompact" | "PermissionRequest" | "Setup" | "TeammateIdle" | "TaskCompleted" | "ConfigChange" | "WorktreeCreate" | "WorktreeRemove" | "Elicitation" | "ElicitationResult";
|
|
230
275
|
//#endregion
|
|
231
276
|
//#region src/hooks/input/types.d.ts
|
|
232
277
|
/**
|
|
@@ -366,11 +411,15 @@ type HookOutput = {
|
|
|
366
411
|
PermissionRequest: PermissionRequestHookOutput;
|
|
367
412
|
Setup: SetupHookOutput;
|
|
368
413
|
Notification: NotificationHookOutput;
|
|
414
|
+
Elicitation: ElicitationHookOutput;
|
|
415
|
+
ElicitationResult: ElicitationResultHookOutput;
|
|
369
416
|
ConfigChange: CommonHookOutputs;
|
|
370
417
|
PreCompact: CommonHookOutputs;
|
|
371
418
|
SessionEnd: CommonHookOutputs;
|
|
372
419
|
TaskCompleted: CommonHookOutputs;
|
|
373
420
|
TeammateIdle: CommonHookOutputs;
|
|
421
|
+
WorktreeCreate: CommonHookOutputs;
|
|
422
|
+
WorktreeRemove: CommonHookOutputs;
|
|
374
423
|
};
|
|
375
424
|
/**
|
|
376
425
|
* @package
|
|
@@ -588,6 +637,20 @@ interface PermissionRequestHookOutput extends CommonHookOutputs {
|
|
|
588
637
|
};
|
|
589
638
|
};
|
|
590
639
|
}
|
|
640
|
+
interface ElicitationHookOutput extends CommonHookOutputs {
|
|
641
|
+
hookSpecificOutput?: {
|
|
642
|
+
action?: "accept" | "decline" | "cancel";
|
|
643
|
+
content?: Record<string, unknown>;
|
|
644
|
+
hookEventName: "Elicitation";
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
interface ElicitationResultHookOutput extends CommonHookOutputs {
|
|
648
|
+
hookSpecificOutput?: {
|
|
649
|
+
action?: "accept" | "decline" | "cancel";
|
|
650
|
+
content?: Record<string, unknown>;
|
|
651
|
+
hookEventName: "ElicitationResult";
|
|
652
|
+
};
|
|
653
|
+
}
|
|
591
654
|
//#endregion
|
|
592
655
|
//#region src/types.d.ts
|
|
593
656
|
type HookTrigger = Partial<{ [TEvent in SupportedHookEvent]: true | Partial<{ [SchemaKey in ExtractExtendedSpecificKeys<TEvent>]?: true }> }>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import getStdin from "get-stdin";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import * as v from "valibot";
|
|
4
4
|
function defineHook(definition) {
|
|
@@ -190,6 +190,27 @@ const HookInputSchemas = {
|
|
|
190
190
|
"skills",
|
|
191
191
|
"user_settings"
|
|
192
192
|
])
|
|
193
|
+
}),
|
|
194
|
+
WorktreeCreate: buildHookInputSchema("WorktreeCreate", { name: v.string() }),
|
|
195
|
+
WorktreeRemove: buildHookInputSchema("WorktreeRemove", { worktree_path: v.string() }),
|
|
196
|
+
Elicitation: buildHookInputSchema("Elicitation", {
|
|
197
|
+
elicitation_id: v.exactOptional(v.string()),
|
|
198
|
+
mcp_server_name: v.string(),
|
|
199
|
+
message: v.string(),
|
|
200
|
+
mode: v.exactOptional(v.picklist(["form", "url"])),
|
|
201
|
+
requested_schema: v.exactOptional(v.record(v.string(), v.unknown())),
|
|
202
|
+
url: v.exactOptional(v.string())
|
|
203
|
+
}),
|
|
204
|
+
ElicitationResult: buildHookInputSchema("ElicitationResult", {
|
|
205
|
+
action: v.picklist([
|
|
206
|
+
"accept",
|
|
207
|
+
"decline",
|
|
208
|
+
"cancel"
|
|
209
|
+
]),
|
|
210
|
+
content: v.exactOptional(v.record(v.string(), v.unknown())),
|
|
211
|
+
elicitation_id: v.exactOptional(v.string()),
|
|
212
|
+
mcp_server_name: v.string(),
|
|
213
|
+
mode: v.exactOptional(v.picklist(["form", "url"]))
|
|
193
214
|
})
|
|
194
215
|
};
|
|
195
216
|
function isNonEmptyString(value) {
|
|
@@ -203,9 +224,9 @@ async function runHook(def) {
|
|
|
203
224
|
kind: "success",
|
|
204
225
|
payload: {}
|
|
205
226
|
});
|
|
227
|
+
const stdin = await getStdin();
|
|
206
228
|
const inputSchema = extractInputSchemaFromTrigger(trigger);
|
|
207
|
-
const
|
|
208
|
-
const parsed = v.parse(inputSchema, JSON.parse(rawInput));
|
|
229
|
+
const parsed = v.parse(inputSchema, JSON.parse(stdin));
|
|
209
230
|
eventName = parsed.hook_event_name;
|
|
210
231
|
const result = await run(createContext(parsed));
|
|
211
232
|
await handleHookResult(eventName, result);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-hooks-ts",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.63",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Write claude code hooks with type safety",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -62,7 +62,8 @@
|
|
|
62
62
|
"vitest": "4.0.18"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@anthropic-ai/claude-agent-sdk": "0.2.
|
|
65
|
+
"@anthropic-ai/claude-agent-sdk": "0.2.63",
|
|
66
|
+
"get-stdin": "10.0.0",
|
|
66
67
|
"valibot": "^1.1.0"
|
|
67
68
|
},
|
|
68
69
|
"scripts": {
|