@pluginfinity/engine 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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,15 +300,43 @@ 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;
297
330
  readonly target: Schema.String;
298
331
  /** The build path both claim, relative to `builds/<target>/`. */
299
332
  readonly file: Schema.String;
333
+ /** Why the path is taken: a generated file, a reserved library directory, or a reserved server file. */
334
+ readonly conflict: Schema.Literals<readonly ["generated", "reserved-dir", "reserved-server-file"]>;
300
335
  }>, import("effect/Cause").YieldableError>;
301
336
  /**
302
- * A copied source file and a generated file would land on the same build path.
337
+ * A copied source file would land on a path pluginfinity owns: a file it
338
+ * generates, a directory it reserves for an injected library, or a server
339
+ * config file the host loads beside servers written inline.
303
340
  *
304
341
  * @public
305
342
  */
@@ -345,7 +382,7 @@ export declare class ComponentsInvalid extends ComponentsInvalid_base {
345
382
  *
346
383
  * @public
347
384
  */
348
- type BuildError = PackageVersionMissing | BuildStale | HostRejected | HookEventUnsupported | HookScriptInvalid | PathConflict | ComponentsInvalid;
385
+ type BuildError = PackageVersionMissing | BuildStale | HostRejected | HookEventUnsupported | HookScriptInvalid | ShippedFileInvalid | PathConflict | ComponentsInvalid;
349
386
  /**
350
387
  * Whether `error` is one of the {@link BuildError} members.
351
388
  *
@@ -353,6 +390,212 @@ type BuildError = PackageVersionMissing | BuildStale | HostRejected | HookEventU
353
390
  */
354
391
  export declare const isBuildError: (error: unknown) => error is BuildError;
355
392
  //#endregion
393
+ //#region src/notes.d.ts
394
+ /**
395
+ * Every note kind, in the order they are sorted and printed.
396
+ *
397
+ * @public
398
+ */
399
+ export declare const BUILD_NOTE_KINDS: readonly ["dropped", "degraded", "tool-dropped", "hook-omitted"];
400
+ /**
401
+ * What a target did to something it could not carry as written: `dropped` a
402
+ * field, `degraded` a field into another form (a description suffix or a body
403
+ * section), `tool-dropped` a tool it cannot name, or `hook-omitted` an event
404
+ * it lacks whose entries all set `fallback: "omit"`.
405
+ *
406
+ * @public
407
+ */
408
+ type BuildNoteKind = (typeof BUILD_NOTE_KINDS)[number];
409
+ /**
410
+ * One info-level fact about a build: something the target dropped, degraded
411
+ * or omitted. A note never fails a build.
412
+ *
413
+ * @public
414
+ */
415
+ interface BuildNote {
416
+ readonly target: KnownTargetId;
417
+ /** Plugin-relative component path (e.g. `agents/okf-docs.md`, `skills/x/SKILL.md`), or `config` for hooks and servers. */
418
+ readonly path: string;
419
+ readonly kind: BuildNoteKind;
420
+ /** The field, tool or event name, e.g. `color`, `ToolSearch`, `Notification`, `lspServers.md.diagnostics`. */
421
+ readonly name: string;
422
+ }
423
+ //#endregion
424
+ //#region src/frontmatter.d.ts
425
+ /**
426
+ * A markdown file split at its YAML frontmatter: the frontmatter text without
427
+ * its fences, and the body after the closing fence, unchanged.
428
+ *
429
+ * @public
430
+ */
431
+ interface SplitMarkdown {
432
+ readonly frontmatter: string;
433
+ readonly body: string;
434
+ }
435
+ /**
436
+ * Split `text` at a frontmatter block that opens on the first line with `---`
437
+ * and closes at the next line holding only `---`; `undefined` when there is
438
+ * none.
439
+ *
440
+ * @public
441
+ */
442
+ export declare const splitFrontmatter: (text: string) => SplitMarkdown | undefined;
443
+ /**
444
+ * The plugin's own MCP servers as a target sees them: `plugin` is the name
445
+ * Claude Code namespaces the plugin's tools with (the Claude target's `name`
446
+ * override, else the base `name`), and `servers` names every server in the
447
+ * target's merged `mcpServers`.
448
+ *
449
+ * @public
450
+ */
451
+ interface OwnMcp {
452
+ readonly plugin: string;
453
+ readonly servers: ReadonlySet<string>;
454
+ }
455
+ /**
456
+ * A field the target's field map leaves open, set on a component: the build
457
+ * cannot decide what to write.
458
+ *
459
+ * @public
460
+ */
461
+ interface UnresolvedField {
462
+ readonly field: string;
463
+ readonly note: string;
464
+ }
465
+ /**
466
+ * Something a target did not carry as written while mapping a component: a
467
+ * field it dropped or degraded, or a tool it could not name, in which case
468
+ * `field` is the tool's name.
469
+ *
470
+ * @public
471
+ */
472
+ interface FieldDrop {
473
+ readonly field: string;
474
+ readonly kind: Exclude<BuildNoteKind, "hook-omitted">;
475
+ }
476
+ /**
477
+ * The result of mapping a component's frontmatter onto a target: the fields
478
+ * to write in order, the sections to append to the body, any fields the
479
+ * target cannot place, and what it dropped or degraded.
480
+ *
481
+ * @public
482
+ */
483
+ interface MappedFrontmatter {
484
+ readonly fields: Readonly<Record<string, unknown>>;
485
+ readonly sections: ReadonlyArray<{
486
+ readonly field: string;
487
+ readonly value: unknown;
488
+ }>;
489
+ readonly unresolved: ReadonlyArray<UnresolvedField>;
490
+ /** Each field dropped or degraded and each tool dropped, once, in the order met. */
491
+ readonly drops: ReadonlyArray<FieldDrop>;
492
+ /** Fields in the target block that are neither core fields nor the target's host fields. */
493
+ readonly unknown: ReadonlyArray<string>;
494
+ }
495
+ /**
496
+ * Map one component's frontmatter onto a target through the target's field
497
+ * map.
498
+ *
499
+ * @remarks
500
+ * The component's `targets` block for this target overlays the base fields:
501
+ * a core field there replaces the base value before mapping, and a host field
502
+ * (one of `hostFields`) is written as is. `own` lets a tool of the plugin's
503
+ * own MCP server take the target's spelling. When the block sets `description`,
504
+ * no field is degraded into it: the author wrote that host's description,
505
+ * so no such field is reported in `drops`.
506
+ *
507
+ * @public
508
+ */
509
+ 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;
510
+ /**
511
+ * Append each degraded field to `body` as a section: a level-two heading and
512
+ * the value as a bullet list, marked like the body's first bullet list (`-`
513
+ * when it has none), so a linter that wants one marker per document passes.
514
+ *
515
+ * @public
516
+ */
517
+ export declare const appendSections: (body: string, sections: ReadonlyArray<{
518
+ readonly field: string;
519
+ readonly value: unknown;
520
+ }>) => string;
521
+ //#endregion
522
+ //#region src/tokens.d.ts
523
+ /**
524
+ * What {@link renderTokens} needs to spell a plugin's tokens and links for
525
+ * one target.
526
+ *
527
+ * @public
528
+ */
529
+ interface TokenContext {
530
+ /** The target being built. */
531
+ readonly target: Target;
532
+ /**
533
+ * The plugin's name on this target: its `<target>.name` override, else
534
+ * `name`. Agent ids and skill commands are spelled with it.
535
+ */
536
+ readonly plugin: string;
537
+ /** The plugin's skill names. */
538
+ readonly skills: ReadonlySet<string>;
539
+ /** The plugin's agent names. */
540
+ readonly agents: ReadonlySet<string>;
541
+ /** Every file under a skill directory, as `<skill>/<path>`, `SKILL.md` included. */
542
+ readonly skillFiles: ReadonlySet<string>;
543
+ /**
544
+ * The plugin's own MCP servers on this target, if it declares any.
545
+ * `own.plugin` is the plugin's Claude name, which Claude Code namespaces
546
+ * MCP tools with: a body names an own tool by that name on every target,
547
+ * and the run-time MCP template's `{plugin}` is filled from it, so it can
548
+ * differ from `plugin` when the target renames the plugin.
549
+ */
550
+ readonly own: OwnMcp | undefined;
551
+ }
552
+ /**
553
+ * A token or link {@link renderTokens} could not spell, with its 1-based line.
554
+ *
555
+ * @public
556
+ */
557
+ interface TokenProblem {
558
+ readonly line: number;
559
+ readonly message: string;
560
+ }
561
+ /**
562
+ * Render a markdown body's tokens and `pluginfinity://` links for one target,
563
+ * or report every one it cannot render.
564
+ *
565
+ * @remarks
566
+ * A token is `{{tool <name>}}`, `{{agent <name>}}`, `{{skill <name>}}` or
567
+ * `{{plugin_root}}`, with whitespace allowed inside the braces, on one line.
568
+ * Tokens are replaced everywhere, fenced and inline code included; `\{{`
569
+ * before a token renders it literally, and before any other `{{` the
570
+ * backslash stays. A `{{` whose first word is not a kind is text, so
571
+ * GitHub Actions expressions, Jinja and Handlebars pass through;
572
+ * a token starts at the `{{` right before its kind, so `{{{tool Read}}}`
573
+ * keeps the outer braces. A known kind that cannot be spelled is a problem:
574
+ * a missing or extra argument, a token never closed on its line, or a brace
575
+ * inside one.
576
+ *
577
+ * An inline markdown link to `pluginfinity://skill/<skill>[/<path>][#anchor]`
578
+ * or `pluginfinity://agent/<agent>` outside fenced and inline code is built in
579
+ * the target's reference style; inside code it stays text. A path style keeps
580
+ * the anchor; a prose style drops it. Any other `pluginfinity://` outside
581
+ * code, in any case (a title, an image, a reference definition, an autolink),
582
+ * is a problem rather than shipped.
583
+ *
584
+ * Known limits: an indented (four-space) code block is not treated as code,
585
+ * an inline code span across two lines is not recognised, and an escaped
586
+ * `\[text](pluginfinity://…)` is still built and keeps its backslash.
587
+ *
588
+ * Run it after host blocks are applied, so a token in another target's block
589
+ * is never evaluated. The result is a pure function of its inputs.
590
+ *
591
+ * @public
592
+ */
593
+ export declare const renderTokens: (text: string, ctx: TokenContext) => {
594
+ readonly text: string;
595
+ } | {
596
+ readonly problems: ReadonlyArray<TokenProblem>;
597
+ };
598
+ //#endregion
356
599
  //#region src/agents.d.ts
357
600
  /**
358
601
  * One agent as read from `agents/<name>.md`: its name, its decoded
@@ -386,15 +629,27 @@ export declare const readAgents: (root: string, known: ReadonlyArray<string>) =>
386
629
  readonly agents: ReadonlyArray<SourceAgent>;
387
630
  readonly failures: ReadonlyArray<ComponentInvalid>;
388
631
  }, PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
632
+ /**
633
+ * An agent rendered for a target: its file, and what the target dropped or
634
+ * degraded from its frontmatter.
635
+ *
636
+ * @public
637
+ */
638
+ interface RenderedAgent {
639
+ readonly file: EmittedFile;
640
+ /** Each about `agents/<name>.md`, in the order met. */
641
+ readonly notes: ReadonlyArray<BuildNote>;
642
+ }
389
643
  /**
390
644
  * Render one agent for a target, or `undefined` when its `targets` block
391
645
  * 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.
646
+ * target's frontmatter, host blocks and then body tokens applied, and
647
+ * degraded fields appended as body sections. It keeps its source mode. A
648
+ * token problem is keyed by its file line and names the target.
394
649
  *
395
650
  * @public
396
651
  */
397
- export declare const renderAgent: (target: Target, id: string, agent: SourceAgent, known: ReadonlyArray<string>) => Effect.Effect<EmittedFile | undefined, ComponentInvalid | PlatformError.PlatformError, FileSystem.FileSystem>;
652
+ 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
653
  //#endregion
399
654
  //#region src/body.d.ts
400
655
  /**
@@ -410,8 +665,8 @@ interface HostBlockProblem {
410
665
  * Keep the passages of a body's host blocks that list `target`, drop the
411
666
  * rest, and remove every marker line. Blocks do not nest; an unclosed block,
412
667
  * 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}.
668
+ * `known` is a problem, and the body is not rewritten. Tokens and
669
+ * `pluginfinity://` links are left for {@link renderTokens}, which runs after.
415
670
  *
416
671
  * @public
417
672
  */
@@ -420,14 +675,6 @@ export declare const applyHostBlocks: (text: string, target: string, known: Read
420
675
  } | {
421
676
  readonly problem: HostBlockProblem;
422
677
  };
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
678
  //#endregion
432
679
  //#region src/discovery.d.ts
433
680
  /**
@@ -632,77 +879,6 @@ interface DoctorInput {
632
879
  */
633
880
  export declare const runDoctor: (input: DoctorInput) => Effect.Effect<DoctorReport, never, ToolDiscovery | FileSystem.FileSystem | Path.Path>;
634
881
  //#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
882
  //#region src/hooks.d.ts
707
883
  /**
708
884
  * One event's hooks as a target builds them: the source event name, the
@@ -730,14 +906,17 @@ interface UnsupportedHookEvent {
730
906
  * The hooks a target builds, before rendering: the base `hooks` with the
731
907
  * target's per-event overrides applied (an override replaces the base entries
732
908
  * 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.
909
+ * name. An event the target lacks is omitted, and listed in `omitted`, when
910
+ * every entry sets `fallback: "omit"`; when any entry would fail, the event
911
+ * is reported in `unsupported`.
735
912
  *
736
913
  * @public
737
914
  */
738
915
  export declare const targetHooks: (target: Target, id: KnownTargetId, config: PluginfinityConfig) => {
739
916
  readonly events: ReadonlyArray<TargetHookEvent>;
740
917
  readonly unsupported: ReadonlyArray<UnsupportedHookEvent>;
918
+ /** Source event names the target lacks whose every entry sets `fallback: "omit"`. */
919
+ readonly omitted: ReadonlyArray<string>;
741
920
  };
742
921
  /**
743
922
  * Every `script` path the given events run.
@@ -791,13 +970,14 @@ export declare const renderHooks: (target: Target, events: ReadonlyArray<TargetH
791
970
  */
792
971
  type Manifest = Readonly<Record<string, unknown>>;
793
972
  /**
794
- * Render a target's manifest from the config and the package version: the
795
- * format's record, cut to the target's key allowlist, in allowlist order, with
796
- * unset keys left out.
973
+ * Render a target's manifest from the config, the package version and the
974
+ * server maps the target places in its manifest (`ServerRender.manifest`):
975
+ * the format's record, cut to the target's key allowlist, in allowlist order,
976
+ * with unset keys left out.
797
977
  *
798
978
  * @public
799
979
  */
800
- export declare const renderManifest: (target: Target, id: KnownTargetId, config: PluginfinityConfig, version: string) => Manifest;
980
+ export declare const renderManifest: (target: Target, id: KnownTargetId, config: PluginfinityConfig, version: string, servers?: Readonly<Record<string, unknown>>) => Manifest;
801
981
  /**
802
982
  * The bytes a manifest is written as: tab-indented JSON with a final newline.
803
983
  *
@@ -841,6 +1021,8 @@ interface TargetBuild {
841
1021
  readonly out: string;
842
1022
  /** How the build directory differed before this run; empty after a write. */
843
1023
  readonly plan: EmitPlan;
1024
+ /** What the target dropped, degraded or omitted, sorted by path (the config last), then kind, then name. */
1025
+ readonly notes: ReadonlyArray<BuildNote>;
844
1026
  }
