@promptscript/cli 1.14.2 → 1.15.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/index.js +170 -72
- package/package.json +1 -1
- package/src/commands/compile.d.ts.map +1 -1
- package/src/utils/markers.d.ts +3 -10
- package/src/utils/markers.d.ts.map +1 -1
package/index.js
CHANGED
|
@@ -840,6 +840,30 @@ var init_levenshtein = __esm({
|
|
|
840
840
|
}
|
|
841
841
|
});
|
|
842
842
|
|
|
843
|
+
// packages/core/src/utils/markers.ts
|
|
844
|
+
function stripPromptScriptMarkers(content) {
|
|
845
|
+
return content.replace(new RegExp(`${HTML_MARKER}\\n*`, "g"), "").replace(new RegExp(`${YAML_MARKER}[^\\n]+\\n*`, "g"), "");
|
|
846
|
+
}
|
|
847
|
+
function isGeneratedByPromptScript(content) {
|
|
848
|
+
const head = new RegExp(`^\\s*(?:${YAML_MARKER}|${HTML_MARKER})`);
|
|
849
|
+
return content.split("\n", 5).some((line) => head.test(line));
|
|
850
|
+
}
|
|
851
|
+
function stripFrontmatterMarkerLines(frontmatter) {
|
|
852
|
+
const markerLine = new RegExp(`^\\s*${YAML_MARKER}`);
|
|
853
|
+
return frontmatter.split("\n").filter((line) => !markerLine.test(line)).join("\n");
|
|
854
|
+
}
|
|
855
|
+
function stripLeadingHtmlMarker(body) {
|
|
856
|
+
return body.replace(new RegExp(`^\\s*${HTML_MARKER}\\n*`), "");
|
|
857
|
+
}
|
|
858
|
+
var HTML_MARKER, YAML_MARKER;
|
|
859
|
+
var init_markers = __esm({
|
|
860
|
+
"packages/core/src/utils/markers.ts"() {
|
|
861
|
+
"use strict";
|
|
862
|
+
HTML_MARKER = "<!--\\s*PromptScript [^>]+-->";
|
|
863
|
+
YAML_MARKER = "#\\s*promptscript-generated:";
|
|
864
|
+
}
|
|
865
|
+
});
|
|
866
|
+
|
|
843
867
|
// packages/core/src/utils/index.ts
|
|
844
868
|
var init_utils = __esm({
|
|
845
869
|
"packages/core/src/utils/index.ts"() {
|
|
@@ -850,6 +874,7 @@ var init_utils = __esm({
|
|
|
850
874
|
init_path();
|
|
851
875
|
init_version();
|
|
852
876
|
init_levenshtein();
|
|
877
|
+
init_markers();
|
|
853
878
|
}
|
|
854
879
|
});
|
|
855
880
|
|
|
@@ -26841,16 +26866,22 @@ function extractReservedParams(params) {
|
|
|
26841
26866
|
const remaining = [];
|
|
26842
26867
|
let only;
|
|
26843
26868
|
let exclude;
|
|
26869
|
+
let includes;
|
|
26870
|
+
let excludes;
|
|
26844
26871
|
for (const param of params) {
|
|
26845
26872
|
if (param.name === "only" && Array.isArray(param.value)) {
|
|
26846
26873
|
only = param.value.filter((v) => typeof v === "string");
|
|
26847
26874
|
} else if (param.name === "exclude" && Array.isArray(param.value)) {
|
|
26848
26875
|
exclude = param.value.filter((v) => typeof v === "string");
|
|
26876
|
+
} else if (param.name === "includes" && Array.isArray(param.value)) {
|
|
26877
|
+
includes = param.value.filter((v) => typeof v === "string");
|
|
26878
|
+
} else if (param.name === "excludes" && Array.isArray(param.value)) {
|
|
26879
|
+
excludes = param.value.filter((v) => typeof v === "string");
|
|
26849
26880
|
} else {
|
|
26850
26881
|
remaining.push(param);
|
|
26851
26882
|
}
|
|
26852
26883
|
}
|
|
26853
|
-
return { only, exclude, remaining };
|
|
26884
|
+
return { only, exclude, includes, excludes, remaining };
|
|
26854
26885
|
}
|
|
26855
26886
|
function filterBlocks(blocks, options) {
|
|
26856
26887
|
if (options.only) {
|
|
@@ -26863,6 +26894,44 @@ function filterBlocks(blocks, options) {
|
|
|
26863
26894
|
}
|
|
26864
26895
|
return blocks;
|
|
26865
26896
|
}
|
|
26897
|
+
function filterSkillsBlock(program2, options) {
|
|
26898
|
+
if (!options.includes && !options.excludes) {
|
|
26899
|
+
return program2;
|
|
26900
|
+
}
|
|
26901
|
+
const skillsBlock = program2.blocks.find((b) => b.name === "skills");
|
|
26902
|
+
if (!skillsBlock || skillsBlock.content.type !== "ObjectContent") {
|
|
26903
|
+
return program2;
|
|
26904
|
+
}
|
|
26905
|
+
const props = skillsBlock.content.properties;
|
|
26906
|
+
const skillNames = Object.keys(props);
|
|
26907
|
+
let filteredNames;
|
|
26908
|
+
if (options.includes) {
|
|
26909
|
+
const allowSet = new Set(options.includes);
|
|
26910
|
+
filteredNames = skillNames.filter((name) => allowSet.has(name));
|
|
26911
|
+
} else {
|
|
26912
|
+
const denySet = new Set(options.excludes);
|
|
26913
|
+
filteredNames = skillNames.filter((name) => !denySet.has(name));
|
|
26914
|
+
}
|
|
26915
|
+
if (filteredNames.length === skillNames.length) {
|
|
26916
|
+
return program2;
|
|
26917
|
+
}
|
|
26918
|
+
const filteredProps = {};
|
|
26919
|
+
for (const name of filteredNames) {
|
|
26920
|
+
filteredProps[name] = deepCloneValue2(props[name]);
|
|
26921
|
+
}
|
|
26922
|
+
const newSkillsBlock = {
|
|
26923
|
+
...deepClone(skillsBlock),
|
|
26924
|
+
content: {
|
|
26925
|
+
type: "ObjectContent",
|
|
26926
|
+
properties: filteredProps,
|
|
26927
|
+
loc: skillsBlock.content.loc
|
|
26928
|
+
}
|
|
26929
|
+
};
|
|
26930
|
+
return {
|
|
26931
|
+
...program2,
|
|
26932
|
+
blocks: program2.blocks.map((b) => b.name === "skills" ? newSkillsBlock : b)
|
|
26933
|
+
};
|
|
26934
|
+
}
|
|
26866
26935
|
|
|
26867
26936
|
// packages/resolver/src/extensions.ts
|
|
26868
26937
|
init_src();
|
|
@@ -27480,7 +27549,9 @@ function parseSkillMd(content) {
|
|
|
27480
27549
|
let rawFrontmatter;
|
|
27481
27550
|
let bodyContent;
|
|
27482
27551
|
if (frontmatterStart >= 0 && frontmatterEnd > frontmatterStart) {
|
|
27483
|
-
const frontmatterLines =
|
|
27552
|
+
const frontmatterLines = stripFrontmatterMarkerLines(
|
|
27553
|
+
lines.slice(frontmatterStart + 1, frontmatterEnd).join("\n")
|
|
27554
|
+
).split("\n");
|
|
27484
27555
|
const parsed = parseFrontmatterFields(frontmatterLines);
|
|
27485
27556
|
name = parsed.name;
|
|
27486
27557
|
description = parsed.description;
|
|
@@ -27491,9 +27562,9 @@ function parseSkillMd(content) {
|
|
|
27491
27562
|
scripts = parsed.scripts;
|
|
27492
27563
|
license = parsed.license;
|
|
27493
27564
|
rawFrontmatter = frontmatterLines.join("\n");
|
|
27494
|
-
bodyContent = lines.slice(frontmatterEnd + 1).join("\n").trim();
|
|
27565
|
+
bodyContent = stripLeadingHtmlMarker(lines.slice(frontmatterEnd + 1).join("\n")).trim();
|
|
27495
27566
|
} else {
|
|
27496
|
-
bodyContent = content.trim();
|
|
27567
|
+
bodyContent = stripLeadingHtmlMarker(content).trim();
|
|
27497
27568
|
}
|
|
27498
27569
|
return {
|
|
27499
27570
|
name,
|
|
@@ -28165,6 +28236,13 @@ async function fileExists(path2) {
|
|
|
28165
28236
|
return false;
|
|
28166
28237
|
}
|
|
28167
28238
|
}
|
|
28239
|
+
async function isGeneratedOutput(filePath) {
|
|
28240
|
+
try {
|
|
28241
|
+
return isGeneratedByPromptScript(await readFile8(filePath, "utf-8"));
|
|
28242
|
+
} catch {
|
|
28243
|
+
return false;
|
|
28244
|
+
}
|
|
28245
|
+
}
|
|
28168
28246
|
async function discoverSkillDirs(basePath) {
|
|
28169
28247
|
const result = /* @__PURE__ */ new Map();
|
|
28170
28248
|
const queue = [{ dir: basePath, depth: 0 }];
|
|
@@ -28182,7 +28260,7 @@ async function discoverSkillDirs(basePath) {
|
|
|
28182
28260
|
if (!isSafeSkillName(entry.name)) continue;
|
|
28183
28261
|
const subDir = resolve9(dir, entry.name);
|
|
28184
28262
|
const skillMd = resolve9(subDir, "SKILL.md");
|
|
28185
|
-
if (await fileExists(skillMd)) {
|
|
28263
|
+
if (await fileExists(skillMd) && !await isGeneratedOutput(skillMd)) {
|
|
28186
28264
|
if (!result.has(entry.name)) {
|
|
28187
28265
|
result.set(entry.name, subDir);
|
|
28188
28266
|
}
|
|
@@ -28266,6 +28344,10 @@ async function resolveNativeSkills(ast, registryPath, sourceFile, localPath, opt
|
|
|
28266
28344
|
if (skillMdPath && await fileExists(skillMdPath)) {
|
|
28267
28345
|
try {
|
|
28268
28346
|
const rawContent = await readFile8(skillMdPath, "utf-8");
|
|
28347
|
+
if (isGeneratedByPromptScript(rawContent)) {
|
|
28348
|
+
logger.verbose(`Ignoring generated SKILL.md for skill '${skillName}': ${skillMdPath}`);
|
|
28349
|
+
continue;
|
|
28350
|
+
}
|
|
28269
28351
|
const parsed = parseSkillMd(rawContent);
|
|
28270
28352
|
const updatedSkill = { ...skillObj };
|
|
28271
28353
|
const skillArgs = extractSkillArgs(skillObj);
|
|
@@ -28396,6 +28478,10 @@ async function discoverCommandFiles(dir, logger = noopLogger2) {
|
|
|
28396
28478
|
logger.verbose(`Skipping binary command file: ${entry.name}`);
|
|
28397
28479
|
continue;
|
|
28398
28480
|
}
|
|
28481
|
+
if (isGeneratedByPromptScript(content)) {
|
|
28482
|
+
logger.verbose(`Skipping generated command file: ${entry.name}`);
|
|
28483
|
+
continue;
|
|
28484
|
+
}
|
|
28399
28485
|
commands[cmdName] = {
|
|
28400
28486
|
type: "TextContent",
|
|
28401
28487
|
value: content.trim(),
|
|
@@ -28474,8 +28560,8 @@ function parseAgentFrontmatter(content) {
|
|
|
28474
28560
|
searchFrom = idx + 1;
|
|
28475
28561
|
}
|
|
28476
28562
|
if (endIdx === -1) return null;
|
|
28477
|
-
const yamlStr = trimmed.slice(3, endIdx).trim();
|
|
28478
|
-
const body = trimmed.slice(endIdx + 3).trim();
|
|
28563
|
+
const yamlStr = stripFrontmatterMarkerLines(trimmed.slice(3, endIdx)).trim();
|
|
28564
|
+
const body = stripLeadingHtmlMarker(trimmed.slice(endIdx + 3)).trim();
|
|
28479
28565
|
const frontmatter = {};
|
|
28480
28566
|
for (const line of yamlStr.split("\n")) {
|
|
28481
28567
|
const colonIdx = line.indexOf(":");
|
|
@@ -28512,6 +28598,10 @@ async function discoverAgentFiles(dir, logger = noopLogger2) {
|
|
|
28512
28598
|
logger.verbose(`Skipping binary agent file: ${entry.name}`);
|
|
28513
28599
|
continue;
|
|
28514
28600
|
}
|
|
28601
|
+
if (isGeneratedByPromptScript(fileContent)) {
|
|
28602
|
+
logger.verbose(`Skipping generated agent file: ${entry.name}`);
|
|
28603
|
+
continue;
|
|
28604
|
+
}
|
|
28515
28605
|
const parsed = parseAgentFrontmatter(fileContent);
|
|
28516
28606
|
if (!parsed) {
|
|
28517
28607
|
logger.verbose(`Skipping agent file without frontmatter: ${entry.name}`);
|
|
@@ -31178,7 +31268,9 @@ var Resolver = class {
|
|
|
31178
31268
|
errors.push(...imported.errors);
|
|
31179
31269
|
if (imported.ast) {
|
|
31180
31270
|
let resolvedImport = imported.ast;
|
|
31181
|
-
const { only, exclude, remaining } = extractReservedParams(
|
|
31271
|
+
const { only, exclude, includes, excludes, remaining } = extractReservedParams(
|
|
31272
|
+
use.params
|
|
31273
|
+
);
|
|
31182
31274
|
if (imported.ast.meta?.params || remaining.length > 0) {
|
|
31183
31275
|
this.logger.debug(`Binding template parameters for ${importPath}`);
|
|
31184
31276
|
try {
|
|
@@ -31209,6 +31301,12 @@ var Resolver = class {
|
|
|
31209
31301
|
blocks: filterBlocks(resolvedImport.blocks, { only, exclude })
|
|
31210
31302
|
};
|
|
31211
31303
|
}
|
|
31304
|
+
if (includes || excludes) {
|
|
31305
|
+
this.logger.debug(
|
|
31306
|
+
`Filtering skills: ${includes ? `includes=[${includes.join(",")}]` : `excludes=[${excludes.join(",")}]`}`
|
|
31307
|
+
);
|
|
31308
|
+
resolvedImport = filterSkillsBlock(resolvedImport, { includes, excludes });
|
|
31309
|
+
}
|
|
31212
31310
|
let effectiveUse = use;
|
|
31213
31311
|
const fromConfig = this.options.skillTargets?.[use.path.raw];
|
|
31214
31312
|
if (use.outputDir && fromConfig && use.outputDir !== fromConfig) {
|
|
@@ -34384,18 +34482,21 @@ var duplicateSkills = {
|
|
|
34384
34482
|
// packages/validator/src/rules/use-block-filter.ts
|
|
34385
34483
|
init_src();
|
|
34386
34484
|
var BLOCK_TYPE_SET = new Set(BLOCK_TYPES);
|
|
34387
|
-
var
|
|
34485
|
+
var RESERVED_BLOCK_PARAMS = ["only", "exclude"];
|
|
34486
|
+
var RESERVED_SKILL_PARAMS = ["includes", "excludes"];
|
|
34388
34487
|
var useBlockFilter = {
|
|
34389
34488
|
id: "PS021",
|
|
34390
34489
|
name: "use-block-filter",
|
|
34391
|
-
description: "Validate only/exclude
|
|
34490
|
+
description: "Validate only/exclude/includes/excludes filter parameters on @use directives",
|
|
34392
34491
|
defaultSeverity: "error",
|
|
34393
34492
|
validate: (ctx) => {
|
|
34394
34493
|
for (const use of ctx.ast.uses) {
|
|
34395
34494
|
if (!use.params || use.params.length === 0) continue;
|
|
34396
34495
|
const onlyParam = use.params.find((p) => p.name === "only");
|
|
34397
34496
|
const excludeParam = use.params.find((p) => p.name === "exclude");
|
|
34398
|
-
|
|
34497
|
+
const includesParam = use.params.find((p) => p.name === "includes");
|
|
34498
|
+
const excludesParam = use.params.find((p) => p.name === "excludes");
|
|
34499
|
+
if (!onlyParam && !excludeParam && !includesParam && !excludesParam) continue;
|
|
34399
34500
|
if (onlyParam && excludeParam) {
|
|
34400
34501
|
ctx.report({
|
|
34401
34502
|
message: '"only" and "exclude" are mutually exclusive in @use',
|
|
@@ -34404,7 +34505,15 @@ var useBlockFilter = {
|
|
|
34404
34505
|
});
|
|
34405
34506
|
continue;
|
|
34406
34507
|
}
|
|
34407
|
-
|
|
34508
|
+
if (includesParam && excludesParam) {
|
|
34509
|
+
ctx.report({
|
|
34510
|
+
message: '"includes" and "excludes" are mutually exclusive in @use',
|
|
34511
|
+
location: use.loc,
|
|
34512
|
+
suggestion: "Use either includes: [...] or excludes: [...], not both"
|
|
34513
|
+
});
|
|
34514
|
+
continue;
|
|
34515
|
+
}
|
|
34516
|
+
for (const paramName of RESERVED_BLOCK_PARAMS) {
|
|
34408
34517
|
const param = paramName === "only" ? onlyParam : excludeParam;
|
|
34409
34518
|
if (!param) continue;
|
|
34410
34519
|
if (!Array.isArray(param.value)) {
|
|
@@ -34433,6 +34542,25 @@ var useBlockFilter = {
|
|
|
34433
34542
|
}
|
|
34434
34543
|
}
|
|
34435
34544
|
}
|
|
34545
|
+
for (const paramName of RESERVED_SKILL_PARAMS) {
|
|
34546
|
+
const param = paramName === "includes" ? includesParam : excludesParam;
|
|
34547
|
+
if (!param) continue;
|
|
34548
|
+
if (!Array.isArray(param.value)) {
|
|
34549
|
+
ctx.report({
|
|
34550
|
+
message: `"${paramName}" expects an array, got ${typeof param.value}. Use ${paramName}: ["skillName"]`,
|
|
34551
|
+
location: param.loc ?? use.loc
|
|
34552
|
+
});
|
|
34553
|
+
continue;
|
|
34554
|
+
}
|
|
34555
|
+
if (param.value.length === 0) {
|
|
34556
|
+
ctx.report({
|
|
34557
|
+
message: paramName === "includes" ? 'Empty "includes" filter imports nothing \u2014 consider removing this @use' : 'Empty "excludes" filter has no effect \u2014 consider removing the parameter',
|
|
34558
|
+
location: param.loc ?? use.loc,
|
|
34559
|
+
severity: "warning"
|
|
34560
|
+
});
|
|
34561
|
+
continue;
|
|
34562
|
+
}
|
|
34563
|
+
}
|
|
34436
34564
|
}
|
|
34437
34565
|
}
|
|
34438
34566
|
};
|
|
@@ -36778,9 +36906,7 @@ async function resolveRegistryPath(config, options = {}) {
|
|
|
36778
36906
|
import { parse as parseYaml5 } from "yaml";
|
|
36779
36907
|
|
|
36780
36908
|
// packages/cli/src/utils/markers.ts
|
|
36781
|
-
|
|
36782
|
-
return content.replace(/<!-- PromptScript [^>]+ -->\n*/g, "").replace(/# promptscript-generated: [^\n]+\n*/g, "");
|
|
36783
|
-
}
|
|
36909
|
+
init_src();
|
|
36784
36910
|
|
|
36785
36911
|
// packages/cli/src/utils/conflict-detector.ts
|
|
36786
36912
|
init_src();
|
|
@@ -37188,13 +37314,15 @@ function resolveCompileConfigPath(projectRoot, options) {
|
|
|
37188
37314
|
}
|
|
37189
37315
|
return configPath;
|
|
37190
37316
|
}
|
|
37191
|
-
|
|
37317
|
+
function hasPromptScriptMarker(content) {
|
|
37318
|
+
const lines = content.split("\n").slice(0, 50);
|
|
37319
|
+
return lines.some((line) => PROMPTSCRIPT_MARKERS2.some((marker) => line.includes(marker)));
|
|
37320
|
+
}
|
|
37321
|
+
async function readFileOrUndefined(filePath) {
|
|
37192
37322
|
try {
|
|
37193
|
-
|
|
37194
|
-
const lines = content.split("\n").slice(0, 50);
|
|
37195
|
-
return lines.some((line) => PROMPTSCRIPT_MARKERS2.some((marker) => line.includes(marker)));
|
|
37323
|
+
return await readFile14(filePath, "utf-8");
|
|
37196
37324
|
} catch {
|
|
37197
|
-
return
|
|
37325
|
+
return void 0;
|
|
37198
37326
|
}
|
|
37199
37327
|
}
|
|
37200
37328
|
async function promptForOverwrite(filePath, services) {
|
|
@@ -37257,69 +37385,32 @@ async function writeOutputs(outputs, options, _config, services) {
|
|
|
37257
37385
|
for (const output of outputs.values()) {
|
|
37258
37386
|
const outputPath = options.output ? resolve17(options.output, output.path) : resolve17(output.path);
|
|
37259
37387
|
const fileExists3 = existsSync13(outputPath);
|
|
37388
|
+
const existingContent = fileExists3 ? await readFileOrUndefined(outputPath) : void 0;
|
|
37389
|
+
const contentMatches = existingContent !== void 0 && stripPromptScriptMarkers(existingContent) === stripPromptScriptMarkers(output.content);
|
|
37260
37390
|
if (options.dryRun) {
|
|
37261
|
-
if (fileExists3) {
|
|
37262
|
-
const isGenerated2 = await isPromptScriptGenerated3(outputPath);
|
|
37263
|
-
if (isGenerated2) {
|
|
37264
|
-
const existingContent = await readFile14(outputPath, "utf-8");
|
|
37265
|
-
const existingWithoutMarker = stripMarkers(existingContent);
|
|
37266
|
-
const newWithoutMarker = stripMarkers(output.content);
|
|
37267
|
-
if (existingWithoutMarker === newWithoutMarker) {
|
|
37268
|
-
ConsoleOutput.dryRun(`Unchanged: ${outputPath}`);
|
|
37269
|
-
result.unchanged.push(outputPath);
|
|
37270
|
-
} else {
|
|
37271
|
-
ConsoleOutput.dryRun(`Would overwrite: ${outputPath}`);
|
|
37272
|
-
result.written.push(outputPath);
|
|
37273
|
-
}
|
|
37274
|
-
} else {
|
|
37275
|
-
const existingContent = await readFile14(outputPath, "utf-8");
|
|
37276
|
-
if (existingContent === output.content) {
|
|
37277
|
-
ConsoleOutput.dryRun(`Unchanged: ${outputPath}`);
|
|
37278
|
-
result.unchanged.push(outputPath);
|
|
37279
|
-
} else {
|
|
37280
|
-
ConsoleOutput.warning(`Would conflict: ${outputPath} (not generated by PromptScript)`);
|
|
37281
|
-
result.written.push(outputPath);
|
|
37282
|
-
}
|
|
37283
|
-
}
|
|
37284
|
-
} else {
|
|
37391
|
+
if (!fileExists3) {
|
|
37285
37392
|
ConsoleOutput.dryRun(`Would write: ${outputPath}`);
|
|
37286
37393
|
result.written.push(outputPath);
|
|
37287
|
-
}
|
|
37288
|
-
|
|
37289
|
-
|
|
37290
|
-
|
|
37291
|
-
|
|
37292
|
-
|
|
37394
|
+
} else if (contentMatches) {
|
|
37395
|
+
ConsoleOutput.dryRun(`Unchanged: ${outputPath}`);
|
|
37396
|
+
result.unchanged.push(outputPath);
|
|
37397
|
+
} else if (existingContent !== void 0 && hasPromptScriptMarker(existingContent)) {
|
|
37398
|
+
ConsoleOutput.dryRun(`Would overwrite: ${outputPath}`);
|
|
37399
|
+
result.written.push(outputPath);
|
|
37400
|
+
} else {
|
|
37401
|
+
ConsoleOutput.warning(`Would conflict: ${outputPath} (not generated by PromptScript)`);
|
|
37293
37402
|
result.written.push(outputPath);
|
|
37294
37403
|
}
|
|
37295
37404
|
continue;
|
|
37296
37405
|
}
|
|
37297
|
-
|
|
37298
|
-
if (isGenerated) {
|
|
37299
|
-
const existingContent = await readFile14(outputPath, "utf-8");
|
|
37300
|
-
const existingWithoutMarker = stripMarkers(existingContent);
|
|
37301
|
-
const newWithoutMarker = stripMarkers(output.content);
|
|
37302
|
-
if (!options.force && existingWithoutMarker === newWithoutMarker) {
|
|
37303
|
-
if (output.mode !== void 0) {
|
|
37304
|
-
await chmod2(outputPath, output.mode);
|
|
37305
|
-
}
|
|
37306
|
-
ConsoleOutput.unchanged(outputPath);
|
|
37307
|
-
result.unchanged.push(outputPath);
|
|
37308
|
-
continue;
|
|
37309
|
-
}
|
|
37406
|
+
if (!fileExists3) {
|
|
37310
37407
|
if (await safeWrite(outputPath, output.content, output.mode)) {
|
|
37311
37408
|
ConsoleOutput.success(outputPath);
|
|
37312
37409
|
result.written.push(outputPath);
|
|
37313
37410
|
}
|
|
37314
37411
|
continue;
|
|
37315
37412
|
}
|
|
37316
|
-
|
|
37317
|
-
try {
|
|
37318
|
-
const existingContent = await readFile14(outputPath, "utf-8");
|
|
37319
|
-
contentMatches = existingContent === output.content;
|
|
37320
|
-
} catch {
|
|
37321
|
-
}
|
|
37322
|
-
if (!options.force && contentMatches) {
|
|
37413
|
+
if (contentMatches) {
|
|
37323
37414
|
if (output.mode !== void 0) {
|
|
37324
37415
|
await chmod2(outputPath, output.mode);
|
|
37325
37416
|
}
|
|
@@ -37327,6 +37418,13 @@ async function writeOutputs(outputs, options, _config, services) {
|
|
|
37327
37418
|
result.unchanged.push(outputPath);
|
|
37328
37419
|
continue;
|
|
37329
37420
|
}
|
|
37421
|
+
if (existingContent !== void 0 && hasPromptScriptMarker(existingContent)) {
|
|
37422
|
+
if (await safeWrite(outputPath, output.content, output.mode)) {
|
|
37423
|
+
ConsoleOutput.success(outputPath);
|
|
37424
|
+
result.written.push(outputPath);
|
|
37425
|
+
}
|
|
37426
|
+
continue;
|
|
37427
|
+
}
|
|
37330
37428
|
if (options.force || overwriteAll) {
|
|
37331
37429
|
if (await safeWrite(outputPath, output.content, output.mode)) {
|
|
37332
37430
|
ConsoleOutput.success(outputPath);
|
|
@@ -38302,8 +38400,8 @@ async function compareOutput(_name, output, _config, showFull, pager) {
|
|
|
38302
38400
|
return true;
|
|
38303
38401
|
}
|
|
38304
38402
|
const existingContent = await readFile15(outputPath, "utf-8");
|
|
38305
|
-
const existingStripped =
|
|
38306
|
-
const newStripped =
|
|
38403
|
+
const existingStripped = stripPromptScriptMarkers(existingContent);
|
|
38404
|
+
const newStripped = stripPromptScriptMarkers(newContent);
|
|
38307
38405
|
if (existingStripped === newStripped) {
|
|
38308
38406
|
pager.write(chalk2.gray(` ${outputPath} (no changes)`));
|
|
38309
38407
|
return false;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../../../packages/cli/src/commands/compile.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAkBlD,OAAO,EAAE,KAAK,WAAW,EAAyB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../../../packages/cli/src/commands/compile.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAkBlD,OAAO,EAAE,KAAK,WAAW,EAAyB,MAAM,gBAAgB,CAAC;AAmhBzE;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,cAAc,EACvB,QAAQ,GAAE,WAAqC,GAC9C,OAAO,CAAC,IAAI,CAAC,CAEf"}
|
package/src/utils/markers.d.ts
CHANGED
|
@@ -2,15 +2,8 @@
|
|
|
2
2
|
* PromptScript generation marker utilities.
|
|
3
3
|
*
|
|
4
4
|
* Markers are added to compiled output files so the compiler can identify
|
|
5
|
-
* files it previously generated.
|
|
6
|
-
*
|
|
5
|
+
* files it previously generated. Stripping them before content comparison
|
|
6
|
+
* avoids false diffs from timestamp-only changes.
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
* Strip PromptScript generation markers from content for comparison purposes.
|
|
10
|
-
* This allows comparing actual content changes while ignoring timestamp updates.
|
|
11
|
-
*
|
|
12
|
-
* Regex literals are inlined to avoid stateful module-level RegExp objects
|
|
13
|
-
* with the `g` flag (which maintain a `lastIndex` cursor between calls).
|
|
14
|
-
*/
|
|
15
|
-
export declare function stripMarkers(content: string): string;
|
|
8
|
+
export { stripPromptScriptMarkers as stripMarkers } from '@promptscript/core';
|
|
16
9
|
//# sourceMappingURL=markers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markers.d.ts","sourceRoot":"","sources":["../../../../../packages/cli/src/utils/markers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH
|
|
1
|
+
{"version":3,"file":"markers.d.ts","sourceRoot":"","sources":["../../../../../packages/cli/src/utils/markers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,wBAAwB,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|