@planu/cli 5.7.11 → 5.7.13

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 (63) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/.planu-build.json +1 -1
  3. package/dist/cli/commands/doctor.d.ts +2 -1
  4. package/dist/cli/commands/doctor.js +51 -1
  5. package/dist/cli/commands/install.js +14 -0
  6. package/dist/cli/commands/package-handoff.js +10 -3
  7. package/dist/config/registries/strict-audit-scripts.json +4 -0
  8. package/dist/config/runtime-policy.json +2 -1
  9. package/dist/engine/abortable-process-runner.js +1 -0
  10. package/dist/engine/bump-carrier-binding.d.ts +10 -0
  11. package/dist/engine/bump-carrier-binding.js +276 -0
  12. package/dist/engine/doctor/npm-cache-check.d.ts +10 -0
  13. package/dist/engine/doctor/npm-cache-check.js +109 -0
  14. package/dist/engine/ears-gate.d.ts +1 -0
  15. package/dist/engine/ears-gate.js +64 -2
  16. package/dist/engine/framework-detector.d.ts +1 -0
  17. package/dist/engine/framework-detector.js +1 -1
  18. package/dist/engine/handoff-artifacts/schemas.d.ts +22 -0
  19. package/dist/engine/handoff-artifacts/schemas.js +13 -1
  20. package/dist/engine/runtime-policy.js +4 -0
  21. package/dist/engine/source-quality-binding.d.ts +26 -0
  22. package/dist/engine/source-quality-binding.js +162 -0
  23. package/dist/engine/source-quality-receipt-reader.d.ts +3 -0
  24. package/dist/engine/source-quality-receipt-reader.js +51 -0
  25. package/dist/engine/spec-format/bdd-parser.js +7 -4
  26. package/dist/engine/spec-format/technical-md-populator.js +114 -3
  27. package/dist/engine/spec-format/unified-spec-builder.js +33 -6
  28. package/dist/engine/spec-grounding/contract.js +3 -1
  29. package/dist/engine/spec-grounding/grounding-entry-parser.js +1 -0
  30. package/dist/engine/validator/blast-radius-gate.d.ts +3 -0
  31. package/dist/engine/validator/blast-radius-gate.js +225 -0
  32. package/dist/engine/validator/spec-compliance-runner.d.ts +2 -0
  33. package/dist/engine/validator/spec-compliance-runner.js +78 -25
  34. package/dist/engine/validator/strict-audits-gate.d.ts +3 -0
  35. package/dist/engine/validator/strict-audits-gate.js +74 -0
  36. package/dist/engine/validator/validation-report-writer.d.ts +2 -0
  37. package/dist/engine/validator/validation-report-writer.js +72 -32
  38. package/dist/storage/runtime-db.js +7 -3
  39. package/dist/storage/spec-store.js +6 -2
  40. package/dist/tools/challenge-spec/scenarios-data.js +4 -3
  41. package/dist/tools/challenge-spec/scenarios-utils.d.ts +1 -0
  42. package/dist/tools/challenge-spec/scenarios-utils.js +47 -3
  43. package/dist/tools/register-spec-tools/core-spec-tools.js +5 -0
  44. package/dist/tools/update-status/batch.js +1 -0
  45. package/dist/tools/update-status/file-sync.d.ts +1 -1
  46. package/dist/tools/update-status/file-sync.js +4 -2
  47. package/dist/tools/update-status/index.js +4 -1
  48. package/dist/tools/update-status/transition-guard.d.ts +0 -1
  49. package/dist/tools/update-status/transition-guard.js +9 -5
  50. package/dist/tools/validate-lint.js +19 -0
  51. package/dist/tools/validate.js +111 -4
  52. package/dist/types/abortable-process.d.ts +1 -0
  53. package/dist/types/handoff-artifacts.d.ts +11 -1
  54. package/dist/types/installation.d.ts +10 -0
  55. package/dist/types/runtime-policy.d.ts +1 -0
  56. package/dist/types/spec-format.d.ts +10 -0
  57. package/dist/types/spec-grounding.d.ts +1 -1
  58. package/dist/types/validation-evidence.d.ts +51 -1
  59. package/package.json +2 -2
  60. package/planu-plugin.json +1 -1
  61. package/src/i18n/messages/en.json +1 -1
  62. package/src/i18n/messages/es.json +1 -1
  63. package/src/i18n/messages/pt.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,46 @@
