lightspec 0.1.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.
Files changed (203) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +435 -0
  3. package/bin/lightspec.js +3 -0
  4. package/dist/cli/index.d.ts +2 -0
  5. package/dist/cli/index.js +361 -0
  6. package/dist/commands/change.d.ts +35 -0
  7. package/dist/commands/change.js +277 -0
  8. package/dist/commands/completion.d.ts +72 -0
  9. package/dist/commands/completion.js +257 -0
  10. package/dist/commands/config.d.ts +8 -0
  11. package/dist/commands/config.js +198 -0
  12. package/dist/commands/feedback.d.ts +9 -0
  13. package/dist/commands/feedback.js +183 -0
  14. package/dist/commands/show.d.ts +14 -0
  15. package/dist/commands/show.js +132 -0
  16. package/dist/commands/spec.d.ts +15 -0
  17. package/dist/commands/spec.js +225 -0
  18. package/dist/commands/validate.d.ts +24 -0
  19. package/dist/commands/validate.js +294 -0
  20. package/dist/core/archive.d.ts +11 -0
  21. package/dist/core/archive.js +280 -0
  22. package/dist/core/completions/command-registry.d.ts +7 -0
  23. package/dist/core/completions/command-registry.js +456 -0
  24. package/dist/core/completions/completion-provider.d.ts +60 -0
  25. package/dist/core/completions/completion-provider.js +102 -0
  26. package/dist/core/completions/factory.d.ts +64 -0
  27. package/dist/core/completions/factory.js +75 -0
  28. package/dist/core/completions/generators/bash-generator.d.ts +32 -0
  29. package/dist/core/completions/generators/bash-generator.js +174 -0
  30. package/dist/core/completions/generators/fish-generator.d.ts +32 -0
  31. package/dist/core/completions/generators/fish-generator.js +157 -0
  32. package/dist/core/completions/generators/powershell-generator.d.ts +33 -0
  33. package/dist/core/completions/generators/powershell-generator.js +207 -0
  34. package/dist/core/completions/generators/zsh-generator.d.ts +44 -0
  35. package/dist/core/completions/generators/zsh-generator.js +250 -0
  36. package/dist/core/completions/installers/bash-installer.d.ts +87 -0
  37. package/dist/core/completions/installers/bash-installer.js +318 -0
  38. package/dist/core/completions/installers/fish-installer.d.ts +43 -0
  39. package/dist/core/completions/installers/fish-installer.js +143 -0
  40. package/dist/core/completions/installers/powershell-installer.d.ts +88 -0
  41. package/dist/core/completions/installers/powershell-installer.js +327 -0
  42. package/dist/core/completions/installers/zsh-installer.d.ts +125 -0
  43. package/dist/core/completions/installers/zsh-installer.js +449 -0
  44. package/dist/core/completions/templates/bash-templates.d.ts +6 -0
  45. package/dist/core/completions/templates/bash-templates.js +24 -0
  46. package/dist/core/completions/templates/fish-templates.d.ts +7 -0
  47. package/dist/core/completions/templates/fish-templates.js +39 -0
  48. package/dist/core/completions/templates/powershell-templates.d.ts +6 -0
  49. package/dist/core/completions/templates/powershell-templates.js +25 -0
  50. package/dist/core/completions/templates/zsh-templates.d.ts +6 -0
  51. package/dist/core/completions/templates/zsh-templates.js +36 -0
  52. package/dist/core/completions/types.d.ts +79 -0
  53. package/dist/core/completions/types.js +2 -0
  54. package/dist/core/config-prompts.d.ts +9 -0
  55. package/dist/core/config-prompts.js +34 -0
  56. package/dist/core/config-schema.d.ts +76 -0
  57. package/dist/core/config-schema.js +200 -0
  58. package/dist/core/config.d.ts +16 -0
  59. package/dist/core/config.js +30 -0
  60. package/dist/core/configurators/agents.d.ts +8 -0
  61. package/dist/core/configurators/agents.js +15 -0
  62. package/dist/core/configurators/base.d.ts +7 -0
  63. package/dist/core/configurators/base.js +2 -0
  64. package/dist/core/configurators/claude.d.ts +8 -0
  65. package/dist/core/configurators/claude.js +15 -0
  66. package/dist/core/configurators/cline.d.ts +8 -0
  67. package/dist/core/configurators/cline.js +15 -0
  68. package/dist/core/configurators/codebuddy.d.ts +8 -0
  69. package/dist/core/configurators/codebuddy.js +15 -0
  70. package/dist/core/configurators/costrict.d.ts +8 -0
  71. package/dist/core/configurators/costrict.js +15 -0
  72. package/dist/core/configurators/iflow.d.ts +8 -0
  73. package/dist/core/configurators/iflow.js +15 -0
  74. package/dist/core/configurators/qoder.d.ts +30 -0
  75. package/dist/core/configurators/qoder.js +42 -0
  76. package/dist/core/configurators/qwen.d.ts +24 -0
  77. package/dist/core/configurators/qwen.js +37 -0
  78. package/dist/core/configurators/registry.d.ts +9 -0
  79. package/dist/core/configurators/registry.js +43 -0
  80. package/dist/core/configurators/slash/amazon-q.d.ts +9 -0
  81. package/dist/core/configurators/slash/amazon-q.js +46 -0
  82. package/dist/core/configurators/slash/antigravity.d.ts +9 -0
  83. package/dist/core/configurators/slash/antigravity.js +23 -0
  84. package/dist/core/configurators/slash/auggie.d.ts +9 -0
  85. package/dist/core/configurators/slash/auggie.js +31 -0
  86. package/dist/core/configurators/slash/base.d.ts +19 -0
  87. package/dist/core/configurators/slash/base.js +69 -0
  88. package/dist/core/configurators/slash/claude.d.ts +9 -0
  89. package/dist/core/configurators/slash/claude.js +37 -0
  90. package/dist/core/configurators/slash/cline.d.ts +9 -0
  91. package/dist/core/configurators/slash/cline.js +23 -0
  92. package/dist/core/configurators/slash/codebuddy.d.ts +9 -0
  93. package/dist/core/configurators/slash/codebuddy.js +34 -0
  94. package/dist/core/configurators/slash/codex.d.ts +14 -0
  95. package/dist/core/configurators/slash/codex.js +109 -0
  96. package/dist/core/configurators/slash/continue.d.ts +9 -0
  97. package/dist/core/configurators/slash/continue.js +46 -0
  98. package/dist/core/configurators/slash/costrict.d.ts +9 -0
  99. package/dist/core/configurators/slash/costrict.js +31 -0
  100. package/dist/core/configurators/slash/crush.d.ts +9 -0
  101. package/dist/core/configurators/slash/crush.js +37 -0
  102. package/dist/core/configurators/slash/cursor.d.ts +9 -0
  103. package/dist/core/configurators/slash/cursor.js +37 -0
  104. package/dist/core/configurators/slash/factory.d.ts +10 -0
  105. package/dist/core/configurators/slash/factory.js +35 -0
  106. package/dist/core/configurators/slash/gemini.d.ts +9 -0
  107. package/dist/core/configurators/slash/gemini.js +22 -0
  108. package/dist/core/configurators/slash/github-copilot.d.ts +9 -0
  109. package/dist/core/configurators/slash/github-copilot.js +34 -0
  110. package/dist/core/configurators/slash/iflow.d.ts +9 -0
  111. package/dist/core/configurators/slash/iflow.js +37 -0
  112. package/dist/core/configurators/slash/kilocode.d.ts +9 -0
  113. package/dist/core/configurators/slash/kilocode.js +17 -0
  114. package/dist/core/configurators/slash/opencode.d.ts +12 -0
  115. package/dist/core/configurators/slash/opencode.js +72 -0
  116. package/dist/core/configurators/slash/qoder.d.ts +35 -0
  117. package/dist/core/configurators/slash/qoder.js +76 -0
  118. package/dist/core/configurators/slash/qwen.d.ts +32 -0
  119. package/dist/core/configurators/slash/qwen.js +49 -0
  120. package/dist/core/configurators/slash/registry.d.ts +8 -0
  121. package/dist/core/configurators/slash/registry.js +78 -0
  122. package/dist/core/configurators/slash/roocode.d.ts +9 -0
  123. package/dist/core/configurators/slash/roocode.js +23 -0
  124. package/dist/core/configurators/slash/toml-base.d.ts +10 -0
  125. package/dist/core/configurators/slash/toml-base.js +53 -0
  126. package/dist/core/configurators/slash/windsurf.d.ts +9 -0
  127. package/dist/core/configurators/slash/windsurf.js +23 -0
  128. package/dist/core/converters/json-converter.d.ts +6 -0
  129. package/dist/core/converters/json-converter.js +51 -0
  130. package/dist/core/global-config.d.ts +39 -0
  131. package/dist/core/global-config.js +115 -0
  132. package/dist/core/index.d.ts +2 -0
  133. package/dist/core/index.js +3 -0
  134. package/dist/core/init.d.ts +52 -0
  135. package/dist/core/init.js +644 -0
  136. package/dist/core/list.d.ts +9 -0
  137. package/dist/core/list.js +171 -0
  138. package/dist/core/parsers/change-parser.d.ts +13 -0
  139. package/dist/core/parsers/change-parser.js +193 -0
  140. package/dist/core/parsers/markdown-parser.d.ts +22 -0
  141. package/dist/core/parsers/markdown-parser.js +187 -0
  142. package/dist/core/parsers/requirement-blocks.d.ts +37 -0
  143. package/dist/core/parsers/requirement-blocks.js +201 -0
  144. package/dist/core/project-config.d.ts +64 -0
  145. package/dist/core/project-config.js +223 -0
  146. package/dist/core/schemas/base.schema.d.ts +13 -0
  147. package/dist/core/schemas/base.schema.js +13 -0
  148. package/dist/core/schemas/change.schema.d.ts +73 -0
  149. package/dist/core/schemas/change.schema.js +31 -0
  150. package/dist/core/schemas/index.d.ts +4 -0
  151. package/dist/core/schemas/index.js +4 -0
  152. package/dist/core/schemas/spec.schema.d.ts +18 -0
  153. package/dist/core/schemas/spec.schema.js +15 -0
  154. package/dist/core/specs-apply.d.ts +73 -0
  155. package/dist/core/specs-apply.js +384 -0
  156. package/dist/core/styles/palette.d.ts +7 -0
  157. package/dist/core/styles/palette.js +8 -0
  158. package/dist/core/templates/agents-root-stub.d.ts +2 -0
  159. package/dist/core/templates/agents-root-stub.js +17 -0
  160. package/dist/core/templates/agents-template.d.ts +2 -0
  161. package/dist/core/templates/agents-template.js +458 -0
  162. package/dist/core/templates/claude-template.d.ts +2 -0
  163. package/dist/core/templates/claude-template.js +2 -0
  164. package/dist/core/templates/cline-template.d.ts +2 -0
  165. package/dist/core/templates/cline-template.js +2 -0
  166. package/dist/core/templates/costrict-template.d.ts +2 -0
  167. package/dist/core/templates/costrict-template.js +2 -0
  168. package/dist/core/templates/index.d.ts +17 -0
  169. package/dist/core/templates/index.js +37 -0
  170. package/dist/core/templates/project-template.d.ts +8 -0
  171. package/dist/core/templates/project-template.js +32 -0
  172. package/dist/core/templates/slash-command-templates.d.ts +4 -0
  173. package/dist/core/templates/slash-command-templates.js +49 -0
  174. package/dist/core/update.d.ts +4 -0
  175. package/dist/core/update.js +88 -0
  176. package/dist/core/validation/constants.d.ts +34 -0
  177. package/dist/core/validation/constants.js +40 -0
  178. package/dist/core/validation/types.d.ts +18 -0
  179. package/dist/core/validation/types.js +2 -0
  180. package/dist/core/validation/validator.d.ts +33 -0
  181. package/dist/core/validation/validator.js +409 -0
  182. package/dist/core/view.d.ts +8 -0
  183. package/dist/core/view.js +168 -0
  184. package/dist/index.d.ts +3 -0
  185. package/dist/index.js +3 -0
  186. package/dist/telemetry/config.d.ts +32 -0
  187. package/dist/telemetry/config.js +68 -0
  188. package/dist/telemetry/index.d.ts +31 -0
  189. package/dist/telemetry/index.js +103 -0
  190. package/dist/utils/file-system.d.ts +25 -0
  191. package/dist/utils/file-system.js +218 -0
  192. package/dist/utils/interactive.d.ts +18 -0
  193. package/dist/utils/interactive.js +21 -0
  194. package/dist/utils/item-discovery.d.ts +4 -0
  195. package/dist/utils/item-discovery.js +72 -0
  196. package/dist/utils/match.d.ts +3 -0
  197. package/dist/utils/match.js +22 -0
  198. package/dist/utils/shell-detection.d.ts +20 -0
  199. package/dist/utils/shell-detection.js +41 -0
  200. package/dist/utils/task-progress.d.ts +8 -0
  201. package/dist/utils/task-progress.js +36 -0
  202. package/package.json +82 -0
  203. package/scripts/postinstall.js +147 -0
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Spec Application Logic
3
+ *
4
+ * Extracted from ArchiveCommand to enable standalone spec application.
5
+ * Applies delta specs from a change to main specs without archiving.
6
+ */
7
+ export interface SpecUpdate {
8
+ source: string;
9
+ target: string;
10
+ exists: boolean;
11
+ }
12
+ export interface ApplyResult {
13
+ capability: string;
14
+ added: number;
15
+ modified: number;
16
+ removed: number;
17
+ renamed: number;
18
+ }
19
+ export interface SpecsApplyOutput {
20
+ changeName: string;
21
+ capabilities: ApplyResult[];
22
+ totals: {
23
+ added: number;
24
+ modified: number;
25
+ removed: number;
26
+ renamed: number;
27
+ };
28
+ noChanges: boolean;
29
+ }
30
+ /**
31
+ * Find all delta spec files that need to be applied from a change.
32
+ */
33
+ export declare function findSpecUpdates(changeDir: string, mainSpecsDir: string): Promise<SpecUpdate[]>;
34
+ /**
35
+ * Build an updated spec by applying delta operations.
36
+ * Returns the rebuilt content and counts of operations.
37
+ */
38
+ export declare function buildUpdatedSpec(update: SpecUpdate, changeName: string): Promise<{
39
+ rebuilt: string;
40
+ counts: {
41
+ added: number;
42
+ modified: number;
43
+ removed: number;
44
+ renamed: number;
45
+ };
46
+ }>;
47
+ /**
48
+ * Write an updated spec to disk.
49
+ */
50
+ export declare function writeUpdatedSpec(update: SpecUpdate, rebuilt: string, counts: {
51
+ added: number;
52
+ modified: number;
53
+ removed: number;
54
+ renamed: number;
55
+ }): Promise<void>;
56
+ /**
57
+ * Build a skeleton spec for new capabilities.
58
+ */
59
+ export declare function buildSpecSkeleton(specFolderName: string, changeName: string): string;
60
+ /**
61
+ * Apply all delta specs from a change to main specs.
62
+ *
63
+ * @param projectRoot - The project root directory
64
+ * @param changeName - The name of the change to apply
65
+ * @param options - Options for the operation
66
+ * @returns Result of the operation with counts
67
+ */
68
+ export declare function applySpecs(projectRoot: string, changeName: string, options?: {
69
+ dryRun?: boolean;
70
+ skipValidation?: boolean;
71
+ silent?: boolean;
72
+ }): Promise<SpecsApplyOutput>;
73
+ //# sourceMappingURL=specs-apply.d.ts.map
@@ -0,0 +1,384 @@
1
+ /**
2
+ * Spec Application Logic
3
+ *
4
+ * Extracted from ArchiveCommand to enable standalone spec application.
5
+ * Applies delta specs from a change to main specs without archiving.
6
+ */
7
+ import { promises as fs } from 'fs';
8
+ import path from 'path';
9
+ import chalk from 'chalk';
10
+ import { extractRequirementsSection, parseDeltaSpec, normalizeRequirementName, } from './parsers/requirement-blocks.js';
11
+ import { Validator } from './validation/validator.js';
12
+ // -----------------------------------------------------------------------------
13
+ // Public API
14
+ // -----------------------------------------------------------------------------
15
+ /**
16
+ * Find all delta spec files that need to be applied from a change.
17
+ */
18
+ export async function findSpecUpdates(changeDir, mainSpecsDir) {
19
+ const updates = [];
20
+ const changeSpecsDir = path.join(changeDir, 'specs');
21
+ try {
22
+ const entries = await fs.readdir(changeSpecsDir, { withFileTypes: true });
23
+ for (const entry of entries) {
24
+ if (entry.isDirectory()) {
25
+ const specFile = path.join(changeSpecsDir, entry.name, 'spec.md');
26
+ const targetFile = path.join(mainSpecsDir, entry.name, 'spec.md');
27
+ try {
28
+ await fs.access(specFile);
29
+ // Check if target exists
30
+ let exists = false;
31
+ try {
32
+ await fs.access(targetFile);
33
+ exists = true;
34
+ }
35
+ catch {
36
+ exists = false;
37
+ }
38
+ updates.push({
39
+ source: specFile,
40
+ target: targetFile,
41
+ exists,
42
+ });
43
+ }
44
+ catch {
45
+ // Source spec doesn't exist, skip
46
+ }
47
+ }
48
+ }
49
+ }
50
+ catch {
51
+ // No specs directory in change
52
+ }
53
+ return updates;
54
+ }
55
+ /**
56
+ * Build an updated spec by applying delta operations.
57
+ * Returns the rebuilt content and counts of operations.
58
+ */
59
+ export async function buildUpdatedSpec(update, changeName) {
60
+ // Read change spec content (delta-format expected)
61
+ const changeContent = await fs.readFile(update.source, 'utf-8');
62
+ // Parse deltas from the change spec file
63
+ const plan = parseDeltaSpec(changeContent);
64
+ const specName = path.basename(path.dirname(update.target));
65
+ // Pre-validate duplicates within sections
66
+ const addedNames = new Set();
67
+ for (const add of plan.added) {
68
+ const name = normalizeRequirementName(add.name);
69
+ if (addedNames.has(name)) {
70
+ throw new Error(`${specName} validation failed - duplicate requirement in ADDED for header "### Requirement: ${add.name}"`);
71
+ }
72
+ addedNames.add(name);
73
+ }
74
+ const modifiedNames = new Set();
75
+ for (const mod of plan.modified) {
76
+ const name = normalizeRequirementName(mod.name);
77
+ if (modifiedNames.has(name)) {
78
+ throw new Error(`${specName} validation failed - duplicate requirement in MODIFIED for header "### Requirement: ${mod.name}"`);
79
+ }
80
+ modifiedNames.add(name);
81
+ }
82
+ const removedNamesSet = new Set();
83
+ for (const rem of plan.removed) {
84
+ const name = normalizeRequirementName(rem);
85
+ if (removedNamesSet.has(name)) {
86
+ throw new Error(`${specName} validation failed - duplicate requirement in REMOVED for header "### Requirement: ${rem}"`);
87
+ }
88
+ removedNamesSet.add(name);
89
+ }
90
+ const renamedFromSet = new Set();
91
+ const renamedToSet = new Set();
92
+ for (const { from, to } of plan.renamed) {
93
+ const fromNorm = normalizeRequirementName(from);
94
+ const toNorm = normalizeRequirementName(to);
95
+ if (renamedFromSet.has(fromNorm)) {
96
+ throw new Error(`${specName} validation failed - duplicate FROM in RENAMED for header "### Requirement: ${from}"`);
97
+ }
98
+ if (renamedToSet.has(toNorm)) {
99
+ throw new Error(`${specName} validation failed - duplicate TO in RENAMED for header "### Requirement: ${to}"`);
100
+ }
101
+ renamedFromSet.add(fromNorm);
102
+ renamedToSet.add(toNorm);
103
+ }
104
+ // Pre-validate cross-section conflicts
105
+ const conflicts = [];
106
+ for (const n of modifiedNames) {
107
+ if (removedNamesSet.has(n))
108
+ conflicts.push({ name: n, a: 'MODIFIED', b: 'REMOVED' });
109
+ if (addedNames.has(n))
110
+ conflicts.push({ name: n, a: 'MODIFIED', b: 'ADDED' });
111
+ }
112
+ for (const n of addedNames) {
113
+ if (removedNamesSet.has(n))
114
+ conflicts.push({ name: n, a: 'ADDED', b: 'REMOVED' });
115
+ }
116
+ // Renamed interplay: MODIFIED must reference the NEW header, not FROM
117
+ for (const { from, to } of plan.renamed) {
118
+ const fromNorm = normalizeRequirementName(from);
119
+ const toNorm = normalizeRequirementName(to);
120
+ if (modifiedNames.has(fromNorm)) {
121
+ throw new Error(`${specName} validation failed - when a rename exists, MODIFIED must reference the NEW header "### Requirement: ${to}"`);
122
+ }
123
+ // Detect ADDED colliding with a RENAMED TO
124
+ if (addedNames.has(toNorm)) {
125
+ throw new Error(`${specName} validation failed - RENAMED TO header collides with ADDED for "### Requirement: ${to}"`);
126
+ }
127
+ }
128
+ if (conflicts.length > 0) {
129
+ const c = conflicts[0];
130
+ throw new Error(`${specName} validation failed - requirement present in multiple sections (${c.a} and ${c.b}) for header "### Requirement: ${c.name}"`);
131
+ }
132
+ const hasAnyDelta = plan.added.length + plan.modified.length + plan.removed.length + plan.renamed.length > 0;
133
+ if (!hasAnyDelta) {
134
+ throw new Error(`Delta parsing found no operations for ${path.basename(path.dirname(update.source))}. ` +
135
+ `Provide ADDED/MODIFIED/REMOVED/RENAMED sections in change spec.`);
136
+ }
137
+ // Load or create base target content
138
+ let targetContent;
139
+ let isNewSpec = false;
140
+ try {
141
+ targetContent = await fs.readFile(update.target, 'utf-8');
142
+ }
143
+ catch {
144
+ // Target spec does not exist; MODIFIED and RENAMED are not allowed for new specs
145
+ // REMOVED will be ignored with a warning since there's nothing to remove
146
+ if (plan.modified.length > 0 || plan.renamed.length > 0) {
147
+ throw new Error(`${specName}: target spec does not exist; only ADDED requirements are allowed for new specs. MODIFIED and RENAMED operations require an existing spec.`);
148
+ }
149
+ // Warn about REMOVED requirements being ignored for new specs
150
+ if (plan.removed.length > 0) {
151
+ console.log(chalk.yellow(`⚠️ Warning: ${specName} - ${plan.removed.length} REMOVED requirement(s) ignored for new spec (nothing to remove).`));
152
+ }
153
+ isNewSpec = true;
154
+ targetContent = buildSpecSkeleton(specName, changeName);
155
+ }
156
+ // Extract requirements section and build name->block map
157
+ const parts = extractRequirementsSection(targetContent);
158
+ const nameToBlock = new Map();
159
+ for (const block of parts.bodyBlocks) {
160
+ nameToBlock.set(normalizeRequirementName(block.name), block);
161
+ }
162
+ // Apply operations in order: RENAMED → REMOVED → MODIFIED → ADDED
163
+ // RENAMED
164
+ for (const r of plan.renamed) {
165
+ const from = normalizeRequirementName(r.from);
166
+ const to = normalizeRequirementName(r.to);
167
+ if (!nameToBlock.has(from)) {
168
+ throw new Error(`${specName} RENAMED failed for header "### Requirement: ${r.from}" - source not found`);
169
+ }
170
+ if (nameToBlock.has(to)) {
171
+ throw new Error(`${specName} RENAMED failed for header "### Requirement: ${r.to}" - target already exists`);
172
+ }
173
+ const block = nameToBlock.get(from);
174
+ const newHeader = `### Requirement: ${to}`;
175
+ const rawLines = block.raw.split('\n');
176
+ rawLines[0] = newHeader;
177
+ const renamedBlock = {
178
+ headerLine: newHeader,
179
+ name: to,
180
+ raw: rawLines.join('\n'),
181
+ };
182
+ nameToBlock.delete(from);
183
+ nameToBlock.set(to, renamedBlock);
184
+ }
185
+ // REMOVED
186
+ for (const name of plan.removed) {
187
+ const key = normalizeRequirementName(name);
188
+ if (!nameToBlock.has(key)) {
189
+ // For new specs, REMOVED requirements are already warned about and ignored
190
+ // For existing specs, missing requirements are an error
191
+ if (!isNewSpec) {
192
+ throw new Error(`${specName} REMOVED failed for header "### Requirement: ${name}" - not found`);
193
+ }
194
+ // Skip removal for new specs (already warned above)
195
+ continue;
196
+ }
197
+ nameToBlock.delete(key);
198
+ }
199
+ // MODIFIED
200
+ for (const mod of plan.modified) {
201
+ const key = normalizeRequirementName(mod.name);
202
+ if (!nameToBlock.has(key)) {
203
+ throw new Error(`${specName} MODIFIED failed for header "### Requirement: ${mod.name}" - not found`);
204
+ }
205
+ // Replace block with provided raw (ensure header line matches key)
206
+ const modHeaderMatch = mod.raw.split('\n')[0].match(/^###\s*Requirement:\s*(.+)\s*$/);
207
+ if (!modHeaderMatch || normalizeRequirementName(modHeaderMatch[1]) !== key) {
208
+ throw new Error(`${specName} MODIFIED failed for header "### Requirement: ${mod.name}" - header mismatch in content`);
209
+ }
210
+ nameToBlock.set(key, mod);
211
+ }
212
+ // ADDED
213
+ for (const add of plan.added) {
214
+ const key = normalizeRequirementName(add.name);
215
+ if (nameToBlock.has(key)) {
216
+ throw new Error(`${specName} ADDED failed for header "### Requirement: ${add.name}" - already exists`);
217
+ }
218
+ nameToBlock.set(key, add);
219
+ }
220
+ // Duplicates within resulting map are implicitly prevented by key uniqueness.
221
+ // Recompose requirements section preserving original ordering where possible
222
+ const keptOrder = [];
223
+ const seen = new Set();
224
+ for (const block of parts.bodyBlocks) {
225
+ const key = normalizeRequirementName(block.name);
226
+ const replacement = nameToBlock.get(key);
227
+ if (replacement) {
228
+ keptOrder.push(replacement);
229
+ seen.add(key);
230
+ }
231
+ }
232
+ // Append any newly added that were not in original order
233
+ for (const [key, block] of nameToBlock.entries()) {
234
+ if (!seen.has(key)) {
235
+ keptOrder.push(block);
236
+ }
237
+ }
238
+ const reqBody = [parts.preamble && parts.preamble.trim() ? parts.preamble.trimEnd() : '']
239
+ .filter(Boolean)
240
+ .concat(keptOrder.map((b) => b.raw))
241
+ .join('\n\n')
242
+ .trimEnd();
243
+ const rebuilt = [parts.before.trimEnd(), parts.headerLine, reqBody, parts.after]
244
+ .filter((s, idx) => !(idx === 0 && s === ''))
245
+ .join('\n')
246
+ .replace(/\n{3,}/g, '\n\n');
247
+ return {
248
+ rebuilt,
249
+ counts: {
250
+ added: plan.added.length,
251
+ modified: plan.modified.length,
252
+ removed: plan.removed.length,
253
+ renamed: plan.renamed.length,
254
+ },
255
+ };
256
+ }
257
+ /**
258
+ * Write an updated spec to disk.
259
+ */
260
+ export async function writeUpdatedSpec(update, rebuilt, counts) {
261
+ // Create target directory if needed
262
+ const targetDir = path.dirname(update.target);
263
+ await fs.mkdir(targetDir, { recursive: true });
264
+ await fs.writeFile(update.target, rebuilt);
265
+ const specName = path.basename(path.dirname(update.target));
266
+ console.log(`Applying changes to lightspec/specs/${specName}/spec.md:`);
267
+ if (counts.added)
268
+ console.log(` + ${counts.added} added`);
269
+ if (counts.modified)
270
+ console.log(` ~ ${counts.modified} modified`);
271
+ if (counts.removed)
272
+ console.log(` - ${counts.removed} removed`);
273
+ if (counts.renamed)
274
+ console.log(` → ${counts.renamed} renamed`);
275
+ }
276
+ /**
277
+ * Build a skeleton spec for new capabilities.
278
+ */
279
+ export function buildSpecSkeleton(specFolderName, changeName) {
280
+ const titleBase = specFolderName;
281
+ return `# ${titleBase} Specification\n\n## Purpose\nTBD - created by archiving change ${changeName}. Update Purpose after archive.\n\n## Requirements\n`;
282
+ }
283
+ /**
284
+ * Apply all delta specs from a change to main specs.
285
+ *
286
+ * @param projectRoot - The project root directory
287
+ * @param changeName - The name of the change to apply
288
+ * @param options - Options for the operation
289
+ * @returns Result of the operation with counts
290
+ */
291
+ export async function applySpecs(projectRoot, changeName, options = {}) {
292
+ const changeDir = path.join(projectRoot, 'lightspec', 'changes', changeName);
293
+ const mainSpecsDir = path.join(projectRoot, 'lightspec', 'specs');
294
+ // Verify change exists
295
+ try {
296
+ const stat = await fs.stat(changeDir);
297
+ if (!stat.isDirectory()) {
298
+ throw new Error(`Change '${changeName}' not found.`);
299
+ }
300
+ }
301
+ catch {
302
+ throw new Error(`Change '${changeName}' not found.`);
303
+ }
304
+ // Find specs to update
305
+ const specUpdates = await findSpecUpdates(changeDir, mainSpecsDir);
306
+ if (specUpdates.length === 0) {
307
+ return {
308
+ changeName,
309
+ capabilities: [],
310
+ totals: { added: 0, modified: 0, removed: 0, renamed: 0 },
311
+ noChanges: true,
312
+ };
313
+ }
314
+ // Prepare all updates first (validation pass, no writes)
315
+ const prepared = [];
316
+ for (const update of specUpdates) {
317
+ const built = await buildUpdatedSpec(update, changeName);
318
+ prepared.push({ update, rebuilt: built.rebuilt, counts: built.counts });
319
+ }
320
+ // Validate rebuilt specs unless validation is skipped
321
+ if (!options.skipValidation) {
322
+ const validator = new Validator();
323
+ for (const p of prepared) {
324
+ const specName = path.basename(path.dirname(p.update.target));
325
+ const report = await validator.validateSpecContent(specName, p.rebuilt);
326
+ if (!report.valid) {
327
+ const errors = report.issues
328
+ .filter((i) => i.level === 'ERROR')
329
+ .map((i) => ` ✗ ${i.message}`)
330
+ .join('\n');
331
+ throw new Error(`Validation errors in rebuilt spec for ${specName}:\n${errors}`);
332
+ }
333
+ }
334
+ }
335
+ // Build results
336
+ const capabilities = [];
337
+ const totals = { added: 0, modified: 0, removed: 0, renamed: 0 };
338
+ for (const p of prepared) {
339
+ const capability = path.basename(path.dirname(p.update.target));
340
+ if (!options.dryRun) {
341
+ // Write the updated spec
342
+ const targetDir = path.dirname(p.update.target);
343
+ await fs.mkdir(targetDir, { recursive: true });
344
+ await fs.writeFile(p.update.target, p.rebuilt);
345
+ if (!options.silent) {
346
+ console.log(`Applying changes to lightspec/specs/${capability}/spec.md:`);
347
+ if (p.counts.added)
348
+ console.log(` + ${p.counts.added} added`);
349
+ if (p.counts.modified)
350
+ console.log(` ~ ${p.counts.modified} modified`);
351
+ if (p.counts.removed)
352
+ console.log(` - ${p.counts.removed} removed`);
353
+ if (p.counts.renamed)
354
+ console.log(` → ${p.counts.renamed} renamed`);
355
+ }
356
+ }
357
+ else if (!options.silent) {
358
+ console.log(`Would apply changes to lightspec/specs/${capability}/spec.md:`);
359
+ if (p.counts.added)
360
+ console.log(` + ${p.counts.added} added`);
361
+ if (p.counts.modified)
362
+ console.log(` ~ ${p.counts.modified} modified`);
363
+ if (p.counts.removed)
364
+ console.log(` - ${p.counts.removed} removed`);
365
+ if (p.counts.renamed)
366
+ console.log(` → ${p.counts.renamed} renamed`);
367
+ }
368
+ capabilities.push({
369
+ capability,
370
+ ...p.counts,
371
+ });
372
+ totals.added += p.counts.added;
373
+ totals.modified += p.counts.modified;
374
+ totals.removed += p.counts.removed;
375
+ totals.renamed += p.counts.renamed;
376
+ }
377
+ return {
378
+ changeName,
379
+ capabilities,
380
+ totals,
381
+ noChanges: false,
382
+ };
383
+ }
384
+ //# sourceMappingURL=specs-apply.js.map
@@ -0,0 +1,7 @@
1
+ export declare const PALETTE: {
2
+ white: import("chalk").ChalkInstance;
3
+ lightGray: import("chalk").ChalkInstance;
4
+ midGray: import("chalk").ChalkInstance;
5
+ darkGray: import("chalk").ChalkInstance;
6
+ };
7
+ //# sourceMappingURL=palette.d.ts.map
@@ -0,0 +1,8 @@
1
+ import chalk from 'chalk';
2
+ export const PALETTE = {
3
+ white: chalk.hex('#f4f4f4'),
4
+ lightGray: chalk.hex('#c8c8c8'),
5
+ midGray: chalk.hex('#8a8a8a'),
6
+ darkGray: chalk.hex('#4a4a4a')
7
+ };
8
+ //# sourceMappingURL=palette.js.map
@@ -0,0 +1,2 @@
1
+ export declare const agentsRootStubTemplate = "# LightSpec Instructions\n\nThese instructions are for AI assistants working in this project.\n\nAlways open `@/lightspec/AGENTS.md` when the request:\n- Mentions planning or proposals (words like proposal, spec, change, plan)\n- Introduces new capabilities, breaking changes, architecture shifts, or big performance/security work\n- Sounds ambiguous and you need the authoritative spec before coding\n\nUse `@/lightspec/AGENTS.md` to learn:\n- How to create and apply change proposals\n- Spec format and conventions\n- Project structure and guidelines\n\nKeep this managed block so 'lightspec update' can refresh the instructions.\n";
2
+ //# sourceMappingURL=agents-root-stub.d.ts.map
@@ -0,0 +1,17 @@
1
+ export const agentsRootStubTemplate = `# LightSpec Instructions
2
+
3
+ These instructions are for AI assistants working in this project.
4
+
5
+ Always open \`@/lightspec/AGENTS.md\` when the request:
6
+ - Mentions planning or proposals (words like proposal, spec, change, plan)
7
+ - Introduces new capabilities, breaking changes, architecture shifts, or big performance/security work
8
+ - Sounds ambiguous and you need the authoritative spec before coding
9
+
10
+ Use \`@/lightspec/AGENTS.md\` to learn:
11
+ - How to create and apply change proposals
12
+ - Spec format and conventions
13
+ - Project structure and guidelines
14
+
15
+ Keep this managed block so 'lightspec update' can refresh the instructions.
16
+ `;
17
+ //# sourceMappingURL=agents-root-stub.js.map
@@ -0,0 +1,2 @@
1
+ export declare const agentsTemplate = "# LightSpec Instructions\n\nInstructions for AI coding assistants using LightSpec for spec-driven development.\n\n## TL;DR Quick Checklist\n\n- Search existing work: `lightspec spec list --long`, `lightspec list` (use `rg` only for full-text search)\n- Decide scope: new capability vs modify existing capability\n- Pick a unique `change-id`: kebab-case, verb-led (`add-`, `update-`, `remove-`, `refactor-`)\n- Scaffold: `proposal.md`, `tasks.md`, `design.md` (only if needed), and delta specs per affected capability\n- Write deltas: use `## ADDED|MODIFIED|REMOVED|RENAMED Requirements`; include at least one `#### Scenario:` per requirement\n- Validate: `lightspec validate [change-id] --strict --no-interactive` and fix issues\n- Request approval: Do not start implementation until proposal is approved\n\n## Three-Stage Workflow\n\n### Stage 1: Creating Changes\nCreate proposal when you need to:\n- Add features or functionality\n- Make breaking changes (API, schema)\n- Change architecture or patterns \n- Optimize performance (changes behavior)\n- Update security patterns\n\nTriggers (examples):\n- \"Help me create a change proposal\"\n- \"Help me plan a change\"\n- \"Help me create a proposal\"\n- \"I want to create a spec proposal\"\n- \"I want to create a spec\"\n\nLoose matching guidance:\n- Contains one of: `proposal`, `change`, `spec`\n- With one of: `create`, `plan`, `make`, `start`, `help`\n\nSkip proposal for:\n- Bug fixes (restore intended behavior)\n- Typos, formatting, comments\n- Dependency updates (non-breaking)\n- Configuration changes\n- Tests for existing behavior\n\n**Workflow**\n1. Review `lightspec/project.md`, `lightspec list`, and `lightspec list --specs` to understand current context.\n2. Choose a unique verb-led `change-id` and scaffold `proposal.md`, `tasks.md`, optional `design.md`, and spec deltas under `lightspec/changes/<id>/`.\n3. Draft spec deltas using `## ADDED|MODIFIED|REMOVED Requirements` with at least one `#### Scenario:` per requirement.\n4. Run `lightspec validate <id> --strict --no-interactive` and resolve any issues before sharing the proposal.\n\n### Stage 2: Implementing Changes\nTrack these steps as TODOs and complete them one by one.\n1. **Read proposal.md** - Understand what's being built\n2. **Read design.md** (if exists) - Review technical decisions\n3. **Read tasks.md** - Get implementation checklist\n4. **Implement tasks sequentially** - Complete in order\n5. **Confirm completion** - Ensure every item in `tasks.md` is finished before updating statuses\n6. **Update checklist** - After all work is done, set every task to `- [x]` so the list reflects reality\n7. **Approval gate** - Do not start implementation until the proposal is reviewed and approved\n\n### Stage 3: Archiving Changes\nAfter deployment, create separate PR to:\n- Move `changes/[name]/` \u2192 `changes/archive/YYYY-MM-DD-[name]/`\n- Update `specs/` if capabilities changed\n- Use `lightspec archive <change-id> --skip-specs --yes` for tooling-only changes (always pass the change ID explicitly)\n- Run `lightspec validate --strict --no-interactive` to confirm the archived change passes checks\n\n## Before Any Task\n\n**Context Checklist:**\n- [ ] Read relevant specs in `specs/[capability]/spec.md`\n- [ ] Check pending changes in `changes/` for conflicts\n- [ ] Read `lightspec/project.md` for conventions\n- [ ] Run `lightspec list` to see active changes\n- [ ] Run `lightspec list --specs` to see existing capabilities\n\n**Before Creating Specs:**\n- Always check if capability already exists\n- Prefer modifying existing specs over creating duplicates\n- Use `lightspec show [spec]` to review current state\n- If request is ambiguous, ask 1\u20132 clarifying questions before scaffolding\n\n### Search Guidance\n- Enumerate specs: `lightspec spec list --long` (or `--json` for scripts)\n- Enumerate changes: `lightspec list` (or `lightspec change list --json` - deprecated but available)\n- Show details:\n - Spec: `lightspec show <spec-id> --type spec` (use `--json` for filters)\n - Change: `lightspec show <change-id> --json --deltas-only`\n- Full-text search (use ripgrep): `rg -n \"Requirement:|Scenario:\" lightspec/specs`\n\n## Quick Start\n\n### CLI Commands\n\n```bash\n# Essential commands\nlightspec list # List active changes\nlightspec list --specs # List specifications\nlightspec show [item] # Display change or spec\nlightspec validate [item] # Validate changes or specs\nlightspec archive <change-id> [--yes|-y] # Archive after deployment (add --yes for non-interactive runs)\n\n# Project management\nlightspec init [path] # Initialize LightSpec\nlightspec update [path] # Update instruction files\n\n# Interactive mode\nlightspec show # Prompts for selection\nlightspec validate # Bulk validation mode\n\n# Debugging\nlightspec show [change] --json --deltas-only\nlightspec validate [change] --strict --no-interactive\n```\n\n### Command Flags\n\n- `--json` - Machine-readable output\n- `--type change|spec` - Disambiguate items\n- `--strict` - Comprehensive validation\n- `--no-interactive` - Disable prompts\n- `--skip-specs` - Archive without spec updates\n- `--yes`/`-y` - Skip confirmation prompts (non-interactive archive)\n\n## Directory Structure\n\n```\nlightspec/\n\u251C\u2500\u2500 project.md # Project conventions\n\u251C\u2500\u2500 specs/ # Current truth - what IS built\n\u2502 \u2514\u2500\u2500 [capability]/ # Single focused capability\n\u2502 \u251C\u2500\u2500 spec.md # Requirements and scenarios\n\u2502 \u2514\u2500\u2500 design.md # Technical patterns\n\u251C\u2500\u2500 changes/ # Proposals - what SHOULD change\n\u2502 \u251C\u2500\u2500 [change-name]/\n\u2502 \u2502 \u251C\u2500\u2500 proposal.md # Why, what, impact\n\u2502 \u2502 \u251C\u2500\u2500 tasks.md # Implementation checklist\n\u2502 \u2502 \u251C\u2500\u2500 design.md # Technical decisions (optional; see criteria)\n\u2502 \u2502 \u2514\u2500\u2500 specs/ # Delta changes\n\u2502 \u2502 \u2514\u2500\u2500 [capability]/\n\u2502 \u2502 \u2514\u2500\u2500 spec.md # ADDED/MODIFIED/REMOVED\n\u2502 \u2514\u2500\u2500 archive/ # Completed changes\n```\n\n## Creating Change Proposals\n\n### Decision Tree\n\n```\nNew request?\n\u251C\u2500 Bug fix restoring spec behavior? \u2192 Fix directly\n\u251C\u2500 Typo/format/comment? \u2192 Fix directly \n\u251C\u2500 New feature/capability? \u2192 Create proposal\n\u251C\u2500 Breaking change? \u2192 Create proposal\n\u251C\u2500 Architecture change? \u2192 Create proposal\n\u2514\u2500 Unclear? \u2192 Create proposal (safer)\n```\n\n### Proposal Structure\n\n1. **Create directory:** `changes/[change-id]/` (kebab-case, verb-led, unique)\n\n2. **Write proposal.md:**\n```markdown\n# Change: [Brief description of change]\n\n## Why\n[1-2 sentences on problem/opportunity]\n\n## What Changes\n- [Bullet list of changes]\n- [Mark breaking changes with **BREAKING**]\n\n## Impact\n- Affected specs: [list capabilities]\n- Affected code: [key files/systems]\n```\n\n3. **Create spec deltas:** `specs/[capability]/spec.md`\n```markdown\n## ADDED Requirements\n### Requirement: New Feature\nThe system SHALL provide...\n\n#### Scenario: Success case\n- **WHEN** user performs action\n- **THEN** expected result\n\n## MODIFIED Requirements\n### Requirement: Existing Feature\n[Complete modified requirement]\n\n## REMOVED Requirements\n### Requirement: Old Feature\n**Reason**: [Why removing]\n**Migration**: [How to handle]\n```\nIf multiple capabilities are affected, create multiple delta files under `changes/[change-id]/specs/<capability>/spec.md`\u2014one per capability.\n\n4. **Create tasks.md:**\n```markdown\n## 1. Implementation\n- [ ] 1.1 Create database schema\n- [ ] 1.2 Implement API endpoint\n- [ ] 1.3 Add frontend component\n- [ ] 1.4 Write tests\n```\n\n5. **Create design.md when needed:**\nCreate `design.md` if any of the following apply; otherwise omit it:\n- Cross-cutting change (multiple services/modules) or a new architectural pattern\n- New external dependency or significant data model changes\n- Security, performance, or migration complexity\n- Ambiguity that benefits from technical decisions before coding\n\nMinimal `design.md` skeleton:\n```markdown\n## Context\n[Background, constraints, stakeholders]\n\n## Goals / Non-Goals\n- Goals: [...]\n- Non-Goals: [...]\n\n## Decisions\n- Decision: [What and why]\n- Alternatives considered: [Options + rationale]\n\n## Risks / Trade-offs\n- [Risk] \u2192 Mitigation\n\n## Migration Plan\n[Steps, rollback]\n\n## Open Questions\n- [...]\n```\n\n## Spec File Format\n\n### Critical: Scenario Formatting\n\n**CORRECT** (use #### headers):\n```markdown\n#### Scenario: User login success\n- **WHEN** valid credentials provided\n- **THEN** return JWT token\n```\n\n**WRONG** (don't use bullets or bold):\n```markdown\n- **Scenario: User login** \u274C\n**Scenario**: User login \u274C\n### Scenario: User login \u274C\n```\n\nEvery requirement MUST have at least one scenario.\n\n### Requirement Wording\n- Use SHALL/MUST for normative requirements (avoid should/may unless intentionally non-normative)\n\n### Delta Operations\n\n- `## ADDED Requirements` - New capabilities\n- `## MODIFIED Requirements` - Changed behavior\n- `## REMOVED Requirements` - Deprecated features\n- `## RENAMED Requirements` - Name changes\n\nHeaders matched with `trim(header)` - whitespace ignored.\n\n#### When to use ADDED vs MODIFIED\n- ADDED: Introduces a new capability or sub-capability that can stand alone as a requirement. Prefer ADDED when the change is orthogonal (e.g., adding \"Slash Command Configuration\") rather than altering the semantics of an existing requirement.\n- MODIFIED: Changes the behavior, scope, or acceptance criteria of an existing requirement. Always paste the full, updated requirement content (header + all scenarios). The archiver will replace the entire requirement with what you provide here; partial deltas will drop previous details.\n- RENAMED: Use when only the name changes. If you also change behavior, use RENAMED (name) plus MODIFIED (content) referencing the new name.\n\nCommon pitfall: Using MODIFIED to add a new concern without including the previous text. This causes loss of detail at archive time. If you aren\u2019t explicitly changing the existing requirement, add a new requirement under ADDED instead.\n\nAuthoring a MODIFIED requirement correctly:\n1) Locate the existing requirement in `lightspec/specs/<capability>/spec.md`.\n2) Copy the entire requirement block (from `### Requirement: ...` through its scenarios).\n3) Paste it under `## MODIFIED Requirements` and edit to reflect the new behavior.\n4) Ensure the header text matches exactly (whitespace-insensitive) and keep at least one `#### Scenario:`.\n\nExample for RENAMED:\n```markdown\n## RENAMED Requirements\n- FROM: `### Requirement: Login`\n- TO: `### Requirement: User Authentication`\n```\n\n## Troubleshooting\n\n### Common Errors\n\n**\"Change must have at least one delta\"**\n- Check `changes/[name]/specs/` exists with .md files\n- Verify files have operation prefixes (## ADDED Requirements)\n\n**\"Requirement must have at least one scenario\"**\n- Check scenarios use `#### Scenario:` format (4 hashtags)\n- Don't use bullet points or bold for scenario headers\n\n**Silent scenario parsing failures**\n- Exact format required: `#### Scenario: Name`\n- Debug with: `lightspec show [change] --json --deltas-only`\n\n### Validation Tips\n\n```bash\n# Always use strict mode for comprehensive checks\nlightspec validate [change] --strict --no-interactive\n\n# Debug delta parsing\nlightspec show [change] --json | jq '.deltas'\n\n# Check specific requirement\nlightspec show [spec] --json -r 1\n```\n\n## Happy Path Script\n\n```bash\n# 1) Explore current state\nlightspec spec list --long\nlightspec list\n# Optional full-text search:\n# rg -n \"Requirement:|Scenario:\" lightspec/specs\n# rg -n \"^#|Requirement:\" lightspec/changes\n\n# 2) Choose change id and scaffold\nCHANGE=add-two-factor-auth\nmkdir -p lightspec/changes/$CHANGE/{specs/auth}\nprintf \"## Why\\n...\\n\\n## What Changes\\n- ...\\n\\n## Impact\\n- ...\\n\" > lightspec/changes/$CHANGE/proposal.md\nprintf \"## 1. Implementation\\n- [ ] 1.1 ...\\n\" > lightspec/changes/$CHANGE/tasks.md\n\n# 3) Add deltas (example)\ncat > lightspec/changes/$CHANGE/specs/auth/spec.md << 'EOF'\n## ADDED Requirements\n### Requirement: Two-Factor Authentication\nUsers MUST provide a second factor during login.\n\n#### Scenario: OTP required\n- **WHEN** valid credentials are provided\n- **THEN** an OTP challenge is required\nEOF\n\n# 4) Validate\nlightspec validate $CHANGE --strict --no-interactive\n```\n\n## Multi-Capability Example\n\n```\nlightspec/changes/add-2fa-notify/\n\u251C\u2500\u2500 proposal.md\n\u251C\u2500\u2500 tasks.md\n\u2514\u2500\u2500 specs/\n \u251C\u2500\u2500 auth/\n \u2502 \u2514\u2500\u2500 spec.md # ADDED: Two-Factor Authentication\n \u2514\u2500\u2500 notifications/\n \u2514\u2500\u2500 spec.md # ADDED: OTP email notification\n```\n\nauth/spec.md\n```markdown\n## ADDED Requirements\n### Requirement: Two-Factor Authentication\n...\n```\n\nnotifications/spec.md\n```markdown\n## ADDED Requirements\n### Requirement: OTP Email Notification\n...\n```\n\n## Best Practices\n\n### Simplicity First\n- Default to <100 lines of new code\n- Single-file implementations until proven insufficient\n- Avoid frameworks without clear justification\n- Choose boring, proven patterns\n\n### Complexity Triggers\nOnly add complexity with:\n- Performance data showing current solution too slow\n- Concrete scale requirements (>1000 users, >100MB data)\n- Multiple proven use cases requiring abstraction\n\n### Clear References\n- Use `file.ts:42` format for code locations\n- Reference specs as `specs/auth/spec.md`\n- Link related changes and PRs\n\n### Capability Naming\n- Use verb-noun: `user-auth`, `payment-capture`\n- Single purpose per capability\n- 10-minute understandability rule\n- Split if description needs \"AND\"\n\n### Change ID Naming\n- Use kebab-case, short and descriptive: `add-two-factor-auth`\n- Prefer verb-led prefixes: `add-`, `update-`, `remove-`, `refactor-`\n- Ensure uniqueness; if taken, append `-2`, `-3`, etc.\n\n## Tool Selection Guide\n\n| Task | Tool | Why |\n|------|------|-----|\n| Find files by pattern | Glob | Fast pattern matching |\n| Search code content | Grep | Optimized regex search |\n| Read specific files | Read | Direct file access |\n| Explore unknown scope | Task | Multi-step investigation |\n\n## Error Recovery\n\n### Change Conflicts\n1. Run `lightspec list` to see active changes\n2. Check for overlapping specs\n3. Coordinate with change owners\n4. Consider combining proposals\n\n### Validation Failures\n1. Run with `--strict` flag\n2. Check JSON output for details\n3. Verify spec file format\n4. Ensure scenarios properly formatted\n\n### Missing Context\n1. Read project.md first\n2. Check related specs\n3. Review recent archives\n4. Ask for clarification\n\n## Quick Reference\n\n### Stage Indicators\n- `changes/` - Proposed, not yet built\n- `specs/` - Built and deployed\n- `archive/` - Completed changes\n\n### File Purposes\n- `proposal.md` - Why and what\n- `tasks.md` - Implementation steps\n- `design.md` - Technical decisions\n- `spec.md` - Requirements and behavior\n\n### CLI Essentials\n```bash\nlightspec list # What's in progress?\nlightspec show [item] # View details\nlightspec validate --strict --no-interactive # Is it correct?\nlightspec archive <change-id> [--yes|-y] # Mark complete (add --yes for automation)\n```\n\nRemember: Specs are truth. Changes are proposals. Keep them in sync.\n";
2
+ //# sourceMappingURL=agents-template.d.ts.map