@pluginfinity/core 0.0.1 → 0.1.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 CHANGED
@@ -1,3 +1,5 @@
1
+ import { Hooks } from "./hooks.js";
2
+ import { McpServers } from "./mcp.js";
1
3
  import { Schema } from "effect";
2
4
 
3
5
  //#region src/config.ts
@@ -9,6 +11,13 @@ import { Schema } from "effect";
9
11
  */
10
12
  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" }));
11
13
  /**
14
+ * How a `script` hook is invoked: through `bash`, which ignores the file
15
+ * mode, or directly, which needs the executable bit.
16
+ *
17
+ * @public
18
+ */
19
+ const ScriptInvoke = Schema.Literals(["bash", "exec"]);
20
+ /**
12
21
  * The plugin-wide fields of a pluginfinity config, before any target key.
13
22
  *
14
23
  * @remarks
@@ -18,9 +27,27 @@ const PluginName = Schema.String.check(Schema.isPattern(/^[a-z0-9]+(?:-[a-z0-9]+
18
27
  *
19
28
  * @public
20
29
  */
21
- const BaseConfigFields = {
22
- /** The plugin's name for every host. Not read from `package.json`. */
23
- name: PluginName };
30
+ const BaseConfigFields = {
31
+ /** The plugin's name for every host. Not read from `package.json`. */
32
+ name: PluginName,
33
+ /** What the plugin does, shown by every host. */
34
+ description: Schema.String.check(Schema.isMinLength(1)),
35
+ author: Schema.optionalKey(Schema.Struct({
36
+ name: Schema.String,
37
+ email: Schema.optionalKey(Schema.String),
38
+ url: Schema.optionalKey(Schema.String)
39
+ })),
40
+ homepage: Schema.optionalKey(Schema.String),
41
+ repository: Schema.optionalKey(Schema.String),
42
+ license: Schema.optionalKey(Schema.String),
43
+ keywords: Schema.optionalKey(Schema.Array(Schema.String)),
44
+ /** How `script` hooks are invoked. Defaults to `{ invoke: "bash" }`. */
45
+ scripts: Schema.optionalKey(Schema.Struct({ invoke: Schema.optionalKey(ScriptInvoke) })),
46
+ /** Hooks keyed by Claude Code event names, generated per target. */
47
+ hooks: Schema.optionalKey(Hooks),
48
+ /** MCP servers in Claude Code's `.mcp.json` server shape. */
49
+ mcpServers: Schema.optionalKey(McpServers)
50
+ };
24
51
  /**
25
52
  * The names of the plugin-wide config fields.
26
53
  *
@@ -28,20 +55,23 @@ name: PluginName };
28
55
  */
29
56
  const BASE_CONFIG_KEYS = Object.keys(BaseConfigFields);
30
57
  /**
31
- * What a target key may override for that host.
32
- *
33
- * @public
34
- */
35
- const TargetOverride = Schema.Struct({
36
- /** The plugin's name on this host, when it differs from the base `name`. */
37
- name: Schema.optionalKey(PluginName) });
38
- /**
39
58
  * A target key's value: `true` to enable the target with no overrides, or an
40
59
  * override object. An absent key means the target is off; `false` is rejected.
41
60
  *
61
+ * @remarks
62
+ * `hooks` is the target's own hooks schema, so each target admits the events
63
+ * it has: a hook under it replaces the base entries for that event on that
64
+ * target, and `[]` removes them. A server under `mcpServers` replaces the base
65
+ * server of that name.
66
+ *
42
67
  * @public
43
68
  */
44
- const TargetSetting = Schema.Union([Schema.Literal(true), TargetOverride]);
69
+ const makeTargetSetting = (hooks) => Schema.Union([Schema.Literal(true), Schema.Struct({
70
+ /** The plugin's name on this host, when it differs from the base `name`. */
71
+ name: Schema.optionalKey(PluginName),
72
+ hooks: Schema.optionalKey(hooks),
73
+ mcpServers: Schema.optionalKey(McpServers)
74
+ })]);
45
75
 
46
76
  //#endregion
