@fission-ai/openspec 0.22.0 → 0.23.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.
@@ -14,9 +14,9 @@ import path from 'path';
14
14
  import * as fs from 'fs';
15
15
  import { loadChangeContext, formatChangeStatus, generateInstructions, listSchemas, listSchemasWithInfo, getSchemaDir, resolveSchema, ArtifactGraph, } from '../core/artifact-graph/index.js';
16
16
  import { createChange, validateChangeName } from '../utils/change-utils.js';
17
- import { getExploreSkillTemplate, getNewChangeSkillTemplate, getContinueChangeSkillTemplate, getApplyChangeSkillTemplate, getFfChangeSkillTemplate, getSyncSpecsSkillTemplate, getArchiveChangeSkillTemplate, getVerifyChangeSkillTemplate, getOpsxExploreCommandTemplate, getOpsxNewCommandTemplate, getOpsxContinueCommandTemplate, getOpsxApplyCommandTemplate, getOpsxFfCommandTemplate, getOpsxSyncCommandTemplate, getOpsxArchiveCommandTemplate, getOpsxVerifyCommandTemplate } from '../core/templates/skill-templates.js';
17
+ import { getExploreSkillTemplate, getNewChangeSkillTemplate, getContinueChangeSkillTemplate, getApplyChangeSkillTemplate, getFfChangeSkillTemplate, getSyncSpecsSkillTemplate, getArchiveChangeSkillTemplate, getBulkArchiveChangeSkillTemplate, getVerifyChangeSkillTemplate, getOpsxExploreCommandTemplate, getOpsxNewCommandTemplate, getOpsxContinueCommandTemplate, getOpsxApplyCommandTemplate, getOpsxFfCommandTemplate, getOpsxSyncCommandTemplate, getOpsxArchiveCommandTemplate, getOpsxBulkArchiveCommandTemplate, getOpsxVerifyCommandTemplate } from '../core/templates/skill-templates.js';
18
18
  import { FileSystemUtils } from '../utils/file-system.js';
19
- import { promptForConfig, serializeConfig, isExitPromptError } from '../core/config-prompts.js';
19
+ import { serializeConfig } from '../core/config-prompts.js';
20
20
  const DEFAULT_SCHEMA = 'spec-driven';
