@pluginfinity/core 0.2.1 → 0.3.1

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 CHANGED
@@ -1,16 +1,19 @@
1
1
  import { Hooks } from "./hooks.js";
2
+ import { EnvConfig } from "./env.js";
2
3
  import { McpServers } from "./mcp.js";
3
4
  import { LspServers } from "./lsp.js";
5
+ import { KebabName } from "./name.js";
6
+ import { Monitors } from "./monitors.js";
4
7
  import { Schema } from "effect";
5
8
 
6
- //#region src/config.ts
9
+ // src/config.ts
7
10
  /**
8
11
  * A plugin name as every host spells it: kebab-case, lowercase letters and
9
12
  * digits separated by single hyphens.
10
13
  *
11
14
  * @public
12
15
  */
13
- const PluginName = Schema.String.check(Schema.isPattern(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, { message: "must be kebab-case: lowercase letters and digits separated by single hyphens" }));
16
+ const PluginName = KebabName;
14
17
  /**
15
18
  * How a `script` hook is invoked: through `bash`, which ignores the file
16
19
  * mode, or directly, which needs the executable bit.
@@ -62,8 +65,12 @@ const BaseConfigFields = {
62
65
  mcpServers: Schema.optionalKey(McpServers),
63
66
  /** LSP servers in Claude Code's `.lsp.json` server shape. */
64
67
  lspServers: Schema.optionalKey(LspServers),
68
+ /** Background monitors, keyed by name; Claude Code delivers each stdout line to the model. */
69
+ monitors: Schema.optionalKey(Monitors),
65
70
  /** Extra files and directories (ending in `/`) shipped to every target. */
66
- files: Schema.optionalKey(Schema.Array(ShippedPath))
71
+ files: Schema.optionalKey(Schema.Array(ShippedPath)),
72
+ /** Session variables the plugin keeps, resolved once at SessionStart; plugin-wide, with no per-target override. */
73
+ env: Schema.optionalKey(EnvConfig)
67
74
  };
68
75
  /**
69
76
  * The names of the plugin-wide config fields.
@@ -79,17 +86,20 @@ const BASE_CONFIG_KEYS = Object.keys(BaseConfigFields);
79
86
  * `hooks` is the target's own hooks schema, so each target admits the events
80
87
  * it has: a hook under it replaces the base entries for that event on that
81
88
  * target, and `[]` removes them. A server under `mcpServers` or `lspServers`
82
- * replaces the base server of that name.
89
+ * replaces the base server of that name, and a monitor under `monitors`
90
+ * replaces the base monitor of that name.
83
91
  *
84
92
  * @public
85
93
  */
86
94
  const makeTargetSetting = (hooks) => Schema.Union([Schema.Literal(true), Schema.Struct({
87
95
  /** The plugin's name on this host, when it differs from the base `name`. */
88
96
  name: Schema.optionalKey(PluginName),
97
+ /** Extra files and directories (ending in `/`) shipped to this target only, on top of the base `files`. */
98
+ files: Schema.optionalKey(Schema.Array(ShippedPath)),
89
99
  hooks: Schema.optionalKey(hooks),
90
100
  mcpServers: Schema.optionalKey(McpServers),
91
- lspServers: Schema.optionalKey(LspServers)
101
+ lspServers: Schema.optionalKey(LspServers),
102
+ monitors: Schema.optionalKey(Monitors)
92
103
  })]);
93
104
 
94
- //#endregion
95
105
  export { BASE_CONFIG_KEYS, BaseConfigFields, PluginName, ScriptInvoke, ShippedPath, makeTargetSetting };
