@planu/cli 6.0.1 → 6.0.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## [6.0.2] - 2026-09-10
2
+
3
+ ### Reliability
4
+ - prove lifecycle persistence, registered-worktree isolation, and implementation-change attribution end to end
5
+ - enforce current stable direct dependencies through a deterministic read-only preflight and pre-push guard
6
+ - distinguish actionable dependency drift from registry, timeout, empty-output, and malformed-output failures
7
+
8
+ ### Maintenance
9
+ - refresh direct dependencies to their current stable compatible releases
10
+ - consolidate overlapping lifecycle specs and discard obsolete work
11
+
1
12
  ## [6.0.1] - 2026-09-10
2
13
 
3
14
  ### Cleanup
@@ -1 +1 @@
1
- {"schemaVersion":1,"commit":"af76d38310eb4ab7b625442c738f40230a8e0b0a"}
1
+ {"schemaVersion":1,"commit":"0b3ee8aba0826533bef0aebc7dc3aeb43999ab00"}
@@ -13,7 +13,9 @@ type AttributableOwnedPaths = {
13
13
  * committed baseline. Failure is deliberately quiet: callers must not turn
14
14
  * baseline tokens into implementation evidence when attribution is unavailable.
15
15
  */
16
- export declare function resolveAttributableOwnedPaths(projectPath: string, ownedPaths: string[]): Promise<AttributableOwnedPaths>;
16
+ export declare function resolveAttributableOwnedPaths(projectPath: string, ownedPaths: string[], baselineSha?: string | null): Promise<AttributableOwnedPaths>;
17
+ /** Capture the selected checkout commit once so a lifecycle call has one stable diff baseline. */
18
+ export declare function captureAttributionBaseline(projectPath: string): Promise<string | null>;
17
19
  /**
18
20
  * Scan the spec's owned paths for evidence of implementation across 4 layers.
19
21
  * Empty ownership yields an empty result — never a repository-wide scan.
@@ -6,13 +6,14 @@ import { execFile } from 'node:child_process';
6
6
  import { promisify } from 'node:util';
7
7
  import { fastReadFiles } from '../core-bridge.js';
8
8
  const CODE_FILE_RE = /\.(ts|js|tsx|jsx)$/;
9
+ const GIT_COMMIT_RE = /^[a-f0-9]{40,64}$/u;
9
10
  const execFileAsync = promisify(execFile);
10
11
  /**
11
12
  * Reduce the already-bounded ownership list to files changed from the current
12
13
  * committed baseline. Failure is deliberately quiet: callers must not turn
13
14
  * baseline tokens into implementation evidence when attribution is unavailable.
14
15
  */
15
- export async function resolveAttributableOwnedPaths(projectPath, ownedPaths) {
16
+ export async function resolveAttributableOwnedPaths(projectPath, ownedPaths, baselineSha) {
16
17
  const bounded = [
17
18
  ...new Set(ownedPaths
18
19
  .map((path) => normalize(path))
@@ -22,9 +23,13 @@ export async function resolveAttributableOwnedPaths(projectPath, ownedPaths) {
22
23
  return { available: true, paths: [] };
23
24
  }
24
25
  try {
26
+ const baseline = baselineSha === undefined ? await captureAttributionBaseline(projectPath) : baselineSha;
27
+ if (baseline === null) {
28
+ return { available: false, paths: [], diagnostic: 'git-baseline-unavailable' };
29
+ }
25
30
  const commands = [
26
- ['diff', '--name-only', '--diff-filter=ACMRTUXB', 'HEAD', '--', ...bounded],
27
- ['diff', '--cached', '--name-only', '--diff-filter=ACMRTUXB', 'HEAD', '--', ...bounded],
31
+ ['diff', '--name-only', '--diff-filter=ACMRTUXB', baseline, '--', ...bounded],
32
+ ['diff', '--cached', '--name-only', '--diff-filter=ACMRTUXB', baseline, '--', ...bounded],
28
33
  ['ls-files', '--others', '--exclude-standard', '--', ...bounded],
29
34
  ];
30
35
  const outputs = await Promise.all(commands.map((args) => execFileAsync('git', ['-C', projectPath, ...args], {
@@ -44,6 +49,17 @@ export async function resolveAttributableOwnedPaths(projectPath, ownedPaths) {
44
49
  return { available: false, paths: [], diagnostic: 'git-baseline-unavailable' };
45
50
  }
46
51
  }
52
+ /** Capture the selected checkout commit once so a lifecycle call has one stable diff baseline. */
53
+ export async function captureAttributionBaseline(projectPath) {
54
+ try {
55
+ const { stdout } = await execFileAsync('git', ['-C', projectPath, 'rev-parse', '--verify', 'HEAD'], { encoding: 'utf8', maxBuffer: 1024 * 1024 });
56
+ const baseline = stdout.trim();
57
+ return GIT_COMMIT_RE.test(baseline) ? baseline : null;
58
+ }
59
+ catch {
60
+ return null;
61
+ }
62
+ }
47
63
  /**
48
64
  * Scan the spec's owned paths for evidence of implementation across 4 layers.
49
65
  * Empty ownership yields an empty result — never a repository-wide scan.
@@ -5,7 +5,7 @@ export declare function executionMkdir(path: string, options: MakeDirectoryOptio
5
5
  recursive: true;
6
6
  }): Promise<string | undefined>;
7
7
  /** Exclusive-create helper for idempotency claims; never overwrites an owner. */
8
- export declare function executionWriteFileExclusive(path: string, content: string, options?: Omit<WriteFileOptions, 'flag'>): Promise<void>;
8
+ export declare function executionWriteFileExclusive(path: string, content: string, options?: Exclude<WriteFileOptions, BufferEncoding>): Promise<void>;
9
9
  export declare function executionRename(source: string, target: string): Promise<void>;
10
10
  export declare function executionLink(source: string, target: string): Promise<void>;
11
11
  export declare function executionRemove(path: string, options?: {
@@ -7,9 +7,9 @@ export async function executionMkdir(path, options) {
7
7
  return mkdir(path, options);
8
8
  }
9
9
  /** Exclusive-create helper for idempotency claims; never overwrites an owner. */
10
- export async function executionWriteFileExclusive(path, content, options = {}) {
10
+ export async function executionWriteFileExclusive(path, content, options) {
11
11
  assertExecutionCanCommit();
12
- await writeFile(path, content, { ...options, flag: 'wx' });
12
+ await writeFile(path, content, { ...(options ?? {}), flag: 'wx' });
13
13
  }
14
14
  export async function executionRename(source, target) {
15
15
  assertExecutionCanCommit();
@@ -746,9 +746,8 @@ async function findByIdempotencyKey(projectPath, key, projectId, windowMs = IDEM
746
746
  return evidenceMatch;
747
747
  }
748
748
  try {
749
- const { glob } = await import('glob');
750
- const { join: joinPath } = await import('node:path');
751
- const specFiles = await glob(joinPath(projectPath, 'planu/specs/*/spec.md'));
749
+ const globModule = await import('glob');
750
+ const specFiles = await globModule.glob(pathJoin(projectPath, 'planu/specs/*/spec.md'));
752
751
  for (const specFile of specFiles) {
753
752
  const fileStat = await fsStat(specFile).catch(() => null);
754
753
  if (fileStat === null || fileStat.mtimeMs < cutoff) {
@@ -776,10 +775,9 @@ async function findByIdempotencyKey(projectPath, key, projectId, windowMs = IDEM
776
775
  /** SPEC-770: Scan for recently written spec.md files (for possibleDuplicates in timeout response). */
777
776
  async function findRecentlyWrittenSpecs(projectPath, windowMs, requestedTitle) {
778
777
  try {
779
- const { glob } = await import('glob');
780
- const { join: joinPath } = await import('node:path');
778
+ const globModule = await import('glob');
781
779
  const cutoff = Date.now() - windowMs;
782
- const specFiles = await glob(joinPath(projectPath, 'planu/specs/*/spec.md'));
780
+ const specFiles = await globModule.glob(pathJoin(projectPath, 'planu/specs/*/spec.md'));
783
781
  const results = [];
784
782
  for (const specFile of specFiles) {
785
783
  const fileStat = await fsStat(specFile).catch(() => null);
@@ -11,7 +11,7 @@ type LifecycleAuthorityRoute = {
11
11
  result: ToolResult;
12
12
  };
13
13
  /** Select the lifecycle path before any transition, artifact, receipt, or log mutation. */
14
- export declare function runOwnershipBoundedCodeReality(spec: Spec, projectPath: string): Promise<GapScore>;
14
+ export declare function runOwnershipBoundedCodeReality(spec: Spec, projectPath: string, baselineSha?: string | null): Promise<GapScore>;
15
15
  export declare function classifyLifecycleAuthority(input: UpdateStatusInput, context: ReconciliationInvocationContext, options?: {
16
16
  requireDoneDigest?: boolean;
17
17
  }): LifecycleAuthorityRoute;
@@ -27,7 +27,7 @@ import { readFile } from 'node:fs/promises';
27
27
  import { queuePostCommitTasks } from './side-effects.js';
28
28
  import { formatKeyValue } from '../output-formatter.js';
29
29
  import { checkCodeReality } from '../../engine/code-scanner/index.js';
30
- import { resolveAttributableOwnedPaths } from '../../engine/code-scanner/layer-scanner.js';
30
+ import { captureAttributionBaseline, resolveAttributableOwnedPaths, } from '../../engine/code-scanner/layer-scanner.js';
31
31
  import { scoreUnavailableAttribution } from '../../engine/code-scanner/gap-scorer.js';
32
32
  import { extractFilesFromSpecBody } from '../../engine/spec-format/technical-md-populator.js';
33
33
  import { isAbsolute, join, resolve } from 'node:path';
@@ -53,7 +53,7 @@ function lifecycleAuthorityError(code, message, fixHint) {
53
53
  };
54
54
  }
55
55
  /** Select the lifecycle path before any transition, artifact, receipt, or log mutation. */
56
- export async function runOwnershipBoundedCodeReality(spec, projectPath) {
56
+ export async function runOwnershipBoundedCodeReality(spec, projectPath, baselineSha) {
57
57
  const specPath = isAbsolute(spec.specPath) ? spec.specPath : join(projectPath, spec.specPath);
58
58
  const specBody = await readSpecContent(specPath);
59
59
  const ownership = specBody === null ? null : await extractFilesFromSpecBody(specBody, projectPath);
@@ -65,7 +65,7 @@ export async function runOwnershipBoundedCodeReality(spec, projectPath) {
65
65
  if (ownedPaths.length === 0) {
66
66
  reportClassifiedDegradation('CODE_REALITY_OWNERSHIP_MISSING', new Error(`spec ${spec.id} declares no canonical owned paths`));
67
67
  }
68
- const attributable = await resolveAttributableOwnedPaths(projectPath, ownedPaths);
68
+ const attributable = await resolveAttributableOwnedPaths(projectPath, ownedPaths, baselineSha);
69
69
  if (!attributable.available) {
70
70
  reportClassifiedDegradation('CODE_REALITY_ATTRIBUTION_UNAVAILABLE', new Error(attributable.diagnostic));
71
71
  return scoreUnavailableAttribution();
@@ -700,6 +700,9 @@ export async function handleUpdateStatus(params, server) {
700
700
  const transitionProjectPath = (params.projectPath?.trim()
701
701
  ? effectiveProjectPath
702
702
  : (knowledge?.projectPath ?? effectiveProjectPath)) || undefined;
703
+ const implementationBaselineSha = newStatus === 'implementing' && transitionProjectPath
704
+ ? await captureAttributionBaseline(transitionProjectPath)
705
+ : undefined;
703
706
  if (authorityRoute.route === 'reconcile') {
704
707
  if (params.evidence !== undefined) {
705
708
  return {
@@ -1041,7 +1044,7 @@ export async function handleUpdateStatus(params, server) {
1041
1044
  const [codeRealityResult, doneGatesResult] = await Promise.all([
1042
1045
  // Code reality: only relevant for 'implementing'
1043
1046
  newStatus === 'implementing' && !reverseTransition && effectiveGatePath
1044
- ? runOwnershipBoundedCodeReality(spec, effectiveGatePath).catch((error) => {
1047
+ ? runOwnershipBoundedCodeReality(spec, effectiveGatePath, implementationBaselineSha).catch((error) => {
1045
1048
  // reliability-optional: CODE_REALITY_ENRICHMENT — downstream evidence gates remain binding
1046
1049
  reportClassifiedDegradation('CODE_REALITY_ENRICHMENT', error);
1047
1050
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planu/cli",
3
- "version": "6.0.1",
3
+ "version": "6.0.2",
4
4
  "description": "Planu — MCP Server for Spec Driven Development. Cross-platform (Linux/macOS/Windows, x64/arm64).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -49,8 +49,9 @@
49
49
  "check:sdd-core": "node scripts/check-sdd-core-closure.mjs",
50
50
  "measure:sdd-core": "node scripts/measure-sdd-core.mjs --baseline tests/fixtures/sdd-core-baseline.json --measure-current",
51
51
  "check:destructive-ops": "bash scripts/check-no-automatic-destructive-ops.sh",
52
+ "check:deps:fresh": "node scripts/check-dependency-freshness.mjs",
52
53
  "check:strict": "pnpm check && pnpm generate:host-tool-registry -- --check && node scripts/prune-dead-exports.mjs --check && pnpm audit:deadcode && pnpm audit:circular && pnpm audit:types",
53
- "check:preflight": "pnpm check && pnpm test:contracts && pnpm measure:sdd-core && pnpm build",
54
+ "check:preflight": "pnpm check:deps:fresh && pnpm check && pnpm test:contracts && pnpm measure:sdd-core && pnpm build",
54
55
  "test:contracts": "node scripts/test-contracts.mjs",
55
56
  "test:migrations": "vitest run tests/storage/corruption-contract.test.ts tests/integration/runtime-storage.test.ts tests/integration/canonical-storage-migration.test.ts tests/storage/sdd-core-migration.test.ts",
56
57
  "test:fault-injection": "vitest run tests/integration/durable-job-runtime.test.ts tests/integration/idempotent-operations.test.ts tests/storage/sdd-core-migration.test.ts",
@@ -102,7 +103,7 @@
102
103
  "@modelcontextprotocol/sdk": "^1.30.0",
103
104
  "glob": "^13.0.6",
104
105
  "yaml": "^2.9.0",
105
- "zod": "^4.5.4"
106
+ "zod": "^4.6.1"
106
107
  },
107
108
  "devDependencies": {
108
109
  "@commitlint/cli": "^21.2.2",
@@ -110,7 +111,7 @@
110
111
  "@eslint/js": "^10.0.1",
111
112
  "@secretlint/secretlint-rule-no-homedir": "^13.0.5",
112
113
  "@secretlint/secretlint-rule-preset-recommend": "^13.0.5",
113
- "@types/node": "^26.4.1",
114
+ "@types/node": "^22.20.2",
114
115
  "@typescript/native": "npm:typescript@^7.0.2",
115
116
  "@vitest/coverage-v8": "^5.0.0",
116
117
  "eslint": "10.10.0",
@@ -119,7 +120,7 @@
119
120
  "eslint-plugin-import": "^2.32.0",
120
121
  "husky": "^9.1.7",
121
122
  "jiti": "2.7.0",
122
- "knip": "^6.34.0",
123
+ "knip": "^6.35.1",
123
124
  "lint-staged": "^17.5.0",
124
125
  "madge": "^8.0.0",
125
126
  "prettier": "^3.9.6",
@@ -127,7 +128,7 @@
127
128
  "tsc-alias": "^1.9.4",
128
129
  "type-coverage": "^2.30.1",
129
130
  "typescript": "npm:@typescript/typescript6@^6.0.2",
130
- "typescript-eslint": "^8.69.0",
131
+ "typescript-eslint": "^8.70.0",
131
132
  "vite": "^8.2.2",
132
133
  "vitest": "^5.0.0"
133
134
  }