@pluginfinity/engine 0.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 C. Spencer Beggs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # @pluginfinity/engine
2
+
3
+ [![npm](https://img.shields.io/npm/v/@pluginfinity%2Fengine?label=npm&color=cb3837)](https://www.npmjs.com/package/@pluginfinity/engine)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-4caf50.svg)](https://opensource.org/licenses/MIT)
5
+ [![Node.js %3E%3D24.11.0](https://img.shields.io/badge/Node.js-%3E%3D24.11.0-5fa04e.svg)](https://nodejs.org/)
6
+ [![TypeScript 7.0](https://img.shields.io/badge/TypeScript-7.0-3178c6.svg)](https://www.typescriptlang.org/)
7
+
8
+ The engine behind every [pluginfinity](https://github.com/spencerbeggs/pluginfinity) front end: config discovery, loading configs through jiti, the typed config errors, and the `doctor` checks. The build pipeline itself is still to come.
9
+
10
+ > **Under development.** This package is part of [pluginfinity](https://www.npmjs.com/package/pluginfinity), which is in early `0.x` development. It installs and runs, but pluginfinity does not build plugins yet, and this package's contents will change without notice between `0.x` releases.
11
+
12
+ ## Install pluginfinity instead
13
+
14
+ To build agent plugins, install the `pluginfinity` package. It provides the command and the `defineConfig` helper.
15
+
16
+ ```bash
17
+ pnpm add -D pluginfinity
18
+ ```
19
+
20
+ This package is an internal layer of the pluginfinity CLI. It is published so that `pluginfinity` installs, not as an API: nothing it exports is supported for direct import, and only what the `pluginfinity` package exports carries a stability promise.
21
+
22
+ ## License
23
+
24
+ [MIT](LICENSE)
package/discovery.js ADDED
@@ -0,0 +1,79 @@
1
+ import { ConfigAmbiguous, ConfigNotFound } from "./errors.js";
2
+ import { GlobPattern } from "@effected/glob";
3
+ import { Walker, descend } from "@effected/walker";
4
+ import { Effect, FileSystem, Path } from "effect";
5
+
6
+ //#region src/discovery.ts
7
+ /**
8
+ * The config file names discovery looks for, in preference order.
9
+ *
10
+ * @public
11
+ */
12
+ const CONFIG_FILE_NAMES = [
13
+ "pluginfinity.config.ts",
14
+ "pluginfinity.config.mts",
15
+ "pluginfinity.config.js",
16
+ "pluginfinity.config.mjs"
17
+ ];
18
+ const ALL_PRUNE = [
19
+ "node_modules",
20
+ "builds",
21
+ ".git"
22
+ ];
23
+ const exists = (fs, path) => fs.exists(path).pipe(Effect.orElseSucceed(() => false));
24
+ /**
25
+ * Finding `pluginfinity.config.*` files. Every member takes its start directory
26
+ * as an absolute path and never reads the process working directory.
27
+ *
28
+ * @public
29
+ */
30
+ var ConfigDiscovery = class {
31
+ constructor() {}
32
+ /**
33
+ * The nearest config at or above `start`, stopping after the first
34
+ * directory that contains `.git`.
35
+ */
36
+ static nearest = (start) => Effect.gen(function* () {
37
+ const fs = yield* FileSystem.FileSystem;
38
+ const path = yield* Path.Path;
39
+ for (const dir of yield* Walker.ascend(start)) {
40
+ const found = [];
41
+ for (const name of CONFIG_FILE_NAMES) if (yield* exists(fs, path.join(dir, name))) found.push(name);
42
+ if (found.length > 1) return yield* Effect.fail(new ConfigAmbiguous({
43
+ path: dir,
44
+ files: found
45
+ }));
46
+ const [only] = found;
47
+ if (only !== void 0) return path.join(dir, only);
48
+ if (yield* exists(fs, path.join(dir, ".git"))) break;
49
+ }
50
+ return yield* Effect.fail(new ConfigNotFound({ path: start }));
51
+ });
52
+ /**
53
+ * Every config at or below `start`, sorted, skipping `node_modules`,
54
+ * `builds` and `.git`. An empty result is not an error here.
55
+ */
56
+ static all = (start) => Effect.gen(function* () {
57
+ const path = yield* Path.Path;
58
+ const pattern = yield* GlobPattern.compile("**/pluginfinity.config.{ts,mts,js,mjs}").pipe(Effect.orDie);
59
+ const relative = yield* descend(pattern, {
60
+ cwd: start,
61
+ prune: ALL_PRUNE,
62
+ onUnreadable: "skip"
63
+ }).pipe(Effect.orDie);
64
+ const byDir = /* @__PURE__ */ new Map();
65
+ for (const file of relative) {
66
+ const absolute = path.join(start, file);
67
+ const dir = path.dirname(absolute);
68
+ byDir.set(dir, [...byDir.get(dir) ?? [], path.basename(absolute)]);
69
+ }
70
+ for (const [dir, files] of byDir) if (files.length > 1) return yield* Effect.fail(new ConfigAmbiguous({
71
+ path: dir,
72
+ files
73
+ }));
74
+ return relative.map((file) => path.join(start, file));
75
+ });
76
+ };
77
+
78
+ //#endregion
79
+ export { CONFIG_FILE_NAMES, ConfigDiscovery };
package/doctor.js ADDED
@@ -0,0 +1,282 @@
1
+ import { ConfigLoader } from "./loader.js";
2
+ import { selectConfigPaths } from "./selection.js";
3
+ import { ENGINE_VERSION } from "./version.js";
4
+ import { Walker } from "@effected/walker";
5
+ import { Duration, Effect, FileSystem, Option, Path, Result, Schema } from "effect";
6
+ import { Tool, ToolDiscovery } from "@effected/commands";
7
+ import { CurrentDistribution, DistributionField, Remediation } from "@effected/engine";
8
+ import { SemVer } from "@effected/semver";
9
+ import { TARGETS } from "@pluginfinity/targets";
10
+
11
+ //#region src/doctor.ts
12
+ /**
13
+ * The lowest Node.js version pluginfinity runs on: the `engines` floor.
14
+ *
15
+ * @public
16
+ */
17
+ const NODE_FLOOR = "24.11.0";
18
+ /**
19
+ * How long one check may take before it is reported as timed out.
20
+ *
21
+ * @public
22
+ */
23
+ const DEFAULT_CHECK_TIMEOUT = Duration.seconds(10);
24
+ /**
25
+ * Whether a check passed.
26
+ *
27
+ * @public
28
+ */
29
+ const CheckStatus = Schema.Literals(["pass", "fail"]);
30
+ /**
31
+ * How much a failing check matters: `required` fails `doctor --strict`,
32
+ * `warning` and `info` never do.
33
+ *
34
+ * @public
35
+ */
36
+ const CheckSeverity = Schema.Literals([
37
+ "required",
38
+ "warning",
39
+ "info"
40
+ ]);
41
+ /**
42
+ * The checklist section a check belongs to.
43
+ *
44
+ * @public
45
+ */
46
+ const CheckGroup = Schema.Literals([
47
+ "runtime",
48
+ "hosts",
49
+ "tools",
50
+ "config"
51
+ ]);
52
+ /**
53
+ * One line of the doctor report.
54
+ *
55
+ * @public
56
+ */
57
+ var DoctorCheck = class extends Schema.Class("DoctorCheck")({
58
+ /** Stable id: `node`, `package-manager`, `claude`, `copilot`, `bats`, `git`, `config`. */
59
+ id: Schema.String,
60
+ group: CheckGroup,
61
+ /** What was checked, for people: `node >= 24.11.0`, `claude`. */
62
+ label: Schema.String,
63
+ status: CheckStatus,
64
+ severity: CheckSeverity,
65
+ /** One line on what was found: `found 2.1.0`, `not found`. */
66
+ detail: Schema.String,
67
+ /** The version found, `null` when absent or unparseable. */
68
+ version: Schema.NullOr(Schema.String),
69
+ /** The config file or directory a config check is about, `null` otherwise. */
70
+ path: Schema.NullOr(Schema.String),
71
+ /** What to do about a failure, `null` on a pass. */
72
+ remediation: Schema.NullOr(Remediation)
73
+ }) {};
74
+ /**
75
+ * Everything `doctor` found, for a front end to render.
76
+ *
77
+ * @public
78
+ */
79
+ var DoctorReport = class extends Schema.Class("DoctorReport")({
80
+ engineVersion: Schema.String,
81
+ distribution: DistributionField,
82
+ checks: Schema.Array(DoctorCheck)
83
+ }) {
84
+ /** No required check failed. Warnings and information never count. */
85
+ get ok() {
86
+ return !this.checks.some((check) => check.severity === "required" && check.status === "fail");
87
+ }
88
+ };
89
+ const LOCKFILES = [
90
+ ["pnpm-lock.yaml", "pnpm"],
91
+ ["package-lock.json", "npm"],
92
+ ["yarn.lock", "yarn"],
93
+ ["bun.lock", "bun"],
94
+ ["bun.lockb", "bun"]
95
+ ];
96
+ const check = (fields) => DoctorCheck.make({
97
+ id: fields.id,
98
+ group: fields.group,
99
+ label: fields.label,
100
+ status: fields.pass ? "pass" : "fail",
101
+ severity: fields.severity,
102
+ detail: fields.detail,
103
+ version: fields.version ?? null,
104
+ path: fields.path ?? null,
105
+ remediation: fields.pass ? null : fields.remediation ?? null
106
+ });
107
+ const nodeCheck = (nodeVersion) => Effect.gen(function* () {
108
+ const base = {
109
+ id: "node",
110
+ group: "runtime",
111
+ label: `node >= ${NODE_FLOOR}`,
112
+ severity: "required"
113
+ };
114
+ const remediation = { hint: `Install Node.js ${NODE_FLOOR} or later.` };
115
+ const floor = yield* SemVer.parse(NODE_FLOOR).pipe(Effect.orDie);
116
+ const parsed = yield* Effect.result(SemVer.parse(nodeVersion));
117
+ if (Result.isFailure(parsed)) return check({
118
+ ...base,
119
+ pass: false,
120
+ detail: `could not parse version "${nodeVersion}"`,
121
+ remediation
122
+ });
123
+ const pass = SemVer.gte(parsed.success, floor);
124
+ return check({
125
+ ...base,
126
+ pass,
127
+ version: nodeVersion,
128
+ detail: pass ? `found ${nodeVersion}` : `found ${nodeVersion}, below the floor`,
129
+ remediation
130
+ });
131
+ });
132
+ const describeFailure = (error) => error._tag === "ToolNotFoundError" ? "not found" : error.message;
133
+ const toolCheck = (fields, name, timeout) => Effect.gen(function* () {
134
+ const discovery = yield* ToolDiscovery;
135
+ const remediation = { hint: `Install ${fields.label} and make sure \`${name}\` is on PATH.` };
136
+ const outcome = yield* discovery.resolve(Tool.named(name)).pipe(Effect.timeoutOption(timeout), Effect.result);
137
+ if (Result.isFailure(outcome)) return check({
138
+ ...fields,
139
+ pass: false,
140
+ detail: describeFailure(outcome.failure),
141
+ remediation
142
+ });
143
+ if (Option.isNone(outcome.success)) return check({
144
+ ...fields,
145
+ pass: false,
146
+ detail: `\`${name} --version\` did not answer within ${Duration.format(timeout)}`,
147
+ remediation: { hint: `Check that \`${name} --version\` runs on its own.` }
148
+ });
149
+ const version = Option.getOrUndefined(outcome.success.value.version);
150
+ return check({
151
+ ...fields,
152
+ pass: true,
153
+ version,
154
+ detail: version === void 0 ? "found (version unknown)" : `found ${version}`
155
+ });
156
+ });
157
+ const detectPackageManager = (start) => Effect.gen(function* () {
158
+ const fs = yield* FileSystem.FileSystem;
159
+ const path = yield* Path.Path;
160
+ const has = (file) => fs.exists(file).pipe(Effect.orElseSucceed(() => false));
161
+ for (const dir of yield* Walker.ascend(start)) {
162
+ for (const [file, manager] of LOCKFILES) if (yield* has(path.join(dir, file))) return manager;
163
+ if (yield* has(path.join(dir, ".git"))) break;
164
+ }
165
+ return "npm";
166
+ });
167
+ const configFailure = (error) => check({
168
+ id: "config",
169
+ group: "config",
170
+ label: "config",
171
+ severity: "required",
172
+ pass: false,
173
+ detail: error.message,
174
+ path: error.path,
175
+ remediation: error.remediation
176
+ });
177
+ const configChecks = (selection, timeout) => Effect.gen(function* () {
178
+ const selected = yield* Effect.result(selectConfigPaths(selection));
179
+ if (Result.isFailure(selected)) {
180
+ const error = selected.failure;
181
+ if (error._tag === "ConfigNotFound" && selection._tag !== "File") return {
182
+ checks: [check({
183
+ id: "config",
184
+ group: "config",
185
+ label: "config",
186
+ severity: "info",
187
+ pass: false,
188
+ detail: "no pluginfinity config found",
189
+ path: error.path,
190
+ remediation: error.remediation
191
+ })],
192
+ loaded: []
193
+ };
194
+ return {
195
+ checks: [configFailure(error)],
196
+ loaded: []
197
+ };
198
+ }
199
+ const checks = [];
200
+ const loaded = [];
201
+ for (const path of selected.success) {
202
+ const result = yield* Effect.result(ConfigLoader.load(path).pipe(Effect.timeoutOption(timeout)));
203
+ if (Result.isFailure(result)) checks.push(configFailure(result.failure));
204
+ else if (Option.isNone(result.success)) checks.push(check({
205
+ id: "config",
206
+ group: "config",
207
+ label: "config",
208
+ severity: "required",
209
+ pass: false,
210
+ detail: `loading did not finish within ${Duration.format(timeout)}`,
211
+ path,
212
+ remediation: { hint: `Check ${path} for a top-level await that never settles.` }
213
+ }));
214
+ else {
215
+ const config = result.success.value;
216
+ loaded.push(config);
217
+ checks.push(check({
218
+ id: "config",
219
+ group: "config",
220
+ label: "config",
221
+ severity: "required",
222
+ pass: true,
223
+ detail: `${config.config.name}: ${config.targets.join(", ")}`,
224
+ path
225
+ }));
226
+ }
227
+ }
228
+ return {
229
+ checks,
230
+ loaded
231
+ };
232
+ });
233
+ const startOf = (selection, path) => selection._tag === "File" ? path.dirname(selection.path) : selection.start;
234
+ /**
235
+ * Report on the environment: the runtime, each host CLI, the tools pluginfinity
236
+ * uses, and the config. Never fails; every problem is a check in the report.
237
+ *
238
+ * @public
239
+ */
240
+ const runDoctor = (input) => Effect.gen(function* () {
241
+ const path = yield* Path.Path;
242
+ const timeout = input.timeout ?? DEFAULT_CHECK_TIMEOUT;
243
+ const config = yield* configChecks(input.selection, timeout);
244
+ const targeted = new Set(config.loaded.flatMap((loaded) => loaded.targets));
245
+ const manager = yield* detectPackageManager(startOf(input.selection, path));
246
+ const probes = yield* Effect.all([
247
+ nodeCheck(input.nodeVersion),
248
+ toolCheck({
249
+ id: "package-manager",
250
+ group: "runtime",
251
+ label: manager,
252
+ severity: "warning"
253
+ }, manager, timeout),
254
+ ...TARGETS.map((target) => toolCheck({
255
+ id: target.id,
256
+ group: "hosts",
257
+ label: target.id,
258
+ severity: targeted.has(target.id) ? "required" : "info"
259
+ }, target.id, timeout)),
260
+ toolCheck({
261
+ id: "bats",
262
+ group: "tools",
263
+ label: "bats",
264
+ severity: "warning"
265
+ }, "bats", timeout),
266
+ toolCheck({
267
+ id: "git",
268
+ group: "tools",
269
+ label: "git",
270
+ severity: "warning"
271
+ }, "git", timeout)
272
+ ], { concurrency: "unbounded" });
273
+ const distribution = yield* CurrentDistribution;
274
+ return DoctorReport.make({
275
+ engineVersion: ENGINE_VERSION,
276
+ distribution: Option.getOrNull(distribution),
277
+ checks: [...probes, ...config.checks]
278
+ });
279
+ });
280
+
281
+ //#endregion
282
+ export { CheckGroup, CheckSeverity, CheckStatus, DEFAULT_CHECK_TIMEOUT, DoctorCheck, DoctorReport, NODE_FLOOR, runDoctor };
package/errors.js ADDED
@@ -0,0 +1,148 @@
1
+ import { Schema } from "effect";
2
+
3
+ //#region src/errors.ts
4
+ /**
5
+ * One problem found while decoding a config: where in the config, and what.
6
+ *
7
+ * @public
8
+ */
9
+ var ConfigIssue = class extends Schema.Class("ConfigIssue")({
10
+ /** The dotted key path inside the config, `""` for the config as a whole. */
11
+ key: Schema.String,
12
+ message: Schema.String
13
+ }) {};
14
+ /**
15
+ * The upward walk reached a `.git` directory or the filesystem root without
16
+ * finding a config, or an explicit `--config` file does not exist.
17
+ *
18
+ * @public
19
+ */
20
+ var ConfigNotFound = class extends Schema.TaggedError()("ConfigNotFound", {
21
+ /** Where discovery started, or the explicit config file that is missing. */
22
+ path: Schema.String,
23
+ /** Set when `path` is a file the user named with `--config`, not a discovery start. */
24
+ explicit: Schema.optionalKey(Schema.Boolean)
25
+ }) {
26
+ get message() {
27
+ return this.explicit === true ? `config file ${this.path} does not exist` : `no pluginfinity.config.{ts,mts,js,mjs} found from ${this.path}`;
28
+ }
29
+ get remediation() {
30
+ return this.explicit === true ? { hint: "Check the path given to --config; a relative path resolves against the launch directory." } : { hint: "Run pluginfinity from inside a plugin, pass its directory as [path], or name the file with --config." };
31
+ }
32
+ };
33
+ /**
34
+ * One directory holds more than one config file.
35
+ *
36
+ * @public
37
+ */
38
+ var ConfigAmbiguous = class extends Schema.TaggedError()("ConfigAmbiguous", {
39
+ /** The directory holding the configs. */
40
+ path: Schema.String,
41
+ files: Schema.Array(Schema.String)
42
+ }) {
43
+ get message() {
44
+ return `${this.path} holds more than one config: ${this.files.join(", ")}`;
45
+ }
46
+ get remediation() {
47
+ return { hint: `Keep one pluginfinity config in ${this.path} and delete the others.` };
48
+ }
49
+ };
50
+ /**
51
+ * Importing the config threw: a syntax error or an unresolved import.
52
+ *
53
+ * @public
54
+ */
55
+ var ConfigLoadFailed = class extends Schema.TaggedError()("ConfigLoadFailed", {
56
+ path: Schema.String,
57
+ /** The first line of what the import threw. */
58
+ detail: Schema.String
59
+ }) {
60
+ get message() {
61
+ return `could not load ${this.path}: ${this.detail}`;
62
+ }
63
+ get remediation() {
64
+ return { hint: `Fix the error in ${this.path} so it imports cleanly.` };
65
+ }
66
+ };
67
+ /**
68
+ * The config's default export does not decode, or it enables no target.
69
+ *
70
+ * @public
71
+ */
72
+ var ConfigInvalid = class extends Schema.TaggedError()("ConfigInvalid", {
73
+ path: Schema.String,
74
+ issues: Schema.Array(ConfigIssue)
75
+ }) {
76
+ get message() {
77
+ return `${this.path} is not a valid pluginfinity config: ${this.issues.map((issue) => issue.key === "" ? issue.message : `${issue.key}: ${issue.message}`).join("; ")}`;
78
+ }
79
+ get remediation() {
80
+ return { hint: `Correct the listed keys in ${this.path}.` };
81
+ }
82
+ };
83
+ /**
84
+ * The config sets a top-level key that is neither a base field nor a known
85
+ * target id.
86
+ *
87
+ * @public
88
+ */
89
+ var UnknownTarget = class extends Schema.TaggedError()("UnknownTarget", {
90
+ path: Schema.String,
91
+ /** The unknown keys, in the order the config spells them. */
92
+ targets: Schema.Array(Schema.String),
93
+ /** Every known target id. */
94
+ known: Schema.Array(Schema.String)
95
+ }) {
96
+ get message() {
97
+ return `${this.path} enables unknown target ${this.targets.map((target) => `"${target}"`).join(", ")}; known targets: ${this.known.join(", ")}`;
98
+ }
99
+ get remediation() {
100
+ return { hint: `Rename or remove the key in ${this.path}; known targets are ${this.known.join(", ")}.` };
101
+ }
102
+ };
103
+ /**
104
+ * `--target` named a known target the config does not enable.
105
+ *
106
+ * @public
107
+ */
108
+ var TargetNotEnabled = class extends Schema.TaggedError()("TargetNotEnabled", {
109
+ path: Schema.String,
110
+ target: Schema.String,
111
+ enabled: Schema.Array(Schema.String)
112
+ }) {
113
+ get message() {
114
+ return `${this.path} does not enable target "${this.target}" (enabled: ${this.enabled.join(", ")})`;
115
+ }
116
+ get remediation() {
117
+ return { hint: `Add \`${this.target}: true\` to ${this.path}, or drop --target ${this.target}.` };
118
+ }
119
+ };
120
+ const CONFIG_ERROR_TAGS = [
121
+ "ConfigNotFound",
122
+ "ConfigAmbiguous",
123
+ "ConfigLoadFailed",
124
+ "ConfigInvalid",
125
+ "UnknownTarget",
126
+ "TargetNotEnabled"
127
+ ];
128
+ /**
129
+ * Whether `error` is one of the {@link ConfigError} members.
130
+ *
131
+ * @public
132
+ */
133
+ const isConfigError = (error) => typeof error === "object" && error !== null && "_tag" in error && typeof error._tag === "string" && CONFIG_ERROR_TAGS.includes(error._tag);
134
+ /**
135
+ * The operation exists in the command surface but is not built yet.
136
+ *
137
+ * @public
138
+ */
139
+ var NotImplemented = class extends Schema.TaggedError()("NotImplemented", {
140
+ /** The command, as typed: `build`, `validate`, `init`, `plugin add`. */
141
+ operation: Schema.String }) {
142
+ get message() {
143
+ return `pluginfinity ${this.operation} is not implemented yet`;
144
+ }
145
+ };
146
+
147
+ //#endregion
148
+ export { ConfigAmbiguous, ConfigInvalid, ConfigIssue, ConfigLoadFailed, ConfigNotFound, NotImplemented, TargetNotEnabled, UnknownTarget, isConfigError };
package/index.d.ts ADDED
@@ -0,0 +1,398 @@
1
+ import { Duration, Effect, FileSystem, Layer, Path, Schema } from "effect";
2
+ import { Remediation } from "@effected/engine";
3
+ import { ToolDiscovery } from "@effected/commands";
4
+ import { KnownTargetId, PluginfinityConfig } from "@pluginfinity/targets";
5
+ import { ChildProcessSpawner } from "effect/process";
6
+ //#region src/errors.d.ts
7
+ declare const ConfigIssue_base: Schema.Class<ConfigIssue, Schema.Struct<{
8
+ /** The dotted key path inside the config, `""` for the config as a whole. */
9
+ readonly key: Schema.String;
10
+ readonly message: Schema.String;
11
+ }>, {}>;
12
+ /**
13
+ * One problem found while decoding a config: where in the config, and what.
14
+ *
15
+ * @public
16
+ */
17
+ export declare class ConfigIssue extends ConfigIssue_base {}
18
+ declare const ConfigNotFound_base: Schema.Class<ConfigNotFound, Schema.TaggedStruct<"ConfigNotFound", {
19
+ /** Where discovery started, or the explicit config file that is missing. */
20
+ readonly path: Schema.String;
21
+ /** Set when `path` is a file the user named with `--config`, not a discovery start. */
22
+ readonly explicit: Schema.optionalKey<Schema.Boolean>;
23
+ }>, import("effect/Cause").YieldableError>;
24
+ /**
25
+ * The upward walk reached a `.git` directory or the filesystem root without
26
+ * finding a config, or an explicit `--config` file does not exist.
27
+ *
28
+ * @public
29
+ */
30
+ export declare class ConfigNotFound extends ConfigNotFound_base {
31
+ get message(): string;
32
+ get remediation(): Remediation;
33
+ }
34
+ declare const ConfigAmbiguous_base: Schema.Class<ConfigAmbiguous, Schema.TaggedStruct<"ConfigAmbiguous", {
35
+ /** The directory holding the configs. */
36
+ readonly path: Schema.String;
37
+ readonly files: Schema.$Array<Schema.String>;
38
+ }>, import("effect/Cause").YieldableError>;
39
+ /**
40
+ * One directory holds more than one config file.
41
+ *
42
+ * @public
43
+ */
44
+ export declare class ConfigAmbiguous extends ConfigAmbiguous_base {
45
+ get message(): string;
46
+ get remediation(): Remediation;
47
+ }
48
+ declare const ConfigLoadFailed_base: Schema.Class<ConfigLoadFailed, Schema.TaggedStruct<"ConfigLoadFailed", {
49
+ readonly path: Schema.String;
50
+ /** The first line of what the import threw. */
51
+ readonly detail: Schema.String;
52
+ }>, import("effect/Cause").YieldableError>;
53
+ /**
54
+ * Importing the config threw: a syntax error or an unresolved import.
55
+ *
56
+ * @public
57
+ */
58
+ export declare class ConfigLoadFailed extends ConfigLoadFailed_base {
59
+ get message(): string;
60
+ get remediation(): Remediation;
61
+ }
62
+ declare const ConfigInvalid_base: Schema.Class<ConfigInvalid, Schema.TaggedStruct<"ConfigInvalid", {
63
+ readonly path: Schema.String;
64
+ readonly issues: Schema.$Array<typeof ConfigIssue>;
65
+ }>, import("effect/Cause").YieldableError>;
66
+ /**
67
+ * The config's default export does not decode, or it enables no target.
68
+ *
69
+ * @public
70
+ */
71
+ export declare class ConfigInvalid extends ConfigInvalid_base {
72
+ get message(): string;
73
+ get remediation(): Remediation;
74
+ }
75
+ declare const UnknownTarget_base: Schema.Class<UnknownTarget, Schema.TaggedStruct<"UnknownTarget", {
76
+ readonly path: Schema.String;
77
+ /** The unknown keys, in the order the config spells them. */
78
+ readonly targets: Schema.$Array<Schema.String>;
79
+ /** Every known target id. */
80
+ readonly known: Schema.$Array<Schema.String>;
81
+ }>, import("effect/Cause").YieldableError>;
82
+ /**
83
+ * The config sets a top-level key that is neither a base field nor a known
84
+ * target id.
85
+ *
86
+ * @public
87
+ */
88
+ export declare class UnknownTarget extends UnknownTarget_base {
89
+ get message(): string;
90
+ get remediation(): Remediation;
91
+ }
92
+ declare const TargetNotEnabled_base: Schema.Class<TargetNotEnabled, Schema.TaggedStruct<"TargetNotEnabled", {
93
+ readonly path: Schema.String;
94
+ readonly target: Schema.String;
95
+ readonly enabled: Schema.$Array<Schema.String>;
96
+ }>, import("effect/Cause").YieldableError>;
97
+ /**
98
+ * `--target` named a known target the config does not enable.
99
+ *
100
+ * @public
101
+ */
102
+ export declare class TargetNotEnabled extends TargetNotEnabled_base {
103
+ get message(): string;
104
+ get remediation(): Remediation;
105
+ }
106
+ /**
107
+ * Every failure finding or loading a config can produce.
108
+ *
109
+ * @public
110
+ */
111
+ type ConfigError = ConfigNotFound | ConfigAmbiguous | ConfigLoadFailed | ConfigInvalid | UnknownTarget | TargetNotEnabled;
112
+ /**
113
+ * Whether `error` is one of the {@link ConfigError} members.
114
+ *
115
+ * @public
116
+ */
117
+ export declare const isConfigError: (error: unknown) => error is ConfigError;
118
+ declare const NotImplemented_base: Schema.Class<NotImplemented, Schema.TaggedStruct<"NotImplemented", {
119
+ /** The command, as typed: `build`, `validate`, `init`, `plugin add`. */
120
+ readonly operation: Schema.String;
121
+ }>, import("effect/Cause").YieldableError>;
122
+ /**
123
+ * The operation exists in the command surface but is not built yet.
124
+ *
125
+ * @public
126
+ */
127
+ export declare class NotImplemented extends NotImplemented_base {
128
+ get message(): string;
129
+ }
130
+ //#endregion
131
+ //#region src/discovery.d.ts
132
+ /**
133
+ * The config file names discovery looks for, in preference order.
134
+ *
135
+ * @public
136
+ */
137
+ export declare const CONFIG_FILE_NAMES: readonly ["pluginfinity.config.ts", "pluginfinity.config.mts", "pluginfinity.config.js", "pluginfinity.config.mjs"];
138
+ /**
139
+ * Finding `pluginfinity.config.*` files. Every member takes its start directory
140
+ * as an absolute path and never reads the process working directory.
141
+ *
142
+ * @public
143
+ */
144
+ export declare class ConfigDiscovery {
145
+ private constructor();
146
+ /**
147
+ * The nearest config at or above `start`, stopping after the first
148
+ * directory that contains `.git`.
149
+ */
150
+ static readonly nearest: (start: string) => Effect.Effect<string, ConfigNotFound | ConfigAmbiguous, FileSystem.FileSystem | Path.Path>;
151
+ /**
152
+ * Every config at or below `start`, sorted, skipping `node_modules`,
153
+ * `builds` and `.git`. An empty result is not an error here.
154
+ */
155
+ static readonly all: (start: string) => Effect.Effect<ReadonlyArray<string>, ConfigAmbiguous, FileSystem.FileSystem | Path.Path>;
156
+ }
157
+ //#endregion
158
+ //#region src/loader.d.ts
159
+ /**
160
+ * A config that loaded, decoded and enables at least one target.
161
+ *
162
+ * @public
163
+ */
164
+ interface LoadedConfig {
165
+ /** The config file's absolute path. */
166
+ readonly path: string;
167
+ /** The config's directory: the plugin root. */
168
+ readonly root: string;
169
+ readonly config: PluginfinityConfig;
170
+ /** The enabled targets, in registry order. */
171
+ readonly targets: ReadonlyArray<KnownTargetId>;
172
+ }
173
+ /**
174
+ * Loading one config file through jiti.
175
+ *
176
+ * @public
177
+ */
178
+ export declare class ConfigLoader {
179
+ private constructor();
180
+ /**
181
+ * Import `path`, take its default export, reject unknown top-level keys,
182
+ * decode it against `PluginfinityConfig`, and require at least one target.
183
+ */
184
+ static readonly load: (path: string) => Effect.Effect<LoadedConfig, ConfigLoadFailed | ConfigInvalid | UnknownTarget, Path.Path>;
185
+ }
186
+ //#endregion
187
+ //#region src/selection.d.ts
188
+ /**
189
+ * Which configs an operation runs against. A front end builds it from
190
+ * `[path]`, `--config` and `--all`; using `--config` and `--all` together is
191
+ * the front end's usage error to report, so a selection never holds both.
192
+ *
193
+ * @public
194
+ */
195
+ type ConfigSelection =
196
+ /** The nearest config at or above `start`. */
197
+ {
198
+ readonly _tag: "Nearest";
199
+ readonly start: string;
200
+ } |
201
+ /** Every config at or below `start`. */
202
+ {
203
+ readonly _tag: "All";
204
+ readonly start: string;
205
+ } |
206
+ /** Exactly this file, no discovery. */
207
+ {
208
+ readonly _tag: "File";
209
+ readonly path: string;
210
+ };
211
+ /**
212
+ * The config paths a selection names, before loading. `All` with no match is
213
+ * `ConfigNotFound`.
214
+ *
215
+ * @public
216
+ */
217
+ export declare const selectConfigPaths: (selection: ConfigSelection) => Effect.Effect<ReadonlyArray<string>, ConfigError, FileSystem.FileSystem | Path.Path>;
218
+ /**
219
+ * A loaded config and the targets an operation will run for it.
220
+ *
221
+ * @public
222
+ */
223
+ interface PreparedPlugin {
224
+ readonly config: LoadedConfig;
225
+ readonly targets: ReadonlyArray<KnownTargetId>;
226
+ }
227
+ /**
228
+ * The front half every config-driven operation shares: select, load, and
229
+ * check the requested targets. An empty `targets` means every enabled target.
230
+ *
231
+ * @public
232
+ */
233
+ export declare const preparePlugins: (input: {
234
+ readonly selection: ConfigSelection;
235
+ readonly targets: ReadonlyArray<KnownTargetId>;
236
+ }) => Effect.Effect<ReadonlyArray<PreparedPlugin>, ConfigError, FileSystem.FileSystem | Path.Path>;
237
+ //#endregion
238
+ //#region src/doctor.d.ts
239
+ /**
240
+ * The lowest Node.js version pluginfinity runs on: the `engines` floor.
241
+ *
242
+ * @public
243
+ */
244
+ export declare const NODE_FLOOR = "24.11.0";
245
+ /**
246
+ * How long one check may take before it is reported as timed out.
247
+ *
248
+ * @public
249
+ */
250
+ export declare const DEFAULT_CHECK_TIMEOUT: Duration.Duration;
251
+ /**
252
+ * Whether a check passed.
253
+ *
254
+ * @public
255
+ */
256
+ export declare const CheckStatus: Schema.Literals<readonly ["pass", "fail"]>;
257
+ /**
258
+ * How much a failing check matters: `required` fails `doctor --strict`,
259
+ * `warning` and `info` never do.
260
+ *
261
+ * @public
262
+ */
263
+ export declare const CheckSeverity: Schema.Literals<readonly ["required", "warning", "info"]>;
264
+ /**
265
+ * The checklist section a check belongs to.
266
+ *
267
+ * @public
268
+ */
269
+ export declare const CheckGroup: Schema.Literals<readonly ["runtime", "hosts", "tools", "config"]>;
270
+ declare const DoctorCheck_base: Schema.Class<DoctorCheck, Schema.Struct<{
271
+ /** Stable id: `node`, `package-manager`, `claude`, `copilot`, `bats`, `git`, `config`. */
272
+ readonly id: Schema.String;
273
+ readonly group: Schema.Literals<readonly ["runtime", "hosts", "tools", "config"]>;
274
+ /** What was checked, for people: `node >= 24.11.0`, `claude`. */
275
+ readonly label: Schema.String;
276
+ readonly status: Schema.Literals<readonly ["pass", "fail"]>;
277
+ readonly severity: Schema.Literals<readonly ["required", "warning", "info"]>;
278
+ /** One line on what was found: `found 2.1.0`, `not found`. */
279
+ readonly detail: Schema.String;
280
+ /** The version found, `null` when absent or unparseable. */
281
+ readonly version: Schema.NullOr<Schema.String>;
282
+ /** The config file or directory a config check is about, `null` otherwise. */
283
+ readonly path: Schema.NullOr<Schema.String>;
284
+ /** What to do about a failure, `null` on a pass. */
285
+ readonly remediation: Schema.NullOr<Schema.Struct<{
286
+ readonly hint: Schema.String;
287
+ readonly suggestedTool: Schema.optionalKey<Schema.String>;
288
+ readonly suggestedArgs: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>;
289
+ }>>;
290
+ }>, {}>;
291
+ /**
292
+ * One line of the doctor report.
293
+ *
294
+ * @public
295
+ */
296
+ export declare class DoctorCheck extends DoctorCheck_base {}
297
+ declare const DoctorReport_base: Schema.Class<DoctorReport, Schema.Struct<{
298
+ readonly engineVersion: Schema.String;
299
+ readonly distribution: Schema.NullOr<Schema.Struct<{
300
+ readonly name: Schema.String;
301
+ readonly version: Schema.String;
302
+ }>>;
303
+ readonly checks: Schema.$Array<typeof DoctorCheck>;
304
+ }>, {}>;
305
+ /**
306
+ * Everything `doctor` found, for a front end to render.
307
+ *
308
+ * @public
309
+ */
310
+ export declare class DoctorReport extends DoctorReport_base {
311
+ /** No required check failed. Warnings and information never count. */
312
+ get ok(): boolean;
313
+ }
314
+ /**
315
+ * The input to {@link runDoctor}.
316
+ *
317
+ * @public
318
+ */
319
+ interface DoctorInput {
320
+ readonly selection: ConfigSelection;
321
+ /** The running Node.js version without a leading `v`, read by the front end. */
322
+ readonly nodeVersion: string;
323
+ /** Per-check time limit; {@link DEFAULT_CHECK_TIMEOUT} when absent. */
324
+ readonly timeout?: Duration.Duration | undefined;
325
+ }
326
+ /**
327
+ * Report on the environment: the runtime, each host CLI, the tools pluginfinity
328
+ * uses, and the config. Never fails; every problem is a check in the report.
329
+ *
330
+ * @public
331
+ */
332
+ export declare const runDoctor: (input: DoctorInput) => Effect.Effect<DoctorReport, never, ToolDiscovery | FileSystem.FileSystem | Path.Path>;
333
+ //#endregion
334
+ //#region src/operations.d.ts
335
+ /**
336
+ * The input to `build`.
337
+ *
338
+ * @public
339
+ */
340
+ interface BuildInput {
341
+ readonly selection: ConfigSelection;
342
+ readonly targets: ReadonlyArray<KnownTargetId>;
343
+ /** Rebuild in memory and compare with `builds/` instead of writing. */
344
+ readonly check: boolean;
345
+ }
346
+ /**
347
+ * The input to `validate`.
348
+ *
349
+ * @public
350
+ */
351
+ interface ValidateInput {
352
+ readonly selection: ConfigSelection;
353
+ readonly targets: ReadonlyArray<KnownTargetId>;
354
+ /** Skip the host CLIs and run only pluginfinity's own checks. */
355
+ readonly skipHosts: boolean;
356
+ }
357
+ /**
358
+ * Regenerate `builds/<id>/`. Runs the real front half (find, load, check the
359
+ * targets), then stops with `NotImplemented`.
360
+ *
361
+ * @public
362
+ */
363
+ export declare const build: (input: BuildInput) => Effect.Effect<never, ConfigError | NotImplemented, FileSystem.FileSystem | Path.Path>;
364
+ /**
365
+ * Validate the plugin. Runs the real front half, then stops with
366
+ * `NotImplemented`.
367
+ *
368
+ * @public
369
+ */
370
+ export declare const validate: (input: ValidateInput) => Effect.Effect<never, ConfigError | NotImplemented, FileSystem.FileSystem | Path.Path>;
371
+ //#endregion
372
+ //#region src/tools.d.ts
373
+ /**
374
+ * The `ToolDiscovery` doctor uses in production: global lookups only, over the
375
+ * platform's `ChildProcessSpawner`. Bound once so every provide shares it.
376
+ *
377
+ * @public
378
+ */
379
+ export declare const ToolDiscoveryLive: Layer.Layer<ToolDiscovery, never, ChildProcessSpawner.ChildProcessSpawner>;
380
+ //#endregion
381
+ //#region src/version.d.ts
382
+ /**
383
+ * The version of `@pluginfinity/engine` this build was made from: the comparable
384
+ * version of a pluginfinity run.
385
+ *
386
+ * @remarks
387
+ * A build-time literal: the bundler replaces `process.env.__PACKAGE_VERSION__`
388
+ * with this package's own version, so this is not a runtime environment read.
389
+ * `"0.0.0"` is the unbuilt-source fallback. Every front end runs the same
390
+ * engine, so this, not a front end's or the carrier's version, is what two
391
+ * reports compare to tell whether the same build produced both.
392
+ *
393
+ * @public
394
+ */
395
+ export declare const ENGINE_VERSION: string;
396
+ //#endregion
397
+ export type { BuildInput, ConfigError, ConfigSelection, DoctorInput, LoadedConfig, PreparedPlugin, ValidateInput };
398
+ //# sourceMappingURL=index.d.ts.map
package/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import { ConfigAmbiguous, ConfigInvalid, ConfigIssue, ConfigLoadFailed, ConfigNotFound, NotImplemented, TargetNotEnabled, UnknownTarget, isConfigError } from "./errors.js";
2
+ import { CONFIG_FILE_NAMES, ConfigDiscovery } from "./discovery.js";
3
+ import { ConfigLoader } from "./loader.js";
4
+ import { preparePlugins, selectConfigPaths } from "./selection.js";
5
+ import { ENGINE_VERSION } from "./version.js";
6
+ import { CheckGroup, CheckSeverity, CheckStatus, DEFAULT_CHECK_TIMEOUT, DoctorCheck, DoctorReport, NODE_FLOOR, runDoctor } from "./doctor.js";
7
+ import { build, validate } from "./operations.js";
8
+ import { ToolDiscoveryLive } from "./tools.js";
9
+
10
+ export { CONFIG_FILE_NAMES, CheckGroup, CheckSeverity, CheckStatus, ConfigAmbiguous, ConfigDiscovery, ConfigInvalid, ConfigIssue, ConfigLoadFailed, ConfigLoader, ConfigNotFound, DEFAULT_CHECK_TIMEOUT, DoctorCheck, DoctorReport, ENGINE_VERSION, NODE_FLOOR, NotImplemented, TargetNotEnabled, ToolDiscoveryLive, UnknownTarget, build, isConfigError, preparePlugins, runDoctor, selectConfigPaths, validate };
package/loader.js ADDED
@@ -0,0 +1,79 @@
1
+ import { ConfigInvalid, ConfigIssue, ConfigLoadFailed, UnknownTarget } from "./errors.js";
2
+ import { Effect, Path, Schema, SchemaIssue } from "effect";
3
+ import { CONFIG_KEYS, KNOWN_TARGET_IDS, PluginfinityConfig, enabledTargets } from "@pluginfinity/targets";
4
+ import { createJiti } from "jiti";
5
+
6
+ //#region src/loader.ts
7
+ const firstLine = (cause) => {
8
+ const text = cause instanceof Error ? cause.message : String(cause);
9
+ return text.split("\n")[0]?.trim() ?? text;
10
+ };
11
+ const formatter = SchemaIssue.makeFormatterStandardSchemaV1();
12
+ const importDefault = (path) => Effect.tryPromise({
13
+ try: () => createJiti(path, {
14
+ fsCache: false,
15
+ moduleCache: false,
16
+ interopDefault: false
17
+ }).import(path),
18
+ catch: (cause) => new ConfigLoadFailed({
19
+ path,
20
+ detail: firstLine(cause)
21
+ })
22
+ }).pipe(Effect.flatMap((mod) => "default" in mod ? Effect.succeed(mod.default) : Effect.fail(new ConfigInvalid({
23
+ path,
24
+ issues: [ConfigIssue.make({
25
+ key: "",
26
+ message: "the config has no default export"
27
+ })]
28
+ }))));
29
+ /**
30
+ * Loading one config file through jiti.
31
+ *
32
+ * @public
33
+ */
34
+ var ConfigLoader = class {
35
+ constructor() {}
36
+ /**
37
+ * Import `path`, take its default export, reject unknown top-level keys,
38
+ * decode it against `PluginfinityConfig`, and require at least one target.
39
+ */
40
+ static load = (path) => Effect.gen(function* () {
41
+ const paths = yield* Path.Path;
42
+ const value = yield* importDefault(path);
43
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
44
+ const unknown = Object.keys(value).filter((key) => !CONFIG_KEYS.includes(key));
45
+ if (unknown.length > 0) return yield* Effect.fail(new UnknownTarget({
46
+ path,
47
+ targets: unknown,
48
+ known: [...KNOWN_TARGET_IDS]
49
+ }));
50
+ }
51
+ const config = yield* Schema.decodeUnknownEffect(PluginfinityConfig)(value, {
52
+ errors: "all",
53
+ onExcessProperty: "error"
54
+ }).pipe(Effect.mapError((error) => new ConfigInvalid({
55
+ path,
56
+ issues: formatter(error.issue).issues.map((issue) => ConfigIssue.make({
57
+ key: (issue.path ?? []).map((segment) => String(segment)).join("."),
58
+ message: issue.message
59
+ }))
60
+ })));
61
+ const targets = enabledTargets(config);
62
+ if (targets.length === 0) return yield* Effect.fail(new ConfigInvalid({
63
+ path,
64
+ issues: [ConfigIssue.make({
65
+ key: "",
66
+ message: `no target is enabled; add at least one of: ${KNOWN_TARGET_IDS.join(", ")}`
67
+ })]
68
+ }));
69
+ return {
70
+ path,
71
+ root: paths.dirname(path),
72
+ config,
73
+ targets
74
+ };
75
+ });
76
+ };
77
+
78
+ //#endregion
79
+ export { ConfigLoader };
package/operations.js ADDED
@@ -0,0 +1,22 @@
1
+ import { NotImplemented } from "./errors.js";
2
+ import { preparePlugins } from "./selection.js";
3
+ import { Effect } from "effect";
4
+
5
+ //#region src/operations.ts
6
+ /**
7
+ * Regenerate `builds/<id>/`. Runs the real front half (find, load, check the
8
+ * targets), then stops with `NotImplemented`.
9
+ *
10
+ * @public
11
+ */
12
+ const build = (input) => preparePlugins(input).pipe(Effect.andThen(Effect.fail(new NotImplemented({ operation: "build" }))));
13
+ /**
14
+ * Validate the plugin. Runs the real front half, then stops with
15
+ * `NotImplemented`.
16
+ *
17
+ * @public
18
+ */
19
+ const validate = (input) => preparePlugins(input).pipe(Effect.andThen(Effect.fail(new NotImplemented({ operation: "validate" }))));
20
+
21
+ //#endregion
22
+ export { build, validate };
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@pluginfinity/engine",
3
+ "version": "0.0.1",
4
+ "private": false,
5
+ "description": "The pluginfinity build pipeline shared by every pluginfinity front end: config discovery, read, transform per target, emit and check.",
6
+ "keywords": [
7
+ "pluginfinity",
8
+ "agent-plugin",
9
+ "effect"
10
+ ],
11
+ "homepage": "https://github.com/spencerbeggs/pluginfinity/tree/main/packages/engine#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/spencerbeggs/pluginfinity/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/spencerbeggs/pluginfinity.git",
18
+ "directory": "packages/engine"
19
+ },
20
+ "license": "MIT",
21
+ "author": {
22
+ "name": "C. Spencer Beggs",
23
+ "email": "spencer@beggs.codes",
24
+ "url": "https://spencerbeg.gs"
25
+ },
26
+ "sideEffects": false,
27
+ "type": "module",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./index.d.ts",
31
+ "import": "./index.js",
32
+ "default": "./index.js"
33
+ },
34
+ "./package.json": "./package.json"
35
+ },
36
+ "dependencies": {
37
+ "@effected/commands": "^0.11.0",
38
+ "@effected/engine": "^0.3.0",
39
+ "@effected/glob": "^0.10.0",
40
+ "@effected/semver": "^0.11.0",
41
+ "@effected/walker": "^0.15.0",
42
+ "@pluginfinity/core": "0.0.1",
43
+ "@pluginfinity/targets": "0.0.1",
44
+ "jiti": "^2.6.1"
45
+ },
46
+ "peerDependencies": {
47
+ "@effect/platform-node": "^4.0.0",
48
+ "effect": "^4.0.0"
49
+ },
50
+ "engines": {
51
+ "node": ">=24.11.0"
52
+ }
53
+ }
package/selection.js ADDED
@@ -0,0 +1,54 @@
1
+ import { ConfigNotFound, TargetNotEnabled } from "./errors.js";
2
+ import { ConfigDiscovery } from "./discovery.js";
3
+ import { ConfigLoader } from "./loader.js";
4
+ import { Effect, FileSystem } from "effect";
5
+
6
+ //#region src/selection.ts
7
+ /**
8
+ * The config paths a selection names, before loading. `All` with no match is
9
+ * `ConfigNotFound`.
10
+ *
11
+ * @public
12
+ */
13
+ const selectConfigPaths = (selection) => Effect.gen(function* () {
14
+ switch (selection._tag) {
15
+ case "Nearest": return [yield* ConfigDiscovery.nearest(selection.start)];
16
+ case "All": {
17
+ const paths = yield* ConfigDiscovery.all(selection.start);
18
+ if (paths.length === 0) return yield* Effect.fail(new ConfigNotFound({ path: selection.start }));
19
+ return paths;
20
+ }
21
+ case "File":
22
+ if (!(yield* (yield* FileSystem.FileSystem).exists(selection.path).pipe(Effect.orElseSucceed(() => false)))) return yield* Effect.fail(new ConfigNotFound({
23
+ path: selection.path,
24
+ explicit: true
25
+ }));
26
+ return [selection.path];
27
+ }
28
+ });
29
+ /**
30
+ * The front half every config-driven operation shares: select, load, and
31
+ * check the requested targets. An empty `targets` means every enabled target.
32
+ *
33
+ * @public
34
+ */
35
+ const preparePlugins = (input) => Effect.gen(function* () {
36
+ const paths = yield* selectConfigPaths(input.selection);
37
+ const prepared = [];
38
+ for (const path of paths) {
39
+ const config = yield* ConfigLoader.load(path);
40
+ for (const target of input.targets) if (!config.targets.includes(target)) return yield* Effect.fail(new TargetNotEnabled({
41
+ path,
42
+ target,
43
+ enabled: [...config.targets]
44
+ }));
45
+ prepared.push({
46
+ config,
47
+ targets: input.targets.length === 0 ? config.targets : input.targets
48
+ });
49
+ }
50
+ return prepared;
51
+ });
52
+
53
+ //#endregion
54
+ export { preparePlugins, selectConfigPaths };
package/tools.js ADDED
@@ -0,0 +1,14 @@
1
+ import { Layer } from "effect";
2
+ import { LocalExec, ToolDiscovery } from "@effected/commands";
3
+
4
+ //#region src/tools.ts
5
+ /**
6
+ * The `ToolDiscovery` doctor uses in production: global lookups only, over the
7
+ * platform's `ChildProcessSpawner`. Bound once so every provide shares it.
8
+ *
9
+ * @public
10
+ */
11
+ const ToolDiscoveryLive = ToolDiscovery.layer.pipe(Layer.provide(LocalExec.layerNone));
12
+
13
+ //#endregion
14
+ export { ToolDiscoveryLive };
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.59.1"
9
+ }
10
+ ]
11
+ }
package/version.js ADDED
@@ -0,0 +1,18 @@
1
+ //#region src/version.ts
2
+ /**
3
+ * The version of `@pluginfinity/engine` this build was made from: the comparable
4
+ * version of a pluginfinity run.
5
+ *
6
+ * @remarks
7
+ * A build-time literal: the bundler replaces `process.env.__PACKAGE_VERSION__`
8
+ * with this package's own version, so this is not a runtime environment read.
9
+ * `"0.0.0"` is the unbuilt-source fallback. Every front end runs the same
10
+ * engine, so this, not a front end's or the carrier's version, is what two
11
+ * reports compare to tell whether the same build produced both.
12
+ *
13
+ * @public
14
+ */
15
+ const ENGINE_VERSION = "0.0.1";
16
+
17
+ //#endregion
18
+ export { ENGINE_VERSION };