package/env.js ADDED
@@ -0,0 +1,93 @@
1
+ import { PluginRelativePath } from "./hooks.js";
2
+ import { Schema } from "effect";
3
+
4
+ // src/env.ts
5
+ const RESERVED_NAME_LIST = [
6
+ "PATH",
7
+ "IFS",
8
+ "HOME",
9
+ "PWD",
10
+ "XDG_STATE_HOME",
11
+ "TMPDIR",
12
+ "SHELL",
13
+ "BASH_ENV",
14
+ "ENV",
15
+ "CDPATH",
16
+ "SHELLOPTS",
17
+ "BASHOPTS",
18
+ "PS4"
19
+ ];
20
+ const RESERVED_NAMES = new Set(RESERVED_NAME_LIST);
21
+ const RESERVED_PREFIXES = [
22
+ "PLUGINFINITY_",
23
+ "_PF_",
24
+ "CLAUDE_",
25
+ "COPILOT_",
26
+ "LD_",
27
+ "DYLD_"
28
+ ];
29
+ const RESERVED_MESSAGE = `is reserved: ${RESERVED_NAME_LIST.join(", ")} and names starting ${RESERVED_PREFIXES.join(", ")} belong to the env library, a host, the shell or the dynamic loader`;
30
+ const NAME_PATTERN = /^[A-Z_][A-Z0-9_]*$/;
31
+ const NAME_MESSAGE = "must be upper case letters, digits and _, not starting with a digit";
32
+ const isReserved = (name) => RESERVED_NAMES.has(name) || RESERVED_PREFIXES.some((prefix) => name.startsWith(prefix));
33
+ /**
34
+ * A session variable's name: upper case letters, digits and `_`, not starting
35
+ * with a digit.
36
+ *
37
+ * @remarks
38
+ * The env library, the hosts, the shell and the dynamic loader own some names:
39
+ * `PATH`, `IFS`, `HOME`, `PWD`, `XDG_STATE_HOME`, `TMPDIR`, `SHELL`,
40
+ * `BASH_ENV`, `ENV`, `CDPATH`, `SHELLOPTS`, `BASHOPTS` and `PS4`, and every name
41
+ * starting `PLUGINFINITY_`, `_PF_`, `CLAUDE_`, `COPILOT_`, `LD_` or `DYLD_`. A
42
+ * declared one would shadow them in every hook, so they are rejected.
43
+ *
44
+ * @public
45
+ */
46
+ const EnvVarName = Schema.String.check(Schema.isPattern(NAME_PATTERN, { message: NAME_MESSAGE }), Schema.makeFilter((name) => isReserved(name) ? RESERVED_MESSAGE : void 0));
47
+ /**
48
+ * One declared session variable. Values are strings; `default` defaults to `""`
49
+ * and holds no newline or other control character but tab.
50
+ *
51
+ * @public
52
+ */
53
+ const EnvVar = Schema.Struct({
54
+ /** The value when nothing else sets it, on one line with no control character but tab. Defaults to `""`. */
55
+ default: Schema.optionalKey(Schema.String.check(Schema.isPattern(/^[^\u0000-\u0008\u000a-\u001f\u007f]*$/, { message: "must be one line with no control character but tab: the session values file holds one NAME=value per line" }))),
56
+ /** What the variable holds, for readers of the config. */
57
+ description: Schema.optionalKey(Schema.String)
58
+ });
59
+ /**
60
+ * The session variables a plugin keeps, resolved once at SessionStart and
61
+ * read by its hooks, skill scripts and monitors.
62
+ *
63
+ * @remarks
64
+ * With `prefix` set, every declared name must start with `${prefix}_`. `setup`
65
+ * is a plugin-relative script whose `NAME=value` stdout lines rank above the
66
+ * defaults and below the project's `.env`. Record keys cannot repeat, so a
67
+ * name is declared once.
68
+ *
69
+ * @public
70
+ */
71
+ const EnvConfig = Schema.Struct({
72
+ /** When set, every declared name starts with `${prefix}_`. */
73
+ prefix: Schema.optionalKey(Schema.String.check(Schema.isPattern(/^[A-Z_][A-Z0-9_]*$/, { message: "must be upper case letters, digits and _, not starting with a digit" }))),
74
+ /** The declared variables, keyed by name: each an {@link EnvVarName}. */
75
+ vars: Schema.Record(Schema.String, EnvVar),
76
+ /** A plugin-relative script that prints `NAME=value` lines at SessionStart. */
77
+ setup: Schema.optionalKey(PluginRelativePath)
78
+ }).check(Schema.makeFilter((env) => Object.keys(env.vars).flatMap((name) => {
79
+ const issue = !NAME_PATTERN.test(name) ? NAME_MESSAGE : isReserved(name) ? RESERVED_MESSAGE : void 0;
80
+ return issue === void 0 ? [] : [{
81
+ path: ["vars", name],
82
+ issue
83
+ }];
84
+ })), Schema.makeFilter((env) => {
85
+ const prefix = env.prefix;
86
+ if (prefix === void 0) return void 0;
87
+ return Object.keys(env.vars).filter((name) => !name.startsWith(`${prefix}_`)).map((name) => ({
88
+ path: ["vars", name],
89
+ issue: `must start with the prefix "${prefix}_"`
90
+ }));
91
+ }));
92
+
93
+ export { EnvConfig, EnvVar, EnvVarName };
package/frontmatter.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PluginName } from "./config.js";
2
2
  import { Schema } from "effect";
3
3
 
4
- //#region src/frontmatter.ts
4
+ // src/frontmatter.ts
5
5
  /**
6
6
  * A skill or agent name: kebab-case and at most 64 characters, the Agent
7
7
  * Skills spec rule and the strictest of the hosts.
@@ -114,5 +114,4 @@ const SKILL_FIELDS = Object.keys(SkillFrontmatter.fields).filter((key) => key !=
114
114
  */
115
115
  const AGENT_FIELDS = Object.keys(AgentFrontmatter.fields).filter((key) => key !== "targets");
116
116
 
117
- //#endregion
118
117
  export { AGENT_FIELDS, AgentFrontmatter, ComponentName, ComponentTargets, SKILL_FIELDS, SkillFrontmatter };
package/hooks.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
 
3
- //#region src/hooks.ts
3
+ // src/hooks.ts
4
4
  /**
5
5
  * Every Claude Code hook event, the vocabulary a plugin's `hooks` config is
6
6
  * written in. Each target maps these to its own names.
@@ -58,6 +58,8 @@ const HookFallback = Schema.Literals(["fail", "omit"]);
58
58
  /**
59
59
  * A path relative to the plugin root: no leading slash, no backslash, no `..`
60
60
  * segment.
61
+ *
62
+ * @public
61
63
  */
62
64
  const PluginRelativePath = Schema.String.check(Schema.isPattern(/^(?![/\\])(?!(?:[\s\S]*\/)?\.\.(?:\/|$))[^\\\u0000-\u001f]+$/, { message: "must be a path relative to the plugin root, with no leading slash, backslash, control character or .. segment" }));
63
65
  const PositiveInt = Schema.Int.check(Schema.isGreaterThan(0, { message: "must be a positive whole number of seconds" }));
@@ -67,7 +69,9 @@ const sharedHookFields = {
67
69
  /** Seconds before the host gives up on the hook. */
68
70
  timeout: Schema.optionalKey(PositiveInt),
69
71
  /** What a target without this event does. Defaults to `"fail"`. */
70
- fallback: Schema.optionalKey(HookFallback)
72
+ fallback: Schema.optionalKey(HookFallback),
73
+ /** Deny or block when the script fails before answering. Defaults to failing open. */
74
+ failClosed: Schema.optionalKey(Schema.Boolean)
71
75
  };