1
+ ## [5.7.13] - 2026-09-03
2
+
3
+ ### Features
4
+ - feat(cli): diagnose root-owned npm cache in doctor and install (SPEC-1733)
5
+
6
+ ### Bug Fixes
7
+ - fix(spec-grounding): accept review_evidence as contract grounding source
8
+ - fix(validator): return indeterminate verdicts when vitest runner fails (SPEC-1734)
9
+ - fix(challenge): exclude package-manager cache clauses from stale-cache scenario (SPEC-1778)
10
+ - fix(validate): run strict audit scripts as a validate gate (SPEC-1775)
11
+ - fix(update-status): allow done to discarded with an audited reason (SPEC-1708)
12
+ - fix(update-status): forward reason through update_status_batch (SPEC-1728)
13
+ - fix(validate): run integration importers in the blast-radius gate (SPEC-1777)
14
+ - fix(ears): mask quoted literals before the vague-verb scan (SPEC-1632)
15
+
16
+
17
+ ## [5.7.12] - 2026-09-03
18
+
19
+ ### Features
20
+ - feat(validate): reuse the source-quality receipt in the lint check
21
+ - feat(validate): run vitest related over the spec's affected files as a blast-radius gate
22
+ - feat(auto-merge): reuse the source-quality receipt in auto-merge.sh and validate:full
23
+
24
+ ### Bug Fixes
25
+ - fix(validator): resolve the blast-radius test runner binary through the technology registry
26
+ - fix(spec-format): fence-aware author section extraction and byte-identical fallback coverage
27
+ - fix(spec-format): use the first author section as the problem fallback instead of the whole source
28
+ - fix(hooks): call lint-staged through node_modules/.bin so pnpm cannot reinstall node_modules on commit
29
+ - fix(challenge-spec): scope the test-context guard per clause and accept DDL actions
30
+ - fix(challenge-spec): anchor database and cache capability signals to persistence and caching actions
31
+ - fix(cli): forward the project path to package_handoff and refresh drifted spec scalars
32
+ - fix(spec-format): accept flat Create/Modify/Test labels and merge sectioned with labelled Files
33
+ - fix(spec-format): keep labelled Files to create/modify entries in Files section
34
+ - fix(runtime-db): treat payload resubmission of a completed job as a fresh run
35
+ - fix(receipt): bound binding probes, skip absent receipt dirs and prove ledger reuse
36
+ - fix(validate): harden the blast-radius gate parsing, path handling and report persistence
37
+ - fix(pre-push): skip product tests on mirror sync of origin/main and surface build-step diagnostics
38
+ - fix(bdd-parser): accept markdown scenario headings and uppercase WHEN-opened blocks
39
+
40
+ ### Refactoring
41
+ - refactor(receipt): move source-quality binding computation into the engine
42
+
43
+
1
44
  ## [5.7.11] - 2026-09-02
2
45
 
3
46
  ### Features
@@ -1 +1 @@
1
- {"schemaVersion":1,"commit":"751d4ec85be2cb3fcb93112587d70211814166b0"}
1
+ {"schemaVersion":1,"commit":"ee3c4024cb57c413795f82e3c5049899d22e2b3f"}
@@ -27,8 +27,9 @@ declare function checkRuntimeDatabase(): DeepCheckResult;
27
27
  declare function checkLocaleResolution(): DeepCheckResult;
28
28
  /** Check (5): every package-owned runtime helper compiled CLI code imports is present. */
29
29
  declare function checkInstallationIntegrity(): DeepCheckResult;
30
+ declare function checkNpmCache(): DeepCheckResult;
30
31
  declare function runDeepChecks(): DeepCheckResult[];
31
- export { checkNodeVersion, checkDataDirWritable, checkRuntimeDatabase, checkLocaleResolution, checkInstallationIntegrity, runDeepChecks, };
32
+ export { checkNodeVersion, checkDataDirWritable, checkRuntimeDatabase, checkLocaleResolution, checkInstallationIntegrity, checkNpmCache, runDeepChecks, };
32
33
  export { checkTool };
33
34
  export declare const doctorCommand: CliCommand;
34
35
  //# sourceMappingURL=doctor.d.ts.map
@@ -10,6 +10,7 @@ import { readJsonFile, hasPlanuEntry } from './install.js';
10
10
  import { resolveStorageLayout } from '../../storage/storage-layout.js';
11
11
  import { RuntimeDatabase } from '../../storage/runtime-db.js';
12
12
  import { getLocale, t } from '../../i18n/index.js';
13
+ import { MAX_FOREIGN_ENTRIES, MAX_SCANNED_ENTRIES, currentUid, resolveNpmCacheDir, checkNpmCacheOwnership, } from '../../engine/doctor/npm-cache-check.js';
13
14
  // ---------------------------------------------------------------------------
