@pluginfinity/core 0.3.2 → 0.4.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/config.js +1 -1
- package/env.js +1 -1
- package/frontmatter.js +1 -1
- package/hook-io/build.js +152 -0
- package/hook-io/events.js +502 -0
- package/hook-io/index.js +37 -0
- package/hook-io/tool-inputs.js +91 -0
- package/hook-io/zig.js +78 -0
- package/hooks.js +137 -5
- package/index.d.ts +334 -8
- package/index.js +6 -2
- package/lsp.js +1 -1
- package/monitors.js +1 -1
- package/package.json +2 -2
- package/target.js +5 -0
- package/version.js +2 -2
package/index.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The platform-free pluginfinity domain model.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Holds the config schemas (plugin-wide fields, hooks, MCP and LSP servers and the
|
|
6
|
+
* per-target override factory), skill and agent frontmatter in Claude Code's
|
|
7
|
+
* field names, and the `Target` schema that describes a host by what it can do.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
1
11
|
import { Schema } from "effect";
|
|
2
12
|
/**
|
|
3
13
|
* Every Claude Code hook event, the vocabulary a plugin's `hooks` config is
|
|
@@ -5,13 +15,13 @@ import { Schema } from "effect";
|
|
|
5
15
|
*
|
|
6
16
|
* @public
|
|
7
17
|
*/
|
|
8
|
-
export declare const CLAUDE_HOOK_EVENTS: readonly ["SessionStart", "Setup", "UserPromptSubmit", "UserPromptExpansion", "PreToolUse", "PermissionRequest", "PermissionDenied", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "Notification", "MessageDisplay", "SubagentStart", "SubagentStop", "TaskCreated", "TaskCompleted", "Stop", "StopFailure", "TeammateIdle", "InstructionsLoaded", "ConfigChange", "CwdChanged", "DirectoryAdded", "FileChanged", "WorktreeCreate", "WorktreeRemove", "PreCompact", "PostCompact", "PreModelSwitch", "PostModelSwitch", "Elicitation", "ElicitationResult", "SessionEnd"];
|
|
18
|
+
export declare const CLAUDE_HOOK_EVENTS: readonly ["SessionStart", "Setup", "UserPromptSubmit", "UserPromptExpansion", "PreSkillShellCommand", "PreToolUse", "PermissionRequest", "PermissionDenied", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "Notification", "MessageDisplay", "SubagentStart", "SubagentStop", "TaskCreated", "TaskCompleted", "Stop", "StopFailure", "TeammateIdle", "InstructionsLoaded", "ConfigChange", "CwdChanged", "DirectoryAdded", "FileChanged", "WorktreeCreate", "WorktreeRemove", "PreCompact", "PostCompact", "PreModelSwitch", "PostModelSwitch", "Elicitation", "ElicitationResult", "SessionEnd"];
|
|
9
19
|
/**
|
|
10
20
|
* A Claude Code hook event name.
|
|
11
21
|
*
|
|
12
22
|
* @public
|
|
13
23
|
*/
|
|
14
|
-
export declare const ClaudeHookEvent: Schema.Literals<readonly ["SessionStart", "Setup", "UserPromptSubmit", "UserPromptExpansion", "PreToolUse", "PermissionRequest", "PermissionDenied", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "Notification", "MessageDisplay", "SubagentStart", "SubagentStop", "TaskCreated", "TaskCompleted", "Stop", "StopFailure", "TeammateIdle", "InstructionsLoaded", "ConfigChange", "CwdChanged", "DirectoryAdded", "FileChanged", "WorktreeCreate", "WorktreeRemove", "PreCompact", "PostCompact", "PreModelSwitch", "PostModelSwitch", "Elicitation", "ElicitationResult", "SessionEnd"]>;
|
|
24
|
+
export declare const ClaudeHookEvent: Schema.Literals<readonly ["SessionStart", "Setup", "UserPromptSubmit", "UserPromptExpansion", "PreSkillShellCommand", "PreToolUse", "PermissionRequest", "PermissionDenied", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "Notification", "MessageDisplay", "SubagentStart", "SubagentStop", "TaskCreated", "TaskCompleted", "Stop", "StopFailure", "TeammateIdle", "InstructionsLoaded", "ConfigChange", "CwdChanged", "DirectoryAdded", "FileChanged", "WorktreeCreate", "WorktreeRemove", "PreCompact", "PostCompact", "PreModelSwitch", "PostModelSwitch", "Elicitation", "ElicitationResult", "SessionEnd"]>;
|
|
15
25
|
/**
|
|
16
26
|
* The decoded `ClaudeHookEvent`.
|
|
17
27
|
*
|
|
@@ -43,6 +53,10 @@ export declare const ScriptHook: Schema.Struct<{
|
|
|
43
53
|
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
44
54
|
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
45
55
|
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
56
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
57
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
58
|
+
readonly async: Schema.optionalKey<Schema.Boolean>;
|
|
59
|
+
readonly asyncRewake: Schema.optionalKey<Schema.Boolean>;
|
|
46
60
|
readonly script: Schema.String;
|
|
47
61
|
readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
48
62
|
}>;
|
|
@@ -56,11 +70,113 @@ export declare const CommandHook: Schema.Struct<{
|
|
|
56
70
|
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
57
71
|
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
58
72
|
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
73
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
74
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
75
|
+
readonly async: Schema.optionalKey<Schema.Boolean>;
|
|
76
|
+
readonly asyncRewake: Schema.optionalKey<Schema.Boolean>;
|
|
59
77
|
readonly command: Schema.String;
|
|
78
|
+
/** The shell the command runs in, on a host that lets a hook choose. Defaults to the host's own. */
|
|
79
|
+
readonly shell: Schema.optionalKey<Schema.Literals<readonly ["bash", "powershell"]>>;
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* A hook that runs a prebuilt native program, one file per platform. `binary`
|
|
83
|
+
* is the path the files share: the build ships every `<binary>-<os>-<arch>`
|
|
84
|
+
* the plugin holds, named as `uname -s` and `uname -m` print there (such as
|
|
85
|
+
* `hooks/bin/guard-Darwin-arm64` and `hooks/bin/guard-Linux-x86_64`), and
|
|
86
|
+
* writes each host a command that runs the one for the machine.
|
|
87
|
+
*
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
export declare const BinaryHook: Schema.Struct<{
|
|
91
|
+
readonly matcher: Schema.optionalKey<Schema.String>;
|
|
92
|
+
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
93
|
+
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
94
|
+
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
95
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
96
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
97
|
+
readonly async: Schema.optionalKey<Schema.Boolean>;
|
|
98
|
+
readonly asyncRewake: Schema.optionalKey<Schema.Boolean>;
|
|
99
|
+
readonly binary: Schema.String;
|
|
100
|
+
readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
101
|
+
}>;
|
|
102
|
+
/**
|
|
103
|
+
* A hook that sends the event's JSON to a URL as an HTTP POST and reads the
|
|
104
|
+
* response body as the hook's answer.
|
|
105
|
+
*
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
108
|
+
export declare const HttpHook: Schema.Struct<{
|
|
109
|
+
readonly matcher: Schema.optionalKey<Schema.String>;
|
|
110
|
+
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
111
|
+
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
112
|
+
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
113
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
114
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
115
|
+
readonly http: Schema.String;
|
|
116
|
+
/** Extra request headers. A value may name an environment variable as `$NAME` or `${NAME}`. */
|
|
117
|
+
readonly headers: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
118
|
+
/** The environment variables `headers` may interpolate. Any other reads as empty. */
|
|
119
|
+
readonly allowedEnvVars: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
120
|
+
}>;
|
|
121
|
+
/**
|
|
122
|
+
* A hook that calls a tool on an MCP server and reads its text output as the
|
|
123
|
+
* hook's answer. A `server` that names one of the plugin's own servers is
|
|
124
|
+
* written with the plugin's scope.
|
|
125
|
+
*
|
|
126
|
+
* @public
|
|
127
|
+
*/
|
|
128
|
+
export declare const McpToolHook: Schema.Struct<{
|
|
129
|
+
readonly matcher: Schema.optionalKey<Schema.String>;
|
|
130
|
+
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
131
|
+
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
132
|
+
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
133
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
134
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
135
|
+
readonly mcpTool: Schema.Struct<{
|
|
136
|
+
readonly server: Schema.String;
|
|
137
|
+
readonly tool: Schema.String;
|
|
138
|
+
/** The tool's arguments. A string value may take a field of the event as `${tool_input.file_path}`. */
|
|
139
|
+
readonly input: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
140
|
+
}>;
|
|
60
141
|
}>;
|
|
61
142
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
143
|
+
* A hook that asks a model one question and reads `{ok, reason}` back.
|
|
144
|
+
* `$ARGUMENTS` in the prompt is the event's JSON.
|
|
145
|
+
*
|
|
146
|
+
* @public
|
|
147
|
+
*/
|
|
148
|
+
export declare const PromptHook: Schema.Struct<{
|
|
149
|
+
readonly matcher: Schema.optionalKey<Schema.String>;
|
|
150
|
+
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
151
|
+
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
152
|
+
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
153
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
154
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
155
|
+
readonly prompt: Schema.String;
|
|
156
|
+
readonly model: Schema.optionalKey<Schema.String>;
|
|
157
|
+
/** Give a refusal's reason back to the agent and continue, instead of ending the turn. */
|
|
158
|
+
readonly continueOnBlock: Schema.optionalKey<Schema.Boolean>;
|
|
159
|
+
}>;
|
|
160
|
+
/**
|
|
161
|
+
* A hook that runs a subagent with tool access to verify a condition; `agent`
|
|
162
|
+
* is its prompt. Experimental on Claude Code.
|
|
163
|
+
*
|
|
164
|
+
* @public
|
|
165
|
+
*/
|
|
166
|
+
export declare const AgentHook: Schema.Struct<{
|
|
167
|
+
readonly matcher: Schema.optionalKey<Schema.String>;
|
|
168
|
+
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
169
|
+
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
170
|
+
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
171
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
172
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
173
|
+
readonly agent: Schema.String;
|
|
174
|
+
readonly model: Schema.optionalKey<Schema.String>;
|
|
175
|
+
}>;
|
|
176
|
+
/**
|
|
177
|
+
* One hook: exactly one of `script`, `command`, `binary`, `http`, `mcpTool`,
|
|
178
|
+
* `prompt` or `agent`. Decode strictly, or a mixed entry decodes as whichever
|
|
179
|
+
* member matches first.
|
|
64
180
|
*
|
|
65
181
|
* @public
|
|
66
182
|
*/
|
|
@@ -69,6 +185,10 @@ export declare const HookEntry: Schema.Union<readonly [Schema.Struct<{
|
|
|
69
185
|
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
70
186
|
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
71
187
|
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
188
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
189
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
190
|
+
readonly async: Schema.optionalKey<Schema.Boolean>;
|
|
191
|
+
readonly asyncRewake: Schema.optionalKey<Schema.Boolean>;
|
|
72
192
|
readonly script: Schema.String;
|
|
73
193
|
readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
74
194
|
}>, Schema.Struct<{
|
|
@@ -76,8 +196,95 @@ export declare const HookEntry: Schema.Union<readonly [Schema.Struct<{
|
|
|
76
196
|
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
77
197
|
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
78
198
|
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
199
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
200
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
201
|
+
readonly async: Schema.optionalKey<Schema.Boolean>;
|
|
202
|
+
readonly asyncRewake: Schema.optionalKey<Schema.Boolean>;
|
|
79
203
|
readonly command: Schema.String;
|
|
204
|
+
/** The shell the command runs in, on a host that lets a hook choose. Defaults to the host's own. */
|
|
205
|
+
readonly shell: Schema.optionalKey<Schema.Literals<readonly ["bash", "powershell"]>>;
|
|
206
|
+
}>, Schema.Struct<{
|
|
207
|
+
readonly matcher: Schema.optionalKey<Schema.String>;
|
|
208
|
+
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
209
|
+
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
210
|
+
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
211
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
212
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
213
|
+
readonly async: Schema.optionalKey<Schema.Boolean>;
|
|
214
|
+
readonly asyncRewake: Schema.optionalKey<Schema.Boolean>;
|
|
215
|
+
readonly binary: Schema.String;
|
|
216
|
+
readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
217
|
+
}>, Schema.Struct<{
|
|
218
|
+
readonly matcher: Schema.optionalKey<Schema.String>;
|
|
219
|
+
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
220
|
+
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
221
|
+
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
222
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
223
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
224
|
+
readonly http: Schema.String;
|
|
225
|
+
/** Extra request headers. A value may name an environment variable as `$NAME` or `${NAME}`. */
|
|
226
|
+
readonly headers: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
227
|
+
/** The environment variables `headers` may interpolate. Any other reads as empty. */
|
|
228
|
+
readonly allowedEnvVars: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
229
|
+
}>, Schema.Struct<{
|
|
230
|
+
readonly matcher: Schema.optionalKey<Schema.String>;
|
|
231
|
+
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
232
|
+
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
233
|
+
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
234
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
235
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
236
|
+
readonly mcpTool: Schema.Struct<{
|
|
237
|
+
readonly server: Schema.String;
|
|
238
|
+
readonly tool: Schema.String;
|
|
239
|
+
/** The tool's arguments. A string value may take a field of the event as `${tool_input.file_path}`. */
|
|
240
|
+
readonly input: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
241
|
+
}>;
|
|
242
|
+
}>, Schema.Struct<{
|
|
243
|
+
readonly matcher: Schema.optionalKey<Schema.String>;
|
|
244
|
+
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
245
|
+
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
246
|
+
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
247
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
248
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
249
|
+
readonly prompt: Schema.String;
|
|
250
|
+
readonly model: Schema.optionalKey<Schema.String>;
|
|
251
|
+
/** Give a refusal's reason back to the agent and continue, instead of ending the turn. */
|
|
252
|
+
readonly continueOnBlock: Schema.optionalKey<Schema.Boolean>;
|
|
253
|
+
}>, Schema.Struct<{
|
|
254
|
+
readonly matcher: Schema.optionalKey<Schema.String>;
|
|
255
|
+
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
256
|
+
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
257
|
+
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
258
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
259
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
260
|
+
readonly agent: Schema.String;
|
|
261
|
+
readonly model: Schema.optionalKey<Schema.String>;
|
|
80
262
|
}>]>;
|
|
263
|
+
/**
|
|
264
|
+
* The kinds of hook handler a host can run, in Claude Code's names. A
|
|
265
|
+
* `script`, a `command` and a `binary` are all `command` handlers.
|
|
266
|
+
*
|
|
267
|
+
* @public
|
|
268
|
+
*/
|
|
269
|
+
export declare const HOOK_HANDLERS: readonly ["command", "http", "mcp_tool", "prompt", "agent"];
|
|
270
|
+
/**
|
|
271
|
+
* A hook handler kind.
|
|
272
|
+
*
|
|
273
|
+
* @public
|
|
274
|
+
*/
|
|
275
|
+
type HookHandler = (typeof HOOK_HANDLERS)[number];
|
|
276
|
+
/**
|
|
277
|
+
* The handler kind an entry is.
|
|
278
|
+
*
|
|
279
|
+
* @public
|
|
280
|
+
*/
|
|
281
|
+
export declare const hookHandler: (entry: typeof HookEntry.Type) => HookHandler;
|
|
282
|
+
/**
|
|
283
|
+
* The entry fields beyond the handler itself that only some hosts carry.
|
|
284
|
+
*
|
|
285
|
+
* @public
|
|
286
|
+
*/
|
|
287
|
+
export declare const HOOK_ENTRY_FIELDS: readonly ["if", "statusMessage", "async", "asyncRewake", "shell"];
|
|
81
288
|
/**
|
|
82
289
|
* The decoded `HookEntry`.
|
|
83
290
|
*
|
|
@@ -95,6 +302,10 @@ export declare const HookEntries: Schema.$Array<Schema.Union<readonly [Schema.St
|
|
|
95
302
|
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
96
303
|
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
97
304
|
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
305
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
306
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
307
|
+
readonly async: Schema.optionalKey<Schema.Boolean>;
|
|
308
|
+
readonly asyncRewake: Schema.optionalKey<Schema.Boolean>;
|
|
98
309
|
readonly script: Schema.String;
|
|
99
310
|
readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
100
311
|
}>, Schema.Struct<{
|
|
@@ -102,7 +313,69 @@ export declare const HookEntries: Schema.$Array<Schema.Union<readonly [Schema.St
|
|
|
102
313
|
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
103
314
|
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
104
315
|
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
316
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
317
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
318
|
+
readonly async: Schema.optionalKey<Schema.Boolean>;
|
|
319
|
+
readonly asyncRewake: Schema.optionalKey<Schema.Boolean>;
|
|
105
320
|
readonly command: Schema.String;
|
|
321
|
+
/** The shell the command runs in, on a host that lets a hook choose. Defaults to the host's own. */
|
|
322
|
+
readonly shell: Schema.optionalKey<Schema.Literals<readonly ["bash", "powershell"]>>;
|
|
323
|
+
}>, Schema.Struct<{
|
|
324
|
+
readonly matcher: Schema.optionalKey<Schema.String>;
|
|
325
|
+
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
326
|
+
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
327
|
+
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
328
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
329
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
330
|
+
readonly async: Schema.optionalKey<Schema.Boolean>;
|
|
331
|
+
readonly asyncRewake: Schema.optionalKey<Schema.Boolean>;
|
|
332
|
+
readonly binary: Schema.String;
|
|
333
|
+
readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
334
|
+
}>, Schema.Struct<{
|
|
335
|
+
readonly matcher: Schema.optionalKey<Schema.String>;
|
|
336
|
+
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
337
|
+
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
338
|
+
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
339
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
340
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
341
|
+
readonly http: Schema.String;
|
|
342
|
+
/** Extra request headers. A value may name an environment variable as `$NAME` or `${NAME}`. */
|
|
343
|
+
readonly headers: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
344
|
+
/** The environment variables `headers` may interpolate. Any other reads as empty. */
|
|
345
|
+
readonly allowedEnvVars: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
346
|
+
}>, Schema.Struct<{
|
|
347
|
+
readonly matcher: Schema.optionalKey<Schema.String>;
|
|
348
|
+
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
349
|
+
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
350
|
+
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
351
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
352
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
353
|
+
readonly mcpTool: Schema.Struct<{
|
|
354
|
+
readonly server: Schema.String;
|
|
355
|
+
readonly tool: Schema.String;
|
|
356
|
+
/** The tool's arguments. A string value may take a field of the event as `${tool_input.file_path}`. */
|
|
357
|
+
readonly input: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
358
|
+
}>;
|
|
359
|
+
}>, Schema.Struct<{
|
|
360
|
+
readonly matcher: Schema.optionalKey<Schema.String>;
|
|
361
|
+
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
362
|
+
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
363
|
+
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
364
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
365
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
366
|
+
readonly prompt: Schema.String;
|
|
367
|
+
readonly model: Schema.optionalKey<Schema.String>;
|
|
368
|
+
/** Give a refusal's reason back to the agent and continue, instead of ending the turn. */
|
|
369
|
+
readonly continueOnBlock: Schema.optionalKey<Schema.Boolean>;
|
|
370
|
+
}>, Schema.Struct<{
|
|
371
|
+
readonly matcher: Schema.optionalKey<Schema.String>;
|
|
372
|
+
readonly timeout: Schema.optionalKey<Schema.Int>;
|
|
373
|
+
readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
|
|
374
|
+
readonly failClosed: Schema.optionalKey<Schema.Boolean>;
|
|
375
|
+
readonly if: Schema.optionalKey<Schema.String>;
|
|
376
|
+
readonly statusMessage: Schema.optionalKey<Schema.String>;
|
|
377
|
+
readonly agent: Schema.String;
|
|
378
|
+
readonly model: Schema.optionalKey<Schema.String>;
|
|
106
379
|
}>]>>;
|
|
107
380
|
/**
|
|
108
381
|
* The fields of a hooks map over the events `E`, each optional.
|
|
@@ -125,7 +398,7 @@ export declare const makeHooks: <const E extends ReadonlyArray<string>>(events:
|
|
|
125
398
|
*
|
|
126
399
|
* @public
|
|
127
400
|
*/
|
|
128
|
-
export declare const Hooks: Schema.Struct<HooksFields<readonly ["SessionStart", "Setup", "UserPromptSubmit", "UserPromptExpansion", "PreToolUse", "PermissionRequest", "PermissionDenied", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "Notification", "MessageDisplay", "SubagentStart", "SubagentStop", "TaskCreated", "TaskCompleted", "Stop", "StopFailure", "TeammateIdle", "InstructionsLoaded", "ConfigChange", "CwdChanged", "DirectoryAdded", "FileChanged", "WorktreeCreate", "WorktreeRemove", "PreCompact", "PostCompact", "PreModelSwitch", "PostModelSwitch", "Elicitation", "ElicitationResult", "SessionEnd"]>>;
|
|
401
|
+
export declare const Hooks: Schema.Struct<HooksFields<readonly ["SessionStart", "Setup", "UserPromptSubmit", "UserPromptExpansion", "PreSkillShellCommand", "PreToolUse", "PermissionRequest", "PermissionDenied", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "Notification", "MessageDisplay", "SubagentStart", "SubagentStop", "TaskCreated", "TaskCompleted", "Stop", "StopFailure", "TeammateIdle", "InstructionsLoaded", "ConfigChange", "CwdChanged", "DirectoryAdded", "FileChanged", "WorktreeCreate", "WorktreeRemove", "PreCompact", "PostCompact", "PreModelSwitch", "PostModelSwitch", "Elicitation", "ElicitationResult", "SessionEnd"]>>;
|
|
129
402
|
/**
|
|
130
403
|
* A plugin name as every host spells it: kebab-case, lowercase letters and
|
|
131
404
|
* digits separated by single hyphens.
|
|
@@ -181,7 +454,7 @@ export declare const BaseConfigFields: {
|
|
|
181
454
|
readonly invoke: Schema.optionalKey<Schema.Literals<readonly ["bash", "exec"]>>;
|
|
182
455
|
}>>;
|
|
183
456
|
/** Hooks keyed by Claude Code event names, generated per target. */
|
|
184
|
-
readonly hooks: Schema.optionalKey<Schema.Struct<HooksFields<readonly ["SessionStart", "Setup", "UserPromptSubmit", "UserPromptExpansion", "PreToolUse", "PermissionRequest", "PermissionDenied", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "Notification", "MessageDisplay", "SubagentStart", "SubagentStop", "TaskCreated", "TaskCompleted", "Stop", "StopFailure", "TeammateIdle", "InstructionsLoaded", "ConfigChange", "CwdChanged", "DirectoryAdded", "FileChanged", "WorktreeCreate", "WorktreeRemove", "PreCompact", "PostCompact", "PreModelSwitch", "PostModelSwitch", "Elicitation", "ElicitationResult", "SessionEnd"]>>>;
|
|
457
|
+
readonly hooks: Schema.optionalKey<Schema.Struct<HooksFields<readonly ["SessionStart", "Setup", "UserPromptSubmit", "UserPromptExpansion", "PreSkillShellCommand", "PreToolUse", "PermissionRequest", "PermissionDenied", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "Notification", "MessageDisplay", "SubagentStart", "SubagentStop", "TaskCreated", "TaskCompleted", "Stop", "StopFailure", "TeammateIdle", "InstructionsLoaded", "ConfigChange", "CwdChanged", "DirectoryAdded", "FileChanged", "WorktreeCreate", "WorktreeRemove", "PreCompact", "PostCompact", "PreModelSwitch", "PostModelSwitch", "Elicitation", "ElicitationResult", "SessionEnd"]>>>;
|
|
185
458
|
/** MCP servers in Claude Code's `.mcp.json` server shape. */
|
|
186
459
|
readonly mcpServers: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{
|
|
187
460
|
readonly type: Schema.optionalKey<Schema.Literal<"stdio">>;
|
|
@@ -445,6 +718,55 @@ export declare const SKILL_FIELDS: ReadonlyArray<SkillField>;
|
|
|
445
718
|
* @public
|
|
446
719
|
*/
|
|
447
720
|
export declare const AGENT_FIELDS: ReadonlyArray<AgentField>;
|
|
721
|
+
/**
|
|
722
|
+
* One event's input and output schemas.
|
|
723
|
+
*
|
|
724
|
+
* @public
|
|
725
|
+
*/
|
|
726
|
+
interface HookIo {
|
|
727
|
+
readonly input: Schema.Codec<unknown, unknown>;
|
|
728
|
+
readonly output: Schema.Codec<unknown, unknown>;
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* The input and output schema of every Claude Code hook event: the JSON a hook
|
|
732
|
+
* receives and the JSON it may answer with.
|
|
733
|
+
*
|
|
734
|
+
* @public
|
|
735
|
+
*/
|
|
736
|
+
export declare const HOOK_IO: Readonly<Record<ClaudeHookEvent, HookIo>>;
|
|
737
|
+
/**
|
|
738
|
+
* The documented `tool_input` shape of each built-in tool, by tool name.
|
|
739
|
+
*
|
|
740
|
+
* @public
|
|
741
|
+
*/
|
|
742
|
+
export declare const TOOL_INPUTS: Readonly<Record<string, Schema.Codec<unknown, unknown>>>;
|
|
743
|
+
/**
|
|
744
|
+
* The Zig source of `zig/src/events.zig`: a struct for each Claude Code hook
|
|
745
|
+
* event's input and, under `tools`, for each built-in tool's `tool_input`. The
|
|
746
|
+
* text is what `zig fmt` would write, so a regeneration that changes nothing
|
|
747
|
+
* writes the same bytes.
|
|
748
|
+
*
|
|
749
|
+
* @public
|
|
750
|
+
*/
|
|
751
|
+
export declare const hookEventsZig: () => string;
|
|
752
|
+
/**
|
|
753
|
+
* A generated JSON Schema file: its name and its text.
|
|
754
|
+
*
|
|
755
|
+
* @public
|
|
756
|
+
*/
|
|
757
|
+
interface HookSchemaFile {
|
|
758
|
+
readonly name: string;
|
|
759
|
+
readonly content: string;
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* The JSON Schema documents for every Claude Code hook event, one for its
|
|
763
|
+
* input and one for its output, and one for each built-in tool's
|
|
764
|
+
* `tool_input`. The text is deterministic, so a regeneration that changes
|
|
765
|
+
* nothing writes the same bytes.
|
|
766
|
+
*
|
|
767
|
+
* @public
|
|
768
|
+
*/
|
|
769
|
+
export declare const hookSchemaFiles: () => ReadonlyArray<HookSchemaFile>;
|
|
448
770
|
/**
|
|
449
771
|
* One LSP server, in Claude Code's `.lsp.json` server shape. `${PLUGIN_ROOT}`
|
|
450
772
|
* is the one placeholder in `command`, `args`, `env` and `workspaceFolder`.
|
|
@@ -842,6 +1164,10 @@ declare const Target_base: Schema.Class<Target, Schema.Struct<{
|
|
|
842
1164
|
readonly format: Schema.Literals<readonly ["claude-hooks-json", "copilot-hooks-v1"]>;
|
|
843
1165
|
readonly events: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, typeof Absent]>>;
|
|
844
1166
|
readonly ownEvents: Schema.$Array<Schema.String>;
|
|
1167
|
+
/** The handler kinds the host runs. An entry of another kind is unsupported there. */
|
|
1168
|
+
readonly handlers: Schema.$Array<Schema.Literals<readonly ["command", "http", "mcp_tool", "prompt", "agent"]>>;
|
|
1169
|
+
/** The optional entry fields the host's hooks format carries; the build drops the rest with a note. */
|
|
1170
|
+
readonly entryFields: Schema.$Array<Schema.Literals<readonly ["if", "statusMessage", "async", "asyncRewake", "shell"]>>;
|
|
845
1171
|
/**
|
|
846
1172
|
* The Claude events whose matcher the host ignores. The build drops the
|
|
847
1173
|
* host `matcher` key there and the hook library applies the matcher at
|
|
@@ -947,12 +1273,12 @@ export declare const unresolved: (note: string) => Unresolved;
|
|
|
947
1273
|
* The version of `@pluginfinity/core` this build was made from.
|
|
948
1274
|
*
|
|
949
1275
|
* @remarks
|
|
950
|
-
* A build-time literal: the
|
|
1276
|
+
* A build-time literal: the build replaces `process.env.__PACKAGE_VERSION__`
|
|
951
1277
|
* with this package's own version, so this is not a runtime environment read.
|
|
952
1278
|
* `"0.0.0"` is the unbuilt-source fallback.
|
|
953
1279
|
*
|
|
954
1280
|
* @public
|
|
955
1281
|
*/
|
|
956
1282
|
export declare const CORE_VERSION: string;
|
|
957
|
-
export type { AgentField, DegradeForm, HooksFields, LspField, SkillField };
|
|
1283
|
+
export type { AgentField, DegradeForm, HookHandler, HookIo, HookSchemaFile, HooksFields, LspField, SkillField };
|
|
958
1284
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { BASE_CONFIG_KEYS, BaseConfigFields, PluginName, ScriptInvoke, ShippedPath, makeTargetSetting } from "./config.js";
|
|
2
2
|
import { EnvConfig, EnvVar, EnvVarName } from "./env.js";
|
|
3
3
|
import { AGENT_FIELDS, AgentFrontmatter, ComponentName, ComponentTargets, SKILL_FIELDS, SkillFrontmatter } from "./frontmatter.js";
|
|
4
|
-
import {
|
|
4
|
+
import { hookSchemaFiles } from "./hook-io/index.js";
|
|
5
|
+
import { AgentHook, BinaryHook, CLAUDE_HOOK_EVENTS, ClaudeHookEvent, CommandHook, HOOK_ENTRY_FIELDS, HOOK_HANDLERS, HookEntries, HookEntry, HookFallback, Hooks, HttpHook, McpToolHook, PluginRelativePath, PromptHook, ScriptHook, hookHandler, makeHooks } from "./hooks.js";
|
|
5
6
|
import { LSP_FIELDS, LspServer, LspServers } from "./lsp.js";
|
|
6
7
|
import { McpServer, McpServers, RemoteMcpServer, ServerEnv, StdioMcpServer } from "./mcp.js";
|
|
7
8
|
import { CommandMonitor, MonitorEntry, MonitorName, MonitorWhen, Monitors, ScriptMonitor } from "./monitors.js";
|
|
9
|
+
import { HOOK_IO } from "./hook-io/events.js";
|
|
10
|
+
import { TOOL_INPUTS } from "./hook-io/tool-inputs.js";
|
|
11
|
+
import { hookEventsZig } from "./hook-io/zig.js";
|
|
8
12
|
import { KebabName } from "./name.js";
|
|
9
13
|
import { Absent, DEGRADE_FORMS, Degrade, Drop, EventMapping, FieldMapEntry, HOOKS_FORMATS, HooksFormat, InFile, InManifest, Keep, LSP_FORMATS, LspFormat, MANIFEST_FORMATS, MCP_FORMATS, ManifestFormat, McpFormat, Rename, RootSpelling, ServerPlacement, Target, ToolMapping, Translate, TranslateTable, Unresolved, ValueMapping, absent, degrade, drop, inFile, inManifest, keep, rename, translate, unresolved } from "./target.js";
|
|
10
14
|
import { CORE_VERSION } from "./version.js";
|
|
11
15
|
|
|
12
|
-
export { AGENT_FIELDS, Absent, AgentFrontmatter, BASE_CONFIG_KEYS, BaseConfigFields, CLAUDE_HOOK_EVENTS, CORE_VERSION, ClaudeHookEvent, CommandHook, CommandMonitor, ComponentName, ComponentTargets, DEGRADE_FORMS, Degrade, Drop, EnvConfig, EnvVar, EnvVarName, EventMapping, FieldMapEntry, HOOKS_FORMATS, HookEntries, HookEntry, HookFallback, Hooks, HooksFormat, InFile, InManifest, KebabName, Keep, LSP_FIELDS, LSP_FORMATS, LspFormat, LspServer, LspServers, MANIFEST_FORMATS, MCP_FORMATS, ManifestFormat, McpFormat, McpServer, McpServers, MonitorEntry, MonitorName, MonitorWhen, Monitors, PluginName, PluginRelativePath, RemoteMcpServer, Rename, RootSpelling, SKILL_FIELDS, ScriptHook, ScriptInvoke, ScriptMonitor, ServerEnv, ServerPlacement, ShippedPath, SkillFrontmatter, StdioMcpServer, Target, ToolMapping, Translate, TranslateTable, Unresolved, ValueMapping, absent, degrade, drop, inFile, inManifest, keep, makeHooks, makeTargetSetting, rename, translate, unresolved };
|
|
16
|
+
export { AGENT_FIELDS, Absent, AgentFrontmatter, AgentHook, BASE_CONFIG_KEYS, BaseConfigFields, BinaryHook, CLAUDE_HOOK_EVENTS, CORE_VERSION, ClaudeHookEvent, CommandHook, CommandMonitor, ComponentName, ComponentTargets, DEGRADE_FORMS, Degrade, Drop, EnvConfig, EnvVar, EnvVarName, EventMapping, FieldMapEntry, HOOKS_FORMATS, HOOK_ENTRY_FIELDS, HOOK_HANDLERS, HOOK_IO, HookEntries, HookEntry, HookFallback, Hooks, HooksFormat, HttpHook, InFile, InManifest, KebabName, Keep, LSP_FIELDS, LSP_FORMATS, LspFormat, LspServer, LspServers, MANIFEST_FORMATS, MCP_FORMATS, ManifestFormat, McpFormat, McpServer, McpServers, McpToolHook, MonitorEntry, MonitorName, MonitorWhen, Monitors, PluginName, PluginRelativePath, PromptHook, RemoteMcpServer, Rename, RootSpelling, SKILL_FIELDS, ScriptHook, ScriptInvoke, ScriptMonitor, ServerEnv, ServerPlacement, ShippedPath, SkillFrontmatter, StdioMcpServer, TOOL_INPUTS, Target, ToolMapping, Translate, TranslateTable, Unresolved, ValueMapping, absent, degrade, drop, hookEventsZig, hookHandler, hookSchemaFiles, inFile, inManifest, keep, makeHooks, makeTargetSetting, rename, translate, unresolved };
|
package/lsp.js
CHANGED
package/monitors.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluginfinity/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The pluginfinity domain model: the host-neutral plugin source, the Target capability schema and the pluginfinity config shape. Platform-free.",
|
|
6
6
|
"keywords": [
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"./package.json": "./package.json"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"effect": "~4.1.
|
|
37
|
+
"effect": "~4.1.0"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=24.11.0"
|
package/target.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
+
import { HOOK_ENTRY_FIELDS, HOOK_HANDLERS } from "./hooks.js";
|
|
2
3
|
|
|
3
4
|
// src/target.ts
|
|
4
5
|
/**
|
|
@@ -212,6 +213,10 @@ var Target = class extends Schema.Class("Target")({
|
|
|
212
213
|
format: HooksFormat,
|
|
213
214
|
events: Schema.Record(Schema.String, EventMapping),
|
|
214
215
|
ownEvents: Schema.Array(Schema.String),
|
|
216
|
+
/** The handler kinds the host runs. An entry of another kind is unsupported there. */
|
|
217
|
+
handlers: Schema.Array(Schema.Literals(HOOK_HANDLERS)),
|
|
218
|
+
/** The optional entry fields the host's hooks format carries; the build drops the rest with a note. */
|
|
219
|
+
entryFields: Schema.Array(Schema.Literals(HOOK_ENTRY_FIELDS)),
|
|
215
220
|
/**
|
|
216
221
|
* The Claude events whose matcher the host ignores. The build drops the
|
|
217
222
|
* host `matcher` key there and the hook library applies the matcher at
|
package/version.js
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
* The version of `@pluginfinity/core` this build was made from.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
* A build-time literal: the
|
|
6
|
+
* A build-time literal: the build replaces `process.env.__PACKAGE_VERSION__`
|
|
7
7
|
* with this package's own version, so this is not a runtime environment read.
|
|
8
8
|
* `"0.0.0"` is the unbuilt-source fallback.
|
|
9
9
|
*
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
|
-
const CORE_VERSION = "0.
|
|
12
|
+
const CORE_VERSION = "0.4.0";
|
|
13
13
|
|
|
14
14
|
export { CORE_VERSION };
|