@fission-ai/openspec 0.3.0 → 0.5.0

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/README.md CHANGED
@@ -15,6 +15,7 @@
15
15
  <a href="https://nodejs.org/"><img alt="node version" src="https://img.shields.io/node/v/@fission-ai/openspec?style=flat-square" /></a>
16
16
  <a href="./LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square" /></a>
17
17
  <a href="https://conventionalcommits.org"><img alt="Conventional Commits" src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=flat-square" /></a>
18
+ <a href="https://discord.gg/saTQQGQZ"><img alt="Discord" src="https://img.shields.io/badge/Discord-Join%20the%20community-5865F2?logo=discord&logoColor=white&style=flat-square" /></a>
18
19
  </p>
19
20
 
20
21
  <p align="center">
@@ -22,7 +23,7 @@
22
23
  </p>
23
24
 
24
25
  <p align="center">
25
- Follow <a href="https://x.com/0xTab">@0xTab on X</a> for updates.
26
+ Follow <a href="https://x.com/0xTab">@0xTab on X</a> for updates · Join the <a href="https://discord.gg/saTQQGQZ">OpenSpec Discord</a> for help and questions.
26
27
  </p>
27
28
 
28
29
  # OpenSpec
@@ -82,13 +83,14 @@ These tools have built-in OpenSpec commands. Select the OpenSpec integration whe
82
83
  |------|----------|
83
84
  | **Claude Code** | `/openspec:proposal`, `/openspec:apply`, `/openspec:archive` |
84
85
  | **Cursor** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` |
86
+ | **OpenCode** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` |
85
87
 
86
88
  #### AGENTS.md Compatible
