@mistralys/persona-builder 2.5.0 → 2.6.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
@@ -65,7 +65,10 @@ function resolveConditionals(text, context) {
65
65
 
66
66
  // src/engine/variables.ts
67
67
  function resolveVariables(text, context, filename) {
68
- return text.replace(/\{\{(\w+)\}\}/g, (match, varName) => {
68
+ return text.replace(/(\\?)\{\{(\w+)\}\}/g, (match, escape, varName) => {
69
+ if (escape === "\\") {
70
+ return `{{${varName}}}`;
71
+ }
69
72
  if (varName in context && context[varName] !== void 0) {
70
73
  return String(context[varName]);
71
74
  }
@@ -214,6 +217,26 @@ function renderFrontmatter(template, context, filename) {
214
217
  return rendered;
215
218
  }
216
219
 
220
+ // src/utils/changelog.ts
221
+ var RE_VERSION_WITH_DATE = /^(\d+\.\d+\.\d+)\s*\((\d{4}-\d{2}-\d{2})\)\s*:/;
222
+ var RE_VERSION_ONLY = /^(\d+\.\d+\.\d+)\s*:/;
223
+ function resolveChangelogMeta(input) {
224
+ if (typeof input !== "string" || input.trim() === "") {
225
+ return void 0;
226
+ }
227
+ for (const line of input.split(/\r?\n/)) {
228
+ const withDate = RE_VERSION_WITH_DATE.exec(line);
229
+ if (withDate !== null) {
230
+ return { version: withDate[1], date: withDate[2] };
231
+ }
232
+ const versionOnly = RE_VERSION_ONLY.exec(line);
233
+ if (versionOnly !== null) {
234
+ return { version: versionOnly[1], date: "" };
235
+ }
236
+ }
237
+ return void 0;
238
+ }
239
+
217
240
  // src/targets/registry.ts
218
241
  var TargetRegistry = class _TargetRegistry {
219
242
  // Map preserves insertion order — names() and allDefinitions() are
@@ -371,7 +394,8 @@ async function buildAgentNameMap(config) {
371
394
  const persona = await loadPersonaYaml(yamlPath);
372
395
  const slug = typeof persona["slug"] === "string" ? persona["slug"] : path2.basename(yamlPath, ".yaml");
373
396
  const name = typeof persona["name"] === "string" ? persona["name"] : slug;
374
- const version = typeof persona["version"] === "string" ? persona["version"] : defaultVersion;
397
+ const clMeta = resolveChangelogMeta(persona["changelog"]);
398
+ const version = clMeta?.version ?? defaultVersion;
375
399
  const underscoredSlug = slug.replace(/-/g, "_");
376
400
  const key = `agent_${underscoredSlug}`;
377
401
  agentMap[key] = `${name} v${version}`;
@@ -391,7 +415,8 @@ function buildContext(options) {
391
415
  configVariables,
392
416
  suiteVariables
393
417
  } = options;
394
- const version = typeof personaMeta["version"] === "string" ? personaMeta["version"] : typeof sharedMeta["default_version"] === "string" ? sharedMeta["default_version"] : "0.0.0";
418
+ const clMeta = resolveChangelogMeta(personaMeta["changelog"]);
419
+ const version = clMeta?.version ?? (typeof sharedMeta["default_version"] === "string" ? sharedMeta["default_version"] : "0.0.0");
395
420
  const merged = {
396
421
  ...configVariables ?? {},
397
422
  ...suiteVariables ?? {},
@@ -399,6 +424,9 @@ function buildContext(options) {
399
424
  ...personaMeta,
400
425
  version
401
426
  };
427
+ if (!("last_updated" in merged)) {
428
+ merged["last_updated"] = clMeta?.date ?? "";
429
+ }
402
430
  const tools = Array.isArray(merged["tools"]) ? merged["tools"] : [];
403
431
  if (!("tools_list" in merged)) {
404
432
  merged["tools_list"] = serializeToolsList(tools);