cc-hooks-ts 2.1.79 → 2.1.84

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 CHANGED
@@ -308,6 +308,7 @@ pnpm typecheck
308
308
  - `src/hooks/event.test-d.ts`
309
309
  - `src/hooks/permission.test-d.ts`
310
310
  - Edit `src/index.ts` for changed tool input / output types.
311
+ - YOU SHOULD NOT MODIFY `version` in `package.json` manually.
311
312
 
312
313
  ## License
313
314
 
package/dist/index.d.mts CHANGED
@@ -19,7 +19,7 @@ declare const HookInputSchemas: {
19
19
  readonly transcript_path: v.StringSchema<undefined>;
20
20
  readonly hook_event_name: v.LiteralSchema<"PreToolUse", undefined>;
21
21
  } & {
22
- tool_name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, AutoComplete<string>>]>;
22
+ tool_name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.GuardAction<string, (s: string) => s is AutoComplete<string>, undefined>]>;
23
23
  tool_input: v.UnknownSchema;
24
24
  tool_use_id: v.StringSchema<undefined>;
25
25
  }, undefined>;
@@ -32,7 +32,7 @@ declare const HookInputSchemas: {
32
32
  readonly transcript_path: v.StringSchema<undefined>;
33
33
  readonly hook_event_name: v.LiteralSchema<"PostToolUse", undefined>;
34
34
  } & {
35
- tool_name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, AutoComplete<string>>]>;
35
+ tool_name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.GuardAction<string, (s: string) => s is AutoComplete<string>, undefined>]>;
36
36
  tool_input: v.UnknownSchema;
37
37
  tool_response: v.UnknownSchema;
38
38
  tool_use_id: v.StringSchema<undefined>;
@@ -46,7 +46,7 @@ declare const HookInputSchemas: {
46
46
  readonly transcript_path: v.StringSchema<undefined>;
47
47
  readonly hook_event_name: v.LiteralSchema<"PostToolUseFailure", undefined>;
48
48
  } & {
49
- tool_name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, AutoComplete<string>>]>;
49
+ tool_name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.GuardAction<string, (s: string) => s is AutoComplete<string>, undefined>]>;
50
50
  error: v.StringSchema<undefined>;
51
51
  is_interrupt: v.ExactOptionalSchema<v.BooleanSchema<undefined>, undefined>;
52
52
  tool_input: v.UnknownSchema;
@@ -249,6 +249,21 @@ declare const HookInputSchemas: {
249
249
  team_name: v.StringSchema<undefined>;
250
250
  teammate_name: v.StringSchema<undefined>;
251
251
  }, undefined>;
252
+ readonly TaskCreated: v.ObjectSchema<{
253
+ readonly agent_id: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
254
+ readonly agent_type: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
255
+ readonly cwd: v.StringSchema<undefined>;
256
+ readonly permission_mode: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
257
+ readonly session_id: v.StringSchema<undefined>;
258
+ readonly transcript_path: v.StringSchema<undefined>;
259
+ readonly hook_event_name: v.LiteralSchema<"TaskCreated", undefined>;
260
+ } & {
261
+ task_description: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
262
+ task_id: v.StringSchema<undefined>;
263
+ task_subject: v.StringSchema<undefined>;
264
+ team_name: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
265
+ teammate_name: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
266
+ }, undefined>;
252
267
  readonly TaskCompleted: v.ObjectSchema<{
253
268
  readonly agent_id: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
254
269
  readonly agent_type: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -345,6 +360,30 @@ declare const HookInputSchemas: {
345
360
  parent_file_path: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
346
361
  trigger_file_path: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
347
362
  }, undefined>;
363
+ readonly CwdChanged: v.ObjectSchema<{
364
+ readonly agent_id: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
365
+ readonly agent_type: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
366
+ readonly cwd: v.StringSchema<undefined>;
367
+ readonly permission_mode: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
368
+ readonly session_id: v.StringSchema<undefined>;
369
+ readonly transcript_path: v.StringSchema<undefined>;
370
+ readonly hook_event_name: v.LiteralSchema<"CwdChanged", undefined>;
371
+ } & {
372
+ new_cwd: v.StringSchema<undefined>;
373
+ old_cwd: v.StringSchema<undefined>;
374
+ }, undefined>;
375
+ readonly FileChanged: v.ObjectSchema<{
376
+ readonly agent_id: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
377
+ readonly agent_type: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
378
+ readonly cwd: v.StringSchema<undefined>;
379
+ readonly permission_mode: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
380
+ readonly session_id: v.StringSchema<undefined>;
381
+ readonly transcript_path: v.StringSchema<undefined>;
382
+ readonly hook_event_name: v.LiteralSchema<"FileChanged", undefined>;
383
+ } & {
384
+ event: v.PicklistSchema<["change", "add", "unlink"], undefined>;
385
+ file_path: v.StringSchema<undefined>;
386
+ }, undefined>;
348
387
  };
