Skip to content

Commit cd172a4

Browse files
authored
feat: add smart sync check to /opsx:archive command (#452)
Instead of blindly asking "want to sync?", archive now performs a quick check to see if delta specs actually need syncing: - Extracts requirement names from delta specs - Checks if corresponding main spec exists - Checks if ADDED requirements appear in main spec - Only prompts if sync appears needed Also improves archive output to always show specs status: - ✓ Synced to main specs - No delta specs - ⚠️ Not synced
1 parent b7f5a42 commit cd172a4

File tree

1 file changed

+69
-15
lines changed

1 file changed

+69
-15
lines changed

src/core/templates/skill-templates.ts

Lines changed: 69 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,14 +1099,38 @@ export function getArchiveChangeSkillTemplate(): SkillTemplate {
10991099
11001100
**If no tasks file exists:** Proceed without task-related warning.
11011101
1102-
4. **Check for delta specs and prompt for sync**
1102+
4. **Check if delta specs need syncing**
11031103
11041104
Check if \`specs/\` directory exists in the change with spec files.
11051105
1106-
**If delta specs exist:**
1107-
- Prompt: "This change has delta specs. Would you like to sync them to main specs before archiving?"
1108-
- If user confirms, execute /opsx:sync logic (use the openspec-sync-specs skill)
1109-
- Proceed with archive regardless of sync choice
1106+
**If delta specs exist, perform a quick sync check:**
1107+
1108+
a. **For each delta spec** at \`openspec/changes/<name>/specs/<capability>/spec.md\`:
1109+
- Extract requirement names (lines matching \`### Requirement: <name>\`)
1110+
- Note which sections exist (ADDED, MODIFIED, REMOVED)
1111+
1112+
b. **Check corresponding main spec** at \`openspec/specs/<capability>/spec.md\`:
1113+
- If main spec doesn't exist → needs sync
1114+
- If main spec exists, check if ADDED requirement names appear in it
1115+
- If any ADDED requirements are missing from main spec → needs sync
1116+
1117+
c. **Report findings:**
1118+
1119+
**If sync needed:**
1120+
\`\`\`
1121+
⚠️ Delta specs may not be synced:
1122+
- specs/auth/spec.md → Main spec missing requirement "Token Refresh"
1123+
- specs/api/spec.md → Main spec doesn't exist yet
1124+
1125+
Would you like to sync now before archiving?
1126+
\`\`\`
1127+
- Use **AskUserQuestion tool** with options: "Sync now", "Archive without syncing"
1128+
- If user chooses sync, execute /opsx:sync logic (use the openspec-sync-specs skill)
1129+
1130+
**If already synced (all requirements found):**
1131+
- Proceed without prompting (specs appear to be in sync)
1132+
1133+
**If no delta specs exist:** Proceed without sync-related checks.
11101134
11111135
5. **Perform the archive**
11121136
@@ -1142,6 +1166,7 @@ export function getArchiveChangeSkillTemplate(): SkillTemplate {
11421166
**Change:** <change-name>
11431167
**Schema:** <schema-name>
11441168
**Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
1169+
**Specs:** ✓ Synced to main specs (or "No delta specs" or "⚠️ Not synced")
11451170
11461171
All artifacts complete. All tasks complete.
11471172
\`\`\`
@@ -1152,7 +1177,8 @@ All artifacts complete. All tasks complete.
11521177
- Don't block archive on warnings - just inform and confirm
11531178
- Preserve .openspec.yaml when moving to archive (it moves with the directory)
11541179
- Show clear summary of what happened
1155-
- If sync is requested, use openspec-sync-specs approach (agent-driven)`
1180+
- If sync is requested, use openspec-sync-specs approach (agent-driven)
1181+
- Quick sync check: look for requirement names in delta specs, verify they exist in main specs`
11561182
};
11571183
}
11581184

@@ -1345,14 +1371,38 @@ export function getOpsxArchiveCommandTemplate(): CommandTemplate {
13451371
13461372
**If no tasks file exists:** Proceed without task-related warning.
13471373
1348-
4. **Check for delta specs and prompt for sync**
1374+
4. **Check if delta specs need syncing**
13491375
13501376
Check if \`specs/\` directory exists in the change with spec files.
13511377
1352-
**If delta specs exist:**
1353-
- Prompt: "This change has delta specs. Would you like to sync them to main specs before archiving?"
1354-
- If user confirms, execute \`/opsx:sync\` logic
1355-
- Proceed with archive regardless of sync choice
1378+
**If delta specs exist, perform a quick sync check:**
1379+
1380+
a. **For each delta spec** at \`openspec/changes/<name>/specs/<capability>/spec.md\`:
1381+
- Extract requirement names (lines matching \`### Requirement: <name>\`)
1382+
- Note which sections exist (ADDED, MODIFIED, REMOVED)
1383+
1384+
b. **Check corresponding main spec** at \`openspec/specs/<capability>/spec.md\`:
1385+
- If main spec doesn't exist → needs sync
1386+
- If main spec exists, check if ADDED requirement names appear in it
1387+
- If any ADDED requirements are missing from main spec → needs sync
1388+
1389+
c. **Report findings:**
1390+
1391+
**If sync needed:**
1392+
\`\`\`
1393+
⚠️ Delta specs may not be synced:
1394+
- specs/auth/spec.md → Main spec missing requirement "Token Refresh"
1395+
- specs/api/spec.md → Main spec doesn't exist yet
1396+
1397+
Would you like to sync now before archiving?
1398+
\`\`\`
1399+
- Use **AskUserQuestion tool** with options: "Sync now", "Archive without syncing"
1400+
- If user chooses sync, execute \`/opsx:sync\` logic
1401+
1402+
**If already synced (all requirements found):**
1403+
- Proceed without prompting (specs appear to be in sync)
1404+
1405+
**If no delta specs exist:** Proceed without sync-related checks.
13561406
13571407
5. **Perform the archive**
13581408
@@ -1377,7 +1427,7 @@ export function getOpsxArchiveCommandTemplate(): CommandTemplate {
13771427
- Change name
13781428
- Schema that was used
13791429
- Archive location
1380-
- Whether specs were synced (if applicable)
1430+
- Spec sync status (synced / not synced / no delta specs)
13811431
- Note about any warnings (incomplete artifacts/tasks)
13821432
13831433
**Output On Success**
@@ -1388,20 +1438,22 @@ export function getOpsxArchiveCommandTemplate(): CommandTemplate {
13881438
**Change:** <change-name>
13891439
**Schema:** <schema-name>
13901440
**Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
1441+
**Specs:** ✓ Synced to main specs
13911442
13921443
All artifacts complete. All tasks complete.
13931444
\`\`\`
13941445
1395-
**Output On Success With Sync**
1446+
**Output On Success (No Delta Specs)**
13961447
13971448
\`\`\`
13981449
## Archive Complete
13991450
14001451
**Change:** <change-name>
14011452
**Schema:** <schema-name>
14021453
**Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
1454+
**Specs:** No delta specs
14031455
1404-
Specs synced to main before archiving.
1456+
All artifacts complete. All tasks complete.
14051457
\`\`\`
14061458
14071459
**Output On Success With Warnings**
@@ -1412,11 +1464,12 @@ Specs synced to main before archiving.
14121464
**Change:** <change-name>
14131465
**Schema:** <schema-name>
14141466
**Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
1467+
**Specs:** ⚠️ Not synced
14151468
14161469
**Warnings:**
14171470
- Archived with 2 incomplete artifacts
14181471
- Archived with 3 incomplete tasks
1419-
- Delta specs were not synced
1472+
- Delta specs were not synced (user chose to skip)
14201473
14211474
Review the archive if this was not intentional.
14221475
\`\`\`
@@ -1442,6 +1495,7 @@ Target archive directory already exists.
14421495
- Use artifact graph (openspec status --json) for completion checking
14431496
- Don't block archive on warnings - just inform and confirm
14441497
- Preserve .openspec.yaml when moving to archive (it moves with the directory)
1498+
- Quick sync check: look for requirement names in delta specs, verify they exist in main specs
14451499
- Show clear summary of what happened
14461500
- If sync is requested, use /opsx:sync approach (agent-driven)`
14471501
};

0 commit comments

Comments
 (0)