@pluginfinity/engine 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { AgentFrontmatter, FieldMapEntry, HookEntry, SkillFrontmatter, Target } from "@pluginfinity/core";
2
+ import { KnownTargetId, PluginfinityConfig } from "@pluginfinity/targets";
2
3
  import { Duration, Effect, FileSystem, Layer, Path, PlatformError, Schema } from "effect";
3
4
  import { Remediation } from "@effected/engine";
4
5
  import { ToolDiscovery } from "@effected/commands";
5
- import { KnownTargetId, PluginfinityConfig } from "@pluginfinity/targets";
6
6
  import { ChildProcessSpawner } from "effect/process";
7
7
  //#region src/emit.d.ts
8
8
  /**
@@ -26,11 +26,14 @@ interface EmittedFile {
26
26
  declare const EmitPlan_base: Schema.Class<EmitPlan, Schema.Struct<{
27
27
  /** Produced, not on disk. */
28
28
  readonly added: Schema.$Array<Schema.String>;
29
- /** On disk with other bytes or another mode. */
29
+ /** On disk with other bytes, or a copied file whose executable bit differs. */
30
30
  readonly changed: Schema.$Array<Schema.String>;
31
31
  /** On disk, no longer produced; an empty directory ends in `/`. */
32
32
  readonly removed: Schema.$Array<Schema.String>;
33
- /** On disk with the same bytes and mode; never touched, so its mtime stays. */
33
+ /**
34
+ * On disk with the same bytes and, for a copied file, the same executable
35
+ * bit; never touched, so its mtime and mode stay.
36
+ */
34
37
  readonly unchanged: Schema.$Array<Schema.String>;
35
38
  }>, {}>;
36
39
  /**
@@ -46,6 +49,10 @@ export declare class EmitPlan extends EmitPlan_base {
46
49
  /**
47
50
  * Compare `files` with what `dir` holds, reading only.
48
51
  *
52
+ * @remarks
53
+ * A file is compared by its bytes and, when it carries a source mode, by its
54
+ * executable bit alone; other permission bits never make a file changed.
55
+ *
49
56
  * @public
50
57
  */
51
58
  export declare const planEmit: (dir: string, files: ReadonlyArray<EmittedFile>) => Effect.Effect<EmitPlan, PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
@@ -72,6 +79,8 @@ declare const ConfigIssue_base: Schema.Class<ConfigIssue, Schema.Struct<{
72
79
  /** The dotted key path inside the config, `""` for the config as a whole. */
73
80
  readonly key: Schema.String;
74
81
  readonly message: Schema.String;
82
+ /** `"token"` for a body token or `pluginfinity://` link that cannot be built. */
83
+ readonly kind: Schema.optionalKey<Schema.Literal<"token">>;
75
84
  }>, {}>;
