@refrakt-md/plan 0.9.9 → 0.10.1

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.
@@ -2,13 +2,13 @@ import { existsSync, mkdirSync, writeFileSync, readFileSync, appendFileSync, chm
2
2
  import { join, dirname } from 'path';
3
3
  import { fileURLToPath } from 'url';
4
4
  import { runCreate } from './create.js';
5
- import { STATUS_PAGES, renderStatusPage, renderTypeIndexPage } from './templates.js';
5
+ import { idExists } from './next-id.js';
6
6
  import { findInstallRoot, detectPackageManager, installCommand } from './project-setup.js';
7
7
  export const EXIT_SUCCESS = 0;
8
8
  export const EXIT_ALREADY_EXISTS = 1;
9
9
  /**
10
- * Tool-specific agent instruction files. These get a short pointer to AGENTS.md.
11
- * AGENTS.md itself is the canonical file — full workflow content lives there.
10
+ * Tool-specific agent instruction files that get a brief plan summary
11
+ * appended, pointing to plan/INSTRUCTIONS.md for the full reference.
12
12
  */
13
13
  export const AGENT_FILES = {
14
14
  claude: 'CLAUDE.md',
@@ -16,94 +16,18 @@ export const AGENT_FILES = {
16
16
  copilot: '.github/copilot-instructions.md',
17
17
  windsurf: '.windsurfrules',
18
18
  cline: '.clinerules',
19
+ agents: 'AGENTS.md',
19
20
  };
20
- /** Absolute-ish path to the canonical agent instructions file. */
21
- export const AGENTS_FILE = 'AGENTS.md';
22
- /** Single pointer line written into tool-specific instruction files. */
23
- const POINTER_LINE = `\n\nSee [AGENTS.md](./AGENTS.md) for agent instructions, including the plan workflow.\n`;
24
- /** Marker used to detect that a tool-specific file already contains our pointer. */
25
- const POINTER_MARKER = 'See [AGENTS.md]';
26
- /** Legacy marker (pre-AGENTS.md migration) — still recognised to avoid duplicate appends. */
27
- const LEGACY_POINTER_MARKERS = ['plan/INSTRUCTIONS.md', 'refrakt plan next'];
28
- /** Full agent-facing workflow written to AGENTS.md. */
29
- const AGENTS_MD_CONTENT = `# Agent Instructions
30
-
31
- This file is the canonical reference for AI coding agents working in this repository. It is read by Claude Code, Cursor, Aider, Codex, Continue, Zed, and other tools that follow the AGENTS.md convention. Tool-specific files (\`CLAUDE.md\`, \`.cursorrules\`, etc.) should be short pointers back here.
32
-
33
- ## Before you start
34
-
35
- Run \`npm run plan -- status\` (or \`./plan status\` if the wrapper script is present). If it fails with "command not found" or a module resolution error, run your package manager's install command (\`npm install\`, \`pnpm install\`, \`yarn\`, or \`bun install\`) and retry.
36
-
37
- **Never edit files under \`plan/\` by hand.** Always use \`refrakt plan\` commands — they keep IDs, statuses, and cross-references consistent. Manual edits will be silently overwritten by later commands.
38
-
39
- ## Plan — Workflow Guide
40
-
41
- Project planning content lives in \`plan/\` as Markdoc files using the \`@refrakt-md/plan\` runes package.
42
-
43
- ### Directory Layout
44
-
45
- \`\`\`
46
- plan/
47
- specs/ — Specifications (what to build)
48
- work/ — Work items and bugs (how to build it)
49
- decisions/ — Architecture decision records (why it's built this way)
50
- milestones/ — Named release targets with scope and goals
51
- \`\`\`
52
-
53
- ### Workflow
54
-
55
- 1. Find next work item: \`refrakt plan next\`
56
- 2. Start working: \`refrakt plan update <id> --status in-progress\`
57
- 3. Read referenced specs and decisions before implementing
58
- 4. Check off criteria: \`refrakt plan update <id> --check "criterion text"\`
59
- 5. Mark complete with resolution: \`refrakt plan update <id> --status done --resolve "summary of what was done"\`
60
- 6. Check project status: \`refrakt plan status\`
61
-
62
- When marking a work item done, always provide a \`--resolve\` summary unless the change is trivial. This captures implementation context (files changed, decisions made, branch/PR) for future reference.
63
-
64
- ### ID Conventions
65
-
66
- | Type | Prefix | Example |
67
- |------|--------|---------|
68
- | Spec | \`SPEC-\` | \`SPEC-023\` |
69
- | Work | \`WORK-\` | \`WORK-051\` |
70
- | Decision | \`ADR-\` | \`ADR-005\` |
71
- | Bug | \`BUG-\` | \`BUG-001\` |
72
- | Milestone | \`v\`+semver | \`v1.0.0\` |
73
-
74
- IDs are auto-assigned when you omit \`--id\` from \`refrakt plan create\`.
75
-
76
- ### Valid Statuses
77
-
78
- - **spec**: \`draft\` → \`review\` → \`accepted\` → \`superseded\` | \`deprecated\`
79
- - **work**: \`draft\` → \`ready\` → \`in-progress\` → \`review\` → \`done\` (also: \`blocked\`)
80
- - **bug**: \`reported\` → \`confirmed\` → \`in-progress\` → \`fixed\` (also: \`wontfix\`, \`duplicate\`)
81
- - **decision**: \`proposed\` → \`accepted\` → \`superseded\` | \`deprecated\`
82
- - **milestone**: \`planning\` → \`active\` → \`complete\`
83
-
84
- ### Creating Items
85
-
86
- \`\`\`bash
87
- refrakt plan create work --title "Description"
88
- refrakt plan create bug --title "Description"
89
- refrakt plan create spec --title "Description"
90
- refrakt plan create decision --title "Description"
91
- refrakt plan create milestone --id v1.0 --title "Description"
92
- \`\`\`
93
-
94
- ### When to Create Each Type
95
-
96
- - **Spec**: A new feature idea, design proposal, or system description. Source of truth for *what* to build.
97
- - **Work item**: A discrete, implementable piece of work with acceptance criteria.
98
- - **Bug**: A defect report. Use instead of a work item when something is broken rather than missing.
99
- - **Decision**: An architectural choice that needs to be recorded for future reference.
100
-
101
- ### JSON Output
102
-
103
- All commands support \`--format json\` for machine-readable output. This is useful for scripting, CI pipelines, and programmatic integration.
21
+ /**
22
+ * Brief plan summary appended to agent instruction files.
23
+ * Points to plan/INSTRUCTIONS.md for the full reference.
24
+ */
25
+ const PLAN_SUMMARY = `\n\n## Plan
104
26
 
105
- See \`plan/INSTRUCTIONS.md\` for an in-tree copy of this workflow, kept alongside the content for convenience.
27
+ Project planning lives in \`plan/\` as Markdoc files. Use \`refrakt plan\` commands to manage items never edit plan files by hand. Run \`refrakt plan next\` to find work. See [plan/INSTRUCTIONS.md](plan/INSTRUCTIONS.md) for the full workflow reference.
106
28
  `;
29
+ /** Markers used to detect that a file already contains our plan section. */
30
+ const PLAN_MARKERS = ['plan/INSTRUCTIONS.md', 'refrakt plan next', 'See [AGENTS.md]'];
107
31
  /** Full tool-agnostic workflow guide written to plan/INSTRUCTIONS.md (kept for reference inside plan/). */
108
32
  const INSTRUCTIONS_CONTENT = `# Plan — Workflow Guide
109
33
 
@@ -114,7 +38,8 @@ This directory contains project planning content using the \`@refrakt-md/plan\`
114
38
  \`\`\`
115
39
  plan/
116
40
  specs/ — Specifications (what to build)
117
- work/ — Work items and bugs (how to build it)
41
+ work/ — Work items (how to build it)
42
+ bugs/ — Bug reports (what is broken)
118
43
  decisions/ — Architecture decision records (why it's built this way)
119
44
  milestones/ — Named release targets with scope and goals
120
45
  \`\`\`
@@ -167,32 +92,77 @@ refrakt plan create milestone --id v1.0 --title "Description"
167
92
  - **Bug**: A defect report. Use instead of a work item when something is broken rather than missing.
168
93
  - **Decision**: An architectural choice that needs to be recorded for future reference.
169
94
 
95
+ ## Runes in Prose
96
+
97
+ Plan content is text-first, but a curated set of runes may be used inside entity bodies (specs, work items, bugs, decisions, milestones) when they genuinely clarify the prose.
98
+
99
+ - **\`sandbox\`** — embed a small runnable component or layout preview
100
+ - **\`diagram\`** — render a structured diagram (architecture, sequence, state)
101
+ - **\`chart\`** — render a chart from inline data
102
+ - **\`datatable\`** — render a structured data table with search/filter/sort
103
+ - **\`budget\`** — structured monetary budget block (costs, spend allocations)
104
+
105
+ Run \`refrakt reference <name>\` to get the exact Markdoc syntax for any rune (e.g. \`refrakt reference sandbox\`).
106
+
107
+ Prefer prose over runes by default — reach for a rune only when it is meaningfully clearer than plain text or a Markdown table.
108
+
170
109
  ## JSON Output
171
110
 
172
111
  All commands support \`--format json\` for machine-readable output. This is useful for scripting, CI pipelines, and programmatic integration.
173
112
  `;
174
113
  /**
175
114
  * Shell command written into .claude/settings.json SessionStart hook.
176
- * Detects the package manager at execution time from lockfiles, so users can
177
- * switch package managers without re-running init.
115
+ *
116
+ * Detection order mirrors detectPackageManager in project-setup.ts:
117
+ * 1. Corepack `packageManager` field in package.json (authoritative)
118
+ * 2. The most recently modified lockfile (newest mtime wins — handles stale
119
+ * pnpm-lock.yaml / yarn.lock leftovers in an npm-workspaces repo)
120
+ * 3. Default to npm
178
121
  */
179
- const HOOK_COMMAND = `[ -x node_modules/.bin/refrakt ] || { if [ -f bun.lockb ] || [ -f bun.lock ]; then bun install; elif [ -f pnpm-lock.yaml ]; then pnpm install; elif [ -f yarn.lock ]; then yarn install; else npm install; fi; }`;
122
+ const HOOK_COMMAND = `[ -x node_modules/.bin/refrakt ] || { pm=""; if [ -f package.json ]; then pm=$(sed -n 's/.*"packageManager"[[:space:]]*:[[:space:]]*"\\([a-z]*\\)@.*/\\1/p' package.json | head -n1); fi; case "$pm" in npm|pnpm|yarn|bun) ;; *) pm="" ;; esac; if [ -z "$pm" ]; then newest=""; for f in bun.lockb bun.lock pnpm-lock.yaml yarn.lock package-lock.json; do [ -f "$f" ] || continue; if [ -z "$newest" ] || [ "$f" -nt "$newest" ]; then newest=$f; fi; done; case "$newest" in bun.lock*) pm=bun ;; pnpm-lock.yaml) pm=pnpm ;; yarn.lock) pm=yarn ;; *) pm=npm ;; esac; fi; case "$pm" in bun) bun install ;; pnpm) pnpm install ;; yarn) yarn install ;; *) npm install ;; esac; }`;
180
123
  /**
181
- * Wrapper script body. Works under any POSIX shell; installs deps on first
182
- * run using the detected package manager, then defers to `npx refrakt plan`.
124
+ * Wrapper script body. Works under any POSIX shell with `-nt` support
125
+ * (dash, bash, ksh, zsh, busybox sh). Installs deps on first run using the
126
+ * detected package manager, then defers to `npx refrakt plan`.
183
127
  */
184
128
  const WRAPPER_SCRIPT = `#!/usr/bin/env sh
185
129
  set -e
186
- if [ ! -x node_modules/.bin/refrakt ]; then
187
- if [ -f bun.lockb ] || [ -f bun.lock ]; then
188
- bun install
189
- elif [ -f pnpm-lock.yaml ]; then
190
- pnpm install
191
- elif [ -f yarn.lock ]; then
192
- yarn install
193
- else
194
- npm install
130
+
131
+ # Detection order:
132
+ # 1. Corepack packageManager field in package.json (authoritative)
133
+ # 2. Newest lockfile by mtime (so a stale pnpm-lock.yaml next to a fresh
134
+ # package-lock.json correctly resolves to npm)
135
+ # 3. Default to npm
136
+ detect_pm() {
137
+ pm=""
138
+ if [ -f package.json ]; then
139
+ pm=$(sed -n 's/.*"packageManager"[[:space:]]*:[[:space:]]*"\\([a-z]*\\)@.*/\\1/p' package.json | head -n1)
195
140
  fi
141
+ case "$pm" in
142
+ npm|pnpm|yarn|bun) echo "$pm"; return ;;
143
+ esac
144
+ newest=""
145
+ for f in bun.lockb bun.lock pnpm-lock.yaml yarn.lock package-lock.json; do
146
+ [ -f "$f" ] || continue
147
+ if [ -z "$newest" ] || [ "$f" -nt "$newest" ]; then
148
+ newest=$f
149
+ fi
150
+ done
151
+ case "$newest" in
152
+ bun.lock*) echo bun ;;
153
+ pnpm-lock.yaml) echo pnpm ;;
154
+ yarn.lock) echo yarn ;;
155
+ *) echo npm ;;
156
+ esac
157
+ }
158
+
159
+ if [ ! -x node_modules/.bin/refrakt ]; then
160
+ case "$(detect_pm)" in
161
+ bun) bun install ;;
162
+ pnpm) pnpm install ;;
163
+ yarn) yarn install ;;
164
+ *) npm install ;;
165
+ esac
196
166
  fi
197
167
  exec npx refrakt plan "$@"
198
168
  `;
@@ -231,53 +201,29 @@ function detectAgentFiles(projectRoot) {
231
201
  }
232
202
  return found;
233
203
  }
234
- function hasPointerMarker(content) {
235
- if (content.includes(POINTER_MARKER))
236
- return true;
237
- return LEGACY_POINTER_MARKERS.some(m => content.includes(m));
204
+ function hasPlanMarker(content) {
205
+ return PLAN_MARKERS.some(m => content.includes(m));
238
206
  }
239
207
  /**
240
- * Append the plan pointer section to a tool-specific agent instruction file.
208
+ * Append the brief plan summary to an agent instruction file.
241
209
  * Creates the file (and parent directories) if it doesn't exist.
242
210
  * Returns true if the file was updated.
243
211
  */
244
- function appendPointer(projectRoot, relPath) {
212
+ function appendPlanSummary(projectRoot, relPath) {
245
213
  const filePath = join(projectRoot, relPath);
246
214
  if (existsSync(filePath)) {
247
215
  const content = readFileSync(filePath, 'utf-8');
248
- if (hasPointerMarker(content)) {
216
+ if (hasPlanMarker(content)) {
249
217
  return false;
250
218
  }
251
- appendFileSync(filePath, POINTER_LINE);
219
+ appendFileSync(filePath, PLAN_SUMMARY);
252
220
  return true;
253
221
  }
254
222
  const dir = dirname(filePath);
255
223
  if (!existsSync(dir)) {
256
224
  mkdirSync(dir, { recursive: true });
257
225
  }
258
- writeFileSync(filePath, POINTER_LINE.trimStart());
259
- return true;
260
- }
261
- /**
262
- * Write AGENTS.md if it doesn't exist; if it exists but lacks our plan
263
- * workflow section, append it. Returns true if the file was created or
264
- * modified.
265
- */
266
- function writeAgentsFile(projectRoot) {
267
- const filePath = join(projectRoot, AGENTS_FILE);
268
- if (!existsSync(filePath)) {
269
- writeFileSync(filePath, AGENTS_MD_CONTENT);
270
- return true;
271
- }
272
- const content = readFileSync(filePath, 'utf-8');
273
- if (content.includes('## Plan — Workflow Guide') || content.includes('refrakt plan next')) {
274
- return false;
275
- }
276
- // Append plan section to existing AGENTS.md (preserve user content above).
277
- const planSectionStart = AGENTS_MD_CONTENT.indexOf('## Plan — Workflow Guide');
278
- const planSection = planSectionStart >= 0 ? AGENTS_MD_CONTENT.slice(planSectionStart) : AGENTS_MD_CONTENT;
279
- const separator = content.endsWith('\n') ? '\n' : '\n\n';
280
- appendFileSync(filePath, separator + planSection);
226
+ writeFileSync(filePath, PLAN_SUMMARY.trimStart());
281
227
  return true;
282
228
  }
283
229
  /**
@@ -392,7 +338,7 @@ export function runInit(options) {
392
338
  })();
393
339
  const created = [];
394
340
  // --- 1. plan/ scaffolding ------------------------------------------------
395
- const dirs = ['work', 'specs', 'decisions', 'milestones'];
341
+ const dirs = ['work', 'bugs', 'specs', 'decisions', 'milestones'];
396
342
  for (const sub of dirs) {
397
343
  const path = join(dir, sub);
398
344
  if (!existsSync(path)) {
@@ -401,88 +347,42 @@ export function runInit(options) {
401
347
  }
402
348
  }
403
349
  const examples = [
404
- { type: 'spec', id: 'SPEC-001', title: 'Example Spec', subDir: 'specs', slug: 'example-spec.md' },
405
- { type: 'work', id: 'WORK-001', title: 'Example Work Item', subDir: 'work', slug: 'example-work-item.md', attrs: { priority: 'medium', complexity: 'simple', tags: '' } },
406
- { type: 'decision', id: 'ADR-001', title: 'Example Decision', subDir: 'decisions', slug: 'example-decision.md' },
407
- { type: 'milestone', id: 'v0.1.0', title: 'First Release', subDir: 'milestones', slug: 'first-release.md' },
350
+ { type: 'spec', id: 'SPEC-001', title: 'Example Spec' },
351
+ { type: 'work', id: 'WORK-001', title: 'Example Work Item', attrs: { priority: 'medium', complexity: 'simple', tags: '' } },
352
+ { type: 'decision', id: 'ADR-001', title: 'Example Decision' },
353
+ { type: 'milestone', id: 'v0.1.0', title: 'First Release' },
408
354
  ];
409
355
  for (const ex of examples) {
410
- const filePath = join(dir, ex.subDir, ex.slug);
411
- if (!existsSync(filePath)) {
412
- runCreate({ dir, type: ex.type, id: ex.id, title: ex.title, attrs: ex.attrs });
413
- created.push(filePath);
414
- }
415
- }
416
- for (const def of STATUS_PAGES) {
417
- const slug = `${def.status}.md`;
418
- const filePath = join(dir, def.typeDir, slug);
419
- if (!existsSync(filePath)) {
420
- writeFileSync(filePath, renderStatusPage(def));
421
- created.push(filePath);
422
- }
423
- }
424
- const typeDirs = [...new Set(STATUS_PAGES.map(p => p.typeDir))];
425
- for (const typeDir of typeDirs) {
426
- const filePath = join(dir, typeDir, 'index.md');
427
- if (!existsSync(filePath)) {
428
- writeFileSync(filePath, renderTypeIndexPage(typeDir));
429
- created.push(filePath);
430
- }
431
- }
432
- const indexFile = join(dir, 'index.md');
433
- if (!existsSync(indexFile)) {
434
- writeFileSync(indexFile, `# Project Plan
435
-
436
- This directory contains project planning content.
437
-
438
- ## Structure
439
-
440
- - [Specifications](specs/) — What to build
441
- - [Work Items](work/) — How to build it
442
- - [Decisions](decisions/) — Why it's built this way
443
- - [Milestones](milestones/) — Named release targets
444
-
445
- ## Quick Start
446
-
447
- \`\`\`bash
448
- refrakt plan next # Find next work item
449
- refrakt plan status # Project overview
450
- refrakt plan create work --id WORK-002 --title "My task"
451
- \`\`\`
452
- `);
453
- created.push(indexFile);
356
+ // Existing projects commonly already use the IDs we seed (SPEC-001, WORK-001,
357
+ // ADR-001, v0.1.0). Skip the example silently instead of crashing — the
358
+ // user has their own content, they don't need placeholders.
359
+ if (idExists(dir, ex.id))
360
+ continue;
361
+ const result = runCreate({ dir, type: ex.type, id: ex.id, title: ex.title, attrs: ex.attrs });
362
+ created.push(result.file);
454
363
  }
455
364
  const instructionsFile = join(dir, 'INSTRUCTIONS.md');
456
365
  if (!existsSync(instructionsFile)) {
457
366
  writeFileSync(instructionsFile, INSTRUCTIONS_CONTENT);
458
367
  created.push(instructionsFile);
459
368
  }
460
- // --- 2. AGENTS.md + tool-specific pointers ------------------------------
369
+ // --- 2. Append plan summary to agent instruction files ------------------
461
370
  const agentFilesUpdated = [];
462
371
  if (agent !== 'none') {
463
- if (writeAgentsFile(projectRoot)) {
464
- agentFilesUpdated.push(AGENTS_FILE);
465
- }
466
- const writePointer = (relPath) => {
467
- if (appendPointer(projectRoot, relPath)) {
372
+ const update = (relPath) => {
373
+ if (appendPlanSummary(projectRoot, relPath)) {
468
374
  agentFilesUpdated.push(relPath);
469
375
  }
470
376
  };
471
377
  if (agent) {
472
378
  const relPath = AGENT_FILES[agent];
473
379
  if (relPath)
474
- writePointer(relPath);
380
+ update(relPath);
475
381
  }
476
382
  else {
477
383
  const existing = detectAgentFiles(projectRoot);
478
- if (existing.length > 0) {
479
- for (const relPath of existing)
480
- writePointer(relPath);
481
- }
482
- else {
483
- // Fallback: ensure Claude Code has a pointer since it's our primary audience.
484
- writePointer(AGENT_FILES.claude);
485
- }
384
+ for (const relPath of existing)
385
+ update(relPath);
486
386
  }
487
387
  }
488
388
  // --- 3. Host package.json wiring ---------------------------------------
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACnG,OAAO,EA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AAC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1D,CAAC,CAAC,EAAE,CAAC;IACL,IAAI,eAAe,EAAE,CAAC;QACrB,WAAW,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC;IAED,0EAA0E;IAC1E,IAAI,cAAc,GAAG,KAAK,CAAC;IAC3B,IAAI,CAAC,SAAS,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;QACpC,cAAc,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;IAED,OAAO;QACN,GAAG;QACH,OAAO;QACP,iBAAiB;QACjB,kBAAkB;QAClB,WAAW;QACX,cAAc;QACd,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;QAC7D,cAAc;KACd,CAAC;AACH,CAAC;AAED,6EAA6E;AAC7E,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,40 @@
1
+ export declare const EXIT_SUCCESS = 0;
2
+ export declare const EXIT_ERRORS = 1;
3
+ export declare const EXIT_INVALID_ARGS = 2;
4
+ export interface MigrateFilenamesOptions {
5
+ dir: string;
6
+ apply?: boolean;
7
+ useGit?: boolean;
8
+ }
9
+ export interface PlannedRename {
10
+ id: string;
11
+ from: string;
12
+ to: string;
13
+ }
14
+ export interface MigrateFilenamesError {
15
+ file: string;
16
+ reason: string;
17
+ }
18
+ export interface MigrateFilenamesResult {
19
+ mode: 'dry-run' | 'apply';
20
+ scanned: number;
21
+ planned: PlannedRename[];
22
+ applied: PlannedRename[];
23
+ skipped: {
24
+ milestones: number;
25
+ alreadyCorrect: number;
26
+ };
27
+ errors: MigrateFilenamesError[];
28
+ exitCode: number;
29
+ }
30
+ /**
31
+ * Scan a plan directory, compute target filenames of the form
32
+ * `{ID}-{slug}.md` for every auto-ID entity, and either preview the
33
+ * renames (dry-run, default) or apply them.
34
+ *
35
+ * Milestones are skipped — they use semver names, not the numeric ID
36
+ * scheme. Files whose current name already matches the target are
37
+ * counted as `alreadyCorrect` and not touched.
38
+ */
39
+ export declare function runMigrateFilenames(options: MigrateFilenamesOptions): MigrateFilenamesResult;
40
+ //# sourceMappingURL=migrate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAKnC,MAAM,WAAW,uBAAuB;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,qBAAqB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACtC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,OAAO,EAAE;QACR,UAAU,EAAE,MAAM,CAAC;QACnB,cAAc,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;CACjB;AAuBD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,uBAAuB,GAAG,sBAAsB,CAkF5F"}
@@ -0,0 +1,110 @@
1
+ import { execFileSync } from 'child_process';
2
+ import { existsSync, renameSync } from 'fs';
3
+ import { basename, dirname, join, resolve } from 'path';
4
+ import { scanPlanFiles } from '../scanner.js';
5
+ export const EXIT_SUCCESS = 0;
6
+ export const EXIT_ERRORS = 1;
7
+ export const EXIT_INVALID_ARGS = 2;
8
+ /** Regex that matches a leading `{PREFIX}-{digits}-` in a filename. */
9
+ const ID_PREFIX_RE = /^(WORK|BUG|SPEC|ADR)-\d+-/;
10
+ /**
11
+ * Strip any existing `{PREFIX}-{digits}-` from a basename so the remaining
12
+ * slug can be recombined with the frontmatter ID.
13
+ */
14
+ function stripIdPrefix(fileName) {
15
+ return fileName.replace(ID_PREFIX_RE, '');
16
+ }
17
+ /**
18
+ * Rename a file, either via `git mv` or `fs.renameSync`. When running
19
+ * `git mv`, cwd is set to the scan dir so git discovery picks the
20
+ * closest enclosing repo (matters for nested repos, e.g. test fixtures).
21
+ */
22
+ function performRename(absFrom, absTo, useGit, cwd) {
23
+ if (useGit) {
24
+ execFileSync('git', ['mv', absFrom, absTo], { cwd, stdio: 'pipe' });
25
+ }
26
+ else {
27
+ renameSync(absFrom, absTo);
28
+ }
29
+ }
30
+ /**
31
+ * Scan a plan directory, compute target filenames of the form
32
+ * `{ID}-{slug}.md` for every auto-ID entity, and either preview the
33
+ * renames (dry-run, default) or apply them.
34
+ *
35
+ * Milestones are skipped — they use semver names, not the numeric ID
36
+ * scheme. Files whose current name already matches the target are
37
+ * counted as `alreadyCorrect` and not touched.
38
+ */
39
+ export function runMigrateFilenames(options) {
40
+ const { dir, apply = false, useGit = false } = options;
41
+ const entities = scanPlanFiles(dir, { cache: false });
42
+ const planned = [];
43
+ const applied = [];
44
+ const errors = [];
45
+ let milestonesSkipped = 0;
46
+ let alreadyCorrect = 0;
47
+ const targetPaths = new Set();
48
+ for (const entity of entities) {
49
+ if (entity.type === 'milestone') {
50
+ milestonesSkipped++;
51
+ continue;
52
+ }
53
+ const id = entity.attributes.id;
54
+ if (!id) {
55
+ errors.push({
56
+ file: entity.file,
57
+ reason: 'missing frontmatter id attribute',
58
+ });
59
+ continue;
60
+ }
61
+ const currentName = basename(entity.file);
62
+ const currentSlug = stripIdPrefix(currentName);
63
+ const targetName = `${id}-${currentSlug}`;
64
+ if (currentName === targetName) {
65
+ alreadyCorrect++;
66
+ continue;
67
+ }
68
+ const relDir = dirname(entity.file);
69
+ const fromRel = entity.file;
70
+ const toRel = relDir === '.' ? targetName : join(relDir, targetName);
71
+ const absFrom = resolve(dir, fromRel);
72
+ const absTo = resolve(dir, toRel);
73
+ if (targetPaths.has(absTo) || (absTo !== absFrom && existsSync(absTo))) {
74
+ errors.push({
75
+ file: entity.file,
76
+ reason: `target ${toRel} already exists or collides with another planned rename`,
77
+ });
78
+ continue;
79
+ }
80
+ targetPaths.add(absTo);
81
+ const rename = { id, from: fromRel, to: toRel };
82
+ planned.push(rename);
83
+ if (apply) {
84
+ try {
85
+ performRename(absFrom, absTo, useGit, resolve(dir));
86
+ applied.push(rename);
87
+ }
88
+ catch (err) {
89
+ errors.push({
90
+ file: entity.file,
91
+ reason: `rename failed: ${err.message ?? String(err)}`,
92
+ });
93
+ }
94
+ }
95
+ }
96
+ const exitCode = errors.length > 0 ? EXIT_ERRORS : EXIT_SUCCESS;
97
+ return {
98
+ mode: apply ? 'apply' : 'dry-run',
99
+ scanned: entities.length,
100
+ planned,
101
+ applied,
102
+ skipped: {
103
+ milestones: milestonesSkipped,
104
+ alreadyCorrect,
105
+ },
106
+ errors,
107
+ exitCode,
108
+ };
109
+ }
110
+ //# sourceMappingURL=migrate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAA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WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAEvB,MAAM,MAAM,GAAkB,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;QAC/D,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAErB,IAAI,KAAK,EAAE,CAAC;YACX,IAAI,CAAC;gBACJ,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;gBACpD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACtB,CAAC;YAAC,OAAO,GAAQ,EAAE,CAAC;gBACnB,MAAM,CAAC,IAAI,CAAC;oBACX,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,MAAM,EAAE,kBAAkB,GAAG,CAAC,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE;iBACtD,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;IACF,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC;IAEhE,OAAO;QACN,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;QACjC,OAAO,EAAE,QAAQ,CAAC,MAAM;QACxB,OAAO;QACP,OAAO;QACP,OAAO,EAAE;YACR,UAAU,EAAE,iBAAiB;YAC7B,cAAc;SACd;QACD,MAAM;QACN,QAAQ;KACR,CAAC;AACH,CAAC"}
@@ -15,8 +15,14 @@ export interface InstallRoot {
15
15
  */
16
16
  export declare function findInstallRoot(startDir: string): InstallRoot | null;
17
17
  /**
18
- * Detect the package manager for a project by looking at lockfiles in
19
- * `rootDir`. Returns 'npm' as the default when no lockfile is present.
18
+ * Detect the package manager for a project. Order of precedence:
19
+ *
20
+ * 1. The corepack `packageManager` field in package.json (authoritative).
21
+ * 2. The most recently modified lockfile. Repositories sometimes accumulate
22
+ * stale lockfiles (e.g. an old pnpm-lock.yaml left behind after a switch
23
+ * to npm), and the newest mtime is the best heuristic for which PM is
24
+ * currently active.
25
+ * 3. Defaults to npm when no lockfile is present.
20
26
  */
21
27
  export declare function detectPackageManager(rootDir: string): PackageManager;
22
28
  /** Shell command that installs dependencies for the given package manager. */
@@ -1 +1 @@
1
- {"version":3,"file":"project-setup.d.ts","sourceRoot":"","sources":["../../src/commands/project-setup.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC3B,8CAA8C;IAC9C,eAAe,EAAE,MAAM,CAAC;IACxB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,iGAAiG;IACjG,eAAe,EAAE,OAAO,CAAC;CACzB;AAID;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CA2BpE;AAeD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CAWpE;AAED,8EAA8E;AAC9E,wBAAgB,cAAc,CAAC,EAAE,EAAE,cAAc,GAAG,MAAM,CAQzD"}
1
+ {"version":3,"file":"project-setup.d.ts","sourceRoot":"","sources":["../../src/commands/project-setup.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC3B,8CAA8C;IAC9C,eAAe,EAAE,MAAM,CAAC;IACxB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,iGAAiG;IACjG,eAAe,EAAE,OAAO,CAAC;CACzB;AAID;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CA2BpE;AA2CD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CAmBpE;AAED,8EAA8E;AAC9E,wBAAgB,cAAc,CAAC,EAAE,EAAE,cAAc,GAAG,MAAM,CAQzD"}