72
76
  /**
73
77
  * A hook that runs a script the plugin ships. The build checks the script
@@ -120,5 +124,4 @@ const makeHooks = (events) => Schema.Struct(Object.fromEntries(events.map((event
120
124
  */
121
125
  const Hooks = makeHooks(CLAUDE_HOOK_EVENTS);
122
126
 
123
- //#endregion
124
- export { CLAUDE_HOOK_EVENTS, ClaudeHookEvent, CommandHook, HookEntries, HookEntry, HookFallback, Hooks, ScriptHook, makeHooks };
127
+ export { CLAUDE_HOOK_EVENTS, ClaudeHookEvent, CommandHook, HookEntries, HookEntry, HookFallback, Hooks, PluginRelativePath, ScriptHook, makeHooks };
package/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Schema } from "effect";
2
- //#region src/hooks.d.ts
3
2
  /**
4
3
  * Every Claude Code hook event, the vocabulary a plugin's `hooks` config is
5
4
  * written in. Each target maps these to its own names.
@@ -26,6 +25,13 @@ export type ClaudeHookEvent = typeof ClaudeHookEvent.Type;
26
25
  * @public
27
26
  */
28
27
  export declare const HookFallback: Schema.Literals<readonly ["fail", "omit"]>;
28
+ /**
29
+ * A path relative to the plugin root: no leading slash, no backslash, no `..`
30
+ * segment.
31
+ *
32
+ * @public
33
+ */
34
+ export declare const PluginRelativePath: Schema.String;
29
35
  /**
30
36
  * A hook that runs a script the plugin ships. The build checks the script
31
37
  * exists and writes each host's command for it.
@@ -36,6 +42,7 @@ export declare const ScriptHook: Schema.Struct<{
36
42
  readonly matcher: Schema.optionalKey<Schema.String>;
37
43
  readonly timeout: Schema.optionalKey<Schema.Int>;
38
44
  readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
45
+ readonly failClosed: Schema.optionalKey<Schema.Boolean>;
39
46
  readonly script: Schema.String;
40
47
  readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
41
48
  }>;
@@ -48,6 +55,7 @@ export declare const CommandHook: Schema.Struct<{
48
55
  readonly matcher: Schema.optionalKey<Schema.String>;
49
56
  readonly timeout: Schema.optionalKey<Schema.Int>;
50
57
  readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
58
+ readonly failClosed: Schema.optionalKey<Schema.Boolean>;
51
59
  readonly command: Schema.String;
52
60
  }>;
53
61
  /**
@@ -60,12 +68,14 @@ export declare const HookEntry: Schema.Union<readonly [Schema.Struct<{
60
68
  readonly matcher: Schema.optionalKey<Schema.String>;
61
69
  readonly timeout: Schema.optionalKey<Schema.Int>;
62
70
  readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
71
+ readonly failClosed: Schema.optionalKey<Schema.Boolean>;
63
72
  readonly script: Schema.String;
64
73
  readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
65
74
  }>, Schema.Struct<{
66
75
  readonly matcher: Schema.optionalKey<Schema.String>;
67
76
  readonly timeout: Schema.optionalKey<Schema.Int>;
68
77
  readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
78
+ readonly failClosed: Schema.optionalKey<Schema.Boolean>;
69
79
  readonly command: Schema.String;
70
80
  }>]>;
71
81
  /**
@@ -84,12 +94,14 @@ export declare const HookEntries: Schema.$Array<Schema.Union<readonly [Schema.St
84
94
  readonly matcher: Schema.optionalKey<Schema.String>;
85
95
  readonly timeout: Schema.optionalKey<Schema.Int>;
86
96
  readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
97
+ readonly failClosed: Schema.optionalKey<Schema.Boolean>;
87
98
  readonly script: Schema.String;
88
99
  readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
89
100
  }>, Schema.Struct<{
90
101
  readonly matcher: Schema.optionalKey<Schema.String>;
91
102
  readonly timeout: Schema.optionalKey<Schema.Int>;
92
103
  readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
104
+ readonly failClosed: Schema.optionalKey<Schema.Boolean>;
93
105
  readonly command: Schema.String;
94
106
  }>]>>;
95
107
  /**
@@ -114,8 +126,6 @@ export declare const makeHooks: <const E extends ReadonlyArray<string>>(events:
114
126
  * @public
115
127
  */
116
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"]>>;
117
- //#endregion
118
- //#region src/config.d.ts
119
129
  /**
120
130
  * A plugin name as every host spells it: kebab-case, lowercase letters and
121
131
  * digits separated by single hyphens.
@@ -199,8 +209,28 @@ export declare const BaseConfigFields: {
199
209
  readonly maxRestarts: Schema.optionalKey<Schema.Number>;
200
210
  readonly diagnostics: Schema.optionalKey<Schema.Boolean>;
201
211
  }>>>;
212
+ /** Background monitors, keyed by name; Claude Code delivers each stdout line to the model. */
213
+ readonly monitors: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{
214
+ readonly description: Schema.String;
215
+ readonly when: Schema.optionalKey<Schema.Union<readonly [Schema.Literal<"always">, Schema.String]>>;
216
+ readonly script: Schema.String;
217
+ readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
218
+ }>, Schema.Struct<{
219
+ readonly description: Schema.String;
220
+ readonly when: Schema.optionalKey<Schema.Union<readonly [Schema.Literal<"always">, Schema.String]>>;
221
+ readonly command: Schema.String;
222
+ }>]>>>;
202
223
  /** Extra files and directories (ending in `/`) shipped to every target. */