21
21
  /**
22
22
  * Checks if color output is disabled via NO_COLOR env or --no-color flag.
@@ -601,6 +601,7 @@ async function artifactExperimentalSetupCommand() {
601
601
  const ffChangeSkill = getFfChangeSkillTemplate();
602
602
  const syncSpecsSkill = getSyncSpecsSkillTemplate();
603
603
  const archiveChangeSkill = getArchiveChangeSkillTemplate();
604
+ const bulkArchiveChangeSkill = getBulkArchiveChangeSkillTemplate();
604
605
  const verifyChangeSkill = getVerifyChangeSkillTemplate();
605
606
  // Get command templates
606
607
  const exploreCommand = getOpsxExploreCommandTemplate();
@@ -610,6 +611,7 @@ async function artifactExperimentalSetupCommand() {
610
611
  const ffCommand = getOpsxFfCommandTemplate();
611
612
  const syncCommand = getOpsxSyncCommandTemplate();
612
613
  const archiveCommand = getOpsxArchiveCommandTemplate();
614
+ const bulkArchiveCommand = getOpsxBulkArchiveCommandTemplate();
613
615
  const verifyCommand = getOpsxVerifyCommandTemplate();
614
616
  // Create skill directories and SKILL.md files
615
617
  const skills = [
@@ -620,6 +622,7 @@ async function artifactExperimentalSetupCommand() {
620
622
  { template: ffChangeSkill, dirName: 'openspec-ff-change' },
621
623
  { template: syncSpecsSkill, dirName: 'openspec-sync-specs' },
622
624
  { template: archiveChangeSkill, dirName: 'openspec-archive-change' },
625
+ { template: bulkArchiveChangeSkill, dirName: 'openspec-bulk-archive-change' },
623
626
  { template: verifyChangeSkill, dirName: 'openspec-verify-change' },
624
627
  ];
625
628
  const createdSkillFiles = [];
@@ -647,6 +650,7 @@ ${template.instructions}
647
650
  { template: ffCommand, fileName: 'ff.md' },
648
651
  { template: syncCommand, fileName: 'sync.md' },
649
652
  { template: archiveCommand, fileName: 'archive.md' },
653
+ { template: bulkArchiveCommand, fileName: 'bulk-archive.md' },
650
654
  { template: verifyCommand, fileName: 'verify.md' },
651
655
  ];
652
656
  const createdCommandFiles = [];
@@ -710,85 +714,35 @@ ${template.content}
710
714
  console.log();
711
715
  }
712
716
  else {
713
- // Prompt for config creation
717
+ // Create config with default schema
718
+ const yamlContent = serializeConfig({ schema: DEFAULT_SCHEMA });
714
719
  try {
715
- const configResult = await promptForConfig(projectRoot);
716
- if (configResult.createConfig && configResult.schema) {
717
- // Build config object
718
- const config = {
719
- schema: configResult.schema,
720
- context: configResult.context,
721
- rules: configResult.rules,
722
- };
723
- // Serialize to YAML
724
- const yamlContent = serializeConfig(config);
725
- // Write config file
726
- try {
727
- await FileSystemUtils.writeFile(configPath, yamlContent);
728
- console.log();
729
- console.log(chalk.green('✓ Created openspec/config.yaml'));
730
- console.log();
731
- console.log('━'.repeat(70));
732
- console.log();
733
- console.log(chalk.bold('📖 Config created at: openspec/config.yaml'));
734
- // Display summary
735
- const contextLines = config.context ? config.context.split('\n').length : 0;
736
- const rulesCount = config.rules ? Object.keys(config.rules).length : 0;
737
- console.log(` • Default schema: ${chalk.cyan(config.schema)}`);
738
- if (contextLines > 0) {
739
- console.log(` • Project context: ${chalk.cyan(`Added (${contextLines} lines)`)}`);
740
- }
741
- if (rulesCount > 0) {
742
- console.log(` • Rules: ${chalk.cyan(`${rulesCount} artifact${rulesCount > 1 ? 's' : ''} configured`)}`);
743
- }
744
- console.log();
745
- // Usage examples
746
- console.log(chalk.bold('Usage:'));
747
- console.log(' • New changes automatically use this schema');
748
- console.log(' • Context injected into all artifact instructions');
749
- console.log(' • Rules applied to matching artifacts');
750
- console.log();
751
- // Git commit suggestion
752
- console.log(chalk.bold('To share with team:'));
753
- console.log(chalk.dim(' git add openspec/config.yaml .claude/'));
754
- console.log(chalk.dim(' git commit -m "Setup OpenSpec experimental workflow with project config"'));
755
- console.log();
756
- }
757
- catch (writeError) {
758
- // Handle file write errors
759
- console.error();
760
- console.error(chalk.red('✗ Failed to write openspec/config.yaml'));
761
- console.error(chalk.dim(` ${writeError.message}`));
762
- console.error();
763
- console.error('Fallback: Create config manually:');
764
- console.error(chalk.dim(' 1. Create openspec/config.yaml'));
765
- console.error(chalk.dim(' 2. Copy the following content:'));
766
- console.error();
767
- console.error(chalk.dim(yamlContent));
768
- console.error();
769
- }
770
- }
771
- else {
772
- // User chose not to create config
773
- console.log();
774
- console.log(chalk.blue('ℹ️ Skipped config creation.'));
775
- console.log(' You can create openspec/config.yaml manually later.');
776
- console.log();
777
- }
720
+ await FileSystemUtils.writeFile(configPath, yamlContent);
721
+ console.log();
722
+ console.log(chalk.green('✓ Created openspec/config.yaml'));
723
+ console.log();
724
+ console.log(` Default schema: ${chalk.cyan(DEFAULT_SCHEMA)}`);
725
+ console.log();
726
+ console.log(chalk.dim(' Edit the file to add project context and per-artifact rules.'));
727
+ console.log();
728
+ // Git commit suggestion
729
+ console.log(chalk.bold('To share with team:'));
730
+ console.log(chalk.dim(' git add openspec/config.yaml .claude/'));
731
+ console.log(chalk.dim(' git commit -m "Setup OpenSpec experimental workflow"'));
732
+ console.log();
778
733
  }
779
- catch (promptError) {
780
- if (isExitPromptError(promptError)) {
781
- // User cancelled (Ctrl+C)
782
- console.log();
783
- console.log(chalk.blue('ℹ️ Config creation cancelled'));
784
- console.log(' Skills and commands already created');
785
- console.log(' Run setup again to create config later');
786
- console.log();
787
- }
788
- else {
789
- // Unexpected error
790
- throw promptError;
791
- }
734
+ catch (writeError) {
735
+ // Handle file write errors
736
+ console.error();
737
+ console.error(chalk.red('✗ Failed to write openspec/config.yaml'));
738
+ console.error(chalk.dim(` ${writeError.message}`));
739
+ console.error();
740
+ console.error('Fallback: Create config manually:');
741
+ console.error(chalk.dim(' 1. Create openspec/config.yaml'));
742
+ console.error(chalk.dim(' 2. Copy the following content:'));
743
+ console.error();
744
+ console.error(chalk.dim(yamlContent));
745
+ console.error();
792
746
  }
793
747
  }
794
748
  console.log('━'.repeat(70));
@@ -1,33 +1,6 @@
1
1
  import type { ProjectConfig } from './project-config.js';
2
2
  /**
3
- * Check if an error is an ExitPromptError (user cancelled with Ctrl+C).
4
- * Used instead of instanceof check since @inquirer modules use dynamic imports.
5
- */
6
- export declare function isExitPromptError(error: unknown): boolean;
7
- /**
8
- * Result of interactive config creation prompts.
9
- */
10
- export interface ConfigPromptResult {
11
- /** Whether to create config file */
12
- createConfig: boolean;
13
- /** Selected schema name */
14
- schema?: string;
15
- /** Project context (optional) */
16
- context?: string;
17
- /** Per-artifact rules (optional) */
18
- rules?: Record<string, string[]>;
19
- }
20
- /**
21
- * Prompt user to create project config interactively.
22
- * Used by experimental setup command.
23
- *
24
- * @param projectRoot - Optional project root for project-local schema resolution
25
- * @returns Config prompt result
26
- * @throws ExitPromptError if user cancels (Ctrl+C)
27
- */
28
- export declare function promptForConfig(projectRoot?: string): Promise<ConfigPromptResult>;
29
- /**
30
- * Serialize config to YAML string with proper multi-line formatting.
3
+ * Serialize config to YAML string with helpful comments.
31
4
  *
32
5
  * @param config - Partial config object (schema required, context/rules optional)
33
6
  * @returns YAML string ready to write to file
@@ -1,151 +1,34 @@
1
- import { stringify as stringifyYaml } from 'yaml';
2
- import { listSchemasWithInfo, resolveSchema } from './artifact-graph/resolver.js';
3
1
  /**
4
- * Check if an error is an ExitPromptError (user cancelled with Ctrl+C).
5
- * Used instead of instanceof check since @inquirer modules use dynamic imports.
6
- */
7
- export function isExitPromptError(error) {
8
- return (error !== null &&
9
- typeof error === 'object' &&
10
- 'name' in error &&
11
- error.name === 'ExitPromptError');
12
- }
13
- /**
14
- * Prompt user to create project config interactively.
15
- * Used by experimental setup command.
16
- *
17
- * @param projectRoot - Optional project root for project-local schema resolution
18
- * @returns Config prompt result
19
- * @throws ExitPromptError if user cancels (Ctrl+C)
20
- */
21
- export async function promptForConfig(projectRoot) {
22
- // Dynamic imports to prevent pre-commit hook hangs (see #367)
23
- const { confirm, select, editor, checkbox } = await import('@inquirer/prompts');
24
- // Ask if user wants to create config
25
- const shouldCreate = await confirm({
26
- message: 'Create openspec/config.yaml?',
27
- default: true,
28
- });
29
- if (!shouldCreate) {
30
- return { createConfig: false };
31
- }
32
- // Get available schemas
33
- const schemas = listSchemasWithInfo(projectRoot);
34
- if (schemas.length === 0) {
35
- throw new Error('No schemas found. Cannot create config.');
36
- }
37
- // Prompt for schema selection
38
- const selectedSchema = await select({
39
- message: 'Default schema for new changes?',
40
- choices: schemas.map((s) => ({
41
- name: `${s.name} (${s.artifacts.join(' → ')})`,
42
- value: s.name,
43
- description: s.description || undefined,
44
- })),
45
- });
46
- // Prompt for project context
47
- console.log('\nAdd project context? (optional)');
48
- console.log('Context is shown to AI when creating artifacts.');
49
- console.log('Examples: tech stack, conventions, style guides, domain knowledge\n');
50
- const contextInput = await editor({
51
- message: 'Press Enter to skip, or edit context:',
52
- default: '',
53
- waitForUseInput: false,
54
- });
55
- const context = contextInput.trim() || undefined;
56
- // Prompt for per-artifact rules
57
- const addRules = await confirm({
58
- message: 'Add per-artifact rules? (optional)',
59
- default: false,
60
- });
61
- let rules;
62
- if (addRules) {
63
- // Load the selected schema to get artifact list
64
- const schema = resolveSchema(selectedSchema, projectRoot);
65
- const artifactIds = schema.artifacts.map((a) => a.id);
66
- // Let user select which artifacts to add rules for
67
- const selectedArtifacts = await checkbox({
68
- message: 'Which artifacts should have custom rules?',
69
- choices: artifactIds.map((id) => ({
70
- name: id,
71
- value: id,
72
- })),
73
- });
74
- if (selectedArtifacts.length > 0) {
75
- rules = {};
76
- // For each selected artifact, collect rules line by line
77
- for (const artifactId of selectedArtifacts) {
78
- const artifactRules = await promptForArtifactRules(artifactId);
79
- if (artifactRules.length > 0) {
80
- rules[artifactId] = artifactRules;
81
- }
82
- }
83
- // If no rules were actually added, set to undefined
84
- if (Object.keys(rules).length === 0) {
85
- rules = undefined;
86
- }
87
- }
88
- }
89
- return {
90
- createConfig: true,
91
- schema: selectedSchema,
92
- context,
93
- rules,
94
- };
95
- }
96
- /**
97
- * Prompt for rules for a specific artifact.
98
- * Collects rules one per line until user enters empty line.
99
- *
100
- * @param artifactId - The artifact ID to collect rules for
101
- * @returns Array of rules
102
- */
103
- async function promptForArtifactRules(artifactId) {
104
- // Dynamic import to prevent pre-commit hook hangs (see #367)
105
- const { input } = await import('@inquirer/prompts');
106
- const rules = [];
107
- console.log(`\nRules for ${artifactId} artifact:`);
108
- console.log('Enter rules one per line, press Enter on empty line to finish:\n');
109
- while (true) {
110
- const rule = await input({
111
- message: '│',
112
- validate: () => {
113
- // Empty string is valid (signals end of input)
114
- return true;
115
- },
116
- });
117
- const trimmed = rule.trim();
118
- // Empty line signals end of input
119
- if (!trimmed) {
120
- break;
121
- }
122
- rules.push(trimmed);
123
- }
124
- return rules;
125
- }
126
- /**
127
- * Serialize config to YAML string with proper multi-line formatting.
2
+ * Serialize config to YAML string with helpful comments.
128
3
  *
129
4
  * @param config - Partial config object (schema required, context/rules optional)
130
5
  * @returns YAML string ready to write to file
131
6
  */
