anvil-dev-framework 0.1.6

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.
Files changed (190) hide show
  1. package/README.md +719 -0
  2. package/VERSION +1 -0
  3. package/docs/ANVIL-REPO-IMPLEMENTATION-PLAN.md +441 -0
  4. package/docs/FIRST-SKILL-TUTORIAL.md +408 -0
  5. package/docs/INSTALLATION-RETRO-NOTES.md +458 -0
  6. package/docs/INSTALLATION.md +984 -0
  7. package/docs/anvil-hud.md +469 -0
  8. package/docs/anvil-init.md +255 -0
  9. package/docs/anvil-state.md +210 -0
  10. package/docs/boris-cherny-ralph-wiggum-insights.md +608 -0
  11. package/docs/command-reference.md +2022 -0
  12. package/docs/hooks-tts.md +368 -0
  13. package/docs/implementation-guide.md +810 -0
  14. package/docs/linear-github-integration.md +247 -0
  15. package/docs/local-issues.md +677 -0
  16. package/docs/patterns/README.md +419 -0
  17. package/docs/planning-responsibilities.md +139 -0
  18. package/docs/session-workflow.md +573 -0
  19. package/docs/simplification-plan-template.md +297 -0
  20. package/docs/simplification-principles.md +129 -0
  21. package/docs/specifications/CCS-RALPH-INTEGRATION-DESIGN.md +633 -0
  22. package/docs/specifications/CCS-RESEARCH-REPORT.md +169 -0
  23. package/docs/specifications/PLAN-ANV-verification-ralph-wiggum.md +403 -0
  24. package/docs/specifications/PLAN-parallel-tracks-anvil-memory-ccs.md +494 -0
  25. package/docs/specifications/SPEC-ANV-VRW/component-01-verify.md +208 -0
  26. package/docs/specifications/SPEC-ANV-VRW/component-02-stop-gate.md +226 -0
  27. package/docs/specifications/SPEC-ANV-VRW/component-03-posttooluse.md +209 -0
  28. package/docs/specifications/SPEC-ANV-VRW/component-04-ralph-wiggum.md +604 -0
  29. package/docs/specifications/SPEC-ANV-VRW/component-05-atomic-actions.md +311 -0
  30. package/docs/specifications/SPEC-ANV-VRW/component-06-verify-subagent.md +264 -0
  31. package/docs/specifications/SPEC-ANV-VRW/component-07-claude-md.md +363 -0
  32. package/docs/specifications/SPEC-ANV-VRW/index.md +182 -0
  33. package/docs/specifications/SPEC-ANV-anvil-memory.md +573 -0
  34. package/docs/specifications/SPEC-ANV-context-checkpoints.md +781 -0
  35. package/docs/specifications/SPEC-ANV-verification-ralph-wiggum.md +789 -0
  36. package/docs/sync.md +122 -0
  37. package/global/CLAUDE.md +140 -0
  38. package/global/agents/verify-app.md +164 -0
  39. package/global/commands/anvil-settings.md +527 -0
  40. package/global/commands/anvil-sync.md +121 -0
  41. package/global/commands/change.md +197 -0
  42. package/global/commands/clarify.md +252 -0
  43. package/global/commands/cleanup.md +292 -0
  44. package/global/commands/commit-push-pr.md +207 -0
  45. package/global/commands/decay-review.md +127 -0
  46. package/global/commands/discover.md +158 -0
  47. package/global/commands/doc-coverage.md +122 -0
  48. package/global/commands/evidence.md +307 -0
  49. package/global/commands/explore.md +121 -0
  50. package/global/commands/force-exit.md +135 -0
  51. package/global/commands/handoff.md +191 -0
  52. package/global/commands/healthcheck.md +302 -0
  53. package/global/commands/hud.md +84 -0
  54. package/global/commands/insights.md +319 -0
  55. package/global/commands/linear-setup.md +184 -0
  56. package/global/commands/lint-fix.md +198 -0
  57. package/global/commands/orient.md +510 -0
  58. package/global/commands/plan.md +228 -0
  59. package/global/commands/ralph.md +346 -0
  60. package/global/commands/ready.md +182 -0
  61. package/global/commands/release.md +305 -0
  62. package/global/commands/retro.md +96 -0
  63. package/global/commands/shard.md +166 -0
  64. package/global/commands/spec.md +227 -0
  65. package/global/commands/sprint.md +184 -0
  66. package/global/commands/tasks.md +228 -0
  67. package/global/commands/test-and-commit.md +151 -0
  68. package/global/commands/validate.md +132 -0
  69. package/global/commands/verify.md +251 -0
  70. package/global/commands/weekly-review.md +156 -0
  71. package/global/hooks/__pycache__/ralph_context_monitor.cpython-314.pyc +0 -0
  72. package/global/hooks/__pycache__/statusline_agent_sync.cpython-314.pyc +0 -0
  73. package/global/hooks/anvil_memory_observe.ts +322 -0
  74. package/global/hooks/anvil_memory_session.ts +166 -0
  75. package/global/hooks/anvil_memory_stop.ts +187 -0
  76. package/global/hooks/parse_transcript.py +116 -0
  77. package/global/hooks/post_merge_cleanup.sh +132 -0
  78. package/global/hooks/post_tool_format.sh +215 -0
  79. package/global/hooks/ralph_context_monitor.py +240 -0
  80. package/global/hooks/ralph_stop.sh +502 -0
  81. package/global/hooks/statusline.sh +1110 -0
  82. package/global/hooks/statusline_agent_sync.py +224 -0
  83. package/global/hooks/stop_gate.sh +250 -0
  84. package/global/lib/.claude/anvil-state.json +21 -0
  85. package/global/lib/__pycache__/agent_registry.cpython-314.pyc +0 -0
  86. package/global/lib/__pycache__/claim_service.cpython-314.pyc +0 -0
  87. package/global/lib/__pycache__/coderabbit_service.cpython-314.pyc +0 -0
  88. package/global/lib/__pycache__/config_service.cpython-314.pyc +0 -0
  89. package/global/lib/__pycache__/coordination_service.cpython-314.pyc +0 -0
  90. package/global/lib/__pycache__/doc_coverage_service.cpython-314.pyc +0 -0
  91. package/global/lib/__pycache__/gate_logger.cpython-314.pyc +0 -0
  92. package/global/lib/__pycache__/github_service.cpython-314.pyc +0 -0
  93. package/global/lib/__pycache__/hygiene_service.cpython-314.pyc +0 -0
  94. package/global/lib/__pycache__/issue_models.cpython-314.pyc +0 -0
  95. package/global/lib/__pycache__/issue_provider.cpython-314.pyc +0 -0
  96. package/global/lib/__pycache__/linear_data_service.cpython-314.pyc +0 -0
  97. package/global/lib/__pycache__/linear_provider.cpython-314.pyc +0 -0
  98. package/global/lib/__pycache__/local_provider.cpython-314.pyc +0 -0
  99. package/global/lib/__pycache__/quality_service.cpython-314.pyc +0 -0
  100. package/global/lib/__pycache__/ralph_state.cpython-314.pyc +0 -0
  101. package/global/lib/__pycache__/state_manager.cpython-314.pyc +0 -0
  102. package/global/lib/__pycache__/transcript_parser.cpython-314.pyc +0 -0
  103. package/global/lib/__pycache__/verification_runner.cpython-314.pyc +0 -0
  104. package/global/lib/__pycache__/verify_iteration.cpython-314.pyc +0 -0
  105. package/global/lib/__pycache__/verify_subagent.cpython-314.pyc +0 -0
  106. package/global/lib/agent_registry.py +995 -0
  107. package/global/lib/anvil-state.sh +435 -0
  108. package/global/lib/claim_service.py +515 -0
  109. package/global/lib/coderabbit_service.py +314 -0
  110. package/global/lib/config_service.py +423 -0
  111. package/global/lib/coordination_service.py +331 -0
  112. package/global/lib/doc_coverage_service.py +1305 -0
  113. package/global/lib/gate_logger.py +316 -0
  114. package/global/lib/github_service.py +310 -0
  115. package/global/lib/handoff_generator.py +775 -0
  116. package/global/lib/hygiene_service.py +712 -0
  117. package/global/lib/issue_models.py +257 -0
  118. package/global/lib/issue_provider.py +339 -0
  119. package/global/lib/linear_data_service.py +210 -0
  120. package/global/lib/linear_provider.py +987 -0
  121. package/global/lib/linear_provider.py.backup +671 -0
  122. package/global/lib/local_provider.py +486 -0
  123. package/global/lib/orient_fast.py +457 -0
  124. package/global/lib/quality_service.py +470 -0
  125. package/global/lib/ralph_prompt_generator.py +563 -0
  126. package/global/lib/ralph_state.py +1202 -0
  127. package/global/lib/state_manager.py +417 -0
  128. package/global/lib/transcript_parser.py +597 -0
  129. package/global/lib/verification_runner.py +557 -0
  130. package/global/lib/verify_iteration.py +490 -0
  131. package/global/lib/verify_subagent.py +250 -0
  132. package/global/skills/README.md +155 -0
  133. package/global/skills/quality-gates/SKILL.md +252 -0
  134. package/global/skills/skill-template/SKILL.md +109 -0
  135. package/global/skills/testing-strategies/SKILL.md +337 -0
  136. package/global/templates/CHANGE-template.md +105 -0
  137. package/global/templates/HANDOFF-template.md +63 -0
  138. package/global/templates/PLAN-template.md +111 -0
  139. package/global/templates/SPEC-template.md +93 -0
  140. package/global/templates/ralph/PROMPT.md.template +89 -0
  141. package/global/templates/ralph/fix_plan.md.template +31 -0
  142. package/global/templates/ralph/progress.txt.template +23 -0
  143. package/global/tests/__pycache__/test_doc_coverage.cpython-314.pyc +0 -0
  144. package/global/tests/test_doc_coverage.py +520 -0
  145. package/global/tests/test_issue_models.py +299 -0
  146. package/global/tests/test_local_provider.py +323 -0
  147. package/global/tools/README.md +178 -0
  148. package/global/tools/__pycache__/anvil-hud.cpython-314.pyc +0 -0
  149. package/global/tools/anvil-hud.py +3622 -0
  150. package/global/tools/anvil-hud.py.bak +3318 -0
  151. package/global/tools/anvil-issue.py +432 -0
  152. package/global/tools/anvil-memory/CLAUDE.md +49 -0
  153. package/global/tools/anvil-memory/README.md +42 -0
  154. package/global/tools/anvil-memory/bun.lock +25 -0
  155. package/global/tools/anvil-memory/bunfig.toml +9 -0
  156. package/global/tools/anvil-memory/package.json +23 -0
  157. package/global/tools/anvil-memory/src/__tests__/ccs/context-monitor.test.ts +535 -0
  158. package/global/tools/anvil-memory/src/__tests__/ccs/edge-cases.test.ts +645 -0
  159. package/global/tools/anvil-memory/src/__tests__/ccs/fixtures.ts +363 -0
  160. package/global/tools/anvil-memory/src/__tests__/ccs/index.ts +8 -0
  161. package/global/tools/anvil-memory/src/__tests__/ccs/integration.test.ts +417 -0
  162. package/global/tools/anvil-memory/src/__tests__/ccs/prompt-generator.test.ts +571 -0
  163. package/global/tools/anvil-memory/src/__tests__/ccs/ralph-stop.test.ts +440 -0
  164. package/global/tools/anvil-memory/src/__tests__/ccs/test-utils.ts +252 -0
  165. package/global/tools/anvil-memory/src/__tests__/commands.test.ts +657 -0
  166. package/global/tools/anvil-memory/src/__tests__/db.test.ts +641 -0
  167. package/global/tools/anvil-memory/src/__tests__/hooks.test.ts +272 -0
  168. package/global/tools/anvil-memory/src/__tests__/performance.test.ts +427 -0
  169. package/global/tools/anvil-memory/src/__tests__/test-utils.ts +113 -0
  170. package/global/tools/anvil-memory/src/commands/checkpoint.ts +197 -0
  171. package/global/tools/anvil-memory/src/commands/get.ts +115 -0
  172. package/global/tools/anvil-memory/src/commands/init.ts +94 -0
  173. package/global/tools/anvil-memory/src/commands/observe.ts +163 -0
  174. package/global/tools/anvil-memory/src/commands/search.ts +112 -0
  175. package/global/tools/anvil-memory/src/db.ts +638 -0
  176. package/global/tools/anvil-memory/src/index.ts +205 -0
  177. package/global/tools/anvil-memory/src/types.ts +122 -0
  178. package/global/tools/anvil-memory/tsconfig.json +29 -0
  179. package/global/tools/ralph-loop.sh +359 -0
  180. package/package.json +45 -0
  181. package/scripts/anvil +822 -0
  182. package/scripts/extract_patterns.py +222 -0
  183. package/scripts/init-project.sh +541 -0
  184. package/scripts/install.sh +229 -0
  185. package/scripts/postinstall.js +41 -0
  186. package/scripts/rollback.sh +188 -0
  187. package/scripts/sync.sh +623 -0
  188. package/scripts/test-statusline.sh +248 -0
  189. package/scripts/update_claude_md.py +224 -0
  190. package/scripts/verify.sh +255 -0