203
224
  readonly files: Schema.optionalKey<Schema.$Array<Schema.String>>;
225
+ /** Session variables the plugin keeps, resolved once at SessionStart; plugin-wide, with no per-target override. */
226
+ readonly env: Schema.optionalKey<Schema.Struct<{
227
+ readonly prefix: Schema.optionalKey<Schema.String>;
228
+ readonly vars: Schema.$Record<Schema.String, Schema.Struct<{
229
+ readonly default: Schema.optionalKey<Schema.String>;
230
+ readonly description: Schema.optionalKey<Schema.String>;
231
+ }>>;
232
+ readonly setup: Schema.optionalKey<Schema.String>;
233
+ }>>;
204
234
  };
205
235
  /**
206
236
  * The names of the plugin-wide config fields.
@@ -216,13 +246,16 @@ export declare const BASE_CONFIG_KEYS: ReadonlyArray<string>;
216
246
  * `hooks` is the target's own hooks schema, so each target admits the events
217
247
  * it has: a hook under it replaces the base entries for that event on that
218
248
  * target, and `[]` removes them. A server under `mcpServers` or `lspServers`
219
- * replaces the base server of that name.
249
+ * replaces the base server of that name, and a monitor under `monitors`
250
+ * replaces the base monitor of that name.
220
251
  *
221
252
  * @public
222
253
  */
223
254
  export declare const makeTargetSetting: <H extends Schema.Top>(hooks: H) => Schema.Union<readonly [Schema.Literal<true>, Schema.Struct<{
224
255
  /** The plugin's name on this host, when it differs from the base `name`. */
225
256
  readonly name: Schema.optionalKey<Schema.String>;
257
+ /** Extra files and directories (ending in `/`) shipped to this target only, on top of the base `files`. */
258
+ readonly files: Schema.optionalKey<Schema.$Array<Schema.String>>;
226
259
  readonly hooks: Schema.optionalKey<H>;
227
260
  readonly mcpServers: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{
228
261
  readonly type: Schema.optionalKey<Schema.Literal<"stdio">>;
@@ -249,9 +282,74 @@ export declare const makeTargetSetting: <H extends Schema.Top>(hooks: H) => Sche
249
282
  readonly maxRestarts: Schema.optionalKey<Schema.Number>;
250
283
  readonly diagnostics: Schema.optionalKey<Schema.Boolean>;
251
284
  }>>>;
285
+ readonly monitors: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{
286
+ readonly description: Schema.String;
287
+ readonly when: Schema.optionalKey<Schema.Union<readonly [Schema.Literal<"always">, Schema.String]>>;
288
+ readonly script: Schema.String;
289
+ readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
290
+ }>, Schema.Struct<{
291
+ readonly description: Schema.String;
292
+ readonly when: Schema.optionalKey<Schema.Union<readonly [Schema.Literal<"always">, Schema.String]>>;
293
+ readonly command: Schema.String;
294
+ }>]>>>;
252
295
  }>]>;
253
- //#endregion
254
- //#region src/frontmatter.d.ts
296
+ /**
297
+ * A session variable's name: upper case letters, digits and `_`, not starting
298
+ * with a digit.
299
+ *
300
+ * @remarks
301
+ * The env library, the hosts, the shell and the dynamic loader own some names:
302
+ * `PATH`, `IFS`, `HOME`, `PWD`, `XDG_STATE_HOME`, `TMPDIR`, `SHELL`,
303
+ * `BASH_ENV`, `ENV`, `CDPATH`, `SHELLOPTS`, `BASHOPTS` and `PS4`, and every name
304
+ * starting `PLUGINFINITY_`, `_PF_`, `CLAUDE_`, `COPILOT_`, `LD_` or `DYLD_`. A
305
+ * declared one would shadow them in every hook, so they are rejected.
306
+ *
307
+ * @public
308
+ */
309
+ export declare const EnvVarName: Schema.String;
310
+ /**
311
+ * One declared session variable. Values are strings; `default` defaults to `""`
312
+ * and holds no newline or other control character but tab.
313
+ *
314
+ * @public
315
+ */
316
+ export declare const EnvVar: Schema.Struct<{
317
+ /** The value when nothing else sets it, on one line with no control character but tab. Defaults to `""`. */
318
+ readonly default: Schema.optionalKey<Schema.String>;
319
+ /** What the variable holds, for readers of the config. */
320
+ readonly description: Schema.optionalKey<Schema.String>;
321
+ }>;
322
+ /**
323
+ * The session variables a plugin keeps, resolved once at SessionStart and
324
+ * read by its hooks, skill scripts and monitors.
325
+ *
326
+ * @remarks
327
+ * With `prefix` set, every declared name must start with `${prefix}_`. `setup`
328
+ * is a plugin-relative script whose `NAME=value` stdout lines rank above the
329
+ * defaults and below the project's `.env`. Record keys cannot repeat, so a
330
+ * name is declared once.
331
+ *
332
+ * @public
333
+ */
334
+ export declare const EnvConfig: Schema.Struct<{
335
+ /** When set, every declared name starts with `${prefix}_`. */
336
+ readonly prefix: Schema.optionalKey<Schema.String>;
337
+ /** The declared variables, keyed by name: each an {@link EnvVarName}. */
338
+ readonly vars: Schema.$Record<Schema.String, Schema.Struct<{
339
+ /** The value when nothing else sets it, on one line with no control character but tab. Defaults to `""`. */
340
+ readonly default: Schema.optionalKey<Schema.String>;
341
+ /** What the variable holds, for readers of the config. */
342
+ readonly description: Schema.optionalKey<Schema.String>;
343
+ }>>;
344
+ /** A plugin-relative script that prints `NAME=value` lines at SessionStart. */
345
+ readonly setup: Schema.optionalKey<Schema.String>;
346
+ }>;
347
+ /**
348
+ * The decoded `EnvConfig`.
349
+ *
350
+ * @public
351
+ */
352
+ export type EnvConfig = typeof EnvConfig.Type;
255
353
  /**
256
354
  * A skill or agent name: kebab-case and at most 64 characters, the Agent
257
355
  * Skills spec rule and the strictest of the hosts.
@@ -347,8 +445,6 @@ export declare const SKILL_FIELDS: ReadonlyArray<SkillField>;
347
445
  * @public
348
446
  */