132
7
  export function serializeConfig(config) {
133
- // Build clean config object (only include defined fields)
134
- const cleanConfig = {
135
- schema: config.schema,
136
- };
137
- if (config.context) {
138
- cleanConfig.context = config.context;
139
- }
140
- if (config.rules && Object.keys(config.rules).length > 0) {
141
- cleanConfig.rules = config.rules;
142
- }
143
- // Serialize to YAML with proper formatting
144
- return stringifyYaml(cleanConfig, {
145
- indent: 2,
146
- lineWidth: 0, // Don't wrap long lines
147
- defaultStringType: 'PLAIN',
148
- defaultKeyType: 'PLAIN',
149
- });
8
+ const lines = [];
9
+ // Schema (required)
10
+ lines.push(`schema: ${config.schema}`);
11
+ lines.push('');
12
+ // Context section with comments
13
+ lines.push('# Project context (optional)');
14
+ lines.push('# This is shown to AI when creating artifacts.');
15
+ lines.push('# Add your tech stack, conventions, style guides, domain knowledge, etc.');
16
+ lines.push('# Example:');
17
+ lines.push('# context: |');
18
+ lines.push('# Tech stack: TypeScript, React, Node.js');
19
+ lines.push('# We use conventional commits');
20
+ lines.push('# Domain: e-commerce platform');
21
+ lines.push('');
22
+ // Rules section with comments
23
+ lines.push('# Per-artifact rules (optional)');
24
+ lines.push('# Add custom rules for specific artifacts.');
25
+ lines.push('# Example:');
26
+ lines.push('# rules:');
27
+ lines.push('# proposal:');
28
+ lines.push('# - Keep proposals under 500 words');
29
+ lines.push('# - Always include a "Non-goals" section');
30
+ lines.push('# tasks:');
31
+ lines.push('# - Break tasks into chunks of max 2 hours');
32
+ return lines.join('\n') + '\n';
150
33
  }
