@pluginfinity/engine 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents.js +88 -0
- package/body.js +110 -0
- package/component.js +157 -0
- package/discovery.js +1 -1
- package/doctor.js +1 -1
- package/emit.js +133 -0
- package/errors.js +198 -5
- package/frontmatter.js +167 -0
- package/hooks.js +99 -0
- package/index.d.ts +552 -9
- package/index.js +9 -2
- package/loader.js +3 -1
- package/manifest.js +45 -0
- package/operations.js +254 -8
- package/package.json +4 -3
- package/skills.js +132 -0
- package/version.js +1 -1
package/index.d.ts
CHANGED
|
@@ -1,8 +1,72 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AgentFrontmatter, FieldMapEntry, HookEntry, SkillFrontmatter, Target } from "@pluginfinity/core";
|
|
2
|
+
import { Duration, Effect, FileSystem, Layer, Path, PlatformError, Schema } from "effect";
|
|
2
3
|
import { Remediation } from "@effected/engine";
|
|
3
4
|
import { ToolDiscovery } from "@effected/commands";
|
|
4
5
|
import { KnownTargetId, PluginfinityConfig } from "@pluginfinity/targets";
|
|
5
6
|
import { ChildProcessSpawner } from "effect/process";
|
|
7
|
+
//#region src/emit.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* The mode every generated file is written with.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare const GENERATED_MODE = 420;
|
|
14
|
+
/**
|
|
15
|
+
* One file a build produces: a `/`-separated path relative to the output
|
|
16
|
+
* directory, its text or bytes, and its mode.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
interface EmittedFile {
|
|
21
|
+
readonly path: string;
|
|
22
|
+
readonly content: string | Uint8Array;
|
|
23
|
+
/** The permission bits; a generated file's are {@link GENERATED_MODE}, a copied file keeps its source's. */
|
|
24
|
+
readonly mode?: number;
|
|
25
|
+
}
|
|
26
|
+
declare const EmitPlan_base: Schema.Class<EmitPlan, Schema.Struct<{
|
|
27
|
+
/** Produced, not on disk. */
|
|
28
|
+
readonly added: Schema.$Array<Schema.String>;
|
|
29
|
+
/** On disk with other bytes or another mode. */
|
|
30
|
+
readonly changed: Schema.$Array<Schema.String>;
|
|
31
|
+
/** On disk, no longer produced; an empty directory ends in `/`. */
|
|
32
|
+
readonly removed: Schema.$Array<Schema.String>;
|
|
33
|
+
/** On disk with the same bytes and mode; never touched, so its mtime stays. */
|
|
34
|
+
readonly unchanged: Schema.$Array<Schema.String>;
|
|
35
|
+
}>, {}>;
|
|
36
|
+
/**
|
|
37
|
+
* How an output directory differs from what a build produces. Every list is
|
|
38
|
+
* sorted and holds `/`-separated paths relative to the output directory.
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export declare class EmitPlan extends EmitPlan_base {
|
|
43
|
+
/** Whether the output directory already matches the build. */
|
|
44
|
+
get clean(): boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Compare `files` with what `dir` holds, reading only.
|
|
48
|
+
*
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
export declare const planEmit: (dir: string, files: ReadonlyArray<EmittedFile>) => Effect.Effect<EmitPlan, PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
52
|
+
/**
|
|
53
|
+
* Bring `dir` in line with `files` according to `plan`: stage every added and
|
|
54
|
+
* changed file in a sibling temporary directory first, so a failed write
|
|
55
|
+
* leaves `dir` untouched; then delete removed files and prune the directories
|
|
56
|
+
* they leave empty; then move each staged file into place. Unchanged files are
|
|
57
|
+
* never written.
|
|
58
|
+
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* Removals run before the moves. A path that changes only by case is a
|
|
61
|
+
* removal and an addition naming the same file on a case-insensitive
|
|
62
|
+
* filesystem, so moving first and removing second deletes the new file. A
|
|
63
|
+
* path that turns from a file into a directory, or back, cannot be moved into
|
|
64
|
+
* place while the old entry still stands.
|
|
65
|
+
*
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export declare const applyEmit: (dir: string, files: ReadonlyArray<EmittedFile>, plan: EmitPlan) => Effect.Effect<void, PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
69
|
+
//#endregion
|
|
6
70
|
//#region src/errors.d.ts
|
|
7
71
|
declare const ConfigIssue_base: Schema.Class<ConfigIssue, Schema.Struct<{
|
|
8
72
|
/** The dotted key path inside the config, `""` for the config as a whole. */
|
|
@@ -78,10 +142,13 @@ declare const UnknownTarget_base: Schema.Class<UnknownTarget, Schema.TaggedStruc
|
|
|
78
142
|
readonly targets: Schema.$Array<Schema.String>;
|
|
79
143
|
/** Every known target id. */
|
|
80
144
|
readonly known: Schema.$Array<Schema.String>;
|
|
145
|
+
/** Every base config field. */
|
|
146
|
+
readonly fields: Schema.$Array<Schema.String>;
|
|
81
147
|
}>, import("effect/Cause").YieldableError>;
|
|
82
148
|
/**
|
|
83
149
|
* The config sets a top-level key that is neither a base field nor a known
|
|
84
|
-
* target id.
|
|
150
|
+
* target id. Base fields and target ids share one key space, so the key may
|
|
151
|
+
* be a misspelt field as easily as an unknown target; the message lists both.
|
|
85
152
|
*
|
|
86
153
|
* @public
|
|
87
154
|
*/
|
|
@@ -127,6 +194,240 @@ declare const NotImplemented_base: Schema.Class<NotImplemented, Schema.TaggedStr
|
|
|
127
194
|
export declare class NotImplemented extends NotImplemented_base {
|
|
128
195
|
get message(): string;
|
|
129
196
|
}
|
|
197
|
+
declare const PackageVersionMissing_base: Schema.Class<PackageVersionMissing, Schema.TaggedStruct<"PackageVersionMissing", {
|
|
198
|
+
/** The `package.json` path that was read. */
|
|
199
|
+
readonly path: Schema.String;
|
|
200
|
+
}>, import("effect/Cause").YieldableError>;
|
|
201
|
+
/**
|
|
202
|
+
* The `package.json` beside a config is missing, unreadable, or has no
|
|
203
|
+
* `version` string. Every manifest copies its version from there.
|
|
204
|
+
*
|
|
205
|
+
* @public
|
|
206
|
+
*/
|
|
207
|
+
export declare class PackageVersionMissing extends PackageVersionMissing_base {
|
|
208
|
+
get message(): string;
|
|
209
|
+
get remediation(): Remediation;
|
|
210
|
+
}
|
|
211
|
+
declare const TargetDrift_base: Schema.Class<TargetDrift, Schema.Struct<{
|
|
212
|
+
readonly target: Schema.String;
|
|
213
|
+
readonly added: Schema.$Array<Schema.String>;
|
|
214
|
+
readonly changed: Schema.$Array<Schema.String>;
|
|
215
|
+
readonly removed: Schema.$Array<Schema.String>;
|
|
216
|
+
}>, {}>;
|
|
217
|
+
/**
|
|
218
|
+
* How one target's `builds/<id>/` differs from a fresh build.
|
|
219
|
+
*
|
|
220
|
+
* @public
|
|
221
|
+
*/
|
|
222
|
+
export declare class TargetDrift extends TargetDrift_base {}
|
|
223
|
+
declare const BuildStale_base: Schema.Class<BuildStale, Schema.TaggedStruct<"BuildStale", {
|
|
224
|
+
/** The config whose builds drifted. */
|
|
225
|
+
readonly path: Schema.String;
|
|
226
|
+
readonly targets: Schema.$Array<typeof TargetDrift>;
|
|
227
|
+
}>, import("effect/Cause").YieldableError>;
|
|
228
|
+
/**
|
|
229
|
+
* `build --check` or `validate` found `builds/` out of date with the source.
|
|
230
|
+
*
|
|
231
|
+
* @public
|
|
232
|
+
*/
|
|
233
|
+
export declare class BuildStale extends BuildStale_base {
|
|
234
|
+
get message(): string;
|
|
235
|
+
get remediation(): Remediation;
|
|
236
|
+
}
|
|
237
|
+
declare const HostRejected_base: Schema.Class<HostRejected, Schema.TaggedStruct<"HostRejected", {
|
|
238
|
+
/** The build directory the host checked. */
|
|
239
|
+
readonly path: Schema.String;
|
|
240
|
+
readonly target: Schema.String;
|
|
241
|
+
/** The command line, as run. */
|
|
242
|
+
readonly command: Schema.String;
|
|
243
|
+
/** What the host printed, stdout then stderr, trimmed. */
|
|
244
|
+
readonly output: Schema.String;
|
|
245
|
+
}>, import("effect/Cause").YieldableError>;
|
|
246
|
+
/**
|
|
247
|
+
* A host's own CLI rejected a build, or could not be run to check it.
|
|
248
|
+
*
|
|
249
|
+
* @public
|
|
250
|
+
*/
|
|
251
|
+
export declare class HostRejected extends HostRejected_base {
|
|
252
|
+
get message(): string;
|
|
253
|
+
get remediation(): Remediation;
|
|
254
|
+
}
|
|
255
|
+
declare const HookEventUnsupported_base: Schema.Class<HookEventUnsupported, Schema.TaggedStruct<"HookEventUnsupported", {
|
|
256
|
+
/** The config. */
|
|
257
|
+
readonly path: Schema.String;
|
|
258
|
+
readonly target: Schema.String;
|
|
259
|
+
readonly events: Schema.$Array<Schema.String>;
|
|
260
|
+
}>, import("effect/Cause").YieldableError>;
|
|
261
|
+
/**
|
|
262
|
+
* A target lacks a hook event the config uses, and an entry for it does not
|
|
263
|
+
* set `fallback: "omit"`.
|
|
264
|
+
*
|
|
265
|
+
* @public
|
|
266
|
+
*/
|
|
267
|
+
export declare class HookEventUnsupported extends HookEventUnsupported_base {
|
|
268
|
+
get message(): string;
|
|
269
|
+
get remediation(): Remediation;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* What is wrong with a hook script: absent from the plugin, or lacking the
|
|
273
|
+
* executable bit under `scripts.invoke: "exec"`.
|
|
274
|
+
*
|
|
275
|
+
* @public
|
|
276
|
+
*/
|
|
277
|
+
export declare const HookScriptProblem: Schema.Literals<readonly ["missing", "not-executable"]>;
|
|
278
|
+
declare const HookScriptInvalid_base: Schema.Class<HookScriptInvalid, Schema.TaggedStruct<"HookScriptInvalid", {
|
|
279
|
+
/** The config. */
|
|
280
|
+
readonly path: Schema.String;
|
|
281
|
+
/** The script, relative to the plugin root. */
|
|
282
|
+
readonly script: Schema.String;
|
|
283
|
+
readonly problem: Schema.Literals<readonly ["missing", "not-executable"]>;
|
|
284
|
+
}>, import("effect/Cause").YieldableError>;
|
|
285
|
+
/**
|
|
286
|
+
* A hook `script` cannot be shipped as configured.
|
|
287
|
+
*
|
|
288
|
+
* @public
|
|
289
|
+
*/
|
|
290
|
+
export declare class HookScriptInvalid extends HookScriptInvalid_base {
|
|
291
|
+
get message(): string;
|
|
292
|
+
get remediation(): Remediation;
|
|
293
|
+
}
|
|
294
|
+
declare const PathConflict_base: Schema.Class<PathConflict, Schema.TaggedStruct<"PathConflict", {
|
|
295
|
+
/** The config. */
|
|
296
|
+
readonly path: Schema.String;
|
|
297
|
+
readonly target: Schema.String;
|
|
298
|
+
/** The build path both claim, relative to `builds/<target>/`. */
|
|
299
|
+
readonly file: Schema.String;
|
|
300
|
+
}>, import("effect/Cause").YieldableError>;
|
|
301
|
+
/**
|
|
302
|
+
* A copied source file and a generated file would land on the same build path.
|
|
303
|
+
*
|
|
304
|
+
* @public
|
|
305
|
+
*/
|
|
306
|
+
export declare class PathConflict extends PathConflict_base {
|
|
307
|
+
get message(): string;
|
|
308
|
+
get remediation(): Remediation;
|
|
309
|
+
}
|
|
310
|
+
declare const ComponentInvalid_base: Schema.Class<ComponentInvalid, Schema.TaggedStruct<"ComponentInvalid", {
|
|
311
|
+
/** The component file, or its directory when the file is missing. */
|
|
312
|
+
readonly path: Schema.String;
|
|
313
|
+
/** The target the problem is specific to, when it is. */
|
|
314
|
+
readonly target: Schema.optionalKey<Schema.String>;
|
|
315
|
+
readonly issues: Schema.$Array<typeof ConfigIssue>;
|
|
316
|
+
}>, import("effect/Cause").YieldableError>;
|
|
317
|
+
/**
|
|
318
|
+
* A skill or agent file does not decode, or cannot be built for a target:
|
|
319
|
+
* bad frontmatter, a name that breaks the rules, a malformed host block, or a
|
|
320
|
+
* field the target cannot place.
|
|
321
|
+
*
|
|
322
|
+
* @public
|
|
323
|
+
*/
|
|
324
|
+
export declare class ComponentInvalid extends ComponentInvalid_base {
|
|
325
|
+
get message(): string;
|
|
326
|
+
get remediation(): Remediation;
|
|
327
|
+
}
|
|
328
|
+
declare const ComponentsInvalid_base: Schema.Class<ComponentsInvalid, Schema.TaggedStruct<"ComponentsInvalid", {
|
|
329
|
+
/** The config. */
|
|
330
|
+
readonly path: Schema.String;
|
|
331
|
+
readonly components: Schema.$Array<typeof ComponentInvalid>;
|
|
332
|
+
}>, import("effect/Cause").YieldableError>;
|
|
333
|
+
/**
|
|
334
|
+
* Every skill and agent problem one build found, so a single run reports them
|
|
335
|
+
* all.
|
|
336
|
+
*
|
|
337
|
+
* @public
|
|
338
|
+
*/
|
|
339
|
+
export declare class ComponentsInvalid extends ComponentsInvalid_base {
|
|
340
|
+
get message(): string;
|
|
341
|
+
get remediation(): Remediation;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Every finding a build or validation can produce after its config loaded.
|
|
345
|
+
*
|
|
346
|
+
* @public
|
|
347
|
+
*/
|
|
348
|
+
type BuildError = PackageVersionMissing | BuildStale | HostRejected | HookEventUnsupported | HookScriptInvalid | PathConflict | ComponentsInvalid;
|
|
349
|
+
/**
|
|
350
|
+
* Whether `error` is one of the {@link BuildError} members.
|
|
351
|
+
*
|
|
352
|
+
* @public
|
|
353
|
+
*/
|
|
354
|
+
export declare const isBuildError: (error: unknown) => error is BuildError;
|
|
355
|
+
//#endregion
|
|
356
|
+
//#region src/agents.d.ts
|
|
357
|
+
/**
|
|
358
|
+
* One agent as read from `agents/<name>.md`: its name, its decoded
|
|
359
|
+
* frontmatter and its body.
|
|
360
|
+
*
|
|
361
|
+
* @public
|
|
362
|
+
*/
|
|
363
|
+
interface SourceAgent {
|
|
364
|
+
/** The file stem, which is the agent's name. */
|
|
365
|
+
readonly name: string;
|
|
366
|
+
/** The absolute path of its file. */
|
|
367
|
+
readonly path: string;
|
|
368
|
+
readonly frontmatter: typeof AgentFrontmatter.Type;
|
|
369
|
+
/** The frontmatter as written, without its fences. */
|
|
370
|
+
readonly frontmatterText: string;
|
|
371
|
+
/** Everything after the closing frontmatter fence, unchanged. */
|
|
372
|
+
readonly body: string;
|
|
373
|
+
/** The file lines before the body. */
|
|
374
|
+
readonly bodyOffset: number;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Read every agent under `<root>/agents/`, sorted by name; none when the
|
|
378
|
+
* directory is absent. An agent whose frontmatter does not decode, whose
|
|
379
|
+
* `name` differs from its file stem, or whose `targets` block names an
|
|
380
|
+
* unknown target is collected in `failures` rather than stopping the read,
|
|
381
|
+
* so one build reports them all.
|
|
382
|
+
*
|
|
383
|
+
* @public
|
|
384
|
+
*/
|
|
385
|
+
export declare const readAgents: (root: string, known: ReadonlyArray<string>) => Effect.Effect<{
|
|
386
|
+
readonly agents: ReadonlyArray<SourceAgent>;
|
|
387
|
+
readonly failures: ReadonlyArray<ComponentInvalid>;
|
|
388
|
+
}, PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
389
|
+
/**
|
|
390
|
+
* Render one agent for a target, or `undefined` when its `targets` block
|
|
391
|
+
* excludes it: the file at `<agents.dir>/<name><agents.suffix>` with the
|
|
392
|
+
* target's frontmatter, degraded fields appended as body sections, and host
|
|
393
|
+
* blocks applied. It keeps its source mode.
|
|
394
|
+
*
|
|
395
|
+
* @public
|
|
396
|
+
*/
|
|
397
|
+
export declare const renderAgent: (target: Target, id: string, agent: SourceAgent, known: ReadonlyArray<string>) => Effect.Effect<EmittedFile | undefined, ComponentInvalid | PlatformError.PlatformError, FileSystem.FileSystem>;
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region src/body.d.ts
|
|
400
|
+
/**
|
|
401
|
+
* Why a body's host blocks are malformed, with the 1-based line it was found on.
|
|
402
|
+
*
|
|
403
|
+
* @public
|
|
404
|
+
*/
|
|
405
|
+
interface HostBlockProblem {
|
|
406
|
+
readonly line: number;
|
|
407
|
+
readonly message: string;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Keep the passages of a body's host blocks that list `target`, drop the
|
|
411
|
+
* rest, and remove every marker line. Blocks do not nest; an unclosed block,
|
|
412
|
+
* a stray close, a marker that is not on a line of its own, or an id outside
|
|
413
|
+
* `known` is a problem, and the body is not rewritten. So, until references
|
|
414
|
+
* are built, is a `pluginfinity://` link; see {@link referenceLines}.
|
|
415
|
+
*
|
|
416
|
+
* @public
|
|
417
|
+
*/
|
|
418
|
+
export declare const applyHostBlocks: (text: string, target: string, known: ReadonlyArray<string>) => {
|
|
419
|
+
readonly text: string;
|
|
420
|
+
} | {
|
|
421
|
+
readonly problem: HostBlockProblem;
|
|
422
|
+
};
|
|
423
|
+
/**
|
|
424
|
+
* The 1-based lines of a body that link to a `pluginfinity://` reference,
|
|
425
|
+
* outside fenced code and inline code spans. References are not built yet,
|
|
426
|
+
* and an unbuilt reference must never ship as text, so each is a problem.
|
|
427
|
+
*
|
|
428
|
+
* @public
|
|
429
|
+
*/
|
|
430
|
+
export declare const referenceLines: (text: string) => ReadonlyArray<number>;
|
|
130
431
|
//#endregion
|
|
131
432
|
//#region src/discovery.d.ts
|
|
132
433
|
/**
|
|
@@ -331,6 +632,165 @@ interface DoctorInput {
|
|
|
331
632
|
*/
|
|
332
633
|
export declare const runDoctor: (input: DoctorInput) => Effect.Effect<DoctorReport, never, ToolDiscovery | FileSystem.FileSystem | Path.Path>;
|
|
333
634
|
//#endregion
|
|
635
|
+
//#region src/frontmatter.d.ts
|
|
636
|
+
/**
|
|
637
|
+
* A markdown file split at its YAML frontmatter: the frontmatter text without
|
|
638
|
+
* its fences, and the body after the closing fence, unchanged.
|
|
639
|
+
*
|
|
640
|
+
* @public
|
|
641
|
+
*/
|
|
642
|
+
interface SplitMarkdown {
|
|
643
|
+
readonly frontmatter: string;
|
|
644
|
+
readonly body: string;
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Split `text` at a frontmatter block that opens on the first line with `---`
|
|
648
|
+
* and closes at the next line holding only `---`; `undefined` when there is
|
|
649
|
+
* none.
|
|
650
|
+
*
|
|
651
|
+
* @public
|
|
652
|
+
*/
|
|
653
|
+
export declare const splitFrontmatter: (text: string) => SplitMarkdown | undefined;
|
|
654
|
+
/**
|
|
655
|
+
* A field the target's field map leaves open, set on a component: the build
|
|
656
|
+
* cannot decide what to write.
|
|
657
|
+
*
|
|
658
|
+
* @public
|
|
659
|
+
*/
|
|
660
|
+
interface UnresolvedField {
|
|
661
|
+
readonly field: string;
|
|
662
|
+
readonly note: string;
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* The result of mapping a component's frontmatter onto a target: the fields
|
|
666
|
+
* to write in order, the sections to append to the body, and any fields the
|
|
667
|
+
* target cannot place.
|
|
668
|
+
*
|
|
669
|
+
* @public
|
|
670
|
+
*/
|
|
671
|
+
interface MappedFrontmatter {
|
|
672
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
673
|
+
readonly sections: ReadonlyArray<{
|
|
674
|
+
readonly field: string;
|
|
675
|
+
readonly value: unknown;
|
|
676
|
+
}>;
|
|
677
|
+
readonly unresolved: ReadonlyArray<UnresolvedField>;
|
|
678
|
+
/** Fields in the target block that are neither core fields nor the target's host fields. */
|
|
679
|
+
readonly unknown: ReadonlyArray<string>;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Map one component's frontmatter onto a target through the target's field
|
|
683
|
+
* map.
|
|
684
|
+
*
|
|
685
|
+
* @remarks
|
|
686
|
+
* The component's `targets` block for this target overlays the base fields:
|
|
687
|
+
* a core field there replaces the base value before mapping, and a host field
|
|
688
|
+
* (one of `hostFields`) is written as is. When the block sets `description`,
|
|
689
|
+
* no field is degraded into it: the author wrote that host's description.
|
|
690
|
+
*
|
|
691
|
+
* @public
|
|
692
|
+
*/
|
|
693
|
+
export declare const mapFrontmatter: (target: Target, map: Readonly<Record<string, FieldMapEntry>>, hostFields: ReadonlyArray<string>, base: Readonly<Record<string, unknown>>, block: Readonly<Record<string, unknown>>) => MappedFrontmatter;
|
|
694
|
+
/**
|
|
695
|
+
* Append each degraded field to `body` as a section: a level-two heading and
|
|
696
|
+
* the value as a bullet list, marked like the body's first bullet list (`-`
|
|
697
|
+
* when it has none), so a linter that wants one marker per document passes.
|
|
698
|
+
*
|
|
699
|
+
* @public
|
|
700
|
+
*/
|
|
701
|
+
export declare const appendSections: (body: string, sections: ReadonlyArray<{
|
|
702
|
+
readonly field: string;
|
|
703
|
+
readonly value: unknown;
|
|
704
|
+
}>) => string;
|
|
705
|
+
//#endregion
|
|
706
|
+
//#region src/hooks.d.ts
|
|
707
|
+
/**
|
|
708
|
+
* One event's hooks as a target builds them: the source event name, the
|
|
709
|
+
* target's name for it, and the entries.
|
|
710
|
+
*
|
|
711
|
+
* @public
|
|
712
|
+
*/
|
|
713
|
+
interface TargetHookEvent {
|
|
714
|
+
/** The event name as the config spells it. */
|
|
715
|
+
readonly event: string;
|
|
716
|
+
/** The target's name for the event. */
|
|
717
|
+
readonly name: string;
|
|
718
|
+
readonly entries: ReadonlyArray<HookEntry>;
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Why a target cannot build an event's hooks: the target lacks the event and
|
|
722
|
+
* an entry's `fallback` is `"fail"`, the default.
|
|
723
|
+
*
|
|
724
|
+
* @public
|
|
725
|
+
*/
|
|
726
|
+
interface UnsupportedHookEvent {
|
|
727
|
+
readonly event: string;
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* The hooks a target builds, before rendering: the base `hooks` with the
|
|
731
|
+
* target's per-event overrides applied (an override replaces the base entries
|
|
732
|
+
* for its event, and `[]` removes them), each event resolved to the target's
|
|
733
|
+
* name. An event the target lacks drops its `"omit"` entries and reports the
|
|
734
|
+
* event when any entry would fail.
|
|
735
|
+
*
|
|
736
|
+
* @public
|
|
737
|
+
*/
|
|
738
|
+
export declare const targetHooks: (target: Target, id: KnownTargetId, config: PluginfinityConfig) => {
|
|
739
|
+
readonly events: ReadonlyArray<TargetHookEvent>;
|
|
740
|
+
readonly unsupported: ReadonlyArray<UnsupportedHookEvent>;
|
|
741
|
+
};
|
|
742
|
+
/**
|
|
743
|
+
* Every `script` path the given events run.
|
|
744
|
+
*
|
|
745
|
+
* @public
|
|
746
|
+
*/
|
|
747
|
+
export declare const hookScripts: (events: ReadonlyArray<TargetHookEvent>) => ReadonlyArray<string>;
|
|
748
|
+
/**
|
|
749
|
+
* Every file the given events' `command` entries name as
|
|
750
|
+
* `${PLUGIN_ROOT}/<path>`, so the build can ship and check them as it does
|
|
751
|
+
* `script` paths.
|
|
752
|
+
*
|
|
753
|
+
* @public
|
|
754
|
+
*/
|
|
755
|
+
export declare const hookCommandFiles: (events: ReadonlyArray<TargetHookEvent>) => ReadonlyArray<string>;
|
|
756
|
+
/**
|
|
757
|
+
* The shell command a hook entry runs on a target: a `script` through `bash`
|
|
758
|
+
* (or executed directly under `scripts.invoke: "exec"`) at the target's
|
|
759
|
+
* plugin root, or a `command` with `${PLUGIN_ROOT}` spelled the target's way.
|
|
760
|
+
*
|
|
761
|
+
* @public
|
|
762
|
+
*/
|
|
763
|
+
export declare const hookCommand: (entry: HookEntry, root: string, invoke: "bash" | "exec") => string;
|
|
764
|
+
/**
|
|
765
|
+
* Render a target's hooks file as JSON text, or `undefined` when the target
|
|
766
|
+
* builds no hooks.
|
|
767
|
+
*
|
|
768
|
+
* @public
|
|
769
|
+
*/
|
|
770
|
+
export declare const renderHooks: (target: Target, events: ReadonlyArray<TargetHookEvent>, invoke: "bash" | "exec") => string | undefined;
|
|
771
|
+
//#endregion
|
|
772
|
+
//#region src/manifest.d.ts
|
|
773
|
+
/**
|
|
774
|
+
* A manifest as written: a JSON object in the target's key order.
|
|
775
|
+
*
|
|
776
|
+
* @public
|
|
777
|
+
*/
|
|
778
|
+
type Manifest = Readonly<Record<string, unknown>>;
|
|
779
|
+
/**
|
|
780
|
+
* Render a target's manifest from the config and the package version: the
|
|
781
|
+
* format's record, cut to the target's key allowlist, in allowlist order, with
|
|
782
|
+
* unset keys left out.
|
|
783
|
+
*
|
|
784
|
+
* @public
|
|
785
|
+
*/
|
|
786
|
+
export declare const renderManifest: (target: Target, id: KnownTargetId, config: PluginfinityConfig, version: string) => Manifest;
|
|
787
|
+
/**
|
|
788
|
+
* The bytes a manifest is written as: tab-indented JSON with a final newline.
|
|
789
|
+
*
|
|
790
|
+
* @public
|
|
791
|
+
*/
|
|
792
|
+
export declare const serializeManifest: (manifest: Manifest) => string;
|
|
793
|
+
//#endregion
|
|
334
794
|
//#region src/operations.d.ts
|
|
335
795
|
/**
|
|
336
796
|
* The input to `build`.
|
|
@@ -355,19 +815,102 @@ interface ValidateInput {
|
|
|
355
815
|
readonly skipHosts: boolean;
|
|
356
816
|
}
|
|
357
817
|
/**
|
|
358
|
-
*
|
|
359
|
-
*
|
|
818
|
+
* One target's build of one plugin.
|
|
819
|
+
*
|
|
820
|
+
* @public
|
|
821
|
+
*/
|
|
822
|
+
interface TargetBuild {
|
|
823
|
+
/** The config file's absolute path. */
|
|
824
|
+
readonly config: string;
|
|
825
|
+
readonly target: KnownTargetId;
|
|
826
|
+
/** The build directory: `<plugin root>/builds/<id>`. */
|
|
827
|
+
readonly out: string;
|
|
828
|
+
/** How the build directory differed before this run; empty after a write. */
|
|
829
|
+
readonly plan: EmitPlan;
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* One target's validation of one plugin.
|
|
833
|
+
*
|
|
834
|
+
* @public
|
|
835
|
+
*/
|
|
836
|
+
interface TargetValidation {
|
|
837
|
+
readonly config: string;
|
|
838
|
+
readonly target: KnownTargetId;
|
|
839
|
+
readonly out: string;
|
|
840
|
+
/** Whether the host CLI checked the build, or `--no-host` skipped it. */
|
|
841
|
+
readonly host: "passed" | "skipped";
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Every failure planning a plugin's builds can produce.
|
|
845
|
+
*
|
|
846
|
+
* @public
|
|
847
|
+
*/
|
|
848
|
+
type PlanError = PackageVersionMissing | HookEventUnsupported | HookScriptInvalid | PathConflict | ComponentsInvalid | NotImplemented | PlatformError.PlatformError;
|
|
849
|
+
/**
|
|
850
|
+
* Regenerate `builds/<id>/` for every selected plugin and target, writing
|
|
851
|
+
* only what differs. With `check`, write nothing and fail with
|
|
852
|
+
* `BuildStale` when anything differs.
|
|
853
|
+
*
|
|
854
|
+
* @public
|
|
855
|
+
*/
|
|
856
|
+
export declare const build: (input: BuildInput) => Effect.Effect<ReadonlyArray<TargetBuild>, ConfigError | PlanError | BuildStale, FileSystem.FileSystem | Path.Path>;
|
|
857
|
+
/**
|
|
858
|
+
* Validate every selected plugin and target: the build directory must match a
|
|
859
|
+
* fresh build, then each host's CLI must accept it unless `skipHosts`.
|
|
860
|
+
*
|
|
861
|
+
* @public
|
|
862
|
+
*/
|
|
863
|
+
export declare const validate: (input: ValidateInput) => Effect.Effect<ReadonlyArray<TargetValidation>, ConfigError | PlanError | BuildStale | HostRejected, FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner>;
|
|
864
|
+
//#endregion
|
|
865
|
+
//#region src/skills.d.ts
|
|
866
|
+
/**
|
|
867
|
+
* The most characters a built skill's `description` may hold: the Agent
|
|
868
|
+
* Skills spec's limit, which Copilot enforces.
|
|
869
|
+
*
|
|
870
|
+
* @public
|
|
871
|
+
*/
|
|
872
|
+
export declare const SKILL_DESCRIPTION_MAX = 1024;
|
|
873
|
+
/**
|
|
874
|
+
* One skill as read from `skills/<name>/`: its name, its decoded frontmatter,
|
|
875
|
+
* its body, and its other files.
|
|
876
|
+
*
|
|
877
|
+
* @public
|
|
878
|
+
*/
|
|
879
|
+
interface SourceSkill {
|
|
880
|
+
/** The directory name, which is the skill's name. */
|
|
881
|
+
readonly name: string;
|
|
882
|
+
/** The absolute path of its `SKILL.md`. */
|
|
883
|
+
readonly path: string;
|
|
884
|
+
readonly frontmatter: typeof SkillFrontmatter.Type;
|
|
885
|
+
/** The frontmatter as written, without its fences. */
|
|
886
|
+
readonly frontmatterText: string;
|
|
887
|
+
/** Everything after the closing frontmatter fence, unchanged. */
|
|
888
|
+
readonly body: string;
|
|
889
|
+
/** The file lines before the body. */
|
|
890
|
+
readonly bodyOffset: number;
|
|
891
|
+
/** Its other files, as `/`-separated paths relative to the skill directory, sorted. */
|
|
892
|
+
readonly files: ReadonlyArray<string>;
|
|
893
|
+
}
|
|
894
|
+
/**
|
|
895
|
+
* Read every skill under `<root>/skills/`, sorted by name; none when the
|
|
896
|
+
* directory is absent. A skill that does not decode is collected in
|
|
897
|
+
* `failures` rather than stopping the read, so one build reports them all.
|
|
360
898
|
*
|
|
361
899
|
* @public
|
|
362
900
|
*/
|
|
363
|
-
export declare const
|
|
901
|
+
export declare const readSkills: (root: string, known: ReadonlyArray<string>) => Effect.Effect<{
|
|
902
|
+
readonly skills: ReadonlyArray<SourceSkill>;
|
|
903
|
+
readonly failures: ReadonlyArray<ComponentInvalid>;
|
|
904
|
+
}, PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
364
905
|
/**
|
|
365
|
-
*
|
|
366
|
-
* `
|
|
906
|
+
* Render one skill for a target, or `undefined` when its `targets` block
|
|
907
|
+
* excludes it: `SKILL.md` with the target's frontmatter and host blocks
|
|
908
|
+
* applied, `.md` support files with host blocks applied, and every other
|
|
909
|
+
* file copied. Every file keeps its source mode.
|
|
367
910
|
*
|
|
368
911
|
* @public
|
|
369
912
|
*/
|
|
370
|
-
export declare const
|
|
913
|
+
export declare const renderSkill: (target: Target, id: string, skill: SourceSkill, known: ReadonlyArray<string>) => Effect.Effect<ReadonlyArray<EmittedFile> | undefined, ComponentInvalid | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
371
914
|
//#endregion
|
|
372
915
|
//#region src/tools.d.ts
|
|
373
916
|
/**
|
|
@@ -394,5 +937,5 @@ export declare const ToolDiscoveryLive: Layer.Layer<ToolDiscovery, never, ChildP
|
|
|
394
937
|
*/
|
|
395
938
|
export declare const ENGINE_VERSION: string;
|
|
396
939
|
//#endregion
|
|
397
|
-
export type { BuildInput, ConfigError, ConfigSelection, DoctorInput, LoadedConfig, PreparedPlugin, ValidateInput };
|
|
940
|
+
export type { BuildError, BuildInput, ConfigError, ConfigSelection, DoctorInput, EmittedFile, HostBlockProblem, LoadedConfig, Manifest, MappedFrontmatter, PlanError, PreparedPlugin, SourceAgent, SourceSkill, SplitMarkdown, TargetBuild, TargetHookEvent, TargetValidation, UnresolvedField, UnsupportedHookEvent, ValidateInput };
|
|
398
941
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { applyHostBlocks, referenceLines } from "./body.js";
|
|
2
|
+
import { BuildStale, ComponentInvalid, ComponentsInvalid, ConfigAmbiguous, ConfigInvalid, ConfigIssue, ConfigLoadFailed, ConfigNotFound, HookEventUnsupported, HookScriptInvalid, HookScriptProblem, HostRejected, NotImplemented, PackageVersionMissing, PathConflict, TargetDrift, TargetNotEnabled, UnknownTarget, isBuildError, isConfigError } from "./errors.js";
|
|
3
|
+
import { appendSections, mapFrontmatter, splitFrontmatter } from "./frontmatter.js";
|
|
4
|
+
import { readAgents, renderAgent } from "./agents.js";
|
|
2
5
|
import { CONFIG_FILE_NAMES, ConfigDiscovery } from "./discovery.js";
|
|
3
6
|
import { ConfigLoader } from "./loader.js";
|
|
4
7
|
import { preparePlugins, selectConfigPaths } from "./selection.js";
|
|
5
8
|
import { ENGINE_VERSION } from "./version.js";
|
|
6
9
|
import { CheckGroup, CheckSeverity, CheckStatus, DEFAULT_CHECK_TIMEOUT, DoctorCheck, DoctorReport, NODE_FLOOR, runDoctor } from "./doctor.js";
|
|
10
|
+
import { EmitPlan, GENERATED_MODE, applyEmit, planEmit } from "./emit.js";
|
|
11
|
+
import { hookCommand, hookCommandFiles, hookScripts, renderHooks, targetHooks } from "./hooks.js";
|
|
12
|
+
import { renderManifest, serializeManifest } from "./manifest.js";
|
|
13
|
+
import { SKILL_DESCRIPTION_MAX, readSkills, renderSkill } from "./skills.js";
|
|
7
14
|
import { build, validate } from "./operations.js";
|
|
8
15
|
import { ToolDiscoveryLive } from "./tools.js";
|
|
9
16
|
|
|
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 };
|
|
17
|
+
export { BuildStale, CONFIG_FILE_NAMES, CheckGroup, CheckSeverity, CheckStatus, ComponentInvalid, ComponentsInvalid, ConfigAmbiguous, ConfigDiscovery, ConfigInvalid, ConfigIssue, ConfigLoadFailed, ConfigLoader, ConfigNotFound, DEFAULT_CHECK_TIMEOUT, DoctorCheck, DoctorReport, ENGINE_VERSION, EmitPlan, GENERATED_MODE, HookEventUnsupported, HookScriptInvalid, HookScriptProblem, HostRejected, NODE_FLOOR, NotImplemented, PackageVersionMissing, PathConflict, SKILL_DESCRIPTION_MAX, TargetDrift, TargetNotEnabled, ToolDiscoveryLive, UnknownTarget, appendSections, applyEmit, applyHostBlocks, build, hookCommand, hookCommandFiles, hookScripts, isBuildError, isConfigError, mapFrontmatter, planEmit, preparePlugins, readAgents, readSkills, referenceLines, renderAgent, renderHooks, renderManifest, renderSkill, runDoctor, selectConfigPaths, serializeManifest, splitFrontmatter, targetHooks, validate };
|
package/loader.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConfigInvalid, ConfigIssue, ConfigLoadFailed, UnknownTarget } from "./errors.js";
|
|
2
|
+
import { BASE_CONFIG_KEYS } from "@pluginfinity/core";
|
|
2
3
|
import { Effect, Path, Schema, SchemaIssue } from "effect";
|
|
3
4
|
import { CONFIG_KEYS, KNOWN_TARGET_IDS, PluginfinityConfig, enabledTargets } from "@pluginfinity/targets";
|
|
4
5
|
import { createJiti } from "jiti";
|
|
@@ -45,7 +46,8 @@ var ConfigLoader = class {
|
|
|
45
46
|
if (unknown.length > 0) return yield* Effect.fail(new UnknownTarget({
|
|
46
47
|
path,
|
|
47
48
|
targets: unknown,
|
|
48
|
-
known: [...KNOWN_TARGET_IDS]
|
|
49
|
+
known: [...KNOWN_TARGET_IDS],
|
|
50
|
+
fields: [...BASE_CONFIG_KEYS]
|
|
49
51
|
}));
|
|
50
52
|
}
|
|
51
53
|
const config = yield* Schema.decodeUnknownEffect(PluginfinityConfig)(value, {
|