845
1027
  /**
846
1028
  * One target's validation of one plugin.
@@ -853,13 +1035,15 @@ interface TargetValidation {
853
1035
  readonly out: string;
854
1036
  /** Whether the host CLI checked the build, or `--no-host` skipped it. */
855
1037
  readonly host: "passed" | "skipped";
1038
+ /** The same notes `build` reports for the target. */
1039
+ readonly notes: ReadonlyArray<BuildNote>;
856
1040
  }
857
1041
  /**
858
1042
  * Every failure planning a plugin's builds can produce.
859
1043
  *
860
1044
  * @public
861
1045
  */
862
- type PlanError = PackageVersionMissing | HookEventUnsupported | HookScriptInvalid | PathConflict | ComponentsInvalid | NotImplemented | PlatformError.PlatformError;
1046
+ type PlanError = PackageVersionMissing | HookEventUnsupported | HookScriptInvalid | ShippedFileInvalid | PathConflict | ComponentsInvalid | PlatformError.PlatformError;
863
1047
  /**
864
1048
  * Regenerate `builds/<id>/` for every selected plugin and target, writing
865
1049
  * only what differs. With `check`, write nothing and fail with
@@ -876,6 +1060,61 @@ export declare const build: (input: BuildInput) => Effect.Effect<ReadonlyArray<T
876
1060
  */