151
34
  //# sourceMappingURL=config-prompts.js.map
@@ -75,6 +75,11 @@ export declare function getOpsxFfCommandTemplate(): CommandTemplate;
75
75
  * For archiving completed changes in the experimental workflow
76
76
  */
77
77
  export declare function getArchiveChangeSkillTemplate(): SkillTemplate;
78
+ /**
79
+ * Template for openspec-bulk-archive-change skill
80
+ * For archiving multiple completed changes at once
81
+ */
82
+ export declare function getBulkArchiveChangeSkillTemplate(): SkillTemplate;
78
83
  /**
79
84
  * Template for /opsx:sync slash command
80
85
  */
@@ -88,6 +93,10 @@ export declare function getVerifyChangeSkillTemplate(): SkillTemplate;
88
93
  * Template for /opsx:archive slash command
89
94
  */
90
95
  export declare function getOpsxArchiveCommandTemplate(): CommandTemplate;
96
+ /**
97
+ * Template for /opsx:bulk-archive slash command
98
+ */
99
+ export declare function getOpsxBulkArchiveCommandTemplate(): CommandTemplate;
91
100
  /**
92
101
  * Template for /opsx:verify slash command
93
102
  */
@@ -1602,6 +1602,251 @@ All artifacts complete. All tasks complete.
1602
1602
  - If delta specs exist, always run the sync assessment and show the combined summary before prompting`
1603
1603
  };
1604
1604
  }
1605
+ /**
1606
+ * Template for openspec-bulk-archive-change skill
1607
+ * For archiving multiple completed changes at once
1608
+ */
1609
+ export function getBulkArchiveChangeSkillTemplate() {
1610
+ return {
1611
+ name: 'openspec-bulk-archive-change',
1612
+ description: 'Archive multiple completed changes at once. Use when archiving several parallel changes.',
1613
+ instructions: `Archive multiple completed changes in a single operation.
1614
+
1615
+ This skill allows you to batch-archive changes, handling spec conflicts intelligently by checking the codebase to determine what's actually implemented.
1616
+
1617
+ **Input**: None required (prompts for selection)
1618
+
1619
+ **Steps**
1620
+
1621
+ 1. **Get active changes**
1622
+
1623
+ Run \`openspec list --json\` to get all active changes.
1624
+
1625
+ If no active changes exist, inform user and stop.
1626
+
1627
+ 2. **Prompt for change selection**
1628
+
1629
+ Use **AskUserQuestion tool** with multi-select to let user choose changes:
1630
+ - Show each change with its schema
1631
+ - Include an option for "All changes"
1632
+ - Allow any number of selections (1+ works, 2+ is the typical use case)
1633
+
1634
+ **IMPORTANT**: Do NOT auto-select. Always let the user choose.
1635
+
1636
+ 3. **Batch validation - gather status for all selected changes**
1637
+
1638
+ For each selected change, collect:
1639
+
1640
+ a. **Artifact status** - Run \`openspec status --change "<name>" --json\`
1641
+ - Parse \`schemaName\` and \`artifacts\` list
1642
+ - Note which artifacts are \`done\` vs other states
1643
+
1644
+ b. **Task completion** - Read \`openspec/changes/<name>/tasks.md\`
1645
+ - Count \`- [ ]\` (incomplete) vs \`- [x]\` (complete)
1646
+ - If no tasks file exists, note as "No tasks"
1647
+
1648
+ c. **Delta specs** - Check \`openspec/changes/<name>/specs/\` directory
1649
+ - List which capability specs exist
1650
+ - For each, extract requirement names (lines matching \`### Requirement: <name>\`)
1651
+
1652
+ 4. **Detect spec conflicts**
1653
+
1654
+ Build a map of \`capability -> [changes that touch it]\`:
1655
+
1656
+ \`\`\`
1657
+ auth -> [change-a, change-b] <- CONFLICT (2+ changes)
1658
+ api -> [change-c] <- OK (only 1 change)
1659
+ \`\`\`
1660
+
1661
+ A conflict exists when 2+ selected changes have delta specs for the same capability.
1662
+
1663
+ 5. **Resolve conflicts agentically**
1664
+
1665
+ **For each conflict**, investigate the codebase:
1666
+
1667
+ a. **Read the delta specs** from each conflicting change to understand what each claims to add/modify
1668
+
1669
+ b. **Search the codebase** for implementation evidence:
1670
+ - Look for code implementing requirements from each delta spec
1671
+ - Check for related files, functions, or tests
1672
+
1673
+ c. **Determine resolution**:
1674
+ - If only one change is actually implemented -> sync that one's specs
1675
+ - If both implemented -> apply in chronological order (older first, newer overwrites)
1676
+ - If neither implemented -> skip spec sync, warn user
1677
+
1678
+ d. **Record resolution** for each conflict:
1679
+ - Which change's specs to apply
1680
+ - In what order (if both)
1681
+ - Rationale (what was found in codebase)
1682
+
1683
+ 6. **Show consolidated status table**
1684
+
1685
+ Display a table summarizing all changes:
1686
+
1687
+ \`\`\`
1688
+ | Change | Artifacts | Tasks | Specs | Conflicts | Status |
1689
+ |---------------------|-----------|-------|---------|-----------|--------|
1690
+ | schema-management | Done | 5/5 | 2 delta | None | Ready |
1691
+ | project-config | Done | 3/3 | 1 delta | None | Ready |
1692
+ | add-oauth | Done | 4/4 | 1 delta | auth (!) | Ready* |
1693
+ | add-verify-skill | 1 left | 2/5 | None | None | Warn |
1694
+ \`\`\`
1695
+
1696
+ For conflicts, show the resolution:
1697
+ \`\`\`
1698
+ * Conflict resolution:
1699
+ - auth spec: Will apply add-oauth then add-jwt (both implemented, chronological order)
1700
+ \`\`\`
1701
+
1702
+ For incomplete changes, show warnings:
1703
+ \`\`\`
1704
+ Warnings:
1705
+ - add-verify-skill: 1 incomplete artifact, 3 incomplete tasks
1706
+ \`\`\`
1707
+
1708
+ 7. **Confirm batch operation**
1709
+
1710
+ Use **AskUserQuestion tool** with a single confirmation:
1711
+
1712
+ - "Archive N changes?" with options based on status
1713
+ - Options might include:
1714
+ - "Archive all N changes"
1715
+ - "Archive only N ready changes (skip incomplete)"
1716
+ - "Cancel"
1717
+
1718
+ If there are incomplete changes, make clear they'll be archived with warnings.
1719
+
1720
+ 8. **Execute archive for each confirmed change**
1721
+
1722
+ Process changes in the determined order (respecting conflict resolution):
1723
+
1724
+ a. **Sync specs** if delta specs exist:
1725
+ - Use the openspec-sync-specs approach (agent-driven intelligent merge)
1726
+ - For conflicts, apply in resolved order
1727
+ - Track if sync was done
1728
+
1729
+ b. **Perform the archive**:
1730
+ \`\`\`bash
1731
+ mkdir -p openspec/changes/archive
1732
+ mv openspec/changes/<name> openspec/changes/archive/YYYY-MM-DD-<name>
1733
+ \`\`\`
1734
+
1735
+ c. **Track outcome** for each change:
1736
+ - Success: archived successfully
1737
+ - Failed: error during archive (record error)
1738
+ - Skipped: user chose not to archive (if applicable)
1739
+
1740
+ 9. **Display summary**
1741
+
1742
+ Show final results:
1743
+
1744
+ \`\`\`
1745
+ ## Bulk Archive Complete
1746
+
1747
+ Archived 3 changes:
1748
+ - schema-management-cli -> archive/2026-01-19-schema-management-cli/
1749
+ - project-config -> archive/2026-01-19-project-config/
1750
+ - add-oauth -> archive/2026-01-19-add-oauth/
1751
+
1752
+ Skipped 1 change:
1753
+ - add-verify-skill (user chose not to archive incomplete)
1754
+
1755
+ Spec sync summary:
1756
+ - 4 delta specs synced to main specs
1757
+ - 1 conflict resolved (auth: applied both in chronological order)
1758
+ \`\`\`
1759
+
1760
+ If any failures:
1761
+ \`\`\`
1762
+ Failed 1 change:
1763
+ - some-change: Archive directory already exists
1764
+ \`\`\`
1765
+
1766
+ **Conflict Resolution Examples**
1767
+
1768
+ Example 1: Only one implemented
1769
+ \`\`\`
1770
+ Conflict: specs/auth/spec.md touched by [add-oauth, add-jwt]
1771
+
1772
+ Checking add-oauth:
1773
+ - Delta adds "OAuth Provider Integration" requirement
1774
+ - Searching codebase... found src/auth/oauth.ts implementing OAuth flow
1775
+
1776
+ Checking add-jwt:
1777
+ - Delta adds "JWT Token Handling" requirement
1778
+ - Searching codebase... no JWT implementation found
1779
+
1780
+ Resolution: Only add-oauth is implemented. Will sync add-oauth specs only.
1781
+ \`\`\`
1782
+
1783
+ Example 2: Both implemented
1784
+ \`\`\`
1785
+ Conflict: specs/api/spec.md touched by [add-rest-api, add-graphql]
1786
+
1787
+ Checking add-rest-api (created 2026-01-10):
1788
+ - Delta adds "REST Endpoints" requirement
1789
+ - Searching codebase... found src/api/rest.ts
1790
+
1791
+ Checking add-graphql (created 2026-01-15):
1792
+ - Delta adds "GraphQL Schema" requirement
1793
+ - Searching codebase... found src/api/graphql.ts
1794
+
1795
+ Resolution: Both implemented. Will apply add-rest-api specs first,
1796
+ then add-graphql specs (chronological order, newer takes precedence).
1797
+ \`\`\`
1798
+
1799
+ **Output On Success**
1800
+
1801
+ \`\`\`
1802
+ ## Bulk Archive Complete
1803
+
1804
+ Archived N changes:
1805
+ - <change-1> -> archive/YYYY-MM-DD-<change-1>/
1806
+ - <change-2> -> archive/YYYY-MM-DD-<change-2>/
1807
+
1808
+ Spec sync summary:
1809
+ - N delta specs synced to main specs
1810
+ - No conflicts (or: M conflicts resolved)
1811
+ \`\`\`
1812
+
1813
+ **Output On Partial Success**
1814
+
1815
+ \`\`\`
1816
+ ## Bulk Archive Complete (partial)
1817
+
1818
+ Archived N changes:
1819
+ - <change-1> -> archive/YYYY-MM-DD-<change-1>/
1820
+
1821
+ Skipped M changes:
1822
+ - <change-2> (user chose not to archive incomplete)
1823
+
1824
+ Failed K changes:
1825
+ - <change-3>: Archive directory already exists
1826
+ \`\`\`
1827
+
1828
+ **Output When No Changes**
1829
+
1830
+ \`\`\`
1831
+ ## No Changes to Archive
1832
+
1833
+ No active changes found. Use \`/opsx:new\` to create a new change.
1834
+ \`\`\`
1835
+
1836
+ **Guardrails**
1837
+ - Allow any number of changes (1+ is fine, 2+ is the typical use case)
1838
+ - Always prompt for selection, never auto-select
1839
+ - Detect spec conflicts early and resolve by checking codebase
1840
+ - When both changes are implemented, apply specs in chronological order
1841
+ - Skip spec sync only when implementation is missing (warn user)
1842
+ - Show clear per-change status before confirming
1843
+ - Use single confirmation for entire batch
1844
+ - Track and report all outcomes (success/skip/fail)
1845
+ - Preserve .openspec.yaml when moving to archive
1846
+ - Archive directory target uses current date: YYYY-MM-DD-<name>
1847
+ - If archive target exists, fail that change but continue with others`
1848
+ };
1849
+ }
1605
1850
  /**
1606
1851
  * Template for /opsx:sync slash command
1607
1852
  */
