This guide helps AI assistants quickly understand the project and make effective contributions. Key principle: This is a personal hobby project for learning - keep it fun and exploratory!
CRITICAL: Think hard about the task before starting! This checklist ensures quality:
# 1. Check branch (NEVER work on master!)
git branch --show-current
# 2. If on master, create feature branch
git checkout -b <type>/<description> # feat/, fix/, refactor/, docs/, test/, chore/
# 3. Run tests to verify starting state
yarn test:ci
# 4. Check current version
cat src/version.ts # Current: 4.35.1
# 5. ALWAYS use TodoWrite tool for multi-step tasks!- Browser-based Apple 1 emulator (TypeScript/React)
- Cycle-accurate 6502 CPU emulation
- Worker-based architecture for performance
- Comprehensive debugging tools
- Personal hobby project - no deadlines or sprints
- For learning and exploration
- Informal tone preferred
- "Ideas to explore" not "requirements"
→ docs/active/architecture.md
→ Check module structure in architecture.md
→ docs/active/consolidated_roadmap.md
→ docs/active/user_experience_analysis.md
→ src/core/types/ or src/apple1/types/
→ docs/active/cpu_test_guidelines.md
ALWAYS follow this workflow for best results:
-
EXPLORE - Read relevant files thoroughly
# Use architecture.md as your map # Search for similar patterns in codebase # Check existing tests for context
-
PLAN - Create detailed implementation plan
- Use TodoWrite tool for tasks with 3+ steps
- Break complex features into manageable chunks
- Think through edge cases and test scenarios
-
CODE - Implement with existing patterns
- Follow code style from neighboring files
- Write tests alongside implementation
- Use type safety (no
anytypes!)
-
COMMIT - Verify and document changes
yarn run lint && yarn run type-check && yarn run test:ci yarn run lint:md:fix # For any markdown changes git add -A && git commit -m "type: description"
- Find related code using architecture.md as guide
- Check if pattern exists (likely in similar components)
- Write tests first if modifying core emulation
- Use existing formatters/utilities
- Messages defined in
src/apple1/types/worker-messages.ts - Use
sendWorkerMessage()for type safety - Check browser DevTools for Worker messages
src/
├── core/ # Emulation engine (CPU, Bus, Memory)
├── apple1/ # System integration, Worker
├── components/ # React UI components
├── services/ # Logging, Worker comm, State persistence
├── contexts/ # React state management
└── hooks/ # Reusable React patterns
CRITICAL: ALL TESTS MUST PASS BEFORE COMMITTING!
- Never break the test suite - if tests fail after your changes, fix them
- Always run
yarn test:cibefore committing any changes - If adding new features, add corresponding tests
- If changing component behavior, update tests to match
For core emulation changes, ALWAYS use TDD:
-
Write the test first
// Example: Testing a new CPU instruction it('should handle new instruction correctly', () => { // Setup initial state // Execute instruction // Assert expected outcome });
-
Verify test fails
yarn test --watch # Run in watch mode for quick iteration
-
Write minimal code to pass
- Implement just enough to make test green
- Don't over-engineer on first pass
-
Refactor and iterate
- Clean up implementation
- Add edge case tests
- Ensure all tests still pass
yarn test # Run all tests
yarn test:watch # Watch mode for TDD
yarn test:ci # Full CI test suite
yarn test:coverage # Check test coverage# GitHub CLI for PR management and complex GitHub operations
brew install gh # macOS
# or: sudo apt install gh # Linux
# Authenticate once
gh auth login
# Visual debugging
# Use browser DevTools for:
# - Worker message inspection
# - Performance profiling
# - React component debuggingThe gh command is available for complex GitHub operations:
# Pull Request Management
gh pr create --title "feat: description" --body "detailed description"
gh pr view 123 # View PR details
gh pr checks 123 # Check CI/CD status
gh pr comments 123 # View PR comments
gh pr merge 123 # Merge PR when ready
# Issue Management
gh issue create --title "bug: description"
gh issue view 456
gh issue list --state open
# Repository Operations
gh repo view # Repository info
gh api repos/owner/repo/pulls # Direct API access
gh release create v1.0.0 # Create releases
# Security & Code Scanning
gh api repos/owner/repo/code-scanning/alerts # CodeQL findings
gh api repos/owner/repo/security-advisories # Security advisoriesUse Cases for AI Assistants:
- Creating and managing pull requests programmatically
- Checking CI/CD pipeline status and failures
- Fetching CodeQL security findings for remediation
- Managing issues and project workflow
- Accessing GitHub API for complex repository operations
# Add to your shell config:
alias a1-lint="yarn run lint && yarn run type-check"
alias a1-test="yarn test:ci"
alias a1-check="a1-lint && a1-test"-
Run quality checks:
yarn run lint && yarn run type-check && yarn run test:ci
-
Fix markdown documentation:
yarn run lint:md:fix # Auto-fix markdown issues -
Update version (MANDATORY before PR):
# Edit src/version.ts # Patch: 4.33.33 → 4.33.34 (bug fixes) # Minor: 4.33.33 → 4.34.0 (new features) # Major: 4.33.33 → 5.0.0 (breaking changes)
-
Commit with conventional format:
git add -A git commit -m "type: description" # feat:, fix:, docs:, etc.
- Components implement
IVersionedStatefulComponent - Always include version and migration support
- See existing components for patterns
- Use
Formattersutility (no manual toString(16)) - Consistent hex formatting:
Formatters.hexWord(addr)
// Type-safe messaging
sendWorkerMessage(worker, WORKER_MESSAGES.SET_BREAKPOINT, address);
```typescript
### Component Inspection
- Implement `IInspectableComponent` for debugger visibility
- Return structured data from `getInspectable()`
## 🚫 Common Pitfalls
1. **NEVER commit to master** - Always use feature branches (THIS IS CRITICAL!)
2. **Don't use console.log** - Use LoggingService
3. **Avoid any types** - TypeScript strict mode is enabled
4. **Don't hardcode colors** - Use design tokens (except CRT display)
5. **Remember version bump** - Required for every PR
## 📊 Project Roadmap
**See `docs/active/consolidated_roadmap.md` for the complete, prioritized roadmap.**
### Quick Summary of Priorities:
🛑 **Critical** - Test stability & core issues
🔴 **High** - Core functionality & architecture
🟡 **Medium** - Enhanced features
🟢 **Low** - Refinements & polish
### Recently Completed ✅
- Jest to Vitest Migration (626 tests)
- Comlink Worker Migration (Phase 2)
- Type System Organization
- State Management Interfaces
- Formatter Migration (97 instances)
- CPU6502 Module Split (6 focused modules)
- Base Classes for Common Patterns (useWorkerState hooks)
### Current Focus Areas:
1. **Stabilization** - Fix type workarounds, race conditions
2. **Architecture** - Split large modules, create reusable patterns
3. **Features** - Memory search, conditional breakpoints, watch expressions
For detailed task breakdowns, timelines, and execution strategy, refer to the consolidated roadmap.
## 🎨 Visual References
### When Working on UI Components
**IMPORTANT**: For UI changes, provide screenshots or mockups to iterate against!
1. **Before starting UI work**, ask for:
- Screenshots of current state
- Visual mockups or sketches
- Specific success criteria
2. **During implementation**:
- Take screenshots of progress
- Compare against references
- Iterate 2-3 times for polish
3. **Example request format**:
```text
"Here's a screenshot of the current memory viewer.
I want to add highlighting for changed values.
Success: Changed bytes show in yellow for 1 second."- Documentation Hub:
docs/README.md - Architecture:
docs/active/architecture.md - Roadmap & Priorities:
docs/active/consolidated_roadmap.md - Standardization Progress:
docs/active/standardization-progress.md - Test Guidelines:
docs/active/cpu_test_guidelines.md
💡 Remember: This is a learning project. If something seems interesting to explore, let's do it! Keep suggestions informal and frame them as opportunities to learn rather than requirements.
ALWAYS verify these before considering a task complete:
- ✅ All tests pass (
yarn test:ci) - ✅ No lint errors (
yarn lint) - ✅ No type errors (
yarn type-check) - ✅ Version bumped in
src/version.ts - ✅ Feature works as described
- ✅ No console.log statements left
- ✅ Documentation updated if needed
For complex changes, consider the following approaches:
- Running the app and manually testing
- Taking screenshots of working features
- Writing integration tests for new workflows
IMPORTANT: After creating or editing any markdown files, always run:
yarn run lint:md:fixThis automatically fixes most formatting issues and ensures consistent documentation.