lean-spec 0.2.8 → 0.2.9-dev.20251205030455
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/dist/backfill-446GBTBC.js +5 -0
- package/dist/{backfill-QIQLXSUG.js.map → backfill-446GBTBC.js.map} +1 -1
- package/dist/{chunk-EBSQ7FUR.js → chunk-BJHJ6IUO.js} +101 -246
- package/dist/chunk-BJHJ6IUO.js.map +1 -0
- package/dist/{chunk-FUIUCGUV.js → chunk-CJMVV46H.js} +14 -87
- package/dist/chunk-CJMVV46H.js.map +1 -0
- package/dist/{chunk-A6JDTXPV.js → chunk-H5MCUMBK.js} +313 -16
- package/dist/chunk-H5MCUMBK.js.map +1 -0
- package/dist/{chunk-LXOJW2FE.js → chunk-RF5PKL6L.js} +3 -3
- package/dist/{chunk-LXOJW2FE.js.map → chunk-RF5PKL6L.js.map} +1 -1
- package/dist/{chunk-LVD7ZAVZ.js → chunk-VN5BUHTV.js} +5 -3
- package/dist/chunk-VN5BUHTV.js.map +1 -0
- package/dist/cli.js +5 -6
- package/dist/cli.js.map +1 -1
- package/dist/{frontmatter-R2DANL5X.js → frontmatter-6ZBAGOEU.js} +3 -3
- package/dist/{frontmatter-R2DANL5X.js.map → frontmatter-6ZBAGOEU.js.map} +1 -1
- package/dist/mcp-server.js +5 -5
- package/dist/validate-DIWYTDEF.js +5 -0
- package/dist/{validate-PT6GAS57.js.map → validate-DIWYTDEF.js.map} +1 -1
- package/package.json +2 -2
- package/templates/detailed/AGENTS.md +59 -105
- package/templates/standard/AGENTS.md +59 -105
- package/dist/backfill-QIQLXSUG.js +0 -5
- package/dist/chunk-A6JDTXPV.js.map +0 -1
- package/dist/chunk-EBSQ7FUR.js.map +0 -1
- package/dist/chunk-FUIUCGUV.js.map +0 -1
- package/dist/chunk-LVD7ZAVZ.js.map +0 -1
- package/dist/validate-PT6GAS57.js +0 -5
|
@@ -12,132 +12,86 @@
|
|
|
12
12
|
|
|
13
13
|
> **Why?** Skipping discovery creates duplicate work. Manual file creation breaks LeanSpec tooling.
|
|
14
14
|
|
|
15
|
-
## 🔧
|
|
16
|
-
|
|
17
|
-
###
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
|
22
|
-
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
lean-spec board # Project overview
|
|
45
|
-
lean-spec list # See all specs
|
|
46
|
-
lean-spec search "query" # Find relevant specs
|
|
47
|
-
lean-spec create <name> # Create new spec
|
|
48
|
-
lean-spec update <spec> --status <status> # Update status
|
|
49
|
-
lean-spec link <spec> --related <other> # Add relationships
|
|
50
|
-
lean-spec unlink <spec> --related <other> # Remove relationships
|
|
51
|
-
lean-spec deps <spec> # Show dependencies
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
**Tip:** Check if you have LeanSpec MCP tools available before using CLI.
|
|
55
|
-
|
|
56
|
-
## ⚠️ SDD Workflow Checkpoints
|
|
57
|
-
|
|
58
|
-
### Before Starting ANY Task
|
|
59
|
-
|
|
60
|
-
1. 📋 **Run `board`** - What's the current project state?
|
|
61
|
-
2. 🔍 **Run `search`** - Are there related specs already?
|
|
62
|
-
3. 📝 **Check existing specs** - Is there one for this work?
|
|
63
|
-
|
|
64
|
-
### During Implementation
|
|
65
|
-
|
|
66
|
-
4. 📊 **Update status to `in-progress`** BEFORE coding
|
|
67
|
-
5. 📝 **Document decisions** in the spec as you work
|
|
68
|
-
6. 🔗 **Link related specs** if you discover connections
|
|
69
|
-
|
|
70
|
-
### After Completing Work
|
|
71
|
-
|
|
72
|
-
7. ✅ **Update status to `complete`** when done
|
|
73
|
-
8. 📄 **Document what you learned** in the spec
|
|
74
|
-
9. 🤔 **Create follow-up specs** if needed
|
|
75
|
-
|
|
76
|
-
### 🚫 Common Mistakes to Avoid
|
|
15
|
+
## 🔧 Managing Specs
|
|
16
|
+
|
|
17
|
+
### MCP Tools (Preferred) with CLI Fallback
|
|
18
|
+
|
|
19
|
+
| Action | MCP Tool | CLI Fallback |
|
|
20
|
+
|--------|----------|--------------|
|
|
21
|
+
| Project status | `board` | `lean-spec board` |
|
|
22
|
+
| List specs | `list` | `lean-spec list` |
|
|
23
|
+
| Search specs | `search` | `lean-spec search "query"` |
|
|
24
|
+
| View spec | `view` | `lean-spec view <spec>` |
|
|
25
|
+
| Create spec | `create` | `lean-spec create <name>` |
|
|
26
|
+
| Update spec | `update` | `lean-spec update <spec> --status <status>` |
|
|
27
|
+
| Link specs | `link` | `lean-spec link <spec> --depends-on <other>` |
|
|
28
|
+
| Unlink specs | `unlink` | `lean-spec unlink <spec> --depends-on <other>` |
|
|
29
|
+
| Dependencies | `deps` | `lean-spec deps <spec>` |
|
|
30
|
+
| Token count | `tokens` | `lean-spec tokens <spec>` |
|
|
31
|
+
|
|
32
|
+
## ⚠️ Core Rules
|
|
33
|
+
|
|
34
|
+
| Rule | Details |
|
|
35
|
+
|------|---------|
|
|
36
|
+
| **NEVER edit frontmatter manually** | Use `update`, `link`, `unlink` for: `status`, `priority`, `tags`, `assignee`, `transitions`, timestamps, `depends_on` |
|
|
37
|
+
| **ALWAYS link spec references** | Content mentions another spec → `lean-spec link <spec> --depends-on <other>` |
|
|
38
|
+
| **Track status transitions** | `planned` → `in-progress` (before coding) → `complete` (after done) |
|
|
39
|
+
| **No nested code blocks** | Use indentation instead |
|
|
40
|
+
|
|
41
|
+
### 🚫 Common Mistakes
|
|
77
42
|
|
|
78
43
|
| ❌ Don't | ✅ Do Instead |
|
|
79
44
|
|----------|---------------|
|
|
80
45
|
| Create spec files manually | Use `create` tool |
|
|
81
|
-
| Skip discovery
|
|
82
|
-
| Leave status as "planned"
|
|
83
|
-
| Finish work without updating spec | Document decisions, update status |
|
|
46
|
+
| Skip discovery | Run `board` and `search` first |
|
|
47
|
+
| Leave status as "planned" | Update to `in-progress` before coding |
|
|
84
48
|
| Edit frontmatter manually | Use `update` tool |
|
|
85
|
-
| Forget about specs mid-conversation | Check spec status periodically |
|
|
86
|
-
|
|
87
|
-
## Core Rules
|
|
88
|
-
|
|
89
|
-
1. **Read README.md first** - Understand project context
|
|
90
|
-
2. **Check specs/** - Review existing specs before starting
|
|
91
|
-
3. **Use MCP tools** - Prefer MCP over CLI when available
|
|
92
|
-
4. **Follow LeanSpec principles** - Clarity over documentation
|
|
93
|
-
5. **Keep it minimal** - If it doesn't add clarity, cut it
|
|
94
|
-
6. **NEVER manually edit frontmatter** - Use `update`, `link`, `unlink` tools
|
|
95
|
-
7. **Track progress in specs** - Update status and document decisions
|
|
96
|
-
|
|
97
|
-
## When to Use Specs
|
|
98
49
|
|
|
99
|
-
|
|
100
|
-
- Features affecting multiple parts of the system
|
|
101
|
-
- Breaking changes or significant refactors
|
|
102
|
-
- Design decisions needing team alignment
|
|
50
|
+
## 📋 SDD Workflow
|
|
103
51
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
-
|
|
107
|
-
|
|
52
|
+
```
|
|
53
|
+
BEFORE: board → search → check existing specs
|
|
54
|
+
DURING: update status to in-progress → code → document decisions → link dependencies
|
|
55
|
+
AFTER: update status to complete → document learnings
|
|
56
|
+
```
|
|
108
57
|
|
|
109
|
-
|
|
58
|
+
**Status tracks implementation, NOT spec writing.**
|
|
110
59
|
|
|
111
|
-
|
|
112
|
-
Informational relationship between specs. Shown from both sides.
|
|
113
|
-
**Use when:** Related topics, coordinated but not blocking work.
|
|
60
|
+
## Spec Dependencies
|
|
114
61
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
**Use when:** True blocking dependency, work order matters.
|
|
62
|
+
Use `depends_on` to express blocking relationships between specs:
|
|
63
|
+
- **`depends_on`** = True blocker, work order matters, directional (A depends on B)
|
|
118
64
|
|
|
119
|
-
|
|
65
|
+
Link dependencies when one spec builds on another:
|
|
66
|
+
```bash
|
|
67
|
+
lean-spec link <spec> --depends-on <other-spec>
|
|
68
|
+
```
|
|
120
69
|
|
|
121
|
-
##
|
|
70
|
+
## When to Use Specs
|
|
122
71
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
- Never leave specs with stale status
|
|
72
|
+
| ✅ Write spec | ❌ Skip spec |
|
|
73
|
+
|---------------|--------------|
|
|
74
|
+
| Multi-part features | Bug fixes |
|
|
75
|
+
| Breaking changes | Trivial changes |
|
|
76
|
+
| Design decisions | Self-explanatory refactors |
|
|
129
77
|
|
|
130
|
-
##
|
|
78
|
+
## Token Thresholds
|
|
131
79
|
|
|
132
80
|
| Tokens | Status |
|
|
133
81
|
|--------|--------|
|
|
134
82
|
| <2,000 | ✅ Optimal |
|
|
135
83
|
| 2,000-3,500 | ✅ Good |
|
|
136
84
|
| 3,500-5,000 | ⚠️ Consider splitting |
|
|
137
|
-
| >5,000 | 🔴
|
|
85
|
+
| >5,000 | 🔴 Must split |
|
|
86
|
+
|
|
87
|
+
## First Principles (Priority Order)
|
|
138
88
|
|
|
139
|
-
|
|
89
|
+
1. **Context Economy** - <2,000 tokens optimal, >3,500 needs splitting
|
|
90
|
+
2. **Signal-to-Noise** - Every word must inform a decision
|
|
91
|
+
3. **Intent Over Implementation** - Capture why, let how emerge
|
|
92
|
+
4. **Bridge the Gap** - Both human and AI must understand
|
|
93
|
+
5. **Progressive Disclosure** - Add complexity only when pain is felt
|
|
140
94
|
|
|
141
95
|
---
|
|
142
96
|
|
|
143
|
-
**Remember:** LeanSpec tracks what you're building. Keep specs in sync with your work!
|
|
97
|
+
**Remember:** LeanSpec tracks what you're building. Keep specs in sync with your work!
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources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;AAEpB,EAAA,IAAI,WAAA,CAAY,SAAS,CAAA,EAAG;AAC1B,IAAA,OAAA,CAAQ,IAAI,mCAAmC,CAAA;AAC/C,IAAA,MAAM,gBAAgB,CAAC,GAAG,IAAI,GAAA,CAAI,WAAW,CAAC,CAAA;AAC9C,IAAA,KAAA,MAAW,UAAU,aAAA,EAAe;AAClC,MAAA,MAAM,QAAQ,WAAA,CAAY,MAAA,CAAO,CAAA,CAAA,KAAK,CAAA,KAAM,MAAM,CAAA,CAAE,MAAA;AACpD,MAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,IAAA,EAAO,MAAM,CAAA,EAAA,EAAK,KAAK,CAAA,CAAA,CAAG,CAAA;AAAA,IACxC;AAAA,EACF;AAGA,EAAA,IAAI,QAAQ,MAAA,EAAQ;AAClB,IAAA,OAAA,CAAQ,IAAI,iEAA4D,CAAA;AAExE,IAAA,IAAI,CAAC,OAAA,CAAQ,eAAA,IAAmB,CAAC,QAAQ,kBAAA,EAAoB;AAC3D,MAAA,OAAA,CAAQ,IAAI,qFAAgF,CAAA;AAAA,IAC9F;AAAA,EACF,CAAA,MAAA,IAAW,UAAU,CAAA,EAAG;AACtB,IAAA,OAAA,CAAQ,IAAI,4CAAuC,CAAA;AACnD,IAAA,OAAA,CAAQ,IAAI,0DAA0D,CAAA;AAAA,EACxE;AACF","file":"chunk-A6JDTXPV.js","sourcesContent":["import { execSync } from 'node:child_process';\nimport * as path from 'node:path';\nimport type { SpecStatus, StatusTransition } from '../frontmatter.js';\n\nexport interface GitTimestampData {\n created_at?: string;\n updated_at?: string;\n completed_at?: string;\n assignee?: string;\n transitions?: StatusTransition[];\n}\n\n/**\n * Check if the current directory is a git repository\n */\nexport function isGitRepository(): boolean {\n try {\n execSync('git rev-parse --is-inside-work-tree', { \n stdio: 'ignore',\n encoding: 'utf-8' \n });\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Get the timestamp of the first commit that created a file\n */\nexport function getFirstCommitTimestamp(filePath: string): string | null {\n try {\n // Use --follow to track file renames\n // Use --diff-filter=A to find the commit that added the file\n // Format as ISO 8601 timestamp\n const timestamp = execSync(\n `git log --follow --format=\"%aI\" --diff-filter=A -- \"${filePath}\" | tail -1`,\n { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'ignore'] }\n ).trim();\n \n return timestamp || null;\n } catch {\n return null;\n }\n}\n\n/**\n * Get the timestamp of the most recent commit that modified a file\n */\nexport function getLastCommitTimestamp(filePath: string): string | null {\n try {\n const timestamp = execSync(\n `git log --format=\"%aI\" -n 1 -- \"${filePath}\"`,\n { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'ignore'] }\n ).trim();\n \n return timestamp || null;\n } catch {\n return null;\n }\n}\n\n/**\n * Get the timestamp when a spec was marked as complete\n * Searches git history for status changes to \"complete\"\n */\nexport function getCompletionTimestamp(filePath: string): string | null {\n try {\n // Get all commits that modified the file, with patch output\n const gitLog = execSync(\n `git log --format=\"%H|%aI\" -p -- \"${filePath}\"`,\n { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'ignore'] }\n );\n \n // Parse commits to find status change to complete\n const commits = gitLog.split('\\ndiff --git').map(section => section.trim());\n \n for (const commit of commits) {\n if (!commit) continue;\n \n // Extract commit hash and timestamp from header\n const headerMatch = commit.match(/^([a-f0-9]{40})\\|([^\\n]+)/);\n if (!headerMatch) continue;\n \n const [, , timestamp] = headerMatch;\n \n // Look for status: complete in the diff\n // Check for both YAML frontmatter and inline status changes\n if (\n /^\\+status:\\s*['\"]?complete['\"]?/m.test(commit) ||\n /^\\+\\*\\*Status\\*\\*:.*complete/mi.test(commit)\n ) {\n return timestamp;\n }\n }\n \n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * Get the author of the first commit (for assignee inference)\n */\nexport function getFirstCommitAuthor(filePath: string): string | null {\n try {\n const author = execSync(\n `git log --follow --format=\"%an\" --diff-filter=A -- \"${filePath}\" | tail -1`,\n { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'ignore'] }\n ).trim();\n \n return author || null;\n } catch {\n return null;\n }\n}\n\n/**\n * Parse all status transitions from git history\n * Reconstructs the full status change timeline\n */\nexport function parseStatusTransitions(filePath: string): StatusTransition[] {\n const transitions: StatusTransition[] = [];\n \n try {\n // Get all commits that modified the file, with patch output\n const gitLog = execSync(\n `git log --format=\"%H|%aI\" -p --reverse -- \"${filePath}\"`,\n { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'ignore'] }\n );\n \n // Parse commits in chronological order (--reverse)\n const commits = gitLog.split('\\ndiff --git').map(section => section.trim());\n \n const validStatuses: SpecStatus[] = ['planned', 'in-progress', 'complete', 'archived'];\n \n for (const commit of commits) {\n if (!commit) continue;\n \n // Extract commit hash and timestamp from header\n const headerMatch = commit.match(/^([a-f0-9]{40})\\|([^\\n]+)/);\n if (!headerMatch) continue;\n \n const [, , timestamp] = headerMatch;\n \n // Look for status changes in the diff\n // Match: +status: complete or +status: 'complete'\n const statusMatch = commit.match(/^\\+status:\\s*['\"]?(\\w+(?:-\\w+)?)['\"]?/m);\n if (statusMatch) {\n const status = statusMatch[1] as SpecStatus;\n \n // Only record valid status values\n if (validStatuses.includes(status)) {\n // Avoid duplicate consecutive transitions\n const lastTransition = transitions[transitions.length - 1];\n if (!lastTransition || lastTransition.status !== status) {\n transitions.push({ status, at: timestamp });\n }\n }\n }\n }\n \n return transitions;\n } catch {\n return [];\n }\n}\n\n/**\n * Extract all git timestamp data for a spec file\n */\nexport function extractGitTimestamps(\n filePath: string,\n options: {\n includeAssignee?: boolean;\n includeTransitions?: boolean;\n } = {}\n): GitTimestampData {\n const data: GitTimestampData = {};\n \n // Core timestamps (always extracted)\n data.created_at = getFirstCommitTimestamp(filePath) ?? undefined;\n data.updated_at = getLastCommitTimestamp(filePath) ?? undefined;\n data.completed_at = getCompletionTimestamp(filePath) ?? undefined;\n \n // Optional fields\n if (options.includeAssignee) {\n const author = getFirstCommitAuthor(filePath);\n if (author) {\n data.assignee = author;\n }\n }\n \n if (options.includeTransitions) {\n const transitions = parseStatusTransitions(filePath);\n if (transitions.length > 0) {\n data.transitions = transitions;\n }\n }\n \n return data;\n}\n\n/**\n * Validate that a file exists in git history\n */\nexport function fileExistsInGit(filePath: string): boolean {\n try {\n execSync(\n `git log -n 1 -- \"${filePath}\"`,\n { stdio: 'ignore', encoding: 'utf-8' }\n );\n return true;\n } catch {\n return false;\n }\n}\n","import * as fs from 'node:fs/promises';\nimport * as path from 'node:path';\n\n/**\n * Create a regex pattern to match spec directories with sequence numbers\n * Handles optional date prefixes like 20251103-001-name\n */\nexport function createSpecDirPattern(): RegExp {\n // Match spec directories, handling optional date prefix\n // Patterns:\n // - 001-name (simple sequence)\n // - 20251103-001-name (date prefix + sequence)\n // - spec-001-name (custom prefix + sequence)\n // We look for: optional-prefix + NNN + dash + name\n // The sequence is 2-4 digits (to avoid matching 8-digit dates as sequences)\n // Requires dash followed by letter to ensure this is a spec directory name\n return /(?:^|\\D)(\\d{2,4})-[a-z]/i;\n}\n\n/**\n * Get next global sequence number across entire specs directory\n */\nexport async function getGlobalNextSeq(specsDir: string, digits: number): Promise<string> {\n try {\n // Recursively find all spec directories with sequence numbers\n const seqNumbers: number[] = [];\n const specPattern = createSpecDirPattern();\n \n async function scanDirectory(dir: string): Promise<void> {\n try {\n const entries = await fs.readdir(dir, { withFileTypes: true });\n \n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n \n // Check if this is a spec directory (NNN-name format)\n const match = entry.name.match(specPattern);\n if (match) {\n const seqNum = parseInt(match[1], 10);\n if (!isNaN(seqNum) && seqNum > 0) {\n seqNumbers.push(seqNum);\n }\n }\n \n // Skip archived directory to avoid confusion\n if (entry.name === 'archived') continue;\n \n // Recursively scan subdirectories (for custom pattern grouping)\n const subDir = path.join(dir, entry.name);\n await scanDirectory(subDir);\n }\n } catch {\n // Directory doesn't exist or can't be read\n }\n }\n \n await scanDirectory(specsDir);\n \n if (seqNumbers.length === 0) {\n return '1'.padStart(digits, '0');\n }\n \n const maxSeq = Math.max(...seqNumbers);\n return String(maxSeq + 1).padStart(digits, '0');\n } catch {\n return '1'.padStart(digits, '0');\n }\n}\n\n/**\n * Get next sequence number for a date directory (legacy, kept for backward compatibility)\n */\nexport async function getNextSeq(dateDir: string, digits: number): Promise<string> {\n try {\n const specPattern = createSpecDirPattern();\n const entries = await fs.readdir(dateDir, { withFileTypes: true });\n const seqNumbers = entries\n .filter((e) => e.isDirectory() && specPattern.test(e.name))\n .map((e) => {\n const match = e.name.match(specPattern);\n return match ? parseInt(match[1], 10) : NaN;\n })\n .filter((n) => !isNaN(n));\n\n if (seqNumbers.length === 0) {\n return '1'.padStart(digits, '0');\n }\n\n const maxSeq = Math.max(...seqNumbers);\n return String(maxSeq + 1).padStart(digits, '0');\n } catch {\n return '1'.padStart(digits, '0');\n }\n}\n\n/**\n * Resolve spec path in multiple ways:\n * 1. Absolute path as given\n * 2. Relative to current directory\n * 3. Relative to specs directory\n * 4. Search by spec name in all subdirectories (flat or grouped)\n * 5. Search by sequence number only\n */\nexport async function resolveSpecPath(\n specPath: string,\n cwd: string,\n specsDir: string\n): Promise<string | null> {\n // Try absolute path\n if (path.isAbsolute(specPath)) {\n try {\n await fs.access(specPath);\n return specPath;\n } catch {\n return null;\n }\n }\n\n // Try relative to cwd\n const cwdPath = path.resolve(cwd, specPath);\n try {\n await fs.access(cwdPath);\n return cwdPath;\n } catch {\n // Continue to next method\n }\n\n // Try relative to specs directory\n const specsPath = path.join(specsDir, specPath);\n try {\n await fs.access(specsPath);\n return specsPath;\n } catch {\n // Continue to next method\n }\n\n // Search by sequence number only (e.g., \"5\" or \"005\")\n const seqMatch = specPath.match(/^0*(\\d+)$/);\n if (seqMatch) {\n const seqNum = parseInt(seqMatch[1], 10);\n const result = await searchBySequence(specsDir, seqNum);\n if (result) return result;\n }\n\n // Last resort: search for spec name in all subdirectories\n const specName = specPath.replace(/^.*\\//, ''); // Get last part\n const result = await searchInAllDirectories(specsDir, specName);\n return result;\n}\n\n/**\n * Search for a spec by sequence number across all directories\n */\nasync function searchBySequence(specsDir: string, seqNum: number): Promise<string | null> {\n const specPattern = createSpecDirPattern();\n \n async function scanDirectory(dir: string): Promise<string | null> {\n try {\n const entries = await fs.readdir(dir, { withFileTypes: true });\n \n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n \n // Check if this matches the sequence number\n const match = entry.name.match(specPattern);\n if (match) {\n const entrySeq = parseInt(match[1], 10);\n if (entrySeq === seqNum) {\n return path.join(dir, entry.name);\n }\n }\n \n // Recursively search subdirectories (including archived)\n const subDir = path.join(dir, entry.name);\n const result = await scanDirectory(subDir);\n if (result) return result;\n }\n } catch {\n // Directory doesn't exist or can't be read\n }\n \n return null;\n }\n \n return scanDirectory(specsDir);\n}\n\n/**\n * Search for a spec by name in all subdirectories\n */\nasync function searchInAllDirectories(specsDir: string, specName: string): Promise<string | null> {\n async function scanDirectory(dir: string): Promise<string | null> {\n try {\n const entries = await fs.readdir(dir, { withFileTypes: true });\n \n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n \n // Check if this matches the spec name\n if (entry.name === specName) {\n return path.join(dir, entry.name);\n }\n \n // Recursively search subdirectories (including archived)\n const subDir = path.join(dir, entry.name);\n const result = await scanDirectory(subDir);\n if (result) return result;\n }\n } catch {\n // Directory doesn't exist or can't be read\n }\n \n return null;\n }\n \n return scanDirectory(specsDir);\n}\n","import * as path from 'node:path';\nimport { Command } from 'commander';\nimport { loadAllSpecs, getSpec, type SpecInfo } from '../spec-loader.js';\nimport { updateFrontmatter, type SpecFrontmatter } from '../frontmatter.js';\nimport { loadConfig } from '../config.js';\nimport { \n isGitRepository,\n extractGitTimestamps,\n fileExistsInGit,\n type GitTimestampData,\n} from '../utils/git-timestamps.js';\nimport { resolveSpecPath } from '../utils/path-helpers.js';\n\nexport interface BackfillResult {\n specPath: string;\n specName: string;\n created_at?: string;\n updated_at?: string;\n completed_at?: string;\n assignee?: string;\n transitionsCount?: number;\n source: 'git' | 'existing' | 'skipped';\n reason?: string;\n}\n\nexport interface BackfillOptions {\n dryRun?: boolean;\n force?: boolean;\n includeAssignee?: boolean;\n includeTransitions?: boolean;\n specs?: string[]; // specific specs to target\n json?: boolean;\n}\n\n/**\n * Backfill command - backfill timestamps from git history\n */\nexport function backfillCommand(): Command {\n return new Command('backfill')\n .description('Backfill timestamps from git history')\n .argument('[specs...]', 'Specific specs to backfill (optional)')\n .option('--dry-run', 'Show what would be updated without making changes')\n .option('--force', 'Overwrite existing timestamp values')\n .option('--assignee', 'Include assignee from first commit author')\n .option('--transitions', 'Include full status transition history')\n .option('--all', 'Include all optional fields (assignee + transitions)')\n .option('--json', 'Output as JSON')\n .action(async (specs: string[] | undefined, options: {\n dryRun?: boolean;\n force?: boolean;\n assignee?: boolean;\n transitions?: boolean;\n all?: boolean;\n json?: boolean;\n }) => {\n await backfillTimestamps({\n dryRun: options.dryRun,\n force: options.force,\n includeAssignee: options.assignee || options.all,\n includeTransitions: options.transitions || options.all,\n specs: specs && specs.length > 0 ? specs : undefined,\n json: options.json,\n });\n });\n}\n\n/**\n * Backfill timestamps from git history for all or specific specs\n */\nexport async function backfillTimestamps(options: BackfillOptions = {}): Promise<BackfillResult[]> {\n const results: BackfillResult[] = [];\n \n // Check if we're in a git repository\n if (!isGitRepository()) {\n console.error('\\x1b[31mError:\\x1b[0m Not in a git repository');\n console.error('Git history is required for backfilling timestamps');\n process.exit(1);\n }\n \n // Load specs to process\n let specs: SpecInfo[];\n \n if (options.specs && options.specs.length > 0) {\n // Load specific specs\n specs = [];\n const config = await loadConfig();\n const cwd = process.cwd();\n const specsDir = path.join(cwd, config.specsDir);\n \n for (const specPath of options.specs) {\n const resolved = await resolveSpecPath(specPath, cwd, specsDir);\n if (!resolved) {\n console.warn(`\\x1b[33mWarning:\\x1b[0m Spec not found: ${specPath}`);\n continue;\n }\n const spec = await getSpec(resolved);\n if (spec) {\n specs.push(spec);\n }\n }\n } else {\n // Load all specs (including archived)\n specs = await loadAllSpecs({ includeArchived: true });\n }\n \n if (specs.length === 0) {\n console.log('No specs found to backfill');\n return results;\n }\n \n // Show what we're doing\n if (options.dryRun) {\n console.log('\\x1b[36m🔍 Dry run mode - no changes will be made\\x1b[0m\\n');\n }\n \n console.log(`Analyzing git history for ${specs.length} spec${specs.length === 1 ? '' : 's'}...\\n`);\n \n // Process each spec\n for (const spec of specs) {\n const result = await backfillSpecTimestamps(spec, options);\n results.push(result);\n }\n \n // Print summary\n printSummary(results, options);\n \n return results;\n}\n\n/**\n * Backfill timestamps for a single spec\n */\nasync function backfillSpecTimestamps(\n spec: SpecInfo,\n options: BackfillOptions\n): Promise<BackfillResult> {\n const result: BackfillResult = {\n specPath: spec.path,\n specName: spec.name,\n source: 'skipped',\n };\n \n // Check if file exists in git history\n if (!fileExistsInGit(spec.filePath)) {\n result.reason = 'Not in git history';\n console.log(`\\x1b[33m⊘\\x1b[0m ${spec.name} - Not in git history`);\n return result;\n }\n \n // Extract git timestamps\n const gitData = extractGitTimestamps(spec.filePath, {\n includeAssignee: options.includeAssignee,\n includeTransitions: options.includeTransitions,\n });\n \n // Determine what needs to be updated\n const updates: Partial<SpecFrontmatter> = {};\n let hasUpdates = false;\n \n // Check created_at\n if (gitData.created_at && (options.force || !spec.frontmatter.created_at)) {\n updates.created_at = gitData.created_at;\n result.created_at = gitData.created_at;\n result.source = 'git';\n hasUpdates = true;\n } else if (spec.frontmatter.created_at) {\n result.created_at = spec.frontmatter.created_at;\n result.source = 'existing';\n }\n \n // Check updated_at\n if (gitData.updated_at && (options.force || !spec.frontmatter.updated_at)) {\n updates.updated_at = gitData.updated_at;\n result.updated_at = gitData.updated_at;\n result.source = 'git';\n hasUpdates = true;\n } else if (spec.frontmatter.updated_at) {\n result.updated_at = spec.frontmatter.updated_at;\n result.source = 'existing';\n }\n \n // Check completed_at\n if (gitData.completed_at && (options.force || !spec.frontmatter.completed_at)) {\n updates.completed_at = gitData.completed_at;\n result.completed_at = gitData.completed_at;\n result.source = 'git';\n hasUpdates = true;\n } else if (spec.frontmatter.completed_at) {\n result.completed_at = spec.frontmatter.completed_at;\n result.source = 'existing';\n }\n \n // Check assignee (optional)\n if (options.includeAssignee && gitData.assignee && (options.force || !spec.frontmatter.assignee)) {\n updates.assignee = gitData.assignee;\n result.assignee = gitData.assignee;\n result.source = 'git';\n hasUpdates = true;\n } else if (spec.frontmatter.assignee) {\n result.assignee = spec.frontmatter.assignee;\n }\n \n // Check transitions (optional)\n if (options.includeTransitions && gitData.transitions && gitData.transitions.length > 0) {\n if (options.force || !spec.frontmatter.transitions || spec.frontmatter.transitions.length === 0) {\n updates.transitions = gitData.transitions;\n result.transitionsCount = gitData.transitions.length;\n result.source = 'git';\n hasUpdates = true;\n } else {\n // Merge with existing transitions (optional: could implement smart merge)\n result.transitionsCount = spec.frontmatter.transitions.length;\n }\n }\n \n // Sync updated date field with updated_at timestamp\n if (updates.updated_at && !updates.updated) {\n updates.updated = updates.updated_at.split('T')[0];\n }\n \n if (!hasUpdates) {\n result.reason = 'Already has complete data';\n console.log(`\\x1b[90m✓\\x1b[0m ${spec.name} - Already complete`);\n return result;\n }\n \n // Apply updates (unless dry run)\n if (!options.dryRun) {\n try {\n await updateFrontmatter(spec.filePath, updates);\n console.log(`\\x1b[32m✓\\x1b[0m ${spec.name} - Updated`);\n } catch (error) {\n result.source = 'skipped';\n result.reason = `Error: ${error instanceof Error ? error.message : String(error)}`;\n console.log(`\\x1b[31m✗\\x1b[0m ${spec.name} - Failed: ${result.reason}`);\n }\n } else {\n console.log(`\\x1b[36m→\\x1b[0m ${spec.name} - Would update`);\n // Show what would be updated\n if (updates.created_at) console.log(` created_at: ${updates.created_at} (git)`);\n if (updates.updated_at) console.log(` updated_at: ${updates.updated_at} (git)`);\n if (updates.completed_at) console.log(` completed_at: ${updates.completed_at} (git)`);\n if (updates.assignee) console.log(` assignee: ${updates.assignee} (git)`);\n if (updates.transitions) console.log(` transitions: ${updates.transitions.length} status changes (git)`);\n }\n \n return result;\n}\n\n/**\n * Print summary of backfill results\n */\nfunction printSummary(results: BackfillResult[], options: BackfillOptions): void {\n console.log('\\n' + '─'.repeat(60));\n console.log('\\x1b[1mSummary:\\x1b[0m\\n');\n \n const total = results.length;\n const updated = results.filter(r => r.source === 'git').length;\n const existing = results.filter(r => r.source === 'existing').length;\n const skipped = results.filter(r => r.source === 'skipped').length;\n \n const timestampUpdates = results.filter(r => \n r.source === 'git' && (r.created_at || r.updated_at || r.completed_at)\n ).length;\n \n const assigneeUpdates = results.filter(r => \n r.source === 'git' && r.assignee\n ).length;\n \n const transitionUpdates = results.filter(r => \n r.source === 'git' && r.transitionsCount\n ).length;\n \n console.log(` ${total} specs analyzed`);\n \n if (options.dryRun) {\n console.log(` ${updated} would be updated`);\n if (timestampUpdates > 0) {\n console.log(` └─ ${timestampUpdates} with timestamps`);\n }\n if (options.includeAssignee && assigneeUpdates > 0) {\n console.log(` └─ ${assigneeUpdates} with assignee`);\n }\n if (options.includeTransitions && transitionUpdates > 0) {\n console.log(` └─ ${transitionUpdates} with transitions`);\n }\n } else {\n console.log(` ${updated} updated`);\n }\n \n console.log(` ${existing} already complete`);\n console.log(` ${skipped} skipped`);\n \n // Show reasons for skipped specs\n const skipReasons = results\n .filter(r => r.source === 'skipped' && r.reason)\n .map(r => r.reason);\n \n if (skipReasons.length > 0) {\n console.log('\\n\\x1b[33mSkipped reasons:\\x1b[0m');\n const uniqueReasons = [...new Set(skipReasons)];\n for (const reason of uniqueReasons) {\n const count = skipReasons.filter(r => r === reason).length;\n console.log(` - ${reason} (${count})`);\n }\n }\n \n // Guidance\n if (options.dryRun) {\n console.log('\\n\\x1b[36mℹ\\x1b[0m Run without --dry-run to apply changes');\n \n if (!options.includeAssignee || !options.includeTransitions) {\n console.log('\\x1b[36mℹ\\x1b[0m Use --all to include optional fields (assignee, transitions)');\n }\n } else if (updated > 0) {\n console.log('\\n\\x1b[32m✓\\x1b[0m Backfill complete!');\n console.log(' Run \\x1b[36mlspec stats\\x1b[0m to see velocity metrics');\n }\n}\n"]}
|