@pluginfinity/core 0.1.1 → 0.2.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 +23 -5
- package/index.d.ts +182 -9
- package/index.js +5 -4
- package/lsp.js +53 -0
- package/mcp.js +9 -2
- package/package.json +1 -1
- package/target.js +75 -8
- package/version.js +1 -1
package/config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Hooks } from "./hooks.js";
|
|
2
2
|
import { McpServers } from "./mcp.js";
|
|
3
|
+
import { LspServers } from "./lsp.js";
|
|
3
4
|
import { Schema } from "effect";
|
|
4
5
|
|
|
5
6
|
//#region src/config.ts
|
|
@@ -18,6 +19,18 @@ const PluginName = Schema.String.check(Schema.isPattern(/^[a-z0-9]+(?:-[a-z0-9]+
|
|
|
18
19
|
*/
|
|
19
20
|
const ScriptInvoke = Schema.Literals(["bash", "exec"]);
|
|
20
21
|
/**
|
|
22
|
+
* A plugin-relative path the build ships to every target: a file, or a
|
|
23
|
+
* directory ending in `/`.
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* The path must be canonical: relative, with no empty, `.` or `..` segment,
|
|
27
|
+
* and not the plugin root itself. It must not be or lie under `builds/` or
|
|
28
|
+
* `node_modules/`, so a build never ships its own output or dependencies.
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
const ShippedPath = Schema.String.check(Schema.isPattern(/^(?!(?:builds|node_modules)(?:\/|$))(?!\.\.?(?:\/|$))[^/]+(?:\/(?!\.\.?(?:\/|$))[^/]+)*\/?$/, { message: "must be a canonical relative path inside the plugin (no empty, . or .. segment), not under builds/ or node_modules/" }));
|
|
33
|
+
/**
|
|
21
34
|
* The plugin-wide fields of a pluginfinity config, before any target key.
|
|
22
35
|
*
|
|
23
36
|
* @remarks
|
|
@@ -46,7 +59,11 @@ const BaseConfigFields = {
|
|
|
46
59
|
/** Hooks keyed by Claude Code event names, generated per target. */
|
|
47
60
|
hooks: Schema.optionalKey(Hooks),
|
|
48
61
|
/** MCP servers in Claude Code's `.mcp.json` server shape. */
|
|
49
|
-
mcpServers: Schema.optionalKey(McpServers)
|
|
62
|
+
mcpServers: Schema.optionalKey(McpServers),
|
|
63
|
+
/** LSP servers in Claude Code's `.lsp.json` server shape. */
|
|
64
|
+
lspServers: Schema.optionalKey(LspServers),
|
|
65
|
+
/** Extra files and directories (ending in `/`) shipped to every target. */
|
|
66
|
+
files: Schema.optionalKey(Schema.Array(ShippedPath))
|
|
50
67
|
};
|
|
51
68
|
/**
|
|
52
69
|
* The names of the plugin-wide config fields.
|
|
@@ -61,8 +78,8 @@ const BASE_CONFIG_KEYS = Object.keys(BaseConfigFields);
|
|
|
61
78
|
* @remarks
|
|
62
79
|
* `hooks` is the target's own hooks schema, so each target admits the events
|
|
63
80
|
* it has: a hook under it replaces the base entries for that event on that
|
|
64
|
-
* target, and `[]` removes them. A server under `mcpServers`
|
|
65
|
-
* server of that name.
|
|
81
|
+
* target, and `[]` removes them. A server under `mcpServers` or `lspServers`
|
|
82
|
+
* replaces the base server of that name.
|
|
66
83
|
*
|
|
67
84
|
* @public
|
|
68
85
|
*/
|
|
@@ -70,8 +87,9 @@ const makeTargetSetting = (hooks) => Schema.Union([Schema.Literal(true), Schema.
|
|
|
70
87
|
/** The plugin's name on this host, when it differs from the base `name`. */
|
|
71
88
|
name: Schema.optionalKey(PluginName),
|
|
72
89
|
hooks: Schema.optionalKey(hooks),
|
|
73
|
-
mcpServers: Schema.optionalKey(McpServers)
|
|
90
|
+
mcpServers: Schema.optionalKey(McpServers),
|
|
91
|
+
lspServers: Schema.optionalKey(LspServers)
|
|
74
92
|
})]);
|
|
75
93
|
|
|
76
94
|
//#endregion
|
|
77
|
-
export { BASE_CONFIG_KEYS, BaseConfigFields, PluginName, ScriptInvoke, makeTargetSetting };
|
|
95
|
+
export { BASE_CONFIG_KEYS, BaseConfigFields, PluginName, ScriptInvoke, ShippedPath, makeTargetSetting };
|
package/index.d.ts
CHANGED
|
@@ -130,6 +130,18 @@ export declare const PluginName: Schema.String;
|
|
|
130
130
|
* @public
|
|
131
131
|
*/
|
|
132
132
|
export declare const ScriptInvoke: Schema.Literals<readonly ["bash", "exec"]>;
|
|
133
|
+
/**
|
|
134
|
+
* A plugin-relative path the build ships to every target: a file, or a
|
|
135
|
+
* directory ending in `/`.
|
|
136
|
+
*
|
|
137
|
+
* @remarks
|
|
138
|
+
* The path must be canonical: relative, with no empty, `.` or `..` segment,
|
|
139
|
+
* and not the plugin root itself. It must not be or lie under `builds/` or
|
|
140
|
+
* `node_modules/`, so a build never ships its own output or dependencies.
|
|
141
|
+
*
|
|
142
|
+
* @public
|
|
143
|
+
*/
|
|
144
|
+
export declare const ShippedPath: Schema.String;
|
|
133
145
|
/**
|
|
134
146
|
* The plugin-wide fields of a pluginfinity config, before any target key.
|
|
135
147
|
*
|
|
@@ -172,6 +184,23 @@ export declare const BaseConfigFields: {
|
|
|
172
184
|
readonly url: Schema.String;
|
|
173
185
|
readonly headers: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
174
186
|
}>]>>>;
|
|
187
|
+
/** LSP servers in Claude Code's `.lsp.json` server shape. */
|
|
188
|
+
readonly lspServers: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Struct<{
|
|
189
|
+
readonly command: Schema.String;
|
|
190
|
+
readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
191
|
+
readonly env: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
192
|
+
readonly extensionToLanguage: Schema.$Record<Schema.String, Schema.String>;
|
|
193
|
+
readonly initializationOptions: Schema.optionalKey<Schema.Unknown>;
|
|
194
|
+
readonly settings: Schema.optionalKey<Schema.Unknown>;
|
|
195
|
+
readonly workspaceFolder: Schema.optionalKey<Schema.String>;
|
|
196
|
+
readonly startupTimeout: Schema.optionalKey<Schema.Number>;
|
|
197
|
+
readonly shutdownTimeout: Schema.optionalKey<Schema.Number>;
|
|
198
|
+
readonly restartOnCrash: Schema.optionalKey<Schema.Boolean>;
|
|
199
|
+
readonly maxRestarts: Schema.optionalKey<Schema.Number>;
|
|
200
|
+
readonly diagnostics: Schema.optionalKey<Schema.Boolean>;
|
|
201
|
+
}>>>;
|
|
202
|
+
/** Extra files and directories (ending in `/`) shipped to every target. */
|
|
203
|
+
readonly files: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
175
204
|
};
|
|
176
205
|
/**
|
|
177
206
|
* The names of the plugin-wide config fields.
|
|
@@ -186,8 +215,8 @@ export declare const BASE_CONFIG_KEYS: ReadonlyArray<string>;
|
|
|
186
215
|
* @remarks
|
|
187
216
|
* `hooks` is the target's own hooks schema, so each target admits the events
|
|
188
217
|
* it has: a hook under it replaces the base entries for that event on that
|
|
189
|
-
* target, and `[]` removes them. A server under `mcpServers`
|
|
190
|
-
* server of that name.
|
|
218
|
+
* target, and `[]` removes them. A server under `mcpServers` or `lspServers`
|
|
219
|
+
* replaces the base server of that name.
|
|
191
220
|
*
|
|
192
221
|
* @public
|
|
193
222
|
*/
|
|
@@ -206,6 +235,20 @@ export declare const makeTargetSetting: <H extends Schema.Top>(hooks: H) => Sche
|
|
|
206
235
|
readonly url: Schema.String;
|
|
207
236
|
readonly headers: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
208
237
|
}>]>>>;
|
|
238
|
+
readonly lspServers: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Struct<{
|
|
239
|
+
readonly command: Schema.String;
|
|
240
|
+
readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
241
|
+
readonly env: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
242
|
+
readonly extensionToLanguage: Schema.$Record<Schema.String, Schema.String>;
|
|
243
|
+
readonly initializationOptions: Schema.optionalKey<Schema.Unknown>;
|
|
244
|
+
readonly settings: Schema.optionalKey<Schema.Unknown>;
|
|
245
|
+
readonly workspaceFolder: Schema.optionalKey<Schema.String>;
|
|
246
|
+
readonly startupTimeout: Schema.optionalKey<Schema.Number>;
|
|
247
|
+
readonly shutdownTimeout: Schema.optionalKey<Schema.Number>;
|
|
248
|
+
readonly restartOnCrash: Schema.optionalKey<Schema.Boolean>;
|
|
249
|
+
readonly maxRestarts: Schema.optionalKey<Schema.Number>;
|
|
250
|
+
readonly diagnostics: Schema.optionalKey<Schema.Boolean>;
|
|
251
|
+
}>>>;
|
|
209
252
|
}>]>;
|
|
210
253
|
//#endregion
|
|
211
254
|
//#region src/frontmatter.d.ts
|
|
@@ -305,7 +348,67 @@ export declare const SKILL_FIELDS: ReadonlyArray<SkillField>;
|
|
|
305
348
|
*/
|
|
306
349
|
export declare const AGENT_FIELDS: ReadonlyArray<AgentField>;
|
|
307
350
|
//#endregion
|
|
351
|
+
//#region src/lsp.d.ts
|
|
352
|
+
/**
|
|
353
|
+
* One LSP server, in Claude Code's `.lsp.json` server shape. `${PLUGIN_ROOT}`
|
|
354
|
+
* is the one placeholder in `command`, `args`, `env` and `workspaceFolder`.
|
|
355
|
+
*
|
|
356
|
+
* @public
|
|
357
|
+
*/
|
|
358
|
+
export declare const LspServer: Schema.Struct<{
|
|
359
|
+
readonly command: Schema.String;
|
|
360
|
+
readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
361
|
+
readonly env: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
362
|
+
readonly extensionToLanguage: Schema.$Record<Schema.String, Schema.String>;
|
|
363
|
+
readonly initializationOptions: Schema.optionalKey<Schema.Unknown>;
|
|
364
|
+
readonly settings: Schema.optionalKey<Schema.Unknown>;
|
|
365
|
+
readonly workspaceFolder: Schema.optionalKey<Schema.String>;
|
|
366
|
+
readonly startupTimeout: Schema.optionalKey<Schema.Number>;
|
|
367
|
+
readonly shutdownTimeout: Schema.optionalKey<Schema.Number>;
|
|
368
|
+
readonly restartOnCrash: Schema.optionalKey<Schema.Boolean>;
|
|
369
|
+
readonly maxRestarts: Schema.optionalKey<Schema.Number>;
|
|
370
|
+
readonly diagnostics: Schema.optionalKey<Schema.Boolean>;
|
|
371
|
+
}>;
|
|
372
|
+
/**
|
|
373
|
+
* A plugin's LSP servers, keyed by server name.
|
|
374
|
+
*
|
|
375
|
+
* @public
|
|
376
|
+
*/
|
|
377
|
+
export declare const LspServers: Schema.$Record<Schema.String, Schema.Struct<{
|
|
378
|
+
readonly command: Schema.String;
|
|
379
|
+
readonly args: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
380
|
+
readonly env: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
381
|
+
readonly extensionToLanguage: Schema.$Record<Schema.String, Schema.String>;
|
|
382
|
+
readonly initializationOptions: Schema.optionalKey<Schema.Unknown>;
|
|
383
|
+
readonly settings: Schema.optionalKey<Schema.Unknown>;
|
|
384
|
+
readonly workspaceFolder: Schema.optionalKey<Schema.String>;
|
|
385
|
+
readonly startupTimeout: Schema.optionalKey<Schema.Number>;
|
|
386
|
+
readonly shutdownTimeout: Schema.optionalKey<Schema.Number>;
|
|
387
|
+
readonly restartOnCrash: Schema.optionalKey<Schema.Boolean>;
|
|
388
|
+
readonly maxRestarts: Schema.optionalKey<Schema.Number>;
|
|
389
|
+
readonly diagnostics: Schema.optionalKey<Schema.Boolean>;
|
|
390
|
+
}>>;
|
|
391
|
+
/**
|
|
392
|
+
* Every LSP server field, so each target's LSP field map can be checked for totality.
|
|
393
|
+
*
|
|
394
|
+
* @public
|
|
395
|
+
*/
|
|
396
|
+
export declare const LSP_FIELDS: readonly ["command", "args", "env", "extensionToLanguage", "initializationOptions", "settings", "workspaceFolder", "startupTimeout", "shutdownTimeout", "restartOnCrash", "maxRestarts", "diagnostics"];
|
|
397
|
+
/**
|
|
398
|
+
* One field name of an LSP server.
|
|
399
|
+
*
|
|
400
|
+
* @public
|
|
401
|
+
*/
|
|
402
|
+
type LspField = (typeof LSP_FIELDS)[number];
|
|
403
|
+
//#endregion
|
|
308
404
|
//#region src/mcp.d.ts
|
|
405
|
+
/**
|
|
406
|
+
* A server's environment. `PLUGINFINITY_` keys are reserved for the
|
|
407
|
+
* variables the build injects.
|
|
408
|
+
*
|
|
409
|
+
* @public
|
|
410
|
+
*/
|
|
411
|
+
export declare const ServerEnv: Schema.$Record<Schema.String, Schema.String>;
|
|
309
412
|
/**
|
|
310
413
|
* A local MCP server the host launches. `${PLUGIN_ROOT}` is the one
|
|
311
414
|
* placeholder in `args`, `env` and `cwd`.
|
|
@@ -391,13 +494,54 @@ export declare const HOOKS_FORMATS: readonly ["claude-hooks-json", "copilot-hook
|
|
|
391
494
|
/** @public */
|
|
392
495
|
export declare const HooksFormat: Schema.Literals<readonly ["claude-hooks-json", "copilot-hooks-v1"]>;
|
|
393
496
|
/**
|
|
394
|
-
* MCP config formats. The engine owns one encoder per format
|
|
497
|
+
* MCP config formats. The engine owns one encoder per format:
|
|
498
|
+
* `claude-mcp-servers` is the bare server map Claude Code reads under a
|
|
499
|
+
* manifest's `mcpServers` key, and `agent-plugins-mcp-1.0` is the Agent
|
|
500
|
+
* Plugins `mcp.json` envelope, `$schema` and an `mcpServers` map.
|
|
501
|
+
*
|
|
502
|
+
* @public
|
|
503
|
+
*/
|
|
504
|
+
export declare const MCP_FORMATS: readonly ["claude-mcp-servers", "agent-plugins-mcp-1.0"];
|
|
505
|
+
/** @public */
|
|
506
|
+
export declare const McpFormat: Schema.Literals<readonly ["claude-mcp-servers", "agent-plugins-mcp-1.0"]>;
|
|
507
|
+
/**
|
|
508
|
+
* LSP config formats. The engine owns one encoder per format:
|
|
509
|
+
* `claude-lsp-servers` is the bare server map Claude Code reads under a
|
|
510
|
+
* manifest's `lspServers` key, and `copilot-lsp-json` is Copilot's
|
|
511
|
+
* `{ "lspServers": … }` file.
|
|
512
|
+
*
|
|
513
|
+
* @public
|
|
514
|
+
*/
|
|
515
|
+
export declare const LSP_FORMATS: readonly ["claude-lsp-servers", "copilot-lsp-json"];
|
|
516
|
+
/** @public */
|
|
517
|
+
export declare const LspFormat: Schema.Literals<readonly ["claude-lsp-servers", "copilot-lsp-json"]>;
|
|
518
|
+
declare const InFile_base: Schema.Class<InFile, Schema.TaggedStruct<"file", {
|
|
519
|
+
readonly path: Schema.String;
|
|
520
|
+
}>, {}>;
|
|
521
|
+
/** Write a target's servers to a file of their own, at a plugin-relative path. @public */
|
|
522
|
+
export declare class InFile extends InFile_base {}
|
|
523
|
+
declare const InManifest_base: Schema.Class<InManifest, Schema.TaggedStruct<"manifest", {
|
|
524
|
+
readonly key: Schema.String;
|
|
525
|
+
readonly reserves: Schema.String;
|
|
526
|
+
}>, {}>;
|
|
527
|
+
/**
|
|
528
|
+
* Write a target's servers inline in its manifest, under a key the manifest's
|
|
529
|
+
* allowlist admits. `reserves` is the plugin-relative file the host also loads
|
|
530
|
+
* servers from by default, such as Claude Code's `.mcp.json`; no file may ship
|
|
531
|
+
* there, since the host would load it beside the inline servers.
|
|
532
|
+
*
|
|
533
|
+
* @public
|
|
534
|
+
*/
|
|
535
|
+
export declare class InManifest extends InManifest_base {}
|
|
536
|
+
/**
|
|
537
|
+
* Where a target writes its MCP or LSP servers: a file of their own, or inline
|
|
538
|
+
* in the manifest.
|
|
395
539
|
*
|
|
396
540
|
* @public
|
|
397
541
|
*/
|
|
398
|
-
export declare const
|
|
542
|
+
export declare const ServerPlacement: Schema.Union<readonly [typeof InFile, typeof InManifest]>;
|
|
399
543
|
/** @public */
|
|
400
|
-
export
|
|
544
|
+
export type ServerPlacement = typeof ServerPlacement.Type;
|
|
401
545
|
declare const Keep_base: Schema.Class<Keep, Schema.TaggedStruct<"keep", {}>, {}>;
|
|
402
546
|
/** Write the field unchanged. @public */
|
|
403
547
|
export declare class Keep extends Keep_base {}
|
|
@@ -484,18 +628,26 @@ declare const Target_base: Schema.Class<Target, Schema.Struct<{
|
|
|
484
628
|
readonly pluginRoot: Schema.Struct<{
|
|
485
629
|
readonly hooks: Schema.Union<readonly [Schema.String, typeof Unresolved]>;
|
|
486
630
|
readonly mcp: Schema.Union<readonly [Schema.String, typeof Unresolved]>;
|
|
631
|
+
readonly lsp: Schema.Union<readonly [Schema.String, typeof Unresolved]>;
|
|
487
632
|
readonly body: Schema.Union<readonly [Schema.String, typeof Unresolved]>;
|
|
488
633
|
}>;
|
|
489
634
|
readonly skills: Schema.Struct<{
|
|
490
635
|
readonly dir: Schema.String;
|
|
491
636
|
readonly fields: Schema.$Record<Schema.String, Schema.Union<readonly [typeof Keep, typeof Rename, typeof Translate, typeof Degrade, typeof Drop, typeof Unresolved]>>;
|
|
492
637
|
readonly hostFields: Schema.$Array<Schema.String>;
|
|
638
|
+
/**
|
|
639
|
+
* How a user invokes a plugin skill: a template with `{plugin}` and `{skill}`,
|
|
640
|
+
* or `unresolved` when the host has no such command.
|
|
641
|
+
*/
|
|
642
|
+
readonly invoke: Schema.Union<readonly [Schema.String, typeof Unresolved]>;
|
|
493
643
|
}>;
|
|
494
644
|
readonly agents: Schema.Struct<{
|
|
495
645
|
readonly dir: Schema.String;
|
|
496
646
|
readonly suffix: Schema.String;
|
|
497
647
|
readonly fields: Schema.$Record<Schema.String, Schema.Union<readonly [typeof Keep, typeof Rename, typeof Translate, typeof Degrade, typeof Drop, typeof Unresolved]>>;
|
|
498
648
|
readonly hostFields: Schema.$Array<Schema.String>;
|
|
649
|
+
/** A plugin agent's run-time id: a template with `{plugin}` and `{agent}`. */
|
|
650
|
+
readonly id: Schema.String;
|
|
499
651
|
}>;
|
|
500
652
|
readonly hooks: Schema.Struct<{
|
|
501
653
|
readonly path: Schema.String;
|
|
@@ -504,10 +656,15 @@ declare const Target_base: Schema.Class<Target, Schema.Struct<{
|
|
|
504
656
|
readonly ownEvents: Schema.$Array<Schema.String>;
|
|
505
657
|
}>;
|
|
506
658
|
readonly mcp: Schema.Struct<{
|
|
507
|
-
readonly
|
|
508
|
-
readonly format: Schema.Literals<readonly ["claude-mcp-
|
|
659
|
+
readonly placement: Schema.Union<readonly [typeof InFile, typeof InManifest]>;
|
|
660
|
+
readonly format: Schema.Literals<readonly ["claude-mcp-servers", "agent-plugins-mcp-1.0"]>;
|
|
509
661
|
readonly schema: Schema.optionalKey<Schema.String>;
|
|
510
662
|
}>;
|
|
663
|
+
readonly lsp: Schema.Struct<{
|
|
664
|
+
readonly placement: Schema.Union<readonly [typeof InFile, typeof InManifest]>;
|
|
665
|
+
readonly format: Schema.Literals<readonly ["claude-lsp-servers", "copilot-lsp-json"]>;
|
|
666
|
+
readonly fields: Schema.$Record<Schema.String, Schema.Union<readonly [typeof Keep, typeof Rename, typeof Translate, typeof Degrade, typeof Drop, typeof Unresolved]>>;
|
|
667
|
+
}>;
|
|
511
668
|
readonly references: Schema.Struct<{
|
|
512
669
|
readonly style: Schema.Literals<readonly ["path", "prose"]>;
|
|
513
670
|
}>;
|
|
@@ -520,6 +677,18 @@ declare const Target_base: Schema.Class<Target, Schema.Struct<{
|
|
|
520
677
|
* leaves it out, for a host that has no such tool.
|
|
521
678
|
*/
|
|
522
679
|
readonly unlisted: Schema.Literals<readonly ["keep", "drop"]>;
|
|
680
|
+
/**
|
|
681
|
+
* The tool names the host shows a model at run time, which a skill or agent
|
|
682
|
+
* body can name. `names` maps a Claude Code tool name to its run-time
|
|
683
|
+
* spelling (or `unresolved`); `mcp` is the template for a plugin MCP tool
|
|
684
|
+
* (`{plugin}`, `{server}`, `{tool}`); `unlisted` says whether a name absent
|
|
685
|
+
* from `names` is `keep`-kept as written or `unresolved`.
|
|
686
|
+
*/
|
|
687
|
+
readonly runtime: Schema.Struct<{
|
|
688
|
+
readonly names: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, typeof Unresolved]>>;
|
|
689
|
+
readonly mcp: Schema.String;
|
|
690
|
+
readonly unlisted: Schema.Literals<readonly ["keep", "unresolved"]>;
|
|
691
|
+
}>;
|
|
523
692
|
}>;
|
|
524
693
|
readonly models: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, typeof Drop, typeof Unresolved]>>;
|
|
525
694
|
readonly efforts: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, typeof Drop, typeof Unresolved]>>;
|
|
@@ -531,7 +700,7 @@ declare const Target_base: Schema.Class<Target, Schema.Struct<{
|
|
|
531
700
|
* Build a description with `Target.make`, which validates it at construction,
|
|
532
701
|
* so a malformed host description fails when `@pluginfinity/targets` loads.
|
|
533
702
|
* Field maps are typed as string records here; `@pluginfinity/targets` checks
|
|
534
|
-
* their totality over `SKILL_FIELDS` and `
|
|
703
|
+
* their totality over `SKILL_FIELDS`, `AGENT_FIELDS` and `LSP_FIELDS` at compile time and in
|
|
535
704
|
* tests. A tool name absent from `tools.names` follows `tools.unlisted`; a value
|
|
536
705
|
* absent from `models` or `efforts` passes through unchanged.
|
|
537
706
|
*
|
|
@@ -539,6 +708,10 @@ declare const Target_base: Schema.Class<Target, Schema.Struct<{
|
|
|
539
708
|
*/
|
|
540
709
|
export declare class Target extends Target_base {}
|
|
541
710
|
/** @public */
|
|
711
|
+
export declare const inFile: (path: string) => InFile;
|
|
712
|
+
/** @public */
|
|
713
|
+
export declare const inManifest: (key: string, reserves: string) => InManifest;
|
|
714
|
+
/** @public */
|
|
542
715
|
export declare const keep: Keep;
|
|
543
716
|
/** @public */
|
|
544
717
|
export declare const drop: Drop;
|
|
@@ -566,5 +739,5 @@ export declare const unresolved: (note: string) => Unresolved;
|
|
|
566
739
|
*/
|
|
567
740
|
export declare const CORE_VERSION: string;
|
|
568
741
|
//#endregion
|
|
569
|
-
export type { AgentField, DegradeForm, HooksFields, SkillField };
|
|
742
|
+
export type { AgentField, DegradeForm, HooksFields, LspField, SkillField };
|
|
570
743
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
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 {
|
|
2
|
+
import { McpServer, McpServers, RemoteMcpServer, ServerEnv, StdioMcpServer } from "./mcp.js";
|
|
3
|
+
import { LSP_FIELDS, LspServer, LspServers } from "./lsp.js";
|
|
4
|
+
import { BASE_CONFIG_KEYS, BaseConfigFields, PluginName, ScriptInvoke, ShippedPath, makeTargetSetting } from "./config.js";
|
|
4
5
|
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";
|
|
6
|
+
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";
|
|
6
7
|
import { CORE_VERSION } from "./version.js";
|
|
7
8
|
|
|
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 };
|
|
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 };
|
package/lsp.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ServerEnv } from "./mcp.js";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
|
|
4
|
+
//#region src/lsp.ts
|
|
5
|
+
const NonNegativeInt = Schema.Number.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0));
|
|
6
|
+
/**
|
|
7
|
+
* One LSP server, in Claude Code's `.lsp.json` server shape. `${PLUGIN_ROOT}`
|
|
8
|
+
* is the one placeholder in `command`, `args`, `env` and `workspaceFolder`.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
const LspServer = Schema.Struct({
|
|
13
|
+
command: Schema.String.check(Schema.isMinLength(1)),
|
|
14
|
+
args: Schema.optionalKey(Schema.Array(Schema.String)),
|
|
15
|
+
env: Schema.optionalKey(ServerEnv),
|
|
16
|
+
extensionToLanguage: Schema.Record(Schema.String.check(Schema.isPattern(/^\.[^./]+/, { message: "must start with a dot, like .ts" })), Schema.String.check(Schema.isMinLength(1))),
|
|
17
|
+
initializationOptions: Schema.optionalKey(Schema.Unknown),
|
|
18
|
+
settings: Schema.optionalKey(Schema.Unknown),
|
|
19
|
+
workspaceFolder: Schema.optionalKey(Schema.String),
|
|
20
|
+
startupTimeout: Schema.optionalKey(NonNegativeInt),
|
|
21
|
+
shutdownTimeout: Schema.optionalKey(NonNegativeInt),
|
|
22
|
+
restartOnCrash: Schema.optionalKey(Schema.Boolean),
|
|
23
|
+
maxRestarts: Schema.optionalKey(NonNegativeInt),
|
|
24
|
+
diagnostics: Schema.optionalKey(Schema.Boolean)
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* A plugin's LSP servers, keyed by server name.
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
const LspServers = Schema.Record(Schema.String, LspServer);
|
|
32
|
+
/**
|
|
33
|
+
* Every LSP server field, so each target's LSP field map can be checked for totality.
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
const LSP_FIELDS = [
|
|
38
|
+
"command",
|
|
39
|
+
"args",
|
|
40
|
+
"env",
|
|
41
|
+
"extensionToLanguage",
|
|
42
|
+
"initializationOptions",
|
|
43
|
+
"settings",
|
|
44
|
+
"workspaceFolder",
|
|
45
|
+
"startupTimeout",
|
|
46
|
+
"shutdownTimeout",
|
|
47
|
+
"restartOnCrash",
|
|
48
|
+
"maxRestarts",
|
|
49
|
+
"diagnostics"
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
export { LSP_FIELDS, LspServer, LspServers };
|
package/mcp.js
CHANGED
|
@@ -2,6 +2,13 @@ import { Schema } from "effect";
|
|
|
2
2
|
|
|
3
3
|
//#region src/mcp.ts
|
|
4
4
|
/**
|
|
5
|
+
* A server's environment. `PLUGINFINITY_` keys are reserved for the
|
|
6
|
+
* variables the build injects.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
const ServerEnv = Schema.Record(Schema.String.check(Schema.isPattern(/^(?!PLUGINFINITY_)/, { message: "PLUGINFINITY_ env keys are reserved for the build" })), Schema.String);
|
|
11
|
+
/**
|
|
5
12
|
* A local MCP server the host launches. `${PLUGIN_ROOT}` is the one
|
|
6
13
|
* placeholder in `args`, `env` and `cwd`.
|
|
7
14
|
*
|
|
@@ -11,7 +18,7 @@ const StdioMcpServer = Schema.Struct({
|
|
|
11
18
|
type: Schema.optionalKey(Schema.Literal("stdio")),
|
|
12
19
|
command: Schema.String.check(Schema.isMinLength(1)),
|
|
13
20
|
args: Schema.optionalKey(Schema.Array(Schema.String)),
|
|
14
|
-
env: Schema.optionalKey(
|
|
21
|
+
env: Schema.optionalKey(ServerEnv),
|
|
15
22
|
cwd: Schema.optionalKey(Schema.String)
|
|
16
23
|
});
|
|
17
24
|
/**
|
|
@@ -38,4 +45,4 @@ const McpServer = Schema.Union([StdioMcpServer, RemoteMcpServer]);
|
|
|
38
45
|
const McpServers = Schema.Record(Schema.String, McpServer);
|
|
39
46
|
|
|
40
47
|
//#endregion
|
|
41
|
-
export { McpServer, McpServers, RemoteMcpServer, StdioMcpServer };
|
|
48
|
+
export { McpServer, McpServers, RemoteMcpServer, ServerEnv, StdioMcpServer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluginfinity/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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": [
|
package/target.js
CHANGED
|
@@ -27,14 +27,49 @@ const HOOKS_FORMATS = ["claude-hooks-json", "copilot-hooks-v1"];
|
|
|
27
27
|
/** @public */
|
|
28
28
|
const HooksFormat = Schema.Literals(HOOKS_FORMATS);
|
|
29
29
|
/**
|
|
30
|
-
* MCP config formats. The engine owns one encoder per format
|
|
30
|
+
* MCP config formats. The engine owns one encoder per format:
|
|
31
|
+
* `claude-mcp-servers` is the bare server map Claude Code reads under a
|
|
32
|
+
* manifest's `mcpServers` key, and `agent-plugins-mcp-1.0` is the Agent
|
|
33
|
+
* Plugins `mcp.json` envelope, `$schema` and an `mcpServers` map.
|
|
31
34
|
*
|
|
32
35
|
* @public
|
|
33
36
|
*/
|
|
34
|
-
const MCP_FORMATS = ["claude-mcp-
|
|
37
|
+
const MCP_FORMATS = ["claude-mcp-servers", "agent-plugins-mcp-1.0"];
|
|
35
38
|
/** @public */
|
|
36
39
|
const McpFormat = Schema.Literals(MCP_FORMATS);
|
|
40
|
+
/**
|
|
41
|
+
* LSP config formats. The engine owns one encoder per format:
|
|
42
|
+
* `claude-lsp-servers` is the bare server map Claude Code reads under a
|
|
43
|
+
* manifest's `lspServers` key, and `copilot-lsp-json` is Copilot's
|
|
44
|
+
* `{ "lspServers": … }` file.
|
|
45
|
+
*
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
const LSP_FORMATS = ["claude-lsp-servers", "copilot-lsp-json"];
|
|
49
|
+
/** @public */
|
|
50
|
+
const LspFormat = Schema.Literals(LSP_FORMATS);
|
|
37
51
|
const NonEmpty = Schema.String.check(Schema.isMinLength(1));
|
|
52
|
+
/** Write a target's servers to a file of their own, at a plugin-relative path. @public */
|
|
53
|
+
var InFile = class extends Schema.TaggedClass()("file", { path: NonEmpty }) {};
|
|
54
|
+
/**
|
|
55
|
+
* Write a target's servers inline in its manifest, under a key the manifest's
|
|
56
|
+
* allowlist admits. `reserves` is the plugin-relative file the host also loads
|
|
57
|
+
* servers from by default, such as Claude Code's `.mcp.json`; no file may ship
|
|
58
|
+
* there, since the host would load it beside the inline servers.
|
|
59
|
+
*
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
var InManifest = class extends Schema.TaggedClass()("manifest", {
|
|
63
|
+
key: NonEmpty,
|
|
64
|
+
reserves: NonEmpty
|
|
65
|
+
}) {};
|
|
66
|
+
/**
|
|
67
|
+
* Where a target writes its MCP or LSP servers: a file of their own, or inline
|
|
68
|
+
* in the manifest.
|
|
69
|
+
*
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
const ServerPlacement = Schema.Union([InFile, InManifest]);
|
|
38
73
|
/** Write the field unchanged. @public */
|
|
39
74
|
var Keep = class extends Schema.TaggedClass()("keep", {}) {};
|
|
40
75
|
/** Write the field under another name. @public */
|
|
@@ -123,7 +158,7 @@ const FieldMap = Schema.Record(Schema.String, FieldMapEntry);
|
|
|
123
158
|
* Build a description with `Target.make`, which validates it at construction,
|
|
124
159
|
* so a malformed host description fails when `@pluginfinity/targets` loads.
|
|
125
160
|
* Field maps are typed as string records here; `@pluginfinity/targets` checks
|
|
126
|
-
* their totality over `SKILL_FIELDS` and `
|
|
161
|
+
* their totality over `SKILL_FIELDS`, `AGENT_FIELDS` and `LSP_FIELDS` at compile time and in
|
|
127
162
|
* tests. A tool name absent from `tools.names` follows `tools.unlisted`; a value
|
|
128
163
|
* absent from `models` or `efforts` passes through unchanged.
|
|
129
164
|
*
|
|
@@ -139,18 +174,26 @@ var Target = class extends Schema.Class("Target")({
|
|
|
139
174
|
pluginRoot: Schema.Struct({
|
|
140
175
|
hooks: RootSpelling,
|
|
141
176
|
mcp: RootSpelling,
|
|
177
|
+
lsp: RootSpelling,
|
|
142
178
|
body: RootSpelling
|
|
143
179
|
}),
|
|
144
180
|
skills: Schema.Struct({
|
|
145
181
|
dir: Schema.String,
|
|
146
182
|
fields: FieldMap,
|
|
147
|
-
hostFields: Schema.Array(Schema.String)
|
|
183
|
+
hostFields: Schema.Array(Schema.String),
|
|
184
|
+
/**
|
|
185
|
+
* How a user invokes a plugin skill: a template with `{plugin}` and `{skill}`,
|
|
186
|
+
* or `unresolved` when the host has no such command.
|
|
187
|
+
*/
|
|
188
|
+
invoke: Schema.Union([Schema.String, Unresolved])
|
|
148
189
|
}),
|
|
149
190
|
agents: Schema.Struct({
|
|
150
191
|
dir: Schema.String,
|
|
151
192
|
suffix: Schema.String,
|
|
152
193
|
fields: FieldMap,
|
|
153
|
-
hostFields: Schema.Array(Schema.String)
|
|
194
|
+
hostFields: Schema.Array(Schema.String),
|
|
195
|
+
/** A plugin agent's run-time id: a template with `{plugin}` and `{agent}`. */
|
|
196
|
+
id: Schema.String
|
|
154
197
|
}),
|
|
155
198
|
hooks: Schema.Struct({
|
|
156
199
|
path: Schema.String,
|
|
@@ -159,10 +202,15 @@ var Target = class extends Schema.Class("Target")({
|
|
|
159
202
|
ownEvents: Schema.Array(Schema.String)
|
|
160
203
|
}),
|
|
161
204
|
mcp: Schema.Struct({
|
|
162
|
-
|
|
205
|
+
placement: ServerPlacement,
|
|
163
206
|
format: McpFormat,
|
|
164
207
|
schema: Schema.optionalKey(Schema.String)
|
|
165
208
|
}),
|
|
209
|
+
lsp: Schema.Struct({
|
|
210
|
+
placement: ServerPlacement,
|
|
211
|
+
format: LspFormat,
|
|
212
|
+
fields: FieldMap
|
|
213
|
+
}),
|
|
166
214
|
references: Schema.Struct({ style: Schema.Literals(["path", "prose"]) }),
|
|
167
215
|
tools: Schema.Struct({
|
|
168
216
|
names: Schema.Record(Schema.String, ToolMapping),
|
|
@@ -172,12 +220,31 @@ var Target = class extends Schema.Class("Target")({
|
|
|
172
220
|
* Claude MCP name the target can spell: `keep` writes it unchanged, `drop`
|
|
173
221
|
* leaves it out, for a host that has no such tool.
|
|
174
222
|
*/
|
|
175
|
-
unlisted: Schema.Literals(["keep", "drop"])
|
|
223
|
+
unlisted: Schema.Literals(["keep", "drop"]),
|
|
224
|
+
/**
|
|
225
|
+
* The tool names the host shows a model at run time, which a skill or agent
|
|
226
|
+
* body can name. `names` maps a Claude Code tool name to its run-time
|
|
227
|
+
* spelling (or `unresolved`); `mcp` is the template for a plugin MCP tool
|
|
228
|
+
* (`{plugin}`, `{server}`, `{tool}`); `unlisted` says whether a name absent
|
|
229
|
+
* from `names` is `keep`-kept as written or `unresolved`.
|
|
230
|
+
*/
|
|
231
|
+
runtime: Schema.Struct({
|
|
232
|
+
names: Schema.Record(Schema.String, Schema.Union([Schema.String, Unresolved])),
|
|
233
|
+
mcp: Schema.String,
|
|
234
|
+
unlisted: Schema.Literals(["keep", "unresolved"])
|
|
235
|
+
})
|
|
176
236
|
}),
|
|
177
237
|
models: Schema.Record(Schema.String, ValueMapping),
|
|
178
238
|
efforts: Schema.Record(Schema.String, ValueMapping)
|
|
179
239
|
}) {};
|
|
180
240
|
/** @public */
|
|
241
|
+
const inFile = (path) => InFile.make({ path });
|
|
242
|
+
/** @public */
|
|
243
|
+
const inManifest = (key, reserves) => InManifest.make({
|
|
244
|
+
key,
|
|
245
|
+
reserves
|
|
246
|
+
});
|
|
247
|
+
/** @public */
|
|
181
248
|
const keep = Keep.make({});
|
|
182
249
|
/** @public */
|
|
183
250
|
const drop = Drop.make({});
|
|
@@ -196,4 +263,4 @@ const degrade = (form) => Degrade.make({ form });
|
|
|
196
263
|
const unresolved = (note) => Unresolved.make({ note });
|
|
197
264
|
|
|
198
265
|
//#endregion
|
|
199
|
-
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 };
|
|
266
|
+
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 };
|