clone

a hermes agent plugin for openspec: tools for spec workflows and a dashboard tab for browsing changes and specs

main
hermes-openspec / skills / openspec-bulk-archive-change / SKILL.md
SKILL.md 7.8K rendered
1---2name: openspec-bulk-archive-change3description: Archive multiple completed changes at once. Use when archiving several parallel changes.4license: MIT5compatibility: Requires openspec CLI.6metadata:7 author: openspec8 version: "1.0"9 generatedBy: "1.4.1"10---1112Archive multiple completed changes in a single operation.1314This skill allows you to batch-archive changes, handling spec conflicts intelligently by checking the codebase to determine what's actually implemented.1516**Input**: None required (prompts for selection)1718**Steps**19201. **Get active changes**2122 Run `openspec list --json` to get all active changes.2324 If no active changes exist, inform user and stop.25262. **Prompt for change selection**2728 Use **AskUserQuestion tool** with multi-select to let user choose changes:29 - Show each change with its schema30 - Include an option for "All changes"31 - Allow any number of selections (1+ works, 2+ is the typical use case)3233 **IMPORTANT**: Do NOT auto-select. Always let the user choose.34353. **Batch validation - gather status for all selected changes**3637 For each selected change, collect:3839 a. **Artifact status** - Run `openspec status --change "<name>" --json`40 - Parse `schemaName`, `artifacts`, `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`41 - Note which artifacts are `done` vs other states4243 If any selected change reports `actionContext.mode: "workspace-planning"`, explain that workspace bulk archive is not supported in this slice and STOP before syncing specs or moving changes. Do not fall back to repo-local paths or edit linked repos.4445 b. **Task completion** - Read `artifactPaths.tasks.existingOutputPaths` from status JSON46 - Count `- [ ]` (incomplete) vs `- [x]` (complete)47 - If no tasks file exists, note as "No tasks"4849 c. **Delta specs** - Check `artifactPaths.specs.existingOutputPaths` from status JSON50 - List which capability specs exist51 - For each, extract requirement names (lines matching `### Requirement: <name>`)52534. **Detect spec conflicts**5455 Build a map of `capability -> [changes that touch it]`:5657 ```58 auth -> [change-a, change-b] <- CONFLICT (2+ changes)59 api -> [change-c] <- OK (only 1 change)60 ```6162 A conflict exists when 2+ selected changes have delta specs for the same capability.63645. **Resolve conflicts agentically**6566 **For each conflict**, investigate the codebase:6768 a. **Read the delta specs** from each conflicting change to understand what each claims to add/modify6970 b. **Search the codebase** for implementation evidence:71 - Look for code implementing requirements from each delta spec72 - Check for related files, functions, or tests7374 c. **Determine resolution**:75 - If only one change is actually implemented -> sync that one's specs76 - If both implemented -> apply in chronological order (older first, newer overwrites)77 - If neither implemented -> skip spec sync, warn user7879 d. **Record resolution** for each conflict:80 - Which change's specs to apply81 - In what order (if both)82 - Rationale (what was found in codebase)83846. **Show consolidated status table**8586 Display a table summarizing all changes:8788 ```89 | Change | Artifacts | Tasks | Specs | Conflicts | Status |90 |---------------------|-----------|-------|---------|-----------|--------|91 | schema-management | Done | 5/5 | 2 delta | None | Ready |92 | project-config | Done | 3/3 | 1 delta | None | Ready |93 | add-oauth | Done | 4/4 | 1 delta | auth (!) | Ready* |94 | add-verify-skill | 1 left | 2/5 | None | None | Warn |95 ```9697 For conflicts, show the resolution:98 ```99 * Conflict resolution:100 - auth spec: Will apply add-oauth then add-jwt (both implemented, chronological order)101 ```102103 For incomplete changes, show warnings:104 ```105 Warnings:106 - add-verify-skill: 1 incomplete artifact, 3 incomplete tasks107 ```1081097. **Confirm batch operation**110111 Use **AskUserQuestion tool** with a single confirmation:112113 - "Archive N changes?" with options based on status114 - Options might include:115 - "Archive all N changes"116 - "Archive only N ready changes (skip incomplete)"117 - "Cancel"118119 If there are incomplete changes, make clear they'll be archived with warnings.1201218. **Execute archive for each confirmed change**122123 Process changes in the determined order (respecting conflict resolution):124125 a. **Sync specs** if delta specs exist:126 - Use the openspec-sync-specs approach (agent-driven intelligent merge)127 - For conflicts, apply in resolved order128 - Track if sync was done129130 b. **Perform the archive**:131 ```bash132 mkdir -p "<planningHome.changesDir>/archive"133 mv "<changeRoot>" "<planningHome.changesDir>/archive/YYYY-MM-DD-<name>"134 ```135136 c. **Track outcome** for each change:137 - Success: archived successfully138 - Failed: error during archive (record error)139 - Skipped: user chose not to archive (if applicable)1401419. **Display summary**142143 Show final results:144145 ```146 ## Bulk Archive Complete147148 Archived 3 changes:149 - schema-management-cli -> archive/2026-01-19-schema-management-cli/150 - project-config -> archive/2026-01-19-project-config/151 - add-oauth -> archive/2026-01-19-add-oauth/152153 Skipped 1 change:154 - add-verify-skill (user chose not to archive incomplete)155156 Spec sync summary:157 - 4 delta specs synced to main specs158 - 1 conflict resolved (auth: applied both in chronological order)159 ```160161 If any failures:162 ```163 Failed 1 change:164 - some-change: Archive directory already exists165 ```166167**Conflict Resolution Examples**168169Example 1: Only one implemented170```171Conflict: specs/auth/spec.md touched by [add-oauth, add-jwt]172173Checking add-oauth:174- Delta adds "OAuth Provider Integration" requirement175- Searching codebase... found src/auth/oauth.ts implementing OAuth flow176177Checking add-jwt:178- Delta adds "JWT Token Handling" requirement179- Searching codebase... no JWT implementation found180181Resolution: Only add-oauth is implemented. Will sync add-oauth specs only.182```183184Example 2: Both implemented185```186Conflict: specs/api/spec.md touched by [add-rest-api, add-graphql]187188Checking add-rest-api (created 2026-01-10):189- Delta adds "REST Endpoints" requirement190- Searching codebase... found src/api/rest.ts191192Checking add-graphql (created 2026-01-15):193- Delta adds "GraphQL Schema" requirement194- Searching codebase... found src/api/graphql.ts195196Resolution: Both implemented. Will apply add-rest-api specs first,197then add-graphql specs (chronological order, newer takes precedence).198```199200**Output On Success**201202```203## Bulk Archive Complete204205Archived N changes:206- <change-1> -> archive/YYYY-MM-DD-<change-1>/207- <change-2> -> archive/YYYY-MM-DD-<change-2>/208209Spec sync summary:210- N delta specs synced to main specs211- No conflicts (or: M conflicts resolved)212```213214**Output On Partial Success**215216```217## Bulk Archive Complete (partial)218219Archived N changes:220- <change-1> -> archive/YYYY-MM-DD-<change-1>/221222Skipped M changes:223- <change-2> (user chose not to archive incomplete)224225Failed K changes:226- <change-3>: Archive directory already exists227```228229**Output When No Changes**230231```232## No Changes to Archive233234No active changes found. Create a new change to get started.235```236237**Guardrails**238- Allow any number of changes (1+ is fine, 2+ is the typical use case)239- Always prompt for selection, never auto-select240- Detect spec conflicts early and resolve by checking codebase241- When both changes are implemented, apply specs in chronological order242- Skip spec sync only when implementation is missing (warn user)243- Show clear per-change status before confirming244- Use single confirmation for entire batch245- Track and report all outcomes (success/skip/fail)246- Preserve .openspec.yaml when moving to archive247- Archive directory target uses current date: YYYY-MM-DD-<name>248- If archive target exists, fail that change but continue with others