@mistralys/persona-builder 2.4.0 → 2.5.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/dist/index.cjs CHANGED
@@ -103,6 +103,10 @@ function serializeTools(tools) {
103
103
  function serializeToolsList(tools) {
104
104
  return tools.map((t) => `'${t}'`).join(", ");
105
105
  }
106
+ function serializeToolsBlock(tools) {
107
+ if (tools.length === 0) return " []";
108
+ return "\n" + tools.map((t) => ` - ${t}`).join("\n");
109
+ }
106
110
  async function loadPartials(dir) {
107
111
  const entries = await promises.readdir(dir, { withFileTypes: true });
108
112
  const mdFiles = entries.filter(
@@ -211,10 +215,10 @@ tools: [{{tools_list}}]
211
215
  ---`;
212
216
  var DEFAULT_FRONTMATTER_CLAUDE_CODE = `---
213
217
  name: {{cc_file_name_stem}}
214
- permissionMode: {{cc_permission_mode}}
218
+ description: {{description}}
215
219
  model: {{cc_model}}
216
220
  memory: {{cc_memory}}
217
- allowedTools: [{{cc_tools_list}}]
221
+ tools:{{cc_tools_block}}
218
222
  ---`;
219
223
  var DEFAULT_FRONTMATTER_DEEP_AGENTS = `---
220
224
  name: {{name}}
@@ -443,6 +447,12 @@ function buildContext(options) {
443
447
  if (!("cc_tools_json" in merged)) {
444
448
  merged["cc_tools_json"] = serializeTools(ccTools);
445
449
  }
450
+ if (!("tools_block" in merged)) {
451
+ merged["tools_block"] = serializeToolsBlock(tools);
452
+ }
453
+ if (!("cc_tools_block" in merged)) {
454
+ merged["cc_tools_block"] = serializeToolsBlock(ccTools);
455
+ }
446
456
  if (!("cc_file_name_stem" in merged) && typeof merged["cc_file_name"] === "string") {
447
457
  const ccFileName = merged["cc_file_name"];
448
458
  merged["cc_file_name_stem"] = ccFileName.replace(/\.md$/, "");
@@ -459,6 +469,9 @@ function buildContext(options) {
459
469
  if (!("da_tools_json" in merged)) {
460
470
  merged["da_tools_json"] = serializeTools(daTools);
461
471
  }
472
+ if (!("da_tools_block" in merged)) {
473
+ merged["da_tools_block"] = serializeToolsBlock(daTools);
474
+ }
462
475
  }
463
476
  for (const [key, value] of Object.entries(agentMap)) {
464
477
  if (!(key in merged)) {
@@ -477,6 +490,21 @@ function buildContext(options) {
477
490
  }
478
491
  return merged;
479
492
  }
493
+ function validateSubagentRefs(persona, agentMap) {
494
+ const subagents = persona.subagents;
495
+ if (!Array.isArray(subagents) || subagents.length === 0) return [];
496
+ const results = [];
497
+ for (const slug of subagents) {
498
+ const key = `agent_slug_${slug.replace(/-/g, "_")}`;
499
+ if (!(key in agentMap)) {
500
+ results.push({
501
+ severity: "error",
502
+ message: `Persona '${persona.name}' declares subagent '${slug}' but no persona with that slug exists in any configured suite.`
503
+ });
504
+ }
505
+ }
506
+ return results;
507
+ }
480
508
  async function buildPersona(personaYamlPath, suiteName, suiteConfig, sharedMeta, partialsMap, config, plugins, target, agentMap = {}, registry = defaultRegistry) {
481
509
  const personaMeta = await loadPersonaYaml(personaYamlPath);
482
510
  let context = buildContext({
@@ -515,7 +543,10 @@ async function buildPersona(personaYamlPath, suiteName, suiteConfig, sharedMeta,
515
543
  ${body}
516
544
  `);
517
545
  output = runPostRender(plugins, output, personaMetaTyped, target);
518
- const validationResults = runValidate(plugins, personaMetaTyped, suiteConfig, target);
546
+ const validationResults = [
547
+ ...runValidate(plugins, personaMetaTyped, suiteConfig, target),
548
+ ...validateSubagentRefs(personaMetaTyped, agentMap)
549
+ ];
519
550
  const def = registry.has(target) ? registry.get(target) : void 0;
520
551
  const outputDir = resolveOutputDir(target, suiteConfig, def);
521
552
  const fnKey = def?.filenameContextKey;
@@ -700,6 +731,7 @@ exports.runPostRender = runPostRender;
700
731
  exports.runSuiteInit = runSuiteInit;
701
732
  exports.runValidate = runValidate;
702
733
  exports.serializeTools = serializeTools;
734
+ exports.serializeToolsBlock = serializeToolsBlock;
703
735
  exports.serializeToolsList = serializeToolsList;
704
736
  exports.validateFileName = validateFileName;
705
737
  exports.validateStrictMarkers = validateStrictMarkers;