47
- export { BASE_CONFIG_KEYS, BaseConfigFields, PluginName, TargetOverride, TargetSetting };
77
+ export { BASE_CONFIG_KEYS, BaseConfigFields, PluginName, ScriptInvoke, makeTargetSetting };
package/frontmatter.js ADDED
@@ -0,0 +1,118 @@
1
+ import { PluginName } from "./config.js";
2
+ import { Schema } from "effect";
3
+
4
+ //#region src/frontmatter.ts
5
+ /**
6
+ * A skill or agent name: kebab-case and at most 64 characters, the Agent
7
+ * Skills spec rule and the strictest of the hosts.
8
+ *
9
+ * @public
10
+ */
11
+ const ComponentName = PluginName.check(Schema.isMaxLength(64));
12
+ /**
13
+ * A component's per-target block: `false` leaves it out of that target, an
14
+ * object holds fields for that host only. Keys are checked against the
15
+ * registry when a plugin is read; the block is stripped on emit.
16
+ *
17
+ * @public
18
+ */
19
+ const ComponentTargets = Schema.Record(Schema.String, Schema.Union([Schema.Literal(false), Schema.Record(Schema.String, Schema.Unknown)]));
20
+ const ToolList = Schema.Union([Schema.String, Schema.Array(Schema.String)]);
21
+ const Effort = Schema.Literals([
22
+ "low",
23
+ "medium",
24
+ "high",
25
+ "xhigh",
26
+ "max"
27
+ ]);
28
+ const PositiveInt = Schema.Int.check(Schema.isGreaterThan(0));
29
+ /**
30
+ * A skill's `SKILL.md` frontmatter, in Claude Code's field names.
31
+ *
32
+ * @public
33
+ */
34
+ const SkillFrontmatter = Schema.Struct({
35
+ name: Schema.optionalKey(ComponentName),
36
+ description: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(1024)),
37
+ license: Schema.optionalKey(Schema.String),
38
+ compatibility: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(500))),
39
+ metadata: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),
40
+ "allowed-tools": Schema.optionalKey(ToolList),
41
+ "disallowed-tools": Schema.optionalKey(ToolList),
42
+ when_to_use: Schema.optionalKey(Schema.String),
43
+ "argument-hint": Schema.optionalKey(Schema.String),
44
+ arguments: Schema.optionalKey(ToolList),
45
+ "disable-model-invocation": Schema.optionalKey(Schema.Boolean),
46
+ "user-invocable": Schema.optionalKey(Schema.Boolean),
47
+ model: Schema.optionalKey(Schema.String),
48
+ effort: Schema.optionalKey(Effort),
49
+ context: Schema.optionalKey(Schema.Literal("fork")),
50
+ agent: Schema.optionalKey(Schema.String),
51
+ background: Schema.optionalKey(Schema.Boolean),
52
+ hooks: Schema.optionalKey(Schema.Record(Schema.String, Schema.Unknown)),
53
+ paths: Schema.optionalKey(ToolList),
54
+ shell: Schema.optionalKey(Schema.Literals(["bash", "powershell"])),
55
+ targets: Schema.optionalKey(ComponentTargets)
56
+ });
57
+ /**
58
+ * An agent file's frontmatter, in Claude Code's field names.
59
+ *
60
+ * @public
61
+ */
62
+ const AgentFrontmatter = Schema.Struct({
63
+ name: ComponentName,
64
+ description: Schema.String.check(Schema.isMinLength(1)),
65
+ tools: Schema.optionalKey(ToolList),
66
+ disallowedTools: Schema.optionalKey(ToolList),
67
+ model: Schema.optionalKey(Schema.String),
68
+ effort: Schema.optionalKey(Effort),
69
+ permissionMode: Schema.optionalKey(Schema.Literals([
70
+ "default",
71
+ "acceptEdits",
72
+ "auto",
73
+ "dontAsk",
74
+ "bypassPermissions",
75
+ "plan",
76
+ "manual"
77
+ ])),
78
+ maxTurns: Schema.optionalKey(PositiveInt),
79
+ skills: Schema.optionalKey(Schema.Array(Schema.String)),
80
+ mcpServers: Schema.optionalKey(Schema.Array(Schema.Union([Schema.String, Schema.Record(Schema.String, Schema.Unknown)]))),
81
+ hooks: Schema.optionalKey(Schema.Record(Schema.String, Schema.Unknown)),
82
+ memory: Schema.optionalKey(Schema.Literals([
83
+ "user",
84
+ "project",
85
+ "local"
86
+ ])),
87
+ background: Schema.optionalKey(Schema.Boolean),
88
+ omitClaudeMd: Schema.optionalKey(Schema.Boolean),
89
+ isolation: Schema.optionalKey(Schema.Literal("worktree")),
90
+ color: Schema.optionalKey(Schema.Literals([
91
+ "red",
92
+ "blue",
93
+ "green",
94
+ "yellow",
95
+ "purple",
96
+ "orange",
97
+ "pink",
98
+ "cyan"
99
+ ])),
100
+ initialPrompt: Schema.optionalKey(Schema.String),
101
+ experimental: Schema.optionalKey(Schema.Struct({ cacheTtl: Schema.optionalKey(Schema.Literals(["5m", "1h"])) })),
102
+ targets: Schema.optionalKey(ComponentTargets)
103
+ });
104
+ /**
105
+ * Every skill frontmatter field except `targets`.
106
+ *
107
+ * @public
108
+ */
109
+ const SKILL_FIELDS = Object.keys(SkillFrontmatter.fields).filter((key) => key !== "targets");
110
+ /**
111
+ * Every agent frontmatter field except `targets`.
112
+ *
113
+ * @public
114
+ */
115
+ const AGENT_FIELDS = Object.keys(AgentFrontmatter.fields).filter((key) => key !== "targets");
116
+
117
+ //#endregion
118
+ export { AGENT_FIELDS, AgentFrontmatter, ComponentName, ComponentTargets, SKILL_FIELDS, SkillFrontmatter };
package/hooks.js ADDED
@@ -0,0 +1,124 @@
1
+ import { Schema } from "effect";
2
+
3
+ //#region src/hooks.ts
4
+ /**
5
+ * Every Claude Code hook event, the vocabulary a plugin's `hooks` config is
6
+ * written in. Each target maps these to its own names.
7
+ *
8
+ * @public
9
+ */
10
+ const CLAUDE_HOOK_EVENTS = [
11
+ "SessionStart",
12
+ "Setup",
13
+ "UserPromptSubmit",
14
+ "UserPromptExpansion",
15
+ "PreToolUse",
16
+ "PermissionRequest",
17
+ "PermissionDenied",
18
+ "PostToolUse",
19
+ "PostToolUseFailure",
20
+ "PostToolBatch",
21
+ "Notification",
22
+ "MessageDisplay",
23
+ "SubagentStart",
24
+ "SubagentStop",
25
+ "TaskCreated",
26
+ "TaskCompleted",
27
+ "Stop",
28
+ "StopFailure",
29
+ "TeammateIdle",
30
+ "InstructionsLoaded",
31
+ "ConfigChange",
32
+ "CwdChanged",
33
+ "DirectoryAdded",
34
+ "FileChanged",
35
+ "WorktreeCreate",
36
+ "WorktreeRemove",
37
+ "PreCompact",
38
+ "PostCompact",
39
+ "PreModelSwitch",
40
+ "PostModelSwitch",
41
+ "Elicitation",
42
+ "ElicitationResult",
43
+ "SessionEnd"
44
+ ];
45
+ /**
46
+ * A Claude Code hook event name.
47
+ *
48
+ * @public
49
+ */
50
+ const ClaudeHookEvent = Schema.Literals(CLAUDE_HOOK_EVENTS);
51
+ /**
52
+ * What a target that lacks a hook's event does with it: fail the build, or
53
+ * leave the hook out of that target.
54
+ *
55
+ * @public
56
+ */
57
+ const HookFallback = Schema.Literals(["fail", "omit"]);
58
+ /**
59
+ * A path relative to the plugin root: no leading slash, no backslash, no `..`
60
+ * segment.
61
+ */
62
+ 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
+ const PositiveInt = Schema.Int.check(Schema.isGreaterThan(0, { message: "must be a positive whole number of seconds" }));
64
+ const sharedHookFields = {
65
+ /** A Claude Code tool-name matcher, such as `Bash` or `Edit|Write`. */
66
+ matcher: Schema.optionalKey(Schema.String),
67
+ /** Seconds before the host gives up on the hook. */
68
+ timeout: Schema.optionalKey(PositiveInt),
69
+ /** What a target without this event does. Defaults to `"fail"`. */
70
+ fallback: Schema.optionalKey(HookFallback)
71
+ };
72
+ /**
73
+ * A hook that runs a script the plugin ships. The build checks the script
74
+ * exists and writes each host's command for it.
75
+ *
76
+ * @public
77
+ */
78
+ const ScriptHook = Schema.Struct({
79
+ script: PluginRelativePath,
80
+ args: Schema.optionalKey(Schema.Array(Schema.String)),
81
+ ...sharedHookFields
82
+ });
83
+ /**
84
+ * A hook given as a command string. `${PLUGIN_ROOT}` is its one placeholder.
85
+ *
86
+ * @public
87
+ */
88
+ const CommandHook = Schema.Struct({
89
+ command: Schema.String.check(Schema.isMinLength(1)),
90
+ ...sharedHookFields
91
+ });
92
+ /**
93
+ * One hook: exactly one of `script` or `command`. Decode strictly, or a mixed
94
+ * entry decodes as whichever member matches first.
95
+ *
96
+ * @public
97
+ */
98
+ const HookEntry = Schema.Union([ScriptHook, CommandHook]);
99
+ /**
100
+ * The hooks for one event. An empty list removes a base event's hooks when
101
+ * used in a target override.
102
+ *
103
+ * @public
104
+ */
105
+ const HookEntries = Schema.Array(HookEntry);
106
+ /**
107
+ * A hooks map admitting exactly the events `E`, each optional.
108
+ *
109
+ * @remarks
110
+ * Built as a `Struct` of optional keys because `Schema.Record` keyed by
111
+ * literals makes every key required.
112
+ *
113
+ * @public
114
+ */
115
+ const makeHooks = (events) => Schema.Struct(Object.fromEntries(events.map((event) => [event, Schema.optionalKey(HookEntries)])));
116
+ /**
117
+ * A plugin's base `hooks` config, keyed by Claude Code event names.
118
+ *
119
+ * @public
120
+ */
121
+ const Hooks = makeHooks(CLAUDE_HOOK_EVENTS);
122
+
123
+ //#endregion
124
+ export { CLAUDE_HOOK_EVENTS, ClaudeHookEvent, CommandHook, HookEntries, HookEntry, HookFallback, Hooks, ScriptHook, makeHooks };
package/index.d.ts CHANGED
@@ -1,4 +1,120 @@
1
1
  import { Schema } from "effect";
