@mistralys/persona-builder 2.5.1 → 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.d.cts CHANGED
@@ -1308,6 +1308,51 @@ declare function validateStrictMarkers(renderedContent: string, requiredMarkers:
1308
1308
  */
1309
1309
  declare function escapeRegExp(str: string): string;
1310
1310
 
1311
+ /**
1312
+ * src/utils/changelog.ts
1313
+ *
1314
+ * Utility for extracting version and date metadata from a changelog block scalar.
1315
+ *
1316
+ * Pure function — zero imports, no I/O, no side effects.
1317
+ */
1318
+ /**
1319
+ * Version and date metadata extracted from a changelog entry.
1320
+ *
1321
+ * `date` is an empty string when the changelog entry has no date component.
1322
+ */
1323
+ interface ChangelogMeta {
1324
+ /** Semver version string, e.g. `'1.5.0'` */
1325
+ version: string;
1326
+ /** ISO date string (`YYYY-MM-DD`), or `''` if absent */
1327
+ date: string;
1328
+ }
1329
+ /**
1330
+ * Extract `version` and `date` from the first matching line of a changelog
1331
+ * block scalar.
1332
+ *
1333
+ * Lines are inspected in order; the first line that contains a recognisable
1334
+ * semver entry wins. This ensures that a later entry with a date does not
1335
+ * shadow an earlier entry that has no date.
1336
+ *
1337
+ * Accepts `unknown` input so callers can pass raw YAML values without casting.
1338
+ * Returns `undefined` when the input is not a non-empty string or contains no
1339
+ * recognisable version line.
1340
+ *
1341
+ * @param input Raw changelog value (typically a YAML block scalar string)
1342
+ * @returns Extracted `{ version, date }`, or `undefined`
1343
+ *
1344
+ * @example
1345
+ * resolveChangelogMeta('1.5.0 (2026-06-13): Added feature')
1346
+ * // => { version: '1.5.0', date: '2026-06-13' }
1347
+ *
1348
+ * resolveChangelogMeta('1.5.0: Added feature')
1349
+ * // => { version: '1.5.0', date: '' }
1350
+ *
1351
+ * resolveChangelogMeta(undefined)
1352
+ * // => undefined
1353
+ */
1354
+ declare function resolveChangelogMeta(input: unknown): ChangelogMeta | undefined;
1355
+
1311
1356
  /**
1312
1357
  * src/targets/built-in.ts
1313
1358
  *
@@ -1340,4 +1385,4 @@ declare const defaultRegistry: TargetRegistry;
1340
1385
 
1341
1386
  declare const VERSION: string;
1342
1387
 
1343
- 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, runPartials, runPersonaPartials, runPostRender, runSuiteInit, runValidate, serializeTools, serializeToolsBlock, serializeToolsList, validateFileName, validateStrictMarkers };
1388
+ export { type BuildConfig, type BuildResult, type BuildSummary, type ChangelogMeta, 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, resolveChangelogMeta, resolveConditionals, resolveFrontmatterTemplate, resolvePartials, resolveVariables, runBuildContext, runPartials, runPersonaPartials, runPostRender, runSuiteInit, runValidate, serializeTools, serializeToolsBlock, serializeToolsList, validateFileName, validateStrictMarkers };
package/dist/index.d.ts CHANGED
@@ -1308,6 +1308,51 @@ declare function validateStrictMarkers(renderedContent: string, requiredMarkers:
1308
1308
  */
1309
1309
  declare function escapeRegExp(str: string): string;
1310
1310
 
1311
+ /**
1312
+ * src/utils/changelog.ts
1313
+ *
1314
+ * Utility for extracting version and date metadata from a changelog block scalar.
1315
+ *
1316
+ * Pure function — zero imports, no I/O, no side effects.
1317
+ */
1318
+ /**
1319
+ * Version and date metadata extracted from a changelog entry.
1320
+ *
1321
+ * `date` is an empty string when the changelog entry has no date component.
1322
+ */
1323
+ interface ChangelogMeta {
1324
+ /** Semver version string, e.g. `'1.5.0'` */
1325
+ version: string;
1326
+ /** ISO date string (`YYYY-MM-DD`), or `''` if absent */
1327
+ date: string;
1328
+ }
1329
+ /**
1330
+ * Extract `version` and `date` from the first matching line of a changelog
1331
+ * block scalar.
1332
+ *
1333
+ * Lines are inspected in order; the first line that contains a recognisable
1334
+ * semver entry wins. This ensures that a later entry with a date does not
1335
+ * shadow an earlier entry that has no date.
1336
+ *
1337
+ * Accepts `unknown` input so callers can pass raw YAML values without casting.
1338
+ * Returns `undefined` when the input is not a non-empty string or contains no
1339
+ * recognisable version line.
1340
+ *
1341
+ * @param input Raw changelog value (typically a YAML block scalar string)
1342
+ * @returns Extracted `{ version, date }`, or `undefined`
1343
+ *
1344
+ * @example
1345
+ * resolveChangelogMeta('1.5.0 (2026-06-13): Added feature')
1346
+ * // => { version: '1.5.0', date: '2026-06-13' }
1347
+ *
1348
+ * resolveChangelogMeta('1.5.0: Added feature')
1349
+ * // => { version: '1.5.0', date: '' }
1350
+ *
1351
+ * resolveChangelogMeta(undefined)
1352
+ * // => undefined
1353
+ */
1354
+ declare function resolveChangelogMeta(input: unknown): ChangelogMeta | undefined;
1355
+
1311
1356
  /**
1312
1357
  * src/targets/built-in.ts
1313
1358
  *
@@ -1340,4 +1385,4 @@ declare const defaultRegistry: TargetRegistry;
1340
1385
 
1341
1386
  declare const VERSION: string;
1342
1387
 
1343
- 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, runPartials, runPersonaPartials, runPostRender, runSuiteInit, runValidate, serializeTools, serializeToolsBlock, serializeToolsList, validateFileName, validateStrictMarkers };
1388
+ export { type BuildConfig, type BuildResult, type BuildSummary, type ChangelogMeta, 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, resolveChangelogMeta, resolveConditionals, resolveFrontmatterTemplate, resolvePartials, resolveVariables, runBuildContext, runPartials, runPersonaPartials, runPostRender, runSuiteInit, runValidate, serializeTools, serializeToolsBlock, serializeToolsList, validateFileName, validateStrictMarkers };
package/dist/index.js CHANGED
@@ -243,6 +243,26 @@ function renderFrontmatter(template, context, filename) {
243
243
  return rendered;
244
244
  }
245
245
 
246
+ // src/utils/changelog.ts
247
+ var RE_VERSION_WITH_DATE = /^(\d+\.\d+\.\d+)\s*\((\d{4}-\d{2}-\d{2})\)\s*:/;
248
+ var RE_VERSION_ONLY = /^(\d+\.\d+\.\d+)\s*:/;
249
+ function resolveChangelogMeta(input) {
250
+ if (typeof input !== "string" || input.trim() === "") {
251
+ return void 0;
252
+ }
253
+ for (const line of input.split(/\r?\n/)) {
254
+ const withDate = RE_VERSION_WITH_DATE.exec(line);
255
+ if (withDate !== null) {
256
+ return { version: withDate[1], date: withDate[2] };
257
+ }
258
+ const versionOnly = RE_VERSION_ONLY.exec(line);
259
+ if (versionOnly !== null) {
260
+ return { version: versionOnly[1], date: "" };
261
+ }
262
+ }
263
+ return void 0;
264
+ }
265
+
246
266
  // src/targets/registry.ts
247
267
  var TargetRegistry = class _TargetRegistry {
248
268
  // Map preserves insertion order — names() and allDefinitions() are
@@ -400,7 +420,8 @@ async function buildAgentNameMap(config) {
400
420
  const persona = await loadPersonaYaml(yamlPath);
401
421
  const slug = typeof persona["slug"] === "string" ? persona["slug"] : path4.basename(yamlPath, ".yaml");
402
422
  const name = typeof persona["name"] === "string" ? persona["name"] : slug;
403
- const version = typeof persona["version"] === "string" ? persona["version"] : defaultVersion;
423
+ const clMeta = resolveChangelogMeta(persona["changelog"]);
424
+ const version = clMeta?.version ?? defaultVersion;
404
425
  const underscoredSlug = slug.replace(/-/g, "_");
405
426
  const key = `agent_${underscoredSlug}`;
406
427
  agentMap[key] = `${name} v${version}`;
@@ -420,7 +441,8 @@ function buildContext(options) {
420
441
  configVariables,
421
442
  suiteVariables
422
443
  } = options;
423
- const version = typeof personaMeta["version"] === "string" ? personaMeta["version"] : typeof sharedMeta["default_version"] === "string" ? sharedMeta["default_version"] : "0.0.0";
444
+ const clMeta = resolveChangelogMeta(personaMeta["changelog"]);
445
+ const version = clMeta?.version ?? (typeof sharedMeta["default_version"] === "string" ? sharedMeta["default_version"] : "0.0.0");
424
446
  const merged = {
425
447
  ...configVariables ?? {},
426
448
  ...suiteVariables ?? {},
@@ -428,6 +450,9 @@ function buildContext(options) {
428
450
  ...personaMeta,
429
451
  version
430
452
  };
453
+ if (!("last_updated" in merged)) {
454
+ merged["last_updated"] = clMeta?.date ?? "";
455
+ }
431
456
  const tools = Array.isArray(merged["tools"]) ? merged["tools"] : [];
432
457
  if (!("tools_list" in merged)) {
433
458
  merged["tools_list"] = serializeToolsList(tools);
@@ -694,6 +719,6 @@ function escapeRegExp(str) {
694
719
  var _pkgRequire = createRequire(import.meta.url);
695
720
  var VERSION = _pkgRequire("../package.json").version;
696
721
 
697
- export { DEFAULT_FRONTMATTER_CLAUDE_CODE, DEFAULT_FRONTMATTER_DEEP_AGENTS, DEFAULT_FRONTMATTER_VSCODE, TARGET_CLAUDE_CODE, TARGET_DEEP_AGENTS, TARGET_VSCODE, TargetRegistry, VERSION, build, buildPersona, buildSuite, collapseBlankLines, defaultRegistry, discoverPersonaYamls, ensureBlankLineBeforeHeadings, escapeRegExp, loadContent, loadMetadata, loadPartials, normalizeNewlines, renderFrontmatter, resolveConditionals, resolveFrontmatterTemplate, resolvePartials, resolveVariables, runBuildContext, runPartials, runPersonaPartials, runPostRender, runSuiteInit, runValidate, serializeTools, serializeToolsBlock, serializeToolsList, validateFileName, validateStrictMarkers };
722
+ export { DEFAULT_FRONTMATTER_CLAUDE_CODE, DEFAULT_FRONTMATTER_DEEP_AGENTS, DEFAULT_FRONTMATTER_VSCODE, TARGET_CLAUDE_CODE, TARGET_DEEP_AGENTS, TARGET_VSCODE, TargetRegistry, VERSION, build, buildPersona, buildSuite, collapseBlankLines, defaultRegistry, discoverPersonaYamls, ensureBlankLineBeforeHeadings, escapeRegExp, loadContent, loadMetadata, loadPartials, normalizeNewlines, renderFrontmatter, resolveChangelogMeta, resolveConditionals, resolveFrontmatterTemplate, resolvePartials, resolveVariables, runBuildContext, runPartials, runPersonaPartials, runPostRender, runSuiteInit, runValidate, serializeTools, serializeToolsBlock, serializeToolsList, validateFileName, validateStrictMarkers };
698
723
  //# sourceMappingURL=index.js.map
699
724
  //# sourceMappingURL=index.js.map