76
85
  /**
77
86
  * One problem found while decoding a config: where in the config, and what.
@@ -291,6 +300,30 @@ export declare class HookScriptInvalid extends HookScriptInvalid_base {
291
300
  get message(): string;
292
301
  get remediation(): Remediation;
293
302
  }
303
+ /**
304
+ * What is wrong with a file a server or the `files` key ships.
305
+ *
306
+ * @public
307
+ */
308
+ export declare const ShippedFileProblem: Schema.Literals<readonly ["missing", "not-executable", "directory", "outside-root", "not-normal"]>;
309
+ declare const ShippedFileInvalid_base: Schema.Class<ShippedFileInvalid, Schema.TaggedStruct<"ShippedFileInvalid", {
310
+ /** The config. */
311
+ readonly path: Schema.String;
312
+ /** The file, relative to the plugin root. */
313
+ readonly file: Schema.String;
314
+ /** What names it: `mcpServers.<name>`, `lspServers.<name>` (prefixed `<target>.` when a target override sets it) or `files`. */
315
+ readonly referencedBy: Schema.String;
316
+ readonly problem: Schema.Literals<readonly ["missing", "not-executable", "directory", "outside-root", "not-normal"]>;
317
+ }>, import("effect/Cause").YieldableError>;
318
+ /**
319
+ * A file the build must ship for a server, or because `files` lists it, cannot be shipped.
320
+ *
321
+ * @public
322
+ */
323
+ export declare class ShippedFileInvalid extends ShippedFileInvalid_base {
324
+ get message(): string;
325
+ get remediation(): Remediation;
326
+ }
294
327
  declare const PathConflict_base: Schema.Class<PathConflict, Schema.TaggedStruct<"PathConflict", {
295
328
  /** The config. */
296
329
  readonly path: Schema.String;
@@ -345,7 +378,7 @@ export declare class ComponentsInvalid extends ComponentsInvalid_base {
345
378
  *
346
379
  * @public
347
380
  */
348
- type BuildError = PackageVersionMissing | BuildStale | HostRejected | HookEventUnsupported | HookScriptInvalid | PathConflict | ComponentsInvalid;
381
+ type BuildError = PackageVersionMissing | BuildStale | HostRejected | HookEventUnsupported | HookScriptInvalid | ShippedFileInvalid | PathConflict | ComponentsInvalid;
349
382
  /**
350
383
  * Whether `error` is one of the {@link BuildError} members.
351
384
  *
@@ -353,6 +386,212 @@ type BuildError = PackageVersionMissing | BuildStale | HostRejected | HookEventU
353
386
  */
354
387
  export declare const isBuildError: (error: unknown) => error is BuildError;
355
388
  //#endregion
389
+ //#region src/notes.d.ts
390
+ /**
391
+ * Every note kind, in the order they are sorted and printed.
392
+ *
393
+ * @public
394
+ */
395
+ export declare const BUILD_NOTE_KINDS: readonly ["dropped", "degraded", "tool-dropped", "hook-omitted"];
396
+ /**
397
+ * What a target did to something it could not carry as written: `dropped` a
398
+ * field, `degraded` a field into another form (a description suffix or a body
399
+ * section), `tool-dropped` a tool it cannot name, or `hook-omitted` an event
400
+ * it lacks whose entries all set `fallback: "omit"`.
401
+ *
402
+ * @public
403
+ */
404
+ type BuildNoteKind = (typeof BUILD_NOTE_KINDS)[number];
405
+ /**
406
+ * One info-level fact about a build: something the target dropped, degraded
407
+ * or omitted. A note never fails a build.
408
+ *
409
+ * @public
410
+ */
411
+ interface BuildNote {
412
+ readonly target: KnownTargetId;
413
+ /** Plugin-relative component path (e.g. `agents/okf-docs.md`, `skills/x/SKILL.md`), or `config` for hooks and servers. */
414
+ readonly path: string;
415
+ readonly kind: BuildNoteKind;
416
+ /** The field, tool or event name, e.g. `color`, `ToolSearch`, `Notification`, `lspServers.md.diagnostics`. */
417
+ readonly name: string;
418
+ }
419
+ //#endregion
420
+ //#region src/frontmatter.d.ts
421
+ /**
422
+ * A markdown file split at its YAML frontmatter: the frontmatter text without
423
+ * its fences, and the body after the closing fence, unchanged.
424
+ *
425
+ * @public
426
+ */
427
+ interface SplitMarkdown {
428
+ readonly frontmatter: string;
429
+ readonly body: string;
430
+ }
431
+ /**
432
+ * Split `text` at a frontmatter block that opens on the first line with `---`
433
+ * and closes at the next line holding only `---`; `undefined` when there is
434
+ * none.
435
+ *
436
+ * @public
437
+ */
438
+ export declare const splitFrontmatter: (text: string) => SplitMarkdown | undefined;
439
+ /**
440
+ * The plugin's own MCP servers as a target sees them: `plugin` is the name
441
+ * Claude Code namespaces the plugin's tools with (the Claude target's `name`
442
+ * override, else the base `name`), and `servers` names every server in the
443
+ * target's merged `mcpServers`.
444
+ *
445
+ * @public
446
+ */
447
+ interface OwnMcp {
448
+ readonly plugin: string;
449
+ readonly servers: ReadonlySet<string>;
450
+ }
451
+ /**
452
+ * A field the target's field map leaves open, set on a component: the build
453
+ * cannot decide what to write.
454
+ *
455
+ * @public
456
+ */
457
+ interface UnresolvedField {
458
+ readonly field: string;
459
+ readonly note: string;
460
+ }
461
+ /**
462
+ * Something a target did not carry as written while mapping a component: a
463
+ * field it dropped or degraded, or a tool it could not name, in which case
464
+ * `field` is the tool's name.
465
+ *
466
+ * @public
467
+ */
468
+ interface FieldDrop {
469
+ readonly field: string;
470
+ readonly kind: Exclude<BuildNoteKind, "hook-omitted">;
471
+ }
472
+ /**
473
+ * The result of mapping a component's frontmatter onto a target: the fields
474
+ * to write in order, the sections to append to the body, any fields the
475
+ * target cannot place, and what it dropped or degraded.
476
+ *
477
+ * @public
478
+ */
479
+ interface MappedFrontmatter {
480
+ readonly fields: Readonly<Record<string, unknown>>;
481
+ readonly sections: ReadonlyArray<{
482
+ readonly field: string;
483
+ readonly value: unknown;
484
+ }>;
485
+ readonly unresolved: ReadonlyArray<UnresolvedField>;
486
+ /** Each field dropped or degraded and each tool dropped, once, in the order met. */
487
+ readonly drops: ReadonlyArray<FieldDrop>;
488
+ /** Fields in the target block that are neither core fields nor the target's host fields. */
489
+ readonly unknown: ReadonlyArray<string>;
490
+ }
491
+ /**
492
+ * Map one component's frontmatter onto a target through the target's field
493
+ * map.
494
+ *
495
+ * @remarks
496
+ * The component's `targets` block for this target overlays the base fields:
497
+ * a core field there replaces the base value before mapping, and a host field
498
+ * (one of `hostFields`) is written as is. `own` lets a tool of the plugin's
499
+ * own MCP server take the target's spelling. When the block sets `description`,
500
+ * no field is degraded into it: the author wrote that host's description,
501
+ * so no such field is reported in `drops`.
502
+ *
503
+ * @public
504
+ */
505
+ export declare const mapFrontmatter: (target: Target, map: Readonly<Record<string, FieldMapEntry>>, hostFields: ReadonlyArray<string>, base: Readonly<Record<string, unknown>>, block: Readonly<Record<string, unknown>>, own?: OwnMcp) => MappedFrontmatter;
506
+ /**
507
+ * Append each degraded field to `body` as a section: a level-two heading and
508
+ * the value as a bullet list, marked like the body's first bullet list (`-`
509
+ * when it has none), so a linter that wants one marker per document passes.
510
+ *
511
+ * @public
512
+ */
513
+ export declare const appendSections: (body: string, sections: ReadonlyArray<{
514
+ readonly field: string;
515
+ readonly value: unknown;
516
+ }>) => string;
517
+ //#endregion
518
+ //#region src/tokens.d.ts
519
+ /**
520
+ * What {@link renderTokens} needs to spell a plugin's tokens and links for
521
+ * one target.
522
+ *
523
+ * @public
524
+ */
525
+ interface TokenContext {
526
+ /** The target being built. */
527
+ readonly target: Target;
528
+ /**
529
+ * The plugin's name on this target: its `<target>.name` override, else
530
+ * `name`. Agent ids and skill commands are spelled with it.
531
+ */
532
+ readonly plugin: string;
533
+ /** The plugin's skill names. */
534
+ readonly skills: ReadonlySet<string>;
535
+ /** The plugin's agent names. */
536
+ readonly agents: ReadonlySet<string>;
537
+ /** Every file under a skill directory, as `<skill>/<path>`, `SKILL.md` included. */
538
+ readonly skillFiles: ReadonlySet<string>;
539
+ /**
540
+ * The plugin's own MCP servers on this target, if it declares any.
541
+ * `own.plugin` is the plugin's Claude name, which Claude Code namespaces
542
+ * MCP tools with: a body names an own tool by that name on every target,
543
+ * and the run-time MCP template's `{plugin}` is filled from it, so it can
544
+ * differ from `plugin` when the target renames the plugin.
545
+ */
546
+ readonly own: OwnMcp | undefined;
547
+ }
548
+ /**
549
+ * A token or link {@link renderTokens} could not spell, with its 1-based line.
550
+ *
551
+ * @public
552
+ */
553
+ interface TokenProblem {
554
+ readonly line: number;
555
+ readonly message: string;
556
+ }
557
+ /**
558
+ * Render a markdown body's tokens and `pluginfinity://` links for one target,
559
+ * or report every one it cannot render.
560
+ *
561
+ * @remarks
562
+ * A token is `{{tool <name>}}`, `{{agent <name>}}`, `{{skill <name>}}` or
563
+ * `{{plugin_root}}`, with whitespace allowed inside the braces, on one line.
564
+ * Tokens are replaced everywhere, fenced and inline code included; `\{{`
565
+ * before a token renders it literally, and before any other `{{` the
566
+ * backslash stays. A `{{` whose first word is not a kind is text, so
567
+ * GitHub Actions expressions, Jinja and Handlebars pass through;
568
+ * a token starts at the `{{` right before its kind, so `{{{tool Read}}}`
569
+ * keeps the outer braces. A known kind that cannot be spelled is a problem:
570
+ * a missing or extra argument, a token never closed on its line, or a brace
571
+ * inside one.
572
+ *
573
+ * An inline markdown link to `pluginfinity://skill/<skill>[/<path>][#anchor]`
574
+ * or `pluginfinity://agent/<agent>` outside fenced and inline code is built in
575
+ * the target's reference style; inside code it stays text. A path style keeps
576
+ * the anchor; a prose style drops it. Any other `pluginfinity://` outside
577
+ * code, in any case (a title, an image, a reference definition, an autolink),
578
+ * is a problem rather than shipped.
579
+ *
580
+ * Known limits: an indented (four-space) code block is not treated as code,
581
+ * an inline code span across two lines is not recognised, and an escaped
582
+ * `\[text](pluginfinity://…)` is still built and keeps its backslash.
583
+ *
584
+ * Run it after host blocks are applied, so a token in another target's block
585
+ * is never evaluated. The result is a pure function of its inputs.
586
+ *
587
+ * @public
588
+ */
589
+ export declare const renderTokens: (text: string, ctx: TokenContext) => {
590
+ readonly text: string;
591
+ } | {
592
+ readonly problems: ReadonlyArray<TokenProblem>;
593
+ };
594
+ //#endregion
356
595
  //#region src/agents.d.ts
357
596
  /**
358
597
  * One agent as read from `agents/<name>.md`: its name, its decoded
@@ -386,15 +625,27 @@ export declare const readAgents: (root: string, known: ReadonlyArray<string>) =>
386
625
  readonly agents: ReadonlyArray<SourceAgent>;
387
626
  readonly failures: ReadonlyArray<ComponentInvalid>;
388
627
  }, PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
628
+ /**
629
+ * An agent rendered for a target: its file, and what the target dropped or
630
+ * degraded from its frontmatter.
631
+ *
632
+ * @public
633
+ */
634
+ interface RenderedAgent {
635
+ readonly file: EmittedFile;
636
+ /** Each about `agents/<name>.md`, in the order met. */
637
+ readonly notes: ReadonlyArray<BuildNote>;
638
+ }
389
639
  /**
390
640
  * Render one agent for a target, or `undefined` when its `targets` block
391
641
  * 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.
642
+ * target's frontmatter, host blocks and then body tokens applied, and
643
+ * degraded fields appended as body sections. It keeps its source mode. A
644
+ * token problem is keyed by its file line and names the target.
394
645
  *
395
646
  * @public
396
647
  */
397
- export declare const renderAgent: (target: Target, id: string, agent: SourceAgent, known: ReadonlyArray<string>) => Effect.Effect<EmittedFile | undefined, ComponentInvalid | PlatformError.PlatformError, FileSystem.FileSystem>;
648
+ export declare const renderAgent: (target: Target, id: KnownTargetId, agent: SourceAgent, known: ReadonlyArray<string>, tokens: TokenContext) => Effect.Effect<RenderedAgent | undefined, ComponentInvalid | PlatformError.PlatformError, FileSystem.FileSystem>;
398
649
  //#endregion
399
650
  //#region src/body.d.ts
400
651
  /**
@@ -410,8 +661,8 @@ interface HostBlockProblem {
410
661
  * Keep the passages of a body's host blocks that list `target`, drop the
411
662
  * rest, and remove every marker line. Blocks do not nest; an unclosed block,
412
663
  * 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}.
664
+ * `known` is a problem, and the body is not rewritten. Tokens and
665
+ * `pluginfinity://` links are left for {@link renderTokens}, which runs after.
415
666
  *
416
667
  * @public
417
668
  */
@@ -420,14 +671,6 @@ export declare const applyHostBlocks: (text: string, target: string, known: Read
420
671
  } | {
421
672
  readonly problem: HostBlockProblem;
422
673
  };
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>;
431
674
  //#endregion
432
675
  //#region src/discovery.d.ts
433
676
  /**
@@ -632,77 +875,6 @@ interface DoctorInput {
632
875
  */
633
876
  export declare const runDoctor: (input: DoctorInput) => Effect.Effect<DoctorReport, never, ToolDiscovery | FileSystem.FileSystem | Path.Path>;
634
877
  //#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
878
  //#region src/hooks.d.ts
707
879
  /**
708
880
  * One event's hooks as a target builds them: the source event name, the
@@ -730,14 +902,17 @@ interface UnsupportedHookEvent {
730
902
  * The hooks a target builds, before rendering: the base `hooks` with the
731
903
  * target's per-event overrides applied (an override replaces the base entries
732
904
  * 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.
905
+ * name. An event the target lacks is omitted, and listed in `omitted`, when
906
+ * every entry sets `fallback: "omit"`; when any entry would fail, the event
907
+ * is reported in `unsupported`.
735
908
  *
736
909
  * @public
737
910
  */
738
911
  export declare const targetHooks: (target: Target, id: KnownTargetId, config: PluginfinityConfig) => {
739
912
  readonly events: ReadonlyArray<TargetHookEvent>;
740
913
  readonly unsupported: ReadonlyArray<UnsupportedHookEvent>;
914
+ /** Source event names the target lacks whose every entry sets `fallback: "omit"`. */
915
+ readonly omitted: ReadonlyArray<string>;
741
916
  };
742
917
  /**
743
918
  * Every `script` path the given events run.
@@ -761,6 +936,20 @@ export declare const hookCommandFiles: (events: ReadonlyArray<TargetHookEvent>)
761
936
  * @public
762
937
  */
763
938
  export declare const hookCommand: (entry: HookEntry, root: string, invoke: "bash" | "exec") => string;
939
+ /**
940
+ * A `script` entry in exec form, for a host that spawns `command` with `args`
941
+ * and no shell: `bash` with the script path as its first argument, or under
942
+ * `scripts.invoke: "exec"` the script itself. The root placeholder is
943
+ * substituted by the host in `args`, and no shell ever parses the path.
944
+ *
945
+ * @public
946
+ */
947
+ export declare const hookExec: (entry: Extract<HookEntry, {
948
+ readonly script: string;
949
+ }>, root: string, invoke: "bash" | "exec") => {
950
+ readonly command: string;
951
+ readonly args: ReadonlyArray<string>;
952
+ };
764
953
  /**
765
954
  * Render a target's hooks file as JSON text, or `undefined` when the target
766
955
  * builds no hooks.
@@ -827,6 +1016,8 @@ interface TargetBuild {
827
1016
  readonly out: string;
828
1017
  /** How the build directory differed before this run; empty after a write. */
829
1018
  readonly plan: EmitPlan;
1019
+ /** What the target dropped, degraded or omitted, sorted by path (the config last), then kind, then name. */
1020
+ readonly notes: ReadonlyArray<BuildNote>;
830
1021
  }
831
1022
  /**
832
1023
  * One target's validation of one plugin.
@@ -839,13 +1030,15 @@ interface TargetValidation {
839
1030
  readonly out: string;
840
1031
  /** Whether the host CLI checked the build, or `--no-host` skipped it. */
841
1032
  readonly host: "passed" | "skipped";
1033
+ /** The same notes `build` reports for the target. */
1034
+ readonly notes: ReadonlyArray<BuildNote>;
842
1035
  }