349
388
  //#endregion
350
389
  //#region src/hooks/event.d.ts
@@ -353,7 +392,7 @@ declare const HookInputSchemas: {
353
392
  *
354
393
  * @package
355
394
  */
356
- type SupportedHookEvent = "PreToolUse" | "PostToolUse" | "PostToolUseFailure" | "Notification" | "UserPromptSubmit" | "SessionStart" | "SessionEnd" | "Stop" | "StopFailure" | "SubagentStart" | "SubagentStop" | "PreCompact" | "PostCompact" | "PermissionRequest" | "Setup" | "TeammateIdle" | "TaskCompleted" | "ConfigChange" | "WorktreeCreate" | "WorktreeRemove" | "Elicitation" | "ElicitationResult" | "InstructionsLoaded";
395
+ type SupportedHookEvent = "PreToolUse" | "PostToolUse" | "PostToolUseFailure" | "Notification" | "UserPromptSubmit" | "SessionStart" | "SessionEnd" | "Stop" | "StopFailure" | "SubagentStart" | "SubagentStop" | "PreCompact" | "PostCompact" | "PermissionRequest" | "Setup" | "TeammateIdle" | "TaskCreated" | "TaskCompleted" | "ConfigChange" | "WorktreeCreate" | "WorktreeRemove" | "Elicitation" | "ElicitationResult" | "InstructionsLoaded" | "CwdChanged" | "FileChanged";
357
396
  //#endregion
358
397
  //#region src/hooks/input/types.d.ts
359
398
  /**
@@ -496,14 +535,17 @@ type HookOutput = {
496
535
  Notification: NotificationHookOutput;
497
536
  Elicitation: ElicitationHookOutput;
498
537
  ElicitationResult: ElicitationResultHookOutput;
538
+ CwdChanged: CwdChangedHookOutput;
539
+ FileChanged: FileChangedHookOutput;
499
540
  ConfigChange: CommonHookOutputs;
500
541
  InstructionsLoaded: CommonHookOutputs;
501
542
  PostCompact: CommonHookOutputs;
502
543
  PreCompact: CommonHookOutputs;
503
544
  SessionEnd: CommonHookOutputs;
504
545
  TaskCompleted: CommonHookOutputs;
546
+ TaskCreated: CommonHookOutputs;
505
547
  TeammateIdle: CommonHookOutputs;
506
- WorktreeCreate: CommonHookOutputs;
548
+ WorktreeCreate: WorktreeCreateHookOutput;
507
549
  WorktreeRemove: CommonHookOutputs;
508
550
  };
509
551
  /**
@@ -646,6 +688,12 @@ interface NotificationHookOutput extends CommonHookOutputs {
646
688
  additionalContext?: string;
647
689
  };
648
690
  }
691
+ interface WorktreeCreateHookOutput extends CommonHookOutputs {
692
+ hookSpecificOutput?: {
693
+ hookEventName: "WorktreeCreate";
694
+ worktreePath: string;
695
+ };
696
+ }
649
697
  /**
650
698
  * @see {@link https://docs.anthropic.com/en/docs/claude-code/hooks#stop%2Fsubagentstop-decision-control}
651
699
  */
@@ -689,6 +737,8 @@ interface SessionStartHookOutput extends CommonHookOutputs {
689
737
  * Adds the string to the context.
690
738
  */
691
739
  additionalContext?: string;
740
+ initialUserMessage?: string;
741
+ watchPaths?: string[];
692
742
  };
693
743
  }
694
744
  interface SetupHookOutput extends CommonHookOutputs {
@@ -736,6 +786,18 @@ interface ElicitationResultHookOutput extends CommonHookOutputs {
736
786
  hookEventName: "ElicitationResult";
737
787
  };
738
788
  }
789
+ interface CwdChangedHookOutput extends CommonHookOutputs {
790
+ hookSpecificOutput?: {
791
+ hookEventName: "CwdChanged";
792
+ watchPaths?: string[];
793
+ };
794
+ }
795
+ interface FileChangedHookOutput extends CommonHookOutputs {
796
+ hookSpecificOutput?: {
797
+ hookEventName: "FileChanged";
798
+ watchPaths?: string[];
799
+ };
800
+ }
739
801
  //#endregion
740
802
  //#region src/types.d.ts
