Files
msd-core/sdk/src/query/plan-scan.test.ts
Tom Boucher 26dcdb1ad0 Refactor SDK-first architecture seams (#3316)
* refactor: tighten sdk-first architecture seams

Refs #3312

* refactor: finish state document seam cleanup

Refs #3312

* test: harden minimal install cleanup assertion

* ci: support sdk-scoped package lock

* fix(3316): restore root package-lock.json and align changeset pr ref

Reverts dec57a83 ("ci: support sdk-scoped package lock") and restores
the root package-lock.json that c249d34d deleted. The deletion was the
wrong direction:

- The root package.json declares its own runtime and dev deps
  (@anthropic-ai/claude-agent-sdk, ws, c8). Without a root lockfile,
  `npm install --no-package-lock` resolves whatever satisfies semver at
  install time — CI today and CI in six months can install different
  transitive trees, defeating reproducibility.
- The lockfile has been part of every release on this repo (long
  history on main); removing it loses the npm audit / Dependabot
  target without compensating benefit.
- The CI workaround pattern (cache-dependency-path: sdk/package-lock.json
  + `npm install --no-package-lock`) papered over the symptom rather
  than fix the cause.

Also fix the changeset pr: from 3312 (issue) to 3316 (PR). CONTEXT.md
flags this exact failure mode as a recurring CodeRabbit finding.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix: address coderabbit review findings

* fix: close remaining coderabbit threads

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 14:21:42 -04:00

36 lines
1.4 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { mkdtemp, mkdir, rm, writeFile } from 'node:fs/promises';
import { join } from 'node:path';
import { tmpdir } from 'node:os';
import { scanPhasePlans } from './plan-scan.js';
describe('scanPhasePlans', () => {
it('counts flat and nested plan files while excluding derivative files', async () => {
const tmpDir = await mkdtemp(join(tmpdir(), 'gsd-plan-scan-'));
try {
const phaseDir = join(tmpDir, 'phases', '1');
const nestedDir = join(phaseDir, 'plans');
await mkdir(nestedDir, { recursive: true });
await writeFile(join(phaseDir, '01-01-PLAN.md'), '# Plan');
await writeFile(join(phaseDir, '01-01-SUMMARY.md'), '# Summary');
await writeFile(join(phaseDir, '01-01-PLAN-OUTLINE.md'), '# Outline');
await writeFile(join(nestedDir, 'PLAN-02-next.md'), '# Plan');
await writeFile(join(nestedDir, 'SUMMARY-02-next.md'), '# Summary');
await writeFile(join(nestedDir, 'PLAN-03-draft.pre-bounce.md'), '# Draft');
await writeFile(join(nestedDir, 'PLAN-04-OUTLINE.md'), '# Outline');
expect(scanPhasePlans(phaseDir)).toMatchObject({
planCount: 2,
summaryCount: 2,
completed: true,
hasNestedPlans: true,
planFiles: ['01-01-PLAN.md', 'PLAN-02-next.md'],
summaryFiles: ['01-01-SUMMARY.md', 'SUMMARY-02-next.md'],
});
} finally {
await rm(tmpDir, { recursive: true, force: true });
}
});
});