349
447
  export declare const AGENT_FIELDS: ReadonlyArray<AgentField>;
350
- //#endregion
351
- //#region src/lsp.d.ts
352
448
  /**
353
449
  * One LSP server, in Claude Code's `.lsp.json` server shape. `${PLUGIN_ROOT}`
354
450
  * is the one placeholder in `command`, `args`, `env` and `workspaceFolder`.
@@ -400,8 +496,6 @@ export declare const LSP_FIELDS: readonly ["command", "args", "env", "extensionT
400
496
  * @public
401
497
  */
402
498
  type LspField = (typeof LSP_FIELDS)[number];
403
- //#endregion
404
- //#region src/mcp.d.ts
405
499
  /**
406
500
  * A server's environment. `PLUGINFINITY_` keys are reserved for the
407
501
  * variables the build injects.
@@ -464,8 +558,90 @@ export declare const McpServers: Schema.$Record<Schema.String, Schema.Union<read
464
558
  readonly url: Schema.String;
465
559
  readonly headers: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
466
560
  }>]>>;
467
- //#endregion
468
- //#region src/target.d.ts
561
+ /**
562
+ * A monitor's name: kebab-case, the key it is written under.
563
+ *
564
+ * @public
565
+ */
566
+ export declare const MonitorName: Schema.String;
567
+ /**
568
+ * When a monitor starts: `"always"` (the default) or the first time a named
569
+ * skill is invoked, as `on-skill-invoke:<skill>`.
570
+ *
571
+ * @remarks
572
+ * `<skill>` is the bare skill name, so the source is host-neutral: it holds no
573
+ * `:`. Claude Code matches the plugin-qualified name `<plugin>:<skill>`, and
574
+ * the build writes that form.
575
+ *
576
+ * @public
577
+ */
578
+ export declare const MonitorWhen: Schema.Union<readonly [Schema.Literal<"always">, Schema.String]>;
579
+ /**
580
+ * A monitor that runs a script the plugin ships. Each line it prints to
581
+ * stdout is delivered to the model.
582
+ *
583
+ * @public
584
+ */
585
+ export declare const ScriptMonitor: Schema.Struct<{
586
+ readonly description: Schema.String;
587
+ readonly when: Schema.optionalKey<Schema.Union<readonly [Schema.Literal<"always">, Schema.String]>>;
588
+ readonly script: Schema.String;
589
+ readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
590
+ }>;
591
+ /**
592
+ * A monitor given as a command string. `${PLUGIN_ROOT}` is its one placeholder.
593
+ *
594
+ * @public
595
+ */
596
+ export declare const CommandMonitor: Schema.Struct<{
597
+ readonly description: Schema.String;
598
+ readonly when: Schema.optionalKey<Schema.Union<readonly [Schema.Literal<"always">, Schema.String]>>;
599
+ readonly command: Schema.String;
600
+ }>;
601
+ /**
602
+ * One monitor: exactly one of `script` or `command`. Decode strictly, or a
603
+ * mixed entry decodes as whichever member matches first.
604
+ *
605
+ * @public
606
+ */
607
+ export declare const MonitorEntry: Schema.Union<readonly [Schema.Struct<{
608
+ readonly description: Schema.String;
609
+ readonly when: Schema.optionalKey<Schema.Union<readonly [Schema.Literal<"always">, Schema.String]>>;
610
+ readonly script: Schema.String;
611
+ readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
612
+ }>, Schema.Struct<{
613
+ readonly description: Schema.String;
614
+ readonly when: Schema.optionalKey<Schema.Union<readonly [Schema.Literal<"always">, Schema.String]>>;
615
+ readonly command: Schema.String;
616
+ }>]>;
617
+ /**
618
+ * The decoded `MonitorEntry`.
619
+ *
620
+ * @public
621
+ */
622
+ export type MonitorEntry = typeof MonitorEntry.Type;
623
+ /**
624
+ * A plugin's monitors, keyed by name.
625
+ *
626
+ * @public
627
+ */
628
+ export declare const Monitors: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{
629
+ readonly description: Schema.String;
630
+ readonly when: Schema.optionalKey<Schema.Union<readonly [Schema.Literal<"always">, Schema.String]>>;
631
+ readonly script: Schema.String;
632
+ readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
633
+ }>, Schema.Struct<{
634
+ readonly description: Schema.String;
635
+ readonly when: Schema.optionalKey<Schema.Union<readonly [Schema.Literal<"always">, Schema.String]>>;
636
+ readonly command: Schema.String;
637
+ }>]>>;
638
+ /**
639
+ * A name every host accepts: kebab-case, lowercase letters and digits
640
+ * separated by single hyphens.
641
+ *
642
+ * @public
643
+ */
644
+ export declare const KebabName: Schema.String;
469
645
  /**
470
646
  * The forms a field can be moved into when a host lacks it. The engine owns
471
647
  * one renderer per form.
@@ -640,6 +816,18 @@ declare const Target_base: Schema.Class<Target, Schema.Struct<{
640
816
  * or `unresolved` when the host has no such command.
641
817
  */
