@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/cli.js CHANGED
@@ -95,6 +95,10 @@ function serializeTools(tools) {
95
95
  function serializeToolsList(tools) {
96
96
  return tools.map((t) => `'${t}'`).join(", ");
97
97
  }
98
+ function serializeToolsBlock(tools) {
99
+ if (tools.length === 0) return " []";
100
+ return "\n" + tools.map((t) => ` - ${t}`).join("\n");
101
+ }
98
102
  async function loadPartials(dir) {
99
103
  const entries = await readdir(dir, { withFileTypes: true });
100
104
  const mdFiles = entries.filter(
@@ -177,10 +181,10 @@ tools: [{{tools_list}}]
177
181
  ---`;
178
182
  var DEFAULT_FRONTMATTER_CLAUDE_CODE = `---
179
183
  name: {{cc_file_name_stem}}
180
- permissionMode: {{cc_permission_mode}}
184
+ description: {{description}}
181
185
  model: {{cc_model}}
182
186
  memory: {{cc_memory}}
183
- allowedTools: [{{cc_tools_list}}]
187
+ tools:{{cc_tools_block}}
184
188
  ---`;
185
189
  var DEFAULT_FRONTMATTER_DEEP_AGENTS = `---
186
190
  name: {{name}}
@@ -409,6 +413,12 @@ function buildContext(options) {
409
413
  if (!("cc_tools_json" in merged)) {
410
414
  merged["cc_tools_json"] = serializeTools(ccTools);
411
415
  }
416
+ if (!("tools_block" in merged)) {
417
+ merged["tools_block"] = serializeToolsBlock(tools);
418
+ }
419
+ if (!("cc_tools_block" in merged)) {
420
+ merged["cc_tools_block"] = serializeToolsBlock(ccTools);
421
+ }
412
422
  if (!("cc_file_name_stem" in merged) && typeof merged["cc_file_name"] === "string") {
413
423
  const ccFileName = merged["cc_file_name"];
414
424
  merged["cc_file_name_stem"] = ccFileName.replace(/\.md$/, "");
@@ -425,6 +435,9 @@ function buildContext(options) {
425
435
  if (!("da_tools_json" in merged)) {
426
436
  merged["da_tools_json"] = serializeTools(daTools);
427
437
  }
438
+ if (!("da_tools_block" in merged)) {
439
+ merged["da_tools_block"] = serializeToolsBlock(daTools);
440
+ }
428
441
  }
429
442
  for (const [key, value] of Object.entries(agentMap)) {
430
443
  if (!(key in merged)) {
@@ -443,6 +456,21 @@ function buildContext(options) {
443
456
  }
444
457
  return merged;
445
458
  }
459
+ function validateSubagentRefs(persona, agentMap) {
460
+ const subagents = persona.subagents;
461
+ if (!Array.isArray(subagents) || subagents.length === 0) return [];
462
+ const results = [];
463
+ for (const slug of subagents) {
464
+ const key = `agent_slug_${slug.replace(/-/g, "_")}`;
465
+ if (!(key in agentMap)) {
466
+ results.push({
467
+ severity: "error",
468
+ message: `Persona '${persona.name}' declares subagent '${slug}' but no persona with that slug exists in any configured suite.`
469
+ });
470
+ }
471
+ }
472
+ return results;
473
+ }
446
474
  async function buildPersona(personaYamlPath, suiteName, suiteConfig, sharedMeta, partialsMap, config, plugins, target, agentMap = {}, registry = defaultRegistry) {
447
475
  const personaMeta = await loadPersonaYaml(personaYamlPath);
448
476
  let context = buildContext({
@@ -481,7 +509,10 @@ async function buildPersona(personaYamlPath, suiteName, suiteConfig, sharedMeta,
481
509
  ${body}
482
510
  `);
483
511
  output = runPostRender(plugins, output, personaMetaTyped, target);
484
- const validationResults = runValidate(plugins, personaMetaTyped, suiteConfig, target);
512
+ const validationResults = [
513
+ ...runValidate(plugins, personaMetaTyped, suiteConfig, target),
514
+ ...validateSubagentRefs(personaMetaTyped, agentMap)
515
+ ];
485
516
  const def = registry.has(target) ? registry.get(target) : void 0;
486
517
  const outputDir = resolveOutputDir(target, suiteConfig, def);
487
518
  const fnKey = def?.filenameContextKey;