@@ -0,0 +1,229 @@
1
+ #!/bin/bash
2
+
3
+ #
4
+ # Anvil Development Framework - Installation Script
5
+ #
6
+ # This script installs Anvil globally to ~/.claude/
7
+ #
8
+
9
+ set -e
10
+
11
+ # Colors
12
+ RED='\033[0;31m'
13
+ GREEN='\033[0;32m'
14
+ YELLOW='\033[1;33m'
15
+ BLUE='\033[0;34m'
16
+ NC='\033[0m' # No Color
17
+
18
+ # Banner
19
+ echo ""
20
+ echo -e "${BLUE}"
21
+ echo " ___ _ ___ _____ _ "
22
+ echo " / \ | \ | \ \ / /_ _| | "
23
+ echo " / /_\ \ | \| |\ \ / / | || | "
24
+ echo " / _____ \| |\ | \ V / | || |___ "
25
+ echo " /_/ \_\_| \_| \_/ |___|_____|"
26
+ echo ""
27
+ echo -e "${NC}"
28
+ echo " Anvil Development Framework Installer"
29
+ echo " ══════════════════════════════════════"
30
+ echo ""
31
+
32
+ # Check if we're in the anvil directory
33
+ if [ ! -f "VERSION" ]; then
34
+ echo -e "${RED}Error: Must run from anvil-dev-framework directory${NC}"
35
+ exit 1
36
+ fi
37
+
38
+ VERSION=$(cat VERSION)
39
+ echo -e "${BLUE}Installing Anvil v${VERSION}...${NC}"
40
+ echo ""
41
+
42
+ # Determine anvil directory
43
+ ANVIL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
44
+
45
+ # Create backup if ~/.claude exists
46
+ if [ -d "$HOME/.claude" ]; then
47
+ BACKUP_DIR="$HOME/.claude-backups/$(date +%Y%m%d_%H%M%S)"
48
+ echo -e "${YELLOW}Backing up existing ~/.claude to ${BACKUP_DIR}${NC}"
49
+ mkdir -p "$BACKUP_DIR"
50
+ cp -r "$HOME/.claude" "$BACKUP_DIR/"
51
+ fi
52
+
53
+ # Create ~/.claude directory structure
54
+ echo -e "${BLUE}Creating directory structure...${NC}"
55
+ mkdir -p "$HOME/.claude"
56
+ mkdir -p "$HOME/.claude/standards"
57
+ mkdir -p "$HOME/.claude/templates"
58
+ mkdir -p "$HOME/.claude/commands"
59
+ mkdir -p "$HOME/.claude/skills"
60
+ mkdir -p "$HOME/.claude/handoffs/archive"
61
+ mkdir -p "$HOME/.claude/analytics"
62
+
63
+ # Copy global files
64
+ echo -e "${BLUE}Installing global configuration...${NC}"
65
+
66
+ # CLAUDE.md (only if doesn't exist or --force)
67
+ if [ ! -f "$HOME/.claude/CLAUDE.md" ] || [ "$1" == "--force" ]; then
68
+ cp "$ANVIL_DIR/global/CLAUDE.md" "$HOME/.claude/CLAUDE.md"
69
+ echo -e " ${GREEN}✓${NC} CLAUDE.md"
70
+ else
71
+ echo -e " ${YELLOW}⊘${NC} CLAUDE.md (exists, use --force to overwrite)"
72
+ fi
73
+
74
+ # Standards
75
+ if [ -d "$ANVIL_DIR/global/standards" ]; then
76
+ for file in "$ANVIL_DIR/global/standards"/*.md; do
77
+ if [ -f "$file" ]; then
78
+ cp "$file" "$HOME/.claude/standards/"
79
+ echo -e " ${GREEN}✓${NC} standards/$(basename "$file")"
80
+ fi
81
+ done
82
+ fi
83
+
84
+ # Templates
85
+ if [ -d "$ANVIL_DIR/global/templates" ]; then
86
+ for file in "$ANVIL_DIR/global/templates"/*.md; do
87
+ if [ -f "$file" ]; then
88
+ cp "$file" "$HOME/.claude/templates/"
89
+ echo -e " ${GREEN}✓${NC} templates/$(basename "$file")"
90
+ fi
91
+ done
92
+ fi
93
+
94
+ # Commands
95
+ if [ -d "$ANVIL_DIR/global/commands" ]; then
96
+ for file in "$ANVIL_DIR/global/commands"/*.md; do
97
+ if [ -f "$file" ]; then
98
+ cp "$file" "$HOME/.claude/commands/"
99
+ echo -e " ${GREEN}✓${NC} commands/$(basename "$file")"
100
+ fi
101
+ done
102
+ fi
103
+
104
+ # Check prerequisites
105
+ echo ""
106
+ echo -e "${BLUE}Checking prerequisites...${NC}"
107
+
108
+ check_tool() {
109
+ if command -v "$1" &> /dev/null; then
110
+ echo -e " ${GREEN}✓${NC} $1 installed"
111
+ return 0
112
+ else
113
+ echo -e " ${RED}✗${NC} $1 not found"
114
+ return 1
115
+ fi
116
+ }
117
+
118
+ MISSING=0
119
+ check_tool "node" || MISSING=1
120
+ check_tool "npm" || MISSING=1
121
+ check_tool "git" || MISSING=1
122
+
123
+ # Optional tools
124
+ echo ""
125
+ echo -e "${BLUE}Checking optional tools...${NC}"
126
+ check_tool "semgrep" || echo -e " ${YELLOW}→ Install with: brew install semgrep${NC}"
127
+ check_tool "trivy" || echo -e " ${YELLOW}→ Install with: brew install trivy${NC}"
128
+ check_tool "gitleaks" || echo -e " ${YELLOW}→ Install with: brew install gitleaks${NC}"
129
+ check_tool "pre-commit" || echo -e " ${YELLOW}→ Install with: brew install pre-commit${NC}"
130
+
131
+ # Create version file
132
+ echo "$VERSION" > "$HOME/.claude/.anvil-version"
133
+
134
+ # Configure shell PATH
135
+ echo ""
136
+ echo -e "${BLUE}Configuring shell environment...${NC}"
137
+
138
+ configure_shell() {
139
+ local shell_rc="$1"
140
+ local shell_name="$2"
141
+
142
+ if [ -f "$shell_rc" ]; then
143
+ # Check if already configured
144
+ if grep -q "ANVIL_HOME" "$shell_rc" 2>/dev/null; then
145
+ # Check if PATH is also configured
146
+ if grep -q 'PATH.*ANVIL_HOME/scripts' "$shell_rc" 2>/dev/null; then
147
+ echo -e " ${GREEN}✓${NC} $shell_name already configured"
148
+ return 0
149
+ else
150
+ # ANVIL_HOME exists but PATH doesn't - add PATH after ANVIL_HOME
151
+ sed -i.bak '/^export ANVIL_HOME=/a\
152
+ export PATH="$PATH:$ANVIL_HOME/scripts"
153
+ ' "$shell_rc"
154
+ rm -f "${shell_rc}.bak"
155
+ echo -e " ${GREEN}✓${NC} Added PATH to $shell_name"
156
+ return 0
157
+ fi
158
+ fi
159
+
160
+ # Add fresh configuration
161
+ cat >> "$shell_rc" << 'EOF'
162
+
163
+ # Anvil Development Framework
164
+ export ANVIL_HOME="$HOME/Projects/anvil-dev-framework"
165
+ export PATH="$PATH:$ANVIL_HOME/scripts"
166
+ EOF
167
+ echo -e " ${GREEN}✓${NC} Configured $shell_name"
168
+ return 0
169
+ fi
170
+ return 1
171
+ }
172
+
173
+ SHELL_CONFIGURED=0
174
+
175
+ # Detect and configure shells
176
+ if [ -n "$ZSH_VERSION" ] || [ "$SHELL" = "/bin/zsh" ] || [ -f "$HOME/.zshrc" ]; then
177
+ configure_shell "$HOME/.zshrc" "zsh" && SHELL_CONFIGURED=1
178
+ fi
179
+
180
+ if [ -n "$BASH_VERSION" ] || [ "$SHELL" = "/bin/bash" ]; then
181
+ # Try .bash_profile first (macOS default), then .bashrc
182
+ if [ -f "$HOME/.bash_profile" ]; then
183
+ configure_shell "$HOME/.bash_profile" "bash" && SHELL_CONFIGURED=1
184
+ elif [ -f "$HOME/.bashrc" ]; then
185
+ configure_shell "$HOME/.bashrc" "bash" && SHELL_CONFIGURED=1
186
+ fi
187
+ fi
188
+
189
+ # Fish shell
190
+ if [ -f "$HOME/.config/fish/config.fish" ]; then
191
+ if ! grep -q "ANVIL_HOME" "$HOME/.config/fish/config.fish" 2>/dev/null; then
192
+ cat >> "$HOME/.config/fish/config.fish" << 'EOF'
193
+
194
+ # Anvil Development Framework
195
+ set -gx ANVIL_HOME "$HOME/Projects/anvil-dev-framework"
196
+ fish_add_path "$ANVIL_HOME/scripts"
197
+ EOF
198
+ echo -e " ${GREEN}✓${NC} Configured fish"
199
+ SHELL_CONFIGURED=1
200
+ else
201
+ echo -e " ${GREEN}✓${NC} fish already configured"
202
+ SHELL_CONFIGURED=1
203
+ fi
204
+ fi
205
+
206
+ if [ $SHELL_CONFIGURED -eq 0 ]; then
207
+ echo -e " ${YELLOW}⚠${NC} Could not detect shell configuration file"
208
+ echo -e " Add this to your shell profile manually:"
209
+ echo -e " ${BLUE}export ANVIL_HOME=\"\$HOME/Projects/anvil-dev-framework\"${NC}"
210
+ echo -e " ${BLUE}export PATH=\"\$PATH:\$ANVIL_HOME/scripts\"${NC}"
211
+ fi
212
+
213
+ # Summary
214
+ echo ""
215
+ echo -e "${GREEN}════════════════════════════════════════${NC}"
216
+ echo -e "${GREEN} Anvil v${VERSION} installed successfully!${NC}"
217
+ echo -e "${GREEN}════════════════════════════════════════${NC}"
218
+ echo ""
219
+ echo "Global configuration installed to: ~/.claude/"
220
+ echo ""
221
+ echo "Next steps:"
222
+ echo " 1. Restart your terminal or run: source ~/.zshrc"
223
+ echo " 2. Customize ~/.claude/CLAUDE.md with your preferences"
224
+ echo " 3. Run 'anvil init' in your project directory"
225
+ echo ""
226
+ if [ $MISSING -eq 1 ]; then
227
+ echo -e "${YELLOW}⚠ Some required tools are missing. Install them before using Anvil.${NC}"
228
+ fi
229
+ echo ""
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Anvil Development Framework - Post-install Script
5
+ *
6
+ * Runs after npm/bun global install to configure the CLI.
7
+ */
8
+
9
+ const fs = require('fs');
10
+ const path = require('path');
11
+ const os = require('os');
12
+
13
+ const BLUE = '\x1b[34m';
14
+ const GREEN = '\x1b[32m';
15
+ const YELLOW = '\x1b[33m';
16
+ const NC = '\x1b[0m';
17
+
18
+ console.log(`
19
+ ${BLUE}
20
+ ___ _ ___ _____ _
21
+ / \\ | \\ | \\ \\ / /_ _| |
22
+ / /_\\ \\ | \\| |\\ \\ / / | || |
23
+ / _____ \\| |\\ | \\ V / | || |___
24
+ /_/ \\_\\_| \\_| \\_/ |___|_____|
25
+ ${NC}
26
+ Anvil Development Framework
27
+ `);
28
+
29
+ // Determine install location
30
+ const installDir = path.resolve(__dirname, '..');
31
+ const homeDir = os.homedir();
32
+
33
+ console.log(`${GREEN}✓${NC} Installed to: ${installDir}`);
34
+ console.log('');
35
+ console.log(`${BLUE}Next steps:${NC}`);
36
+ console.log(' 1. Run: anvil --help');
37
+ console.log(' 2. Initialize a project: anvil init');
38
+ console.log('');
39
+ console.log(`${YELLOW}Note:${NC} The anvil command should now be available globally.`);
40
+ console.log(' If not, ensure your npm/bun global bin is in your PATH.');
41
+ console.log('');
@@ -0,0 +1,188 @@
1
+ #!/bin/bash
2
+
3
+ #
4
+ # Anvil Development Framework - Rollback Script
5
+ #
6
+ # Restores a previous Anvil installation from backup
7
+ #
8
+
9
+ set -e
10
+
11
+ # Colors
12
+ RED='\033[0;31m'
13
+ GREEN='\033[0;32m'
14
+ YELLOW='\033[1;33m'
15
+ BLUE='\033[0;34m'
16
+ NC='\033[0m' # No Color
17
+
18
+ # Banner
19
+ echo ""
20
+ echo -e "${BLUE}Anvil Rollback${NC}"
21
+ echo "═══════════════"
22
+ echo ""
23
+
24
+ # Show usage
25
+ usage() {
26
+ echo "Usage: $0 [backup_path]"
27
+ echo ""
28
+ echo "Restores Anvil from a backup created during installation."
29
+ echo ""
30
+ echo "If no backup_path is provided, lists available backups."
31
+ echo ""
32
+ echo "Examples:"
33
+ echo " $0 # List available backups"
34
+ echo " $0 ~/.claude-backups/20241217_143022 # Restore specific backup"
35
+ echo ""
36
+ }
37
+
38
+ # List available backups
39
+ list_backups() {
40
+ echo -e "${BLUE}Available backups:${NC}"
41
+ echo ""
42
+
43
+ BACKUP_BASE="$HOME/.claude-backups"
44
+
45
+ if [ ! -d "$BACKUP_BASE" ]; then
46
+ echo -e "${YELLOW}No backups found at $BACKUP_BASE${NC}"
47
+ echo ""
48
+ echo "Backups are created automatically during installation."
49
+ return 1
50
+ fi
51
+
52
+ BACKUPS=$(ls -1 "$BACKUP_BASE" 2>/dev/null | sort -r)
53
+
54
+ if [ -z "$BACKUPS" ]; then
55
+ echo -e "${YELLOW}No backups found.${NC}"
56
+ return 1
57
+ fi
58
+
59
+ for backup in $BACKUPS; do
60
+ BACKUP_PATH="$BACKUP_BASE/$backup"
61
+
62
+ # Check what's in the backup
63
+ HAS_GLOBAL=""
64
+ HAS_PROJECT=""
65
+
66
+ if [ -d "$BACKUP_PATH/global-claude" ]; then
67
+ HAS_GLOBAL="global"
68
+ fi
69
+
70
+ if [ -d "$BACKUP_PATH/project-claude" ]; then
71
+ HAS_PROJECT="project"
72
+ fi
73
+
74
+ # Format date from directory name
75
+ DATE_PART=$(echo "$backup" | cut -d'_' -f1)
76
+ TIME_PART=$(echo "$backup" | cut -d'_' -f2)
77
+
78
+ FORMATTED_DATE="${DATE_PART:0:4}-${DATE_PART:4:2}-${DATE_PART:6:2}"
79
+ FORMATTED_TIME="${TIME_PART:0:2}:${TIME_PART:2:2}:${TIME_PART:4:2}"
80
+
81
+ CONTENTS=""
82
+ [ -n "$HAS_GLOBAL" ] && CONTENTS="$HAS_GLOBAL"
83
+ [ -n "$HAS_PROJECT" ] && CONTENTS="$CONTENTS${CONTENTS:+, }$HAS_PROJECT"
84
+
85
+ echo -e " ${GREEN}$backup${NC}"
86
+ echo " Date: $FORMATTED_DATE $FORMATTED_TIME"
87
+ echo " Contains: $CONTENTS"
88
+ echo " Path: $BACKUP_PATH"
89
+ echo ""
90
+ done
91
+
92
+ echo "To restore, run:"
93
+ echo " $0 ~/.claude-backups/<backup_name>"
94
+ echo ""
95
+ }
96
+
97
+ # Restore from backup
98
+ restore_backup() {
99
+ BACKUP_PATH="$1"
100
+
101
+ # Validate backup exists
102
+ if [ ! -d "$BACKUP_PATH" ]; then
103
+ echo -e "${RED}Error: Backup not found at $BACKUP_PATH${NC}"
104
+ exit 1
105
+ fi
106
+
107
+ echo -e "${BLUE}Restoring from: $BACKUP_PATH${NC}"
108
+ echo ""
109
+
110
+ # Confirm
111
+ echo -e "${YELLOW}Warning: This will overwrite current Anvil configuration.${NC}"
112
+ echo ""
113
+ read -p "Continue? (y/N) " -n 1 -r
114
+ echo ""
115
+
116
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
117
+ echo "Cancelled."
118
+ exit 0
119
+ fi
120
+
121
+ echo ""
122
+
123
+ # Restore global (~/.claude)
124
+ if [ -d "$BACKUP_PATH/global-claude" ]; then
125
+ echo -e "${BLUE}Restoring global configuration...${NC}"
126
+
127
+ # Create current backup first
128
+ CURRENT_BACKUP="$HOME/.claude-backups/pre-rollback-$(date +%Y%m%d_%H%M%S)"
129
+ mkdir -p "$CURRENT_BACKUP"
130
+
131
+ if [ -d "$HOME/.claude" ]; then
132
+ cp -r "$HOME/.claude" "$CURRENT_BACKUP/global-claude"
133
+ echo -e " ${GREEN}✓${NC} Current config backed up to $CURRENT_BACKUP"
134
+ fi
135
+
136
+ # Remove current and restore
137
+ rm -rf "$HOME/.claude"
138
+ cp -r "$BACKUP_PATH/global-claude/.claude" "$HOME/.claude"
139
+ echo -e " ${GREEN}✓${NC} Global config restored to ~/.claude"
140
+ else
141
+ echo -e "${YELLOW}No global backup found in this backup.${NC}"
142
+ fi
143
+
144
+ # Restore project (.claude) if in a project directory
145
+ if [ -d "$BACKUP_PATH/project-claude" ] && [ -d ".git" ]; then
146
+ echo ""
147
+ echo -e "${BLUE}Restoring project configuration...${NC}"
148
+
149
+ # Backup current project config
150
+ if [ -d ".claude" ]; then
151
+ mkdir -p "$CURRENT_BACKUP"
152
+ cp -r ".claude" "$CURRENT_BACKUP/project-claude"
153
+ echo -e " ${GREEN}✓${NC} Current project config backed up"
154
+ fi
155
+
156
+ # Remove current and restore
157
+ rm -rf ".claude"
158
+ cp -r "$BACKUP_PATH/project-claude/.claude" ".claude"
159
+ echo -e " ${GREEN}✓${NC} Project config restored to .claude/"
160
+ elif [ -d "$BACKUP_PATH/project-claude" ]; then
161
+ echo ""
162
+ echo -e "${YELLOW}Project backup exists but not in a git repository.${NC}"
163
+ echo "Navigate to your project and run again, or manually copy:"
164
+ echo " cp -r $BACKUP_PATH/project-claude/.claude /path/to/project/.claude"
165
+ fi
166
+
167
+ echo ""
168
+ echo -e "${GREEN}════════════════════════════════════════${NC}"
169
+ echo -e "${GREEN} Rollback complete!${NC}"
170
+ echo -e "${GREEN}════════════════════════════════════════${NC}"
171
+ echo ""
172
+ echo "Pre-rollback backup saved to: $CURRENT_BACKUP"
173
+ echo ""
174
+ echo "Run './scripts/verify.sh' to verify the restored installation."
175
+ echo ""
176
+ }
177
+
178
+ # Main
179
+ if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
180
+ usage
181
+ exit 0
182
+ fi
183
+
184
+ if [ -z "$1" ]; then
185
+ list_backups
186
+ else
187
+ restore_backup "$1"
188
+ fi