@planu/cli 5.7.16 → 5.7.18

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,24 @@
1
+ ## [5.7.18] - 2026-09-04
2
+
3
+ ### Bug Fixes
4
+ - fix(release): strip only the duration from gate results, not every field
5
+ - fix(tools): keep declared verbose flag and detect zod shapes structurally
6
+ - fix(handoff,tools): resolve relative specPath and honor verbose:true
7
+
8
+ ### Performance
9
+ - perf(release): measure gate durations and reuse the typecheck build-info
10
+
11
+
12
+ ## [5.7.17] - 2026-09-04
13
+
14
+ ### Bug Fixes
15
+ - fix(handoff): degrade the handoff digest when a relative spec path has no project root (SPEC-1796)
16
+ - fix(validate): let a stage supply its own gate deadline so blast-radius keeps its budget (SPEC-1797)
17
+ - fix(handoff): resolve spec.specPath against project root before digesting
18
+ - fix(handoff): fold spec content into handoff job identity
19
+ - fix(release): give release pushes a hook-aware timeout budget (SPEC-1795)
20
+
21
+
1
22
  ## [5.7.16] - 2026-09-04
2
23
 
3
24
  ### Bug Fixes
@@ -1 +1 @@
1
- {"schemaVersion":1,"commit":"5af535ce75c63652afeaaa128d25102e161667d3"}
1
+ {"schemaVersion":1,"commit":"61a73981c39f96a78cffbc3031cef4c10647fb56"}
@@ -2,7 +2,7 @@
2
2
  /* eslint-disable max-lines -- package assembly and the SPEC-1240 atomic-publish/version-fence path stay co-located for auditability */
3
3
  import { createHash, randomUUID } from 'node:crypto';
4
4
  import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
5
- import { join } from 'node:path';
5
+ import { isAbsolute, join, resolve as resolvePath } from 'node:path';
6
6
  import { stripFrontmatter } from './frontmatter-parser.js';
7
7
  // eslint-disable-next-line no-restricted-imports -- grandfathered layer violation, remediation SPEC-1661 SPEC-1662 SPEC-1663
8
8
  import { hashProjectPath, projectDataDir } from '../storage/base-store.js';
@@ -641,11 +641,20 @@ function buildConstraints(knowledge) {
641
641
  });
642
642
  return constraints;
643
643
  }
644
+ async function readSpecFile(specPath, projectPath) {
645
+ if (isAbsolute(specPath)) {
646
+ return readFile(specPath, 'utf-8').catch(() => '');
647
+ }
648
+ if (!projectPath) {
649
+ return '';
650
+ }
651
+ return readFile(resolvePath(projectPath, specPath), 'utf-8').catch(() => '');
652
+ }
644
653
  // ── Public API ───────────────────────────────────────────────────────────────
645
654
  export async function packageHandoff(spec, knowledge, versionFence) {
646
655
  const warnings = [];
647
656
  const rawSpecContent = spec.specPath
648
- ? await readFile(spec.specPath, 'utf-8').catch(() => '')
657
+ ? await readSpecFile(spec.specPath, knowledge.projectPath)
649
658
  : '';
650
659
  const huContent = rawSpecContent ? stripFrontmatter(rawSpecContent) : '';
651
660
  const fichaContent = huContent;
@@ -12,6 +12,9 @@ export declare function readPolicy(projectPath: string): {
12
12
  }[];
13
13
  sourceReceiptInputPatterns: string[];
14
14
  };
15
+ export declare function stripGateResultDurations<T extends {
16
+ durationMs?: number;
17
+ }>(results: T[]): Omit<T, 'durationMs'>[];
15
18
  export declare function computeBinding(projectPath: string): {
16
19
  source: {
17
20
  maskedTreeDigest: string;
@@ -149,6 +149,9 @@ function collectInputs(projectPath, patterns) {
149
149
  return { path, sha256: sha256(bytes) };
150
150
  });
151
151
  }
