@pluginfinity/engine 0.2.0 → 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/errors.js +20 -4
- package/index.d.ts +21 -10
- package/manifest.js +6 -4
- package/operations.js +20 -14
- package/package.json +3 -3
- package/servers.js +30 -23
- package/version.js +1 -1
package/errors.js
CHANGED
|
@@ -322,7 +322,9 @@ var ShippedFileInvalid = class extends Schema.TaggedError()("ShippedFileInvalid"
|
|
|
322
322
|
}
|
|
323
323
|
};
|
|
324
324
|
/**
|
|
325
|
-
* A copied source file
|
|
325
|
+
* A copied source file would land on a path pluginfinity owns: a file it
|
|
326
|
+
* generates, a directory it reserves for an injected library, or a server
|
|
327
|
+
* config file the host loads beside servers written inline.
|
|
326
328
|
*
|
|
327
329
|
* @public
|
|
328
330
|
*/
|
|
@@ -331,13 +333,27 @@ var PathConflict = class extends Schema.TaggedError()("PathConflict", {
|
|
|
331
333
|
path: Schema.String,
|
|
332
334
|
target: Schema.String,
|
|
333
335
|
/** The build path both claim, relative to `builds/<target>/`. */
|
|
334
|
-
file: Schema.String
|
|
336
|
+
file: Schema.String,
|
|
337
|
+
/** Why the path is taken: a generated file, a reserved library directory, or a reserved server file. */
|
|
338
|
+
conflict: Schema.Literals([
|
|
339
|
+
"generated",
|
|
340
|
+
"reserved-dir",
|
|
341
|
+
"reserved-server-file"
|
|
342
|
+
])
|
|
335
343
|
}) {
|
|
336
344
|
get message() {
|
|
337
|
-
|
|
345
|
+
switch (this.conflict) {
|
|
346
|
+
case "reserved-dir": return `${this.file} is under a directory pluginfinity reserves for its injected library`;
|
|
347
|
+
case "reserved-server-file": return `${this.target} loads ${this.file} as a server config file, but the plugin also ships a source file at that path`;
|
|
348
|
+
default: return `${this.target} generates ${this.file}, but the plugin also ships a source file at that path`;
|
|
349
|
+
}
|
|
338
350
|
}
|
|
339
351
|
get remediation() {
|
|
340
|
-
|
|
352
|
+
switch (this.conflict) {
|
|
353
|
+
case "reserved-dir": return { hint: `Move ${this.file} out of the reserved directory.` };
|
|
354
|
+
case "reserved-server-file": return { hint: `Declare those servers under mcpServers or lspServers in the pluginfinity config instead of shipping ${this.file}.` };
|
|
355
|
+
default: return { hint: `Delete or move the source ${this.file}; pluginfinity writes that file itself.` };
|
|
356
|
+
}
|
|
341
357
|
}
|
|
342
358
|
};
|
|
343
359
|
/**
|
package/index.d.ts
CHANGED
|
@@ -330,9 +330,13 @@ declare const PathConflict_base: Schema.Class<PathConflict, Schema.TaggedStruct<
|
|
|
330
330
|
readonly target: Schema.String;
|
|
331
331
|
/** The build path both claim, relative to `builds/<target>/`. */
|
|
332
332
|
readonly file: Schema.String;
|
|
333
|
+
/** Why the path is taken: a generated file, a reserved library directory, or a reserved server file. */
|
|
334
|
+
readonly conflict: Schema.Literals<readonly ["generated", "reserved-dir", "reserved-server-file"]>;
|
|
333
335
|
}>, import("effect/Cause").YieldableError>;
|
|
334
336
|
/**
|
|
335
|
-
* A copied source file
|
|
337
|
+
* A copied source file would land on a path pluginfinity owns: a file it
|
|
338
|
+
* generates, a directory it reserves for an injected library, or a server
|
|
339
|
+
* config file the host loads beside servers written inline.
|
|
336
340
|
*
|
|
337
341
|
* @public
|
|
338
342
|
*/
|
|
@@ -966,13 +970,14 @@ export declare const renderHooks: (target: Target, events: ReadonlyArray<TargetH
|
|
|
966
970
|
*/
|
|
967
971
|
type Manifest = Readonly<Record<string, unknown>>;
|
|
968
972
|
/**
|
|
969
|
-
* Render a target's manifest from the config
|
|
970
|
-
*
|
|
971
|
-
*
|
|
973
|
+
* Render a target's manifest from the config, the package version and the
|
|
974
|
+
* server maps the target places in its manifest (`ServerRender.manifest`):
|
|
975
|
+
* the format's record, cut to the target's key allowlist, in allowlist order,
|
|
976
|
+
* with unset keys left out.
|
|
972
977
|
*
|
|
973
978
|
* @public
|
|
974
979
|
*/
|
|
975
|
-
export declare const renderManifest: (target: Target, id: KnownTargetId, config: PluginfinityConfig, version: string) => Manifest;
|
|
980
|
+
export declare const renderManifest: (target: Target, id: KnownTargetId, config: PluginfinityConfig, version: string, servers?: Readonly<Record<string, unknown>>) => Manifest;
|
|
976
981
|
/**
|
|
977
982
|
* The bytes a manifest is written as: tab-indented JSON with a final newline.
|
|
978
983
|
*
|
|
@@ -1057,24 +1062,30 @@ export declare const validate: (input: ValidateInput) => Effect.Effect<ReadonlyA
|
|
|
1057
1062
|
//#endregion
|
|
1058
1063
|
//#region src/servers.d.ts
|
|
1059
1064
|
/**
|
|
1060
|
-
* A target's server config files, the
|
|
1061
|
-
*
|
|
1062
|
-
* the server
|
|
1065
|
+
* A target's server config files, the server maps it writes inline in its
|
|
1066
|
+
* manifest, the problems that stop it building them, whether any server is a
|
|
1067
|
+
* local process that needs the server library, and the server fields the
|
|
1068
|
+
* target dropped.
|
|
1063
1069
|
*
|
|
1064
1070
|
* @public
|
|
1065
1071
|
*/
|
|
1066
1072
|
interface ServerRender {
|
|
1073
|
+
/** The server files of a target that places its servers in files. */
|
|
1067
1074
|
readonly files: ReadonlyArray<EmittedFile>;
|
|
1075
|
+
/** The server maps of a target that places its servers in its manifest, by manifest key. */
|
|
1076
|
+
readonly manifest: Readonly<Record<string, unknown>>;
|
|
1068
1077
|
readonly issues: ReadonlyArray<ConfigIssue>;
|
|
1069
1078
|
readonly stdio: boolean;
|
|
1070
1079
|
/** Each LSP field dropped, as a `config` note named `<origin>.<server>.<field>`, in the order met. */
|
|
1071
1080
|
readonly notes: ReadonlyArray<BuildNote>;
|
|
1072
1081
|
}
|
|
1073
1082
|
/**
|
|
1074
|
-
* The target's MCP and LSP
|
|
1083
|
+
* The target's MCP and LSP configs: base servers with the target's
|
|
1075
1084
|
* overrides applied by name, `${PLUGIN_ROOT}` rewritten to the target's
|
|
1076
1085
|
* spelling, LSP fields mapped through the target's field map, and the
|
|
1077
|
-
* server-library variables added to every local server's `env`.
|
|
1086
|
+
* server-library variables added to every local server's `env`. Each config
|
|
1087
|
+
* goes where the target places it: a file of its own, or inline under a
|
|
1088
|
+
* manifest key, for `renderManifest` to write.
|
|
1078
1089
|
*
|
|
1079
1090
|
* @public
|
|
1080
1091
|
*/
|
package/manifest.js
CHANGED
|
@@ -15,14 +15,16 @@ const FORMATS = {
|
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
|
-
* Render a target's manifest from the config
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* Render a target's manifest from the config, the package version and the
|
|
19
|
+
* server maps the target places in its manifest (`ServerRender.manifest`):
|
|
20
|
+
* the format's record, cut to the target's key allowlist, in allowlist order,
|
|
21
|
+
* with unset keys left out.
|
|
21
22
|
*
|
|
22
23
|
* @public
|
|
23
24
|
*/
|
|
24
|
-
const renderManifest = (target, id, config, version) => {
|
|
25
|
+
const renderManifest = (target, id, config, version, servers = {}) => {
|
|
25
26
|
const record = FORMATS[target.manifest.format](target, {
|
|
27
|
+
...servers,
|
|
26
28
|
name: pluginName(config, id),
|
|
27
29
|
version,
|
|
28
30
|
description: config.description,
|
package/operations.js
CHANGED
|
@@ -197,7 +197,10 @@ const tokenContext = (target, id, config, skills, agents) => {
|
|
|
197
197
|
* and an executable file when a whole `command`; a named directory ships every
|
|
198
198
|
* file under it), and every file the `files` key lists, each once. A target
|
|
199
199
|
* with a local server gets the server library under `lib/pluginfinity/`,
|
|
200
|
-
* which is reserved the same way.
|
|
200
|
+
* which is reserved the same way. A target that writes its servers inline
|
|
201
|
+
* in its manifest also reserves the server file its host loads by default
|
|
202
|
+
* (Claude Code's `.mcp.json` and `.lsp.json`), but only when this plugin
|
|
203
|
+
* has servers of that kind inline.
|
|
201
204
|
*/
|
|
202
205
|
const planPlugin = (prepared) => Effect.gen(function* () {
|
|
203
206
|
const path = yield* Path.Path;
|
|
@@ -253,7 +256,16 @@ const planPlugin = (prepared) => Effect.gen(function* () {
|
|
|
253
256
|
])];
|
|
254
257
|
const copied = [];
|
|
255
258
|
for (const file of shipped) copied.push(yield* copyFile(config.root, file));
|
|
256
|
-
const
|
|
259
|
+
const rendered = renderServers(target, id, config.config, pluginName(config.config, id), SERVER_LIB_DIR);
|
|
260
|
+
if (rendered.issues.length > 0) {
|
|
261
|
+
const issue = new ComponentInvalid({
|
|
262
|
+
path: config.path,
|
|
263
|
+
target: id,
|
|
264
|
+
issues: rendered.issues
|
|
265
|
+
});
|
|
266
|
+
if (!failures.some((seen) => seen.message === issue.message)) failures.push(issue);
|
|
267
|
+
}
|
|
268
|
+
const manifest = renderManifest(target, id, config.config, version, rendered.manifest);
|
|
257
269
|
const generated = [{
|
|
258
270
|
path: target.manifest.path,
|
|
259
271
|
content: serializeManifest(manifest)
|
|
@@ -266,15 +278,6 @@ const planPlugin = (prepared) => Effect.gen(function* () {
|
|
|
266
278
|
});
|
|
267
279
|
generated.push(...hookLibFiles(id, String(manifest.name), ENGINE_VERSION));
|
|
268
280
|
}
|
|
269
|
-
const rendered = renderServers(target, id, config.config, String(manifest.name), SERVER_LIB_DIR);
|
|
270
|
-
if (rendered.issues.length > 0) {
|
|
271
|
-
const issue = new ComponentInvalid({
|
|
272
|
-
path: config.path,
|
|
273
|
-
target: id,
|
|
274
|
-
issues: rendered.issues
|
|
275
|
-
});
|
|
276
|
-
if (!failures.some((seen) => seen.message === issue.message)) failures.push(issue);
|
|
277
|
-
}
|
|
278
281
|
generated.push(...rendered.files);
|
|
279
282
|
notes.push(...rendered.notes);
|
|
280
283
|
if (rendered.stdio) generated.push(...serverLibFiles());
|
|
@@ -291,18 +294,21 @@ const planPlugin = (prepared) => Effect.gen(function* () {
|
|
|
291
294
|
generated.push(agentRender.file);
|
|
292
295
|
notes.push(...agentRender.notes);
|
|
293
296
|
}
|
|
294
|
-
const
|
|
297
|
+
const reservedFiles = new Set([target.mcp.placement, target.lsp.placement].flatMap((placement) => placement._tag === "manifest" && placement.key in rendered.manifest ? [placement.reserves] : []));
|
|
298
|
+
const reserved = copied.find((file) => reservedFiles.has(file.path) || ["hooks/lib/pluginfinity", "lib/pluginfinity"].some((dir) => file.path === dir || file.path.startsWith(`${dir}/`)));
|
|
295
299
|
if (reserved !== void 0) return yield* Effect.fail(new PathConflict({
|
|
296
300
|
path: config.path,
|
|
297
301
|
target: id,
|
|
298
|
-
file: reserved.path
|
|
302
|
+
file: reserved.path,
|
|
303
|
+
conflict: reservedFiles.has(reserved.path) ? "reserved-server-file" : "reserved-dir"
|
|
299
304
|
}));
|
|
300
305
|
const copiedPaths = new Set(copied.map((file) => file.path));
|
|
301
306
|
const conflict = generated.find((file) => copiedPaths.has(file.path));
|
|
302
307
|
if (conflict !== void 0) return yield* Effect.fail(new PathConflict({
|
|
303
308
|
path: config.path,
|
|
304
309
|
target: id,
|
|
305
|
-
file: conflict.path
|
|
310
|
+
file: conflict.path,
|
|
311
|
+
conflict: "generated"
|
|
306
312
|
}));
|
|
307
313
|
const files = [...generated, ...copied];
|
|
308
314
|
const out = path.join(config.root, "builds", id);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluginfinity/engine",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The pluginfinity build pipeline shared by every pluginfinity front end: config discovery, read, transform per target, emit and check.",
|
|
6
6
|
"keywords": [
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"@effected/semver": "^0.11.0",
|
|
41
41
|
"@effected/walker": "^0.15.0",
|
|
42
42
|
"@effected/yaml": "^0.19.1",
|
|
43
|
-
"@pluginfinity/core": "0.2.
|
|
44
|
-
"@pluginfinity/targets": "0.2.
|
|
43
|
+
"@pluginfinity/core": "0.2.1",
|
|
44
|
+
"@pluginfinity/targets": "0.2.1",
|
|
45
45
|
"jiti": "^2.6.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
package/servers.js
CHANGED
|
@@ -134,7 +134,7 @@ const mcpEntries = ({ servers, env, root, issues }, copilot) => {
|
|
|
134
134
|
return out;
|
|
135
135
|
};
|
|
136
136
|
const MCP_ENCODERS = {
|
|
137
|
-
"claude-mcp-
|
|
137
|
+
"claude-mcp-servers": (input) => mcpEntries(input, false),
|
|
138
138
|
"agent-plugins-mcp-1.0": (input) => ({
|
|
139
139
|
...input.target.mcp.schema === void 0 ? {} : { $schema: input.target.mcp.schema },
|
|
140
140
|
mcpServers: mcpEntries(input, true)
|
|
@@ -151,14 +151,23 @@ const lspEntries = ({ target, servers, env, root, issues, dropped }) => {
|
|
|
151
151
|
return out;
|
|
152
152
|
};
|
|
153
153
|
const LSP_ENCODERS = {
|
|
154
|
-
"claude-lsp-
|
|
154
|
+
"claude-lsp-servers": (input) => lspEntries(input),
|
|
155
155
|
"copilot-lsp-json": (input) => ({ lspServers: lspEntries(input) })
|
|
156
156
|
};
|
|
157
|
+
const place = (placement, value, files, manifest) => {
|
|
158
|
+
if (placement._tag === "file") files.push({
|
|
159
|
+
path: placement.path,
|
|
160
|
+
content: serialize(value)
|
|
161
|
+
});
|
|
162
|
+
else manifest[placement.key] = value;
|
|
163
|
+
};
|
|
157
164
|
/**
|
|
158
|
-
* The target's MCP and LSP
|
|
165
|
+
* The target's MCP and LSP configs: base servers with the target's
|
|
159
166
|
* overrides applied by name, `${PLUGIN_ROOT}` rewritten to the target's
|
|
160
167
|
* spelling, LSP fields mapped through the target's field map, and the
|
|
161
|
-
* server-library variables added to every local server's `env`.
|
|
168
|
+
* server-library variables added to every local server's `env`. Each config
|
|
169
|
+
* goes where the target places it: a file of its own, or inline under a
|
|
170
|
+
* manifest key, for `renderManifest` to write.
|
|
162
171
|
*
|
|
163
172
|
* @public
|
|
164
173
|
*/
|
|
@@ -166,43 +175,41 @@ const renderServers = (target, id, config, plugin, libDir) => {
|
|
|
166
175
|
const issues = [];
|
|
167
176
|
const dropped = [];
|
|
168
177
|
const files = [];
|
|
178
|
+
const manifest = {};
|
|
169
179
|
const mcp = merged(id, config, "mcpServers");
|
|
170
180
|
const lsp = merged(id, config, "lspServers");
|
|
171
181
|
if (mcp.length > 0) {
|
|
172
182
|
const root = rootOf(target.pluginRoot.mcp, "mcpServers", issues);
|
|
173
183
|
if (root !== void 0) {
|
|
174
184
|
const env = injectedEnv(id, plugin, root, libDir);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
root,
|
|
182
|
-
issues
|
|
183
|
-
}))
|
|
185
|
+
const value = MCP_ENCODERS[target.mcp.format]({
|
|
186
|
+
target,
|
|
187
|
+
servers: mcp,
|
|
188
|
+
env,
|
|
189
|
+
root,
|
|
190
|
+
issues
|
|
184
191
|
});
|
|
192
|
+
place(target.mcp.placement, value, files, manifest);
|
|
185
193
|
}
|
|
186
194
|
}
|
|
187
195
|
if (lsp.length > 0) {
|
|
188
196
|
const root = rootOf(target.pluginRoot.lsp, "lspServers", issues);
|
|
189
197
|
if (root !== void 0) {
|
|
190
198
|
const env = injectedEnv(id, plugin, root, libDir);
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
issues,
|
|
199
|
-
dropped
|
|
200
|
-
}))
|
|
199
|
+
const value = LSP_ENCODERS[target.lsp.format]({
|
|
200
|
+
target,
|
|
201
|
+
servers: lsp,
|
|
202
|
+
env,
|
|
203
|
+
root,
|
|
204
|
+
issues,
|
|
205
|
+
dropped
|
|
201
206
|
});
|
|
207
|
+
place(target.lsp.placement, value, files, manifest);
|
|
202
208
|
}
|
|
203
209
|
}
|
|
204
210
|
return {
|
|
205
211
|
files,
|
|
212
|
+
manifest,
|
|
206
213
|
issues,
|
|
207
214
|
stdio: mcp.some(([, , server]) => isStdio(server)) || lsp.length > 0,
|
|
208
215
|
notes: dropped.map((name) => ({
|