claude-code-orchestrator-kit 1.0.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.
- package/.claude/agents/database/workers/api-builder.md +155 -0
- package/.claude/agents/database/workers/database-architect.md +193 -0
- package/.claude/agents/database/workers/supabase-auditor.md +1070 -0
- package/.claude/agents/development/workers/code-reviewer.md +968 -0
- package/.claude/agents/development/workers/cost-calculator-specialist.md +683 -0
- package/.claude/agents/development/workers/llm-service-specialist.md +999 -0
- package/.claude/agents/development/workers/skill-builder-v2.md +480 -0
- package/.claude/agents/development/workers/typescript-types-specialist.md +649 -0
- package/.claude/agents/development/workers/utility-builder.md +582 -0
- package/.claude/agents/documentation/workers/technical-writer.md +152 -0
- package/.claude/agents/frontend/workers/fullstack-nextjs-specialist.md +206 -0
- package/.claude/agents/frontend/workers/visual-effects-creator.md +159 -0
- package/.claude/agents/health/orchestrators/bug-orchestrator.md +1045 -0
- package/.claude/agents/health/orchestrators/dead-code-orchestrator.md +1045 -0
- package/.claude/agents/health/orchestrators/dependency-orchestrator.md +1045 -0
- package/.claude/agents/health/orchestrators/security-orchestrator.md +1045 -0
- package/.claude/agents/health/workers/bug-fixer.md +525 -0
- package/.claude/agents/health/workers/bug-hunter.md +649 -0
- package/.claude/agents/health/workers/dead-code-hunter.md +446 -0
- package/.claude/agents/health/workers/dead-code-remover.md +437 -0
- package/.claude/agents/health/workers/dependency-auditor.md +379 -0
- package/.claude/agents/health/workers/dependency-updater.md +436 -0
- package/.claude/agents/health/workers/security-scanner.md +700 -0
- package/.claude/agents/health/workers/vulnerability-fixer.md +524 -0
- package/.claude/agents/infrastructure/workers/infrastructure-specialist.md +156 -0
- package/.claude/agents/infrastructure/workers/orchestration-logic-specialist.md +1260 -0
- package/.claude/agents/infrastructure/workers/qdrant-specialist.md +503 -0
- package/.claude/agents/infrastructure/workers/quality-validator-specialist.md +984 -0
- package/.claude/agents/meta/workers/meta-agent-v3.md +503 -0
- package/.claude/agents/research/workers/problem-investigator.md +507 -0
- package/.claude/agents/research/workers/research-specialist.md +423 -0
- package/.claude/agents/testing/workers/accessibility-tester.md +813 -0
- package/.claude/agents/testing/workers/integration-tester.md +188 -0
- package/.claude/agents/testing/workers/mobile-fixes-implementer.md +252 -0
- package/.claude/agents/testing/workers/mobile-responsiveness-tester.md +180 -0
- package/.claude/agents/testing/workers/performance-optimizer.md +262 -0
- package/.claude/agents/testing/workers/test-writer.md +800 -0
- package/.claude/commands/health-bugs.md +297 -0
- package/.claude/commands/health-cleanup.md +297 -0
- package/.claude/commands/health-deps.md +297 -0
- package/.claude/commands/health-metrics.md +747 -0
- package/.claude/commands/health-security.md +297 -0
- package/.claude/commands/push.md +21 -0
- package/.claude/commands/speckit.analyze.md +184 -0
- package/.claude/commands/speckit.checklist.md +294 -0
- package/.claude/commands/speckit.clarify.md +178 -0
- package/.claude/commands/speckit.constitution.md +78 -0
- package/.claude/commands/speckit.implement.md +182 -0
- package/.claude/commands/speckit.plan.md +87 -0
- package/.claude/commands/speckit.specify.md +250 -0
- package/.claude/commands/speckit.tasks.md +137 -0
- package/.claude/commands/translate-doc.md +95 -0
- package/.claude/commands/worktree-cleanup.md +382 -0
- package/.claude/commands/worktree-create.md +287 -0
- package/.claude/commands/worktree-list.md +239 -0
- package/.claude/commands/worktree-remove.md +339 -0
- package/.claude/schemas/base-plan.schema.json +82 -0
- package/.claude/schemas/bug-plan.schema.json +71 -0
- package/.claude/schemas/dead-code-plan.schema.json +71 -0
- package/.claude/schemas/dependency-plan.schema.json +74 -0
- package/.claude/schemas/security-plan.schema.json +71 -0
- package/.claude/scripts/gates/check-bundle-size.sh +47 -0
- package/.claude/scripts/gates/check-coverage.sh +67 -0
- package/.claude/scripts/gates/check-security.sh +46 -0
- package/.claude/scripts/release.sh +740 -0
- package/.claude/settings.local.json +21 -0
- package/.claude/settings.local.json.example +20 -0
- package/.claude/skills/calculate-priority-score/SKILL.md +229 -0
- package/.claude/skills/calculate-priority-score/scoring-matrix.json +83 -0
- package/.claude/skills/extract-version/SKILL.md +228 -0
- package/.claude/skills/format-commit-message/SKILL.md +189 -0
- package/.claude/skills/format-commit-message/template.md +64 -0
- package/.claude/skills/format-markdown-table/SKILL.md +202 -0
- package/.claude/skills/format-markdown-table/examples.md +84 -0
- package/.claude/skills/format-todo-list/SKILL.md +222 -0
- package/.claude/skills/format-todo-list/template.json +30 -0
- package/.claude/skills/generate-changelog/SKILL.md +258 -0
- package/.claude/skills/generate-changelog/commit-mapping.json +47 -0
- package/.claude/skills/generate-report-header/SKILL.md +228 -0
- package/.claude/skills/generate-report-header/template.md +66 -0
- package/.claude/skills/parse-error-logs/SKILL.md +286 -0
- package/.claude/skills/parse-error-logs/patterns.json +26 -0
- package/.claude/skills/parse-git-status/SKILL.md +164 -0
- package/.claude/skills/parse-package-json/SKILL.md +151 -0
- package/.claude/skills/parse-package-json/schema.json +43 -0
- package/.claude/skills/render-template/SKILL.md +245 -0
- package/.claude/skills/rollback-changes/SKILL.md +582 -0
- package/.claude/skills/rollback-changes/changes-log-schema.json +101 -0
- package/.claude/skills/run-quality-gate/SKILL.md +404 -0
- package/.claude/skills/run-quality-gate/gate-mappings.json +97 -0
- package/.claude/skills/validate-plan-file/SKILL.md +327 -0
- package/.claude/skills/validate-plan-file/schema.json +35 -0
- package/.claude/skills/validate-report-file/SKILL.md +256 -0
- package/.claude/skills/validate-report-file/schema.json +67 -0
- package/.env.example +49 -0
- package/.github/BRANCH_PROTECTION.md +137 -0
- package/.github/workflows/build.yml +70 -0
- package/.github/workflows/claude-code-review.yml +255 -0
- package/.github/workflows/claude.yml +79 -0
- package/.github/workflows/deploy-staging.yml +90 -0
- package/.github/workflows/test.yml +104 -0
- package/.gitignore +116 -0
- package/CLAUDE.md +137 -0
- package/LICENSE +72 -0
- package/README.md +1098 -0
- package/docs/ARCHITECTURE.md +746 -0
- package/docs/Agents Ecosystem/AGENT-ORCHESTRATION.md +568 -0
- package/docs/Agents Ecosystem/AI-AGENT-ECOSYSTEM-README.md +658 -0
- package/docs/Agents Ecosystem/ARCHITECTURE.md +606 -0
- package/docs/Agents Ecosystem/QUALITY-GATES-SPECIFICATION.md +1315 -0
- package/docs/Agents Ecosystem/REPORT-TEMPLATE-STANDARD.md +1324 -0
- package/docs/Agents Ecosystem/spec-kit-comprehensive-updates.md +478 -0
- package/docs/FAQ.md +572 -0
- package/docs/MIGRATION-GUIDE.md +542 -0
- package/docs/PERFORMANCE-OPTIMIZATION.md +494 -0
- package/docs/ROADMAP.md +439 -0
- package/docs/TUTORIAL-CUSTOM-AGENTS.md +2041 -0
- package/docs/USE-CASES.md +706 -0
- package/index.js +96 -0
- package/mcp/.mcp.base.json +21 -0
- package/mcp/.mcp.frontend.json +29 -0
- package/mcp/.mcp.full.json +67 -0
- package/mcp/.mcp.local.example.json +7 -0
- package/mcp/.mcp.local.json +7 -0
- package/mcp/.mcp.n8n.json +45 -0
- package/mcp/.mcp.supabase-full.json +35 -0
- package/mcp/.mcp.supabase-only.json +28 -0
- package/package.json +78 -0
- package/postinstall.js +71 -0
- package/switch-mcp.sh +101 -0
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rollback-changes
|
|
3
|
+
description: Automatically rollback changes from failed workflow phases using changes log files. Use when workflows fail and need to restore previous state, including file restoration, artifact cleanup, and command reversal. Use for error recovery after failed bug fixes, security patches, or refactoring operations.
|
|
4
|
+
allowed-tools: Bash, Read, Write
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Rollback Changes
|
|
8
|
+
|
|
9
|
+
Automatically rollback changes from failed workflow phases by reading changes log files and reversing all tracked modifications.
|
|
10
|
+
|
|
11
|
+
## When to Use
|
|
12
|
+
|
|
13
|
+
- Workflow phase fails and needs state restoration
|
|
14
|
+
- Automated rollback after failed bug fixes
|
|
15
|
+
- Restore previous state after failed security patches
|
|
16
|
+
- Cleanup after failed refactoring operations
|
|
17
|
+
- Error recovery in worker agents
|
|
18
|
+
- Quality gate failures requiring revert
|
|
19
|
+
|
|
20
|
+
## Instructions
|
|
21
|
+
|
|
22
|
+
### Step 1: Read Changes Log File
|
|
23
|
+
|
|
24
|
+
Use Read tool to load the changes log file.
|
|
25
|
+
|
|
26
|
+
**Expected Input**:
|
|
27
|
+
- `changes_log_path`: String (path to changes log JSON, e.g., `.bug-changes.json`)
|
|
28
|
+
- `phase`: String (workflow phase name, e.g., "bug-fixing")
|
|
29
|
+
- `confirmation_required`: Boolean (default: true, ask user before rollback)
|
|
30
|
+
|
|
31
|
+
**Tools Used**: Read
|
|
32
|
+
|
|
33
|
+
### Step 2: Parse Changes Log
|
|
34
|
+
|
|
35
|
+
Parse the JSON content and validate structure.
|
|
36
|
+
|
|
37
|
+
**Required Fields**:
|
|
38
|
+
- `phase`: String (workflow phase that made changes)
|
|
39
|
+
- `timestamp`: String (ISO-8601 timestamp)
|
|
40
|
+
- `files_modified`: Array of objects with `{path, backup}` (files with backups)
|
|
41
|
+
- `files_created`: Array of strings (new files created)
|
|
42
|
+
- `commands_executed`: Array of strings (commands that were run)
|
|
43
|
+
- `git_commits`: Array of strings (commit SHAs if any)
|
|
44
|
+
|
|
45
|
+
**Optional Fields**:
|
|
46
|
+
- `artifacts`: Array of strings (temporary files to remove)
|
|
47
|
+
- `plan_files`: Array of strings (plan files to remove)
|
|
48
|
+
- `metadata`: Object (additional context)
|
|
49
|
+
|
|
50
|
+
### Step 3: Request Confirmation (if required)
|
|
51
|
+
|
|
52
|
+
If `confirmation_required` is true, ask user for confirmation.
|
|
53
|
+
|
|
54
|
+
**Confirmation Prompt**:
|
|
55
|
+
```
|
|
56
|
+
Rollback changes from phase "{phase}"?
|
|
57
|
+
|
|
58
|
+
Changes to revert:
|
|
59
|
+
- Files modified: {count}
|
|
60
|
+
- Files created: {count}
|
|
61
|
+
- Commands executed: {count}
|
|
62
|
+
- Git commits: {count}
|
|
63
|
+
|
|
64
|
+
This action will:
|
|
65
|
+
1. Restore {count} files from backups
|
|
66
|
+
2. Delete {count} created files
|
|
67
|
+
3. Revert {count} commands
|
|
68
|
+
4. Revert {count} git commits
|
|
69
|
+
|
|
70
|
+
Proceed with rollback? (yes/no)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**If user says "no"**: Return without taking action (dry run result)
|
|
74
|
+
|
|
75
|
+
**If `confirmation_required` is false**: Skip confirmation and proceed
|
|
76
|
+
|
|
77
|
+
### Step 4: Restore Modified Files
|
|
78
|
+
|
|
79
|
+
For each file in `files_modified`, restore from backup.
|
|
80
|
+
|
|
81
|
+
**Restoration Process**:
|
|
82
|
+
```bash
|
|
83
|
+
# For each {path, backup} in files_modified:
|
|
84
|
+
if [ -f "{backup}" ]; then
|
|
85
|
+
cp "{backup}" "{path}"
|
|
86
|
+
echo "✓ Restored {path} from {backup}"
|
|
87
|
+
else
|
|
88
|
+
echo "⚠ Backup not found: {backup} (skipping)"
|
|
89
|
+
fi
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Error Handling**:
|
|
93
|
+
- Missing backup file: Log warning, continue with other files
|
|
94
|
+
- Copy failure: Log error, continue with other files
|
|
95
|
+
- Permission issues: Log error, continue with other files
|
|
96
|
+
|
|
97
|
+
**Tools Used**: Bash
|
|
98
|
+
|
|
99
|
+
### Step 5: Delete Created Files
|
|
100
|
+
|
|
101
|
+
For each file in `files_created`, delete if it exists.
|
|
102
|
+
|
|
103
|
+
**Deletion Process**:
|
|
104
|
+
```bash
|
|
105
|
+
# For each file in files_created:
|
|
106
|
+
if [ -f "{file}" ]; then
|
|
107
|
+
rm "{file}"
|
|
108
|
+
echo "✓ Deleted created file: {file}"
|
|
109
|
+
elif [ -d "{file}" ]; then
|
|
110
|
+
rm -rf "{file}"
|
|
111
|
+
echo "✓ Deleted created directory: {file}"
|
|
112
|
+
else
|
|
113
|
+
echo "⚠ File not found (already deleted?): {file}"
|
|
114
|
+
fi
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Error Handling**:
|
|
118
|
+
- File not found: Log warning (may already be deleted)
|
|
119
|
+
- Permission issues: Log error, continue with other files
|
|
120
|
+
- Directory not empty: Use `rm -rf` with caution
|
|
121
|
+
|
|
122
|
+
**Tools Used**: Bash
|
|
123
|
+
|
|
124
|
+
### Step 6: Revert Commands
|
|
125
|
+
|
|
126
|
+
For each command in `commands_executed`, attempt to revert.
|
|
127
|
+
|
|
128
|
+
**Revert Mapping**:
|
|
129
|
+
- `pnpm install` → `pnpm install` (re-run to restore lockfile)
|
|
130
|
+
- `git add {files}` → `git restore --staged {files}`
|
|
131
|
+
- `git commit` → Handled in Step 7
|
|
132
|
+
- `pnpm build` → `rm -rf dist/` (remove build artifacts)
|
|
133
|
+
- Custom commands → Log only (cannot automatically revert)
|
|
134
|
+
|
|
135
|
+
**Revert Process**:
|
|
136
|
+
```bash
|
|
137
|
+
# For each command:
|
|
138
|
+
case "{command}" in
|
|
139
|
+
"pnpm install")
|
|
140
|
+
pnpm install
|
|
141
|
+
echo "✓ Re-ran pnpm install to restore dependencies"
|
|
142
|
+
;;
|
|
143
|
+
"git add "*)
|
|
144
|
+
git restore --staged .
|
|
145
|
+
echo "✓ Unstaged all files"
|
|
146
|
+
;;
|
|
147
|
+
"pnpm build")
|
|
148
|
+
rm -rf dist/
|
|
149
|
+
echo "✓ Removed build artifacts"
|
|
150
|
+
;;
|
|
151
|
+
*)
|
|
152
|
+
echo "⚠ Cannot auto-revert: {command} (manual intervention required)"
|
|
153
|
+
;;
|
|
154
|
+
esac
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Error Handling**:
|
|
158
|
+
- Command fails: Log error, continue with other commands
|
|
159
|
+
- Unknown command: Log warning, cannot revert
|
|
160
|
+
- Already reverted: Log info, continue
|
|
161
|
+
|
|
162
|
+
**Tools Used**: Bash
|
|
163
|
+
|
|
164
|
+
### Step 7: Revert Git Commits
|
|
165
|
+
|
|
166
|
+
For each commit SHA in `git_commits`, revert the commit.
|
|
167
|
+
|
|
168
|
+
**Revert Process**:
|
|
169
|
+
```bash
|
|
170
|
+
# For each SHA in git_commits (in reverse order):
|
|
171
|
+
git revert --no-edit {sha}
|
|
172
|
+
if [ $? -eq 0 ]; then
|
|
173
|
+
echo "✓ Reverted commit {sha}"
|
|
174
|
+
else
|
|
175
|
+
echo "❌ Failed to revert commit {sha} (may have conflicts)"
|
|
176
|
+
fi
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Error Handling**:
|
|
180
|
+
- Revert conflicts: Log error, provide manual instructions
|
|
181
|
+
- Commit not found: Log error, skip commit
|
|
182
|
+
- Detached HEAD: Log error, skip git operations
|
|
183
|
+
|
|
184
|
+
**Tools Used**: Bash
|
|
185
|
+
|
|
186
|
+
### Step 8: Cleanup Artifacts
|
|
187
|
+
|
|
188
|
+
Remove temporary files and plan files.
|
|
189
|
+
|
|
190
|
+
**Cleanup Process**:
|
|
191
|
+
```bash
|
|
192
|
+
# Remove plan files
|
|
193
|
+
rm -f .{workflow}-plan.json
|
|
194
|
+
|
|
195
|
+
# Remove other artifacts if specified
|
|
196
|
+
for artifact in {artifacts}; do
|
|
197
|
+
rm -f "{artifact}"
|
|
198
|
+
echo "✓ Removed artifact: {artifact}"
|
|
199
|
+
done
|
|
200
|
+
|
|
201
|
+
# Remove rollback backups (optional, only if all succeeded)
|
|
202
|
+
if [ {all_succeeded} == true ]; then
|
|
203
|
+
rm -rf .rollback/
|
|
204
|
+
echo "✓ Removed rollback backups"
|
|
205
|
+
fi
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Tools Used**: Bash
|
|
209
|
+
|
|
210
|
+
### Step 9: Generate Rollback Report
|
|
211
|
+
|
|
212
|
+
Create a structured report of all actions taken.
|
|
213
|
+
|
|
214
|
+
**Report Structure**:
|
|
215
|
+
```json
|
|
216
|
+
{
|
|
217
|
+
"success": true|false,
|
|
218
|
+
"phase": "bug-fixing",
|
|
219
|
+
"actions_taken": [
|
|
220
|
+
"Restored 3 files from backups",
|
|
221
|
+
"Deleted 2 created files",
|
|
222
|
+
"Reverted 1 git commit",
|
|
223
|
+
"Cleaned up 2 artifacts"
|
|
224
|
+
],
|
|
225
|
+
"files_restored": 3,
|
|
226
|
+
"files_deleted": 2,
|
|
227
|
+
"commands_reverted": 1,
|
|
228
|
+
"git_commits_reverted": 1,
|
|
229
|
+
"artifacts_cleaned": 2,
|
|
230
|
+
"errors": [],
|
|
231
|
+
"warnings": [
|
|
232
|
+
"Backup not found: .rollback/file.backup (skipped)"
|
|
233
|
+
],
|
|
234
|
+
"timestamp": "2025-10-18T14:45:00Z",
|
|
235
|
+
"duration_ms": 1234
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**Tools Used**: Write
|
|
240
|
+
|
|
241
|
+
### Step 10: Return Structured Output
|
|
242
|
+
|
|
243
|
+
Return complete rollback result.
|
|
244
|
+
|
|
245
|
+
**Expected Output**:
|
|
246
|
+
```json
|
|
247
|
+
{
|
|
248
|
+
"success": true,
|
|
249
|
+
"phase": "bug-fixing",
|
|
250
|
+
"actions_taken": [
|
|
251
|
+
"Restored src/app.ts from .rollback/src-app.ts.backup",
|
|
252
|
+
"Deleted src/new-file.ts",
|
|
253
|
+
"Reverted git commit abc123",
|
|
254
|
+
"Removed artifact .bug-fixing-plan.json"
|
|
255
|
+
],
|
|
256
|
+
"files_restored": 1,
|
|
257
|
+
"files_deleted": 1,
|
|
258
|
+
"commands_reverted": 0,
|
|
259
|
+
"git_commits_reverted": 1,
|
|
260
|
+
"artifacts_cleaned": 1,
|
|
261
|
+
"errors": [],
|
|
262
|
+
"warnings": [],
|
|
263
|
+
"timestamp": "2025-10-18T14:45:00Z",
|
|
264
|
+
"duration_ms": 1234
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Error Handling
|
|
269
|
+
|
|
270
|
+
- **Missing Changes Log**: Return error "Changes log not found at {path}"
|
|
271
|
+
- **Invalid JSON**: Return error "Invalid JSON in changes log: {details}"
|
|
272
|
+
- **Missing Required Fields**: Return error "Changes log missing required field: {field}"
|
|
273
|
+
- **Backup Not Found**: Log warning, continue with other files (partial rollback)
|
|
274
|
+
- **File Deletion Failed**: Log error, continue with other files
|
|
275
|
+
- **Git Revert Failed**: Log error with conflict details, continue with other operations
|
|
276
|
+
- **User Declined**: Return dry run result with `success: false, user_declined: true`
|
|
277
|
+
- **Partial Rollback**: Return `success: true` with warnings array documenting issues
|
|
278
|
+
|
|
279
|
+
## Examples
|
|
280
|
+
|
|
281
|
+
### Example 1: Full Rollback (All Operations Succeed)
|
|
282
|
+
|
|
283
|
+
**Input**:
|
|
284
|
+
```json
|
|
285
|
+
{
|
|
286
|
+
"changes_log_path": ".bug-changes.json",
|
|
287
|
+
"phase": "bug-fixing",
|
|
288
|
+
"confirmation_required": false
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
**Changes Log Content**:
|
|
293
|
+
```json
|
|
294
|
+
{
|
|
295
|
+
"phase": "bug-fixing",
|
|
296
|
+
"timestamp": "2025-10-18T14:30:00Z",
|
|
297
|
+
"files_modified": [
|
|
298
|
+
{"path": "src/app.ts", "backup": ".rollback/src-app.ts.backup"},
|
|
299
|
+
{"path": "src/utils.ts", "backup": ".rollback/src-utils.ts.backup"}
|
|
300
|
+
],
|
|
301
|
+
"files_created": ["src/new-helper.ts"],
|
|
302
|
+
"commands_executed": ["pnpm install", "pnpm build"],
|
|
303
|
+
"git_commits": ["abc123def456"],
|
|
304
|
+
"artifacts": [".bug-fixing-plan.json"]
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
**Output**:
|
|
309
|
+
```json
|
|
310
|
+
{
|
|
311
|
+
"success": true,
|
|
312
|
+
"phase": "bug-fixing",
|
|
313
|
+
"actions_taken": [
|
|
314
|
+
"Restored src/app.ts from .rollback/src-app.ts.backup",
|
|
315
|
+
"Restored src/utils.ts from .rollback/src-utils.ts.backup",
|
|
316
|
+
"Deleted src/new-helper.ts",
|
|
317
|
+
"Re-ran pnpm install to restore dependencies",
|
|
318
|
+
"Removed build artifacts (dist/)",
|
|
319
|
+
"Reverted git commit abc123def456",
|
|
320
|
+
"Removed artifact .bug-fixing-plan.json"
|
|
321
|
+
],
|
|
322
|
+
"files_restored": 2,
|
|
323
|
+
"files_deleted": 1,
|
|
324
|
+
"commands_reverted": 2,
|
|
325
|
+
"git_commits_reverted": 1,
|
|
326
|
+
"artifacts_cleaned": 1,
|
|
327
|
+
"errors": [],
|
|
328
|
+
"warnings": [],
|
|
329
|
+
"timestamp": "2025-10-18T14:45:00Z",
|
|
330
|
+
"duration_ms": 2345
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Example 2: Partial Rollback (Some Backups Missing)
|
|
335
|
+
|
|
336
|
+
**Input**:
|
|
337
|
+
```json
|
|
338
|
+
{
|
|
339
|
+
"changes_log_path": ".security-changes.json",
|
|
340
|
+
"phase": "security-remediation",
|
|
341
|
+
"confirmation_required": false
|
|
342
|
+
}
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
**Changes Log Content**:
|
|
346
|
+
```json
|
|
347
|
+
{
|
|
348
|
+
"phase": "security-remediation",
|
|
349
|
+
"timestamp": "2025-10-18T14:30:00Z",
|
|
350
|
+
"files_modified": [
|
|
351
|
+
{"path": "src/auth.ts", "backup": ".rollback/src-auth.ts.backup"},
|
|
352
|
+
{"path": "src/db.ts", "backup": ".rollback/src-db.ts.backup"}
|
|
353
|
+
],
|
|
354
|
+
"files_created": ["src/new-auth.ts"],
|
|
355
|
+
"commands_executed": [],
|
|
356
|
+
"git_commits": []
|
|
357
|
+
}
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
**Scenario**: Backup for `src/db.ts` is missing
|
|
361
|
+
|
|
362
|
+
**Output**:
|
|
363
|
+
```json
|
|
364
|
+
{
|
|
365
|
+
"success": true,
|
|
366
|
+
"phase": "security-remediation",
|
|
367
|
+
"actions_taken": [
|
|
368
|
+
"Restored src/auth.ts from .rollback/src-auth.ts.backup",
|
|
369
|
+
"Deleted src/new-auth.ts"
|
|
370
|
+
],
|
|
371
|
+
"files_restored": 1,
|
|
372
|
+
"files_deleted": 1,
|
|
373
|
+
"commands_reverted": 0,
|
|
374
|
+
"git_commits_reverted": 0,
|
|
375
|
+
"artifacts_cleaned": 0,
|
|
376
|
+
"errors": [],
|
|
377
|
+
"warnings": [
|
|
378
|
+
"Backup not found: .rollback/src-db.ts.backup (file not restored)"
|
|
379
|
+
],
|
|
380
|
+
"timestamp": "2025-10-18T14:45:00Z",
|
|
381
|
+
"duration_ms": 456
|
|
382
|
+
}
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### Example 3: Dry Run (User Declines)
|
|
386
|
+
|
|
387
|
+
**Input**:
|
|
388
|
+
```json
|
|
389
|
+
{
|
|
390
|
+
"changes_log_path": ".refactor-changes.json",
|
|
391
|
+
"phase": "refactoring",
|
|
392
|
+
"confirmation_required": true
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
**User Response**: "no"
|
|
397
|
+
|
|
398
|
+
**Output**:
|
|
399
|
+
```json
|
|
400
|
+
{
|
|
401
|
+
"success": false,
|
|
402
|
+
"phase": "refactoring",
|
|
403
|
+
"user_declined": true,
|
|
404
|
+
"actions_taken": [],
|
|
405
|
+
"files_restored": 0,
|
|
406
|
+
"files_deleted": 0,
|
|
407
|
+
"commands_reverted": 0,
|
|
408
|
+
"git_commits_reverted": 0,
|
|
409
|
+
"artifacts_cleaned": 0,
|
|
410
|
+
"errors": [],
|
|
411
|
+
"warnings": [],
|
|
412
|
+
"timestamp": "2025-10-18T14:45:00Z",
|
|
413
|
+
"duration_ms": 0
|
|
414
|
+
}
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
### Example 4: No Changes Log (File Missing)
|
|
418
|
+
|
|
419
|
+
**Input**:
|
|
420
|
+
```json
|
|
421
|
+
{
|
|
422
|
+
"changes_log_path": ".nonexistent-changes.json",
|
|
423
|
+
"phase": "unknown",
|
|
424
|
+
"confirmation_required": false
|
|
425
|
+
}
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
**Output**:
|
|
429
|
+
```json
|
|
430
|
+
{
|
|
431
|
+
"success": false,
|
|
432
|
+
"phase": "unknown",
|
|
433
|
+
"actions_taken": [],
|
|
434
|
+
"files_restored": 0,
|
|
435
|
+
"files_deleted": 0,
|
|
436
|
+
"commands_reverted": 0,
|
|
437
|
+
"git_commits_reverted": 0,
|
|
438
|
+
"artifacts_cleaned": 0,
|
|
439
|
+
"errors": [
|
|
440
|
+
"Changes log not found at .nonexistent-changes.json"
|
|
441
|
+
],
|
|
442
|
+
"warnings": [],
|
|
443
|
+
"timestamp": "2025-10-18T14:45:00Z",
|
|
444
|
+
"duration_ms": 10
|
|
445
|
+
}
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Example 5: Git Revert with Conflicts
|
|
449
|
+
|
|
450
|
+
**Input**:
|
|
451
|
+
```json
|
|
452
|
+
{
|
|
453
|
+
"changes_log_path": ".bug-changes.json",
|
|
454
|
+
"phase": "bug-fixing",
|
|
455
|
+
"confirmation_required": false
|
|
456
|
+
}
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
**Changes Log Content**:
|
|
460
|
+
```json
|
|
461
|
+
{
|
|
462
|
+
"phase": "bug-fixing",
|
|
463
|
+
"timestamp": "2025-10-18T14:30:00Z",
|
|
464
|
+
"files_modified": [],
|
|
465
|
+
"files_created": [],
|
|
466
|
+
"commands_executed": [],
|
|
467
|
+
"git_commits": ["abc123", "def456"]
|
|
468
|
+
}
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
**Scenario**: Reverting `abc123` causes conflicts
|
|
472
|
+
|
|
473
|
+
**Output**:
|
|
474
|
+
```json
|
|
475
|
+
{
|
|
476
|
+
"success": true,
|
|
477
|
+
"phase": "bug-fixing",
|
|
478
|
+
"actions_taken": [
|
|
479
|
+
"Reverted git commit def456"
|
|
480
|
+
],
|
|
481
|
+
"files_restored": 0,
|
|
482
|
+
"files_deleted": 0,
|
|
483
|
+
"commands_reverted": 0,
|
|
484
|
+
"git_commits_reverted": 1,
|
|
485
|
+
"artifacts_cleaned": 0,
|
|
486
|
+
"errors": [
|
|
487
|
+
"Failed to revert commit abc123: Merge conflict in src/app.ts"
|
|
488
|
+
],
|
|
489
|
+
"warnings": [
|
|
490
|
+
"Manual resolution required for commit abc123"
|
|
491
|
+
],
|
|
492
|
+
"timestamp": "2025-10-18T14:45:00Z",
|
|
493
|
+
"duration_ms": 876
|
|
494
|
+
}
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
## Validation
|
|
498
|
+
|
|
499
|
+
- [ ] Reads and parses changes log correctly
|
|
500
|
+
- [ ] Requests user confirmation when required
|
|
501
|
+
- [ ] Restores files from backups successfully
|
|
502
|
+
- [ ] Deletes created files correctly
|
|
503
|
+
- [ ] Reverts commands appropriately
|
|
504
|
+
- [ ] Handles git revert operations
|
|
505
|
+
- [ ] Cleans up artifacts
|
|
506
|
+
- [ ] Generates structured report
|
|
507
|
+
- [ ] Handles partial rollback gracefully
|
|
508
|
+
- [ ] Returns clear error messages for failures
|
|
509
|
+
- [ ] Logs warnings for non-critical issues
|
|
510
|
+
- [ ] Completes within reasonable time (< 30 seconds typical)
|
|
511
|
+
|
|
512
|
+
## Safety Features
|
|
513
|
+
|
|
514
|
+
### Confirmation by Default
|
|
515
|
+
- Always ask for confirmation unless explicitly disabled
|
|
516
|
+
- Show clear summary of what will be reverted
|
|
517
|
+
- Allow user to cancel before any changes
|
|
518
|
+
|
|
519
|
+
### Partial Rollback Acceptable
|
|
520
|
+
- Don't fail entirely if some backups are missing
|
|
521
|
+
- Continue with other operations when one fails
|
|
522
|
+
- Document all issues in warnings array
|
|
523
|
+
|
|
524
|
+
### No Silent Failures
|
|
525
|
+
- Log all errors and warnings explicitly
|
|
526
|
+
- Return detailed actions_taken array
|
|
527
|
+
- Provide troubleshooting context in errors
|
|
528
|
+
|
|
529
|
+
### Backup Verification
|
|
530
|
+
- Never delete original files without verifying backup exists
|
|
531
|
+
- Check backup file exists before restoration
|
|
532
|
+
- Preserve backups until full rollback succeeds
|
|
533
|
+
|
|
534
|
+
### Audit Trail
|
|
535
|
+
- Log all rollback actions for debugging
|
|
536
|
+
- Include timestamps and durations
|
|
537
|
+
- Return complete report for documentation
|
|
538
|
+
|
|
539
|
+
## Integration with Workers
|
|
540
|
+
|
|
541
|
+
Workers should create changes log files during operations:
|
|
542
|
+
|
|
543
|
+
```markdown
|
|
544
|
+
## Step 2: Track Changes
|
|
545
|
+
|
|
546
|
+
Before making any modifications:
|
|
547
|
+
1. Create changes log: `.{domain}-changes.json`
|
|
548
|
+
2. For each file modified:
|
|
549
|
+
- Create backup in `.rollback/{path}.backup`
|
|
550
|
+
- Add to `files_modified` array
|
|
551
|
+
3. For each file created:
|
|
552
|
+
- Add to `files_created` array
|
|
553
|
+
4. For each command executed:
|
|
554
|
+
- Add to `commands_executed` array
|
|
555
|
+
5. For each git commit:
|
|
556
|
+
- Add SHA to `git_commits` array
|
|
557
|
+
6. Write changes log after each modification
|
|
558
|
+
|
|
559
|
+
## Step 5: Rollback on Failure
|
|
560
|
+
|
|
561
|
+
If quality gate fails or error occurs:
|
|
562
|
+
1. Use rollback-changes Skill with:
|
|
563
|
+
- changes_log_path: ".{domain}-changes.json"
|
|
564
|
+
- phase: "{current-phase}"
|
|
565
|
+
- confirmation_required: false (automated rollback)
|
|
566
|
+
2. If rollback succeeds, report clean state
|
|
567
|
+
3. If rollback fails, report partial state with warnings
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
## Supporting Files
|
|
571
|
+
|
|
572
|
+
- `changes-log-schema.json`: JSON schema for changes log format (see below)
|
|
573
|
+
|
|
574
|
+
## Notes
|
|
575
|
+
|
|
576
|
+
- Rollback operations are best-effort (may not be 100% reversible)
|
|
577
|
+
- Git revert operations may require manual conflict resolution
|
|
578
|
+
- Some commands (custom scripts) cannot be automatically reverted
|
|
579
|
+
- Backups should be stored in `.rollback/` directory (gitignored)
|
|
580
|
+
- Changes log files should be temporary (removed after successful completion)
|
|
581
|
+
- Partial rollback is acceptable and documented in warnings
|
|
582
|
+
- Always verify backup exists before deletion operations
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Changes Log Schema",
|
|
4
|
+
"description": "Schema for tracking changes during workflow phases to enable automatic rollback",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["phase", "timestamp", "files_modified", "files_created", "commands_executed", "git_commits"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"phase": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Workflow phase that made the changes (e.g., 'bug-fixing', 'security-remediation')",
|
|
11
|
+
"examples": ["bug-fixing", "security-remediation", "refactoring", "dependency-update"]
|
|
12
|
+
},
|
|
13
|
+
"timestamp": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"format": "date-time",
|
|
16
|
+
"description": "ISO-8601 timestamp when changes were started"
|
|
17
|
+
},
|
|
18
|
+
"files_modified": {
|
|
19
|
+
"type": "array",
|
|
20
|
+
"description": "Files that were modified with their backup locations",
|
|
21
|
+
"items": {
|
|
22
|
+
"type": "object",
|
|
23
|
+
"required": ["path", "backup"],
|
|
24
|
+
"properties": {
|
|
25
|
+
"path": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"description": "Original file path (e.g., 'src/app.ts')"
|
|
28
|
+
},
|
|
29
|
+
"backup": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"description": "Backup file path (e.g., '.rollback/src-app.ts.backup')"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files_created": {
|
|
37
|
+
"type": "array",
|
|
38
|
+
"description": "New files or directories created during the phase",
|
|
39
|
+
"items": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"description": "Path to created file or directory"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"commands_executed": {
|
|
45
|
+
"type": "array",
|
|
46
|
+
"description": "Shell commands that were executed",
|
|
47
|
+
"items": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"description": "Full command string (e.g., 'pnpm install', 'git add .')"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"git_commits": {
|
|
53
|
+
"type": "array",
|
|
54
|
+
"description": "Git commit SHAs created during the phase",
|
|
55
|
+
"items": {
|
|
56
|
+
"type": "string",
|
|
57
|
+
"pattern": "^[0-9a-f]{7,40}$",
|
|
58
|
+
"description": "Git commit SHA (short or full)"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"artifacts": {
|
|
62
|
+
"type": "array",
|
|
63
|
+
"description": "Temporary files to remove during rollback (optional)",
|
|
64
|
+
"items": {
|
|
65
|
+
"type": "string",
|
|
66
|
+
"description": "Path to artifact file"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"plan_files": {
|
|
70
|
+
"type": "array",
|
|
71
|
+
"description": "Plan files created during the workflow (optional)",
|
|
72
|
+
"items": {
|
|
73
|
+
"type": "string",
|
|
74
|
+
"pattern": "^\\..*-plan\\.json$",
|
|
75
|
+
"description": "Plan file path (e.g., '.bug-fixing-plan.json')"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"metadata": {
|
|
79
|
+
"type": "object",
|
|
80
|
+
"description": "Additional context about the changes",
|
|
81
|
+
"properties": {
|
|
82
|
+
"workflow": {
|
|
83
|
+
"type": "string",
|
|
84
|
+
"description": "Parent workflow name"
|
|
85
|
+
},
|
|
86
|
+
"agent": {
|
|
87
|
+
"type": "string",
|
|
88
|
+
"description": "Agent that made the changes"
|
|
89
|
+
},
|
|
90
|
+
"iteration": {
|
|
91
|
+
"type": "integer",
|
|
92
|
+
"description": "Iteration number if part of retry loop"
|
|
93
|
+
},
|
|
94
|
+
"reason": {
|
|
95
|
+
"type": "string",
|
|
96
|
+
"description": "Reason for the changes"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|