741
803
  type HookTrigger = Partial<{ [TEvent in SupportedHookEvent]: true | Partial<{ [SchemaKey in ExtractExtendedSpecificKeys<TEvent>]?: true }> }>;
@@ -1163,6 +1225,13 @@ interface ToolSchema {
1163
1225
  input: ReadMcpResourceInput;
1164
1226
  response: ReadMcpResourceOutput;
1165
1227
  };
1228
+ Skill: {
1229
+ input: {
1230
+ args?: string;
1231
+ skill: string;
1232
+ };
1233
+ response: unknown;
1234
+ };
1166
1235
  SubscribeMcpResource: {
1167
1236
  input: SubscribeMcpResourceInput;
1168
1237
  response: SubscribeMcpResourceOutput;
@@ -1187,6 +1256,16 @@ interface ToolSchema {
1187
1256
  input: TodoWriteInput;
1188
1257
  response: TodoWriteOutput;
1189
1258
  };
1259
+ ToolSearch: {
1260
+ input: {
1261
+ /**
1262
+ * @default 5
1263
+ */
1264
+ max_results?: number;
1265
+ query: string;
1266
+ };
1267
+ response: unknown;
1268
+ };
1190
1269
  UnsubscribeMcpResource: {
1191
1270
  input: UnsubscribeMcpResourceInput;
1192
1271
  response: UnsubscribeMcpResourceOutput;
package/dist/index.mjs CHANGED
@@ -179,18 +179,18 @@ function buildSubagentInputSchema(hook_event_name, entries) {
179
179
  */
180
180
  const HookInputSchemas = {
181
181
  PreToolUse: buildHookInputSchema("PreToolUse", {
182
- tool_name: v.pipe(v.string(), v.transform((s) => s)),
182
+ tool_name: v.pipe(v.string(), v.guard((s) => true)),
183
183
  tool_input: v.unknown(),
184
184
  tool_use_id: v.string()
185
185
  }),
186
186
  PostToolUse: buildHookInputSchema("PostToolUse", {
187
- tool_name: v.pipe(v.string(), v.transform((s) => s)),
187
+ tool_name: v.pipe(v.string(), v.guard((s) => true)),
188
188
  tool_input: v.unknown(),
189
189
  tool_response: v.unknown(),
190
190
  tool_use_id: v.string()
191
191
  }),
192
192
  PostToolUseFailure: buildHookInputSchema("PostToolUseFailure", {
193
- tool_name: v.pipe(v.string(), v.transform((s) => s)),
193
+ tool_name: v.pipe(v.string(), v.guard((s) => true)),
194
194
  error: v.string(),
195
195
  is_interrupt: v.exactOptional(v.boolean()),
196
196
  tool_input: v.unknown(),
@@ -261,6 +261,13 @@ const HookInputSchemas = {
261
261
  team_name: v.string(),
262
262
  teammate_name: v.string()
263
263
  }),
264
+ TaskCreated: buildHookInputSchema("TaskCreated", {
265
+ task_description: v.exactOptional(v.string()),
266
+ task_id: v.string(),
267
+ task_subject: v.string(),
268
+ team_name: v.exactOptional(v.string()),
269
+ teammate_name: v.exactOptional(v.string())
270
+ }),
264
271
  TaskCompleted: buildHookInputSchema("TaskCompleted", {
265
272
  task_description: v.exactOptional(v.string()),
266
273
  task_id: v.string(),
@@ -317,6 +324,18 @@ const HookInputSchemas = {
317
324
  ]),
318
325
  parent_file_path: v.exactOptional(v.string()),
319
326
  trigger_file_path: v.exactOptional(v.string())
327
+ }),
328
+ CwdChanged: buildHookInputSchema("CwdChanged", {
329
+ new_cwd: v.string(),
330
+ old_cwd: v.string()
331
+ }),
332
+ FileChanged: buildHookInputSchema("FileChanged", {
333
+ event: v.picklist([
334
+ "change",
335
+ "add",
336
+ "unlink"
337
+ ]),
338
+ file_path: v.string()
320
339
  })
321
340
  };
322
341
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-hooks-ts",
3
- "version": "2.1.79",
3
+ "version": "2.1.84",
4
4
  "type": "module",
5
5
  "description": "Write claude code hooks with type safety",
6
6
  "sideEffects": false,
@@ -62,7 +62,7 @@
62
62
  "vitest": "4.1.0"
63
63
  },
64
64
  "dependencies": {
65
- "@anthropic-ai/claude-agent-sdk": "0.2.79",
65
+ "@anthropic-ai/claude-agent-sdk": "0.2.84",
66
66
  "get-stdin": "10.0.0",
67
67
  "valibot": "^1.1.0"
68
68
  },