mustflow 2.18.7 → 2.18.21

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.
Files changed (32) hide show
  1. package/README.md +4 -0
  2. package/dist/cli/commands/dashboard.js +68 -12
  3. package/dist/cli/commands/init.js +20 -20
  4. package/dist/cli/commands/run.js +1 -8
  5. package/dist/cli/commands/update.js +6 -11
  6. package/dist/cli/commands/verify.js +45 -15
  7. package/dist/cli/lib/dashboard-preferences.js +8 -6
  8. package/dist/cli/lib/filesystem.js +11 -1
  9. package/dist/cli/lib/git-changes.js +7 -1
  10. package/dist/cli/lib/local-index/index.js +31 -31
  11. package/dist/cli/lib/manifest-lock.js +38 -12
  12. package/dist/core/change-classification.js +24 -2
  13. package/dist/core/command-classification.js +0 -16
  14. package/dist/core/command-contract-rules.js +23 -3
  15. package/dist/core/run-write-drift.js +4 -0
  16. package/package.json +1 -1
  17. package/templates/default/i18n.toml +42 -6
  18. package/templates/default/locales/en/.mustflow/skills/INDEX.md +11 -5
  19. package/templates/default/locales/en/.mustflow/skills/cli-output-contract-review/SKILL.md +146 -0
  20. package/templates/default/locales/en/.mustflow/skills/command-contract-authoring/SKILL.md +121 -0
  21. package/templates/default/locales/en/.mustflow/skills/cross-platform-filesystem-safety/SKILL.md +137 -0
  22. package/templates/default/locales/en/.mustflow/skills/dependency-reality-check/SKILL.md +19 -6
  23. package/templates/default/locales/en/.mustflow/skills/external-prompt-injection-defense/SKILL.md +26 -10
  24. package/templates/default/locales/en/.mustflow/skills/llm-service-ux-review/SKILL.md +139 -0
  25. package/templates/default/locales/en/.mustflow/skills/process-execution-safety/SKILL.md +120 -0
  26. package/templates/default/locales/en/.mustflow/skills/routes.toml +38 -2
  27. package/templates/default/locales/en/.mustflow/skills/search-ad-content-authoring/SKILL.md +148 -0
  28. package/templates/default/locales/en/.mustflow/skills/security-privacy-review/SKILL.md +46 -12
  29. package/templates/default/locales/en/.mustflow/skills/security-regression-tests/SKILL.md +43 -12
  30. package/templates/default/locales/en/.mustflow/skills/ui-quality-gate/SKILL.md +34 -14
  31. package/templates/default/manifest.toml +23 -1
  32. package/dist/cli/commands/run/builtin-dispatch.js +0 -92
package/README.md CHANGED
@@ -228,6 +228,10 @@ your-project/
228
228
  │ └─ SKILL.md
229
229
  ├─ vertical-slice-tdd/
230
230
  │ └─ SKILL.md
231
+ ├─ llm-service-ux-review/
232
+ │ └─ SKILL.md
233
+ ├─ search-ad-content-authoring/
234
+ │ └─ SKILL.md
231
235
  ├─ ui-quality-gate/
232
236
  │ └─ SKILL.md
233
237
  ├─ visual-review-artifact/
@@ -1,5 +1,5 @@
1
1
  import { randomBytes } from 'node:crypto';
2
- import { existsSync, readFileSync } from 'node:fs';
2
+ import { existsSync, readFileSync, statSync } from 'node:fs';
3
3
  import http from 'node:http';
4
4
  import path from 'node:path';
5
5
  import { openPathInFileManager, openUrlInBrowser } from '../lib/browser-open.js';
@@ -14,8 +14,8 @@ import { readGitChangedFiles } from '../lib/git-changes.js';
14
14
  import { isRecord, readCommandContract, readPositiveInteger, readString, readStringArray, } from '../lib/command-contract.js';
15
15
  import { readDashboardPreferences, updateDashboardPreferences, } from '../lib/dashboard-preferences.js';
16
16
  import { DOC_REVIEW_LEDGER_RELATIVE_PATH, isDocReviewStatus, isReviewerKind, listDocReviewEntries, markDocReviewEntry, } from '../lib/doc-review-ledger.js';
17
- import { inspectManifestLock } from '../lib/manifest-lock.js';
18
- import { readLatestLocalVerificationReadModelQueries, readLocalCommandEffectGraphs, } from '../lib/local-index.js';
17
+ import { MANIFEST_LOCK_RELATIVE_PATH, inspectManifestLock } from '../lib/manifest-lock.js';
18
+ import { getLocalIndexDatabasePath, readLatestLocalVerificationReadModelQueries, readLocalCommandEffectGraphs, } from '../lib/local-index.js';
19
19
  import { readPackageMetadata } from '../lib/package-info.js';
20
20
  import { t } from '../lib/i18n.js';
21
21
  import { resolveMustflowRoot } from '../lib/project-root.js';
