@planu/cli 4.10.0 → 4.10.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,15 @@
1
+ ## [4.10.2] - 2026-07-02
2
+
3
+ ### Bug Fixes
4
+ - fix(SPEC-1105): preserve legacy spec ids during init migration
5
+
6
+
7
+ ## [4.10.1] - 2026-07-01
8
+
9
+ ### Bug Fixes
10
+ - fix: prevent generated spec artifacts and refresh graph status
11
+
12
+
1
13
  ## [4.10.0] - 2026-07-01
2
14
 
3
15
  ### Features
@@ -145,11 +145,26 @@ export async function getProjectGraphFreshnessHint(args) {
145
145
  if (!policy.enabled) {
146
146
  return undefined;
147
147
  }
148
- const freshness = await getProjectGraphFreshness({
148
+ let freshness = await getProjectGraphFreshness({
149
149
  projectId,
150
150
  projectPath: args.projectPath,
151
151
  policy,
152
152
  });
153
+ if (!freshness.exists ||
154
+ freshness.reason === 'source_changed' ||
155
+ freshness.reason === 'corrupt') {
156
+ try {
157
+ await buildProjectKnowledgeGraph({ projectId, projectPath: args.projectPath, policy });
158
+ freshness = await getProjectGraphFreshness({
159
+ projectId,
160
+ projectPath: args.projectPath,
161
+ policy,
162
+ });
163
+ }
164
+ catch {
165
+ // status must stay non-blocking; fall back to the stale hint below.
166
+ }
167
+ }
153
168
  if (!freshness.stale) {
154
169
  return undefined;
155
170
  }
@@ -2,7 +2,7 @@
2
2
  // Detects old-format specs, extracts useful info, generates lean files, deletes obsolete files.
3
3
  import { readFile, readdir, stat } from 'node:fs/promises';
4
4
  import { atomicWriteFile } from '../safety/atomic-write-file.js';
5
- import { join } from 'node:path';
5
+ import { basename, join } from 'node:path';
6
6
  import { safeUnlink } from './git-aware-fs.js';
7
7
  import { parseFrontmatterLocal } from './frontmatter-parser.js';
8
8
  import { generateLeanSpecContent } from '../spec-format/lean-spec-generator.js';
@@ -324,6 +324,27 @@ function buildSpecFromMetadata(metadata, id, title, specStatus, estimation, spec
324
324
  impactAnalysis: null,
325
325
  };
326
326
  }
327
+ function normalizeSpecId(value) {
328
+ if (typeof value !== 'string') {
329
+ return null;
330
+ }
331
+ const trimmed = value.trim();
332
+ return /^SPEC-\d+$/.test(trimmed) ? trimmed : null;
333
+ }
334
+ function inferSpecIdFromDirectory(specDir) {
335
+ const match = /^(SPEC-\d+)(?:$|[-_])/.exec(basename(specDir));
336
+ return match?.[1] ?? null;
337
+ }
338
+ function inferSpecIdFromHeading(content) {
339
+ const match = /^#\s+(SPEC-\d+)(?:\b|[:\s—–-])/m.exec(content);
340
+ return match?.[1] ?? null;
341
+ }
342
+ function resolveSpecId(metadata, specDir, specContent) {
343
+ return (normalizeSpecId(metadata.id) ??
344
+ normalizeSpecId(metadata.spec_id) ??
345
+ inferSpecIdFromDirectory(specDir) ??
346
+ inferSpecIdFromHeading(specContent));
347
+ }
327
348
  /** Write a verified backup of a file before overwriting. Returns backup path. Throws on failure. */
328
349
  async function writeVerifiedBackup(filePath) {
329
350
  const content = await readFile(filePath, 'utf-8');
@@ -354,7 +375,10 @@ export async function migrateSpecToLean(specDir, projectPath) {
354
375
  }
355
376
  // Parse frontmatter
356
377
  const { metadata } = parseFrontmatterLocal(specContent);
357
- const id = typeof metadata.id === 'string' ? metadata.id : 'SPEC-000';
378
+ const id = resolveSpecId(metadata, specDir, specContent);
379
+ if (!id) {
380
+ return 'missing valid spec id';
381
+ }
358
382
  const title = typeof metadata.title === 'string' ? metadata.title : 'Untitled';
359
383
  const status = typeof metadata.status === 'string' ? metadata.status : 'draft';
360
384
  // Read old technical.md first (needed for estimation extraction)
@@ -0,0 +1,2 @@
1
+ export declare function resolveTddStubArtifactPath(specId: string, projectPath: string): string;
2
+ //# sourceMappingURL=stub-artifact-path.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { join } from 'node:path';
2
+ import { hashProjectPath, projectDataDir } from '../../storage/base-store.js';
3
+ export function resolveTddStubArtifactPath(specId, projectPath) {
4
+ const projectId = hashProjectPath(projectPath);
5
+ return join(projectDataDir(projectId), 'handoffs', specId, 'test-stubs.ts');
6
+ }
7
+ //# sourceMappingURL=stub-artifact-path.js.map
@@ -1,6 +1,7 @@
1
1
  // SPEC-452 — Generates TDD test stubs from spec acceptance criteria
2
2
  import { readFile, writeFile, mkdir } from 'node:fs/promises';
3
- import { join, dirname } from 'node:path';
3
+ import { dirname, join } from 'node:path';
4
+ import { resolveTddStubArtifactPath } from './stub-artifact-path.js';
4
5
  const SECTION_RE = /^###\s+(.+)$/;
5
6
  function sanitizeTestName(text) {
6
7
  return text.replace(/[`'"]/g, '').trim();
@@ -73,7 +74,7 @@ export async function generateTestStubs(specId, projectPath) {
73
74
  return { specId, stubs: [], fileContent: '', outputPath: '' };
74
75
  }
75
76
  const fileContent = buildStubFileContent(specId, stubs);
76
- const outputPath = join(dirname(specFile), 'test-stubs.ts');
77
+ const outputPath = resolveTddStubArtifactPath(specId, projectPath);
77
78
  await mkdir(dirname(outputPath), { recursive: true });
78
79
  await writeFile(outputPath, fileContent, 'utf-8');
79
80
  return { specId, stubs, fileContent, outputPath };
@@ -1,18 +1,24 @@
1
1
  // SPEC-452 — TDD gates for status transitions
2
2
  import { readFile } from 'node:fs/promises';
3
3
  import { join } from 'node:path';
4
+ import { resolveTddStubArtifactPath } from './stub-artifact-path.js';
4
5
  const TDD_STUB_MARKER = "expect.fail('TDD stub";
6
+ async function readExternalStubContent(specId, projectPath) {
7
+ try {
8
+ return await readFile(resolveTddStubArtifactPath(specId, projectPath), 'utf-8');
9
+ }
10
+ catch (err) {
11
+ if (err instanceof Error && 'code' in err && err.code === 'ENOENT') {
12
+ return null;
13
+ }
14
+ throw err;
15
+ }
16
+ }
5
17
  export async function checkTddReadiness(specId, projectPath) {
6
- const specDir = join(projectPath, 'planu', 'specs');
7
18
  const { glob } = await import('glob');
8
- // Check for test-stubs.ts in spec dir
9
- const stubMatches = await glob(`${specDir}/${specId}-*/test-stubs.ts`);
10
- const hasStubs = stubMatches.length > 0;
11
- let stubCount = 0;
12
- if (hasStubs && stubMatches[0]) {
13
- const content = await readFile(stubMatches[0], 'utf-8');
14
- stubCount = (content.match(/it\(/g) ?? []).length;
15
- }
19
+ const stubContent = await readExternalStubContent(specId, projectPath);
20
+ const hasStubs = stubContent !== null;
21
+ const stubCount = stubContent === null ? 0 : (stubContent.match(/it\(/g) ?? []).length;
16
22
  // Check for test files referencing this spec
17
23
  const testsDir = join(projectPath, 'tests');
18
24
  const testFiles = await glob(`${testsDir}/**/*.test.ts`);
@@ -37,13 +43,10 @@ export async function checkTddReadiness(specId, projectPath) {
37
43
  return { hasStubs, stubCount, hasTestFiles, recommendation };
38
44
  }
39
45
  export async function checkTddCompletion(specId, projectPath) {
40
- const specDir = join(projectPath, 'planu', 'specs');
41
- const { glob } = await import('glob');
42
- const stubMatches = await glob(`${specDir}/${specId}-*/test-stubs.ts`);
43
- if (stubMatches.length === 0 || !stubMatches[0]) {
46
+ const content = await readExternalStubContent(specId, projectPath);
47
+ if (content === null) {
44
48
  return { unresolvedStubs: 0, totalStubs: 0, resolvedPercentage: 100, pendingCriteria: [] };
45
49
  }
46
- const content = await readFile(stubMatches[0], 'utf-8');
47
50
  const allStubs = content.match(/it\(/g) ?? [];
48
51
  const unresolvedMatches = content.match(new RegExp(TDD_STUB_MARKER.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g')) ?? [];
49
52
  const totalStubs = allStubs.length;
@@ -3,7 +3,7 @@
3
3
  // Phase logic lives in src/engine/execution-plan/phases.ts
4
4
  // Mobile distribution lives in src/engine/execution-plan/mobile-distribution.ts
5
5
  // Utilities live in src/engine/execution-plan/plan-utils.ts
6
- import { writeFile } from 'node:fs/promises';
6
+ import { mkdir, writeFile } from 'node:fs/promises';
7
7
  import { dirname, join } from 'node:path';
8
8
  import { specStore, knowledgeStore, patternStore } from '../storage/index.js';
9
9
  import { t, ti } from '../i18n/index.js';
@@ -12,6 +12,7 @@ import { generateSetupPhase, generateDataLayerPhase, generateBusinessLogicPhase,
12
12
  import { generateMobileDistributionPhase, isMobileDistributionSpec, } from '../engine/execution-plan/mobile-distribution.js';
13
13
  import { isDesktopReleaseSpec, generateDesktopDistributionPhase, } from '../engine/execution-plan/desktop-distribution.js';
14
14
  import { determineCriticalPath, findParallelizable, readSpecContent, } from '../engine/execution-plan/plan-utils.js';
15
+ import { projectDataDir } from '../storage/base-store.js';
15
16
  export async function handleGenerateExecutionPlan(args) {
16
17
  const { specId, projectId } = args;
17
18
  const spec = await specStore.getSpec(projectId, specId);
@@ -38,9 +39,9 @@ export async function handleGenerateExecutionPlan(args) {
38
39
  const plan = { phases, totalSteps, criticalPath, parallelizable };
39
40
  let planPath;
40
41
  try {
41
- const planDir = dirname(spec.specPath);
42
- planPath = join(planDir, 'PLAN.md');
42
+ planPath = join(projectDataDir(projectId), 'handoffs', specId, 'execution-plan.md');
43
43
  const planContent = generatePlanMarkdown(plan, spec);
44
+ await mkdir(dirname(planPath), { recursive: true });
44
45
  await writeFile(planPath, planContent, 'utf-8');
45
46
  await specStore.updateSpec(projectId, specId, { planPath });
46
47
  /* v8 ignore next 3 -- defensive: filesystem write failure during plan generation */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planu/cli",
3
- "version": "4.10.0",
3
+ "version": "4.10.2",
4
4
  "description": "Planu — MCP Server for Spec Driven Development with native Rust acceleration for hot paths. Cross-platform (Linux/macOS/Windows, x64/arm64, glibc/musl).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -34,14 +34,14 @@
34
34
  "packageName": "@planu/core"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@planu/core-darwin-arm64": "4.10.0",
38
- "@planu/core-darwin-x64": "4.10.0",
39
- "@planu/core-linux-arm64-gnu": "4.10.0",
40
- "@planu/core-linux-arm64-musl": "4.10.0",
41
- "@planu/core-linux-x64-gnu": "4.10.0",
42
- "@planu/core-linux-x64-musl": "4.10.0",
43
- "@planu/core-win32-arm64-msvc": "4.10.0",
44
- "@planu/core-win32-x64-msvc": "4.10.0"
37
+ "@planu/core-darwin-arm64": "4.10.2",
38
+ "@planu/core-darwin-x64": "4.10.2",
39
+ "@planu/core-linux-arm64-gnu": "4.10.2",
40
+ "@planu/core-linux-arm64-musl": "4.10.2",
41
+ "@planu/core-linux-x64-gnu": "4.10.2",
42
+ "@planu/core-linux-x64-musl": "4.10.2",
43
+ "@planu/core-win32-arm64-msvc": "4.10.2",
44
+ "@planu/core-win32-x64-msvc": "4.10.2"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=24.0.0"
@@ -129,7 +129,7 @@
129
129
  ],
130
130
  "license": "SEE LICENSE IN LICENSE",
131
131
  "dependencies": {
132
- "@anthropic-ai/sdk": "^0.109.0",
132
+ "@anthropic-ai/sdk": "^0.110.0",
133
133
  "@modelcontextprotocol/sdk": "^1.29.0",
134
134
  "glob": "^13.0.6",
135
135
  "yaml": "^2.9.0",
@@ -177,7 +177,7 @@
177
177
  "@semantic-release/changelog": "^6.0.3",
178
178
  "@semantic-release/commit-analyzer": "^13.0.1",
179
179
  "@semantic-release/git": "^10.0.1",
180
- "@semantic-release/github": "^12.0.8",
180
+ "@semantic-release/github": "^12.0.9",
181
181
  "@semantic-release/npm": "^13.1.5",
182
182
  "@semantic-release/release-notes-generator": "^14.1.1",
183
183
  "@stryker-mutator/core": "^9.6.1",
@@ -194,7 +194,7 @@
194
194
  "happy-dom": "^20.10.6",
195
195
  "husky": "^9.1.7",
196
196
  "javascript-obfuscator": "^5.4.3",
197
- "knip": "^6.23.0",
197
+ "knip": "^6.24.0",
198
198
  "lint-staged": "^17.0.8",
199
199
  "madge": "^8.0.0",
200
200
  "prettier": "^3.9.4",
@@ -204,7 +204,7 @@
204
204
  "type-coverage": "^2.29.7",
205
205
  "typescript": "^6.0.3",
206
206
  "typescript-eslint": "^8.62.1",
207
- "vite": "^8.1.2",
207
+ "vite": "^8.1.3",
208
208
  "vitest": "^4.1.9",
209
209
  "vue": "^3.5.39"
210
210
  }
package/planu-native.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dev.planu.native",
3
3
  "displayName": "Planu Native Lightweight Surface",
4
- "version": "4.10.0",
4
+ "version": "4.10.2",
5
5
  "packageName": "@planu/cli",
6
6
  "modes": {
7
7
  "lightweight": {
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": "4.10.0",
5
+ "version": "4.10.2",
6
6
  "icon": "assets/plugin/icon.svg",
7
7
  "command": [
8
8
  "npx",