152
+ export function stripGateResultDurations(results) {
153
+ return results.map(({ durationMs: _durationMs, ...rest }) => rest);
154
+ }
152
155
  export function computeBinding(projectPath) {
153
156
  assertCleanSource(projectPath);
154
157
  const policy = readPolicy(projectPath);
@@ -1,7 +1,7 @@
1
1
  import { existsSync, lstatSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
2
2
  import { isAbsolute, join } from 'node:path';
3
3
  import { canonical } from './bump-carrier-binding.js';
4
- import { computeBinding, runIdentity, sha256 } from './source-quality-binding.js';
4
+ import { computeBinding, runIdentity, sha256, stripGateResultDurations, } from './source-quality-binding.js';
5
5
  import { VALIDATION_COMMANDS } from './validation-impact-planner.js';
6
6
  function successfulResults(commandPlan) {
7
7
  return commandPlan.map(({ id, executable, args }) => ({ id, executable, args, exitCode: 0 }));
@@ -39,7 +39,8 @@ export function readMatchingSourceQualityReceipt(projectPath, command) {
39
39
  }
40
40
  const actual = JSON.parse(readFileSync(path, 'utf8'));
41
41
  const expected = { schemaVersion: 1, key, binding, results };
42
- if (canonical(actual) !== canonical(expected)) {
42
+ const actualWithoutDurations = { ...actual, results: stripGateResultDurations(actual.results) };
43
+ if (canonical(actualWithoutDurations) !== canonical(expected)) {
43
44
  return null;
44
45
  }
45
46
  return { key, path };
@@ -17,5 +17,5 @@ export declare function compactStructuredContent(structuredContent: Record<strin
17
17
  * Also bounds structuredContent so token recording reflects the actual visible
18
18
  * payload instead of unbounded internal data.
19
19
  */
20
- export declare function compressToolOutput(result: ToolResult): ToolResult;
20
+ export declare function compressToolOutput(result: ToolResult, verbose?: boolean): ToolResult;
21
21
  //# sourceMappingURL=output-compressor.d.ts.map
@@ -250,7 +250,7 @@ export function compactStructuredContent(structuredContent, options = {}) {
250
250
  * Also bounds structuredContent so token recording reflects the actual visible
251
251
  * payload instead of unbounded internal data.
252
252
  */
253
- export function compressToolOutput(result) {
253
+ export function compressToolOutput(result, verbose = false) {
254
254
  // Don't compress error results — they need full context for debugging
255
255
  if (result.isError === true) {
256
256
  return result;
@@ -259,6 +259,9 @@ export function compressToolOutput(result) {
259
259
  if (process.env.PLANU_VERBOSE_OUTPUT === 'true') {
260
260
  return result;
261
261
  }
262
+ if (verbose) {
263
+ return result;
264
+ }
262
265
  const compressed = result.content.map((block) => ({
263
266
  ...block,
264
267
  text: compressTextBlock(block.text),
@@ -52,7 +52,9 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
52
52
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
53
53
  });
54
54
  import { createHash } from 'node:crypto';
55
- import { specStore } from '../storage/index.js';
55
+ import { readFile } from 'node:fs/promises';
56
+ import { isAbsolute, resolve as resolvePath } from 'node:path';
57
+ import { specStore, knowledgeStore } from '../storage/index.js';
56
58
  import { DurableJobRuntime, DurableJobNotFoundError, publicJobCursor, } from '../engine/execution/job-runtime.js';
57
59
  import { schedulePackageHandoffJobExecution } from '../engine/execution/package-handoff-job-executor.js';
58
60
  import { acquireLock, releaseLock } from '../engine/safety/cross-process-lock.js';
@@ -61,10 +63,33 @@ export { formatHandoff } from '../engine/handoff-format.js';
61
63
  const SUBMISSION_LOCK_WAIT_MS = 5_000;
62
64
  const SUBMISSION_LOCK_POLL_MS = 100;
63
65
  const TERMINAL_RECOVERABLE_STATES = new Set(['failed', 'cancelled', 'dead-letter']);
64
- function deriveOperationId(projectId, specId, specVersion) {
65
- const digest = createHash('sha256').update(`${projectId}|${specId}|${specVersion}`).digest('hex');
66
+ function deriveOperationId(projectId, specId, specVersion, specContentDigest) {
67
+ const digest = createHash('sha256')
68
+ .update(`${projectId}|${specId}|${specVersion}|${specContentDigest}`)
69
+ .digest('hex');
66
70
  return `handoff-${digest}`;
67
71
  }
72
+ async function resolveProjectRoot(projectId, projectPath) {
73
+ if (projectPath) {
74
+ return projectPath;
75
+ }
76
+ const knowledge = await knowledgeStore.getKnowledge(projectId);
77
+ return knowledge?.projectPath;
78
+ }
79
+ async function digestSpecFile(projectId, projectPath, specPath) {
80
+ if (!specPath) {
81
+ return '';
82
+ }
83
+ if (isAbsolute(specPath)) {
84
+ return readFile(specPath).then((bytes) => createHash('sha256').update(bytes).digest('hex'), () => '');
85
+ }
86
+ const projectRoot = await resolveProjectRoot(projectId, projectPath);
87
+ if (!projectRoot) {
88
+ return '';
89
+ }
90
+ const absoluteSpecPath = resolvePath(projectRoot, specPath);
91
+ return readFile(absoluteSpecPath).then((bytes) => createHash('sha256').update(bytes).digest('hex'), () => '');
92
+ }
68
93
  async function acquireSubmissionLock(projectId, operationId) {
69
94
  const deadlineAt = Date.now() + SUBMISSION_LOCK_WAIT_MS;
70
95
  while (Date.now() < deadlineAt) {
@@ -99,7 +124,8 @@ export async function handlePackageHandoff(args) {
99
124
  };
100
125
  }
101
126
  const specVersion = spec.spec_version ?? '0.0.0';
102
- const operationId = deriveOperationId(projectId, specId, specVersion);
127
+ const specContentDigest = await digestSpecFile(projectId, args.projectPath, spec.specPath);
128
+ const operationId = deriveOperationId(projectId, specId, specVersion, specContentDigest);
103
129
  const submissionLock = await acquireSubmissionLock(projectId, operationId);
104
130
  try {
105
131
  const env_1 = { stack: [], error: void 0, hasError: false };
@@ -401,6 +401,9 @@ function safeWithTelemetry(toolName, handler) {
401
401
  const projectPath = safeArgs !== null && typeof safeArgs === 'object'
402
402
  ? safeArgs.projectPath
403
403
  : undefined;
404
+ const verboseRequested = safeArgs !== null &&
405
+ typeof safeArgs === 'object' &&
406
+ safeArgs.verbose === true;
404
407
  const startTime = Date.now();
405
408
  // SPEC-922: Parse context header and evaluate compact mode
406
409
  const contextUsed = parseContextHeader(extra && typeof extra === 'object' ? extra : undefined);
@@ -435,9 +438,12 @@ function safeWithTelemetry(toolName, handler) {
435
438
  isError: true,
436
439
  };
437
440
  // SPEC-455: Compress verbose JSON outputs to save LLM tokens
438
- const compressed = compressToolOutput(result);
441
+ const compressed = compressToolOutput(result, verboseRequested);
439
442
  // SPEC-922: Apply compact mode middleware
440
- const compacted = applyCompactMode(compressed, decision, {
443
+ const effectiveDecision = verboseRequested
444
+ ? { ...decision, mode: 'verbose' }
445
+ : decision;
446
+ const compacted = applyCompactMode(compressed, effectiveDecision, {
441
447
  projectPath,
442
448
  flow: toolName,
443
449
  });
@@ -1,8 +1,48 @@
1
1
  // tools/tool-registry.ts — Local registry that tracks registered MCP tools.
2
2
  // Replaces fragile access to SDK-internal `_registeredTools` property.
3
3
  // Uses a Proxy to transparently intercept registerTool/tool calls on McpServer.
4
+ import { z } from 'zod';
4
5
  /** Module-level store of tool name -> RegisteredTool (ToolSlot interface). */
5
6
  const registeredTools = new Map();
7
+ const VERBOSE_FLAG_DESCRIPTION = 'When true, returns the full untruncated tool output instead of the default compressed/truncated summary.';
8
+ function withVerboseFlag(config) {
9
+ if (config === null || typeof config !== 'object' || !('inputSchema' in config)) {
10
+ return config;
11
+ }
12
+ const cfg = config;
13
+ const inputSchema = cfg.inputSchema !== null && typeof cfg.inputSchema === 'object'
14
+ ? cfg.inputSchema
15
+ : {};
16
+ return {
17
+ ...cfg,
18
+ inputSchema: {
19
+ verbose: z.boolean().optional().describe(VERBOSE_FLAG_DESCRIPTION),
20
+ ...inputSchema,
21
+ },
22
+ };
23
+ }
24
+ function isZodLikeSchema(value) {
25
+ return (value !== null &&
26
+ typeof value === 'object' &&
27
+ typeof value.parse === 'function' &&
28
+ typeof value.safeParse === 'function');
29
+ }
30
+ function isRawShape(value) {
31
+ if (value === null || typeof value !== 'object' || Array.isArray(value)) {
32
+ return false;
33
+ }
34
+ const entries = Object.values(value);
35
+ return entries.length > 0 && entries.every(isZodLikeSchema);
36
+ }
37
+ function findLegacyRawShape(args) {
38
+ return [args[1], args[2]].find(isRawShape);
39
+ }
40
+ function injectVerboseIntoLegacyShape(args) {
41
+ const shape = findLegacyRawShape(args);
42
+ if (shape && !('verbose' in shape)) {
43
+ shape.verbose = z.boolean().optional().describe(VERBOSE_FLAG_DESCRIPTION);
44
+ }
45
+ }
6
46
  /**
7
47
  * Returns the map of all registered tools captured via `withToolTracking()`.
8
48
  * Each entry maps tool name -> { enable(), disable(), enabled }.
@@ -26,7 +66,14 @@ export function withToolTracking(server) {
26
66
  throw new Error(`Duplicate MCP tool registration: ${name}`);
27
67
  }
28
68
  const originalMethod = Reflect.get(target, prop, receiver);
29
- const registered = originalMethod.apply(target, args);
69
+ let finalArgs = args;
70
+ if (prop === 'registerTool' && args.length >= 2) {
71
+ finalArgs = [args[0], withVerboseFlag(args[1]), ...args.slice(2)];
72
+ }
73
+ else if (prop === 'tool') {
74
+ injectVerboseIntoLegacyShape(args);
75
+ }
76
+ const registered = originalMethod.apply(target, finalArgs);
30
77
  registeredTools.set(name, registered);
31
78
  return registered;
32
79
  };
@@ -4,7 +4,7 @@ import type { ValidateInput, ToolResult, ContractSpec, ContractValidation } from
4
4
  import type { ValidateWorkerProgress } from '../types/validate-worker.js';
5
5
  export { validateContractCompliance };
6
6
  export type { ContractSpec, ContractValidation };
7
- export declare function createValidationStageRunner(onProgress?: (progress: ValidateWorkerProgress) => void): <T>(phase: string, command: string, work: () => T | Promise<T>) => Promise<T>;
7
+ export declare function createValidationStageRunner(onProgress?: (progress: ValidateWorkerProgress) => void): <T>(phase: string, command: string, work: () => T | Promise<T>, deadlineMs?: number) => Promise<T>;
8
8
  /** Public MCP boundary: persist and acknowledge validation work without running it inline. */
9
9
  export declare function handleValidate(args: ValidateInput): Promise<ToolResult>;
10
10
  export declare function executeValidate(args: ValidateInput, server?: McpServer, onProgress?: (progress: ValidateWorkerProgress) => void): Promise<ToolResult>;
@@ -90,16 +90,19 @@ import { createPendingValidationSubmission } from '../engine/validation/durable-
90
90
  import { PROJECT_ID as CANONICAL_PROJECT_ID } from '../engine/validation/validation-receipt-codec.js';
91
91
  import { acquireLock, releaseLock } from '../engine/safety/cross-process-lock.js';
92
92
  import { getRuntimePolicy } from '../engine/runtime-policy.js';
93
+ import { PROCESS_TERMINATION_GRACE_MS, PROCESS_TREE_EXTINCTION_TIMEOUT_MS, PROCESS_CHILD_CLOSE_TIMEOUT_MS, } from '../engine/abortable-process-runner.js';
93
94
  import { resolveValidationWorktree, ValidationWorktreeError, } from '../engine/validation/validation-worktree.js';
94
95
  // Re-export for external use (SPEC-018)
95
96
  export { validateContractCompliance };
96
97
  const VALIDATION_GATE_TOTAL = 11;
97
98
  const GATE_DEADLINE_EXEMPT_PHASES = new Set(['lint', 'compliance']);
98
- async function runWithGateDeadline(phase, command, work) {
99
+ const BLAST_RADIUS_TERMINATION_MARGIN_MS = PROCESS_TERMINATION_GRACE_MS +
100
+ PROCESS_TREE_EXTINCTION_TIMEOUT_MS +
101
+ PROCESS_CHILD_CLOSE_TIMEOUT_MS;
102
+ async function runWithGateDeadline(phase, command, work, deadlineMs = getRuntimePolicy().validation.perGateTimeoutMs) {
99
103
  if (GATE_DEADLINE_EXEMPT_PHASES.has(phase)) {
100
104
  return work();
101
105
  }
102
- const deadlineMs = getRuntimePolicy().validation.perGateTimeoutMs;
103
106
  let timer;
104
107
  const deadline = new Promise((_resolve, reject) => {
105
108
  timer = setTimeout(() => {
@@ -180,7 +183,7 @@ function strictAuditsSuggestions(strictAuditsGate) {
180
183
  export function createValidationStageRunner(onProgress) {
181
184
  const startedAt = Date.now();
182
185
  let completedGates = 0;
183
- return async (phase, command, work) => {
186
+ return async (phase, command, work, deadlineMs) => {
184
187
  const emit = (status) => {
185
188
  onProgress?.({
186
189
  phase,
@@ -194,7 +197,7 @@ export function createValidationStageRunner(onProgress) {
194
197
  };
195
198
  emit('running');
196
199
  try {
197
- const result = await runWithGateDeadline(phase, command, work);
200
+ const result = await runWithGateDeadline(phase, command, work, deadlineMs);
198
201
  completedGates += 1;
199
202
  emit('passed');
200
203
  return result;
@@ -440,6 +443,8 @@ export async function executeValidate(args, server, onProgress) {
440
443
  const auditedFiles = [...new Set(result.qualityIssues.map((i) => i.file))];
441
444
  const codeState = await scanCodeForSpec(executionSpec, projectPath);
442
445
  const reliabilityGate = await runStage('reliability', 'scripts/check-reliability-policies.mjs --json', () => runReliabilityGate(projectPath, codeState.affectedFiles));
446
+ const blastRadiusTimeoutMs = getRuntimePolicy().validation.blastRadiusTimeoutMs;
447
+ const integrationTimeoutMs = computeIntegrationTimeoutMs();
443
448
  const blastRadiusGate = await runStage('blast-radius', "vitest related over the spec's affected source files", async () => {
444
449
  const absoluteSpecPath = isAbsolute(executionSpec.specPath)
445
450
  ? executionSpec.specPath
@@ -449,11 +454,11 @@ export async function executeValidate(args, server, onProgress) {
449
454
  ...new Set([...collectDeclaredSpecFiles(raw), ...codeState.affectedFiles]),
450
455
  ];
451
456
  return runBlastRadiusGate(projectPath, candidateFiles, {
452
- timeoutMs: getRuntimePolicy().validation.blastRadiusTimeoutMs,
453
- integrationTimeoutMs: computeIntegrationTimeoutMs(),
457
+ timeoutMs: blastRadiusTimeoutMs,
458
+ integrationTimeoutMs,
454
459
  signal: getToolExecutionSignal(),
455
460
  });
456
- });
461
+ }, blastRadiusTimeoutMs + integrationTimeoutMs + BLAST_RADIUS_TERMINATION_MARGIN_MS);
457
462
  const { conventionViolations, regressionDetected } = await runStage('conventions', 'validate project conventions', () => scanProjectConventions(projectId, projectPath));
458
463
  const lintCheck = await runStage('lint', knowledge.lintCommand ?? 'pnpm lint', () => runLintCheck(projectPath, knowledge.lintCommand ?? null, {
459
464
  projectId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planu/cli",
3
- "version": "5.7.16",
3
+ "version": "5.7.18",
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",
@@ -41,7 +41,7 @@
41
41
  "lint:fix": "eslint src/ tests/ --fix --max-warnings 0",
42
42
  "format": "prettier --write 'src/**/*.ts' 'tests/**/*.test.ts'",
43
43
  "format:check": "prettier --check --cache --cache-strategy content 'src/**/*.ts' 'tests/**/*.test.ts'",
44
- "typecheck": "tsc --noEmit",
44
+ "typecheck": "tsc --noEmit --incremental --tsBuildInfoFile node_modules/.cache/planu-typecheck.tsbuildinfo",
45
45
  "typecheck:compat": "tsc6 --noEmit",
46
46
  "verify:typescript-migration": "node scripts/verify-typescript-migration.mjs",
47
47
  "test": "vitest run --maxWorkers=6",
package/planu-plugin.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "dev.planu.cli",
3
3
  "displayName": "Planu — Spec Driven Development",
4
4
  "description": "Manage software specs, estimations, and autonomous SDD workflows. Language-agnostic MCP server for Claude Code.",
5
- "version": "5.7.16",
5
+ "version": "5.7.18",
6
6
  "icon": "assets/plugin/icon.svg",
7
7
  "command": ["npx", "@planu/cli@latest"],
8
8
  "packageName": "@planu/cli",