642
818
  readonly invoke: Schema.Union<readonly [Schema.String, typeof Unresolved]>;
819
+ /**
820
+ * How a skill body names a skill's directory: `own` for the skill the body
821
+ * belongs to, `other` for a sibling, a template with `{skill}`, and `agent`
822
+ * for a sibling named from an agent body, which has no skill base
823
+ * directory. Where the host expands no path in bodies these are
824
+ * placeholders the model fills in, not paths.
825
+ */
826
+ readonly dirSpelling: Schema.Struct<{
827
+ readonly own: Schema.String;
828
+ readonly other: Schema.String;
829
+ readonly agent: Schema.Union<readonly [Schema.String, typeof Unresolved]>;
830
+ }>;
643
831
  }>;
644
832
  readonly agents: Schema.Struct<{
645
833
  readonly dir: Schema.String;
@@ -654,6 +842,28 @@ declare const Target_base: Schema.Class<Target, Schema.Struct<{
654
842
  readonly format: Schema.Literals<readonly ["claude-hooks-json", "copilot-hooks-v1"]>;
655
843
  readonly events: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, typeof Absent]>>;
656
844
  readonly ownEvents: Schema.$Array<Schema.String>;
845
+ /**
846
+ * The Claude events whose matcher the host ignores. The build drops the
847
+ * host `matcher` key there and the hook library applies the matcher at
848
+ * run time instead.
849
+ */
850
+ readonly matcherIgnored: Schema.$Array<Schema.String>;
851
+ /**
852
+ * The Claude events where the host honours each kind of hook output: the
853
+ * `context` a hook adds to the model's view and the `system_message` it
854
+ * shows the user. Mirrors `hook_supports` in the hook library, which a test
855
+ * pins; the build notes a script that emits output the host would ignore.
856
+ */
857
+ readonly output: Schema.Struct<{
858
+ readonly context: Schema.$Array<Schema.String>;
859
+ readonly system_message: Schema.$Array<Schema.String>;
860
+ }>;
861
+ /**
862
+ * The Claude events from which the host passes values a hook exports to
863
+ * the model's shell (Claude Code's `CLAUDE_ENV_FILE`); empty when it has
864
+ * no such channel, and a skill script must source `env.sh` instead.
865
+ */
866
+ readonly envShell: Schema.$Array<Schema.String>;
657
867
  }>;
658
868
  readonly mcp: Schema.Struct<{
659
869
  readonly placement: Schema.Union<readonly [typeof InFile, typeof InManifest]>;
@@ -665,6 +875,14 @@ declare const Target_base: Schema.Class<Target, Schema.Struct<{
665
875
  readonly format: Schema.Literals<readonly ["claude-lsp-servers", "copilot-lsp-json"]>;
666
876
  readonly fields: Schema.$Record<Schema.String, Schema.Union<readonly [typeof Keep, typeof Rename, typeof Translate, typeof Degrade, typeof Drop, typeof Unresolved]>>;
667
877
  }>;
878
+ /**
879
+ * Where the host reads background monitors and how it spells the plugin root
880
+ * in their commands, or `unresolved` when the host has no monitors.
881
+ */
882
+ readonly monitors: Schema.Union<readonly [Schema.Struct<{
883
+ readonly path: Schema.String;
884
+ readonly root: Schema.String;
885
+ }>, typeof Unresolved]>;
668
886
  readonly references: Schema.Struct<{
669
887
  readonly style: Schema.Literals<readonly ["path", "prose"]>;
670
888
  }>;
@@ -725,8 +943,6 @@ export declare const translate: (table: typeof TranslateTable.Type, to?: string)
725
943
  export declare const degrade: (form: DegradeForm) => Degrade;
726
944
  /** @public */
727
945
  export declare const unresolved: (note: string) => Unresolved;
728
- //#endregion
729
- //#region src/version.d.ts
730
946
  /**
731
947
  * The version of `@pluginfinity/core` this build was made from.
732
948
  *
@@ -738,6 +954,5 @@ export declare const unresolved: (note: string) => Unresolved;
738
954
  * @public
739
955
  */
740
956
  export declare const CORE_VERSION: string;
741
- //#endregion
742
957
  export type { AgentField, DegradeForm, HooksFields, LspField, SkillField };
743
958
  //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -1,9 +1,12 @@
1
- import { CLAUDE_HOOK_EVENTS, ClaudeHookEvent, CommandHook, HookEntries, HookEntry, HookFallback, Hooks, ScriptHook, makeHooks } from "./hooks.js";
1
+ import { CLAUDE_HOOK_EVENTS, ClaudeHookEvent, CommandHook, HookEntries, HookEntry, HookFallback, Hooks, PluginRelativePath, ScriptHook, makeHooks } from "./hooks.js";
2
+ import { EnvConfig, EnvVar, EnvVarName } from "./env.js";
2
3
  import { McpServer, McpServers, RemoteMcpServer, ServerEnv, StdioMcpServer } from "./mcp.js";
3
4
  import { LSP_FIELDS, LspServer, LspServers } from "./lsp.js";
5
+ import { KebabName } from "./name.js";
6
+ import { CommandMonitor, MonitorEntry, MonitorName, MonitorWhen, Monitors, ScriptMonitor } from "./monitors.js";
4
7
  import { BASE_CONFIG_KEYS, BaseConfigFields, PluginName, ScriptInvoke, ShippedPath, makeTargetSetting } from "./config.js";
5
8
  import { AGENT_FIELDS, AgentFrontmatter, ComponentName, ComponentTargets, SKILL_FIELDS, SkillFrontmatter } from "./frontmatter.js";
6
9
  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";
7
10
  import { CORE_VERSION } from "./version.js";
8
11
 
9
- export { AGENT_FIELDS, Absent, AgentFrontmatter, BASE_CONFIG_KEYS, BaseConfigFields, CLAUDE_HOOK_EVENTS, CORE_VERSION, ClaudeHookEvent, CommandHook, ComponentName, ComponentTargets, DEGRADE_FORMS, Degrade, Drop, EventMapping, FieldMapEntry, HOOKS_FORMATS, HookEntries, HookEntry, HookFallback, Hooks, HooksFormat, InFile, InManifest, Keep, LSP_FIELDS, LSP_FORMATS, LspFormat, LspServer, LspServers, MANIFEST_FORMATS, MCP_FORMATS, ManifestFormat, McpFormat, McpServer, McpServers, PluginName, RemoteMcpServer, Rename, RootSpelling, SKILL_FIELDS, ScriptHook, ScriptInvoke, ServerEnv, ServerPlacement, ShippedPath, SkillFrontmatter, StdioMcpServer, Target, ToolMapping, Translate, TranslateTable, Unresolved, ValueMapping, absent, degrade, drop, inFile, inManifest, keep, makeHooks, makeTargetSetting, rename, translate, unresolved };
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 };
package/lsp.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ServerEnv } from "./mcp.js";
2
2
  import { Schema } from "effect";