843
1036
  /**
844
1037
  * Every failure planning a plugin's builds can produce.
845
1038
  *
846
1039
  * @public
847
1040
  */
848
- type PlanError = PackageVersionMissing | HookEventUnsupported | HookScriptInvalid | PathConflict | ComponentsInvalid | NotImplemented | PlatformError.PlatformError;
1041
+ type PlanError = PackageVersionMissing | HookEventUnsupported | HookScriptInvalid | ShippedFileInvalid | PathConflict | ComponentsInvalid | PlatformError.PlatformError;
849
1042
  /**
850
1043
  * Regenerate `builds/<id>/` for every selected plugin and target, writing
851
1044
  * only what differs. With `check`, write nothing and fail with
@@ -862,6 +1055,55 @@ export declare const build: (input: BuildInput) => Effect.Effect<ReadonlyArray<T
862
1055
  */
863
1056
  export declare const validate: (input: ValidateInput) => Effect.Effect<ReadonlyArray<TargetValidation>, ConfigError | PlanError | BuildStale | HostRejected, FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner>;
864
1057
  //#endregion
1058
+ //#region src/servers.d.ts
1059
+ /**
1060
+ * A target's server config files, the problems that stop it building them,
1061
+ * whether any server is a local process that needs the server library, and
1062
+ * the server fields the target dropped.
1063
+ *
1064
+ * @public
1065
+ */
1066
+ interface ServerRender {
1067
+ readonly files: ReadonlyArray<EmittedFile>;
1068
+ readonly issues: ReadonlyArray<ConfigIssue>;
1069
+ readonly stdio: boolean;
1070
+ /** Each LSP field dropped, as a `config` note named `<origin>.<server>.<field>`, in the order met. */
1071
+ readonly notes: ReadonlyArray<BuildNote>;
1072
+ }
1073
+ /**
1074
+ * The target's MCP and LSP config files: base servers with the target's
1075
+ * overrides applied by name, `${PLUGIN_ROOT}` rewritten to the target's
1076
+ * spelling, LSP fields mapped through the target's field map, and the
1077
+ * server-library variables added to every local server's `env`.
1078
+ *
1079
+ * @public
1080
+ */
1081
+ export declare const renderServers: (target: Target, id: KnownTargetId, config: PluginfinityConfig, plugin: string, libDir: string) => ServerRender;
1082
+ /**
1083
+ * The plugin files a target's servers name after `${PLUGIN_ROOT}/`.
1084
+ *
1085
+ * @public
1086
+ */
1087
+ interface ServerFiles {
1088
+ /** Paths a whole `command` names; they must be executable. */
1089
+ readonly commands: ReadonlyArray<string>;
1090
+ /** Every other path a server names: a file, or a directory whose files all ship. */
1091
+ readonly others: ReadonlyArray<string>;
1092
+ /**
1093
+ * Each path's first naming server, as `mcpServers.<name>` or `lspServers.<name>`,
1094
+ * prefixed with the target for a server a target override sets, as `copilot.mcpServers.<name>`.
1095
+ */
1096
+ readonly owners: ReadonlyMap<string, string>;
1097
+ }
1098
+ /**
1099
+ * The plugin files a target's servers name after `${PLUGIN_ROOT}/`: those a
1100
+ * whole `command` names, which must be executable, and every other one.
1101
+ * Only the fields the root placeholder is documented in are scanned.
1102
+ *
1103
+ * @public
1104
+ */
1105
+ export declare const serverFiles: (target: Target, id: KnownTargetId, config: PluginfinityConfig) => ServerFiles;
1106
+ //#endregion
865
1107
  //#region src/skills.d.ts