2
+ //#region src/hooks.d.ts
3
+ /**
4
+ * Every Claude Code hook event, the vocabulary a plugin's `hooks` config is
5
+ * written in. Each target maps these to its own names.
6
+ *
7
+ * @public
8
+ */
9
+ 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"];
10
+ /**
11
+ * A Claude Code hook event name.
12
+ *
13
+ * @public
14
+ */
15
+ 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"]>;
16
+ /**
17
+ * The decoded `ClaudeHookEvent`.
18
+ *
19
+ * @public
20
+ */
21
+ export type ClaudeHookEvent = typeof ClaudeHookEvent.Type;
22
+ /**
23
+ * What a target that lacks a hook's event does with it: fail the build, or
24
+ * leave the hook out of that target.
25
+ *
26
+ * @public
27
+ */
28
+ export declare const HookFallback: Schema.Literals<readonly ["fail", "omit"]>;
29
+ /**
30
+ * A hook that runs a script the plugin ships. The build checks the script
31
+ * exists and writes each host's command for it.
32
+ *
33
+ * @public
34
+ */
35
+ export declare const ScriptHook: Schema.Struct<{
36
+ readonly matcher: Schema.optionalKey<Schema.String>;
37
+ readonly timeout: Schema.optionalKey<Schema.Int>;
38
+ readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
39
+ readonly script: Schema.String;
40
+ readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
41
+ }>;
42
+ /**
43
+ * A hook given as a command string. `${PLUGIN_ROOT}` is its one placeholder.
44
+ *
45
+ * @public
46
+ */
47
+ export declare const CommandHook: Schema.Struct<{
48
+ readonly matcher: Schema.optionalKey<Schema.String>;
49
+ readonly timeout: Schema.optionalKey<Schema.Int>;
50
+ readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
51
+ readonly command: Schema.String;
52
+ }>;
53
+ /**
54
+ * One hook: exactly one of `script` or `command`. Decode strictly, or a mixed
55
+ * entry decodes as whichever member matches first.
56
+ *
57
+ * @public
58
+ */
59
+ export declare const HookEntry: Schema.Union<readonly [Schema.Struct<{
60
+ readonly matcher: Schema.optionalKey<Schema.String>;
61
+ readonly timeout: Schema.optionalKey<Schema.Int>;
62
+ readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
63
+ readonly script: Schema.String;
64
+ readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
65
+ }>, Schema.Struct<{
66
+ readonly matcher: Schema.optionalKey<Schema.String>;
67
+ readonly timeout: Schema.optionalKey<Schema.Int>;
68
+ readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
69
+ readonly command: Schema.String;
70
+ }>]>;
71
+ /**
72
+ * The decoded `HookEntry`.
73
+ *
74
+ * @public
75
+ */
76
+ export type HookEntry = typeof HookEntry.Type;
77
+ /**
78
+ * The hooks for one event. An empty list removes a base event's hooks when
79
+ * used in a target override.
80
+ *
81
+ * @public
82
+ */
83
+ export declare const HookEntries: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
84
+ readonly matcher: Schema.optionalKey<Schema.String>;
85
+ readonly timeout: Schema.optionalKey<Schema.Int>;
86
+ readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
87
+ readonly script: Schema.String;
88
+ readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
89
+ }>, Schema.Struct<{
90
+ readonly matcher: Schema.optionalKey<Schema.String>;
91
+ readonly timeout: Schema.optionalKey<Schema.Int>;
92
+ readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "omit"]>>;
93
+ readonly command: Schema.String;
94
+ }>]>>;
95
+ /**
96
+ * The fields of a hooks map over the events `E`, each optional.
97
+ *
98
+ * @public
99
+ */
100
+ type HooksFields<E extends ReadonlyArray<string>> = { readonly [K in E[number]]: Schema.optionalKey<typeof HookEntries>; };
101
+ /**
102
+ * A hooks map admitting exactly the events `E`, each optional.
103
+ *
104
+ * @remarks
105
+ * Built as a `Struct` of optional keys because `Schema.Record` keyed by
106
+ * literals makes every key required.
107
+ *
108
+ * @public
109
+ */
110
+ export declare const makeHooks: <const E extends ReadonlyArray<string>>(events: E) => Schema.Struct<HooksFields<E>>;
111
+ /**
112
+ * A plugin's base `hooks` config, keyed by Claude Code event names.
113
+ *
114
+ * @public
115
+ */
116
+ 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
2
118
  //#region src/config.d.ts
3
119
  /**
4
120
  * A plugin name as every host spells it: kebab-case, lowercase letters and
@@ -7,6 +123,13 @@ import { Schema } from "effect";
7
123
  * @public
8
124
  */
9
125
  export declare const PluginName: Schema.String;
126
+ /**
127
+ * How a `script` hook is invoked: through `bash`, which ignores the file
128
+ * mode, or directly, which needs the executable bit.
129
+ *
130
+ * @public
131
+ */
132
+ export declare const ScriptInvoke: Schema.Literals<readonly ["bash", "exec"]>;
10
133
  /**
11
134
  * The plugin-wide fields of a pluginfinity config, before any target key.
12
135
  *
@@ -20,6 +143,35 @@ export declare const PluginName: Schema.String;
20
143
  export declare const BaseConfigFields: {
21
144
  /** The plugin's name for every host. Not read from `package.json`. */
22
145
  readonly name: Schema.String;
