@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/index.cjs CHANGED
@@ -73,7 +73,10 @@ function resolveConditionals(text, context) {
73
73
 
74
74
  // src/engine/variables.ts
75
75
  function resolveVariables(text, context, filename) {
76
- return text.replace(/\{\{(\w+)\}\}/g, (match, varName) => {
76
+ return text.replace(/(\\?)\{\{(\w+)\}\}/g, (match, escape, varName) => {
77
+ if (escape === "\\") {
78
+ return `{{${varName}}}`;
79
+ }
77
80
  if (varName in context && context[varName] !== void 0) {
78
81
  return String(context[varName]);
79
82
  }
@@ -248,6 +251,26 @@ function renderFrontmatter(template, context, filename) {
248
251
  return rendered;
249
252
  }
250
253
 
254
+ // src/utils/changelog.ts
255
+ var RE_VERSION_WITH_DATE = /^(\d+\.\d+\.\d+)\s*\((\d{4}-\d{2}-\d{2})\)\s*:/;
256
+ var RE_VERSION_ONLY = /^(\d+\.\d+\.\d+)\s*:/;
257
+ function resolveChangelogMeta(input) {
258
+ if (typeof input !== "string" || input.trim() === "") {
259
+ return void 0;
260
+ }
261
+ for (const line of input.split(/\r?\n/)) {
262
+ const withDate = RE_VERSION_WITH_DATE.exec(line);
263
+ if (withDate !== null) {
264
+ return { version: withDate[1], date: withDate[2] };
265
+ }
266
+ const versionOnly = RE_VERSION_ONLY.exec(line);
267
+ if (versionOnly !== null) {
268
+ return { version: versionOnly[1], date: "" };
269
+ }
270
+ }
271
+ return void 0;
272
+ }
273
+
251
274
  // src/targets/registry.ts
252
275
  var TargetRegistry = class _TargetRegistry {
253
276
  // Map preserves insertion order — names() and allDefinitions() are
@@ -405,7 +428,8 @@ async function buildAgentNameMap(config) {
405
428
  const persona = await loadPersonaYaml(yamlPath);
406
429
  const slug = typeof persona["slug"] === "string" ? persona["slug"] : path4__default.default.basename(yamlPath, ".yaml");
407
430
  const name = typeof persona["name"] === "string" ? persona["name"] : slug;
408
- const version = typeof persona["version"] === "string" ? persona["version"] : defaultVersion;
431
+ const clMeta = resolveChangelogMeta(persona["changelog"]);
432
+ const version = clMeta?.version ?? defaultVersion;
409
433
  const underscoredSlug = slug.replace(/-/g, "_");
410
434
  const key = `agent_${underscoredSlug}`;
411
435
  agentMap[key] = `${name} v${version}`;
@@ -425,7 +449,8 @@ function buildContext(options) {
425
449
  configVariables,
426
450
  suiteVariables
427
451
  } = options;
428
- const version = typeof personaMeta["version"] === "string" ? personaMeta["version"] : typeof sharedMeta["default_version"] === "string" ? sharedMeta["default_version"] : "0.0.0";
452
+ const clMeta = resolveChangelogMeta(personaMeta["changelog"]);
453
+ const version = clMeta?.version ?? (typeof sharedMeta["default_version"] === "string" ? sharedMeta["default_version"] : "0.0.0");
429
454
  const merged = {
430
455
  ...configVariables ?? {},
431
456
  ...suiteVariables ?? {},
@@ -433,6 +458,9 @@ function buildContext(options) {
433
458
  ...personaMeta,
434
459
  version
435
460
  };
461
+ if (!("last_updated" in merged)) {
462
+ merged["last_updated"] = clMeta?.date ?? "";
463
+ }
436
464
  const tools = Array.isArray(merged["tools"]) ? merged["tools"] : [];
437
465
  if (!("tools_list" in merged)) {
438
466
  merged["tools_list"] = serializeToolsList(tools);
@@ -720,6 +748,7 @@ exports.loadMetadata = loadMetadata;
720
748
  exports.loadPartials = loadPartials;
721
749
  exports.normalizeNewlines = normalizeNewlines;
722
750
  exports.renderFrontmatter = renderFrontmatter;
751
+ exports.resolveChangelogMeta = resolveChangelogMeta;
723
752
  exports.resolveConditionals = resolveConditionals;
724
753
  exports.resolveFrontmatterTemplate = resolveFrontmatterTemplate;
725
754
  exports.resolvePartials = resolvePartials;