@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/README.md +7 -4
- package/dist/cli.cjs +31 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +31 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +32 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -2
- package/dist/index.d.ts +51 -2
- package/dist/index.js +32 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -86,7 +86,7 @@ declare function resolveConditionals(text: string, context: Record<string, unkno
|
|
|
86
86
|
* variables.ts
|
|
87
87
|
*
|
|
88
88
|
* Pure template-engine function for resolving variable substitutions.
|
|
89
|
-
* Handles {{varName}} syntax. No file-system I/O.
|
|
89
|
+
* Handles {{varName}} substitution and \{{varName}} escape syntax. No file-system I/O.
|
|
90
90
|
*/
|
|
91
91
|
/**
|
|
92
92
|
* Resolve variable substitutions in a template string.
|
|
@@ -96,6 +96,10 @@ declare function resolveConditionals(text: string, context: Record<string, unkno
|
|
|
96
96
|
* the original marker is preserved and a warning is emitted via
|
|
97
97
|
* `console.warn`, identifying the file by `filename` for easier debugging.
|
|
98
98
|
*
|
|
99
|
+
* **Escape syntax:** prefix a marker with a backslash (`\{{varName}}`) to
|
|
100
|
+
* emit the literal `{{varName}}` text in the output without performing any
|
|
101
|
+
* lookup or triggering an unresolved-variable warning.
|
|
102
|
+
*
|
|
99
103
|
* Note: this step must run AFTER `resolvePartials` and `resolveConditionals`
|
|
100
104
|
* so that only plain variable markers remain.
|
|
101
105
|
*
|
|
@@ -1304,6 +1308,51 @@ declare function validateStrictMarkers(renderedContent: string, requiredMarkers:
|
|
|
1304
1308
|
*/
|
|
1305
1309
|
declare function escapeRegExp(str: string): string;
|
|
1306
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
|
+
|
|
1307
1356
|
/**
|
|
1308
1357
|
* src/targets/built-in.ts
|
|
1309
1358
|
*
|
|
@@ -1336,4 +1385,4 @@ declare const defaultRegistry: TargetRegistry;
|
|
|
1336
1385
|
|
|
1337
1386
|
declare const VERSION: string;
|
|
1338
1387
|
|
|
1339
|
-
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
|
@@ -86,7 +86,7 @@ declare function resolveConditionals(text: string, context: Record<string, unkno
|
|
|
86
86
|
* variables.ts
|
|
87
87
|
*
|
|
88
88
|
* Pure template-engine function for resolving variable substitutions.
|
|
89
|
-
* Handles {{varName}} syntax. No file-system I/O.
|
|
89
|
+
* Handles {{varName}} substitution and \{{varName}} escape syntax. No file-system I/O.
|
|
90
90
|
*/
|
|
91
91
|
/**
|
|
92
92
|
* Resolve variable substitutions in a template string.
|
|
@@ -96,6 +96,10 @@ declare function resolveConditionals(text: string, context: Record<string, unkno
|
|
|
96
96
|
* the original marker is preserved and a warning is emitted via
|
|
97
97
|
* `console.warn`, identifying the file by `filename` for easier debugging.
|
|
98
98
|
*
|
|
99
|
+
* **Escape syntax:** prefix a marker with a backslash (`\{{varName}}`) to
|
|
100
|
+
* emit the literal `{{varName}}` text in the output without performing any
|
|
101
|
+
* lookup or triggering an unresolved-variable warning.
|
|
102
|
+
*
|
|
99
103
|
* Note: this step must run AFTER `resolvePartials` and `resolveConditionals`
|
|
100
104
|
* so that only plain variable markers remain.
|
|
101
105
|
*
|
|
@@ -1304,6 +1308,51 @@ declare function validateStrictMarkers(renderedContent: string, requiredMarkers:
|
|
|
1304
1308
|
*/
|
|
1305
1309
|
declare function escapeRegExp(str: string): string;
|
|
1306
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
|
+
|
|
1307
1356
|
/**
|
|
1308
1357
|
* src/targets/built-in.ts
|
|
1309
1358
|
*
|
|
@@ -1336,4 +1385,4 @@ declare const defaultRegistry: TargetRegistry;
|
|
|
1336
1385
|
|
|
1337
1386
|
declare const VERSION: string;
|
|
1338
1387
|
|
|
1339
|
-
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
|
@@ -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(
|
|
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
|
}
|
|
@@ -240,6 +243,26 @@ function renderFrontmatter(template, context, filename) {
|
|
|
240
243
|
return rendered;
|
|
241
244
|
}
|
|
242
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
|
+
|
|
243
266
|
// src/targets/registry.ts
|
|
244
267
|
var TargetRegistry = class _TargetRegistry {
|
|
245
268
|
// Map preserves insertion order — names() and allDefinitions() are
|
|
@@ -397,7 +420,8 @@ async function buildAgentNameMap(config) {
|
|
|
397
420
|
const persona = await loadPersonaYaml(yamlPath);
|
|
398
421
|
const slug = typeof persona["slug"] === "string" ? persona["slug"] : path4.basename(yamlPath, ".yaml");
|
|
399
422
|
const name = typeof persona["name"] === "string" ? persona["name"] : slug;
|
|
400
|
-
const
|
|
423
|
+
const clMeta = resolveChangelogMeta(persona["changelog"]);
|
|
424
|
+
const version = clMeta?.version ?? defaultVersion;
|
|
401
425
|
const underscoredSlug = slug.replace(/-/g, "_");
|
|
402
426
|
const key = `agent_${underscoredSlug}`;
|
|
403
427
|
agentMap[key] = `${name} v${version}`;
|
|
@@ -417,7 +441,8 @@ function buildContext(options) {
|
|
|
417
441
|
configVariables,
|
|
418
442
|
suiteVariables
|
|
419
443
|
} = options;
|
|
420
|
-
const
|
|
444
|
+
const clMeta = resolveChangelogMeta(personaMeta["changelog"]);
|
|
445
|
+
const version = clMeta?.version ?? (typeof sharedMeta["default_version"] === "string" ? sharedMeta["default_version"] : "0.0.0");
|
|
421
446
|
const merged = {
|
|
422
447
|
...configVariables ?? {},
|
|
423
448
|
...suiteVariables ?? {},
|
|
@@ -425,6 +450,9 @@ function buildContext(options) {
|
|
|
425
450
|
...personaMeta,
|
|
426
451
|
version
|
|
427
452
|
};
|
|
453
|
+
if (!("last_updated" in merged)) {
|
|
454
|
+
merged["last_updated"] = clMeta?.date ?? "";
|
|
455
|
+
}
|
|
428
456
|
const tools = Array.isArray(merged["tools"]) ? merged["tools"] : [];
|
|
429
457
|
if (!("tools_list" in merged)) {
|
|
430
458
|
merged["tools_list"] = serializeToolsList(tools);
|
|
@@ -691,6 +719,6 @@ function escapeRegExp(str) {
|
|
|
691
719
|
var _pkgRequire = createRequire(import.meta.url);
|
|
692
720
|
var VERSION = _pkgRequire("../package.json").version;
|
|
693
721
|
|
|
694
|
-
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 };
|
|
695
723
|
//# sourceMappingURL=index.js.map
|
|
696
724
|
//# sourceMappingURL=index.js.map
|