Project: WorkForge v3.0 - Worktree Close & Environment Sync Status: In Progress - Phase 1 Started: 2025-10-26 Last Updated: 2025-10-26
- Create new directory structure
- Create
src/commands/directory - Create
src/core/directory - Create
src/ui/directory - Create
src/types/directory - Create
docs/directory
- Create
- Create
src/types/index.ts- Define
WorkspaceConfiginterface - Define
PathConfiginterface - Define
WorktreeInfointerface - Define
SafetyCheckResultinterface - Define
EnvVariableinterface - Define
EnvDiffinterface - Define
EnvModificationinterface - Define
SyncDecisioninterface - Define
SyncResultinterface - Define
SyncTargetsinterface - Define
AuditOperationinterface - Define
ProjectMetadatainterface - Define
BackupInfointerface - Define
Configinterface - Define all command option interfaces
- Define
PackageManagerInfointerface
- Define
- Implement
src/core/ConfigManager.ts- Define default configuration constant
- Implement
load()method - Implement
save()method - Implement
get(key)method - Implement
set(key, value)method - Implement
merge()private method - Implement
getNestedValue()private method - Implement
setNestedValue()private method - Write unit tests for ConfigManager (deferred)
- Implement
src/core/ProjectIdentifier.ts- Implement
generateId()static method (SHA-256 hash) - Implement
getRemoteUrl()private static method - Implement
getProjectDir()static method - Implement
getBackupDir()static method - Implement
updateMetadata()static method - Implement
getMetadata()static method - Implement
getAllProjectDirs()static method - Implement
getAllProjects()static method - Write unit tests for ProjectIdentifier (deferred)
- Implement
- Create
src/commands/create.ts- Move
WorkspaceCreatorclass from index.ts - Rename to
CreateCommand - Integrate ConfigManager for defaults
- Integrate ProjectIdentifier for metadata
- Add logic to show existing worktrees
- Export
CreateCommandclass
- Move
- Implement
src/core/EnvFileParser.ts- Implement
parse(filePath)method - Implement
parseLine()private method - Handle comments (# and //)
- Handle empty lines
- Handle quoted values (single and double)
- Handle multi-line values
- Handle inline comments
- Handle escape sequences
- Implement
stringify(vars)method - Implement all parsing helper methods
- Write comprehensive unit tests (deferred)
- Implement
- Implement
src/core/WorktreeResolver.ts- Implement
resolve(path, name)method- Pattern 1: Explicit path resolution
- Pattern 2: Name-based lookup
- Pattern 3: Auto-detect from current directory
- Implement
getWorktrees(repoRoot)method - Implement
findByBranchName(name)method - Implement
isWorktree(directory)method - Implement
getMainRepo(worktreePath)method - Parse
git worktree list --porcelainoutput - Implement all helper methods
- Write unit tests (deferred)
- Implement
- Update
src/ui/Logger.ts- Integrate with config.display.colorEnabled
- Integrate with config.display.verboseOutput
- Add progress indicator support
- Export Logger utility
- Implement
src/core/EnvDiffer.ts- Implement
compare(sourcePath, targetPath)method - Implement
compareVariables(source, target)method - Detect added variables
- Detect removed variables
- Detect modified variables
- Track unchanged variables
- Write unit tests for all cases
- Implement
- Implement
src/ui/DiffDisplay.ts- Implement
show(diff, targets)method - Implement
printHeader()private method - Implement
printAdded()private method - Implement
printModified()private method (side-by-side) - Implement
printRemoved()private method - Implement
printUnchangedSummary()private method - Implement
printFooter()private method - Implement
truncate()utility - Implement
pad()utility - Test visual output manually
- Implement
- Implement
src/ui/SyncPrompt.ts- Implement
prompt(diff, autoYes)method - Implement
promptAdded()private method - Implement
promptModified()private method - Implement
promptRemoved()private method - Implement
autoAcceptAll()private method - Test all interactive flows manually
- Implement
- Implement
src/core/BackupManager.ts- Implement
createBackup(envPath)method - Generate timestamp for backup filename
- Create ~/.workforge/backups// structure
- Implement
cleanupOldBackups()private method - Implement
listBackups()method - Implement
restore(backupPath, targetPath)method - Implement
deleteBackup(backupPath)method - Write unit tests
- Implement
- Implement
src/core/AuditLogger.ts- Implement
log(operation)method - Implement
appendToLog()private method (human-readable) - Implement
formatLogEntry()private method - Implement
addToHistory()private method (JSON) - Implement
cleanupOldLogs()private method - Create ~/.workforge/projects// structure
- Create .meta.json file
- Write unit tests
- Implement
- Test human-readable log format
- Test JSON history format
- Test metadata creation
- Test log cleanup based on retentionDays
- Test with includeVariableValues = true/false
- Implement
src/core/SafetyChecker.ts- Implement
check(worktree)method - Implement
checkUncommittedChanges()private method - Implement
checkUnpushedCommits()private method - Implement
checkBranchMerged()private method - Implement
checkRemoteBranch()private method - Check for detached HEAD
- Check for merge in progress
- Check for rebase in progress
- Write unit tests
- Implement
- Implement
src/core/EnvSyncer.ts- Implement
sync(source, target, decision)method - Implement
mergeVariables()private method - Apply added variables
- Apply modified variables
- Apply removed variables
- Preserve comments and formatting
- Handle errors gracefully
- Write unit tests
- Implement
- Implement
src/core/WorktreeRemover.ts- Implement
remove(worktree, force)method - Execute
git worktree remove - Handle locked worktrees
- Handle missing directories
- Handle permission errors
- Write unit tests
- Implement
- Implement
src/core/BranchCleaner.ts- Implement
cleanup(branch, safety, choice)method - Safe delete (git branch -d)
- Force delete (git branch -D)
- Handle remote branch warnings
- Prompt user based on merge status
- Write unit tests
- Implement
- Implement
src/commands/close.ts- Parse command-line arguments
- Implement main
run()method - Discover worktree (all 3 patterns)
- Run safety checks
- Display warnings
- Prompt for confirmation
- Execute environment sync
- Remove worktree
- Cleanup branch
- Log operation to audit
- Show summary
- Handle --dry-run mode
- Write integration tests
- Implement
src/core/SyncTargetResolver.ts- Implement
resolve(options)method - Pattern 1: --from and --to
- Pattern 2: Only --from (to=main)
- Pattern 3: Only --to (from=main)
- Pattern 4: --between (bidirectional)
- Validate .env files exist
- Write unit tests
- Implement
- Implement
src/commands/sync-env.ts- Parse command-line arguments
- Implement main
run()method - Resolve source and target
- Parse .env files
- Generate diff
- Display diff
- Get user decision
- Create backup
- Perform sync
- Log operation
- Show summary
- Handle --dry-run mode
- Write integration tests
- Implement bidirectional comparison display
- Implement direction selection prompt
- Test worktree-to-worktree sync
- Test main-to-worktree sync
- Test worktree-to-main sync
- Implement
src/ui/ListDisplay.ts- Implement
show(worktrees, format)method - Implement table format display
- Implement JSON format display
- Implement simple format display
- Add sorting functionality
- Test visual output
- Implement
- Implement
src/commands/list.ts- Parse command-line arguments
- Implement main
run()method - Get worktrees for current repo
- Get worktrees for all repos (--all)
- Enrich with metadata (status, age)
- Sort based on option
- Display in selected format
- Write tests
- Implement
src/commands/cleanup.ts- Parse command-line arguments
- Implement main
run()method - Find backups to clean
- Find logs to clean
- Apply --older-than filter
- Show preview
- Prompt for confirmation
- Perform cleanup
- Show summary
- Handle --dry-run mode
- Write tests
- Update create command to use ConfigManager
- Add existing worktrees display
- Integrate AuditLogger for creation tracking
- Update project metadata on create
- Test all integration points
- Update
src/index.ts- Import all command classes
- Set up yargs with subcommands
- Add
createsubcommand - Add
closesubcommand - Add
sync-envsubcommand - Add
listsubcommand - Add
cleanupsubcommand - Route to appropriate command handler
- Add global error handling
- Test all commands via CLI
- Add comprehensive help for each command
- Add usage examples
- Add option descriptions
- Test --help output
- Create
docs/configuration.md- Config file location
- All configuration options with descriptions
- Default values
- Examples
- Create
docs/sync-operations.md- How sync works
- Close command with sync
- Sync-env patterns
- Diff display explanation
- Conflict resolution
- Backup and recovery
- Create
docs/advanced-usage.md- List command usage
- Cleanup operations
- Multiple worktree management
- CI/CD integration
- Create
docs/troubleshooting.md- Common issues
- Debugging
- Manual recovery
- FAQ
- Update
README.md- Add v3.0 features section
- Add new commands overview
- Add configuration overview
- Link to new docs
- Update examples
- Update
INSTALLATION_GUIDE.md- Update version references
- Add new features notes
- Update
CLAUDE.md- Add new architecture description
- Add configuration system
- Add audit logging system
- Add backup system
- Add key algorithms
- Update file structure
- Add links from README to docs/
- Add links from docs/ back to README
- Add inter-doc links where relevant
- Verify all links work
- Test complete close workflow
- Test complete sync-env workflow
- Test list command with multiple repos
- Test cleanup command
- Test enhanced create command
- Test all command combinations
- Test error scenarios
- Test empty .env files
- Test malformed .env files
- Test very large .env files
- Test concurrent modifications
- Test locked files
- Test detached HEAD
- Test merge/rebase in progress
- Test multiple worktrees same branch
- Test remote renamed
- Test no internet connection
- Test with sensitive values in .env
- Test backup file permissions
- Test config file validation
- Test command injection prevention
- Verify audit log security
- Test on macOS
- Test on Linux
- Test on Windows (Git Bash/WSL)
- Fix platform-specific issues
- Test with large worktree lists
- Test with large .env files
- Test with many backups
- Test with large audit logs
- Optimize slow operations
- Review all error messages
- Ensure messages are clear and helpful
- Add hints where appropriate
- Test all error paths
- Review all prompts for clarity
- Test color output
- Test non-color output
- Verify progress indicators
- Test verbose mode
- Polish summary displays
- Update version in package.json to 3.0.0
- Update version in all documentation
- Update CHANGELOG
- Run
npm run build - Test built dist/ files
- Verify package.json bin entries
- Test global installation
- Run all tests
- Verify all features work
- Check for console warnings
- Review all TODO comments in code
- Clean up debug code
- All features implemented
- All tests passing
- Documentation complete
- Cross-platform tested
- Security reviewed
- Performance acceptable
- README updated
- CLAUDE.md updated
- SPEC.md updated
- Version bumped to 3.0.0
- Update this file as tasks are completed
- Mark completed tasks with [x]
- Add new tasks as discovered
- Reference SPEC.md for detailed implementation guidance