@r_masseater/cc-effect-hooks 0.0.0 → 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 +87 -0
- package/README.md +67 -1
- package/dist/index.d.mts +1217 -0
- package/dist/index.mjs +823 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +54 -5
- package/skills/write-plugin-hooks/SKILL.md +45 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["JsonObject","OptionalString","OptionalFinite","OptionalString","OptionalFinite","OptionalString","JsonObject","OptionalString","OptionalBoolean","Arr","taggedError","Str","Arr","Str","Arr","Num"],"sources":["../src/entities/hook/model/answers.ts","../src/entities/hook/model/define-hook.ts","../src/entities/hook/model/shared.ts","../src/entities/hook/model/event-parts.ts","../src/entities/hook/model/events.ts","../src/entities/hook/model/outputs.ts","../src/features/define-hook/model/run-hook.ts","../src/features/define-plugin/model/manifest.ts","../src/features/define-plugin/model/definition.ts","../src/features/define-plugin/model/install-deps.ts","../src/features/define-plugin/model/layout.ts","../src/features/define-plugin/model/plugin.ts"],"sourcesContent":["import type { HookOutput } from \"./outputs.ts\";\n\nexport type ContextEvent =\n | \"PreToolUse\"\n | \"PostToolUse\"\n | \"PostToolUseFailure\"\n | \"PostToolBatch\"\n | \"Notification\"\n | \"UserPromptSubmit\"\n | \"UserPromptExpansion\"\n | \"SessionStart\"\n | \"Setup\"\n | \"Stop\"\n | \"SubagentStart\"\n | \"SubagentStop\"\n | \"PostModelSwitch\";\n\nexport type ContextAnswer<Event extends ContextEvent> = Readonly<{\n hookSpecificOutput: Readonly<{ hookEventName: Event; additionalContext: string }>;\n}>;\n\nexport const allow = (reason: string): HookOutput<\"PreToolUse\"> => ({\n hookSpecificOutput: {\n hookEventName: \"PreToolUse\",\n permissionDecision: \"allow\",\n permissionDecisionReason: reason,\n },\n});\n\nexport const deny = (reason: string): HookOutput<\"PreToolUse\"> => ({\n hookSpecificOutput: {\n hookEventName: \"PreToolUse\",\n permissionDecision: \"deny\",\n permissionDecisionReason: reason,\n },\n});\n\nexport const addContext = <Event extends ContextEvent>(\n event: Event,\n text: string,\n): ContextAnswer<Event> => ({\n hookSpecificOutput: { hookEventName: event, additionalContext: text },\n});\n","import type { Effect } from \"effect\";\n\nimport type { HookEvent, HookInput, ToolEvent } from \"./events.ts\";\nimport type { HookOutput } from \"./outputs.ts\";\nimport type { ToolInput, ToolName } from \"./tools.ts\";\n\nexport type Trigger<Event extends HookEvent> = Readonly<{\n timeout?: number;\n}> &\n (Event extends ToolEvent\n ? Readonly<\n | { tools: readonly [ToolName, ...ToolName[]]; matcher?: never }\n | { matcher?: string; tools?: never }\n >\n : Readonly<{ matcher?: string; tools?: never }>);\n\nexport type Triggers = Readonly<{ [Event in HookEvent]?: Trigger<Event> }>;\n\nexport type Named<Event extends ToolEvent, Name extends ToolName> = Name extends ToolName\n ? Omit<HookInput<Event>, \"tool_name\" | \"tool_input\"> &\n Readonly<{ tool_name: Name; tool_input: ToolInput<Name> }>\n : never;\n\nexport type InputFor<Event extends HookEvent, Of> = Event extends ToolEvent\n ? Of extends Readonly<{ tools: readonly (infer Name extends ToolName)[] }>\n ? Named<Event, Name>\n : HookInput<Event>\n : HookInput<Event>;\n\nexport type EventsOf<On extends Triggers> = keyof On & HookEvent;\n\nexport type InputOf<On extends Triggers> = {\n [Event in EventsOf<On>]: InputFor<Event, On[Event]>;\n}[EventsOf<On>];\n\nexport type OutputOf<On extends Triggers> = HookOutput<EventsOf<On>>;\n\nexport type Hook<On extends Triggers, Failure, Requirements> = Readonly<{\n entry: string;\n on: On;\n\n timeout?: number;\n\n node?: readonly string[];\n run: (input: InputOf<On>) => Effect.Effect<OutputOf<On>, Failure, Requirements>;\n}>;\n\nexport type AnyHook = Readonly<{\n entry: string;\n on: Triggers;\n timeout?: number;\n node?: readonly string[];\n}>;\n\nexport const defineHook = <const On extends Triggers, Failure = never, Requirements = never>(\n hook: Hook<On, Failure, Requirements>,\n): Hook<On, Failure, Requirements> => hook;\n","import { Schema } from \"effect\";\n\nimport type { Decodes, SdkBackgroundTaskSummary, SdkSessionCronSummary } from \"./decodes.ts\";\n\nexport const baseFields = {\n session_id: Schema.String,\n transcript_path: Schema.String,\n cwd: Schema.String,\n prompt_id: Schema.optionalKey(Schema.String),\n permission_mode: Schema.optionalKey(Schema.String),\n agent_id: Schema.optionalKey(Schema.String),\n agent_type: Schema.optionalKey(Schema.String),\n effort: Schema.Struct({ level: Schema.String }).pipe(Schema.optionalKey),\n};\n\nexport type BaseFields = typeof baseFields;\n\nexport const McpServerProvenance = Schema.Struct({ name: Schema.String, source: Schema.String });\n\nexport const PermissionBehavior = Schema.Literals([\"allow\", \"deny\", \"ask\"]);\n\nconst PermissionUpdateDestination = Schema.Literals([\n \"userSettings\",\n \"projectSettings\",\n \"localSettings\",\n \"session\",\n \"cliArg\",\n]);\n\nconst PermissionMode = Schema.Literals([\n \"default\",\n \"acceptEdits\",\n \"bypassPermissions\",\n \"plan\",\n \"dontAsk\",\n \"auto\",\n]);\n\nconst PermissionRuleValue = Schema.Struct({\n toolName: Schema.String,\n ruleContent: Schema.optionalKey(Schema.String),\n});\n\nconst rulesFields = {\n rules: Schema.Array(PermissionRuleValue),\n behavior: PermissionBehavior,\n destination: PermissionUpdateDestination,\n};\n\nconst directoriesFields = {\n directories: Schema.Array(Schema.String),\n destination: PermissionUpdateDestination,\n};\n\nexport const PermissionUpdate = Schema.Union([\n Schema.Struct({ type: Schema.Literal(\"addRules\"), ...rulesFields }),\n Schema.Struct({ type: Schema.Literal(\"replaceRules\"), ...rulesFields }),\n Schema.Struct({ type: Schema.Literal(\"removeRules\"), ...rulesFields }),\n Schema.Struct({\n type: Schema.Literal(\"setMode\"),\n mode: PermissionMode,\n destination: PermissionUpdateDestination,\n }),\n Schema.Struct({ type: Schema.Literal(\"addDirectories\"), ...directoriesFields }),\n Schema.Struct({ type: Schema.Literal(\"removeDirectories\"), ...directoriesFields }),\n]);\n\nexport const BackgroundTaskSummary = Schema.Struct({\n id: Schema.String,\n type: Schema.String,\n status: Schema.String,\n description: Schema.String,\n command: Schema.optionalKey(Schema.String),\n agent_type: Schema.optionalKey(Schema.String),\n server: Schema.optionalKey(Schema.String),\n tool: Schema.optionalKey(Schema.String),\n name: Schema.optionalKey(Schema.String),\n}) satisfies Decodes<SdkBackgroundTaskSummary>;\n\nexport const SessionCronSummary = Schema.Struct({\n id: Schema.String,\n schedule: Schema.String,\n recurring: Schema.Boolean,\n prompt: Schema.String,\n}) satisfies Decodes<SdkSessionCronSummary>;\n\nexport const ElicitationAction = Schema.Literals([\"accept\", \"decline\", \"cancel\"]);\n\nexport const ElicitationMode = Schema.Literals([\"form\", \"url\"]);\n\nexport const JsonObject = Schema.Record(Schema.String, Schema.Unknown);\n\nexport const CompactTrigger = Schema.Literals([\"manual\", \"auto\"]);\n\nexport const OptionalString = Schema.optionalKey(Schema.String);\n\nexport const OptionalFinite = Schema.optionalKey(Schema.Finite);\n","import { Schema } from \"effect\";\n\nimport type { Decodes, SubagentStartHookInput, SubagentStopHookInput } from \"./decodes.ts\";\nimport {\n BackgroundTaskSummary,\n McpServerProvenance,\n OptionalString,\n SessionCronSummary,\n baseFields,\n} from \"./shared.ts\";\nimport type { BaseFields } from \"./shared.ts\";\n\nexport type EventFields<Name extends string, Fields extends Schema.Struct.Fields> = BaseFields & {\n readonly hook_event_name: Schema.Literal<Name>;\n} & Fields;\n\nexport const event = <Name extends string, Fields extends Schema.Struct.Fields>(\n name: Name,\n fields: Fields,\n): Schema.Struct<EventFields<Name, Fields>> =>\n Schema.Struct({ ...baseFields, hook_event_name: Schema.Literal(name), ...fields }).annotate({\n identifier: `${name}Input`,\n });\n\nexport const OptionalMcpServer = Schema.optionalKey(McpServerProvenance);\n\nexport const PromptSource = Schema.Literals([\n \"user\",\n \"sdk\",\n \"system\",\n \"loop_wakeup\",\n \"schedule_wakeup\",\n \"poll_event\",\n]).pipe(Schema.optionalKey);\n\nexport const BatchedToolCall = Schema.Struct({\n tool_name: Schema.String,\n tool_input: Schema.Unknown,\n tool_use_id: Schema.String,\n tool_response: Schema.optionalKey(Schema.Unknown),\n});\n\nexport const SkillCommand = Schema.Struct({ command: Schema.String });\n\nexport const toolCall = {\n tool_name: Schema.String,\n tool_input: Schema.Unknown,\n tool_use_id: Schema.String,\n mcp_server: OptionalMcpServer,\n};\n\nexport const modelSwitch = {\n from_model: Schema.String,\n to_model: Schema.String,\n requested_model: Schema.String.pipe(Schema.NullOr),\n context_tokens: Schema.Finite,\n prompt_cache_warm: Schema.Boolean,\n cache_ttl: Schema.Literals([\"5m\", \"1h\"]),\n estimated_cache_write_usd: Schema.Finite,\n pricing: Schema.Literals([\"configured\", \"catalog\", \"default\"]),\n};\n\nexport const stopping = {\n stop_hook_active: Schema.Boolean,\n last_assistant_message: OptionalString,\n background_tasks: BackgroundTaskSummary.pipe(Schema.Array, Schema.optionalKey),\n session_crons: SessionCronSummary.pipe(Schema.Array, Schema.optionalKey),\n};\n\nexport const subagent = { agent_id: Schema.String, agent_type: Schema.String };\n\nexport const task = {\n task_id: Schema.String,\n task_subject: Schema.String,\n task_description: OptionalString,\n teammate_name: OptionalString,\n team_name: OptionalString,\n};\n\nexport const subagentStart = Schema.Struct({\n ...baseFields,\n hook_event_name: Schema.Literal(\"SubagentStart\"),\n ...subagent,\n}) satisfies Decodes<SubagentStartHookInput>;\n\nexport const subagentStop = Schema.Struct({\n ...baseFields,\n hook_event_name: Schema.Literal(\"SubagentStop\"),\n ...stopping,\n ...subagent,\n agent_transcript_path: Schema.String,\n}) satisfies Decodes<SubagentStopHookInput>;\n","import { Schema } from \"effect\";\n\nimport type {\n Decodes,\n ConfigChangeHookInput,\n CwdChangedHookInput,\n DirectoryAddedHookInput,\n ElicitationHookInput,\n ElicitationResultHookInput,\n FileChangedHookInput,\n InstructionsLoadedHookInput,\n MessageDisplayHookInput,\n NotificationHookInput,\n PermissionDeniedHookInput,\n PermissionRequestHookInput,\n PostCompactHookInput,\n PostModelSwitchHookInput,\n PostToolBatchHookInput,\n PostToolUseFailureHookInput,\n PostToolUseHookInput,\n PreCompactHookInput,\n PreModelSwitchHookInput,\n PreSkillShellCommandHookInput,\n PreToolUseHookInput,\n SessionEndHookInput,\n SessionStartHookInput,\n SetupHookInput,\n StopFailureHookInput,\n StopHookInput,\n TaskCompletedHookInput,\n TaskCreatedHookInput,\n TeammateIdleHookInput,\n UserPromptExpansionHookInput,\n UserPromptSubmitHookInput,\n WorktreeCreateHookInput,\n WorktreeRemoveHookInput,\n SubagentStartHookInput,\n SubagentStopHookInput,\n} from \"./decodes.ts\";\nimport {\n event,\n OptionalMcpServer,\n PromptSource,\n BatchedToolCall,\n SkillCommand,\n toolCall,\n modelSwitch,\n stopping,\n task,\n subagentStart,\n subagentStop,\n} from \"./event-parts.ts\";\nimport {\n CompactTrigger,\n ElicitationAction,\n ElicitationMode,\n JsonObject,\n OptionalFinite,\n OptionalString,\n PermissionUpdate,\n} from \"./shared.ts\";\n\nexport type { EventFields } from \"./event-parts.ts\";\n\nexport const HookInputs = {\n PreToolUse: event(\"PreToolUse\", toolCall) satisfies Decodes<PreToolUseHookInput>,\n PostToolUse: event(\"PostToolUse\", {\n ...toolCall,\n tool_response: Schema.Unknown,\n duration_ms: OptionalFinite,\n }) satisfies Decodes<PostToolUseHookInput>,\n PostToolUseFailure: event(\"PostToolUseFailure\", {\n ...toolCall,\n error: Schema.String,\n is_interrupt: Schema.optionalKey(Schema.Boolean),\n duration_ms: OptionalFinite,\n }) satisfies Decodes<PostToolUseFailureHookInput>,\n PostToolBatch: event(\"PostToolBatch\", {\n tool_calls: Schema.Array(BatchedToolCall),\n }) satisfies Decodes<PostToolBatchHookInput>,\n Notification: event(\"Notification\", {\n message: Schema.String,\n title: OptionalString,\n notification_type: Schema.String,\n }) satisfies Decodes<NotificationHookInput>,\n UserPromptSubmit: event(\"UserPromptSubmit\", {\n prompt: Schema.String,\n source: PromptSource,\n session_title: OptionalString,\n }) satisfies Decodes<UserPromptSubmitHookInput>,\n UserPromptExpansion: event(\"UserPromptExpansion\", {\n expansion_type: Schema.Literals([\"slash_command\", \"mcp_prompt\"]),\n command_name: Schema.String,\n command_args: Schema.String,\n command_source: OptionalString,\n prompt: Schema.String,\n }) satisfies Decodes<UserPromptExpansionHookInput>,\n SessionStart: event(\"SessionStart\", {\n source: Schema.Literals([\"startup\", \"resume\", \"clear\", \"compact\", \"fork\"]),\n model: OptionalString,\n session_title: OptionalString,\n seconds_since_last_response: OptionalFinite,\n context_tokens: OptionalFinite,\n prompt_cache_likely_expired: Schema.optionalKey(Schema.Boolean),\n estimated_cache_write_usd: OptionalFinite,\n }) satisfies Decodes<SessionStartHookInput>,\n SessionEnd: event(\"SessionEnd\", {\n reason: Schema.Literals([\"clear\", \"resume\", \"logout\", \"prompt_input_exit\", \"other\"]),\n }) satisfies Decodes<SessionEndHookInput>,\n Stop: event(\"Stop\", stopping) satisfies Decodes<StopHookInput>,\n StopFailure: event(\"StopFailure\", {\n error: Schema.Literals([\n \"authentication_failed\",\n \"oauth_org_not_allowed\",\n \"account_on_hold\",\n \"verification_required\",\n \"billing_error\",\n \"rate_limit\",\n \"overloaded\",\n \"invalid_request\",\n \"model_not_found\",\n \"server_error\",\n \"unknown\",\n \"max_output_tokens\",\n \"cloud_credential_error\",\n ]),\n error_details: OptionalString,\n last_assistant_message: OptionalString,\n }) satisfies Decodes<StopFailureHookInput>,\n SubagentStart: subagentStart.annotate({\n identifier: \"SubagentStartInput\",\n }) satisfies Decodes<SubagentStartHookInput>,\n SubagentStop: subagentStop.annotate({\n identifier: \"SubagentStopInput\",\n }) satisfies Decodes<SubagentStopHookInput>,\n PreCompact: event(\"PreCompact\", {\n trigger: CompactTrigger,\n custom_instructions: Schema.String.pipe(Schema.NullOr),\n }) satisfies Decodes<PreCompactHookInput>,\n PostCompact: event(\"PostCompact\", {\n trigger: CompactTrigger,\n compact_summary: Schema.String,\n }) satisfies Decodes<PostCompactHookInput>,\n PreModelSwitch: event(\"PreModelSwitch\", {\n ...modelSwitch,\n source: Schema.Literals([\"command\", \"picker\", \"sdk\"]),\n }) satisfies Decodes<PreModelSwitchHookInput>,\n PostModelSwitch: event(\"PostModelSwitch\", {\n ...modelSwitch,\n source: Schema.Literals([\"command\", \"picker\", \"sdk\", \"auto\", \"resume\"]),\n }) satisfies Decodes<PostModelSwitchHookInput>,\n PermissionRequest: event(\"PermissionRequest\", {\n tool_name: Schema.String,\n tool_input: Schema.Unknown,\n permission_suggestions: PermissionUpdate.pipe(Schema.Array, Schema.optionalKey),\n mcp_server: OptionalMcpServer,\n }) satisfies Decodes<PermissionRequestHookInput>,\n PermissionDenied: event(\"PermissionDenied\", {\n ...toolCall,\n reason: Schema.String,\n }) satisfies Decodes<PermissionDeniedHookInput>,\n Setup: event(\"Setup\", {\n trigger: Schema.Literals([\"init\", \"maintenance\"]),\n }) satisfies Decodes<SetupHookInput>,\n TeammateIdle: event(\"TeammateIdle\", {\n teammate_name: Schema.String,\n team_name: Schema.String,\n }) satisfies Decodes<TeammateIdleHookInput>,\n TaskCreated: event(\"TaskCreated\", task) satisfies Decodes<TaskCreatedHookInput>,\n TaskCompleted: event(\"TaskCompleted\", task) satisfies Decodes<TaskCompletedHookInput>,\n Elicitation: event(\"Elicitation\", {\n mcp_server_name: Schema.String,\n message: Schema.String,\n mode: ElicitationMode.pipe(Schema.optionalKey),\n url: OptionalString,\n elicitation_id: OptionalString,\n requested_schema: JsonObject.pipe(Schema.optionalKey),\n }) satisfies Decodes<ElicitationHookInput>,\n ElicitationResult: event(\"ElicitationResult\", {\n mcp_server_name: Schema.String,\n elicitation_id: OptionalString,\n mode: ElicitationMode.pipe(Schema.optionalKey),\n action: ElicitationAction,\n content: JsonObject.pipe(Schema.optionalKey),\n }) satisfies Decodes<ElicitationResultHookInput>,\n ConfigChange: event(\"ConfigChange\", {\n source: Schema.Literals([\n \"user_settings\",\n \"project_settings\",\n \"local_settings\",\n \"policy_settings\",\n \"skills\",\n ]),\n file_path: OptionalString,\n }) satisfies Decodes<ConfigChangeHookInput>,\n WorktreeCreate: event(\"WorktreeCreate\", {\n name: Schema.String,\n }) satisfies Decodes<WorktreeCreateHookInput>,\n WorktreeRemove: event(\"WorktreeRemove\", {\n worktree_path: Schema.String,\n }) satisfies Decodes<WorktreeRemoveHookInput>,\n InstructionsLoaded: event(\"InstructionsLoaded\", {\n file_path: Schema.String,\n memory_type: Schema.Literals([\"User\", \"Project\", \"Local\", \"Managed\"]),\n load_reason: Schema.Literals([\n \"session_start\",\n \"nested_traversal\",\n \"path_glob_match\",\n \"include\",\n \"compact\",\n ]),\n globs: Schema.String.pipe(Schema.Array, Schema.optionalKey),\n trigger_file_path: OptionalString,\n parent_file_path: OptionalString,\n }) satisfies Decodes<InstructionsLoadedHookInput>,\n CwdChanged: event(\"CwdChanged\", {\n old_cwd: Schema.String,\n new_cwd: Schema.String,\n }) satisfies Decodes<CwdChangedHookInput>,\n FileChanged: event(\"FileChanged\", {\n file_path: Schema.String,\n event: Schema.Literals([\"change\", \"add\", \"unlink\"]),\n }) satisfies Decodes<FileChangedHookInput>,\n DirectoryAdded: event(\"DirectoryAdded\", {\n directory: Schema.String,\n source: Schema.Literals([\"slash_command\", \"register_repo_root\"]),\n }) satisfies Decodes<DirectoryAddedHookInput>,\n MessageDisplay: event(\"MessageDisplay\", {\n turn_id: Schema.String,\n message_id: Schema.String,\n index: Schema.Finite,\n final: Schema.Boolean,\n delta: Schema.String,\n }) satisfies Decodes<MessageDisplayHookInput>,\n PreSkillShellCommand: event(\"PreSkillShellCommand\", {\n tool_name: Schema.String,\n tool_input: SkillCommand,\n tool_use_id: Schema.String,\n command_name: Schema.String,\n command_source: OptionalString,\n invoked_by: Schema.Literals([\"user\", \"claude\", \"other\"]),\n }) satisfies Decodes<PreSkillShellCommandHookInput>,\n};\n\nexport type HookEvent = keyof typeof HookInputs;\n\nexport type HookInput<Event extends HookEvent> = (typeof HookInputs)[Event][\"Type\"];\n\nexport type ToolEvent =\n | \"PreToolUse\"\n | \"PostToolUse\"\n | \"PostToolUseFailure\"\n | \"PermissionRequest\"\n | \"PermissionDenied\";\n","import { Record, Schema } from \"effect\";\n\nimport type {\n Decodes,\n CwdChangedHookSpecificOutput,\n ElicitationHookSpecificOutput,\n ElicitationResultHookSpecificOutput,\n FileChangedHookSpecificOutput,\n MessageDisplayHookSpecificOutput,\n NotificationHookSpecificOutput,\n PermissionDeniedHookSpecificOutput,\n PermissionRequestHookSpecificOutput,\n PostModelSwitchHookSpecificOutput,\n PostToolBatchHookSpecificOutput,\n PostToolUseFailureHookSpecificOutput,\n PostToolUseHookSpecificOutput,\n PreModelSwitchHookSpecificOutput,\n PreSkillShellCommandHookSpecificOutput,\n PreToolUseHookSpecificOutput,\n SessionStartHookSpecificOutput,\n SetupHookSpecificOutput,\n StopHookSpecificOutput,\n SubagentStartHookSpecificOutput,\n SubagentStopHookSpecificOutput,\n UserPromptExpansionHookSpecificOutput,\n UserPromptSubmitHookSpecificOutput,\n WorktreeCreateHookSpecificOutput,\n} from \"./decodes.ts\";\nimport type { HookEvent } from \"./events.ts\";\nimport { ElicitationAction, PermissionBehavior, PermissionUpdate } from \"./shared.ts\";\n\nconst JsonObject = Schema.Record(Schema.String, Schema.Unknown);\n\nconst PermissionDecision = Schema.Literals([...PermissionBehavior.literals, \"defer\"]);\n\nconst specific = <Name extends HookEvent, Fields extends Schema.Struct.Fields>(\n name: Name,\n fields: Fields,\n): Schema.Struct<{ readonly hookEventName: Schema.Literal<Name> } & Fields> =>\n Schema.Struct({ hookEventName: Schema.Literal(name), ...fields });\n\nconst OptionalString = Schema.optionalKey(Schema.String);\n\nconst OptionalBoolean = Schema.optionalKey(Schema.Boolean);\n\nconst OptionalUnknown = Schema.optionalKey(Schema.Unknown);\n\nconst OptionalObject = JsonObject.pipe(Schema.optionalKey);\n\nconst AllowRequest = Schema.Struct({\n behavior: Schema.Literal(\"allow\"),\n updatedInput: OptionalObject,\n updatedPermissions: PermissionUpdate.pipe(Schema.Array, Schema.optionalKey),\n});\n\nconst DenyRequest = Schema.Struct({\n behavior: Schema.Literal(\"deny\"),\n message: OptionalString,\n interrupt: OptionalBoolean,\n});\n\nconst context = { additionalContext: OptionalString };\n\nconst watch = { watchPaths: Schema.String.pipe(Schema.Array, Schema.optionalKey) };\n\nconst elicitation = {\n action: ElicitationAction.pipe(Schema.optionalKey),\n content: OptionalObject,\n};\n\nconst OptionalDecision = PermissionDecision.pipe(Schema.optionalKey);\n\nexport const HookSpecificOutputs = {\n PreToolUse: specific(\"PreToolUse\", {\n permissionDecision: OptionalDecision,\n permissionDecisionReason: OptionalString,\n updatedInput: OptionalObject,\n ...context,\n }) satisfies Decodes<PreToolUseHookSpecificOutput>,\n PostToolUse: specific(\"PostToolUse\", {\n ...context,\n classifierContext: OptionalString,\n updatedToolOutput: OptionalUnknown,\n updatedMCPToolOutput: OptionalUnknown,\n }) satisfies Decodes<PostToolUseHookSpecificOutput>,\n PostToolUseFailure: specific(\n \"PostToolUseFailure\",\n context,\n ) satisfies Decodes<PostToolUseFailureHookSpecificOutput>,\n PostToolBatch: specific(\n \"PostToolBatch\",\n context,\n ) satisfies Decodes<PostToolBatchHookSpecificOutput>,\n Notification: specific(\"Notification\", context) satisfies Decodes<NotificationHookSpecificOutput>,\n UserPromptSubmit: specific(\"UserPromptSubmit\", {\n ...context,\n sessionTitle: OptionalString,\n suppressOriginalPrompt: OptionalBoolean,\n }) satisfies Decodes<UserPromptSubmitHookSpecificOutput>,\n UserPromptExpansion: specific(\"UserPromptExpansion\", {\n ...context,\n suppressOriginalPrompt: OptionalBoolean,\n }) satisfies Decodes<UserPromptExpansionHookSpecificOutput>,\n SessionStart: specific(\"SessionStart\", {\n ...context,\n ...watch,\n initialUserMessage: OptionalString,\n sessionTitle: OptionalString,\n reloadSkills: OptionalBoolean,\n }) satisfies Decodes<SessionStartHookSpecificOutput>,\n Setup: specific(\"Setup\", context) satisfies Decodes<SetupHookSpecificOutput>,\n Stop: specific(\"Stop\", context) satisfies Decodes<StopHookSpecificOutput>,\n SubagentStart: specific(\n \"SubagentStart\",\n context,\n ) satisfies Decodes<SubagentStartHookSpecificOutput>,\n SubagentStop: specific(\"SubagentStop\", context) satisfies Decodes<SubagentStopHookSpecificOutput>,\n PreModelSwitch: specific(\"PreModelSwitch\", {\n permissionDecision: PermissionBehavior.pipe(Schema.optionalKey),\n permissionDecisionReason: OptionalString,\n }) satisfies Decodes<PreModelSwitchHookSpecificOutput>,\n PostModelSwitch: specific(\n \"PostModelSwitch\",\n context,\n ) satisfies Decodes<PostModelSwitchHookSpecificOutput>,\n PermissionRequest: specific(\"PermissionRequest\", {\n decision: Schema.Union([AllowRequest, DenyRequest]),\n }) satisfies Decodes<PermissionRequestHookSpecificOutput>,\n PermissionDenied: specific(\"PermissionDenied\", {\n retry: OptionalBoolean,\n }) satisfies Decodes<PermissionDeniedHookSpecificOutput>,\n Elicitation: specific(\n \"Elicitation\",\n elicitation,\n ) satisfies Decodes<ElicitationHookSpecificOutput>,\n ElicitationResult: specific(\n \"ElicitationResult\",\n elicitation,\n ) satisfies Decodes<ElicitationResultHookSpecificOutput>,\n CwdChanged: specific(\"CwdChanged\", watch) satisfies Decodes<CwdChangedHookSpecificOutput>,\n FileChanged: specific(\"FileChanged\", watch) satisfies Decodes<FileChangedHookSpecificOutput>,\n WorktreeCreate: specific(\"WorktreeCreate\", {\n worktreePath: Schema.String,\n }) satisfies Decodes<WorktreeCreateHookSpecificOutput>,\n MessageDisplay: specific(\"MessageDisplay\", {\n displayContent: OptionalString,\n }) satisfies Decodes<MessageDisplayHookSpecificOutput>,\n PreSkillShellCommand: specific(\"PreSkillShellCommand\", {\n permissionDecision: OptionalDecision,\n permissionDecisionReason: OptionalString,\n updatedInput: OptionalObject,\n }) satisfies Decodes<PreSkillShellCommandHookSpecificOutput>,\n};\n\nexport type SpecificEvent = keyof typeof HookSpecificOutputs;\n\nconst commonFields = {\n continue: OptionalBoolean,\n suppressOutput: OptionalBoolean,\n stopReason: OptionalString,\n decision: Schema.Literals([\"approve\", \"block\"]).pipe(Schema.optionalKey),\n systemMessage: OptionalString,\n terminalSequence: OptionalString,\n reason: OptionalString,\n};\n\nexport const HookOutputSchema = Schema.Struct({\n ...commonFields,\n hookSpecificOutput: Schema.Union(Record.values(HookSpecificOutputs)).pipe(Schema.optionalKey),\n});\n\nexport type CommonOutput = Schema.Struct<typeof commonFields>[\"Type\"];\n\nexport type AnySpecificOutput = (typeof HookSpecificOutputs)[SpecificEvent][\"Type\"];\n\nexport type HookSpecificOutput<Event extends HookEvent> = Extract<\n AnySpecificOutput,\n { readonly hookEventName: Event }\n>;\n\nexport type HookOutput<Event extends HookEvent> = CommonOutput & {\n readonly hookSpecificOutput?: HookSpecificOutput<Event>;\n};\n","import {\n readHookInput,\n runHookWith,\n writeHookOutput,\n} from \"@r_masseater/masseater-utils/plugin-kit\";\nimport type { Platform } from \"@r_masseater/masseater-utils/plugin-kit\";\nimport { Array as Arr, Effect, Layer, Option, Record, Schema, pipe } from \"effect\";\nimport type { Stdio } from \"effect\";\n\nimport { HookInputs, HookOutputSchema } from \"#/entities/hook/index.ts\";\nimport type {\n Hook,\n HookEvent,\n HookInput,\n HookOutput,\n InputOf,\n Triggers,\n} from \"#/entities/hook/index.ts\";\n\ntype InputSchema = (typeof HookInputs)[HookEvent];\n\nconst schemaOf =\n (on: Triggers) =>\n (event: HookEvent): Option.Option<InputSchema> =>\n pipe(\n Option.fromUndefinedOr<unknown>(on[event]),\n Option.map((): InputSchema => HookInputs[event]),\n );\n\nconst EVENTS = Record.keys(HookInputs);\n\nconst inputSchemaOf = (on: Triggers): Schema.Union<readonly InputSchema[]> => {\n const pick = schemaOf(on);\n return Schema.Union(pipe(EVENTS, Arr.map(pick), Arr.getSomes));\n};\n\nconst writeOutput = writeHookOutput(HookOutputSchema);\n\nconst answerOf = (output: HookOutput<HookEvent>): (typeof HookOutputSchema)[\"Type\"] => output;\n\nconst SILENT = \"{}\";\n\nconst encodeAnswer = Schema.encodeEffect(Schema.fromJsonString(HookOutputSchema));\nconst EventCall = Schema.Struct({\n hook_event_name: Schema.Literals(EVENTS),\n tool_name: Schema.optionalKey(Schema.String),\n});\n\nconst eventCallOf = Schema.decodeUnknownOption(EventCall);\n\nconst taggedError = Schema.TaggedError;\n\nexport class ToolNotListed extends taggedError<ToolNotListed, { readonly brand: unique symbol }>()(\n \"ToolNotListed\",\n { event: Schema.String, tool: Schema.String },\n) {}\n\nconst listed = (tools: readonly string[], tool: string | undefined): boolean =>\n pipe(\n Option.fromUndefinedOr(tool),\n Option.exists((name) => Arr.contains(tools, name)),\n );\n\nconst isFor =\n <On extends Triggers>(on: On) =>\n (input: unknown): input is InputOf<On> =>\n pipe(\n eventCallOf(input),\n Option.exists(({ hook_event_name: event, tool_name: tool }) =>\n pipe(\n Option.fromUndefinedOr(on[event]),\n Option.flatMapNullishOr((trigger) => trigger.tools),\n Option.match({ onNone: () => true, onSome: (tools) => listed(tools, tool) }),\n ),\n ),\n );\n\nconst notListed = (input: HookInput<HookEvent>): ToolNotListed =>\n ToolNotListed.make({\n event: input.hook_event_name,\n tool: pipe(\n eventCallOf(input),\n Option.flatMapNullishOr(({ tool_name: tool }) => tool),\n Option.getOrElse(() => \"\"),\n ),\n });\n\n/** @internal */\nexport const handle = <On extends Triggers, Failure, Requirements>(\n hook: Hook<On, Failure, Requirements>,\n): Effect.Effect<void, Failure | Schema.SchemaError | ToolNotListed, Requirements | Stdio.Stdio> =>\n Effect.gen(function* handleEvent() {\n const decoded = yield* readHookInput(inputSchemaOf(hook.on));\n const input = yield* Effect.filterOrFail(Effect.succeed(decoded), isFor(hook.on), notListed);\n const output = yield* hook.run(input);\n const answer = answerOf(output);\n const text = yield* encodeAnswer(answer).pipe(Effect.orDie);\n if (text === SILENT) {\n return;\n }\n yield* writeOutput(answer);\n });\n\n/** @stability unstable */\nexport const runHook = <On extends Triggers, Failure>(\n hook: Hook<On, Failure, Platform>,\n serviceName: string,\n): void => {\n runHookWith({ serviceName, services: Layer.empty })(handle(hook));\n};\n\n/** @stability unstable */\nexport const runHookWithServices = <On extends Triggers, Failure, Provided, LayerFailure>(\n hook: Hook<On, Failure, Platform | Provided>,\n options: Readonly<{\n serviceName: string;\n services: Layer.Layer<Provided, LayerFailure, Platform>;\n }>,\n): void => {\n runHookWith(options)(handle(hook));\n};\n","import { Schema } from \"effect\";\n\nconst OptionalString = Schema.optionalKey(Schema.String);\n\nconst OptionalBoolean = Schema.optionalKey(Schema.Boolean);\n\nconst OptionalFinite = Schema.optionalKey(Schema.Finite);\n\nconst DefaultValue = Schema.Union([\n Schema.String,\n Schema.Finite,\n Schema.Boolean,\n Schema.Array(Schema.String),\n]);\n\nexport const UserConfigOptionSchema = Schema.Struct({\n type: Schema.Literals([\"string\", \"number\", \"boolean\", \"directory\", \"file\"]),\n title: Schema.String,\n description: Schema.String,\n required: OptionalBoolean,\n default: DefaultValue.pipe(Schema.optionalKey),\n options: Schema.String.pipe(Schema.Array, Schema.optionalKey),\n multiple: OptionalBoolean,\n sensitive: OptionalBoolean,\n min: OptionalFinite,\n max: OptionalFinite,\n});\n\nexport type UserConfigOption = typeof UserConfigOptionSchema.Type;\n\nconst Author = Schema.Struct({ name: Schema.String, email: OptionalString, url: OptionalString });\n\nconst manifestFields = {\n author: Author.pipe(Schema.optionalKey),\n homepage: OptionalString,\n repository: OptionalString,\n license: OptionalString,\n keywords: Schema.String.pipe(Schema.Array, Schema.optionalKey),\n types: OptionalString,\n userConfig: Schema.Record(Schema.String, UserConfigOptionSchema).pipe(Schema.optionalKey),\n mcpServers: Schema.Record(Schema.String, Schema.Unknown).pipe(Schema.optionalKey),\n};\n\nexport const ManifestFieldsSchema = Schema.Struct(manifestFields);\n\nexport type ManifestFields = typeof ManifestFieldsSchema.Type;\n\nexport const PluginManifestSchema = Schema.Struct({\n name: Schema.String,\n description: OptionalString,\n ...manifestFields,\n hooks: OptionalString,\n});\n\nexport type PluginManifest = typeof PluginManifestSchema.Type;\n\nconst CommandHook = Schema.Struct({\n type: Schema.Literal(\"command\"),\n command: Schema.String,\n args: Schema.Array(Schema.String),\n timeout: OptionalFinite,\n});\n\nconst HookGroupSchema = Schema.Struct({\n matcher: OptionalString,\n hooks: Schema.Array(CommandHook),\n});\n\nexport const HooksFileSchema = Schema.Struct({\n hooks: Schema.Record(Schema.String, Schema.Array(HookGroupSchema)),\n});\n\nexport type HooksFile = typeof HooksFileSchema.Type;\n\nexport type HookGroup = typeof HookGroupSchema.Type;\n","import { Record, Schema, pipe } from \"effect\";\n\nimport { HookInputs } from \"#/entities/hook/index.ts\";\n\nimport { ManifestFieldsSchema } from \"./manifest.ts\";\n\nconst TriggerSchema = Schema.Struct({\n timeout: Schema.optionalKey(Schema.Finite),\n tools: Schema.String.pipe(Schema.NonEmptyArray, Schema.optionalKey),\n matcher: Schema.optionalKey(Schema.String),\n});\n\nconst optionalTrigger = (): Schema.optionalKey<typeof TriggerSchema> =>\n Schema.optionalKey(TriggerSchema);\n\nconst TriggersSchema = Schema.Struct(pipe(HookInputs, Record.map(optionalTrigger)));\n\nconst HookDataSchema = Schema.Struct({\n entry: Schema.String,\n on: TriggersSchema,\n timeout: Schema.optionalKey(Schema.Finite),\n node: Schema.String.pipe(Schema.Array, Schema.optionalKey),\n});\n\nexport const PluginDataSchema = Schema.Struct({\n entry: Schema.String,\n hooks: HookDataSchema.pipe(Schema.Array, Schema.optionalKey),\n hooksFile: Schema.optionalKey(Schema.String),\n installDependencies: Schema.optionalKey(Schema.Boolean),\n manifest: Schema.optionalKey(ManifestFieldsSchema),\n});\n\nexport type PluginData = typeof PluginDataSchema.Type;\n\nexport type HookData = typeof HookDataSchema.Type;\n\nexport type TriggerData = typeof TriggerSchema.Type;\n\nexport const PluginModuleSchema = Schema.Struct({ default: PluginDataSchema });\n","export const INSTALL_DEPS_FILE = \"hooks/install-deps.sh\";\n\nexport const INSTALL_DEPS_SCRIPT = `#!/bin/sh\nset -u\nroot=\"\\${CLAUDE_PLUGIN_ROOT:-$(dirname \"$(dirname \"$0\")\")}\"\ndata=\"\\${CLAUDE_PLUGIN_DATA:-}\"\nwait_seconds=\"\\${HOOK_DEPS_WAIT_SECONDS:-8}\"\n\ninstalled() {\n [ -d \"$data/node_modules\" ] && cmp -s \"$root/package.json\" \"$data/installed.json\"\n}\n\nprovide() {\n mkdir -p \"$data\"\n installed && return 0\n lock=\"$data/install.lock\"\n if [ -d \"$lock\" ] && [ -n \"$(find \"$lock\" -maxdepth 0 -mmin +3)\" ]; then\n rm -rf \"$lock\"\n fi\n if mkdir \"$lock\" 2>/dev/null; then\n cp \"$root/package.json\" \"$data/package.json\"\n npm install --omit=dev --no-audit --no-fund --no-package-lock --prefix \"$data\" >/dev/null &&\n cp \"$root/package.json\" \"$data/installed.json\"\n rm -rf \"$lock\"\n else\n tries=$((wait_seconds * 5))\n while [ \"$tries\" -gt 0 ] && ! installed; do\n sleep 0.2\n tries=$((tries - 1))\n done\n fi\n installed\n}\n\nif [ ! -e \"$root/node_modules\" ]; then\n [ -n \"$data\" ] || exit 0\n provide || exit 0\n ln -s \"$data/node_modules\" \"$root/node_modules\" 2>/dev/null\n [ -e \"$root/node_modules\" ] || exit 0\nfi\n\n[ \"$#\" -gt 0 ] || exit 0\nscript=\"$1\"\nshift\nexec node \"$@\" \"$root/hooks/$script\"\n`;\n","import { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nconst WIDTH = 100;\nconst STEP = 2;\nconst AFTER_CLOSE = 1;\nconst CLOSING = /^\\s*\\]/u;\nconst TRAILING_COMMA = /,$/u;\n\nconst indentOf = (line: string): number => Str.length(line) - Str.length(Str.trimStart(line));\n\nconst isPrimitiveAt =\n (indent: number) =>\n (line: string): boolean =>\n indentOf(line) === indent && !Str.endsWith(\"{\")(line) && !Str.endsWith(\"[\")(line);\n\nconst closeOf = (rest: readonly string[], indent: number): Option.Option<number> =>\n Arr.findFirstIndex(rest, (line) => indentOf(line) === indent && CLOSING.test(line));\n\nconst inlineOf = (head: string, rest: readonly string[], close: number): Option.Option<string> => {\n const items = Arr.take(rest, close);\n const itemIndent = indentOf(head) + STEP;\n const closing = pipe(\n Arr.get(rest, close),\n Option.map(Str.trim),\n Option.getOrElse(() => \"]\"),\n );\n const line = `${head}${pipe(\n items,\n Arr.map((item) => pipe(Str.trim(item), Str.replace(TRAILING_COMMA, \"\"))),\n Arr.join(\", \"),\n )}${closing}`;\n return Option.liftPredicate(\n line,\n () =>\n Arr.isReadonlyArrayNonEmpty(items) &&\n pipe(items, Arr.every(isPrimitiveAt(itemIndent))) &&\n Str.length(line) <= WIDTH,\n );\n};\n\nconst collapsed = (lines: readonly string[]): readonly string[] =>\n Arr.matchLeft(lines, {\n onEmpty: (): readonly string[] => [],\n onNonEmpty: (head, rest): readonly string[] => {\n const inline = pipe(\n Option.liftPredicate(head, Str.endsWith(\"[\")),\n Option.flatMap(() => closeOf(rest, indentOf(head))),\n Option.flatMap((close) =>\n pipe(\n inlineOf(head, rest, close),\n Option.map((line) => [line, ...collapsed(Arr.drop(rest, close + AFTER_CLOSE))]),\n ),\n ),\n );\n return Option.getOrElse(inline, () => [head, ...collapsed(rest)]);\n },\n });\n\nexport const formatted = (json: string): string =>\n pipe(Str.split(json, \"\\n\"), collapsed, Arr.join(\"\\n\"));\n","import {\n Array as Arr,\n Effect,\n Number as Num,\n Option,\n Record,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nimport { HookInputs } from \"#/entities/hook/index.ts\";\nimport type { HookEvent, AnyHook } from \"#/entities/hook/index.ts\";\n\nimport { PluginModuleSchema } from \"./definition.ts\";\nimport type { HookData, PluginData, TriggerData } from \"./definition.ts\";\nimport { INSTALL_DEPS_FILE, INSTALL_DEPS_SCRIPT } from \"./install-deps.ts\";\nimport { formatted } from \"./layout.ts\";\nimport { HooksFileSchema, PluginManifestSchema } from \"./manifest.ts\";\nimport type { HookGroup, HooksFile, ManifestFields, PluginManifest } from \"./manifest.ts\";\n\nexport const DEFAULT_HOOKS_FILE = \"hooks/hooks.json\";\n\nconst MANIFEST_FILE = \".claude-plugin/plugin.json\";\nconst PLUGIN_ROOT = `\\${CLAUDE_PLUGIN_ROOT}`;\nconst INDENT = 2;\nconst INSTALL_TIMEOUT = 120;\nconst HOOKS_DIR = \"hooks/\";\nconst HOOKS_DIR_LENGTH = Str.length(HOOKS_DIR);\nconst INSTALLER = `${PLUGIN_ROOT}/${INSTALL_DEPS_FILE}`;\nconst REGEX_SPECIAL = /[$()*+.?[\\\\\\]^{|}]/gu;\n\nexport type PluginDefinition = Readonly<{\n entry: string;\n hooks?: readonly AnyHook[];\n\n hooksFile?: string;\n installDependencies?: boolean;\n manifest?: ManifestFields;\n}>;\n\nexport const definePlugin = (plugin: PluginDefinition): PluginDefinition => plugin;\n\nconst taggedError = Schema.TaggedError;\n\nexport class HookOutsidePlugin extends taggedError<\n HookOutsidePlugin,\n { readonly brand: unique symbol }\n>()(\"HookOutsidePlugin\", { hook: Schema.String, root: Schema.String }) {}\n\nexport type PluginFile = Readonly<{ path: string; text: string }>;\n\nexport type PackageFields = Readonly<{ name: string; description?: string }>;\n\ntype EventTrigger = readonly [HookEvent, TriggerData];\n\nconst rootOf = (entry: string): string => new URL(\".\", entry).href;\n\nconst moduleIn = (root: string, hook: HookData): Effect.Effect<string, HookOutsidePlugin> =>\n pipe(\n Option.liftPredicate(hook.entry, Str.startsWith(root)),\n Option.map(Str.slice(root.length)),\n Effect.fromOption,\n Effect.mapError(() => HookOutsidePlugin.make({ hook: hook.entry, root })),\n );\n\nconst escaped = Str.replaceAll(REGEX_SPECIAL, String.raw`\\$&`);\n\nconst toolsMatcher = (tools: readonly string[]): string =>\n `^(${pipe(tools, Arr.map(escaped), Arr.join(\"|\"))})$`;\n\nconst matcherOf = (trigger: TriggerData): Option.Option<string> =>\n pipe(\n Option.fromUndefinedOr(trigger.tools),\n Option.map(toolsMatcher),\n Option.orElse(() => Option.fromUndefinedOr(trigger.matcher)),\n );\n\nconst triggerOf =\n (on: HookData[\"on\"]) =>\n (event: HookEvent): Option.Option<EventTrigger> =>\n pipe(\n Option.fromUndefinedOr(on[event]),\n Option.map((trigger: TriggerData): EventTrigger => [event, trigger]),\n );\n\nconst triggersOf = (on: HookData[\"on\"]): readonly EventTrigger[] =>\n pipe(Record.keys(HookInputs), Arr.map(triggerOf(on)), Arr.getSomes);\n\ntype Command = Readonly<{\n command: string;\n args: readonly string[];\n timeout: Option.Option<number>;\n}>;\n\nconst timeoutOf = (hook: HookData, trigger: TriggerData): Option.Option<number> =>\n Option.firstSomeOf([\n Option.fromUndefinedOr(trigger.timeout),\n Option.fromUndefinedOr(hook.timeout),\n ]);\n\nconst nodeCommand = (hook: HookData, module: string, trigger: TriggerData): Command => ({\n command: \"node\",\n args: [...(hook.node ?? []), `${PLUGIN_ROOT}/${module}`],\n timeout: timeoutOf(hook, trigger),\n});\n\nconst fromHooksDir = (module: string): string =>\n pipe(\n Option.liftPredicate(module, Str.startsWith(HOOKS_DIR)),\n Option.map(Str.slice(HOOKS_DIR_LENGTH)),\n Option.getOrElse(() => `../${module}`),\n );\n\nconst installerCommand = (hook: HookData, module: string, trigger: TriggerData): Command => ({\n command: \"sh\",\n args: [INSTALLER, fromHooksDir(module), ...(hook.node ?? [])],\n timeout: Option.some(\n pipe(\n timeoutOf(hook, trigger),\n Option.getOrElse(() => INSTALL_TIMEOUT),\n Num.max(INSTALL_TIMEOUT),\n ),\n ),\n});\n\nconst groupOf = (trigger: TriggerData, { command, args, timeout }: Command): HookGroup => {\n const entry = {\n type: \"command\" as const,\n command,\n args,\n ...Option.match(timeout, { onNone: () => ({}), onSome: (seconds) => ({ timeout: seconds }) }),\n };\n const matcher = Option.match(matcherOf(trigger), {\n onNone: () => ({}),\n onSome: (text) => ({ matcher: text }),\n });\n return { ...matcher, hooks: [entry] };\n};\n\nconst groupsOf = Effect.fn(\"groupsOf\")(function* groupsOf(\n root: string,\n installs: boolean,\n hook: HookData,\n) {\n const module = yield* moduleIn(root, hook);\n return pipe(\n triggersOf(hook.on),\n Arr.map(([event, trigger]): readonly [string, HookGroup] => {\n const command = pipe(\n Option.liftPredicate(event, (name) => installs && name === \"SessionStart\"),\n Option.match({\n onNone: () => nodeCommand(hook, module, trigger),\n onSome: () => installerCommand(hook, module, trigger),\n }),\n );\n return [event, groupOf(trigger, command)];\n }),\n );\n});\n\nconst startsSession = (hooks: readonly HookData[]): boolean =>\n pipe(\n hooks,\n Arr.some((hook) => Option.isSome(Option.fromUndefinedOr(hook.on.SessionStart))),\n );\n\nconst installOnly = (\n installs: boolean,\n hooks: readonly HookData[],\n): readonly (readonly [string, HookGroup])[] =>\n pipe(\n Option.liftPredicate(installs, (value) => value && !startsSession(hooks)),\n Option.map((): readonly [string, HookGroup] => [\n \"SessionStart\",\n { hooks: [{ type: \"command\", command: \"sh\", args: [INSTALLER], timeout: INSTALL_TIMEOUT }] },\n ]),\n Option.toArray,\n );\n\nconst hooksFileOf = Effect.fn(\"hooksFileOf\")(function* hooksFileOf(\n root: string,\n installs: boolean,\n hooks: readonly HookData[],\n) {\n const entries = yield* Effect.forEach(hooks, (hook) => groupsOf(root, installs, hook), {\n concurrency: 1,\n });\n return pipe(\n [installOnly(installs, hooks), ...entries],\n Arr.flatten,\n Arr.groupBy(([event]): string => event),\n Record.map(Arr.map(([, group]) => group)),\n (grouped): HooksFile => ({ hooks: grouped }),\n );\n});\n\nconst encodeManifest = Schema.encodeEffect(\n Schema.fromJsonString(PluginManifestSchema, { space: INDENT }),\n);\nconst encodeHooks = Schema.encodeEffect(Schema.fromJsonString(HooksFileSchema, { space: INDENT }));\n\nconst manifestOf = (\n plugin: PluginData,\n { name, description }: PackageFields,\n named: Option.Option<string>,\n): PluginManifest => ({\n name,\n ...Option.match(Option.fromUndefinedOr(description), {\n onNone: () => ({}),\n onSome: (text) => ({ description: text }),\n }),\n ...plugin.manifest,\n ...Option.match(named, { onNone: () => ({}), onSome: (path) => ({ hooks: `./${path}` }) }),\n});\n\nconst hooksFileTextOf = Effect.fn(\"hooksFileTextOf\")(function* hooksFileTextOf(\n root: string,\n installs: boolean,\n hooks: Arr.NonEmptyReadonlyArray<HookData>,\n) {\n const file = yield* hooksFileOf(root, installs, hooks);\n return yield* encodeHooks(file).pipe(Effect.orDie);\n});\n\nexport const pluginFiles = Effect.fn(\"pluginFiles\")(function* pluginFiles(\n plugin: PluginData,\n fields: PackageFields,\n) {\n const hooks = Option.liftPredicate(plugin.hooks ?? [], Arr.isReadonlyArrayNonEmpty);\n const installs = plugin.installDependencies === true;\n const hooksPath = plugin.hooksFile ?? DEFAULT_HOOKS_FILE;\n const named = pipe(\n hooks,\n Option.map(() => hooksPath),\n Option.filter((path) => path !== DEFAULT_HOOKS_FILE),\n );\n const manifest = yield* encodeManifest(manifestOf(plugin, fields, named)).pipe(Effect.orDie);\n const hooksText = yield* pipe(\n hooks,\n Option.map((list) => hooksFileTextOf(rootOf(plugin.entry), installs, list)),\n Effect.transposeOption,\n );\n return [\n { path: MANIFEST_FILE, text: `${formatted(manifest)}\\n` },\n ...Option.match(hooksText, {\n onNone: (): readonly PluginFile[] => [],\n onSome: (text): readonly PluginFile[] => [{ path: hooksPath, text: `${formatted(text)}\\n` }],\n }),\n ...pipe(\n Option.liftPredicate(installs, Boolean),\n Option.map((): PluginFile => ({ path: INSTALL_DEPS_FILE, text: INSTALL_DEPS_SCRIPT })),\n Option.toArray,\n ),\n ];\n});\n\nconst decodeModule = Schema.decodeUnknownEffect(PluginModuleSchema);\n\nexport const moduleFiles = Effect.fn(\"moduleFiles\")(function* moduleFiles(\n loaded: unknown,\n fields: PackageFields,\n) {\n const plugin = yield* decodeModule(loaded);\n return yield* pluginFiles(plugin.default, fields);\n});\n"],"mappings":";;;AAqBA,MAAa,SAAS,YAA8C,EAClE,oBAAoB;CAClB,eAAe;CACf,oBAAoB;CACpB,0BAA0B;AAC5B,EACF;AAEA,MAAa,QAAQ,YAA8C,EACjE,oBAAoB;CAClB,eAAe;CACf,oBAAoB;CACpB,0BAA0B;AAC5B,EACF;AAEA,MAAa,cACX,OACA,UAC0B,EAC1B,oBAA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ACA,OAAO,KAAK,SAAS,gBAAgB,OAAO,OAAO,KAAK,GAAG,UAAU,IAAI,CAAC,GAC1E,OAAO,eACT;CACA,OAAO;EACL;GAAE,MAAM;GAAe,MAAM,GAAG,UAAU,QAAQ,EAAE;EAAI;EACxD,GAAG,OAAO,MAAM,WAAW;GACzB,cAAqC,CAAC;GACtC,SAAS,SAAgC,CAAC;IAAE,MAAM;IAAW,MAAM,GAAG,UAAU,IAAI,EAAE;GAAI,CAAC;EAC7F,CAAC;EACD,GAAG,KACD,OAAO,cAAc,UAAU,OAAO,GACtC,OAAO,WAAuB;GAAE,MAAM;GAAmB,MAAM;EAAoB,EAAE,GACrF,OAAO,OACT;CACF;AACF,CAAC;AAED,MAAM,eAAe,OAAO,oBAAoB,kBAAkB;AAElE,MAAa,cAAc,OAAO,GAAG,aAAa,CAAC,CAAC,UAAU,YAC5D,QACA,QACA;CACA,MAAM,SAAS,OAAO,aAAa,MAAM;CACzC,OAAO,OAAO,YAAY,OAAO,SAAS,MAAM;AAClD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@r_masseater/cc-effect-hooks",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Write Claude Code plugin hooks with Effect: typed input for every hook event and tool, typed answers, and plugin.json and hooks.json generated from the same definitions.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"claude-code",
|
|
7
|
+
"claude-code-plugin",
|
|
8
|
+
"effect",
|
|
9
|
+
"hooks",
|
|
10
|
+
"tanstack-intent"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/masseater/ecosystems/tree/main/libs/cc-effect-hooks#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/masseater/ecosystems/issues"
|
|
15
|
+
},
|
|
5
16
|
"license": "MIT",
|
|
6
17
|
"repository": {
|
|
7
18
|
"type": "git",
|
|
8
19
|
"url": "git+https://github.com/masseater/ecosystems.git",
|
|
9
20
|
"directory": "libs/cc-effect-hooks"
|
|
10
21
|
},
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"
|
|
22
|
+
"files": [
|
|
23
|
+
"LICENSE",
|
|
24
|
+
"dist",
|
|
25
|
+
"skills/write-plugin-hooks"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"imports": {
|
|
30
|
+
"#/*": "./src/*"
|
|
31
|
+
},
|
|
32
|
+
"exports": {
|
|
33
|
+
".": "./dist/index.mjs",
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public",
|
|
38
|
+
"provenance": true
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@r_masseater/masseater-utils": ">=0.9.3"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.332",
|
|
45
|
+
"@effect/platform-node": "4.2.0",
|
|
46
|
+
"@effect/vitest": "4.2.0",
|
|
47
|
+
"@types/node": "26.6.11",
|
|
48
|
+
"effect": "4.2.0",
|
|
49
|
+
"vite-plus": "1.9.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"@anthropic-ai/claude-agent-sdk": ">=0.3.332",
|
|
53
|
+
"@effect/platform-node": "^4.1.0",
|
|
54
|
+
"effect": "^4.1.0"
|
|
55
|
+
},
|
|
56
|
+
"peerDependenciesMeta": {
|
|
57
|
+
"@anthropic-ai/claude-agent-sdk": {
|
|
58
|
+
"optional": true
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=26.13.1"
|
|
14
63
|
}
|
|
15
64
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: write-plugin-hooks
|
|
3
|
+
description: >
|
|
4
|
+
Use when writing or changing a Claude Code plugin hook in TypeScript with Effect, or the plugin.json
|
|
5
|
+
and hooks.json of such a plugin: defineHook with its events, tools and timeout, the typed answers,
|
|
6
|
+
runHook, and definePlugin with pluginFiles.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# write-plugin-hooks
|
|
10
|
+
|
|
11
|
+
A hook written against raw JSON repeats the event's input shape in each plugin, and a matcher in hooks.json drifts from what the code expects. `defineHook` names the events and tools once, types the input from them, and the plugin's files are generated from the same values.
|
|
12
|
+
|
|
13
|
+
## Setup
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
bun add @r_masseater/cc-effect-hooks effect @effect/platform-node
|
|
17
|
+
bun add -d @anthropic-ai/claude-agent-sdk
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## A hook
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
/// <reference types="node" />
|
|
24
|
+
import { defineHook, deny, runHook } from "@r_masseater/cc-effect-hooks";
|
|
25
|
+
import { Effect } from "effect";
|
|
26
|
+
|
|
27
|
+
export const guard = defineHook({
|
|
28
|
+
entry: import.meta.url,
|
|
29
|
+
on: { PreToolUse: { tools: ["Bash"] } },
|
|
30
|
+
run: (input) =>
|
|
31
|
+
Effect.succeed(input.tool_input.command.includes("--no-verify") ? deny("Run the hooks.") : {}),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (import.meta.main) runHook(guard, "my-plugin");
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- `on` maps each event to its trigger: `tools` for a list of tool names (it types `tool_input`), `matcher` for a raw matcher, and `timeout` for that event only.
|
|
38
|
+
- One module may run for several events; narrow the input with `input.hook_event_name`.
|
|
39
|
+
- Return `{}` to say nothing. `deny(reason)` and `allow(reason)` answer `PreToolUse`; `addContext(event, text)` adds text for Claude. Any other answer is a plain object of the event's answer type.
|
|
40
|
+
- Fail with `blockHook(reason)` to block with exit code 2.
|
|
41
|
+
- `runHookWithServices(hook, { serviceName, services })` adds a layer the hook needs.
|
|
42
|
+
|
|
43
|
+
## The plugin
|
|
44
|
+
|
|
45
|
+
Export a `definePlugin({ entry: import.meta.url, hooks, manifest })` value from the plugin root. `pluginFiles(plugin, { name, description })` returns plugin.json and the hooks file. Do not edit those files by hand; regenerate them. plugin.json gets no `version`. A plugin whose hooks import npm packages sets `installDependencies: true`: `pluginFiles` then also writes `hooks/install-deps.sh`, which installs the `package.json` dependencies into `CLAUDE_PLUGIN_DATA` at SessionStart and links them as `node_modules`, and runs the SessionStart hooks through it.
|