146
+ /** What the plugin does, shown by every host. */
147
+ readonly description: Schema.String;
148
+ readonly author: Schema.optionalKey<Schema.Struct<{
149
+ readonly name: Schema.String;
150
+ readonly email: Schema.optionalKey<Schema.String>;
151
+ readonly url: Schema.optionalKey<Schema.String>;
152
+ }>>;
153
+ readonly homepage: Schema.optionalKey<Schema.String>;
154
+ readonly repository: Schema.optionalKey<Schema.String>;
155
+ readonly license: Schema.optionalKey<Schema.String>;
156
+ readonly keywords: Schema.optionalKey<Schema.$Array<Schema.String>>;
157
+ /** How `script` hooks are invoked. Defaults to `{ invoke: "bash" }`. */
158
+ readonly scripts: Schema.optionalKey<Schema.Struct<{
159
+ readonly invoke: Schema.optionalKey<Schema.Literals<readonly ["bash", "exec"]>>;
160
+ }>>;
161
+ /** Hooks keyed by Claude Code event names, generated per target. */
162
+ 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"]>>>;
163
+ /** MCP servers in Claude Code's `.mcp.json` server shape. */
164
+ readonly mcpServers: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{
165
+ readonly type: Schema.optionalKey<Schema.Literal<"stdio">>;
166
+ readonly command: Schema.String;
167
+ readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
168
+ readonly env: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
169
+ readonly cwd: Schema.optionalKey<Schema.String>;
170
+ }>, Schema.Struct<{
171
+ readonly type: Schema.Literals<readonly ["http", "sse"]>;
172
+ readonly url: Schema.String;
173
+ readonly headers: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
174
+ }>]>>>;
23
175
  };
24
176
  /**
25
177
  * The names of the plugin-wide config fields.
@@ -28,36 +180,372 @@ export declare const BaseConfigFields: {
28
180
  */
29
181
  export declare const BASE_CONFIG_KEYS: ReadonlyArray<string>;
30
182
  /**
31
- * What a target key may override for that host.
183
+ * A target key's value: `true` to enable the target with no overrides, or an
184
+ * override object. An absent key means the target is off; `false` is rejected.
185
+ *
186
+ * @remarks
187
+ * `hooks` is the target's own hooks schema, so each target admits the events
188
+ * it has: a hook under it replaces the base entries for that event on that
189
+ * target, and `[]` removes them. A server under `mcpServers` replaces the base
190
+ * server of that name.
32
191
  *
33
192
  * @public
34
193
  */
35
- export declare const TargetOverride: Schema.Struct<{
194
+ export declare const makeTargetSetting: <H extends Schema.Top>(hooks: H) => Schema.Union<readonly [Schema.Literal<true>, Schema.Struct<{
36
195
  /** The plugin's name on this host, when it differs from the base `name`. */
37
196
  readonly name: Schema.optionalKey<Schema.String>;
38
- }>;
197
+ readonly hooks: Schema.optionalKey<H>;
198
+ readonly mcpServers: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{
199
+ readonly type: Schema.optionalKey<Schema.Literal<"stdio">>;
200
+ readonly command: Schema.String;
201
+ readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
202
+ readonly env: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
203
+ readonly cwd: Schema.optionalKey<Schema.String>;
204
+ }>, Schema.Struct<{
205
+ readonly type: Schema.Literals<readonly ["http", "sse"]>;
206
+ readonly url: Schema.String;
207
+ readonly headers: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
208
+ }>]>>>;
209
+ }>]>;
210
+ //#endregion
211
+ //#region src/frontmatter.d.ts
39
212
  /**
40
- * The decoded `TargetOverride`.
213
+ * A skill or agent name: kebab-case and at most 64 characters, the Agent
214
+ * Skills spec rule and the strictest of the hosts.
41
215
  *
42
216
  * @public
43
217
  */
44
- export type TargetOverride = typeof TargetOverride.Type;
218
+ export declare const ComponentName: Schema.String;
45
219
  /**
46
- * A target key's value: `true` to enable the target with no overrides, or an
47
- * override object. An absent key means the target is off; `false` is rejected.
220
+ * A component's per-target block: `false` leaves it out of that target, an
221
+ * object holds fields for that host only. Keys are checked against the
222
+ * registry when a plugin is read; the block is stripped on emit.
48
223
  *
49
224
  * @public
50
225
  */
