Move git utilities from scripts/modules/utils/git-utils.js to packages/tm-core/src/utils/git-utils.ts for better type safety and reusability.
## Changes
**New File**: `packages/tm-core/src/utils/git-utils.ts`
- Converted from JavaScript to TypeScript with full type annotations
- Added `GitHubRepoInfo` interface for type safety
- Includes all essential git functions needed for Phase 1:
- `isGitRepository`, `isGitRepositorySync`
- `getCurrentBranch`, `getCurrentBranchSync`
- `getLocalBranches`, `getRemoteBranches`
- `isGhCliAvailable`, `getGitHubRepoInfo`
- `getDefaultBranch`, `isOnDefaultBranch`
- `sanitizeBranchNameForTag`, `isValidBranchForTag`
**Updated Files**:
- `preflight-checker.service.ts`: Now imports from local git-utils
- `packages/tm-core/src/utils/index.ts`: Exports git utilities
## Rationale
Phase 1 will need git operations for:
- Creating feature branches (WorkflowOrchestrator)
- Checking git status before execution
- Validating clean working tree
- Branch naming validation
Having these utilities in tm-core provides:
- Type safety (no more `require()` hacks)
- Better testability
- Cleaner imports
- Reusability across services
## Verification
✅ All tests pass (1298 passed, 121 test suites)
✅ Typecheck passes (5/5 successful)
✅ Build successful
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fix git-utils import in PreflightChecker using require() with type casting
- Fix ConfigManager initialization in TaskLoaderService (use async factory)
- Fix TaskService.getTask return type (returns Task | null directly)
- Export PreflightChecker and TaskLoaderService from @tm/core
- Fix unused parameter and type annotations in autopilot command
- Add boolean fallback for optional dryRun parameter
All turbo:typecheck errors resolved.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implements the complete Phase 0 spike for autonomous TDD workflow with orchestration architecture.
## What's New
### Core Services (tm-core)
- **PreflightChecker**: Validates environment prerequisites
- Test command detection from package.json
- Git working tree status validation
- Required tools availability (git, gh, node, npm)
- Default branch detection
- **TaskLoaderService**: Comprehensive task validation
- Task existence and structure validation
- Subtask dependency analysis with circular detection
- Execution order calculation via topological sort
- Helpful expansion suggestions for unready tasks
### CLI Command
- **autopilot command**: `tm autopilot <taskId> --dry-run`
- Displays complete execution plan without executing
- Shows preflight check results
- Lists subtasks in dependency order
- Preview RED/GREEN/COMMIT phases per subtask
- Registered in command registry
### Architecture Documentation
- **Phase 0 completion**: Marked tdd-workflow-phase-0-spike.md as complete
- **Orchestration model**: Added execution model section to main workflow doc
- Clarifies orchestrator guides AI sessions vs direct execution
- WorkflowOrchestrator API design (getNextWorkUnit, completeWorkUnit)
- State machine approach for phase transitions
- **Phase 1 roadmap**: New tdd-workflow-phase-1-orchestrator.md
- Detailed state machine specifications
- MCP integration plan with new tool definitions
- Implementation checklist with 6 clear steps
- Example usage flows
## Technical Details
**Preflight Checks**:
- ✅ Test command detection
- ✅ Git working tree status
- ✅ Required tools validation
- ✅ Default branch detection
**Task Validation**:
- ✅ Task existence check
- ✅ Status validation (no completed/cancelled tasks)
- ✅ Subtask presence validation
- ✅ Dependency resolution with circular detection
- ✅ Execution order calculation
**Architecture Decision**:
Adopted orchestration model where WorkflowOrchestrator maintains state and generates work units, while Claude Code (via MCP) executes the actual work. This provides:
- Clean separation of concerns
- Human-in-the-loop capability
- Simpler implementation (no AI integration in orchestrator)
- Flexible executor support
## Out of Scope (Phase 0)
- Actual test generation
- Actual code implementation
- Git operations (commits, branches, PR)
- Test execution
→ All deferred to Phase 1
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>