866
1108
  /**
867
1109
  * The most characters a built skill's `description` may hold: the Agent
@@ -902,15 +1144,31 @@ export declare const readSkills: (root: string, known: ReadonlyArray<string>) =>
902
1144
  readonly skills: ReadonlyArray<SourceSkill>;
903
1145
  readonly failures: ReadonlyArray<ComponentInvalid>;
904
1146
  }, PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
1147
+ /**
1148
+ * A skill rendered for a target: its files, and what the target dropped or
1149
+ * degraded from its frontmatter.
1150
+ *
1151
+ * @public
1152
+ */
1153
+ interface RenderedSkill {
1154
+ readonly files: ReadonlyArray<EmittedFile>;
1155
+ /** Each about `skills/<name>/SKILL.md`, in the order met. */
1156
+ readonly notes: ReadonlyArray<BuildNote>;
1157
+ }
905
1158
  /**
906
1159
  * 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.
1160
+ * excludes it: `SKILL.md` with the target's frontmatter, then host blocks
1161
+ * and body tokens applied, `.md` support files with host blocks and tokens
1162
+ * applied, and every other file copied. Every file keeps its source mode.
1163
+ *
1164
+ * @remarks
1165
+ * Fails with one `ComponentInvalid` when one file has problems, and with a
1166
+ * `ComponentsInvalid` holding one per file when several do. A token problem
1167
+ * is keyed by its file line and names the target.
910
1168
  *
911
1169
  * @public
912
1170
  */
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>;
1171
+ export declare const renderSkill: (target: Target, id: KnownTargetId, skill: SourceSkill, known: ReadonlyArray<string>, tokens: TokenContext) => Effect.Effect<RenderedSkill | undefined, ComponentInvalid | ComponentsInvalid | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
914
1172
  //#endregion