51
- export declare const TargetSetting: Schema.Union<readonly [Schema.Literal<true>, Schema.Struct<{
52
- /** The plugin's name on this host, when it differs from the base `name`. */
226
+ export declare const ComponentTargets: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Literal<false>, Schema.$Record<Schema.String, Schema.Unknown>]>>;
227
+ /**
228
+ * A skill's `SKILL.md` frontmatter, in Claude Code's field names.
229
+ *
230
+ * @public
231
+ */
232
+ export declare const SkillFrontmatter: Schema.Struct<{
53
233
  readonly name: Schema.optionalKey<Schema.String>;
234
+ readonly description: Schema.String;
235
+ readonly license: Schema.optionalKey<Schema.String>;
236
+ readonly compatibility: Schema.optionalKey<Schema.String>;
237
+ readonly metadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
238
+ readonly "allowed-tools": Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
239
+ readonly "disallowed-tools": Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
240
+ readonly when_to_use: Schema.optionalKey<Schema.String>;
241
+ readonly "argument-hint": Schema.optionalKey<Schema.String>;
242
+ readonly arguments: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
243
+ readonly "disable-model-invocation": Schema.optionalKey<Schema.Boolean>;
244
+ readonly "user-invocable": Schema.optionalKey<Schema.Boolean>;
245
+ readonly model: Schema.optionalKey<Schema.String>;
246
+ readonly effort: Schema.optionalKey<Schema.Literals<readonly ["low", "medium", "high", "xhigh", "max"]>>;
247
+ readonly context: Schema.optionalKey<Schema.Literal<"fork">>;
248
+ readonly agent: Schema.optionalKey<Schema.String>;
249
+ readonly background: Schema.optionalKey<Schema.Boolean>;
250
+ readonly hooks: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>;
251
+ readonly paths: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
252
+ readonly shell: Schema.optionalKey<Schema.Literals<readonly ["bash", "powershell"]>>;
253
+ readonly targets: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Literal<false>, Schema.$Record<Schema.String, Schema.Unknown>]>>>;
254
+ }>;
255
+ /**
256
+ * An agent file's frontmatter, in Claude Code's field names.
257
+ *
258
+ * @public
259
+ */
260
+ export declare const AgentFrontmatter: Schema.Struct<{
261
+ readonly name: Schema.String;
262
+ readonly description: Schema.String;
263
+ readonly tools: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
264
+ readonly disallowedTools: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
265
+ readonly model: Schema.optionalKey<Schema.String>;
266
+ readonly effort: Schema.optionalKey<Schema.Literals<readonly ["low", "medium", "high", "xhigh", "max"]>>;
267
+ readonly permissionMode: Schema.optionalKey<Schema.Literals<readonly ["default", "acceptEdits", "auto", "dontAsk", "bypassPermissions", "plan", "manual"]>>;
268
+ readonly maxTurns: Schema.optionalKey<Schema.Int>;
269
+ readonly skills: Schema.optionalKey<Schema.$Array<Schema.String>>;
270
+ readonly mcpServers: Schema.optionalKey<Schema.$Array<Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Unknown>]>>>;
271
+ readonly hooks: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>;
272
+ readonly memory: Schema.optionalKey<Schema.Literals<readonly ["user", "project", "local"]>>;
273
+ readonly background: Schema.optionalKey<Schema.Boolean>;
274
+ readonly omitClaudeMd: Schema.optionalKey<Schema.Boolean>;
275
+ readonly isolation: Schema.optionalKey<Schema.Literal<"worktree">>;
276
+ readonly color: Schema.optionalKey<Schema.Literals<readonly ["red", "blue", "green", "yellow", "purple", "orange", "pink", "cyan"]>>;
277
+ readonly initialPrompt: Schema.optionalKey<Schema.String>;
278
+ readonly experimental: Schema.optionalKey<Schema.Struct<{
279
+ readonly cacheTtl: Schema.optionalKey<Schema.Literals<readonly ["5m", "1h"]>>;
280
+ }>>;
281
+ readonly targets: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Literal<false>, Schema.$Record<Schema.String, Schema.Unknown>]>>>;
282
+ }>;
283
+ /**
284
+ * A skill frontmatter field every target's field map must cover.
285
+ *
286
+ * @public
287
+ */
288
+ type SkillField = Exclude<keyof typeof SkillFrontmatter.fields, "targets">;
289
+ /**
290
+ * An agent frontmatter field every target's field map must cover.
291
+ *
292
+ * @public
293
+ */
294
+ type AgentField = Exclude<keyof typeof AgentFrontmatter.fields, "targets">;
295
+ /**
296
+ * Every skill frontmatter field except `targets`.
297
+ *
298
+ * @public
299
+ */
300
+ export declare const SKILL_FIELDS: ReadonlyArray<SkillField>;
301
+ /**
302
+ * Every agent frontmatter field except `targets`.
303
+ *
304
+ * @public
305
+ */
306
+ export declare const AGENT_FIELDS: ReadonlyArray<AgentField>;
307
+ //#endregion
308
+ //#region src/mcp.d.ts
309
+ /**
310
+ * A local MCP server the host launches. `${PLUGIN_ROOT}` is the one
311
+ * placeholder in `args`, `env` and `cwd`.
312
+ *
313
+ * @public
314
+ */
315
+ export declare const StdioMcpServer: Schema.Struct<{
316
+ readonly type: Schema.optionalKey<Schema.Literal<"stdio">>;
317
+ readonly command: Schema.String;
318
+ readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
319
+ readonly env: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
320
+ readonly cwd: Schema.optionalKey<Schema.String>;
321
+ }>;
322
+ /**
323
+ * A remote MCP server the host connects to.
324
+ *
325
+ * @public
326
+ */
327
+ export declare const RemoteMcpServer: Schema.Struct<{
328
+ readonly type: Schema.Literals<readonly ["http", "sse"]>;
329
+ readonly url: Schema.String;
330
+ readonly headers: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
331
+ }>;
332
+ /**
333
+ * One MCP server, in Claude Code's `.mcp.json` server shape.
334
+ *
335
+ * @public
336
+ */
337
+ export declare const McpServer: Schema.Union<readonly [Schema.Struct<{
338
+ readonly type: Schema.optionalKey<Schema.Literal<"stdio">>;
339
+ readonly command: Schema.String;
340
+ readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
341
+ readonly env: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
342
+ readonly cwd: Schema.optionalKey<Schema.String>;
343
+ }>, Schema.Struct<{
344
+ readonly type: Schema.Literals<readonly ["http", "sse"]>;
345
+ readonly url: Schema.String;
346
+ readonly headers: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
54
347
  }>]>;
