Restore archived increments back to active folder
Restore archived increments back to the active folder for reference, updates, or resuming old work. Use when you need to continue work on a completed increment or review past implementations.
/plugin marketplace add anton-abyzov/specweave/plugin install sw@specweaveRestore an archived increment back to the main increments folder. Useful when you need to reference, update, or continue work on an old increment.
# Restore specific increment
/sw:restore 0031
# Restore multiple increments
/sw:restore 0001 0002 0003
# List archived increments
/sw:restore --list
<increment-ids>: Increment IDs to restore (e.g., "1", "0001", "0031")--list: List all archived increments without restoring/sw:restore 0031
Output:
š¦ Restoring increment from archive...
Increment: 0031-external-tool-status-sync
Source: .specweave/increments/_archive/0031-external-tool-status-sync/
Target: .specweave/increments/0031-external-tool-status-sync/
Checking target location...
ā Target location is empty
ā
Restored: 0031-external-tool-status-sync
Location: .specweave/increments/0031-external-tool-status-sync/
š Archive Statistics:
Active: 33 increments (+ 1 restored)
Archived: 30 increments (- 1)
Next: /sw:do 0031 (to continue work)
/sw:restore --list
Output:
š¦ Archived Increments:
.specweave/increments/_archive/
āāā 0001-core-framework (152 days old)
āāā 0002-plugin-system (148 days old)
āāā 0003-auth-service (145 days old)
āāā 0004-payment-integration (142 days old)
āāā 0005-api-gateway (140 days old)
...
āāā 0030-jira-integration (35 days old)
āāā 0031-external-tool-status-sync (12 days old)
Total: 31 archived increments
To restore: /sw:restore <increment-id>
/sw:restore 0030 0031
Output:
š¦ Restoring increments from archive...
Restoring 0030-jira-integration...
ā
Restored
Restoring 0031-external-tool-status-sync...
ā
Restored
ā
Restored: 2 increments
š Archive Statistics:
Active: 34 increments (+ 2 restored)
Archived: 29 increments (- 2)
ā Error: Increment 0031 not found in archive
Archive location: .specweave/increments/_archive/
Available archived increments:
⢠0001-core-framework
⢠0002-plugin-system
⢠0003-auth-service
...
Use: /sw:restore --list to see all
ā Error: Cannot restore 0031 - already exists in active folder
Conflict:
Archive: .specweave/increments/_archive/0031-external-tool-status-sync/
Active: .specweave/increments/0031-external-tool-status-sync/
Options:
1. Delete active version first (if it's a duplicate)
2. Resolve duplicates: /sw:fix-duplicates
3. Archive active version: /sw:archive 0031
4. Rename one version manually
Recommended: /sw:fix-duplicates (auto-resolves conflicts)
ā Error: Permission denied
Could not move:
From: .specweave/increments/_archive/0031-external-tool-status-sync/
To: .specweave/increments/0031-external-tool-status-sync/
Check:
⢠File permissions
⢠Disk space
⢠Files not open in another program
Before restoring, the system checks:
/sw:archive <increment-id> - Archive completed increments/sw:status - View archive statistics/sw:fix-duplicates - Auto-resolve duplicate increments/sw:do <increment-id> - Resume work on restored incrementimport { Task } from '@claude/types';
const task = new Task('restore-increment', 'Restore increment from archive');
task.run(async () => {
const { IncrementArchiver } = await import('../../../dist/src/core/increment/increment-archiver.js');
const archiver = new IncrementArchiver(process.cwd());
// Parse arguments
const args = process.argv.slice(2);
// List mode
if (args.includes('--list')) {
const archived = await archiver.listArchived();
console.log('\nš¦ Archived Increments:\n');
if (archived.length === 0) {
console.log('No archived increments found.');
return;
}
console.log('.specweave/increments/_archive/');
archived.forEach(inc => {
console.log(`āāā ${inc}`);
});
console.log(`\nTotal: ${archived.length} archived increments`);
console.log('\nTo restore: /sw:restore <increment-id>');
return;
}
// Restore mode
const incrementIds = args.filter(arg => !arg.startsWith('--'));
if (incrementIds.length === 0) {
console.error('ā Error: No increment IDs provided');
console.log('\nUsage:');
console.log(' /sw:restore <increment-id>');
console.log(' /sw:restore --list');
return;
}
// Restore each increment
let restored = 0;
let errors = 0;
for (const id of incrementIds) {
try {
// Normalize ID to 4-digit format
const normalizedId = id.padStart(4, '0');
// Find archived increment
const archived = await archiver.listArchived();
const match = archived.find(inc => inc.startsWith(normalizedId));
if (!match) {
console.error(`ā Increment ${normalizedId} not found in archive`);
errors++;
continue;
}
// Restore increment
await archiver.restore(match);
console.log(`ā
Restored: ${match}`);
restored++;
} catch (error) {
console.error(`ā Failed to restore ${id}: ${error.message}`);
errors++;
}
}
// Show statistics
if (restored > 0 || errors > 0) {
console.log('\nš Restore Summary:');
if (restored > 0) {
console.log(` ā
Restored: ${restored} increment${restored > 1 ? 's' : ''}`);
}
if (errors > 0) {
console.log(` ā Errors: ${errors} increment${errors > 1 ? 's' : ''}`);
}
// Show updated stats
const stats = await archiver.getStats();
console.log('\nš Archive Statistics:');
console.log(` Active: ${stats.active} increments`);
console.log(` Archived: ${stats.archived} increments`);
}
});
export default task;
Archives are preserved history, not deleted work. You can restore anytime:
Common scenarios for restoring from archive:
Once restored, the increment is back in the active folder:
/sw:status/sw:do/sw:archiveBest Practice: Keep archives clean by only restoring when needed, then re-archiving when done.
Recommended Workflow:
# 1. List archived increments
/sw:restore --list
# 2. Restore specific increment
/sw:restore 0031
# 3. Review or update the increment
cat .specweave/increments/0031-external-tool-status-sync/spec.md
# 4. Re-archive when done
/sw:archive 0031