3
3
 
4
- //#region src/lsp.ts
4
+ // src/lsp.ts
5
5
  const NonNegativeInt = Schema.Number.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0));
6
6
  /**
7
7
  * One LSP server, in Claude Code's `.lsp.json` server shape. `${PLUGIN_ROOT}`
@@ -49,5 +49,4 @@ const LSP_FIELDS = [
49
49
  "diagnostics"
50
50
  ];
51
51
 
52
- //#endregion
53
52
  export { LSP_FIELDS, LspServer, LspServers };
package/mcp.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
 
3
- //#region src/mcp.ts
3
+ // src/mcp.ts
4
4
  /**
5
5
  * A server's environment. `PLUGINFINITY_` keys are reserved for the
6
6
  * variables the build injects.
@@ -44,5 +44,4 @@ const McpServer = Schema.Union([StdioMcpServer, RemoteMcpServer]);
44
44
  */
45
45
  const McpServers = Schema.Record(Schema.String, McpServer);
46
46
 
47
- //#endregion
48
47
  export { McpServer, McpServers, RemoteMcpServer, ServerEnv, StdioMcpServer };
package/monitors.js ADDED
@@ -0,0 +1,64 @@
1
+ import { PluginRelativePath } from "./hooks.js";
2
+ import { KebabName } from "./name.js";
3
+ import { Schema } from "effect";
4
+
5
+ // src/monitors.ts
6
+ /**
7
+ * A monitor's name: kebab-case, the key it is written under.
8
+ *
9
+ * @public
10
+ */
11
+ const MonitorName = KebabName;
12
+ /**
13
+ * When a monitor starts: `"always"` (the default) or the first time a named
14
+ * skill is invoked, as `on-skill-invoke:<skill>`.
15
+ *
16
+ * @remarks
17
+ * `<skill>` is the bare skill name, so the source is host-neutral: it holds no
18
+ * `:`. Claude Code matches the plugin-qualified name `<plugin>:<skill>`, and
19
+ * the build writes that form.
20
+ *
21
+ * @public
22
+ */
23
+ const MonitorWhen = Schema.Union([Schema.Literal("always"), Schema.String.check(Schema.isPattern(/^on-skill-invoke:[^:]+$/, { message: "must be \"always\" or \"on-skill-invoke:<skill>\" with the bare skill name, no plugin prefix: the build qualifies it" }))]);
24
+ const sharedMonitorFields = {
25
+ /** What the monitor watches, shown by the host. */
26
+ description: Schema.String.check(Schema.isMinLength(1)),
27
+ /** When the monitor starts. Defaults to `"always"`. */
28
+ when: Schema.optionalKey(MonitorWhen)
29
+ };
30
+ /**
31
+ * A monitor that runs a script the plugin ships. Each line it prints to
32
+ * stdout is delivered to the model.
33
+ *
34
+ * @public
35
+ */
36
+ const ScriptMonitor = Schema.Struct({
37
+ script: PluginRelativePath,
38
+ args: Schema.optionalKey(Schema.Array(Schema.String)),
39
+ ...sharedMonitorFields
40
+ });
41
+ /**
42
+ * A monitor given as a command string. `${PLUGIN_ROOT}` is its one placeholder.
43
+ *
44
+ * @public
45
+ */
46
+ const CommandMonitor = Schema.Struct({
47
+ command: Schema.String.check(Schema.isMinLength(1)),
48
+ ...sharedMonitorFields
49
+ });
50
+ /**
51
+ * One monitor: exactly one of `script` or `command`. Decode strictly, or a
52
+ * mixed entry decodes as whichever member matches first.
53
+ *
54
+ * @public
55
+ */
56
+ const MonitorEntry = Schema.Union([ScriptMonitor, CommandMonitor]);
57
+ /**
58
+ * A plugin's monitors, keyed by name.
59
+ *
60
+ * @public
61
+ */
62
+ const Monitors = Schema.Record(MonitorName, MonitorEntry);
63
+
64
+ export { CommandMonitor, MonitorEntry, MonitorName, MonitorWhen, Monitors, ScriptMonitor };
package/name.js ADDED
@@ -0,0 +1,12 @@
1
+ import { Schema } from "effect";
2
+
3
+ // src/name.ts
4
+ /**
5
+ * A name every host accepts: kebab-case, lowercase letters and digits
6
+ * separated by single hyphens.
7
+ *
8
+ * @public
9
+ */
10
+ const KebabName = Schema.String.check(Schema.isPattern(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, { message: "must be kebab-case: lowercase letters and digits separated by single hyphens" }));
11
+
12
+ export { KebabName };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluginfinity/core",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
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.0.0"
37
+ "effect": "~4.1.1"
38
38
  },
