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