915
1173
  //#region src/tools.d.ts
916
1174
  /**
@@ -937,5 +1195,5 @@ export declare const ToolDiscoveryLive: Layer.Layer<ToolDiscovery, never, ChildP
937
1195
  */
938
1196
  export declare const ENGINE_VERSION: string;
939
1197
  //#endregion
940
- export type { BuildError, BuildInput, ConfigError, ConfigSelection, DoctorInput, EmittedFile, HostBlockProblem, LoadedConfig, Manifest, MappedFrontmatter, PlanError, PreparedPlugin, SourceAgent, SourceSkill, SplitMarkdown, TargetBuild, TargetHookEvent, TargetValidation, UnresolvedField, UnsupportedHookEvent, ValidateInput };
1198
+ export type { BuildError, BuildInput, BuildNote, BuildNoteKind, ConfigError, ConfigSelection, DoctorInput, EmittedFile, FieldDrop, HostBlockProblem, LoadedConfig, Manifest, MappedFrontmatter, OwnMcp, PlanError, PreparedPlugin, RenderedAgent, RenderedSkill, ServerFiles, ServerRender, SourceAgent, SourceSkill, SplitMarkdown, TargetBuild, TargetHookEvent, TargetValidation, TokenContext, TokenProblem, UnresolvedField, UnsupportedHookEvent, ValidateInput };
941
1199
  //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -1,6 +1,7 @@
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";
1
+ import { applyHostBlocks } from "./body.js";
2
+ import { BuildStale, ComponentInvalid, ComponentsInvalid, ConfigAmbiguous, ConfigInvalid, ConfigIssue, ConfigLoadFailed, ConfigNotFound, HookEventUnsupported, HookScriptInvalid, HookScriptProblem, HostRejected, NotImplemented, PackageVersionMissing, PathConflict, ShippedFileInvalid, ShippedFileProblem, TargetDrift, TargetNotEnabled, UnknownTarget, isBuildError, isConfigError } from "./errors.js";
3
3
  import { appendSections, mapFrontmatter, splitFrontmatter } from "./frontmatter.js";