39
39
  "engines": {
40
40
  "node": ">=24.11.0"
package/target.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
 
3
- //#region src/target.ts
3
+ // src/target.ts
4
4
  /**
5
5
  * The forms a field can be moved into when a host lacks it. The engine owns
6
6
  * one renderer per form.
@@ -185,7 +185,19 @@ var Target = class extends Schema.Class("Target")({
185
185
  * How a user invokes a plugin skill: a template with `{plugin}` and `{skill}`,
186
186
  * or `unresolved` when the host has no such command.
187
187
  */
188
- invoke: Schema.Union([Schema.String, Unresolved])
188
+ invoke: Schema.Union([Schema.String, Unresolved]),
189
+ /**
190
+ * How a skill body names a skill's directory: `own` for the skill the body
191
+ * belongs to, `other` for a sibling, a template with `{skill}`, and `agent`
192
+ * for a sibling named from an agent body, which has no skill base
193
+ * directory. Where the host expands no path in bodies these are
194
+ * placeholders the model fills in, not paths.
195
+ */
196
+ dirSpelling: Schema.Struct({
197
+ own: Schema.String,
198
+ other: Schema.String,
199
+ agent: RootSpelling
200
+ })
189
201
  }),
190
202
  agents: Schema.Struct({
191
203
  dir: Schema.String,
@@ -199,7 +211,29 @@ var Target = class extends Schema.Class("Target")({
199
211
  path: Schema.String,
200
212
  format: HooksFormat,
201
213
  events: Schema.Record(Schema.String, EventMapping),
202
- ownEvents: Schema.Array(Schema.String)
214
+ ownEvents: Schema.Array(Schema.String),
215
+ /**
216
+ * The Claude events whose matcher the host ignores. The build drops the
217
+ * host `matcher` key there and the hook library applies the matcher at
218
+ * run time instead.
219
+ */
220
+ matcherIgnored: Schema.Array(Schema.String),
221
+ /**
222
+ * The Claude events where the host honours each kind of hook output: the
223
+ * `context` a hook adds to the model's view and the `system_message` it
224
+ * shows the user. Mirrors `hook_supports` in the hook library, which a test
225
+ * pins; the build notes a script that emits output the host would ignore.
226
+ */
227
+ output: Schema.Struct({
228
+ context: Schema.Array(Schema.String),
229
+ system_message: Schema.Array(Schema.String)
230
+ }),
231
+ /**
232
+ * The Claude events from which the host passes values a hook exports to
233
+ * the model's shell (Claude Code's `CLAUDE_ENV_FILE`); empty when it has
234
+ * no such channel, and a skill script must source `env.sh` instead.
235
+ */
236
+ envShell: Schema.Array(Schema.String)
203
237
  }),
204
238
  mcp: Schema.Struct({
205
239
  placement: ServerPlacement,
@@ -211,6 +245,14 @@ var Target = class extends Schema.Class("Target")({
211
245
  format: LspFormat,
212
246
  fields: FieldMap
213
247
  }),
248
+ /**
249
+ * Where the host reads background monitors and how it spells the plugin root
250
+ * in their commands, or `unresolved` when the host has no monitors.
251
+ */
252
+ monitors: Schema.Union([Schema.Struct({
253
+ path: Schema.String,
254
+ root: Schema.String
255
+ }), Unresolved]),
214
256
  references: Schema.Struct({ style: Schema.Literals(["path", "prose"]) }),
215
257
  tools: Schema.Struct({
216
258
  names: Schema.Record(Schema.String, ToolMapping),
@@ -262,5 +304,4 @@ const degrade = (form) => Degrade.make({ form });
262
304
  /** @public */
263
305
  const unresolved = (note) => Unresolved.make({ note });
264
306
 
265
- //#endregion
266
307
  export { Absent, DEGRADE_FORMS, Degrade, DegradeForm, 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 };
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.59.1"
8
+ "packageVersion": "7.60.0"
9
9
  }
10
10
  ]
11
11
  }
package/version.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/version.ts
1
+ // src/version.ts
2
2
  /**
3
3
  * The version of `@pluginfinity/core` this build was made from.
4
4
  *
@@ -9,7 +9,6 @@
9
9
  *
10
10
  * @public
11
11
  */
12
- const CORE_VERSION = "0.2.1";
12
+ const CORE_VERSION = "0.3.1";
13
13
 
14
- //#endregion
15
14
  export { CORE_VERSION };