14
15
  // Constants
15
16
  // ---------------------------------------------------------------------------
@@ -251,6 +252,54 @@ function checkInstallationIntegrity() {
251
252
  detail: `INCOMPLETE_INSTALLATION: ${packageName}@${version} is missing ${missing.join(', ')}. Reinstall with: npm install -g ${packageName}@${version}`,
252
253
  };
253
254
  }
255
+ function checkNpmCache() {
256
+ const uid = currentUid();
257
+ if (uid === null) {
258
+ return {
259
+ name: 'npm cache',
260
+ status: 'ok',
261
+ detail: 'Ownership check does not apply on this platform.',
262
+ };
263
+ }
264
+ const cacheDir = resolveNpmCacheDir(process.env, homedir());
265
+ const finding = checkNpmCacheOwnership(cacheDir, uid);
266
+ if (finding.status === 'ok') {
267
+ if (!finding.truncated) {
268
+ return {
269
+ name: 'npm cache',
270
+ status: 'ok',
271
+ detail: `Checked ${String(finding.scanned)} entries under ${finding.cacheDir}; all owned by the current user.`,
272
+ };
273
+ }
274
+ return {
275
+ name: 'npm cache',
276
+ status: 'ok',
277
+ detail: `Checked the first ${String(MAX_SCANNED_ENTRIES)} entries under ${finding.cacheDir}; all owned by the current user.`,
278
+ };
279
+ }
280
+ if (finding.status === 'unreadable') {
281
+ return {
282
+ name: 'npm cache',
283
+ status: 'warn',
284
+ detail: `Cannot read ${finding.cacheDir}. Check permissions, then run: ${finding.fix}`,
285
+ };
286
+ }
287
+ const noun = finding.foreignCount === 1 ? 'entry' : 'entries';
288
+ const limits = [];
289
+ if (finding.foreignCount >= MAX_FOREIGN_ENTRIES) {
290
+ limits.push(`count capped at ${String(MAX_FOREIGN_ENTRIES)}`);
291
+ }
292
+ if (finding.truncated) {
293
+ limits.push(`scan stopped at ${String(MAX_SCANNED_ENTRIES)} entries`);
294
+ }
295
+ const suffix = limits.length > 0 ? ` (${limits.join('; ')})` : '';
296
+ return {
297
+ name: 'npm cache',
298
+ status: 'fail',
299
+ detail: `npm cache contains ${String(finding.foreignCount)} ${noun} not owned by the current user${suffix}` +
300
+ ` — npx cannot write to it and the MCP server fails to start. Run: ${finding.fix}`,
301
+ };
302
+ }
254
303
  function runDeepChecks() {
255
304
  return [
256
305
  checkNodeVersion(),
@@ -258,6 +307,7 @@ function runDeepChecks() {
258
307
  checkRuntimeDatabase(),
259
308
  checkLocaleResolution(),
260
309
  checkInstallationIntegrity(),
310
+ checkNpmCache(),
261
311
  ];
262
312
  }
263
313
  function deepCheckIcon(status) {
@@ -282,7 +332,7 @@ function printDeepChecks(results) {
282
332
  }
283
333
  }
284
334
  // Exported for tests
285
- export { checkNodeVersion, checkDataDirWritable, checkRuntimeDatabase, checkLocaleResolution, checkInstallationIntegrity, runDeepChecks, };
335
+ export { checkNodeVersion, checkDataDirWritable, checkRuntimeDatabase, checkLocaleResolution, checkInstallationIntegrity, checkNpmCache, runDeepChecks, };
286
336
  function statusIcon(status) {
287
337
  switch (status) {
288
338
  case 'ok':
@@ -8,6 +8,7 @@ import { planuVersion } from '../../config/version.js';
8
8
  import { confirm, select } from '../interactive.js';
9
9
  import { resolveStorageLayout } from '../../storage/storage-layout.js';
10
10
  import { removeCommercialState } from '../../engine/migrations/remove-commercial-state.js';
11
+ import { currentUid, resolveNpmCacheDir, checkNpmCacheOwnership, } from '../../engine/doctor/npm-cache-check.js';
11
12
  // ---------------------------------------------------------------------------
12
13
  // Constants
13
14
  // ---------------------------------------------------------------------------
@@ -299,6 +300,18 @@ function printDetectionResults(detected, notFound) {
299
300
  process.stdout.write(` ${dim('-')} ${tool.name} ${dim('(not found)')}\n`);
300
301
  }
301
302
  }
303
+ function printNpmCacheWarning() {
304
+ const uid = currentUid();
305
+ if (uid === null) {
306
+ return;
307
+ }
308
+ const cacheDir = resolveNpmCacheDir(process.env, homedir());
309
+ const finding = checkNpmCacheOwnership(cacheDir, uid);
310
+ if (finding.status !== 'foreign-owned') {
311
+ return;
312
+ }
313
+ process.stdout.write(`${yellow('⚠ npm cache has files owned by another user.')} Run: ${finding.fix}\n\n`);
314
+ }
302
315
  async function resolveScope(scopeArg) {
303
316
  if (scopeArg === 'user' || scopeArg === 'project') {
304
317
  return scopeArg;
@@ -417,6 +430,7 @@ export const installCommand = {
417
430
  }
418
431
  printDetectionResults(detected, notFound);
419
432
  process.stdout.write('\n');
433
+ printNpmCacheWarning();
420
434
  if (detected.length === 0) {
421
435
  const docsUrl = claudeCodeDocsUrl();
422
436
  process.stdout.write(`${yellow('⚠ No AI tools detected on this machine.')}\n\n` +
@@ -41,9 +41,16 @@ export const packageHandoffCommand = {
41
41
  return;
42
42
  }
43
43
  const projectPath = values['project-path'];
44
- const projectId = values['project-id'] ??
45
- detectProjectId(projectPath ? resolve(projectPath) : undefined);
46
- const submission = await handlePackageHandoff({ projectId, specId });
44
+ const resolvedPath = projectPath ? resolve(projectPath) : undefined;
45
+ const detectedId = detectProjectId(resolvedPath);
46
+ const explicitProjectId = values['project-id'];
47
+ if (explicitProjectId && resolvedPath && explicitProjectId !== detectedId) {
48
+ process.stderr.write(`${red('Error:')} --project-id ${explicitProjectId} does not match the project detected at ${resolvedPath} (${detectedId})\n`);
49
+ process.exitCode = 1;
50
+ return;
51
+ }
52
+ const projectId = explicitProjectId ?? detectedId;
53
+ const submission = await handlePackageHandoff({ projectId, specId, projectPath: resolvedPath });
47
54
  if (submission.isError) {
48
55
  process.stderr.write(`${red(formatToolResult(submission, flags))}\n`);
49
56
  process.exitCode = 1;
@@ -0,0 +1,4 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "scripts": ["audit:hardcodes", "check:public-privacy", "check:environment-schema", "audit:i18n"]
4
+ }
@@ -44,7 +44,8 @@
44
44
  "freshnessInvalidationCoalesceMs": 25,
45
45
  "receiptPublicationDeadlineMs": 20000,
46
46
  "receiptCheckpointLogMaxBytes": 1048576,
47
- "receiptCheckpointResultMaxBytes": 4194304
47
+ "receiptCheckpointResultMaxBytes": 4194304,
48
+ "blastRadiusTimeoutMs": 300000
48
49
  },
49
50
  "postCommit": {
50
51
  "defaultTaskTimeoutMs": 10000,
@@ -145,6 +145,7 @@ export function runAbortableProcess(command, args, options) {
145
145
  cwd: options.cwd,
146
146
  detached: runtimePlatform() !== 'win32',
147
147
  stdio: ['ignore', 'pipe', 'pipe'],
148
+ ...(options.env !== undefined ? { env: options.env } : {}),
148
149
  });
149
150
  let stdout = '';
150
151
  let stderr = '';
@@ -0,0 +1,10 @@
1
+ export declare const VERSION_PLACEHOLDER = "0.0.0";
2
+ export declare const BUMP_CARRIER_STRUCTURAL_PATHS: readonly ['package.json', 'planu-plugin.json', 'pnpm-lock.yaml', 'website/public/proof/product-proof.json'];
3
+ export declare const BUMP_CARRIER_EXCLUDED_PATHS: readonly ['CHANGELOG.md', 'planu/session-context.md', 'planu/project.json'];
4
+ export declare function isStructuralCarrierPath(path: string): boolean;
5
+ export declare function isExcludedCarrierPath(path: string): boolean;
6
+ export declare function isBumpCarrierPath(path: string): boolean;
7
+ export declare function canonical(value: unknown): string;
8
+ export declare function normalizeCarrierBytes(path: string, raw: Buffer): Buffer;
9
+ export declare function filterMaskedTreeEntries(entries: string[]): string[];
10
+ //# sourceMappingURL=bump-carrier-binding.d.ts.map
@@ -0,0 +1,276 @@
1
+ export const VERSION_PLACEHOLDER = '0.0.0';
2
+ export const BUMP_CARRIER_STRUCTURAL_PATHS = [
3
+ 'package.json',
4
+ 'planu-plugin.json',
5
+ 'pnpm-lock.yaml',
6
+ 'website/public/proof/product-proof.json',
7
+ ];
8
+ export const BUMP_CARRIER_EXCLUDED_PATHS = [
9
+ 'CHANGELOG.md',
10
+ 'planu/session-context.md',
11
+ 'planu/project.json',
12
+ ];
13
+ const STRUCTURAL_SET = new Set(BUMP_CARRIER_STRUCTURAL_PATHS);
14
+ const EXCLUDED_SET = new Set(BUMP_CARRIER_EXCLUDED_PATHS);
15
+ const CARRIER_SET = new Set([...STRUCTURAL_SET, ...EXCLUDED_SET]);
16
+ export function isStructuralCarrierPath(path) {
17
+ return STRUCTURAL_SET.has(path);
18
+ }
19
+ export function isExcludedCarrierPath(path) {
20
+ return EXCLUDED_SET.has(path);
21
+ }
22
+ export function isBumpCarrierPath(path) {
23
+ return CARRIER_SET.has(path);
24
+ }
25
+ export function canonical(value) {
26
+ if (Array.isArray(value)) {
27
+ return `[${value.map(canonical).join(',')}]`;
28
+ }
29
+ if (value !== null && typeof value === 'object') {
30
+ return `{${Object.entries(value)
31
+ .sort(([left], [right]) => left.localeCompare(right))
32
+ .map(([key, entry]) => `${JSON.stringify(key)}:${canonical(entry)}`)
33
+ .join(',')}}`;
34
+ }
35
+ return JSON.stringify(value);
36
+ }
37
+ function findUniqueLineMatch(text, pattern) {
38
+ const matches = [...text.matchAll(new RegExp(pattern, 'gmu'))];
39
+ if (matches.length !== 1) {
40
+ return null;
41
+ }
42
+ const match = matches[0];
43
+ if (match === undefined) {
44
+ return null;
45
+ }
46
+ const [full, prefix = '', value = '', suffix = ''] = match;
47
+ return { full, prefix, value, suffix, index: match.index };
48
+ }
49
+ function substituteLine(text, pattern, replacement) {
50
+ const match = findUniqueLineMatch(text, pattern);
51
+ if (match === null) {
52
+ return null;
53
+ }
54
+ const replaced = `${match.prefix}${replacement(match.value)}${match.suffix}`;
55
+ return text.slice(0, match.index) + replaced + text.slice(match.index + match.full.length);
56
+ }
57
+ function substituteAllLines(text, pattern, expectedCount, replacement) {
58
+ const matches = [...text.matchAll(new RegExp(pattern, 'gmu'))];
59
+ if (matches.length !== expectedCount) {
60
+ return null;
61
+ }
62
+ let result = '';
63
+ let cursor = 0;
64
+ for (const match of matches) {
65
+ const [full, prefix = '', value = '', suffix = ''] = match;
66
+ result += text.slice(cursor, match.index) + prefix + replacement(value) + suffix;
67
+ cursor = match.index + full.length;
68
+ }
69
+ return result + text.slice(cursor);
70
+ }
71
+ function isIsoTimestamp(value) {
72
+ if (typeof value !== 'string') {
73
+ return false;
74
+ }
75
+ const date = new Date(value);
76
+ return !Number.isNaN(date.getTime()) && date.toISOString() === value;
77
+ }
78
+ function isLosslessUtf8(raw, text) {
79
+ return Buffer.from(text, 'utf8').equals(raw);
80
+ }
81
+ const TOP_LEVEL_VERSION_LINE = /^( {2}"version": ")([^"]*)(",?)$/mu;
82
+ function normalizeVersionField(raw) {
83
+ const text = raw.toString('utf8');
84
+ if (!isLosslessUtf8(raw, text)) {
85
+ return raw;
86
+ }
87
+ const next = substituteLine(text, TOP_LEVEL_VERSION_LINE, () => VERSION_PLACEHOLDER);
88
+ return next === null ? raw : Buffer.from(next, 'utf8');
89
+ }
90
+ const RELEASE_VERSION_LINE = /^( {4}"version": ")([^"]*)(",?)$/mu;
91
+ const RELEASE_TAG_LINE = /^( {4}"tag": ")([^"]*)(",?)$/mu;
92
+ const RELEASE_SOURCE_URL_LINE = /^( {6}"url": ")([^"]*)(")$/mu;
93
+ const RELEASE_COMMIT_LINE = /^( {4}"commit": ")([^"]*)(",?)$/mu;
94
+ const TOP_LEVEL_GENERATED_AT_LINE = /^( {2}"generatedAt": ")([^"]*)(",?)$/mu;
95
+ const RELEASE_VERIFIED_AT_LINE = /^( {4}"verifiedAt": ")([^"]*)(",?)$/mu;
96
+ const METRIC_VERIFIED_AT_LINE = /^( {6}"verifiedAt": ")([^"]*)(",?)$/mu;
97
+ const METRICS_ARRAY_HEADER = '\n "metrics": [';
98
+ const COMMIT_SHA_PATTERN = /^[0-9a-f]{40}$/u;
99
+ const COMMIT_SHA_PLACEHOLDER = '0'.repeat(40);
100
+ const TIMESTAMP_PLACEHOLDER = '1970-01-01T00:00:00.000Z';
101
+ function findMetricsArrayRegion(text) {
102
+ const headerIndex = text.indexOf(METRICS_ARRAY_HEADER);
103
+ if (headerIndex === -1 || text.includes(METRICS_ARRAY_HEADER, headerIndex + 1)) {
104
+ return null;
105
+ }
106
+ const start = headerIndex + METRICS_ARRAY_HEADER.length;
107
+ const closeIndex = text.indexOf('\n ]', start);
108
+ if (closeIndex === -1) {
109
+ return null;
110
+ }
111
+ return { start, end: closeIndex };
112
+ }
113
+ function substituteAllLinesInRegion(text, region, pattern, expectedCount, replacement) {
114
+ const slice = text.slice(region.start, region.end);
115
+ const replacedSlice = substituteAllLines(slice, pattern, expectedCount, replacement);
116
+ if (replacedSlice === null) {
117
+ return null;
118
+ }
119
+ return text.slice(0, region.start) + replacedSlice + text.slice(region.end);
120
+ }
121
+ function parseValidatedProductProof(text) {
122
+ let parsed;
123
+ try {
124
+ parsed = JSON.parse(text);
125
+ }
126
+ catch {
127
+ return null;
128
+ }
129
+ const release = parsed.release;
130
+ if (!release || typeof release !== 'object') {
131
+ return null;
132
+ }
133
+ const { version, tag, source, commit, verifiedAt: releaseVerifiedAt } = release;
134
+ if (typeof version !== 'string' || typeof tag !== 'string' || tag !== `v${version}`) {
135
+ return null;
136
+ }
137
+ const url = source && typeof source === 'object' ? source.url : undefined;
138
+ if (typeof url !== 'string' || !url.includes(version)) {
139
+ return null;
140
+ }
141
+ if (typeof commit !== 'string' || !COMMIT_SHA_PATTERN.test(commit)) {
142
+ return null;
143
+ }
144
+ if (!isIsoTimestamp(parsed.generatedAt) || !isIsoTimestamp(releaseVerifiedAt)) {
145
+ return null;
146
+ }
147
+ const metrics = parsed.metrics;
148
+ if (!Array.isArray(metrics)) {
149
+ return null;
150
+ }
151
+ for (const metric of metrics) {
152
+ if (!metric ||
153
+ typeof metric !== 'object' ||
154
+ !isIsoTimestamp(metric.verifiedAt)) {
155
+ return null;
156
+ }
157
+ }
158
+ return { version, metricsCount: metrics.length };
159
+ }
160
+ function normalizeProductProof(raw) {
161
+ const text = raw.toString('utf8');
162
+ if (!isLosslessUtf8(raw, text)) {
163
+ return raw;
164
+ }
165
+ const validated = parseValidatedProductProof(text);
166
+ if (validated === null) {
167
+ return raw;
168
+ }
169
+ const { version, metricsCount } = validated;
170
+ let next = substituteLine(text, RELEASE_VERSION_LINE, () => VERSION_PLACEHOLDER);
171
+ if (next === null) {
172
+ return raw;
173
+ }
174
+ next = substituteLine(next, RELEASE_TAG_LINE, () => `v${VERSION_PLACEHOLDER}`);
175
+ if (next === null) {
176
+ return raw;
177
+ }
178
+ next = substituteLine(next, RELEASE_SOURCE_URL_LINE, (value) => value.split(version).join(VERSION_PLACEHOLDER));
179
+ if (next === null) {
180
+ return raw;
181
+ }
182
+ next = substituteLine(next, RELEASE_COMMIT_LINE, () => COMMIT_SHA_PLACEHOLDER);
183
+ if (next === null) {
184
+ return raw;
185
+ }
186
+ next = substituteLine(next, TOP_LEVEL_GENERATED_AT_LINE, () => TIMESTAMP_PLACEHOLDER);
187
+ if (next === null) {
188
+ return raw;
189
+ }
190
+ next = substituteLine(next, RELEASE_VERIFIED_AT_LINE, () => TIMESTAMP_PLACEHOLDER);
191
+ if (next === null) {
192
+ return raw;
193
+ }
194
+ const metricsRegion = findMetricsArrayRegion(next);
195
+ if (metricsRegion === null) {
196
+ return raw;
197
+ }
198
+ next = substituteAllLinesInRegion(next, metricsRegion, METRIC_VERIFIED_AT_LINE, metricsCount, () => TIMESTAMP_PLACEHOLDER);
199
+ if (next === null) {
200
+ return raw;
201
+ }
202
+ return Buffer.from(next, 'utf8');
203
+ }
204
+ const IMPORTERS_HEADER = /^importers:\s*$/u;
205
+ const ROOT_IMPORTER_HEADER = /^ {2}\.:\s*$/u;
206
+ const IMPORTER_KEY = /^ {2}\S/u;
207
+ const ROOT_VERSION_LINE = /^( {4}version:\s*)\S.*$/u;
208
+ function normalizePnpmLock(raw) {
209
+ const lines = raw.toString('utf8').split('\n');
210
+ let inImporters = false;
211
+ let inRootImporter = false;
212
+ const normalized = lines.map((line) => {
213
+ if (IMPORTERS_HEADER.test(line)) {
214
+ inImporters = true;
215
+ inRootImporter = false;
216
+ return line;
217
+ }
218
+ if (!inImporters) {
219
+ return line;
220
+ }
221
+ if (/^\S/u.test(line)) {
222
+ inImporters = false;
223
+ inRootImporter = false;
224
+ return line;
225
+ }
226
+ if (ROOT_IMPORTER_HEADER.test(line)) {
227
+ inRootImporter = true;
228
+ return line;
229
+ }
230
+ if (IMPORTER_KEY.test(line)) {
231
+ inRootImporter = false;
232
+ return line;
233
+ }
234
+ if (inRootImporter) {
235
+ const match = ROOT_VERSION_LINE.exec(line);
236
+ if (match) {
237
+ return `${match[1]}${VERSION_PLACEHOLDER}`;
238
+ }
239
+ }
240
+ return line;
241
+ });
242
+ return Buffer.from(normalized.join('\n'), 'utf8');
243
+ }
244
+ export function normalizeCarrierBytes(path, raw) {
245
+ try {
246
+ if (path === 'package.json' || path === 'planu-plugin.json') {
247
+ return normalizeVersionField(raw);
248
+ }
249
+ if (path === 'website/public/proof/product-proof.json') {
250
+ return normalizeProductProof(raw);
251
+ }
252
+ if (path === 'pnpm-lock.yaml') {
253
+ return normalizePnpmLock(raw);
254
+ }
255
+ }
256
+ catch {
257
+ return raw;
258
+ }
259
+ return raw;
260
+ }
261
+ const MASKED_OBJECT_ID = '0'.repeat(40);
262
+ export function filterMaskedTreeEntries(entries) {
263
+ return entries.map((entry) => {
264
+ const tabIndex = entry.indexOf('\t');
265
+ if (tabIndex === -1) {
266
+ return entry;
267
+ }
268
+ const path = entry.slice(tabIndex + 1);
269
+ if (!isBumpCarrierPath(path)) {
270
+ return entry;
271
+ }
272
+ const [mode, type] = entry.slice(0, tabIndex).split(' ');
273
+ return `${mode} ${type} ${MASKED_OBJECT_ID}\t${path}`;
274
+ });
275
+ }
276
+ //# sourceMappingURL=bump-carrier-binding.js.map
@@ -0,0 +1,10 @@
1
+ import type { NpmCacheFinding } from '../../types/index.js';
2
+ export declare const CACACHE_DIR = "_cacache";
3
+ export declare const NPM_CACHE_SUBDIRS: readonly ['content-v2', 'index-v5'];
4
+ export declare const MAX_FOREIGN_ENTRIES = 50;
5
+ export declare const MAX_SCANNED_ENTRIES = 2000;
6
+ export declare const MAX_SAMPLE_ENTRIES = 5;
7
+ export declare function currentUid(): number | null;
8
+ export declare function resolveNpmCacheDir(env: NodeJS.ProcessEnv, home: string): string;
9
+ export declare function checkNpmCacheOwnership(cacheDir: string, uid: number): NpmCacheFinding;
10
+ //# sourceMappingURL=npm-cache-check.d.ts.map
@@ -0,0 +1,109 @@
1
+ import { existsSync, readdirSync, lstatSync } from 'node:fs';
2
+ import { join, relative } from 'node:path';
3
+ export const CACACHE_DIR = '_cacache';
4
+ export const NPM_CACHE_SUBDIRS = ['content-v2', 'index-v5'];
5
+ export const MAX_FOREIGN_ENTRIES = 50;
6
+ export const MAX_SCANNED_ENTRIES = 2000;
7
+ export const MAX_SAMPLE_ENTRIES = 5;
8
+ export function currentUid() {
9
+ return process.getuid?.() ?? null;
10
+ }
11
+ export function resolveNpmCacheDir(env, home) {
12
+ const configured = env.npm_config_cache;
13
+ if (configured !== undefined && configured.trim() !== '') {
14
+ return configured;
15
+ }
16
+ return join(home, '.npm');
17
+ }
18
+ function readDirEntries(dir) {
19
+ try {
20
+ return readdirSync(dir, { withFileTypes: true });
21
+ }
22
+ catch {
23
+ return null;
24
+ }
25
+ }
26
+ function statEntry(entryPath) {
27
+ try {
28
+ return lstatSync(entryPath);
29
+ }
30
+ catch {
31
+ return null;
32
+ }
33
+ }
34
+ export function checkNpmCacheOwnership(cacheDir, uid) {
35
+ const fix = `sudo chown -R $USER ${cacheDir}`;
36
+ const emptyFinding = (status) => ({
37
+ status,
38
+ cacheDir,
39
+ foreignCount: 0,
40
+ scanned: 0,
41
+ truncated: false,
42
+ sampleEntries: [],
43
+ fix,
44
+ });
45
+ if (!existsSync(cacheDir)) {
46
+ return emptyFinding('ok');
47
+ }
48
+ if (readDirEntries(cacheDir) === null) {
49
+ return emptyFinding('unreadable');
50
+ }
51
+ const cacache = join(cacheDir, CACACHE_DIR);
52
+ if (!existsSync(cacache)) {
53
+ return emptyFinding('ok');
54
+ }
55
+ let foreignCount = 0;
56
+ let scanned = 0;
57
+ let truncated = false;
58
+ const sampleEntries = [];
59
+ const walkDir = (dir) => {
60
+ const entries = readDirEntries(dir);
61
+ if (entries === null) {
62
+ return false;
63
+ }
64
+ for (const entry of entries) {
65
+ if (scanned >= MAX_SCANNED_ENTRIES) {
66
+ truncated = true;
67
+ return true;
68
+ }
69
+ scanned += 1;
70
+ const entryPath = join(dir, entry.name);
71
+ const st = statEntry(entryPath);
72
+ if (st === null) {
73
+ continue;
74
+ }
75
+ if (st.uid !== uid) {
76
+ foreignCount += 1;
77
+ if (sampleEntries.length < MAX_SAMPLE_ENTRIES) {
78
+ sampleEntries.push(relative(cacheDir, entryPath));
79
+ }
80
+ if (foreignCount >= MAX_FOREIGN_ENTRIES) {
81
+ return true;
82
+ }
83
+ }
84
+ if (st.isDirectory() && walkDir(entryPath)) {
85
+ return true;
86
+ }
87
+ }
88
+ return false;
89
+ };
90
+ for (const name of NPM_CACHE_SUBDIRS) {
91
+ const root = join(cacache, name);
92
+ if (!existsSync(root)) {
93
+ continue;
94
+ }
95
+ if (walkDir(root)) {
96
+ break;
97
+ }
98
+ }
99
+ return {
100
+ status: foreignCount > 0 ? 'foreign-owned' : 'ok',
101
+ cacheDir,
102
+ foreignCount,
103
+ scanned,
104
+ truncated,
105
+ sampleEntries,
106
+ fix,
107
+ };
108
+ }
109
+ //# sourceMappingURL=npm-cache-check.js.map
@@ -9,6 +9,7 @@ export interface CopulaViolation {
9
9
  * Returns a CopulaViolation if found, or null if the text is clean.
10
10
  */
11
11
  export declare function checkCopulaViolation(scenarioText: string): CopulaViolation | null;
12
+ export declare function maskQuotedSpans(text: string): string;
12
13
  /**
13
14
  * SPEC-631: Scan acceptance criteria lines for vague modal verbs.
14
15
  * Returns formatted blocker strings (one per violation) with original line and GWT rewrite.