87
89
  These tools automatically read workflow instructions from `openspec/AGENTS.md`. Ask them to follow the OpenSpec workflow if they need a reminder. Learn more about the [AGENTS.md convention](https://agents.md/).
88
90
 
89
91
  | Tools |
90
92
  |-------|
91
- | Codex • Amp • Jules • OpenCode • Gemini CLI • GitHub Copilot • Others |
93
+ | Codex • Amp • Jules • Gemini CLI • GitHub Copilot • Others |
92
94
 
93
95
  ### Install & Initialize
94
96
 
@@ -183,13 +185,13 @@ You: Please archive the change
183
185
  (Shortcut for tools with slash commands: /openspec:archive add-profile-filters)
184
186
 
185
187
  AI: I'll archive the add-profile-filters change.
186
- *Runs: openspec archive add-profile-filters*
188
+ *Runs: openspec archive add-profile-filters --yes*
187
189
  ✓ Change archived successfully. Specs updated. Ready for the next feature!
188
190
  ```
189
191
 
190
192
  Or run the command yourself in terminal:
191
193
  ```bash
192
- $ openspec archive add-profile-filters # Archive the completed change
194
+ $ openspec archive add-profile-filters --yes # Archive the completed change without prompts
193
195
  ```
194
196
 
195
197
  **Note:** Tools with native slash commands (Claude Code, Cursor) can use the shortcuts shown. All other tools work with natural language requests to "create an OpenSpec proposal", "apply the OpenSpec change", or "archive the change".
@@ -201,7 +203,7 @@ openspec list # View active change folders
201
203
  openspec view # Interactive dashboard of specs and changes
202
204
  openspec show <change> # Display change details (proposal, tasks, spec updates)
203
205
  openspec validate <change> # Check spec formatting and structure
204
- openspec archive <change> # Move a completed change into archive/
206
+ openspec archive <change> [--yes|-y] # Move a completed change into archive/ (non-interactive with --yes)
205
207
  ```
206
208
 
207
209
  ## Example: How AI Creates OpenSpec Files
@@ -6,6 +6,7 @@ export const OPENSPEC_MARKERS = {
6
6
  export const AI_TOOLS = [
7
7
  { name: 'Claude Code (✅ OpenSpec custom slash commands available)', value: 'claude', available: true, successLabel: 'Claude Code' },
8
8
  { name: 'Cursor (✅ OpenSpec custom slash commands available)', value: 'cursor', available: true, successLabel: 'Cursor' },
9
+ { name: 'OpenCode (✅ OpenSpec custom slash commands available)', value: 'opencode', available: true, successLabel: 'OpenCode' },
9
10
  { name: 'AGENTS.md (works with Codex, Amp, Copilot, …)', value: 'agents', available: true, successLabel: 'your AGENTS.md-compatible assistant' }
10
11
  ];
11
12
  //# sourceMappingURL=config.js.map
@@ -0,0 +1,9 @@
1
+ import { SlashCommandConfigurator } from "./base.js";
2
+ import { SlashCommandId } from "../../templates/index.js";
3
+ export declare class OpenCodeSlashCommandConfigurator extends SlashCommandConfigurator {
4
+ readonly toolId = "opencode";
5
+ readonly isAvailable = true;
6
+ protected getRelativePath(id: SlashCommandId): string;
7
+ protected getFrontmatter(id: SlashCommandId): string | undefined;
8
+ }
9
+ //# sourceMappingURL=opencode.d.ts.map
@@ -0,0 +1,36 @@
1
+ import { SlashCommandConfigurator } from "./base.js";
2
+ const FILE_PATHS = {
3
+ proposal: ".opencode/command/openspec-proposal.md",
4
+ apply: ".opencode/command/openspec-apply.md",
5
+ archive: ".opencode/command/openspec-archive.md",
6
+ };
7
+ const FRONTMATTER = {
8
+ proposal: `---
9
+ agent: build
10
+ description: Scaffold a new OpenSpec change and validate strictly.
11
+ ---
12
+ The user has requested the following change proposal. Use the openspec instructions to create their change proposal.
13
+ <UserRequest>
14
+ $ARGUMENTS
15
+ </UserRequest>
16
+ `,
17
+ apply: `---
18
+ agent: build
19
+ description: Implement an approved OpenSpec change and keep tasks in sync.
20
+ ---`,
21
+ archive: `---
22
+ agent: build
23
+ description: Archive a deployed OpenSpec change and update specs.
24
+ ---`,
25
+ };
26
+ export class OpenCodeSlashCommandConfigurator extends SlashCommandConfigurator {
27
+ toolId = "opencode";
28
+ isAvailable = true;
29
+ getRelativePath(id) {
30
+ return FILE_PATHS[id];
31
+ }
32
+ getFrontmatter(id) {
33
+ return FRONTMATTER[id];
34
+ }
35
+ }
36
+ //# sourceMappingURL=opencode.js.map
@@ -1,12 +1,15 @@
1
1
  import { ClaudeSlashCommandConfigurator } from './claude.js';
2
2
  import { CursorSlashCommandConfigurator } from './cursor.js';
3
+ import { OpenCodeSlashCommandConfigurator } from './opencode.js';
3
4
  export class SlashCommandRegistry {
4
5
  static configurators = new Map();
5
6
  static {
6
7
  const claude = new ClaudeSlashCommandConfigurator();
7
8
  const cursor = new CursorSlashCommandConfigurator();
9
+ const opencode = new OpenCodeSlashCommandConfigurator();
8
10
  this.configurators.set(claude.toolId, claude);
9
11
  this.configurators.set(cursor.toolId, cursor);
12
+ this.configurators.set(opencode.toolId, opencode);
10
13
  }
11
14
  static register(configurator) {
12
15
  this.configurators.set(configurator.toolId, configurator);
@@ -33,7 +33,8 @@ export class JsonConverter {
33
33
  return JSON.stringify(jsonChange, null, 2);
34
34
  }
35
35
  extractNameFromPath(filePath) {
36
- const parts = filePath.split('/');
36
+ const normalizedPath = filePath.replaceAll('\\', '/');
37
+ const parts = normalizedPath.split('/');
37
38
  for (let i = parts.length - 1; i >= 0; i--) {
38
39
  if (parts[i] === 'specs' || parts[i] === 'changes') {
39
40
  if (i < parts.length - 1) {
@@ -41,8 +42,9 @@ export class JsonConverter {
41
42
  }
42
43
  }
43
44
  }
44
- const fileName = parts[parts.length - 1];
45
- return fileName.replace('.md', '');
45
+ const fileName = parts[parts.length - 1] ?? '';
46
+ const dotIndex = fileName.lastIndexOf('.');
47
+ return dotIndex > 0 ? fileName.slice(0, dotIndex) : fileName;
46
48
  }
47
49
  }
48
50
  //# sourceMappingURL=json-converter.js.map
package/dist/core/init.js CHANGED
@@ -1,72 +1,30 @@
1
1
  import path from 'path';
2
- import { createPrompt, isBackspaceKey, isDownKey, isEnterKey, isSpaceKey, isUpKey, useKeypress, usePagination, useState } from '@inquirer/core';
2
+ import { createPrompt, isBackspaceKey, isDownKey, isEnterKey, isSpaceKey, isUpKey, useKeypress, usePagination, useState, } from '@inquirer/core';
3
3
  import chalk from 'chalk';
4
4
  import ora from 'ora';
5
5
  import { FileSystemUtils } from '../utils/file-system.js';
6
6
  import { TemplateManager } from './templates/index.js';
7
7
  import { ToolRegistry } from './configurators/registry.js';
8
8
  import { SlashCommandRegistry } from './configurators/slash/registry.js';
9
- import { AI_TOOLS, OPENSPEC_DIR_NAME } from './config.js';
9
+ import { AI_TOOLS, OPENSPEC_DIR_NAME, } from './config.js';
10
10
  const PROGRESS_SPINNER = {
11
11
  interval: 80,
12
- frames: ['░░░', '▒░░', '▒▒░', '▒▒▒', '▓▒▒', '▓▓▒', '▓▓▓', '▒▓▓', '░▒▓']
12
+ frames: ['░░░', '▒░░', '▒▒░', '▒▒▒', '▓▒▒', '▓▓▒', '▓▓▓', '▒▓▓', '░▒▓'],
13
13
  };
14
14
  const PALETTE = {
15
15
  white: chalk.hex('#f4f4f4'),
16
16
  lightGray: chalk.hex('#c8c8c8'),
17
17
  midGray: chalk.hex('#8a8a8a'),
18
- darkGray: chalk.hex('#4a4a4a')
18
+ darkGray: chalk.hex('#4a4a4a'),
19
19
  };
20
20
  const LETTER_MAP = {
21
- O: [
22
- ' ████ ',
23
- '██ ██',
24
- '██ ██',
25
- '██ ██',
26
- ' ████ '
27
- ],
28
- P: [
29
- '█████ ',
30
- '██ ██',
31
- '█████ ',
32
- '██ ',
33
- '██ '
34
- ],
35
- E: [
36
- '██████',
37
- '██ ',
38
- '█████ ',
39
- '██ ',
40
- '██████'
41
- ],
42
- N: [
43
- '██ ██',
44
- '███ ██',
45
- '██ ███',
46
- '██ ██',
47
- '██ ██'
48
- ],
49
- S: [
50
- ' █████',
51
- '██ ',
52
- ' ████ ',
53
- ' ██',
54
- '█████ '
55
- ],
56
- C: [
57
- ' █████',
58
- '██ ',
59
- '██ ',
60
- '██ ',
61
- ' █████'
62
- ],
63
- ' ': [
64
- ' ',
65
- ' ',
66
- ' ',
67
- ' ',
68
- ' '
69
- ]
21
+ O: [' ████ ', '██ ██', '██ ██', '██ ██', ' ████ '],
22
+ P: ['█████ ', '██ ██', '█████ ', '██ ', '██ '],
23
+ E: ['██████', '██ ', '█████ ', '██ ', '██████'],
24
+ N: ['██ ██', '███ ██', '██ ███', '██ ██', '██ ██'],
25
+ S: [' █████', '██ ', ' ████ ', ' ██', '█████ '],
26
+ C: [' █████', '██ ', '██ ', '██ ', ' █████'],
27
+ ' ': [' ', ' ', ' ', ' ', ' '],
70
28
  };
71
29
  const sanitizeToolLabel = (raw) => raw.replace(/✅/gu, '✔').trim();
72
30
  const parseToolLabel = (raw) => {
@@ -77,7 +35,7 @@ const parseToolLabel = (raw) => {
77
35
  }
78
36
  return {
79
37
  primary: match[1].trim(),
80
- annotation: match[2].trim()
38
+ annotation: match[2].trim(),
81
39
  };
82
40
  };
83
41
  const toolSelectionWizard = createPrompt((config, done) => {
@@ -101,12 +59,16 @@ const toolSelectionWizard = createPrompt((config, done) => {
101
59
  loop: config.choices.length > 1,
102
60
  renderItem: ({ item, isActive }) => {
103
61
  const isSelected = selectedSet.has(item.value);
104
- const cursorSymbol = isActive ? PALETTE.white('›') : PALETTE.midGray(' ');
105
- const indicator = isSelected ? PALETTE.white('') : PALETTE.midGray('○');
62
+ const cursorSymbol = isActive
63
+ ? PALETTE.white('')
64
+ : PALETTE.midGray(' ');
65
+ const indicator = isSelected
66
+ ? PALETTE.white('◉')
67
+ : PALETTE.midGray('○');
106
68
  const nameColor = isActive ? PALETTE.white : PALETTE.midGray;
107
69
  const label = `${nameColor(item.label.primary)}${item.configured ? PALETTE.midGray(' (already configured)') : ''}`;
108
70
  return `${cursorSymbol} ${indicator} ${label}`;
109
- }
71
+ },
110
72
  });
111
73
  useKeypress((key) => {
112
74
  if (step === 'intro') {
@@ -247,13 +209,13 @@ export class InitCommand {
247
209
  }
248
210
  throw new Error('You must select at least one AI tool to configure.');
249
211
  }
250
- const availableTools = AI_TOOLS.filter(tool => tool.available);
212
+ const availableTools = AI_TOOLS.filter((tool) => tool.available);
251
213
  const selectedIds = new Set(config.aiTools);
252
- const selectedTools = availableTools.filter(tool => selectedIds.has(tool.value));
253
- const created = selectedTools.filter(tool => !existingToolStates[tool.value]);
254
- const refreshed = selectedTools.filter(tool => existingToolStates[tool.value]);
255
- const skippedExisting = availableTools.filter(tool => !selectedIds.has(tool.value) && existingToolStates[tool.value]);
256
- const skipped = availableTools.filter(tool => !selectedIds.has(tool.value) && !existingToolStates[tool.value]);
214
+ const selectedTools = availableTools.filter((tool) => selectedIds.has(tool.value));
215
+ const created = selectedTools.filter((tool) => !existingToolStates[tool.value]);
216
+ const refreshed = selectedTools.filter((tool) => existingToolStates[tool.value]);
217
+ const skippedExisting = availableTools.filter((tool) => !selectedIds.has(tool.value) && existingToolStates[tool.value]);
218
+ const skipped = availableTools.filter((tool) => !selectedIds.has(tool.value) && !existingToolStates[tool.value]);
257
219
  // Step 1: Create directory structure
258
220
  if (!extendMode) {
259
221
  const structureSpinner = this.startSpinner('Creating OpenSpec structure...');
@@ -261,7 +223,7 @@ export class InitCommand {
261
223
  await this.generateFiles(openspecPath, config);
262
224
  structureSpinner.stopAndPersist({
263
225
  symbol: PALETTE.white('▌'),
264
- text: PALETTE.white('OpenSpec structure created')
226
+ text: PALETTE.white('OpenSpec structure created'),
265
227
  });
266
228
  }
267
229
  else {
@@ -272,7 +234,7 @@ export class InitCommand {
272
234
  await this.configureAITools(projectPath, openspecDir, config.aiTools);
273
235
  toolSpinner.stopAndPersist({
274
236
  symbol: PALETTE.white('▌'),
275
- text: PALETTE.white('AI tools configured')
237
+ text: PALETTE.white('AI tools configured'),
276
238
  });
277
239
  // Success message
278
240
  this.displaySuccessMessage(selectedTools, created, refreshed, skippedExisting, skipped, extendMode);
@@ -280,7 +242,7 @@ export class InitCommand {
280
242
  async validate(projectPath, _openspecPath) {
281
243
  const extendMode = await FileSystemUtils.directoryExists(_openspecPath);
282
244
  // Check write permissions
283
- if (!await FileSystemUtils.ensureWritePermissions(projectPath)) {
245
+ if (!(await FileSystemUtils.ensureWritePermissions(projectPath))) {
284
246
  throw new Error(`Insufficient permissions to write to ${projectPath}`);
285
247
  }
286
248
  return extendMode;
@@ -290,7 +252,7 @@ export class InitCommand {
290
252
  return { aiTools: selectedTools };
291
253
  }
292
254
  async promptForAITools(existingTools, extendMode) {
293
- const availableTools = AI_TOOLS.filter(tool => tool.available);
255
+ const availableTools = AI_TOOLS.filter((tool) => tool.available);
294
256
  if (availableTools.length === 0) {
295
257
  return [];
296
258
  }
@@ -298,7 +260,9 @@ export class InitCommand {
298
260
  ? 'Which AI tools would you like to add or refresh?'
299
261
  : 'Which AI tools do you use?';
300
262
  const initialSelected = extendMode
301
- ? availableTools.filter(tool => existingTools[tool.value]).map(tool => tool.value)
263
+ ? availableTools
264
+ .filter((tool) => existingTools[tool.value])
265
+ .map((tool) => tool.value)
302
266
  : [];
303
267
  return this.prompt({
304
268
  extendMode,
@@ -306,9 +270,9 @@ export class InitCommand {
306
270
  choices: availableTools.map((tool) => ({
307
271
  value: tool.value,
308
272
  label: parseToolLabel(tool.name),
309
- configured: Boolean(existingTools[tool.value])
273
+ configured: Boolean(existingTools[tool.value]),
310
274
  })),
311
- initialSelected
275
+ initialSelected,
312
276
  });
313
277
  }
314
278
  async getExistingToolStates(projectPath) {
@@ -320,7 +284,8 @@ export class InitCommand {
320
284
  }
321
285
  async isToolConfigured(projectPath, toolId) {
322
286
  const configFile = ToolRegistry.get(toolId)?.configFileName;
323
- if (configFile && await FileSystemUtils.fileExists(path.join(projectPath, configFile)))
287
+ if (configFile &&
288
+ (await FileSystemUtils.fileExists(path.join(projectPath, configFile))))
324
289
  return true;
325
290
  const slashConfigurator = SlashCommandRegistry.get(toolId);
326
291
  if (!slashConfigurator)
@@ -336,7 +301,7 @@ export class InitCommand {
336
301
  openspecPath,
337
302
  path.join(openspecPath, 'specs'),
338
303
  path.join(openspecPath, 'changes'),
339
- path.join(openspecPath, 'changes', 'archive')
304
+ path.join(openspecPath, 'changes', 'archive'),
340
305
  ];
341
306
  for (const dir of directories) {
342
307
  await FileSystemUtils.createDirectory(dir);
@@ -376,10 +341,18 @@ export class InitCommand {
376
341
  console.log();
377
342
  console.log(PALETTE.lightGray('Tool summary:'));
378
343
  const summaryLines = [
379
- created.length ? `${PALETTE.white('▌')} ${PALETTE.white('Created:')} ${this.formatToolNames(created)}` : null,
380
- refreshed.length ? `${PALETTE.lightGray('▌')} ${PALETTE.lightGray('Refreshed:')} ${this.formatToolNames(refreshed)}` : null,
381
- skippedExisting.length ? `${PALETTE.midGray('▌')} ${PALETTE.midGray('Skipped (already configured):')} ${this.formatToolNames(skippedExisting)}` : null,
382
- skipped.length ? `${PALETTE.darkGray('▌')} ${PALETTE.darkGray('Skipped:')} ${this.formatToolNames(skipped)}` : null
344
+ created.length
345
+ ? `${PALETTE.white('▌')} ${PALETTE.white('Created:')} ${this.formatToolNames(created)}`
346
+ : null,
347
+ refreshed.length
348
+ ? `${PALETTE.lightGray('▌')} ${PALETTE.lightGray('Refreshed:')} ${this.formatToolNames(refreshed)}`
349
+ : null,
350
+ skippedExisting.length
351
+ ? `${PALETTE.midGray('▌')} ${PALETTE.midGray('Skipped (already configured):')} ${this.formatToolNames(skippedExisting)}`
352
+ : null,
353
+ skipped.length
354
+ ? `${PALETTE.darkGray('▌')} ${PALETTE.darkGray('Skipped:')} ${this.formatToolNames(skipped)}`
355
+ : null,
383
356
  ].filter((line) => Boolean(line));
384
357
  for (const line of summaryLines) {
385
358
  console.log(line);
@@ -427,7 +400,7 @@ export class InitCommand {
427
400
  PALETTE.lightGray,
428
401
  PALETTE.midGray,
429
402
  PALETTE.lightGray,
430
- PALETTE.white
403
+ PALETTE.white,
431
404
  ];
432
405
  console.log();
433
406
  rows.forEach((row, index) => {
@@ -442,7 +415,7 @@ export class InitCommand {
442
415
  text,
443
416
  stream: process.stdout,
444
417
  color: 'gray',
445
- spinner: PROGRESS_SPINNER
418
+ spinner: PROGRESS_SPINNER,
446
419
  }).start();
447
420
  }
448
421
  }
@@ -124,7 +124,7 @@ export class ChangeParser extends MarkdownParser {
124
124
  }
125
125
  parseRenames(content) {
126
126
  const renames = [];
127
- const lines = content.split('\n');
127
+ const lines = ChangeParser.normalizeContent(content).split('\n');
128
128
  let currentRename = {};
129
129
  for (const line of lines) {
130
130
  const fromMatch = line.match(/^\s*-?\s*FROM:\s*`?###\s*Requirement:\s*(.+?)`?\s*$/);
@@ -146,7 +146,8 @@ export class ChangeParser extends MarkdownParser {
146
146
  return renames;
147
147
  }
148
148
  parseSectionsFromContent(content) {
149
- const lines = content.split('\n');
149
+ const normalizedContent = ChangeParser.normalizeContent(content);
150
+ const lines = normalizedContent.split('\n');
150
151
  const sections = [];
151
152
  const stack = [];
152
153
  for (let i = 0; i < lines.length; i++) {
@@ -9,6 +9,7 @@ export declare class MarkdownParser {
9
9
  private lines;
10
10
  private currentLine;
11
11
  constructor(content: string);
12
+ protected static normalizeContent(content: string): string;
12
13
  parseSpec(name: string): Spec;
13
14
  parseChange(name: string): Change;
14
15
  protected parseSections(): Section[];
@@ -2,9 +2,13 @@ export class MarkdownParser {
2
2
  lines;
3
3
  currentLine;
4
4
  constructor(content) {
5
- this.lines = content.split('\n');
5
+ const normalized = MarkdownParser.normalizeContent(content);
6
+ this.lines = normalized.split('\n');
6
7
  this.currentLine = 0;
7
8
  }
9
+ static normalizeContent(content) {
10
+ return content.replace(/\r\n?/g, '\n');
11
+ }
8
12
  parseSpec(name) {
9
13
  const sections = this.parseSections();
10
14
  const purpose = this.findSection(sections, 'Purpose')?.content || '';
@@ -6,7 +6,8 @@ const REQUIREMENT_HEADER_REGEX = /^###\s*Requirement:\s*(.+)\s*$/;
6
6
  * Extracts the Requirements section from a spec file and parses requirement blocks.
7
7
  */
8
8
  export function extractRequirementsSection(content) {
9
- const lines = content.split('\n');
9
+ const normalized = normalizeLineEndings(content);
10
+ const lines = normalized.split('\n');
10
11
  const reqHeaderIndex = lines.findIndex(l => /^##\s+Requirements\s*$/i.test(l));
11
12
  if (reqHeaderIndex === -1) {
12
13
  // No requirements section; create an empty one at the end
@@ -70,11 +71,15 @@ export function extractRequirementsSection(content) {
70
71
  after: after.startsWith('\n') ? after : '\n' + after,
71
72
  };
72
73
  }
74
+ function normalizeLineEndings(content) {
75
+ return content.replace(/\r\n?/g, '\n');
76
+ }
73
77
  /**
74
78
  * Parse a delta-formatted spec change file content into a DeltaPlan with raw blocks.
75
79
  */
76
80
  export function parseDeltaSpec(content) {
77
- const sections = splitTopLevelSections(content);
81
+ const normalized = normalizeLineEndings(content);
82
+ const sections = splitTopLevelSections(normalized);
78
83
  const added = parseRequirementBlocksFromSection(sections['ADDED Requirements'] || '');
79
84
  const modified = parseRequirementBlocksFromSection(sections['MODIFIED Requirements'] || '');
80
85
  const removedNames = parseRemovedNames(sections['REMOVED Requirements'] || '');
@@ -103,7 +108,7 @@ function splitTopLevelSections(content) {
103
108
  function parseRequirementBlocksFromSection(sectionBody) {
104
109
  if (!sectionBody)
105
110
  return [];
106
- const lines = sectionBody.split('\n');
111
+ const lines = normalizeLineEndings(sectionBody).split('\n');
107
112
  const blocks = [];
108
113
  let i = 0;
109
114
  while (i < lines.length) {
@@ -133,7 +138,7 @@ function parseRemovedNames(sectionBody) {
133
138
  if (!sectionBody)
134
139
  return [];
135
140
  const names = [];
136
- const lines = sectionBody.split('\n');
141
+ const lines = normalizeLineEndings(sectionBody).split('\n');
137
142
  for (const line of lines) {
138
143
  const m = line.match(REQUIREMENT_HEADER_REGEX);
139
144
  if (m) {
@@ -152,7 +157,7 @@ function parseRenamedPairs(sectionBody) {
152
157
  if (!sectionBody)
153
158
  return [];
154
159
  const pairs = [];
155
- const lines = sectionBody.split('\n');
160
+ const lines = normalizeLineEndings(sectionBody).split('\n');
156
161
  let current = {};
157
162
  for (const line of lines) {
158
163
  const fromMatch = line.match(/^\s*-?\s*FROM:\s*`?###\s*Requirement:\s*(.+?)`?\s*$/);
@@ -1,2 +1,2 @@
1
- export declare const agentsTemplate = "# OpenSpec Instructions\n\nInstructions for AI coding assistants using OpenSpec for spec-driven development.\n\n## TL;DR Quick Checklist\n\n- Search existing work: `openspec spec list --long`, `openspec 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: `openspec validate [change-id] --strict` 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 `openspec/project.md`, `openspec list`, and `openspec 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 `openspec/changes/<id>/`.\n3. Draft spec deltas using `## ADDED|MODIFIED|REMOVED Requirements` with at least one `#### Scenario:` per requirement.\n4. Run `openspec validate <id> --strict` and resolve any issues before sharing the proposal.\n\n### Stage 2: Implementing Changes\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. **Mark complete immediately** - Update `- [x]` after each task\n6. **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 `openspec archive [change] --skip-specs` for tooling-only changes\n- Run `openspec validate --strict` 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 `openspec/project.md` for conventions\n- [ ] Run `openspec list` to see active changes\n- [ ] Run `openspec 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 `openspec 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: `openspec spec list --long` (or `--json` for scripts)\n- Enumerate changes: `openspec list` (or `openspec change list --json` - deprecated but available)\n- Show details:\n - Spec: `openspec show <spec-id> --type spec` (use `--json` for filters)\n - Change: `openspec show <change-id> --json --deltas-only`\n- Full-text search (use ripgrep): `rg -n \"Requirement:|Scenario:\" openspec/specs`\n\n## Quick Start\n\n### CLI Commands\n\n```bash\n# Essential commands\nopenspec list # List active changes\nopenspec list --specs # List specifications\nopenspec show [item] # Display change or spec\nopenspec diff [change] # Show spec differences\nopenspec validate [item] # Validate changes or specs\nopenspec archive [change] # Archive after deployment\n\n# Project management\nopenspec init [path] # Initialize OpenSpec\nopenspec update [path] # Update instruction files\n\n# Interactive mode\nopenspec show # Prompts for selection\nopenspec validate # Bulk validation mode\n\n# Debugging\nopenspec show [change] --json --deltas-only\nopenspec validate [change] --strict\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\n## Directory Structure\n\n```\nopenspec/\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## 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 `openspec/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: `openspec show [change] --json --deltas-only`\n\n### Validation Tips\n\n```bash\n# Always use strict mode for comprehensive checks\nopenspec validate [change] --strict\n\n# Debug delta parsing\nopenspec show [change] --json | jq '.deltas'\n\n# Check specific requirement\nopenspec show [spec] --json -r 1\n```\n\n## Happy Path Script\n\n```bash\n# 1) Explore current state\nopenspec spec list --long\nopenspec list\n# Optional full-text search:\n# rg -n \"Requirement:|Scenario:\" openspec/specs\n# rg -n \"^#|Requirement:\" openspec/changes\n\n# 2) Choose change id and scaffold\nCHANGE=add-two-factor-auth\nmkdir -p openspec/changes/$CHANGE/{specs/auth}\nprintf \"## Why\\n...\\n\\n## What Changes\\n- ...\\n\\n## Impact\\n- ...\\n\" > openspec/changes/$CHANGE/proposal.md\nprintf \"## 1. Implementation\\n- [ ] 1.1 ...\\n\" > openspec/changes/$CHANGE/tasks.md\n\n# 3) Add deltas (example)\ncat > openspec/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\nopenspec validate $CHANGE --strict\n```\n\n## Multi-Capability Example\n\n```\nopenspec/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 `openspec 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\nopenspec list # What's in progress?\nopenspec show [item] # View details\nopenspec diff [change] # What's changing?\nopenspec validate --strict # Is it correct?\nopenspec archive [change] # Mark complete\n```\n\nRemember: Specs are truth. Changes are proposals. Keep them in sync.\n";
1
+ export declare const agentsTemplate = "# OpenSpec Instructions\n\nInstructions for AI coding assistants using OpenSpec for spec-driven development.\n\n## TL;DR Quick Checklist\n\n- Search existing work: `openspec spec list --long`, `openspec 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: `openspec validate [change-id] --strict` 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 `openspec/project.md`, `openspec list`, and `openspec 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 `openspec/changes/<id>/`.\n3. Draft spec deltas using `## ADDED|MODIFIED|REMOVED Requirements` with at least one `#### Scenario:` per requirement.\n4. Run `openspec validate <id> --strict` 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 `openspec archive [change] --skip-specs --yes` for tooling-only changes\n- Run `openspec validate --strict` 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 `openspec/project.md` for conventions\n- [ ] Run `openspec list` to see active changes\n- [ ] Run `openspec 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 `openspec 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: `openspec spec list --long` (or `--json` for scripts)\n- Enumerate changes: `openspec list` (or `openspec change list --json` - deprecated but available)\n- Show details:\n - Spec: `openspec show <spec-id> --type spec` (use `--json` for filters)\n - Change: `openspec show <change-id> --json --deltas-only`\n- Full-text search (use ripgrep): `rg -n \"Requirement:|Scenario:\" openspec/specs`\n\n## Quick Start\n\n### CLI Commands\n\n```bash\n# Essential commands\nopenspec list # List active changes\nopenspec list --specs # List specifications\nopenspec show [item] # Display change or spec\nopenspec diff [change] # Show spec differences\nopenspec validate [item] # Validate changes or specs\nopenspec archive [change] [--yes|-y] # Archive after deployment (add --yes for non-interactive runs)\n\n# Project management\nopenspec init [path] # Initialize OpenSpec\nopenspec update [path] # Update instruction files\n\n# Interactive mode\nopenspec show # Prompts for selection\nopenspec validate # Bulk validation mode\n\n# Debugging\nopenspec show [change] --json --deltas-only\nopenspec validate [change] --strict\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```\nopenspec/\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## 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 `openspec/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: `openspec show [change] --json --deltas-only`\n\n### Validation Tips\n\n```bash\n# Always use strict mode for comprehensive checks\nopenspec validate [change] --strict\n\n# Debug delta parsing\nopenspec show [change] --json | jq '.deltas'\n\n# Check specific requirement\nopenspec show [spec] --json -r 1\n```\n\n## Happy Path Script\n\n```bash\n# 1) Explore current state\nopenspec spec list --long\nopenspec list\n# Optional full-text search:\n# rg -n \"Requirement:|Scenario:\" openspec/specs\n# rg -n \"^#|Requirement:\" openspec/changes\n\n# 2) Choose change id and scaffold\nCHANGE=add-two-factor-auth\nmkdir -p openspec/changes/$CHANGE/{specs/auth}\nprintf \"## Why\\n...\\n\\n## What Changes\\n- ...\\n\\n## Impact\\n- ...\\n\" > openspec/changes/$CHANGE/proposal.md\nprintf \"## 1. Implementation\\n- [ ] 1.1 ...\\n\" > openspec/changes/$CHANGE/tasks.md\n\n# 3) Add deltas (example)\ncat > openspec/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\nopenspec validate $CHANGE --strict\n```\n\n## Multi-Capability Example\n\n```\nopenspec/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 `openspec 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\nopenspec list # What's in progress?\nopenspec show [item] # View details\nopenspec diff [change] # What's changing?\nopenspec validate --strict # Is it correct?\nopenspec archive [change] [--yes|-y] # Mark complete (add --yes for automation)\n```\n\nRemember: Specs are truth. Changes are proposals. Keep them in sync.\n";
2
2
  //# sourceMappingURL=agents-template.d.ts.map
@@ -47,18 +47,20 @@ Skip proposal for:
47
47
  4. Run \`openspec validate <id> --strict\` and resolve any issues before sharing the proposal.
48
48
 
49
49
  ### Stage 2: Implementing Changes
50
+ Track these steps as TODOs and complete them one by one.
50
51
  1. **Read proposal.md** - Understand what's being built
51
52
  2. **Read design.md** (if exists) - Review technical decisions
52
53
  3. **Read tasks.md** - Get implementation checklist
53
54
  4. **Implement tasks sequentially** - Complete in order
54
- 5. **Mark complete immediately** - Update \`- [x]\` after each task
55
- 6. **Approval gate** - Do not start implementation until the proposal is reviewed and approved
55
+ 5. **Confirm completion** - Ensure every item in \`tasks.md\` is finished before updating statuses
56
+ 6. **Update checklist** - After all work is done, set every task to \`- [x]\` so the list reflects reality
57
+ 7. **Approval gate** - Do not start implementation until the proposal is reviewed and approved
56
58
 
57
59
  ### Stage 3: Archiving Changes
58
60
  After deployment, create separate PR to:
59
61
  - Move \`changes/[name]/\` → \`changes/archive/YYYY-MM-DD-[name]/\`
60
62
  - Update \`specs/\` if capabilities changed
61
- - Use \`openspec archive [change] --skip-specs\` for tooling-only changes
63
+ - Use \`openspec archive [change] --skip-specs --yes\` for tooling-only changes
62
64
  - Run \`openspec validate --strict\` to confirm the archived change passes checks
63
65
 
64
66
  ## Before Any Task
@@ -95,7 +97,7 @@ openspec list --specs # List specifications
95
97
  openspec show [item] # Display change or spec
96
98
  openspec diff [change] # Show spec differences
97
99
  openspec validate [item] # Validate changes or specs
98
- openspec archive [change] # Archive after deployment
100
+ openspec archive [change] [--yes|-y] # Archive after deployment (add --yes for non-interactive runs)
99
101
 
100
102
  # Project management
101
103
  openspec init [path] # Initialize OpenSpec
@@ -117,6 +119,7 @@ openspec validate [change] --strict
117
119
  - \`--strict\` - Comprehensive validation
118
120
  - \`--no-interactive\` - Disable prompts
119
121
  - \`--skip-specs\` - Archive without spec updates
122
+ - \`--yes\`/\`-y\` - Skip confirmation prompts (non-interactive archive)
120
123
 
121
124
  ## Directory Structure
122
125
 
@@ -447,7 +450,7 @@ openspec list # What's in progress?
447
450
  openspec show [item] # View details
448
451
  openspec diff [change] # What's changing?
449
452
  openspec validate --strict # Is it correct?
450
- openspec archive [change] # Mark complete
453
+ openspec archive [change] [--yes|-y] # Mark complete (add --yes for automation)
451
454
  \`\`\`
452
455
 
453
456
  Remember: Specs are truth. Changes are proposals. Keep them in sync.
@@ -16,15 +16,17 @@ const proposalReferences = `**Reference**
16
16
  - Search existing requirements with \`rg -n "Requirement:|Scenario:" openspec/specs\` before writing new ones.
17
17
  - Explore the codebase with \`rg <keyword>\`, \`ls\`, or direct file reads so proposals align with current implementation realities.`;
18
18
  const applySteps = `**Steps**
19
+ Track these steps as TODOs and complete them one by one.
19
20
  1. Read \`changes/<id>/proposal.md\`, \`design.md\` (if present), and \`tasks.md\` to confirm scope and acceptance criteria.
20
21
  2. Work through tasks sequentially, keeping edits minimal and focused on the requested change.
21
- 3. Mark each task \`- [x]\` immediately after completing it to keep the checklist in sync.
22
- 4. Reference \`openspec list\` or \`openspec show <item>\` when additional context is required.`;
22
+ 3. Confirm completion before updating statuses—make sure every item in \`tasks.md\` is finished.
23
+ 4. Update the checklist after all work is done so each task is marked \`- [x]\` and reflects reality.
24
+ 5. Reference \`openspec list\` or \`openspec show <item>\` when additional context is required.`;
23
25
  const applyReferences = `**Reference**
24
26
  - Use \`openspec show <id> --json --deltas-only\` if you need additional context from the proposal while implementing.`;
25
27
  const archiveSteps = `**Steps**
26
28
  1. Identify the requested change ID (via the prompt or \`openspec list\`).
27
- 2. Run \`openspec archive <id>\` to let the CLI move the change and apply spec updates (use \`--skip-specs\` only for tooling-only work).
29
+ 2. Run \`openspec archive <id> --yes\` to let the CLI move the change and apply spec updates without prompts (use \`--skip-specs\` only for tooling-only work).
28
30
  3. Review the command output to confirm the target specs were updated and the change landed in \`changes/archive/\`.
29
31
  4. Validate with \`openspec validate --strict\` and inspect with \`openspec show <id>\` if anything looks off.`;
30
32
  const archiveReferences = `**Reference**
@@ -297,7 +297,8 @@ export class Validator {
297
297
  return msg;
298
298
  }
299
299
  extractNameFromPath(filePath) {
300
- const parts = filePath.split('/');
300
+ const normalizedPath = filePath.replaceAll('\\', '/');
301
+ const parts = normalizedPath.split('/');
301
302
  // Look for the directory name after 'specs' or 'changes'
302
303
  for (let i = parts.length - 1; i >= 0; i--) {
303
304
  if (parts[i] === 'specs' || parts[i] === 'changes') {
@@ -307,8 +308,9 @@ export class Validator {
307
308
  }
308
309
  }
309
310
  // Fallback to filename without extension if not in expected structure
310
- const fileName = parts[parts.length - 1];
311
- return fileName.replace('.md', '');
311
+ const fileName = parts[parts.length - 1] ?? '';
312
+ const dotIndex = fileName.lastIndexOf('.');
313
+ return dotIndex > 0 ? fileName.slice(0, dotIndex) : fileName;
312
314
  }
313
315
  createReport(issues) {
314
316
  const errors = issues.filter(i => i.level === 'ERROR').length;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fission-ai/openspec",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "AI-native system for spec-driven development",
5
5
  "keywords": [
6
6
  "openspec",
@@ -18,8 +18,7 @@
18
18
  "author": "OpenSpec Contributors",
19
19
  "type": "module",
20
20
  "publishConfig": {
21
- "access": "public",
22
- "tag": "next"
21
+ "access": "public"
23
22
  },
24
23
  "exports": {
25
24
  ".": {