Skip to content

Commit 13e6549

Browse files
fix: address all CodeRabbit and PR AutoForgeAI#137 review comments
Security fixes: - Add path traversal protection in restore_backup (validates paths stay within project) - Implement copy-then-delete backup approach (prevents data loss on partial failures) - Add manifest version validation and structure checks - Fix stale lock recovery with PID/timestamp tracking API improvements: - Remove TOCTOU race condition in detach endpoint (rely on detach module's check) - Add agent lock check to reattach endpoint for consistency - Change async def to def for blocking I/O endpoints (FastAPI threadpool) - Return relative backup_path instead of absolute (security) UI fixes: - Make is_detached non-optional in ProjectSummary type - Add loadingLabel prop to ConfirmDialog (fixes hardcoded "Deleting...") - Add cache invalidations for project-specific queries in detach/reattach CLI fixes: - Use mutually exclusive group for --include-artifacts/--no-artifacts - Add KeyboardInterrupt handling with proper exit code - Fix import ordering (ruff I001) Other: - Fix gitignore substring check to use line-based matching - Add 53 security tests (path traversal, manifest validation, lock recovery) - Update CLAUDE.md documentation for detach feature Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f43e9da commit 13e6549

9 files changed

Lines changed: 559 additions & 122 deletions

File tree

CLAUDE.md

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ npm run lint # Run ESLint
9999
```bash
100100
ruff check . # Lint
101101
mypy . # Type check
102-
python test_security.py # Security unit tests (163 tests)
102+
python test_security.py # Security unit tests (164 tests)
103+
python test_detach.py # Detach/reattach tests (53 tests)
103104
python test_security_integration.py # Integration tests (9 tests)
104105
```
105106

@@ -133,6 +134,57 @@ Configuration in `pyproject.toml`:
133134
- `registry.py` - Project registry for mapping names to paths (cross-platform)
134135
- `parallel_orchestrator.py` - Concurrent agent execution with dependency-aware scheduling
135136
- `api/dependency_resolver.py` - Cycle detection (Kahn's algorithm + DFS) and dependency validation
137+
- `detach.py` - Project detach/reattach functionality for Claude Code integration
138+
139+
### Project Detach/Reattach
140+
141+
The detach feature allows temporarily removing Autocoder files from a project, enabling Claude Code to run without Autocoder restrictions on completed projects.
142+
143+
**CLI Usage:**
144+
145+
```bash
146+
# Detach project (move Autocoder files to backup)
147+
python detach.py my-project
148+
149+
# Reattach project (restore files from backup)
150+
python detach.py --reattach my-project
151+
152+
# Check status
153+
python detach.py --status my-project
154+
155+
# List all projects with detach status
156+
python detach.py --list
157+
158+
# Preview detach operation (dry run)
159+
python detach.py --dry-run my-project
160+
161+
# Exclude .playwright-mcp artifacts from backup
162+
python detach.py --no-artifacts my-project
163+
```
164+
165+
**API Endpoints:**
166+
167+
- `GET /api/projects/{name}/detach-status` - Check if project is detached
168+
- `POST /api/projects/{name}/detach` - Detach project (move files to backup)
169+
- `POST /api/projects/{name}/reattach` - Reattach project (restore from backup)
170+
171+
**Security Features:**
172+
173+
- Path traversal protection during restore (validates all paths stay within project directory)
174+
- Copy-then-delete backup approach (atomic operations prevent data loss on partial failures)
175+
- Lock file with PID/timestamp for stale lock recovery
176+
- Manifest version validation for forward compatibility
177+
178+
**Files backed up:**
179+
180+
- `.autocoder/` directory
181+
- `prompts/` directory
182+
- `.playwright-mcp/` directory (unless `--no-artifacts`)
183+
- `features.db`, `assistant.db` (and WAL files)
184+
- `CLAUDE.md`, `.claude_settings.json`, `.agent.lock`
185+
- Generated test files (`test-*.json`, `test-*.py`, etc.)
186+
187+
**Tests:** `test_detach.py` (53 tests including security tests)
136188

137189
### Project Registry
138190

@@ -312,7 +364,8 @@ blocked_commands:
312364

313365
**Files:**
314366
- `security.py` - Command validation logic and hardcoded blocklist
315-
- `test_security.py` - Unit tests for security system (136 tests)
367+
- `test_security.py` - Unit tests for security system (164 tests)
368+
- `test_detach.py` - Unit tests for detach/reattach functionality (53 tests)
316369
- `test_security_integration.py` - Integration tests with real hooks (9 tests)
317370
- `TEST_SECURITY.md` - Quick testing reference guide
318371
- `examples/project_allowed_commands.yaml` - Project config example (all commented by default)

0 commit comments

Comments
 (0)