@@ -36,6 +36,61 @@ const RELEASE_FILE_PATTERNS = [
36
36
  ];
37
37
  const SKILL_INDEX_RELATIVE_PATH = '.mustflow/skills/INDEX.md';
38
38
  const LATEST_RUN_RELATIVE_PATH = '.mustflow/state/runs/latest.json';
39
+ const COMMANDS_RELATIVE_PATH = '.mustflow/config/commands.toml';
40
+ const AGENTS_RELATIVE_PATH = 'AGENTS.md';
41
+ const STATUS_BLOCK_CACHE_TTL_MS = 750;
42
+ const dashboardStatusBlockCache = new Map();
43
+ function dashboardStatusBlockCacheKey(projectRoot, blockName) {
44
+ return `${path.resolve(projectRoot)}\0${blockName}`;
45
+ }
46
+ function readFileSignature(filePath) {
47
+ try {
48
+ const stat = statSync(filePath);
49
+ return `${stat.mtimeMs}:${stat.size}`;
50
+ }
51
+ catch {
52
+ return 'missing';
53
+ }
54
+ }
55
+ function readProjectFileSignature(projectRoot, relativePath) {
56
+ return `${relativePath}=${readFileSignature(path.join(projectRoot, ...relativePath.split('/')))}`;
57
+ }
58
+ function readStatusBlockSignature(projectRoot, relativePaths) {
59
+ return relativePaths.map((relativePath) => readProjectFileSignature(projectRoot, relativePath)).join('|');
60
+ }
61
+ function readLocalIndexSignature(projectRoot) {
62
+ return `local_index=${readFileSignature(getLocalIndexDatabasePath(projectRoot))}`;
63
+ }
64
+ function readDashboardStatusBlock(projectRoot, blockName, signature, readBlock) {
65
+ const key = dashboardStatusBlockCacheKey(projectRoot, blockName);
66
+ const cached = dashboardStatusBlockCache.get(key);
67
+ const now = Date.now();
68
+ if (cached && cached.signature === signature && cached.expiresAt > now) {
69
+ return cached.value;
70
+ }
71
+ const value = readBlock();
72
+ dashboardStatusBlockCache.set(key, {
73
+ signature,
74
+ expiresAt: Date.now() + STATUS_BLOCK_CACHE_TTL_MS,
75
+ value,
76
+ });
77
+ return value;
78
+ }
79
+ async function readDashboardStatusBlockAsync(projectRoot, blockName, signature, readBlock) {
80
+ const key = dashboardStatusBlockCacheKey(projectRoot, blockName);
81
+ const cached = dashboardStatusBlockCache.get(key);
82
+ const now = Date.now();
83
+ if (cached && cached.signature === signature && cached.expiresAt > now) {
84
+ return cached.value;
85
+ }
86
+ const value = await readBlock();
87
+ dashboardStatusBlockCache.set(key, {
88
+ signature,
89
+ expiresAt: Date.now() + STATUS_BLOCK_CACHE_TTL_MS,
90
+ value,
91
+ });
92
+ return value;
93
+ }
39
94
  function readFrontmatterLines(content) {
40
95
  if (!content.startsWith('---')) {
41
96
  return [];
@@ -677,16 +732,17 @@ function renderRunHistoryResponse(projectRoot) {
677
732
  }
678
733
  async function renderStatusResponse(projectRoot) {
679
734
  const context = getAgentContext(projectRoot);
680
- const manifest = inspectManifestLock(projectRoot);
735
+ const manifest = readDashboardStatusBlock(projectRoot, 'manifest', readStatusBlockSignature(projectRoot, [MANIFEST_LOCK_RELATIVE_PATH]), () => inspectManifestLock(projectRoot));
681
736
  const lock = manifest.readResult.kind === 'present' ? manifest.readResult.lock : undefined;
682
- const activeDocuments = listDocReviewEntries(projectRoot);
683
- const rawCommandContract = readDashboardCommandContract(projectRoot);
684
- const commandContract = await renderCommandContractResponse(projectRoot, rawCommandContract);
737
+ const activeDocuments = readDashboardStatusBlock(projectRoot, 'doc_review', readStatusBlockSignature(projectRoot, [DOC_REVIEW_LEDGER_RELATIVE_PATH]), () => listDocReviewEntries(projectRoot));
738
+ const rawCommandContractSignature = readStatusBlockSignature(projectRoot, [COMMANDS_RELATIVE_PATH]);
739
+ const rawCommandContract = readDashboardStatusBlock(projectRoot, 'raw_command_contract', rawCommandContractSignature, () => readDashboardCommandContract(projectRoot));
740
+ const commandContract = await readDashboardStatusBlockAsync(projectRoot, 'command_contract', `${rawCommandContractSignature}|${readLocalIndexSignature(projectRoot)}`, () => renderCommandContractResponse(projectRoot, rawCommandContract));
685
741
  const gitChangedFilesResult = readGitChangedFiles(projectRoot);
686
742
  const gitChangedFiles = gitChangedFilesResult.ok ? gitChangedFilesResult.files : [];
687
743
  const packageMetadata = readPackageMetadata();
688
744
  const verification = createDashboardVerificationSnapshot(projectRoot, rawCommandContract, commandContract.intents, gitChangedFiles, manifest.changedFiles, manifest.missingFiles);
689
- const readModel = await readLatestLocalVerificationReadModelQueries(projectRoot);
745
+ const readModel = await readDashboardStatusBlockAsync(projectRoot, 'verification_read_model', readLocalIndexSignature(projectRoot), () => readLatestLocalVerificationReadModelQueries(projectRoot));
690
746
  return {
691
747
  schema_version: '1',
692
748
  command: 'dashboard status',
@@ -696,12 +752,12 @@ async function renderStatusResponse(projectRoot) {
696
752
  release: {
697
753
  package_name: packageMetadata.name,
698
754
  package_version: packageMetadata.version,
699
- version_sources: detectVersionSources(projectRoot),
755
+ version_sources: readDashboardStatusBlock(projectRoot, 'version_sources', readStatusBlockSignature(projectRoot, ['package.json']), () => detectVersionSources(projectRoot)),
700
756
  release_sensitive_changed_files: matchingFiles(gitChangedFiles, RELEASE_FILE_PATTERNS),
701
757
  },
702
- update: renderUpdateResponse(projectRoot),
703
- run_history: renderRunHistoryResponse(projectRoot),
704
- skills: renderSkillsResponse(projectRoot),
758
+ update: readDashboardStatusBlock(projectRoot, 'update', readStatusBlockSignature(projectRoot, [AGENTS_RELATIVE_PATH, MANIFEST_LOCK_RELATIVE_PATH]), () => renderUpdateResponse(projectRoot)),
759
+ run_history: readDashboardStatusBlock(projectRoot, 'run_history', readStatusBlockSignature(projectRoot, [LATEST_RUN_RELATIVE_PATH]), () => renderRunHistoryResponse(projectRoot)),
760
+ skills: readDashboardStatusBlock(projectRoot, 'skills', readStatusBlockSignature(projectRoot, [SKILL_INDEX_RELATIVE_PATH]), () => renderSkillsResponse(projectRoot)),
705
761
  tracked_files: lock?.files.length ?? 0,
706
762
  changed_files: manifest.changedFiles,
707
763
  missing_files: manifest.missingFiles,
@@ -1,9 +1,9 @@
1
- import { copyFileSync, existsSync, mkdirSync, readFileSync } from 'node:fs';
1
+ import { existsSync, readFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { stdin as processStdin, stdout as processStdout } from 'node:process';
4
4
  import { createInterface } from 'node:readline/promises';
5
5
  import { printUsageError, renderHelp } from '../lib/cli-output.js';
6
- import { ensureFileTargetInsideWithoutSymlinks, ensureInside, readUtf8FileInsideWithoutSymlinks, writeUtf8FileInsideWithoutSymlinks, } from '../lib/filesystem.js';
6
+ import { copyFileInsideWithoutSymlinks, ensureFileTargetInsideWithoutSymlinks, ensureInside, readUtf8FileInsideWithoutSymlinks, writeUtf8FileInsideWithoutSymlinks, } from '../lib/filesystem.js';
7
7
  import { localeMessage, t } from '../lib/i18n.js';
8
8
  import { isLocaleTag } from '../lib/locale-tags.js';
9
9
  import { MANIFEST_LOCK_RELATIVE_PATH, sha256File } from '../lib/manifest-lock.js';
@@ -463,8 +463,11 @@ function parseOptions(args, reporter, lang) {
463
463
  preferenceOverrides,
464
464
  };
465
465
  }
466
- function sameTemplateFileContent(projectRoot, source, targetPath) {
467
- return (source.content ?? readFileSync(source.sourcePath, 'utf8')) === readUtf8FileInsideWithoutSymlinks(projectRoot, targetPath);
466
+ function readTemplateSourceText(templateRoot, sourcePath) {
467
+ return readUtf8FileInsideWithoutSymlinks(templateRoot, sourcePath);
468
+ }
469
+ function sameTemplateFileContent(projectRoot, templateRoot, source, targetPath) {
470
+ return (source.content ?? readTemplateSourceText(templateRoot, source.sourcePath)) === readUtf8FileInsideWithoutSymlinks(projectRoot, targetPath);
468
471
  }
469
472
  function formatLocaleChoice(locale) {
470
473
  const label = LOCALE_LABELS[locale] ?? locale;
@@ -605,11 +608,11 @@ async function promptInitOptions(template, options, reporter, lang) {
605
608
  function escapeRegExp(value) {
606
609
  return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
607
610
  }
608
- function planStatus(projectRoot, source, targetPath, options) {
611
+ function planStatus(projectRoot, templateRoot, source, targetPath, options) {
609
612
  if (!existsSync(targetPath)) {
610
613
  return 'create';
611
614
  }
612
- if (sameTemplateFileContent(projectRoot, source, targetPath)) {
615
+ if (sameTemplateFileContent(projectRoot, templateRoot, source, targetPath)) {
613
616
  return 'unchanged';
614
617
  }
615
618
  if (options.force) {
@@ -620,17 +623,15 @@ function planStatus(projectRoot, source, targetPath, options) {
620
623
  }
621
624
  return 'conflict';
622
625
  }
623
- function writeTemplateFile(projectRoot, source, targetPath) {
626
+ function writeTemplateFile(projectRoot, templateRoot, source, targetPath) {
624
627
  if (source.content !== undefined) {
625
628
  writeUtf8FileInsideWithoutSymlinks(projectRoot, targetPath, source.content);
626
629
  return;
627
630
  }
628
- ensureFileTargetInsideWithoutSymlinks(projectRoot, targetPath, { allowMissingLeaf: true });
629
- mkdirSync(path.dirname(targetPath), { recursive: true });
630
- copyFileSync(source.sourcePath, targetPath);
631
+ copyFileInsideWithoutSymlinks(templateRoot, source.sourcePath, projectRoot, targetPath);
631
632
  }
632
633
  function writePlannedFile(projectRoot, file) {
633
- writeTemplateFile(projectRoot, file, file.targetPath);
634
+ writeTemplateFile(projectRoot, file.sourceRoot, file, file.targetPath);
634
635
  }
635
636
  function gitignoreFragmentPath(template) {
636
637
  return path.join(template.templateRoot, template.manifest.commonRoot, GITIGNORE_FRAGMENT_RELATIVE_PATH);
@@ -646,11 +647,11 @@ function mergeGitignoreContent(existingContent, fragmentContent) {
646
647
  }
647
648
  return `${existingContent.trimEnd()}\n\n${normalizedFragment}\n`;
648
649
  }
649
- function planGitignoreStatus(projectRoot, sourcePath, targetPath) {
650
+ function planGitignoreStatus(projectRoot, sourceRoot, sourcePath, targetPath) {
650
651
  if (!existsSync(targetPath)) {
651
652
  return 'create';
652
653
  }
653
- const mergedContent = mergeGitignoreContent(readUtf8FileInsideWithoutSymlinks(projectRoot, targetPath), readFileSync(sourcePath, 'utf8'));
654
+ const mergedContent = mergeGitignoreContent(readUtf8FileInsideWithoutSymlinks(projectRoot, targetPath), readTemplateSourceText(sourceRoot, sourcePath));
654
655
  return mergedContent === readUtf8FileInsideWithoutSymlinks(projectRoot, targetPath) ? 'unchanged' : 'merge';
655
656
  }
656
657
  function renderPlanVerb(status) {
@@ -699,10 +700,11 @@ function buildPlannedFiles(template, selectedLocale, targetRoot, options) {
699
700
  return {
700
701
  relativePath: source.relativePath,
701
702
  sourcePath: source.sourcePath,
703
+ sourceRoot: template.templateRoot,
702
704
  sourceKind: source.sourceKind,
703
705
  content: source.content,
704
706
  targetPath,
705
- status: planStatus(targetRoot, source, targetPath, options),
707
+ status: planStatus(targetRoot, template.templateRoot, source, targetPath, options),
706
708
  lock: true,
707
709
  };
708
710
  });
@@ -714,9 +716,10 @@ function buildPlannedFiles(template, selectedLocale, targetRoot, options) {
714
716
  plannedFiles.push({
715
717
  relativePath: GITIGNORE_RELATIVE_PATH,
716
718
  sourcePath,
719
+ sourceRoot: template.templateRoot,
717
720
  sourceKind: 'common',
718
721
  targetPath,
719
- status: planGitignoreStatus(targetRoot, sourcePath, targetPath),
722
+ status: planGitignoreStatus(targetRoot, template.templateRoot, sourcePath, targetPath),
720
723
  lock: false,
721
724
  });
722
725
  return plannedFiles;
@@ -730,10 +733,7 @@ function backupConflictingFiles(projectRoot, conflicts) {
730
733
  for (const conflict of conflicts) {
731
734
  const backupPath = path.join(backupRoot, conflict.relativePath);
732
735
  ensureInside(backupRoot, backupPath);
733
- ensureFileTargetInsideWithoutSymlinks(projectRoot, conflict.targetPath);
734
- ensureFileTargetInsideWithoutSymlinks(projectRoot, backupPath, { allowMissingLeaf: true });
735
- mkdirSync(path.dirname(backupPath), { recursive: true });
736
- copyFileSync(conflict.targetPath, backupPath);
736
+ copyFileInsideWithoutSymlinks(projectRoot, conflict.targetPath, projectRoot, backupPath);
737
737
  }
738
738
  return backupRoot;
739
739
  }
@@ -960,7 +960,7 @@ export async function runInit(args, reporter, lang = 'en') {
960
960
  if (file.status === 'merge') {
961
961
  ensureFileTargetInsideWithoutSymlinks(targetRoot, file.targetPath);
962
962
  const mergedContent = file.relativePath === GITIGNORE_RELATIVE_PATH
963
- ? mergeGitignoreContent(readUtf8FileInsideWithoutSymlinks(targetRoot, file.targetPath), readFileSync(file.sourcePath, 'utf8'))
963
+ ? mergeGitignoreContent(readUtf8FileInsideWithoutSymlinks(targetRoot, file.targetPath), readTemplateSourceText(file.sourceRoot, file.sourcePath))
964
964
  : mergeAgentsContent(readUtf8FileInsideWithoutSymlinks(targetRoot, file.targetPath), selectedLocale);
965
965
  writeUtf8FileInsideWithoutSymlinks(targetRoot, file.targetPath, mergedContent);
966
966
  merged += 1;
@@ -5,12 +5,11 @@ import { readCommandContract, readMustflowConfigIfExists } from '../../core/conf
5
5
  import { resolveRunReceiptRetentionPolicy } from '../../core/retention-policy.js';
6
6
  import { t } from '../lib/i18n.js';
7
7
  import { resolveMustflowRoot } from '../lib/project-root.js';
8
- import { createRunPlan, createRunPreview, isMustflowBuiltinIntent, renderRunPreviewText, } from '../lib/run-plan.js';
8
+ import { createRunPlan, createRunPreview, renderRunPreviewText, } from '../lib/run-plan.js';
9
9
  import { writeRunReceipt, } from '../../core/run-receipt.js';
10
10
  import { recordRunPerformanceHistory } from '../../core/run-performance-history.js';
11
11
  import { RunProfiler } from '../../core/run-profile.js';
12
12
  import { finishRunWriteTracking, startRunWriteTracking } from '../../core/run-write-drift.js';
13
- import { runBuiltinArgvInProcess } from './run/builtin-dispatch.js';
14
13
  import { getRunStatus, runArgvCommandStreaming, runShellCommandStreaming } from './run/executor.js';
15
14
  import { emitOutput, isOutputLimitExceededError } from './run/output.js';
16
15
  import { createPendingTimeoutTermination, getKillMethod, terminateProcessTree } from './run/process-tree.js';
@@ -179,12 +178,6 @@ export async function runRun(args, reporter, lang = 'en', options = {}) {
179
178
  const childStartedAtMs = performance.now();
180
179
  const startedAt = new Date();
181
180
  const result = await profiler.measureAsync('child_command', async () => {
182
- if (plan.commandArgv && isMustflowBuiltinIntent(plan.intent)) {
183
- const builtinResult = await runBuiltinArgvInProcess(plan.commandArgv, plan.cwd, lang);
184
- if (builtinResult) {
185
- return builtinResult;
186
- }
187
- }
188
181
  if (plan.commandArgv) {
189
182
  streamedOutput = !json;
190
183
  return runArgvCommandStreaming(plan.argvCommand, plan.cwd, env, plan.timeoutSeconds, plan.killAfterSeconds, plan.maxOutputBytes, stdoutTailBytes, stderrTailBytes, reporter, !json, true);
@@ -1,7 +1,7 @@
1
1
  import { createHash } from 'node:crypto';
2
- import { copyFileSync, existsSync, mkdirSync } from 'node:fs';
2
+ import { existsSync } from 'node:fs';
3
3
  import path from 'node:path';
4
- import { ensureFileTargetInsideWithoutSymlinks, ensureInside, writeUtf8FileInsideWithoutSymlinks, } from '../lib/filesystem.js';
4
+ import { copyFileInsideWithoutSymlinks, ensureFileTargetInsideWithoutSymlinks, ensureInside, writeUtf8FileInsideWithoutSymlinks, } from '../lib/filesystem.js';
5
5
  import { MANIFEST_LOCK_RELATIVE_PATH, readManifestLock, sha256File } from '../lib/manifest-lock.js';
6
6
  import { printUsageError, renderHelp } from '../lib/cli-output.js';
7
7
  import { t } from '../lib/i18n.js';
@@ -70,14 +70,12 @@ function lockedTemplateSkillNames(files) {
70
70
  function getInstalledTemplateFiles(projectRoot, template, lock) {
71
71
  return getTemplateFiles(template, lock.templateLocale ?? template.manifest.defaultLocale, lock.templateProfile ?? template.manifest.defaultProfile, { extraSkillNames: lockedTemplateSkillNames(lock.files) });
72
72
  }
73
- function writeTemplateFile(projectRoot, source, targetPath) {
73
+ function writeTemplateFile(projectRoot, templateRoot, source, targetPath) {
74
74
  if (source.content !== undefined) {
75
75
  writeUtf8FileInsideWithoutSymlinks(projectRoot, targetPath, source.content);
76
76
  return;
77
77
  }
78
- ensureFileTargetInsideWithoutSymlinks(projectRoot, targetPath, { allowMissingLeaf: true });
79
- mkdirSync(path.dirname(targetPath), { recursive: true });
80
- copyFileSync(source.sourcePath, targetPath);
78
+ copyFileInsideWithoutSymlinks(templateRoot, source.sourcePath, projectRoot, targetPath);
81
79
  }
82
80
  function templateTargetSafetyIssue(projectRoot, targetPath, allowMissingLeaf) {
83
81
  try {
@@ -223,7 +221,7 @@ function copyTemplateFile(projectRoot, relativePath) {
223
221
  ensureInside(template.templateRoot, source.sourcePath);
224
222
  ensureInside(projectRoot, targetPath);
225
223
  ensureFileTargetInsideWithoutSymlinks(projectRoot, targetPath, { allowMissingLeaf: true });
226
- writeTemplateFile(projectRoot, source, targetPath);
224
+ writeTemplateFile(projectRoot, template.templateRoot, source, targetPath);
227
225
  }
228
226
  function backupUpdateFiles(projectRoot, items, reporter, lang) {
229
227
  const updateItems = items.filter((item) => item.action === 'update');
@@ -237,10 +235,7 @@ function backupUpdateFiles(projectRoot, items, reporter, lang) {
237
235
  const backupPath = path.join(backupRoot, item.relativePath);
238
236
  ensureInside(projectRoot, sourcePath);
239
237
  ensureInside(backupRoot, backupPath);
240
- ensureFileTargetInsideWithoutSymlinks(projectRoot, sourcePath);
241
- ensureFileTargetInsideWithoutSymlinks(projectRoot, backupPath, { allowMissingLeaf: true });
242
- mkdirSync(path.dirname(backupPath), { recursive: true });
243
- copyFileSync(sourcePath, backupPath);
238
+ copyFileInsideWithoutSymlinks(projectRoot, sourcePath, projectRoot, backupPath);
244
239
  }
245
240
  reporter.stdout(t(lang, 'update.backup.files', {
246
241
  count: updateItems.length,
@@ -16,7 +16,7 @@ import { readCommandContract } from '../../core/config-loading.js';
16
16
  import { DEFAULT_VERIFY_PARALLELISM, parseVerifyArgs } from './verify/args.js';
17
17
  import { printUsageError, renderHelp } from '../lib/cli-output.js';
18
18
  import { t } from '../lib/i18n.js';
19
- import { readLocalCommandEffectGraph, readLocalPathSurfaces, readLocalSourceAnchorVerdictRisks, } from '../lib/local-index.js';
19
+ import { readLocalCommandEffectGraphs, readLocalPathSurfaces, readLocalSourceAnchorVerdictRisks, } from '../lib/local-index.js';
20
20
  import { resolveMustflowRoot } from '../lib/project-root.js';
21
21
  const VERIFY_SCHEMA_VERSION = '1';
22
22
  const RUN_STATE_DIR = path.join('.mustflow', 'state', 'runs');
@@ -578,6 +578,20 @@ function skippedResult(candidate) {
578
578
  receipt: null,
579
579
  };
580
580
  }
581
+ function stoppedAfterFailedBatchResult(entry, verificationPlanId) {
582
+ return {
583
+ intent: entry.intent,
584
+ status: 'skipped',
585
+ skipped: true,
586
+ reason: 'stopped_after_failed_batch',
587
+ detail: 'Skipped because an earlier verification batch failed and the schedule failure policy stops before the next batch.',
588
+ exit_code: null,
589
+ verification_plan_id: verificationPlanId,
590
+ receipt_path: null,
591
+ receipt_sha256: null,
592
+ receipt: null,
593
+ };
594
+ }
581
595
  function candidateResultKey(candidate) {
582
596
  return candidate.intent
583
597
  ? `intent:${candidate.intent}`
@@ -670,21 +684,40 @@ async function runVerificationEntriesInParallelChunks(entries, parallelism, lang
670
684
  }
671
685
  return results;
672
686
  }
687
+ function verificationResultFailed(result) {
688
+ return (!result.skipped &&
689
+ (result.status === 'failed' ||
690
+ result.status === 'timed_out' ||
691
+ result.status === 'start_failed' ||
692
+ result.status === 'output_limit_exceeded'));
693
+ }
673
694
  async function runScheduledVerificationIntents(report, lang, verificationPlanId, scheduledTestTargets, parallelism) {
674
- if (parallelism <= DEFAULT_VERIFY_PARALLELISM) {
675
- return runVerificationEntriesSequentially(report.schedule.entries, lang, verificationPlanId, scheduledTestTargets);
676
- }
677
695
  const results = [];
678
- for (const batch of report.schedule.batches) {
696
+ for (let batchIndex = 0; batchIndex < report.schedule.batches.length; batchIndex += 1) {
697
+ const batch = report.schedule.batches[batchIndex];
679
698
  const entries = entriesForScheduleBatch(report.schedule.entries, batch);
680
699
  if (entries.length === 0) {
681
700
  continue;
682
701
  }
702
+ let batchResults;
683
703
  if (entries.length > 1 && entries.every((entry) => entry.parallelEligible)) {
684
- results.push(...(await runVerificationEntriesInParallelChunks(entries, parallelism, lang, verificationPlanId, scheduledTestTargets)));
704
+ batchResults =
705
+ parallelism > DEFAULT_VERIFY_PARALLELISM
706
+ ? await runVerificationEntriesInParallelChunks(entries, parallelism, lang, verificationPlanId, scheduledTestTargets)
707
+ : await runVerificationEntriesSequentially(entries, lang, verificationPlanId, scheduledTestTargets);
708
+ }
709
+ else {
710
+ batchResults = await runVerificationEntriesSequentially(entries, lang, verificationPlanId, scheduledTestTargets);
711
+ }
712
+ results.push(...batchResults);
713
+ if (!batchResults.some(verificationResultFailed)) {
685
714
  continue;
686
715
  }
687
- results.push(...(await runVerificationEntriesSequentially(entries, lang, verificationPlanId, scheduledTestTargets)));
716
+ const remainingEntries = report.schedule.batches
717
+ .slice(batchIndex + 1)
718
+ .flatMap((remainingBatch) => entriesForScheduleBatch(report.schedule.entries, remainingBatch));
719
+ results.push(...remainingEntries.map((entry) => stoppedAfterFailedBatchResult(entry, verificationPlanId)));
720
+ break;
688
721
  }
689
722
  return results;
690
723
  }
@@ -1276,14 +1309,11 @@ async function createPlanOnlyOutput(input, projectRoot) {
1276
1309
  if (!firstEntry) {
1277
1310
  return { ...report, verification_plan_id: verificationPlanId, requirements };
1278
1311
  }
1279
- const firstGraph = await readLocalCommandEffectGraph(projectRoot, firstEntry.intent);
1280
- const graphsByIntent = new Map([[firstEntry.intent, firstGraph]]);
1281
- if (firstGraph.status === 'fresh') {
1282
- for (const entry of report.schedule.entries.slice(1)) {
1283
- if (!graphsByIntent.has(entry.intent)) {
1284
- graphsByIntent.set(entry.intent, await readLocalCommandEffectGraph(projectRoot, entry.intent));
1285
- }
1286
- }
1312
+ const scheduledIntents = Array.from(new Set(report.schedule.entries.map((entry) => entry.intent)));
1313
+ const graphsByIntent = await readLocalCommandEffectGraphs(projectRoot, scheduledIntents);
1314
+ const firstGraph = graphsByIntent.get(firstEntry.intent);
1315
+ if (!firstGraph) {
1316
+ return { ...report, verification_plan_id: verificationPlanId, requirements };
1287
1317
  }
1288
1318
  return {
1289
1319
  ...report,
@@ -1,10 +1,11 @@
1
- import { existsSync, readFileSync, writeFileSync } from 'node:fs';
1
+ import { existsSync } from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { isRecord } from './command-contract.js';
4
+ import { readUtf8FileInsideWithoutSymlinks, writeUtf8FileInsideWithoutSymlinks } from './filesystem.js';
4
5
  import { isLocaleTag } from './locale-tags.js';
5
- import { markManifestLockFileCustomized } from './manifest-lock.js';
6
+ import { ensureManifestLockTargetSafe, markManifestLockFileCustomized } from './manifest-lock.js';
6
7
  import { COMMIT_MESSAGE_STYLES, TEST_AUTHORING_POLICIES } from './preferences-options.js';
7
- import { readTomlFile } from './toml.js';
8
+ import { parseTomlText } from './toml.js';
8
9
  const PREFERENCES_RELATIVE_PATH = '.mustflow/config/preferences.toml';
9
10
  export const DASHBOARD_PREFERENCE_SETTINGS = [
10
11
  {
@@ -281,7 +282,7 @@ export function readDashboardPreferences(projectRoot) {
281
282
  if (!existsSync(preferencesPath)) {
282
283
  throw new Error('Missing .mustflow/config/preferences.toml. Run mf init first or switch to a mustflow root.');
283
284
  }
284
- const parsed = readTomlFile(preferencesPath);
285
+ const parsed = parseTomlText(readUtf8FileInsideWithoutSymlinks(projectRoot, preferencesPath));
285
286
  if (!isRecord(parsed)) {
286
287
  throw new Error('.mustflow/config/preferences.toml must contain a TOML table.');
287
288
  }
@@ -390,7 +391,7 @@ function coerceUpdateValue(definition, value) {
390
391
  export function updateDashboardPreferences(projectRoot, updates) {
391
392
  const preferencesPath = getPreferencesPath(projectRoot);
392
393
  const definitionsById = new Map(DASHBOARD_PREFERENCE_SETTINGS.map((definition) => [definition.id, definition]));
393
- let content = readFileSync(preferencesPath, 'utf8');
394
+ let content = readUtf8FileInsideWithoutSymlinks(projectRoot, preferencesPath);
394
395
  for (const update of updates) {
395
396
  const definition = definitionsById.get(update.id);
396
397
  if (!definition) {
@@ -399,7 +400,8 @@ export function updateDashboardPreferences(projectRoot, updates) {
399
400
  const value = coerceUpdateValue(definition, update.value);
400
401
  content = setTomlScalar(content, definition.path, value);
401
402
  }
402
- writeFileSync(preferencesPath, content);
403
+ ensureManifestLockTargetSafe(projectRoot);
404
+ writeUtf8FileInsideWithoutSymlinks(projectRoot, preferencesPath, content);
403
405
  markManifestLockFileCustomized(projectRoot, PREFERENCES_RELATIVE_PATH);
404
406
  return readDashboardPreferences(projectRoot);
405
407
  }
@@ -48,11 +48,14 @@ export function ensureInsideWithoutSymlinks(parentPath, childPath, options = {})
48
48
  }
49
49
  }
50
50
  export function readUtf8FileInsideWithoutSymlinks(parentPath, childPath) {
51
+ return readFileInsideWithoutSymlinks(parentPath, childPath).toString('utf8');
52
+ }
53
+ export function readFileInsideWithoutSymlinks(parentPath, childPath) {
51
54
  const absoluteChildPath = path.resolve(childPath);
52
55
  ensureInsideWithoutSymlinks(parentPath, absoluteChildPath);
53
56
  const fileDescriptor = openSync(absoluteChildPath, constants.O_RDONLY | NOFOLLOW_FLAG);
54
57
  try {
55
- return readFileSync(fileDescriptor, 'utf8');
58
+ return readFileSync(fileDescriptor);
56
59
  }
57
60
  finally {
58
61
  closeSync(fileDescriptor);
@@ -79,6 +82,9 @@ export function ensureFileTargetInsideWithoutSymlinks(parentPath, childPath, opt
79
82
  }
80
83
  }
81
84
  export function writeUtf8FileInsideWithoutSymlinks(parentPath, childPath, content) {
85
+ writeFileInsideWithoutSymlinks(parentPath, childPath, content);
86
+ }
87
+ export function writeFileInsideWithoutSymlinks(parentPath, childPath, content) {
82
88
  const absoluteChildPath = path.resolve(childPath);
83
89
  const directoryPath = path.dirname(absoluteChildPath);
84
90
  ensureInsideWithoutSymlinks(parentPath, directoryPath, { allowMissingLeaf: true });
@@ -92,6 +98,10 @@ export function writeUtf8FileInsideWithoutSymlinks(parentPath, childPath, conten
92
98
  closeSync(fileDescriptor);
93
99
  }
94
100
  }
101
+ export function copyFileInsideWithoutSymlinks(sourceParentPath, sourcePath, targetParentPath, targetPath) {
102
+ const content = readFileInsideWithoutSymlinks(sourceParentPath, sourcePath);
103
+ writeFileInsideWithoutSymlinks(targetParentPath, targetPath, content);
104
+ }
95
105
  export function copyFileIfMissing(sourcePath, targetPath, relativePath) {
96
106
  if (existsSync(targetPath)) {
97
107
  return { status: 'skipped', relativePath };
@@ -1,5 +1,7 @@
1
1
  import { spawnSync } from 'node:child_process';
2
2
  import { parseGitStatusOutput } from '../../core/change-classification.js';
3
+ const GIT_STATUS_TIMEOUT_MS = 10_000;
4
+ const GIT_STATUS_MAX_BUFFER_BYTES = 16 * 1024 * 1024;
3
5
  export class GitChangedFilesError extends Error {
4
6
  result;
5
7
  constructor(result) {
@@ -9,9 +11,13 @@ export class GitChangedFilesError extends Error {
9
11
  }
10
12
  }
11
13
  export function readGitChangedFiles(projectRoot) {
12
- const result = spawnSync('git', ['status', '--short', '--untracked-files=all'], {
14
+ const result = spawnSync('git', ['status', '--porcelain=v1', '-z', '--untracked-files=all'], {
13
15
  cwd: projectRoot,
14
16
  encoding: 'utf8',
17
+ input: '',
18
+ maxBuffer: GIT_STATUS_MAX_BUFFER_BYTES,
19
+ stdio: ['ignore', 'pipe', 'pipe'],
20
+ timeout: GIT_STATUS_TIMEOUT_MS,
15
21
  windowsHide: true,
16
22
  });
17
23
  if (result.status !== 0 || typeof result.stdout !== 'string') {