877
1061
  export declare const validate: (input: ValidateInput) => Effect.Effect<ReadonlyArray<TargetValidation>, ConfigError | PlanError | BuildStale | HostRejected, FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner>;
878
1062
  //#endregion
1063
+ //#region src/servers.d.ts
1064
+ /**
1065
+ * A target's server config files, the server maps it writes inline in its
1066
+ * manifest, the problems that stop it building them, whether any server is a
1067
+ * local process that needs the server library, and the server fields the
1068
+ * target dropped.
1069
+ *
1070
+ * @public
1071
+ */
1072
+ interface ServerRender {
1073
+ /** The server files of a target that places its servers in files. */
1074
+ readonly files: ReadonlyArray<EmittedFile>;
1075
+ /** The server maps of a target that places its servers in its manifest, by manifest key. */
1076
+ readonly manifest: Readonly<Record<string, unknown>>;
1077
+ readonly issues: ReadonlyArray<ConfigIssue>;
1078
+ readonly stdio: boolean;
1079
+ /** Each LSP field dropped, as a `config` note named `<origin>.<server>.<field>`, in the order met. */
1080
+ readonly notes: ReadonlyArray<BuildNote>;
1081
+ }
1082
+ /**
1083
+ * The target's MCP and LSP configs: base servers with the target's
1084
+ * overrides applied by name, `${PLUGIN_ROOT}` rewritten to the target's
1085
+ * spelling, LSP fields mapped through the target's field map, and the
1086
+ * server-library variables added to every local server's `env`. Each config
1087
+ * goes where the target places it: a file of its own, or inline under a
1088
+ * manifest key, for `renderManifest` to write.
1089
+ *
1090
+ * @public
1091
+ */
1092
+ export declare const renderServers: (target: Target, id: KnownTargetId, config: PluginfinityConfig, plugin: string, libDir: string) => ServerRender;
1093
+ /**
1094
+ * The plugin files a target's servers name after `${PLUGIN_ROOT}/`.
1095
+ *
1096
+ * @public
1097
+ */
1098
+ interface ServerFiles {
1099
+ /** Paths a whole `command` names; they must be executable. */
1100
+ readonly commands: ReadonlyArray<string>;
1101
+ /** Every other path a server names: a file, or a directory whose files all ship. */
1102
+ readonly others: ReadonlyArray<string>;
1103
+ /**
1104
+ * Each path's first naming server, as `mcpServers.<name>` or `lspServers.<name>`,
1105
+ * prefixed with the target for a server a target override sets, as `copilot.mcpServers.<name>`.
1106
+ */
1107
+ readonly owners: ReadonlyMap<string, string>;
1108
+ }
1109
+ /**
1110
+ * The plugin files a target's servers name after `${PLUGIN_ROOT}/`: those a
1111
+ * whole `command` names, which must be executable, and every other one.
1112
+ * Only the fields the root placeholder is documented in are scanned.
1113
+ *
1114
+ * @public
1115
+ */
1116
+ export declare const serverFiles: (target: Target, id: KnownTargetId, config: PluginfinityConfig) => ServerFiles;
1117
+ //#endregion
879
1118
  //#region src/skills.d.ts