55
348
  /**
56
- * The decoded `TargetSetting`.
349
+ * A plugin's MCP servers, keyed by server name.
350
+ *
351
+ * @public
352
+ */
353
+ export declare const McpServers: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{
354
+ readonly type: Schema.optionalKey<Schema.Literal<"stdio">>;
355
+ readonly command: Schema.String;
356
+ readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
357
+ readonly env: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
358
+ readonly cwd: Schema.optionalKey<Schema.String>;
359
+ }>, Schema.Struct<{
360
+ readonly type: Schema.Literals<readonly ["http", "sse"]>;
361
+ readonly url: Schema.String;
362
+ readonly headers: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
363
+ }>]>>;
364
+ //#endregion
365
+ //#region src/target.d.ts
366
+ /**
367
+ * The forms a field can be moved into when a host lacks it. The engine owns
368
+ * one renderer per form.
369
+ *
370
+ * @public
371
+ */
372
+ export declare const DEGRADE_FORMS: readonly ["description-suffix", "body-section"];
373
+ /** @public */
374
+ declare const DegradeForm: Schema.Literals<readonly ["description-suffix", "body-section"]>;
375
+ /** @public */
376
+ type DegradeForm = typeof DegradeForm.Type;
377
+ /**
378
+ * Manifest formats. The engine owns one encoder per format.
379
+ *
380
+ * @public
381
+ */
382
+ export declare const MANIFEST_FORMATS: readonly ["claude-plugin-json", "agent-plugins-1.0"];
383
+ /** @public */
384
+ export declare const ManifestFormat: Schema.Literals<readonly ["claude-plugin-json", "agent-plugins-1.0"]>;
385
+ /**
386
+ * Hooks file formats. The engine owns one encoder per format.
387
+ *
388
+ * @public
389
+ */
390
+ export declare const HOOKS_FORMATS: readonly ["claude-hooks-json", "copilot-hooks-v1"];
391
+ /** @public */
392
+ export declare const HooksFormat: Schema.Literals<readonly ["claude-hooks-json", "copilot-hooks-v1"]>;
393
+ /**
394
+ * MCP config formats. The engine owns one encoder per format.
395
+ *
396
+ * @public
397
+ */
398
+ export declare const MCP_FORMATS: readonly ["claude-mcp-json", "agent-plugins-mcp-1.0"];
399
+ /** @public */
400
+ export declare const McpFormat: Schema.Literals<readonly ["claude-mcp-json", "agent-plugins-mcp-1.0"]>;
401
+ declare const Keep_base: Schema.Class<Keep, Schema.TaggedStruct<"keep", {}>, {}>;
402
+ /** Write the field unchanged. @public */
403
+ export declare class Keep extends Keep_base {}
404
+ declare const Rename_base: Schema.Class<Rename, Schema.TaggedStruct<"rename", {
405
+ readonly to: Schema.String;
406
+ }>, {}>;
407
+ /** Write the field under another name. @public */
408
+ export declare class Rename extends Rename_base {}
409
+ /**
410
+ * The tables a field's value can be translated through: `tools` for tool lists,
411
+ * `models` for a model name, `efforts` for an effort level.
412
+ *
413
+ * @public
414
+ */
415
+ export declare const TranslateTable: Schema.Literals<readonly ["tools", "models", "efforts"]>;
416
+ declare const Translate_base: Schema.Class<Translate, Schema.TaggedStruct<"translate", {
417
+ readonly table: Schema.Literals<readonly ["tools", "models", "efforts"]>;
418
+ readonly to: Schema.optionalKey<Schema.String>;
419
+ }>, {}>;
420
+ /** Map the field's value through a named table, optionally writing it under another name. @public */
421
+ export declare class Translate extends Translate_base {}
422
+ declare const Degrade_base: Schema.Class<Degrade, Schema.TaggedStruct<"degrade", {
423
+ readonly form: Schema.Literals<readonly ["description-suffix", "body-section"]>;
424
+ }>, {}>;
425
+ /** Move the field into a named form the engine renders. @public */
426
+ export declare class Degrade extends Degrade_base {}
427
+ declare const Drop_base: Schema.Class<Drop, Schema.TaggedStruct<"drop", {}>, {}>;
428
+ /** Leave the field out; the host lacks it. @public */
429
+ export declare class Drop extends Drop_base {}
430
+ declare const Unresolved_base: Schema.Class<Unresolved, Schema.TaggedStruct<"unresolved", {
431
+ readonly note: Schema.String;
432
+ }>, {}>;
433
+ /**
434
+ * A fact the host documentation leaves open, with a note on what is unknown.
435
+ *
436
+ * @public
437
+ */
438
+ export declare class Unresolved extends Unresolved_base {}
439
+ declare const Absent_base: Schema.Class<Absent, Schema.TaggedStruct<"absent", {}>, {}>;
440
+ /** A Claude Code event the target does not have. @public */
441
+ export declare class Absent extends Absent_base {}
442
+ /**
443
+ * What a target does with one frontmatter field.
444
+ *
445
+ * @public
446
+ */
447
+ export declare const FieldMapEntry: Schema.Union<readonly [typeof Keep, typeof Rename, typeof Translate, typeof Degrade, typeof Drop, typeof Unresolved]>;
448
+ /** @public */
449
+ export type FieldMapEntry = typeof FieldMapEntry.Type;
450
+ /**
451
+ * How the plugin root is spelled at one site, or that the docs leave it open.
452
+ *
453
+ * @public
454
+ */
455
+ export declare const RootSpelling: Schema.Union<readonly [Schema.String, typeof Unresolved]>;
456
+ /**
457
+ * A Claude Code event's name on a target, or that the target lacks it.
458
+ *
459
+ * @public
460
+ */
461
+ export declare const EventMapping: Schema.Union<readonly [Schema.String, typeof Absent]>;
462
+ /**
463
+ * A Claude Code tool name's spelling on a target, `drop` to leave it out, or
464
+ * that the docs leave it open.
465
+ *
466
+ * @public
467
+ */
468
+ export declare const ToolMapping: Schema.Union<readonly [Schema.String, typeof Drop, typeof Unresolved]>;
469
+ /**
470
+ * A Claude Code value's spelling on a target, in the `models` or `efforts`
471
+ * table: the target's value, `drop` to leave the field out, or `unresolved`
472
+ * when the target has no counterpart and the author must choose.
473
+ *
474
+ * @public
475
+ */
476
+ export declare const ValueMapping: Schema.Union<readonly [Schema.String, typeof Drop, typeof Unresolved]>;
477
+ declare const Target_base: Schema.Class<Target, Schema.Struct<{
478
+ readonly manifest: Schema.Struct<{
479
+ readonly path: Schema.String;
480
+ readonly format: Schema.Literals<readonly ["claude-plugin-json", "agent-plugins-1.0"]>;
481
+ readonly schema: Schema.optionalKey<Schema.String>;
482
+ readonly keys: Schema.$Array<Schema.String>;
483
+ }>;
484
+ readonly pluginRoot: Schema.Struct<{
485
+ readonly hooks: Schema.Union<readonly [Schema.String, typeof Unresolved]>;
486
+ readonly mcp: Schema.Union<readonly [Schema.String, typeof Unresolved]>;
487
+ readonly body: Schema.Union<readonly [Schema.String, typeof Unresolved]>;
488
+ }>;
489
+ readonly skills: Schema.Struct<{
490
+ readonly dir: Schema.String;
491
+ readonly fields: Schema.$Record<Schema.String, Schema.Union<readonly [typeof Keep, typeof Rename, typeof Translate, typeof Degrade, typeof Drop, typeof Unresolved]>>;
492
+ readonly hostFields: Schema.$Array<Schema.String>;
493
+ }>;
494
+ readonly agents: Schema.Struct<{
495
+ readonly dir: Schema.String;
496
+ readonly suffix: Schema.String;
497
+ readonly fields: Schema.$Record<Schema.String, Schema.Union<readonly [typeof Keep, typeof Rename, typeof Translate, typeof Degrade, typeof Drop, typeof Unresolved]>>;
498
+ readonly hostFields: Schema.$Array<Schema.String>;
499
+ }>;
500
+ readonly hooks: Schema.Struct<{
501
+ readonly path: Schema.String;
502
+ readonly format: Schema.Literals<readonly ["claude-hooks-json", "copilot-hooks-v1"]>;
503
+ readonly events: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, typeof Absent]>>;
504
+ readonly ownEvents: Schema.$Array<Schema.String>;
505
+ }>;
506
+ readonly mcp: Schema.Struct<{
507
+ readonly path: Schema.String;
508
+ readonly format: Schema.Literals<readonly ["claude-mcp-json", "agent-plugins-mcp-1.0"]>;
509
+ readonly schema: Schema.optionalKey<Schema.String>;
510
+ }>;
511
+ readonly references: Schema.Struct<{
512
+ readonly style: Schema.Literals<readonly ["path", "prose"]>;
513
+ }>;
514
+ readonly tools: Schema.Struct<{
515
+ readonly names: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, typeof Drop, typeof Unresolved]>>;
516
+ readonly mcp: Schema.String;
517
+ }>;
518
+ readonly models: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, typeof Drop, typeof Unresolved]>>;
519
+ readonly efforts: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, typeof Drop, typeof Unresolved]>>;
520
+ }>, {}>;
521
+ /**
522
+ * One host, described by what it can do.
523
+ *
524
+ * @remarks
525
+ * Build a description with `Target.make`, which validates it at construction,
526
+ * so a malformed host description fails when `@pluginfinity/targets` loads.
527
+ * Field maps are typed as string records here; `@pluginfinity/targets` checks
528
+ * their totality over `SKILL_FIELDS` and `AGENT_FIELDS` at compile time and in
529
+ * tests. A tool name absent from `tools.names`, or a value absent from `models`
530
+ * or `efforts`, passes through unchanged.
57
531
  *
58
532
  * @public
59
533
  */
