|
| 1 | +--- |
| 2 | +name: OPSX: Archive |
| 3 | +description: Archive a completed change in the experimental workflow |
| 4 | +category: Workflow |
| 5 | +tags: [workflow, archive, experimental] |
| 6 | +--- |
| 7 | + |
| 8 | +Archive a completed change in the experimental workflow. |
| 9 | + |
| 10 | +**Input**: Optionally specify `--change <name>` after `/opsx:archive`. If omitted, MUST prompt for available changes. |
| 11 | + |
| 12 | +**Steps** |
| 13 | + |
| 14 | +1. **If no change name provided, prompt for selection** |
| 15 | + |
| 16 | + Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select. |
| 17 | + |
| 18 | + Show only active changes (not already archived). |
| 19 | + Include the schema used for each change if available. |
| 20 | + |
| 21 | + **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose. |
| 22 | + |
| 23 | +2. **Check artifact completion status** |
| 24 | + |
| 25 | + Run `openspec status --change "<name>" --json` to check artifact completion. |
| 26 | + |
| 27 | + Parse the JSON to understand: |
| 28 | + - `schemaName`: The workflow being used |
| 29 | + - `artifacts`: List of artifacts with their status (`done` or other) |
| 30 | + |
| 31 | + **If any artifacts are not `done`:** |
| 32 | + - Display warning listing incomplete artifacts |
| 33 | + - Prompt user for confirmation to continue |
| 34 | + - Proceed if user confirms |
| 35 | + |
| 36 | +3. **Check task completion status** |
| 37 | + |
| 38 | + Read the tasks file (typically `tasks.md`) to check for incomplete tasks. |
| 39 | + |
| 40 | + Count tasks marked with `- [ ]` (incomplete) vs `- [x]` (complete). |
| 41 | + |
| 42 | + **If incomplete tasks found:** |
| 43 | + - Display warning showing count of incomplete tasks |
| 44 | + - Prompt user for confirmation to continue |
| 45 | + - Proceed if user confirms |
| 46 | + |
| 47 | + **If no tasks file exists:** Proceed without task-related warning. |
| 48 | + |
| 49 | +4. **Check if delta specs need syncing** |
| 50 | + |
| 51 | + Check if `specs/` directory exists in the change with spec files. |
| 52 | + |
| 53 | + **If delta specs exist, perform a quick sync check:** |
| 54 | + |
| 55 | + a. **For each delta spec** at `openspec/changes/<name>/specs/<capability>/spec.md`: |
| 56 | + - Extract requirement names (lines matching `### Requirement: <name>`) |
| 57 | + - Note which sections exist (ADDED, MODIFIED, REMOVED) |
| 58 | + |
| 59 | + b. **Check corresponding main spec** at `openspec/specs/<capability>/spec.md`: |
| 60 | + - If main spec doesn't exist → needs sync |
| 61 | + - If main spec exists, check if ADDED requirement names appear in it |
| 62 | + - If any ADDED requirements are missing from main spec → needs sync |
| 63 | + |
| 64 | + c. **Report findings:** |
| 65 | + |
| 66 | + **If sync needed:** |
| 67 | + ``` |
| 68 | + ⚠️ Delta specs may not be synced: |
| 69 | + - specs/auth/spec.md → Main spec missing requirement "Token Refresh" |
| 70 | + - specs/api/spec.md → Main spec doesn't exist yet |
| 71 | +
|
| 72 | + Would you like to sync now before archiving? |
| 73 | + ``` |
| 74 | + - Use **AskUserQuestion tool** with options: "Sync now", "Archive without syncing" |
| 75 | + - If user chooses sync, execute `/opsx:sync` logic |
| 76 | +
|
| 77 | + **If already synced (all requirements found):** |
| 78 | + - Proceed without prompting (specs appear to be in sync) |
| 79 | +
|
| 80 | + **If no delta specs exist:** Proceed without sync-related checks. |
| 81 | +
|
| 82 | +5. **Perform the archive** |
| 83 | +
|
| 84 | + Create the archive directory if it doesn't exist: |
| 85 | + ```bash |
| 86 | + mkdir -p openspec/changes/archive |
| 87 | + ``` |
| 88 | + |
| 89 | + Generate target name using current date: `YYYY-MM-DD-<change-name>` |
| 90 | + |
| 91 | + **Check if target already exists:** |
| 92 | + - If yes: Fail with error, suggest renaming existing archive or using different date |
| 93 | + - If no: Move the change directory to archive |
| 94 | + |
| 95 | + ```bash |
| 96 | + mv openspec/changes/<name> openspec/changes/archive/YYYY-MM-DD-<name> |
| 97 | + ``` |
| 98 | + |
| 99 | +6. **Display summary** |
| 100 | + |
| 101 | + Show archive completion summary including: |
| 102 | + - Change name |
| 103 | + - Schema that was used |
| 104 | + - Archive location |
| 105 | + - Spec sync status (synced / not synced / no delta specs) |
| 106 | + - Note about any warnings (incomplete artifacts/tasks) |
| 107 | + |
| 108 | +**Output On Success** |
| 109 | + |
| 110 | +``` |
| 111 | +## Archive Complete |
| 112 | +
|
| 113 | +**Change:** <change-name> |
| 114 | +**Schema:** <schema-name> |
| 115 | +**Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/ |
| 116 | +**Specs:** ✓ Synced to main specs |
| 117 | +
|
| 118 | +All artifacts complete. All tasks complete. |
| 119 | +``` |
| 120 | + |
| 121 | +**Output On Success (No Delta Specs)** |
| 122 | + |
| 123 | +``` |
| 124 | +## Archive Complete |
| 125 | +
|
| 126 | +**Change:** <change-name> |
| 127 | +**Schema:** <schema-name> |
| 128 | +**Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/ |
| 129 | +**Specs:** No delta specs |
| 130 | +
|
| 131 | +All artifacts complete. All tasks complete. |
| 132 | +``` |
| 133 | + |
| 134 | +**Output On Success With Warnings** |
| 135 | + |
| 136 | +``` |
| 137 | +## Archive Complete (with warnings) |
| 138 | +
|
| 139 | +**Change:** <change-name> |
| 140 | +**Schema:** <schema-name> |
| 141 | +**Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/ |
| 142 | +**Specs:** ⚠️ Not synced |
| 143 | +
|
| 144 | +**Warnings:** |
| 145 | +- Archived with 2 incomplete artifacts |
| 146 | +- Archived with 3 incomplete tasks |
| 147 | +- Delta specs were not synced (user chose to skip) |
| 148 | +
|
| 149 | +Review the archive if this was not intentional. |
| 150 | +``` |
| 151 | + |
| 152 | +**Output On Error (Archive Exists)** |
| 153 | + |
| 154 | +``` |
| 155 | +## Archive Failed |
| 156 | +
|
| 157 | +**Change:** <change-name> |
| 158 | +**Target:** openspec/changes/archive/YYYY-MM-DD-<name>/ |
| 159 | +
|
| 160 | +Target archive directory already exists. |
| 161 | +
|
| 162 | +**Options:** |
| 163 | +1. Rename the existing archive |
| 164 | +2. Delete the existing archive if it's a duplicate |
| 165 | +3. Wait until a different date to archive |
| 166 | +``` |
| 167 | + |
| 168 | +**Guardrails** |
| 169 | +- Always prompt for change selection if not provided |
| 170 | +- Use artifact graph (openspec status --json) for completion checking |
| 171 | +- Don't block archive on warnings - just inform and confirm |
| 172 | +- Preserve .openspec.yaml when moving to archive (it moves with the directory) |
| 173 | +- Quick sync check: look for requirement names in delta specs, verify they exist in main specs |
| 174 | +- Show clear summary of what happened |
| 175 | +- If sync is requested, use /opsx:sync approach (agent-driven) |
0 commit comments