@@ -2068,6 +2313,252 @@ Target archive directory already exists.
2068
2313
  - If delta specs exist, always run the sync assessment and show the combined summary before prompting`
2069
2314
  };
2070
2315
  }
2316
+ /**
2317
+ * Template for /opsx:bulk-archive slash command
2318
+ */
2319
+ export function getOpsxBulkArchiveCommandTemplate() {
2320
+ return {
2321
+ name: 'OPSX: Bulk Archive',
2322
+ description: 'Archive multiple completed changes at once',
2323
+ category: 'Workflow',
2324
+ tags: ['workflow', 'archive', 'experimental', 'bulk'],
2325
+ content: `Archive multiple completed changes in a single operation.
2326
+
2327
+ This skill allows you to batch-archive changes, handling spec conflicts intelligently by checking the codebase to determine what's actually implemented.
2328
+
2329
+ **Input**: None required (prompts for selection)
2330
+
2331
+ **Steps**
2332
+
2333
+ 1. **Get active changes**
2334
+
2335
+ Run \`openspec list --json\` to get all active changes.
2336
+
2337
+ If no active changes exist, inform user and stop.
2338
+
2339
+ 2. **Prompt for change selection**
2340
+
2341
+ Use **AskUserQuestion tool** with multi-select to let user choose changes:
2342
+ - Show each change with its schema
2343
+ - Include an option for "All changes"
2344
+ - Allow any number of selections (1+ works, 2+ is the typical use case)
2345
+
2346
+ **IMPORTANT**: Do NOT auto-select. Always let the user choose.
2347
+
2348
+ 3. **Batch validation - gather status for all selected changes**
2349
+
2350
+ For each selected change, collect:
2351
+
2352
+ a. **Artifact status** - Run \`openspec status --change "<name>" --json\`
2353
+ - Parse \`schemaName\` and \`artifacts\` list
2354
+ - Note which artifacts are \`done\` vs other states
2355
+
2356
+ b. **Task completion** - Read \`openspec/changes/<name>/tasks.md\`
2357
+ - Count \`- [ ]\` (incomplete) vs \`- [x]\` (complete)
2358
+ - If no tasks file exists, note as "No tasks"
2359
+
2360
+ c. **Delta specs** - Check \`openspec/changes/<name>/specs/\` directory
2361
+ - List which capability specs exist
2362
+ - For each, extract requirement names (lines matching \`### Requirement: <name>\`)
2363
+
2364
+ 4. **Detect spec conflicts**
2365
+
2366
+ Build a map of \`capability -> [changes that touch it]\`:
2367
+
2368
+ \`\`\`
2369
+ auth -> [change-a, change-b] <- CONFLICT (2+ changes)
2370
+ api -> [change-c] <- OK (only 1 change)
2371
+ \`\`\`
2372
+
2373
+ A conflict exists when 2+ selected changes have delta specs for the same capability.
2374
+
2375
+ 5. **Resolve conflicts agentically**
2376
+
2377
+ **For each conflict**, investigate the codebase:
2378
+
2379
+ a. **Read the delta specs** from each conflicting change to understand what each claims to add/modify
2380
+
2381
+ b. **Search the codebase** for implementation evidence:
2382
+ - Look for code implementing requirements from each delta spec
2383
+ - Check for related files, functions, or tests
2384
+
2385
+ c. **Determine resolution**:
2386
+ - If only one change is actually implemented -> sync that one's specs
2387
+ - If both implemented -> apply in chronological order (older first, newer overwrites)
2388
+ - If neither implemented -> skip spec sync, warn user
2389
+
2390
+ d. **Record resolution** for each conflict:
2391
+ - Which change's specs to apply
2392
+ - In what order (if both)
2393
+ - Rationale (what was found in codebase)
2394
+
2395
+ 6. **Show consolidated status table**
2396
+
2397
+ Display a table summarizing all changes:
2398
+
2399
+ \`\`\`
2400
+ | Change | Artifacts | Tasks | Specs | Conflicts | Status |
2401
+ |---------------------|-----------|-------|---------|-----------|--------|
2402
+ | schema-management | Done | 5/5 | 2 delta | None | Ready |
2403
+ | project-config | Done | 3/3 | 1 delta | None | Ready |
2404
+ | add-oauth | Done | 4/4 | 1 delta | auth (!) | Ready* |
2405
+ | add-verify-skill | 1 left | 2/5 | None | None | Warn |
2406
+ \`\`\`
2407
+
2408
+ For conflicts, show the resolution:
2409
+ \`\`\`
2410
+ * Conflict resolution:
2411
+ - auth spec: Will apply add-oauth then add-jwt (both implemented, chronological order)
2412
+ \`\`\`
2413
+
2414
+ For incomplete changes, show warnings:
2415
+ \`\`\`
2416
+ Warnings:
2417
+ - add-verify-skill: 1 incomplete artifact, 3 incomplete tasks
2418
+ \`\`\`
2419
+
2420
+ 7. **Confirm batch operation**
2421
+
2422
+ Use **AskUserQuestion tool** with a single confirmation:
2423
+
2424
+ - "Archive N changes?" with options based on status
2425
+ - Options might include:
2426
+ - "Archive all N changes"
2427
+ - "Archive only N ready changes (skip incomplete)"
2428
+ - "Cancel"
2429
+
2430
+ If there are incomplete changes, make clear they'll be archived with warnings.
2431
+
2432
+ 8. **Execute archive for each confirmed change**
2433
+
2434
+ Process changes in the determined order (respecting conflict resolution):
2435
+
2436
+ a. **Sync specs** if delta specs exist:
2437
+ - Use the openspec-sync-specs approach (agent-driven intelligent merge)
2438
+ - For conflicts, apply in resolved order
2439
+ - Track if sync was done
2440
+
2441
+ b. **Perform the archive**:
2442
+ \`\`\`bash
2443
+ mkdir -p openspec/changes/archive
2444
+ mv openspec/changes/<name> openspec/changes/archive/YYYY-MM-DD-<name>
2445
+ \`\`\`
2446
+
2447
+ c. **Track outcome** for each change:
2448
+ - Success: archived successfully
2449
+ - Failed: error during archive (record error)
2450
+ - Skipped: user chose not to archive (if applicable)
2451
+
2452
+ 9. **Display summary**
2453
+
2454
+ Show final results:
2455
+
2456
+ \`\`\`
2457
+ ## Bulk Archive Complete
2458
+
2459
+ Archived 3 changes:
2460
+ - schema-management-cli -> archive/2026-01-19-schema-management-cli/
2461
+ - project-config -> archive/2026-01-19-project-config/
2462
+ - add-oauth -> archive/2026-01-19-add-oauth/
2463
+
2464
+ Skipped 1 change:
2465
+ - add-verify-skill (user chose not to archive incomplete)
2466
+
2467
+ Spec sync summary:
2468
+ - 4 delta specs synced to main specs
2469
+ - 1 conflict resolved (auth: applied both in chronological order)
2470
+ \`\`\`
2471
+
2472
+ If any failures:
2473
+ \`\`\`
2474
+ Failed 1 change:
2475
+ - some-change: Archive directory already exists
2476
+ \`\`\`
2477
+
2478
+ **Conflict Resolution Examples**
2479
+
2480
+ Example 1: Only one implemented
2481
+ \`\`\`
2482
+ Conflict: specs/auth/spec.md touched by [add-oauth, add-jwt]
2483
+
2484
+ Checking add-oauth:
2485
+ - Delta adds "OAuth Provider Integration" requirement
2486
+ - Searching codebase... found src/auth/oauth.ts implementing OAuth flow
2487
+
2488
+ Checking add-jwt:
2489
+ - Delta adds "JWT Token Handling" requirement
2490
+ - Searching codebase... no JWT implementation found
2491
+
2492
+ Resolution: Only add-oauth is implemented. Will sync add-oauth specs only.
2493
+ \`\`\`
2494
+
2495
+ Example 2: Both implemented
2496
+ \`\`\`
2497
+ Conflict: specs/api/spec.md touched by [add-rest-api, add-graphql]
2498
+
2499
+ Checking add-rest-api (created 2026-01-10):
2500
+ - Delta adds "REST Endpoints" requirement
2501
+ - Searching codebase... found src/api/rest.ts
2502
+
2503
+ Checking add-graphql (created 2026-01-15):
2504
+ - Delta adds "GraphQL Schema" requirement
2505
+ - Searching codebase... found src/api/graphql.ts
2506
+
2507
+ Resolution: Both implemented. Will apply add-rest-api specs first,
2508
+ then add-graphql specs (chronological order, newer takes precedence).
2509
+ \`\`\`
2510
+
2511
+ **Output On Success**
2512
+
2513
+ \`\`\`
2514
+ ## Bulk Archive Complete
2515
+
2516
+ Archived N changes:
2517
+ - <change-1> -> archive/YYYY-MM-DD-<change-1>/
2518
+ - <change-2> -> archive/YYYY-MM-DD-<change-2>/
2519
+
2520
+ Spec sync summary:
2521
+ - N delta specs synced to main specs
2522
+ - No conflicts (or: M conflicts resolved)
2523
+ \`\`\`
2524
+
2525
+ **Output On Partial Success**
2526
+
2527
+ \`\`\`
2528
+ ## Bulk Archive Complete (partial)
2529
+
2530
+ Archived N changes:
2531
+ - <change-1> -> archive/YYYY-MM-DD-<change-1>/
2532
+
2533
+ Skipped M changes:
2534
+ - <change-2> (user chose not to archive incomplete)
2535
+
2536
+ Failed K changes:
2537
+ - <change-3>: Archive directory already exists
2538
+ \`\`\`
2539
+
2540
+ **Output When No Changes**
2541
+
2542
+ \`\`\`
2543
+ ## No Changes to Archive
2544
+
2545
+ No active changes found. Use \`/opsx:new\` to create a new change.
2546
+ \`\`\`
2547
+
2548
+ **Guardrails**
2549
+ - Allow any number of changes (1+ is fine, 2+ is the typical use case)
2550
+ - Always prompt for selection, never auto-select
2551
+ - Detect spec conflicts early and resolve by checking codebase
2552
+ - When both changes are implemented, apply specs in chronological order
2553
+ - Skip spec sync only when implementation is missing (warn user)
2554
+ - Show clear per-change status before confirming
2555
+ - Use single confirmation for entire batch
2556
+ - Track and report all outcomes (success/skip/fail)
2557
+ - Preserve .openspec.yaml when moving to archive
2558
+ - Archive directory target uses current date: YYYY-MM-DD-<name>
2559
+ - If archive target exists, fail that change but continue with others`
2560
+ };
2561
+ }
2071
2562
  /**
2072
2563
  * Template for /opsx:verify slash command
2073
2564
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fission-ai/openspec",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "AI-native system for spec-driven development",
5
5
  "keywords": [
6
6
  "openspec",