@pluginfinity/core 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config.js +23 -5
- package/index.d.ts +140 -4
- package/index.js +5 -4
- package/lsp.js +53 -0
- package/mcp.js +9 -2
- package/package.json +1 -1
- package/target.js +38 -5
- 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`.
|
|
@@ -398,6 +501,14 @@ export declare const HooksFormat: Schema.Literals<readonly ["claude-hooks-json",
|
|
|
398
501
|
export declare const MCP_FORMATS: readonly ["claude-mcp-json", "agent-plugins-mcp-1.0"];
|
|
399
502
|
/** @public */
|
|
400
503
|
export declare const McpFormat: Schema.Literals<readonly ["claude-mcp-json", "agent-plugins-mcp-1.0"]>;
|
|
504
|
+
/**
|
|
505
|
+
* LSP config formats. The engine owns one encoder per format.
|
|
506
|
+
*
|
|
507
|
+
* @public
|
|
508
|
+
*/
|
|
509
|
+
export declare const LSP_FORMATS: readonly ["claude-lsp-json", "copilot-lsp-json"];
|
|
510
|
+
/** @public */
|
|
511
|
+
export declare const LspFormat: Schema.Literals<readonly ["claude-lsp-json", "copilot-lsp-json"]>;
|
|
401
512
|
declare const Keep_base: Schema.Class<Keep, Schema.TaggedStruct<"keep", {}>, {}>;
|
|
402
513
|
/** Write the field unchanged. @public */
|
|
403
514
|
export declare class Keep extends Keep_base {}
|
|
@@ -484,18 +595,26 @@ declare const Target_base: Schema.Class<Target, Schema.Struct<{
|
|
|
484
595
|
readonly pluginRoot: Schema.Struct<{
|
|
485
596
|
readonly hooks: Schema.Union<readonly [Schema.String, typeof Unresolved]>;
|
|
486
597
|
readonly mcp: Schema.Union<readonly [Schema.String, typeof Unresolved]>;
|
|
598
|
+
readonly lsp: Schema.Union<readonly [Schema.String, typeof Unresolved]>;
|
|
487
599
|
readonly body: Schema.Union<readonly [Schema.String, typeof Unresolved]>;
|
|
488
600
|
}>;
|
|
489
601
|
readonly skills: Schema.Struct<{
|
|
490
602
|
readonly dir: Schema.String;
|
|
491
603
|
readonly fields: Schema.$Record<Schema.String, Schema.Union<readonly [typeof Keep, typeof Rename, typeof Translate, typeof Degrade, typeof Drop, typeof Unresolved]>>;
|
|
492
604
|
readonly hostFields: Schema.$Array<Schema.String>;
|
|
605
|
+
/**
|
|
606
|
+
* How a user invokes a plugin skill: a template with `{plugin}` and `{skill}`,
|
|
607
|
+
* or `unresolved` when the host has no such command.
|
|
608
|
+
*/
|
|
609
|
+
readonly invoke: Schema.Union<readonly [Schema.String, typeof Unresolved]>;
|
|
493
610
|
}>;
|
|
494
611
|
readonly agents: Schema.Struct<{
|
|
495
612
|
readonly dir: Schema.String;
|
|
496
613
|
readonly suffix: Schema.String;
|
|
497
614
|
readonly fields: Schema.$Record<Schema.String, Schema.Union<readonly [typeof Keep, typeof Rename, typeof Translate, typeof Degrade, typeof Drop, typeof Unresolved]>>;
|
|
498
615
|
readonly hostFields: Schema.$Array<Schema.String>;
|
|
616
|
+
/** A plugin agent's run-time id: a template with `{plugin}` and `{agent}`. */
|
|
617
|
+
readonly id: Schema.String;
|
|
499
618
|
}>;
|
|
500
619
|
readonly hooks: Schema.Struct<{
|
|
501
620
|
readonly path: Schema.String;
|
|
@@ -508,6 +627,11 @@ declare const Target_base: Schema.Class<Target, Schema.Struct<{
|
|
|
508
627
|
readonly format: Schema.Literals<readonly ["claude-mcp-json", "agent-plugins-mcp-1.0"]>;
|
|
509
628
|
readonly schema: Schema.optionalKey<Schema.String>;
|
|
510
629
|
}>;
|
|
630
|
+
readonly lsp: Schema.Struct<{
|
|
631
|
+
readonly path: Schema.String;
|
|
632
|
+
readonly format: Schema.Literals<readonly ["claude-lsp-json", "copilot-lsp-json"]>;
|
|
633
|
+
readonly fields: Schema.$Record<Schema.String, Schema.Union<readonly [typeof Keep, typeof Rename, typeof Translate, typeof Degrade, typeof Drop, typeof Unresolved]>>;
|
|
634
|
+
}>;
|
|
511
635
|
readonly references: Schema.Struct<{
|
|
512
636
|
readonly style: Schema.Literals<readonly ["path", "prose"]>;
|
|
513
637
|
}>;
|
|
@@ -520,6 +644,18 @@ declare const Target_base: Schema.Class<Target, Schema.Struct<{
|
|
|
520
644
|
* leaves it out, for a host that has no such tool.
|
|
521
645
|
*/
|
|
522
646
|
readonly unlisted: Schema.Literals<readonly ["keep", "drop"]>;
|
|
647
|
+
/**
|
|
648
|
+
* The tool names the host shows a model at run time, which a skill or agent
|
|
649
|
+
* body can name. `names` maps a Claude Code tool name to its run-time
|
|
650
|
+
* spelling (or `unresolved`); `mcp` is the template for a plugin MCP tool
|
|
651
|
+
* (`{plugin}`, `{server}`, `{tool}`); `unlisted` says whether a name absent
|
|
652
|
+
* from `names` is `keep`-kept as written or `unresolved`.
|
|
653
|
+
*/
|
|
654
|
+
readonly runtime: Schema.Struct<{
|
|
655
|
+
readonly names: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, typeof Unresolved]>>;
|
|
656
|
+
readonly mcp: Schema.String;
|
|
657
|
+
readonly unlisted: Schema.Literals<readonly ["keep", "unresolved"]>;
|
|
658
|
+
}>;
|
|
523
659
|
}>;
|
|
524
660
|
readonly models: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, typeof Drop, typeof Unresolved]>>;
|
|
525
661
|
readonly efforts: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, typeof Drop, typeof Unresolved]>>;
|
|
@@ -531,7 +667,7 @@ declare const Target_base: Schema.Class<Target, Schema.Struct<{
|
|
|
531
667
|
* Build a description with `Target.make`, which validates it at construction,
|
|
532
668
|
* so a malformed host description fails when `@pluginfinity/targets` loads.
|
|
533
669
|
* Field maps are typed as string records here; `@pluginfinity/targets` checks
|
|
534
|
-
* their totality over `SKILL_FIELDS` and `
|
|
670
|
+
* their totality over `SKILL_FIELDS`, `AGENT_FIELDS` and `LSP_FIELDS` at compile time and in
|
|
535
671
|
* tests. A tool name absent from `tools.names` follows `tools.unlisted`; a value
|
|
536
672
|
* absent from `models` or `efforts` passes through unchanged.
|
|
537
673
|
*
|
|
@@ -566,5 +702,5 @@ export declare const unresolved: (note: string) => Unresolved;
|
|
|
566
702
|
*/
|
|
567
703
|
export declare const CORE_VERSION: string;
|
|
568
704
|
//#endregion
|
|
569
|
-
export type { AgentField, DegradeForm, HooksFields, SkillField };
|
|
705
|
+
export type { AgentField, DegradeForm, HooksFields, LspField, SkillField };
|
|
570
706
|
//# 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, Keep, LSP_FORMATS, LspFormat, 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
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, 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, ShippedPath, SkillFrontmatter, StdioMcpServer, Target, ToolMapping, Translate, TranslateTable, Unresolved, ValueMapping, absent, degrade, drop, 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.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
CHANGED
|
@@ -34,6 +34,14 @@ const HooksFormat = Schema.Literals(HOOKS_FORMATS);
|
|
|
34
34
|
const MCP_FORMATS = ["claude-mcp-json", "agent-plugins-mcp-1.0"];
|
|
35
35
|
/** @public */
|
|
36
36
|
const McpFormat = Schema.Literals(MCP_FORMATS);
|
|
37
|
+
/**
|
|
38
|
+
* LSP config formats. The engine owns one encoder per format.
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
const LSP_FORMATS = ["claude-lsp-json", "copilot-lsp-json"];
|
|
43
|
+
/** @public */
|
|
44
|
+
const LspFormat = Schema.Literals(LSP_FORMATS);
|
|
37
45
|
const NonEmpty = Schema.String.check(Schema.isMinLength(1));
|
|
38
46
|
/** Write the field unchanged. @public */
|
|
39
47
|
var Keep = class extends Schema.TaggedClass()("keep", {}) {};
|
|
@@ -123,7 +131,7 @@ const FieldMap = Schema.Record(Schema.String, FieldMapEntry);
|
|
|
123
131
|
* Build a description with `Target.make`, which validates it at construction,
|
|
124
132
|
* so a malformed host description fails when `@pluginfinity/targets` loads.
|
|
125
133
|
* Field maps are typed as string records here; `@pluginfinity/targets` checks
|
|
126
|
-
* their totality over `SKILL_FIELDS` and `
|
|
134
|
+
* their totality over `SKILL_FIELDS`, `AGENT_FIELDS` and `LSP_FIELDS` at compile time and in
|
|
127
135
|
* tests. A tool name absent from `tools.names` follows `tools.unlisted`; a value
|
|
128
136
|
* absent from `models` or `efforts` passes through unchanged.
|
|
129
137
|
*
|
|
@@ -139,18 +147,26 @@ var Target = class extends Schema.Class("Target")({
|
|
|
139
147
|
pluginRoot: Schema.Struct({
|
|
140
148
|
hooks: RootSpelling,
|
|
141
149
|
mcp: RootSpelling,
|
|
150
|
+
lsp: RootSpelling,
|
|
142
151
|
body: RootSpelling
|
|
143
152
|
}),
|
|
144
153
|
skills: Schema.Struct({
|
|
145
154
|
dir: Schema.String,
|
|
146
155
|
fields: FieldMap,
|
|
147
|
-
hostFields: Schema.Array(Schema.String)
|
|
156
|
+
hostFields: Schema.Array(Schema.String),
|
|
157
|
+
/**
|
|
158
|
+
* How a user invokes a plugin skill: a template with `{plugin}` and `{skill}`,
|
|
159
|
+
* or `unresolved` when the host has no such command.
|
|
160
|
+
*/
|
|
161
|
+
invoke: Schema.Union([Schema.String, Unresolved])
|
|
148
162
|
}),
|
|
149
163
|
agents: Schema.Struct({
|
|
150
164
|
dir: Schema.String,
|
|
151
165
|
suffix: Schema.String,
|
|
152
166
|
fields: FieldMap,
|
|
153
|
-
hostFields: Schema.Array(Schema.String)
|
|
167
|
+
hostFields: Schema.Array(Schema.String),
|
|
168
|
+
/** A plugin agent's run-time id: a template with `{plugin}` and `{agent}`. */
|
|
169
|
+
id: Schema.String
|
|
154
170
|
}),
|
|
155
171
|
hooks: Schema.Struct({
|
|
156
172
|
path: Schema.String,
|
|
@@ -163,6 +179,11 @@ var Target = class extends Schema.Class("Target")({
|
|
|
163
179
|
format: McpFormat,
|
|
164
180
|
schema: Schema.optionalKey(Schema.String)
|
|
165
181
|
}),
|
|
182
|
+
lsp: Schema.Struct({
|
|
183
|
+
path: Schema.String,
|
|
184
|
+
format: LspFormat,
|
|
185
|
+
fields: FieldMap
|
|
186
|
+
}),
|
|
166
187
|
references: Schema.Struct({ style: Schema.Literals(["path", "prose"]) }),
|
|
167
188
|
tools: Schema.Struct({
|
|
168
189
|
names: Schema.Record(Schema.String, ToolMapping),
|
|
@@ -172,7 +193,19 @@ var Target = class extends Schema.Class("Target")({
|
|
|
172
193
|
* Claude MCP name the target can spell: `keep` writes it unchanged, `drop`
|
|
173
194
|
* leaves it out, for a host that has no such tool.
|
|
174
195
|
*/
|
|
175
|
-
unlisted: Schema.Literals(["keep", "drop"])
|
|
196
|
+
unlisted: Schema.Literals(["keep", "drop"]),
|
|
197
|
+
/**
|
|
198
|
+
* The tool names the host shows a model at run time, which a skill or agent
|
|
199
|
+
* body can name. `names` maps a Claude Code tool name to its run-time
|
|
200
|
+
* spelling (or `unresolved`); `mcp` is the template for a plugin MCP tool
|
|
201
|
+
* (`{plugin}`, `{server}`, `{tool}`); `unlisted` says whether a name absent
|
|
202
|
+
* from `names` is `keep`-kept as written or `unresolved`.
|
|
203
|
+
*/
|
|
204
|
+
runtime: Schema.Struct({
|
|
205
|
+
names: Schema.Record(Schema.String, Schema.Union([Schema.String, Unresolved])),
|
|
206
|
+
mcp: Schema.String,
|
|
207
|
+
unlisted: Schema.Literals(["keep", "unresolved"])
|
|
208
|
+
})
|
|
176
209
|
}),
|
|
177
210
|
models: Schema.Record(Schema.String, ValueMapping),
|
|
178
211
|
efforts: Schema.Record(Schema.String, ValueMapping)
|
|
@@ -196,4 +229,4 @@ const degrade = (form) => Degrade.make({ form });
|
|
|
196
229
|
const unresolved = (note) => Unresolved.make({ note });
|
|
197
230
|
|
|
198
231
|
//#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 };
|
|
232
|
+
export { Absent, DEGRADE_FORMS, Degrade, DegradeForm, Drop, EventMapping, FieldMapEntry, HOOKS_FORMATS, HooksFormat, Keep, LSP_FORMATS, LspFormat, MANIFEST_FORMATS, MCP_FORMATS, ManifestFormat, McpFormat, Rename, RootSpelling, Target, ToolMapping, Translate, TranslateTable, Unresolved, ValueMapping, absent, degrade, drop, keep, rename, translate, unresolved };
|