880
1119
  /**
881
1120
  * The most characters a built skill's `description` may hold: the Agent
@@ -916,15 +1155,31 @@ export declare const readSkills: (root: string, known: ReadonlyArray<string>) =>
916
1155
  readonly skills: ReadonlyArray<SourceSkill>;
917
1156
  readonly failures: ReadonlyArray<ComponentInvalid>;
918
1157
  }, PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
1158
+ /**
1159
+ * A skill rendered for a target: its files, and what the target dropped or
1160
+ * degraded from its frontmatter.
1161
+ *
1162
+ * @public
1163
+ */
1164
+ interface RenderedSkill {
1165
+ readonly files: ReadonlyArray<EmittedFile>;
1166
+ /** Each about `skills/<name>/SKILL.md`, in the order met. */
1167
+ readonly notes: ReadonlyArray<BuildNote>;
1168
+ }
919
1169
  /**
920
1170
  * Render one skill for a target, or `undefined` when its `targets` block
921
- * excludes it: `SKILL.md` with the target's frontmatter and host blocks
922
- * applied, `.md` support files with host blocks applied, and every other
923
- * file copied. Every file keeps its source mode.
1171
+ * excludes it: `SKILL.md` with the target's frontmatter, then host blocks
1172
+ * and body tokens applied, `.md` support files with host blocks and tokens
1173
+ * applied, and every other file copied. Every file keeps its source mode.
1174
+ *
1175
+ * @remarks
1176
+ * Fails with one `ComponentInvalid` when one file has problems, and with a
1177
+ * `ComponentsInvalid` holding one per file when several do. A token problem
1178
+ * is keyed by its file line and names the target.
924
1179
  *
925
1180
  * @public
926
1181
  */