4
+ import { renderTokens } from "./tokens.js";
4
5
  import { readAgents, renderAgent } from "./agents.js";
5
6
  import { CONFIG_FILE_NAMES, ConfigDiscovery } from "./discovery.js";
6
7
  import { ConfigLoader } from "./loader.js";
@@ -8,10 +9,12 @@ import { preparePlugins, selectConfigPaths } from "./selection.js";
8
9
  import { ENGINE_VERSION } from "./version.js";
9
10
  import { CheckGroup, CheckSeverity, CheckStatus, DEFAULT_CHECK_TIMEOUT, DoctorCheck, DoctorReport, NODE_FLOOR, runDoctor } from "./doctor.js";
10
11
  import { EmitPlan, GENERATED_MODE, applyEmit, planEmit } from "./emit.js";
11
- import { hookCommand, hookCommandFiles, hookScripts, renderHooks, targetHooks } from "./hooks.js";
12
+ import { hookCommand, hookCommandFiles, hookExec, hookScripts, renderHooks, targetHooks } from "./hooks.js";
12
13
  import { renderManifest, serializeManifest } from "./manifest.js";
14
+ import { BUILD_NOTE_KINDS } from "./notes.js";
15
+ import { renderServers, serverFiles } from "./servers.js";
13
16
  import { SKILL_DESCRIPTION_MAX, readSkills, renderSkill } from "./skills.js";