60
- export type TargetSetting = typeof TargetSetting.Type;
534
+ export declare class Target extends Target_base {}
535
+ /** @public */
536
+ export declare const keep: Keep;
537
+ /** @public */
538
+ export declare const drop: Drop;
539
+ /** @public */
540
+ export declare const absent: Absent;
541
+ /** @public */
542
+ export declare const rename: (to: string) => Rename;
543
+ /** @public */
544
+ export declare const translate: (table: typeof TranslateTable.Type, to?: string) => Translate;
545
+ /** @public */
546
+ export declare const degrade: (form: DegradeForm) => Degrade;
547
+ /** @public */
548
+ export declare const unresolved: (note: string) => Unresolved;
61
549
  //#endregion
62
550
  //#region src/version.d.ts
63
551
  /**
@@ -72,4 +560,5 @@ export type TargetSetting = typeof TargetSetting.Type;
72
560
  */
73
561
  export declare const CORE_VERSION: string;
74
562
  //#endregion
563
+ export type { AgentField, DegradeForm, HooksFields, SkillField };
75
564
  //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -1,4 +1,8 @@
1
- import { BASE_CONFIG_KEYS, BaseConfigFields, PluginName, TargetOverride, TargetSetting } from "./config.js";
1
+ import { CLAUDE_HOOK_EVENTS, ClaudeHookEvent, CommandHook, HookEntries, HookEntry, HookFallback, Hooks, ScriptHook, makeHooks } from "./hooks.js";
2
+ import { McpServer, McpServers, RemoteMcpServer, StdioMcpServer } from "./mcp.js";
3
+ import { BASE_CONFIG_KEYS, BaseConfigFields, PluginName, ScriptInvoke, makeTargetSetting } from "./config.js";
4
+ import { AGENT_FIELDS, AgentFrontmatter, ComponentName, ComponentTargets, SKILL_FIELDS, SkillFrontmatter } from "./frontmatter.js";
5
+ import { Absent, DEGRADE_FORMS, Degrade, Drop, EventMapping, FieldMapEntry, HOOKS_FORMATS, HooksFormat, Keep, MANIFEST_FORMATS, MCP_FORMATS, ManifestFormat, McpFormat, Rename, RootSpelling, Target, ToolMapping, Translate, TranslateTable, Unresolved, ValueMapping, absent, degrade, drop, keep, rename, translate, unresolved } from "./target.js";
2
6
  import { CORE_VERSION } from "./version.js";
3
7
 
