@mistralys/persona-builder 2.1.2 → 2.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/README.md +17 -3
- package/dist/cli.cjs +197 -35
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +197 -35
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +205 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +307 -45
- package/dist/index.d.ts +307 -45
- package/dist/index.js +200 -36
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -31,7 +31,8 @@ declare function resolvePartials(text: string, partialsMap: Record<string, strin
|
|
|
31
31
|
* conditionals.ts
|
|
32
32
|
*
|
|
33
33
|
* Pure template-engine function for resolving conditional blocks.
|
|
34
|
-
* Handles {{#if flag}}…{{/if}} and {{#if flag}}…{{else}}…{{/if}} syntax
|
|
34
|
+
* Handles {{#if flag}}…{{/if}} and {{#if flag}}…{{else}}…{{/if}} syntax,
|
|
35
|
+
* including nested {{#if}} blocks inside {{else}} branches.
|
|
35
36
|
* No file-system I/O.
|
|
36
37
|
*/
|
|
37
38
|
/**
|
|
@@ -41,6 +42,9 @@ declare function resolvePartials(text: string, partialsMap: Record<string, strin
|
|
|
41
42
|
* `{{#if flag}}content{{/if}}`
|
|
42
43
|
* `{{#if flag}}truthy-content{{else}}falsy-content{{/if}}`
|
|
43
44
|
*
|
|
45
|
+
* Nested conditionals inside `{{else}}` branches are supported:
|
|
46
|
+
* `{{#if a}}A{{else}}{{#if b}}B{{else}}C{{/if}}{{/if}}`
|
|
47
|
+
*
|
|
44
48
|
* Behaviour:
|
|
45
49
|
* - When `context[flag]` is truthy: the delimiters are stripped and the
|
|
46
50
|
* content before `{{else}}` (or the entire inner block if no `{{else}}`)
|
|
@@ -55,6 +59,12 @@ declare function resolvePartials(text: string, partialsMap: Record<string, strin
|
|
|
55
59
|
* Leading and trailing newlines within the kept content are trimmed so the
|
|
56
60
|
* output does not accumulate extra blank lines.
|
|
57
61
|
*
|
|
62
|
+
* Nesting algorithm: the regex matches only *innermost* blocks — those
|
|
63
|
+
* whose content contains no further `{{#if` markers. The replacement loop
|
|
64
|
+
* repeats until the output stabilises, resolving each nesting level in
|
|
65
|
+
* depth-first (innermost-first) order. This avoids the closing `{{/if}}`
|
|
66
|
+
* ambiguity that arises with non-greedy single-pass matching.
|
|
67
|
+
*
|
|
58
68
|
* @param text - Template string potentially containing {{#if}} blocks
|
|
59
69
|
* @param context - Key-value map used to evaluate flag truthiness
|
|
60
70
|
* @returns The template string with conditional blocks resolved
|
|
@@ -204,11 +214,19 @@ declare function loadPartials(dir: string): Promise<Record<string, string>>;
|
|
|
204
214
|
* - PersonaBuildPlugin — interface every plugin must implement
|
|
205
215
|
*/
|
|
206
216
|
/**
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
217
|
+
* Identifies a build output target.
|
|
218
|
+
*
|
|
219
|
+
* Resolves to `string` to allow custom targets alongside the three built-in
|
|
220
|
+
* well-known values:
|
|
221
|
+
* - `'vscode'` → VS Code `.prompt.md` / `.agent.md` instruction files
|
|
222
|
+
* - `'claude-code'` → Claude Code `.md` instruction files
|
|
223
|
+
* - `'deep-agents'` → Deep Agents `.md` instruction files
|
|
224
|
+
*
|
|
225
|
+
* Use the exported constants `TARGET_VSCODE`, `TARGET_CLAUDE_CODE`, and
|
|
226
|
+
* `TARGET_DEEP_AGENTS` from `src/targets/types.ts` for type-safe references
|
|
227
|
+
* to the built-in targets.
|
|
210
228
|
*/
|
|
211
|
-
type TargetType =
|
|
229
|
+
type TargetType = string;
|
|
212
230
|
/**
|
|
213
231
|
* Typed representation of a persona YAML metadata file.
|
|
214
232
|
*
|
|
@@ -236,10 +254,50 @@ interface PersonaMetadata {
|
|
|
236
254
|
interface SuiteConfig {
|
|
237
255
|
/** Absolute or relative path to the suite source directory */
|
|
238
256
|
srcDir: string;
|
|
239
|
-
/**
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
257
|
+
/**
|
|
258
|
+
* Output path for VS Code formatted persona files.
|
|
259
|
+
*
|
|
260
|
+
* @deprecated Use `outputDirs['vscode']` instead. Kept for backwards
|
|
261
|
+
* compatibility. When `outputDirs['vscode']` is present it takes
|
|
262
|
+
* precedence. Will be removed in a future major version.
|
|
263
|
+
*/
|
|
264
|
+
outVscode?: string;
|
|
265
|
+
/**
|
|
266
|
+
* Output path for Claude Code formatted persona files.
|
|
267
|
+
*
|
|
268
|
+
* @deprecated Use `outputDirs['claude-code']` instead. Kept for backwards
|
|
269
|
+
* compatibility. When `outputDirs['claude-code']` is present it takes
|
|
270
|
+
* precedence. Will be removed in a future major version.
|
|
271
|
+
*/
|
|
272
|
+
outClaudeCode?: string;
|
|
273
|
+
/**
|
|
274
|
+
* Generic map of output directories keyed by target output-dir key.
|
|
275
|
+
*
|
|
276
|
+
* Takes precedence over the deprecated `outVscode` / `outClaudeCode` fields.
|
|
277
|
+
* Required for custom targets beyond the built-in ones. Each key must match
|
|
278
|
+
* the target's `outputDirKey` field (declared in its `TargetDefinition`),
|
|
279
|
+
* **not** necessarily the target name.
|
|
280
|
+
*
|
|
281
|
+
* For the three built-in targets `outputDirKey` equals the target name, so
|
|
282
|
+
* there is no difference in practice:
|
|
283
|
+
* - `'vscode'` → `TargetDefinition.outputDirKey === 'vscode'`
|
|
284
|
+
* - `'claude-code'` → `TargetDefinition.outputDirKey === 'claude-code'`
|
|
285
|
+
* - `'deep-agents'` → `TargetDefinition.outputDirKey === 'deep-agents'`
|
|
286
|
+
*
|
|
287
|
+
* For a custom target where `name: 'my-target'` and
|
|
288
|
+
* `outputDirKey: 'mydir'`, the map key must be `'mydir'`:
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* ```ts
|
|
292
|
+
* outputDirs: {
|
|
293
|
+
* 'vscode': './out/vs-code',
|
|
294
|
+
* 'claude-code': './out/claude-code',
|
|
295
|
+
* 'deep-agents': './out/deep-agents',
|
|
296
|
+
* 'mydir': './out/my-target', // outputDirKey for a custom target
|
|
297
|
+
* }
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
outputDirs?: Record<string, string>;
|
|
243
301
|
/**
|
|
244
302
|
* Optional persona mode string (e.g. 'ledger').
|
|
245
303
|
* When present, plugins can use this to branch behaviour.
|
|
@@ -301,7 +359,7 @@ interface PersonaBuildPlugin {
|
|
|
301
359
|
* @param suite The suite configuration object
|
|
302
360
|
* @returns Updated rendering context (must include all original keys)
|
|
303
361
|
*/
|
|
304
|
-
onBuildContext?(context: Record<string, unknown>, persona: PersonaMetadata, suite: SuiteConfig): Record<string, unknown>;
|
|
362
|
+
onBuildContext?(context: Record<string, unknown>, persona: PersonaMetadata, suite: SuiteConfig, target?: TargetType): Record<string, unknown>;
|
|
305
363
|
/**
|
|
306
364
|
* Called for each persona after body rendering.
|
|
307
365
|
*
|
|
@@ -464,9 +522,10 @@ declare function runSuiteInit(plugins: PersonaBuildPlugin[], suite: SuiteConfig,
|
|
|
464
522
|
* @param ctx Initial rendering context for this persona
|
|
465
523
|
* @param persona Typed metadata for the persona being built
|
|
466
524
|
* @param suite The suite configuration object
|
|
525
|
+
* @param target The current build target (optional — forwarded to each plugin)
|
|
467
526
|
* @returns Accumulated rendering context after all plugins have run
|
|
468
527
|
*/
|
|
469
|
-
declare function runBuildContext(plugins: PersonaBuildPlugin[], ctx: Record<string, unknown>, persona: PersonaMetadata, suite: SuiteConfig): Record<string, unknown>;
|
|
528
|
+
declare function runBuildContext(plugins: PersonaBuildPlugin[], ctx: Record<string, unknown>, persona: PersonaMetadata, suite: SuiteConfig, target?: TargetType): Record<string, unknown>;
|
|
470
529
|
/**
|
|
471
530
|
* Invoke the `onPostRender` hook on every registered plugin, chaining the
|
|
472
531
|
* output string sequentially.
|
|
@@ -497,6 +556,156 @@ declare function runPostRender(plugins: PersonaBuildPlugin[], rendered: string,
|
|
|
497
556
|
*/
|
|
498
557
|
declare function runValidate(plugins: PersonaBuildPlugin[], persona: PersonaMetadata, suite: SuiteConfig, target?: TargetType): ValidationResult[];
|
|
499
558
|
|
|
559
|
+
/**
|
|
560
|
+
* src/targets/types.ts
|
|
561
|
+
*
|
|
562
|
+
* Target type definitions for @mistralys/persona-builder.
|
|
563
|
+
*
|
|
564
|
+
* Defines the TargetDefinition interface and well-known target name constants.
|
|
565
|
+
*/
|
|
566
|
+
/**
|
|
567
|
+
* Describes a build target — maps a target name to its output directory key,
|
|
568
|
+
* filename context key, default frontmatter template, and optional
|
|
569
|
+
* auto-injected context flags.
|
|
570
|
+
*/
|
|
571
|
+
interface TargetDefinition {
|
|
572
|
+
/** Unique target identifier (e.g. 'vscode', 'claude-code'). */
|
|
573
|
+
name: string;
|
|
574
|
+
/**
|
|
575
|
+
* Key used to look up the output directory in the suite's output dir map.
|
|
576
|
+
* For built-in targets this matches the target name.
|
|
577
|
+
*/
|
|
578
|
+
outputDirKey: string;
|
|
579
|
+
/**
|
|
580
|
+
* Context field name that holds a custom output filename for this target.
|
|
581
|
+
* When present and non-empty in the rendered context, it overrides the
|
|
582
|
+
* default filename derived from the persona name.
|
|
583
|
+
*/
|
|
584
|
+
filenameContextKey?: string;
|
|
585
|
+
/**
|
|
586
|
+
* Default frontmatter template string for this target.
|
|
587
|
+
* Used when neither a plugin nor a BuildConfig template is provided.
|
|
588
|
+
*/
|
|
589
|
+
defaultFrontmatter: string;
|
|
590
|
+
/**
|
|
591
|
+
* Declarative context flags merged into the build context when this target
|
|
592
|
+
* is rendered. Useful for `{{#if target_vscode}}` guards.
|
|
593
|
+
*
|
|
594
|
+
* All entries are spread into the context by `buildContext()` via a
|
|
595
|
+
* registry lookup — `registry.get(target).contextFlags`. The fallback path
|
|
596
|
+
* (for targets absent from the registry) injects a single boolean flag
|
|
597
|
+
* derived from the target name: `target_${name.replace(/-/g, '_')} = true`.
|
|
598
|
+
*/
|
|
599
|
+
contextFlags?: Record<string, unknown>;
|
|
600
|
+
/**
|
|
601
|
+
* Whether this target is included in the default build when no explicit
|
|
602
|
+
* `targets` array is configured. Defaults to `true` when omitted.
|
|
603
|
+
*
|
|
604
|
+
* Set to `false` for opt-in targets (e.g. `'deep-agents'`) that should
|
|
605
|
+
* only be built when explicitly requested via `config.targets`.
|
|
606
|
+
*/
|
|
607
|
+
defaultEnabled?: boolean;
|
|
608
|
+
}
|
|
609
|
+
/** Well-known name constant for the VS Code target. */
|
|
610
|
+
declare const TARGET_VSCODE: "vscode";
|
|
611
|
+
/** Well-known name constant for the Claude Code target. */
|
|
612
|
+
declare const TARGET_CLAUDE_CODE: "claude-code";
|
|
613
|
+
/** Well-known name constant for the Deep Agents target. */
|
|
614
|
+
declare const TARGET_DEEP_AGENTS: "deep-agents";
|
|
615
|
+
/**
|
|
616
|
+
* Default VS Code frontmatter template.
|
|
617
|
+
*
|
|
618
|
+
* Minimal fields that work for standalone personas. Projects using numbered
|
|
619
|
+
* workflows (e.g. ledger) should inject a richer template via a plugin.
|
|
620
|
+
*/
|
|
621
|
+
declare const DEFAULT_FRONTMATTER_VSCODE = "---\nname: '{{name}} v{{version}}'\ndescription: '{{description}}'\ntools: [{{tools_list}}]\n---";
|
|
622
|
+
/**
|
|
623
|
+
* Default Claude Code frontmatter template.
|
|
624
|
+
*
|
|
625
|
+
* Minimal fields that work for standalone personas. Projects using numbered
|
|
626
|
+
* workflows should inject a richer template via a plugin.
|
|
627
|
+
*/
|
|
628
|
+
declare const DEFAULT_FRONTMATTER_CLAUDE_CODE = "---\nname: {{cc_file_name_stem}}\npermissionMode: {{cc_permission_mode}}\nmodel: {{cc_model}}\nmemory: {{cc_memory}}\nallowedTools: [{{cc_tools_list}}]\n---";
|
|
629
|
+
/**
|
|
630
|
+
* Default Deep Agents frontmatter template.
|
|
631
|
+
*
|
|
632
|
+
* Minimal fields — no IDE-specific properties. Suitable for headless
|
|
633
|
+
* LangGraph / Deep Agents pipeline executors that consume persona files
|
|
634
|
+
* without an IDE host.
|
|
635
|
+
*/
|
|
636
|
+
declare const DEFAULT_FRONTMATTER_DEEP_AGENTS = "---\nname: {{name}}\ndescription: {{description}}\n---";
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* src/targets/registry.ts
|
|
640
|
+
*
|
|
641
|
+
* TargetRegistry — holds TargetDefinition entries and allows consumers to
|
|
642
|
+
* register custom build targets alongside (or instead of) the built-in ones.
|
|
643
|
+
*/
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Registry that maps target names to their TargetDefinition objects.
|
|
647
|
+
*
|
|
648
|
+
* Consumers can extend the default build system by calling `register()` with
|
|
649
|
+
* a custom TargetDefinition before invoking `build()`.
|
|
650
|
+
*
|
|
651
|
+
* @example
|
|
652
|
+
* ```ts
|
|
653
|
+
* import { defaultRegistry } from '@mistralys/persona-builder';
|
|
654
|
+
*
|
|
655
|
+
* defaultRegistry.register({
|
|
656
|
+
* name: 'my-target',
|
|
657
|
+
* outputDirKey: 'my-target',
|
|
658
|
+
* defaultFrontmatter: '---\nmy: frontmatter\n---',
|
|
659
|
+
* contextFlags: { target_my_target: true },
|
|
660
|
+
* });
|
|
661
|
+
* ```
|
|
662
|
+
*/
|
|
663
|
+
declare class TargetRegistry {
|
|
664
|
+
private readonly _definitions;
|
|
665
|
+
/**
|
|
666
|
+
* Register a new target definition.
|
|
667
|
+
*
|
|
668
|
+
* @param definition The target descriptor to register.
|
|
669
|
+
* @throws {Error} If a target with the same `name` is already registered.
|
|
670
|
+
*/
|
|
671
|
+
register(definition: TargetDefinition): void;
|
|
672
|
+
/**
|
|
673
|
+
* Retrieve a registered target definition by name.
|
|
674
|
+
*
|
|
675
|
+
* Returns a shallow copy — mutating the returned object does not affect
|
|
676
|
+
* the registry's internal state.
|
|
677
|
+
*
|
|
678
|
+
* @param name The target name to look up.
|
|
679
|
+
* @returns A shallow copy of the matching TargetDefinition.
|
|
680
|
+
* @throws {Error} If no target with the given name is registered.
|
|
681
|
+
*/
|
|
682
|
+
get(name: string): TargetDefinition;
|
|
683
|
+
/**
|
|
684
|
+
* Returns `true` if a target with the given name is registered.
|
|
685
|
+
*
|
|
686
|
+
* @param name The target name to check.
|
|
687
|
+
*/
|
|
688
|
+
has(name: string): boolean;
|
|
689
|
+
/**
|
|
690
|
+
* Returns the names of all registered targets, in registration order.
|
|
691
|
+
*/
|
|
692
|
+
names(): string[];
|
|
693
|
+
/**
|
|
694
|
+
* Returns all registered TargetDefinition objects, in registration order.
|
|
695
|
+
*
|
|
696
|
+
* Returns shallow copies — mutating a returned definition does not affect
|
|
697
|
+
* the registry's internal state.
|
|
698
|
+
*/
|
|
699
|
+
allDefinitions(): TargetDefinition[];
|
|
700
|
+
/**
|
|
701
|
+
* Returns a new TargetRegistry pre-populated with the same definitions.
|
|
702
|
+
*
|
|
703
|
+
* Useful for test isolation: clone the `defaultRegistry` to get an
|
|
704
|
+
* independent copy that can be mutated without affecting the singleton.
|
|
705
|
+
*/
|
|
706
|
+
clone(): TargetRegistry;
|
|
707
|
+
}
|
|
708
|
+
|
|
500
709
|
/**
|
|
501
710
|
* src/builders/types.ts
|
|
502
711
|
*
|
|
@@ -541,10 +750,25 @@ interface BuildConfig {
|
|
|
541
750
|
*/
|
|
542
751
|
plugins?: PersonaBuildPlugin[];
|
|
543
752
|
/**
|
|
544
|
-
* Target output formats to build.
|
|
545
|
-
*
|
|
753
|
+
* Target output formats to build.
|
|
754
|
+
*
|
|
755
|
+
* Default behaviour depends on whether `targetRegistry` is provided:
|
|
756
|
+
* - **No custom registry** (default): builds `['vscode', 'claude-code']` to
|
|
757
|
+
* preserve backward compatibility — suites that do not configure a
|
|
758
|
+
* `'deep-agents'` output directory would otherwise fail silently.
|
|
759
|
+
* - **Custom registry supplied**: builds all targets registered in that
|
|
760
|
+
* registry (equivalent to `registry.names()`).
|
|
761
|
+
*
|
|
762
|
+
* Pass an explicit array to override either default:
|
|
763
|
+
* ```ts
|
|
764
|
+
* targets: ['vscode', 'claude-code', 'deep-agents']
|
|
765
|
+
* ```
|
|
766
|
+
*
|
|
767
|
+
* Accepts any registered target name — all three built-in targets
|
|
768
|
+
* (`'vscode'`, `'claude-code'`, `'deep-agents'`) and any custom target
|
|
769
|
+
* added via `targetRegistry`.
|
|
546
770
|
*/
|
|
547
|
-
targets?:
|
|
771
|
+
targets?: string[];
|
|
548
772
|
/**
|
|
549
773
|
* When `true`, no files are written to disk. The build still renders all
|
|
550
774
|
* personas and collects ValidationResults, but all write operations are
|
|
@@ -558,12 +782,24 @@ interface BuildConfig {
|
|
|
558
782
|
*/
|
|
559
783
|
strict?: boolean;
|
|
560
784
|
/**
|
|
561
|
-
* Optional map of default frontmatter templates, keyed by target
|
|
785
|
+
* Optional map of default frontmatter templates, keyed by target name.
|
|
562
786
|
* These are used as library defaults and can be overridden by plugin
|
|
563
|
-
* `frontmatterTemplates`. When absent, built-in defaults from
|
|
564
|
-
* `
|
|
787
|
+
* `frontmatterTemplates`. When absent, built-in defaults from the
|
|
788
|
+
* `TargetDefinition.defaultFrontmatter` are used.
|
|
565
789
|
*/
|
|
566
|
-
frontmatter?:
|
|
790
|
+
frontmatter?: Record<string, string>;
|
|
791
|
+
/**
|
|
792
|
+
* Optional target registry to use for this build.
|
|
793
|
+
*
|
|
794
|
+
* When provided, overrides the built-in `defaultRegistry` for output
|
|
795
|
+
* directory resolution, filename key lookup, frontmatter defaults, and
|
|
796
|
+
* context flag injection. Consumers can register custom targets on the
|
|
797
|
+
* provided registry to extend the build system without touching source code.
|
|
798
|
+
*
|
|
799
|
+
* Defaults to `defaultRegistry` (pre-registered with `'vscode'`,
|
|
800
|
+
* `'claude-code'`, and `'deep-agents'`) when not supplied.
|
|
801
|
+
*/
|
|
802
|
+
targetRegistry?: TargetRegistry;
|
|
567
803
|
}
|
|
568
804
|
/**
|
|
569
805
|
* The outcome of building a single persona for a single target.
|
|
@@ -571,8 +807,8 @@ interface BuildConfig {
|
|
|
571
807
|
interface BuildResult {
|
|
572
808
|
/** The suite identifier this persona belongs to */
|
|
573
809
|
suite: string;
|
|
574
|
-
/** Target
|
|
575
|
-
target:
|
|
810
|
+
/** Target name this result was generated for (e.g. `'vscode'`, `'claude-code'`, or a custom target) */
|
|
811
|
+
target: string;
|
|
576
812
|
/** Absolute path to the persona YAML source file */
|
|
577
813
|
personaYamlPath: string;
|
|
578
814
|
/** Absolute path to the output file (may not exist if check mode) */
|
|
@@ -610,7 +846,7 @@ interface BuildSummary {
|
|
|
610
846
|
*
|
|
611
847
|
* Frontmatter template registry for @mistralys/persona-builder.
|
|
612
848
|
*
|
|
613
|
-
* Ships
|
|
849
|
+
* Ships three minimal default templates — one per built-in target — that work for the
|
|
614
850
|
* "standalone" persona mode (simple personas without numbered workflows or
|
|
615
851
|
* MCP server blocks). Projects needing richer frontmatter register custom
|
|
616
852
|
* templates via the `PersonaBuildPlugin.frontmatterTemplates` property.
|
|
@@ -622,37 +858,23 @@ interface BuildSummary {
|
|
|
622
858
|
* No partials in frontmatter — frontmatter is kept deliberately simple.
|
|
623
859
|
*/
|
|
624
860
|
|
|
625
|
-
/**
|
|
626
|
-
* Default VS Code frontmatter template.
|
|
627
|
-
*
|
|
628
|
-
* Minimal fields that work for standalone personas. Projects using numbered
|
|
629
|
-
* workflows (e.g. ledger) should inject a richer template via a plugin.
|
|
630
|
-
*/
|
|
631
|
-
declare const DEFAULT_FRONTMATTER_VSCODE = "---\nname: '{{name}} v{{version}}'\ndescription: '{{description}}'\ntools: [{{tools_list}}]\n---";
|
|
632
|
-
/**
|
|
633
|
-
* Default Claude Code frontmatter template.
|
|
634
|
-
*
|
|
635
|
-
* Minimal fields that work for standalone personas. Projects using numbered
|
|
636
|
-
* workflows should inject a richer template via a plugin.
|
|
637
|
-
*/
|
|
638
|
-
declare const DEFAULT_FRONTMATTER_CLAUDE_CODE = "---\nname: {{cc_file_name_stem}}\npermissionMode: {{cc_permission_mode}}\nmodel: {{cc_model}}\nmemory: {{cc_memory}}\nallowedTools: [{{cc_tools_list}}]\n---";
|
|
639
861
|
/**
|
|
640
862
|
* Resolve frontmatter template precedence.
|
|
641
863
|
*
|
|
642
864
|
* Precedence order (highest wins):
|
|
643
|
-
* 1. Plugin `frontmatterTemplates` —
|
|
644
|
-
*
|
|
645
|
-
* *first* registered plugin with a template takes precedence over later
|
|
646
|
-
* ones, matching the general plugin-chain contract).
|
|
865
|
+
* 1. Plugin `frontmatterTemplates` — plugins are checked in registration
|
|
866
|
+
* order; the first plugin with a matching key wins.
|
|
647
867
|
* 2. `configTemplates` — templates passed via `BuildConfig.frontmatter`
|
|
648
|
-
* 3.
|
|
868
|
+
* 3. Registry default — `TargetDefinition.defaultFrontmatter` for the target
|
|
869
|
+
* 4. Library default (`DEFAULT_FRONTMATTER_VSCODE`) — safety fallback only
|
|
649
870
|
*
|
|
650
|
-
* @param target The build target ('vscode'
|
|
871
|
+
* @param target The build target name (e.g. `'vscode'`, `'claude-code'`, or a custom target)
|
|
651
872
|
* @param plugins Registered plugins (searched in order; first match wins)
|
|
652
873
|
* @param configTemplates Optional caller-supplied overrides from BuildConfig
|
|
874
|
+
* @param registry Optional TargetRegistry for resolving the built-in default template
|
|
653
875
|
* @returns The resolved template string
|
|
654
876
|
*/
|
|
655
|
-
declare function resolveFrontmatterTemplate(target:
|
|
877
|
+
declare function resolveFrontmatterTemplate(target: string, plugins: PersonaBuildPlugin[], configTemplates?: Record<string, string>, registry?: TargetRegistry): string;
|
|
656
878
|
/**
|
|
657
879
|
* Render a frontmatter template string against the given context.
|
|
658
880
|
*
|
|
@@ -714,9 +936,17 @@ declare function renderFrontmatter(template: string, context: Record<string, unk
|
|
|
714
936
|
* @param config Top-level BuildConfig
|
|
715
937
|
* @param plugins Registered plugins
|
|
716
938
|
* @param target Target output format
|
|
939
|
+
* @param agentMap Pre-built cross-suite agent name map
|
|
940
|
+
* @param registry Target registry to use. Defaults to `defaultRegistry`.
|
|
941
|
+
* **Two-registry limitation:** If you pass a custom `TargetRegistry` only
|
|
942
|
+
* to `build()` (via `config.targetRegistry`) and call `buildPersona()`
|
|
943
|
+
* directly without also passing that registry here, your custom targets
|
|
944
|
+
* will not be visible — `defaultRegistry` will be used instead. Either
|
|
945
|
+
* pass the same registry instance explicitly, or call `build()` to have
|
|
946
|
+
* the registry forwarded automatically.
|
|
717
947
|
* @returns BuildResult for this persona × target combination
|
|
718
948
|
*/
|
|
719
|
-
declare function buildPersona(personaYamlPath: string, suiteName: string, suiteConfig: SuiteConfig, sharedMeta: Record<string, unknown>, partialsMap: Record<string, string>, config: BuildConfig, plugins: PersonaBuildPlugin[], target:
|
|
949
|
+
declare function buildPersona(personaYamlPath: string, suiteName: string, suiteConfig: SuiteConfig, sharedMeta: Record<string, unknown>, partialsMap: Record<string, string>, config: BuildConfig, plugins: PersonaBuildPlugin[], target: string, agentMap?: Record<string, string>, registry?: TargetRegistry): Promise<BuildResult>;
|
|
720
950
|
/**
|
|
721
951
|
* Build all personas in a suite for a single output target.
|
|
722
952
|
*
|
|
@@ -732,9 +962,17 @@ declare function buildPersona(personaYamlPath: string, suiteName: string, suiteC
|
|
|
732
962
|
* @param config Top-level BuildConfig
|
|
733
963
|
* @param plugins Registered plugins
|
|
734
964
|
* @param target Target output format
|
|
965
|
+
* @param agentMap Pre-built cross-suite agent name map
|
|
966
|
+
* @param registry Target registry to use. Defaults to `defaultRegistry`.
|
|
967
|
+
* **Two-registry limitation:** If you pass a custom `TargetRegistry` only
|
|
968
|
+
* to `build()` (via `config.targetRegistry`) and call `buildSuite()`
|
|
969
|
+
* directly without also passing that registry here, your custom targets
|
|
970
|
+
* will not be visible — `defaultRegistry` will be used instead. Either
|
|
971
|
+
* pass the same registry instance explicitly, or call `build()` to have
|
|
972
|
+
* the registry forwarded automatically.
|
|
735
973
|
* @returns Array of BuildResult objects, one per persona
|
|
736
974
|
*/
|
|
737
|
-
declare function buildSuite(suiteName: string, suiteConfig: SuiteConfig, config: BuildConfig, plugins: PersonaBuildPlugin[], target:
|
|
975
|
+
declare function buildSuite(suiteName: string, suiteConfig: SuiteConfig, config: BuildConfig, plugins: PersonaBuildPlugin[], target: string, agentMap?: Record<string, string>, registry?: TargetRegistry): Promise<BuildResult[]>;
|
|
738
976
|
/**
|
|
739
977
|
* Top-level build orchestrator.
|
|
740
978
|
*
|
|
@@ -843,6 +1081,30 @@ declare function validateStrictMarkers(renderedContent: string, requiredMarkers:
|
|
|
843
1081
|
*/
|
|
844
1082
|
declare function escapeRegExp(str: string): string;
|
|
845
1083
|
|
|
1084
|
+
/**
|
|
1085
|
+
* src/targets/built-in.ts
|
|
1086
|
+
*
|
|
1087
|
+
* Creates and exports the defaultRegistry — a TargetRegistry pre-populated
|
|
1088
|
+
* with the three built-in targets: 'vscode', 'claude-code', and 'deep-agents'.
|
|
1089
|
+
*
|
|
1090
|
+
* Consumers import defaultRegistry when they need to register additional
|
|
1091
|
+
* custom targets or query the built-in target definitions.
|
|
1092
|
+
*/
|
|
1093
|
+
|
|
1094
|
+
/**
|
|
1095
|
+
* Singleton TargetRegistry pre-populated with the three built-in targets:
|
|
1096
|
+
* `'vscode'`, `'claude-code'`, and `'deep-agents'`.
|
|
1097
|
+
*
|
|
1098
|
+
* Import and call `register()` on this instance to add custom targets before
|
|
1099
|
+
* invoking `build()`.
|
|
1100
|
+
*
|
|
1101
|
+
* **Warning:** This is a module-level singleton. Calling `register()` on it
|
|
1102
|
+
* in tests mutates shared state that persists across test cases. Use
|
|
1103
|
+
* `defaultRegistry.clone()` to obtain an isolated copy for test scenarios
|
|
1104
|
+
* that need to register additional targets.
|
|
1105
|
+
*/
|
|
1106
|
+
declare const defaultRegistry: TargetRegistry;
|
|
1107
|
+
|
|
846
1108
|
/**
|
|
847
1109
|
* @mistralys/persona-builder
|
|
848
1110
|
*
|
|
@@ -851,4 +1113,4 @@ declare function escapeRegExp(str: string): string;
|
|
|
851
1113
|
|
|
852
1114
|
declare const VERSION: string;
|
|
853
1115
|
|
|
854
|
-
export { type BuildConfig, type BuildResult, type BuildSummary, DEFAULT_FRONTMATTER_CLAUDE_CODE, DEFAULT_FRONTMATTER_VSCODE, type PersonaBuildPlugin, type PersonaMetadata, type SuiteConfig, type TargetType, VERSION, type ValidationResult, build, buildPersona, buildSuite, collapseBlankLines, discoverPersonaYamls, ensureBlankLineBeforeHeadings, escapeRegExp, loadContent, loadMetadata, loadPartials, normalizeNewlines, renderFrontmatter, resolveConditionals, resolveFrontmatterTemplate, resolvePartials, resolveVariables, runBuildContext, runPostRender, runSuiteInit, runValidate, serializeTools, serializeToolsList, validateFileName, validateStrictMarkers };
|
|
1116
|
+
export { type BuildConfig, type BuildResult, type BuildSummary, DEFAULT_FRONTMATTER_CLAUDE_CODE, DEFAULT_FRONTMATTER_DEEP_AGENTS, DEFAULT_FRONTMATTER_VSCODE, type PersonaBuildPlugin, type PersonaMetadata, type SuiteConfig, TARGET_CLAUDE_CODE, TARGET_DEEP_AGENTS, TARGET_VSCODE, type TargetDefinition, TargetRegistry, type TargetType, VERSION, type ValidationResult, build, buildPersona, buildSuite, collapseBlankLines, defaultRegistry, discoverPersonaYamls, ensureBlankLineBeforeHeadings, escapeRegExp, loadContent, loadMetadata, loadPartials, normalizeNewlines, renderFrontmatter, resolveConditionals, resolveFrontmatterTemplate, resolvePartials, resolveVariables, runBuildContext, runPostRender, runSuiteInit, runValidate, serializeTools, serializeToolsList, validateFileName, validateStrictMarkers };
|