927
- 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>;
1182
+ 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>;
928
1183
  //#endregion
929
1184
  //#region src/tools.d.ts
930
1185
  /**
@@ -951,5 +1206,5 @@ export declare const ToolDiscoveryLive: Layer.Layer<ToolDiscovery, never, ChildP
951
1206
  */
952
1207
  export declare const ENGINE_VERSION: string;
953
1208
  //#endregion
954
- export type { BuildError, BuildInput, ConfigError, ConfigSelection, DoctorInput, EmittedFile, HostBlockProblem, LoadedConfig, Manifest, MappedFrontmatter, PlanError, PreparedPlugin, SourceAgent, SourceSkill, SplitMarkdown, TargetBuild, TargetHookEvent, TargetValidation, UnresolvedField, UnsupportedHookEvent, ValidateInput };
1209
+ 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 };
955
1210
  //# 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";
@@ -10,8 +11,10 @@ import { CheckGroup, CheckSeverity, CheckStatus, DEFAULT_CHECK_TIMEOUT, DoctorCh
10
11
  import { EmitPlan, GENERATED_MODE, applyEmit, planEmit } from "./emit.js";
11
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, hookExec, 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
@@ -15,14 +15,16 @@ const FORMATS = {
15
15
  }
16
16
  };
17
17
  /**
18
- * Render a target's manifest from the config and the package version: the
19
- * format's record, cut to the target's key allowlist, in allowlist order, with
20
- * unset keys left out.
18
+ * Render a target's manifest from the config, the package version and the
19
+ * server maps the target places in its manifest (`ServerRender.manifest`):
20
+ * the format's record, cut to the target's key allowlist, in allowlist order,
21
+ * with unset keys left out.
21
22
  *
22
23
  * @public
23
24
  */
24
- const renderManifest = (target, id, config, version) => {
25
+ const renderManifest = (target, id, config, version, servers = {}) => {
25
26
  const record = FORMATS[target.manifest.format](target, {
27
+ ...servers,
26
28
  name: pluginName(config, id),
27
29
  version,
28
30
  description: config.description,
@@ -42,4 +44,4 @@ const renderManifest = (target, id, config, version) => {
42
44
  const serializeManifest = (manifest) => `${JSON.stringify(manifest, null, " ")}\n`;
43
45
 
44
46
  //#endregion
45
- export { renderManifest, serializeManifest };
47
+ export { pluginName, renderManifest, serializeManifest };