4
- export { BASE_CONFIG_KEYS, BaseConfigFields, CORE_VERSION, PluginName, TargetOverride, TargetSetting };
8
+ 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, Keep, MANIFEST_FORMATS, MCP_FORMATS, ManifestFormat, McpFormat, McpServer, McpServers, PluginName, RemoteMcpServer, Rename, RootSpelling, SKILL_FIELDS, ScriptHook, ScriptInvoke, SkillFrontmatter, StdioMcpServer, Target, ToolMapping, Translate, TranslateTable, Unresolved, ValueMapping, absent, degrade, drop, keep, makeHooks, makeTargetSetting, rename, translate, unresolved };
package/mcp.js ADDED
@@ -0,0 +1,41 @@
1
+ import { Schema } from "effect";
2
+
3
+ //#region src/mcp.ts
4
+ /**
5
+ * A local MCP server the host launches. `${PLUGIN_ROOT}` is the one
6
+ * placeholder in `args`, `env` and `cwd`.
7
+ *
8
+ * @public
9
+ */
10
+ const StdioMcpServer = Schema.Struct({
11
+ type: Schema.optionalKey(Schema.Literal("stdio")),
12
+ command: Schema.String.check(Schema.isMinLength(1)),
13
+ args: Schema.optionalKey(Schema.Array(Schema.String)),
14
+ env: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),
15
+ cwd: Schema.optionalKey(Schema.String)
16
+ });
17
+ /**
18
+ * A remote MCP server the host connects to.
19
+ *
20
+ * @public
21
+ */
22
+ const RemoteMcpServer = Schema.Struct({
23
+ type: Schema.Literals(["http", "sse"]),
24
+ url: Schema.String.check(Schema.isPattern(/^https?:\/\//, { message: "must be an http or https URL" })),
25
+ headers: Schema.optionalKey(Schema.Record(Schema.String, Schema.String))
26
+ });
27
+ /**
28
+ * One MCP server, in Claude Code's `.mcp.json` server shape.
29
+ *
30
+ * @public
31
+ */
32
+ const McpServer = Schema.Union([StdioMcpServer, RemoteMcpServer]);
33
+ /**
34
+ * A plugin's MCP servers, keyed by server name.
35
+ *
36
+ * @public
37
+ */
38
+ const McpServers = Schema.Record(Schema.String, McpServer);
39
+
40
+ //#endregion
41
+ export { McpServer, McpServers, RemoteMcpServer, StdioMcpServer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluginfinity/core",
3
- "version": "0.0.1",
3
+ "version": "0.1.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": [
package/target.js ADDED
@@ -0,0 +1,193 @@
1
+ import { Schema } from "effect";
2
+
3
+ //#region src/target.ts
4
+ /**
5
+ * The forms a field can be moved into when a host lacks it. The engine owns
6
+ * one renderer per form.
7
+ *
8
+ * @public
9
+ */
10
+ const DEGRADE_FORMS = ["description-suffix", "body-section"];
11
+ /** @public */
12
+ const DegradeForm = Schema.Literals(DEGRADE_FORMS);
13
+ /**
14
+ * Manifest formats. The engine owns one encoder per format.
15
+ *
16
+ * @public
17
+ */
18
+ const MANIFEST_FORMATS = ["claude-plugin-json", "agent-plugins-1.0"];
19
+ /** @public */
20
+ const ManifestFormat = Schema.Literals(MANIFEST_FORMATS);
21
+ /**
22
+ * Hooks file formats. The engine owns one encoder per format.
23
+ *
24
+ * @public
25
+ */
26
+ const HOOKS_FORMATS = ["claude-hooks-json", "copilot-hooks-v1"];
27
+ /** @public */
28
+ const HooksFormat = Schema.Literals(HOOKS_FORMATS);
29
+ /**
30
+ * MCP config formats. The engine owns one encoder per format.
31
+ *
32
+ * @public
33
+ */
34
+ const MCP_FORMATS = ["claude-mcp-json", "agent-plugins-mcp-1.0"];
35
+ /** @public */
36
+ const McpFormat = Schema.Literals(MCP_FORMATS);
37
+ const NonEmpty = Schema.String.check(Schema.isMinLength(1));
38
+ /** Write the field unchanged. @public */
39
+ var Keep = class extends Schema.TaggedClass()("keep", {}) {};
40
+ /** Write the field under another name. @public */
41
+ var Rename = class extends Schema.TaggedClass()("rename", { to: NonEmpty }) {};
42
+ /**
43
+ * The tables a field's value can be translated through: `tools` for tool lists,
44
+ * `models` for a model name, `efforts` for an effort level.
45
+ *
46
+ * @public
47
+ */
48
+ const TranslateTable = Schema.Literals([
49
+ "tools",
50
+ "models",
51
+ "efforts"
52
+ ]);
53
+ /** Map the field's value through a named table, optionally writing it under another name. @public */
54
+ var Translate = class extends Schema.TaggedClass()("translate", {
55
+ table: TranslateTable,
56
+ to: Schema.optionalKey(NonEmpty)
57
+ }) {};
58
+ /** Move the field into a named form the engine renders. @public */
59
+ var Degrade = class extends Schema.TaggedClass()("degrade", { form: DegradeForm }) {};
60
+ /** Leave the field out; the host lacks it. @public */
61
+ var Drop = class extends Schema.TaggedClass()("drop", {}) {};
62
+ /**
63
+ * A fact the host documentation leaves open, with a note on what is unknown.
64
+ *
65
+ * @public
66
+ */
67
+ var Unresolved = class extends Schema.TaggedClass()("unresolved", { note: NonEmpty }) {};
68
+ /** A Claude Code event the target does not have. @public */
69
+ var Absent = class extends Schema.TaggedClass()("absent", {}) {};
70
+ /**
71
+ * What a target does with one frontmatter field.
72
+ *
73
+ * @public
74
+ */
75
+ const FieldMapEntry = Schema.Union([
76
+ Keep,
77
+ Rename,
78
+ Translate,
79
+ Degrade,
80
+ Drop,
81
+ Unresolved
82
+ ]);
83
+ /**
84
+ * How the plugin root is spelled at one site, or that the docs leave it open.
85
+ *
86
+ * @public
87
+ */
88
+ const RootSpelling = Schema.Union([Schema.String, Unresolved]);
89
+ /**
90
+ * A Claude Code event's name on a target, or that the target lacks it.
91
+ *
92
+ * @public
93
+ */
94
+ const EventMapping = Schema.Union([Schema.String, Absent]);
95
+ /**
96
+ * A Claude Code tool name's spelling on a target, `drop` to leave it out, or
97
+ * that the docs leave it open.
98
+ *
99
+ * @public
100
+ */
101
+ const ToolMapping = Schema.Union([
102
+ Schema.String,
103
+ Drop,
104
+ Unresolved
105
+ ]);
106
+ /**
107
+ * A Claude Code value's spelling on a target, in the `models` or `efforts`
108
+ * table: the target's value, `drop` to leave the field out, or `unresolved`
109
+ * when the target has no counterpart and the author must choose.
110
+ *
111
+ * @public
112
+ */
113
+ const ValueMapping = Schema.Union([
114
+ Schema.String,
115
+ Drop,
116
+ Unresolved
117
+ ]);
118
+ const FieldMap = Schema.Record(Schema.String, FieldMapEntry);
119
+ /**
120
+ * One host, described by what it can do.
121
+ *
122
+ * @remarks
123
+ * Build a description with `Target.make`, which validates it at construction,
124
+ * so a malformed host description fails when `@pluginfinity/targets` loads.
125
+ * Field maps are typed as string records here; `@pluginfinity/targets` checks
126
+ * their totality over `SKILL_FIELDS` and `AGENT_FIELDS` at compile time and in
127
+ * tests. A tool name absent from `tools.names`, or a value absent from `models`
128
+ * or `efforts`, passes through unchanged.
129
+ *
130
+ * @public
131
+ */
132
+ var Target = class extends Schema.Class("Target")({
133
+ manifest: Schema.Struct({
134
+ path: Schema.String,
135
+ format: ManifestFormat,
136
+ schema: Schema.optionalKey(Schema.String),
137
+ keys: Schema.Array(Schema.String)
138
+ }),
139
+ pluginRoot: Schema.Struct({
140
+ hooks: RootSpelling,
141
+ mcp: RootSpelling,
142
+ body: RootSpelling
143
+ }),
144
+ skills: Schema.Struct({
145
+ dir: Schema.String,
146
+ fields: FieldMap,
147
+ hostFields: Schema.Array(Schema.String)
148
+ }),
149
+ agents: Schema.Struct({
150
+ dir: Schema.String,
151
+ suffix: Schema.String,
152
+ fields: FieldMap,
153
+ hostFields: Schema.Array(Schema.String)
154
+ }),
155
+ hooks: Schema.Struct({
156
+ path: Schema.String,
157
+ format: HooksFormat,
158
+ events: Schema.Record(Schema.String, EventMapping),
159
+ ownEvents: Schema.Array(Schema.String)
160
+ }),
161
+ mcp: Schema.Struct({
162
+ path: Schema.String,
163
+ format: McpFormat,
164
+ schema: Schema.optionalKey(Schema.String)
165
+ }),
166
+ references: Schema.Struct({ style: Schema.Literals(["path", "prose"]) }),
167
+ tools: Schema.Struct({
168
+ names: Schema.Record(Schema.String, ToolMapping),
169
+ mcp: Schema.String
170
+ }),
171
+ models: Schema.Record(Schema.String, ValueMapping),
172
+ efforts: Schema.Record(Schema.String, ValueMapping)
173
+ }) {};
174
+ /** @public */
175
+ const keep = Keep.make({});
176
+ /** @public */
177
+ const drop = Drop.make({});
178
+ /** @public */
179
+ const absent = Absent.make({});
180
+ /** @public */
181
+ const rename = (to) => Rename.make({ to });
182
+ /** @public */
183
+ const translate = (table, to) => Translate.make(to === void 0 ? { table } : {
184
+ table,
185
+ to
186
+ });
187
+ /** @public */
188
+ const degrade = (form) => Degrade.make({ form });
189
+ /** @public */
190
+ const unresolved = (note) => Unresolved.make({ note });
191
+
192
+ //#endregion
193
+ export { Absent, DEGRADE_FORMS, Degrade, DegradeForm, Drop, EventMapping, FieldMapEntry, HOOKS_FORMATS, HooksFormat, Keep, MANIFEST_FORMATS, MCP_FORMATS, ManifestFormat, McpFormat, Rename, RootSpelling, Target, ToolMapping, Translate, TranslateTable, Unresolved, ValueMapping, absent, degrade, drop, keep, rename, translate, unresolved };
package/version.js CHANGED
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * @public
11
11
  */
12
- const CORE_VERSION = "0.0.1";
12
+ const CORE_VERSION = "0.1.0";
13
13
 
14
14
  //#endregion
15
15
  export { CORE_VERSION };