14
17
  import { build, validate } from "./operations.js";
15
18
  import { ToolDiscoveryLive } from "./tools.js";
16
19
 
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 };
20
+ export { BUILD_NOTE_KINDS, 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, ShippedFileInvalid, ShippedFileProblem, TargetDrift, TargetNotEnabled, ToolDiscoveryLive, UnknownTarget, appendSections, applyEmit, applyHostBlocks, build, hookCommand, hookCommandFiles, hookExec, hookScripts, isBuildError, isConfigError, mapFrontmatter, planEmit, preparePlugins, readAgents, readSkills, renderAgent, renderHooks, renderManifest, renderServers, renderSkill, renderTokens, runDoctor, selectConfigPaths, serializeManifest, serverFiles, splitFrontmatter, targetHooks, validate };
package/manifest.js CHANGED
@@ -42,4 +42,4 @@ const renderManifest = (target, id, config, version) => {
42
42
  const serializeManifest = (manifest) => `${JSON.stringify(manifest, null, " ")}\n`;
43
43
 
44
44
  //#endregion
45
- export { renderManifest, serializeManifest };
45
+ export { pluginName, renderManifest, serializeManifest };
package/notes.js ADDED
@@ -0,0 +1,29 @@
1
+ //#region src/notes.ts
2
+ /**
3
+ * Every note kind, in the order they are sorted and printed.
4
+ *
5
+ * @public
6
+ */
7
+ const BUILD_NOTE_KINDS = [
8
+ "dropped",
9
+ "degraded",
10
+ "tool-dropped",
11
+ "hook-omitted"
12
+ ];
13
+ /** The path of notes about the config: hooks and servers. */
14
+ const CONFIG_NOTE_PATH = "config";
15
+ const compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
16
+ const order = (a, b) => Number(a.path === "config") - Number(b.path === "config") || compare(a.path, b.path) || BUILD_NOTE_KINDS.indexOf(a.kind) - BUILD_NOTE_KINDS.indexOf(b.kind) || compare(a.name, b.name);
17
+ /** The notes without duplicates, sorted by path (the config last), then kind, then name. */
18
+ const sortNotes = (notes) => {
19
+ const seen = /* @__PURE__ */ new Set();
20
+ return notes.filter((note) => {
21
+ const key = `${note.target}\0${note.path}\0${note.kind}\0${note.name}`;
22
+ if (seen.has(key)) return false;
23
+ seen.add(key);
24
+ return true;
25
+ }).sort(order);
26
+ };
27
+
28
+ //#endregion
29
+ export { BUILD_NOTE_KINDS, CONFIG_NOTE_PATH, sortNotes };