Skip to content

Conversation

@seocombat
Copy link

Summary

Fixes "The command line is too long" errors on Windows when running the agent or spec creation.

On Windows, command line arguments are limited to ~8KB. This caused failures when:

  1. client.py passed **os.environ to MCP server config (PATH alone can exceed 2KB on Windows)
  2. spec_chat_session.py passed 18KB skill content as system_prompt

Changes

  • client.py: Remove env from MCP config, pass --project-dir as CLI argument instead
  • mcp_server/feature_mcp.py: Add argparse support for --project-dir (with fallback to PROJECT_DIR env var for backward compatibility)
  • server/services/spec_chat_session.py: Use short system_prompt, pass skill content in first message instead

Test plan

  • Tested on Windows 10 with long PATH environment variable
  • Agent starts successfully without "command line too long" error
  • Spec creation chat works without errors
  • MCP server still works with env var fallback (backward compatible)

🤖 Generated with Claude Code

seocombat and others added 9 commits January 6, 2026 23:09
On Windows, command line arguments are limited to ~8KB. This caused
"The command line is too long" errors when:

1. client.py passed **os.environ to MCP server config (PATH alone can
   exceed 2KB on Windows)
2. spec_chat_session.py passed 18KB skill content as system_prompt

Changes:
- client.py: Remove env from MCP config, pass --project-dir as CLI arg
- mcp_server/feature_mcp.py: Add argparse support for --project-dir
  (with fallback to PROJECT_DIR env var for backward compatibility)
- spec_chat_session.py: Use short system_prompt, pass skill content
  in first message instead

Tested on Windows 10 with long PATH environment variable.
- Use short system_prompt to avoid Windows command line limits
- Pass project context in first message instead (like spec_chat_session)
- Use absolute path for MCP server script to fix module resolution
- Add ROOT_DIR constant to client.py for consistent path handling

The long system_prompt (6331 chars) was causing Claude CLI
initialization to timeout on Windows. This follows the same
pattern as spec_chat_session.py which uses a short system_prompt
and passes content in the first message.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements a coordinator-worker pattern for running multiple agents in parallel:

- Add FeatureStatus enum (pending/in_progress/passing/conflict/failed)
- Add atomic feature claiming via SQLite CTE with RETURNING
- Add lease-based heartbeat for stale claim recovery (30min timeout)
- Add WorktreeManager for git worktree lifecycle management
- Add ParallelCoordinator for spawning/monitoring workers
- Add parallel_agent.py CLI entry point (--workers 1-10)
- Update process_manager to choose single vs parallel agent script
- Add UI worker count selector (cycles 1→3→5)
- Add ruff.toml config and fix lint errors

Usage:
  CLI: python parallel_agent.py --project-dir my-app --workers 5
  UI: Click users icon to select worker count before starting

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Critical fixes:
- Add init_database_direct() for DB initialization without MCP server
- Call init_database_direct() in coordinator before any MCP tool calls
- Add --worktree-path and --feature-id CLI args to autonomous_agent_demo
- Add work_dir parameter to separate code changes from DB access
- Add feature_get_by_id MCP tool for fetching specific features
- Add get_coding_prompt_parallel() with override instructions for bound feature
- Workers now use feature_get_by_id instead of feature_get_next

Major fix:
- Capture target branch at startup via git symbolic-ref
- merge_feature_branch() now uses explicit branch checkout, not HEAD
- Prevents detached HEAD issues during merge operations

Minor fix:
- Pass --model to worker subprocess (verified working)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Major fixes:
- Add feature_get_by_id to allowed tools in prompt templates
- Copy app_spec.txt to worktrees via WORKTREE_SYNC_FILES

Tests added (14 passing):
- Concurrent claim uniqueness (N workers → N distinct features)
- Heartbeat lease_lost behavior (wrong worker_id)
- Stale reclaim (claimed_at old → returns to pending)
- Merge serialization smoke test (asyncio.Lock blocks concurrent access)
- Migration forwards/backwards sanity (Enum storage + passes invariant)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- WORKTREE_SYNC_FILES now uses (src, dst) tuples to support path remapping
- prompts/app_spec.txt → app_spec.txt ensures agents can read spec
- Fixed misleading comment: "dest doesn't exist" not "source is newer"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add overwrite flag to WORKTREE_SYNC_FILES tuples
- prompts/app_spec.txt always overwrites root app_spec.txt (overwrite=True)
- Prevents stale specs when prompts/ version is updated

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
pRizz added a commit to pRizz/autocoder that referenced this pull request Jan 21, 2026
- Verified WebSocket server accepts connections on /ws endpoint
- Tested with Node.js ws client (test-ws.cjs)
- Verified browser UI shows "Connected" status
- Confirmed welcome message sent on connection
- All 5 test steps verified successfully

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
ArchitectVS7 referenced this pull request in ArchitectVS7/autocoder-2 Jan 21, 2026
… + Phase 1 Regression Fix

PHASE 3 COMPLETION - 31/31 FEATURES (100%), 108/108 TESTS PASSING ✅

Task 3.6: Performance Checkpoint Agent (4/4 features, 13 tests)
==============================================================
Created checkpoint_agent_performance.py with PerformanceAgent class

Features Implemented:
- Heavy dependency detection (moment.js, lodash, axios)
- N+1 query detection (queries inside loops)
- Inefficient query patterns (SELECT *, .all().count())
- Bundle size analysis (package.json + build output)

Key Capabilities:
- Analyzes .py, .js, .ts, .jsx, .tsx, .sql, .json files
- Pattern-based detection with regex matching
- Severity levels: CRITICAL (>500KB bundles), WARNING (N+1, full lodash), INFO (moment, axios)
- Provides actionable suggestions for optimization

Tests: All 13 tests passing
- test_analyze_no_changes
- test_detect_heavy_dependency_moment
- test_detect_heavy_dependency_lodash
- test_detect_n_plus_one_query
- test_detect_inefficient_select_all
- test_detect_axios_usage
- test_check_bundle_size_estimation
- test_analyze_multiple_files
- test_metadata_includes_issue_counts
- test_status_reflects_severity
- test_only_analyzes_relevant_files
- test_handles_file_read_errors
- test_suggests_alternatives

Task 3.7: Auto-Fix Feature Creation (4/4 features, 10 tests)
============================================================
Created checkpoint_autofix.py with CheckpointAutoFix class

Features Implemented:
- Automatically creates fix features for critical issues
- Groups issues by location to avoid duplicates
- Priority insertion (current_priority - 0.5)
- Category: "checkpoint_fix" for easy filtering

Key Methods:
- create_fix_features() - Creates Feature DB entries
- should_create_fixes() - Checks total_critical > 0
- get_fix_features() - Retrieves all fix features
- mark_fix_completed() - Marks fix as passing
- cleanup_completed_fixes() - Removes completed fixes

Fix Feature Structure:
- Auto-generated name with issue type and location
- Detailed markdown description with all issues
- Implementation steps with suggestions
- Verification step to re-run checkpoint

Tests: All 10 tests passing
- test_create_fix_for_critical_issue
- test_no_fix_for_warnings
- test_groups_issues_by_location
- test_creates_separate_fixes_for_different_files
- test_fix_feature_includes_suggestions
- test_should_create_fixes
- test_get_fix_features
- test_mark_fix_completed
- test_cleanup_completed_fixes
- test_convenience_function

Infrastructure Improvements:
============================
- Added `issues` property to AggregatedCheckpointResult
  - Convenient access to all issues from all checkpoint results
  - Returns List[CheckpointIssue] by collecting from all results
- Fixed test dataclass instantiation to use CheckpointDecision enum
- Updated test pattern to wrap issues in CheckpointResult objects

Phase 1 Regression Testing (+1 test fixed):
===========================================
Fixed test_complete_skip_to_unblock_cycle:
- Updated to use BlockerType.ENV_CONFIG.value instead of string
- Ensures proper enum value comparison in end-to-end workflow
- Phase 1 now at 38/39 tests passing (97.4%) ⬆️ from 37/39 (95%)
- Only 1 test remaining (needs input mocking)

Documentation Updates:
======================
FEATURE_TESTING_MATRIX.md:
- Updated Task 3.6 with all implementation details
- Updated Task 3.7 with all implementation details
- Phase 3 Summary: 31/31 features (100%), 108/108 tests passing
- Phase 1 Summary: 38/39 tests passing (97.4%)
- Added commit #7 to Phase 3 Regression Testing Improvements

Summary:
========
✅ Phase 3: COMPLETE - 31/31 features (100%), 108/108 tests (100%)
✅ Phase 1: 38/39 tests passing (97.4%) - 11 tests fixed during Phase 3
✅ Performance Agent: Detects bundle sizes, N+1 queries, heavy deps
✅ Auto-Fix: Creates fix features automatically for critical issues
✅ Regression: Fixed 1 additional Phase 1 test (enum value comparison)
devxalted added a commit to devxalted/autocoder that referenced this pull request Jan 23, 2026
* feat: add brownfield initializer prompt template

Create .claude/templates/brownfield_initializer_prompt.template.md
for brownfield (existing codebase) development projects.

Key differences from greenfield initializer:
- Emphasizes reading CLAUDE.md and existing code first
- Creates fewer, targeted features (10-50 vs 150-400)
- Each feature references specific files to modify
- Removes init.sh and git init steps
- Adds brownfield-specific rules section
- Includes verification steps for each feature

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add brownfield coding prompt template

- Create brownfield_coding_prompt.template.md with brownfield-specific rules
- CRITICAL rules section: read before modifying, Edit not Write, follow patterns
- Emphasizes minimal changes and no refactoring beyond scope
- Includes verification checklist for brownfield modifications

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add is_brownfield_project detection function

- Add is_brownfield_project(project_dir: Path) -> bool to prompts.py
- Detects existing codebases by checking for source directories
  (src/, app/, lib/, server/, ui/)
- Checks for project files (package.json, pyproject.toml, Cargo.toml, go.mod)
- Checks for .git directory
- Returns False if features.db exists (already initialized)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add --brownfield and --greenfield CLI flags

- Add --brownfield flag to force brownfield mode for modifying existing codebases
- Add --greenfield flag to force greenfield mode for new projects
- Both flags follow existing argparse patterns (action=store_true)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add brownfield prompt loading functions

- Add get_brownfield_initializer_prompt() for brownfield-specific initializer prompts
- Add get_brownfield_coding_prompt() for brownfield-specific coding prompts
- Both follow existing fallback pattern: project override -> base template

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: integrate brownfield mode in agent startup

- Add brownfield mode detection in autonomous_agent_demo.py
- Import is_brownfield_project from prompts
- Auto-detect brownfield based on project structure when no flag set
- Pass brownfield_mode to run_autonomous_agent and run_parallel_orchestrator
- Update agent.py to select brownfield prompts based on mode
- Update parallel_orchestrator.py to pass --brownfield flag to subprocesses

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: always show brownfield/greenfield mode in startup banner

- Modified startup banner to display mode regardless of setting
- Shows "Mode: brownfield" or "Mode: greenfield" to indicate project type
- Lowercase "brownfield" to match the feature spec requirement

Completes Feature leonvanzyl#7: Add brownfield mode indicator to progress output

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Admin <admin@localhost>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
devxalted added a commit to devxalted/autocoder that referenced this pull request Jan 23, 2026
* feat: add git_workflow.py module for core git operations

Implements subprocess-based git operations for the Autocoder agent:
- _run_git(): safe git execution with timeout and error handling
- is_git_repo(), get_main_branch(): repo detection
- generate_branch_name(): slugify feature names for branches
- create_branch(), checkout_branch(), get_current_branch(): branch management
- commit_changes(), push_branch(): commit and push operations
- create_pr(), get_pr_status(): PR operations using gh CLI
- delete_remote_branch(): cleanup operations

Includes additional utilities:
- branch_exists(), create_and_checkout_branch()
- get_commit_sha(), has_uncommitted_changes()

Feature leonvanzyl#3 - git_workflow.py module

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: add progress tracking file

Track implementation progress for git workflow features.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add git workflow columns to Feature model

Add 8 new columns for git workflow integration:
- branch_name (indexed): git branch name for this feature
- branch_type: type of branch (feature/bugfix)
- worktree_path: path to git worktree for parallel agent isolation
- commit_sha: SHA of completion commit
- pr_number (indexed): GitHub PR number
- pr_url: full URL to the GitHub PR
- pr_status: current PR status (open/merged/closed)
- merged_at: timestamp when PR was merged

All columns are nullable for backwards compatibility with existing databases.
Includes migration function _migrate_add_git_columns() that safely adds
columns to existing databases using ALTER TABLE.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: update progress - Feature #1 git columns complete

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add worktree_manager.py module for parallel agent isolation

Implements git worktree management for running multiple agents concurrently:
- _get_worktrees_dir(): Returns worktrees directory path pattern
- create_worktree(): Creates worktree with branch for feature
- remove_worktree(): Removes worktree with shutil fallback
- list_worktrees(): Parses 'git worktree list --porcelain' output
- cleanup_stale_worktrees(): Removes worktrees for passing features

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: update progress - Feature leonvanzyl#4 worktree_manager complete

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add git workflow Pydantic schemas

Add Pydantic schemas for git-related API endpoints:
- GitConfig, GitConfigUpdate: Git workflow configuration
- GitStatusResponse: Repository status (is_git_repo, current_branch, etc.)
- GitBranchInfo, GitBranchListResponse: Branch information
- GitWorktreeInfo, GitWorktreeListResponse: Worktree information
- GitPRInfo, GitPRListResponse: Pull request information
- Updated FeatureResponse with git fields (branch_name, branch_type,
  worktree_path, commit_sha, pr_number, pr_url, pr_status, merged_at)

Feature leonvanzyl#5 - Git Pydantic schemas

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: update progress - Feature leonvanzyl#5 git schemas complete

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add git config helpers to project_config.py

Add GitConfig TypedDict and helper functions for managing git workflow
configuration in projects. This enables per-project git workflow settings
stored in .autocoder/config.json.

- Add GitConfig TypedDict with fields: enabled, auto_branch, auto_commit,
  auto_pr, pr_target_branch
- Add DEFAULT_GIT_CONFIG with sensible defaults (enabled=False, auto_branch=True,
  auto_commit=True, auto_pr=False, pr_target_branch="main")
- Add get_git_config(project_dir) function to load git settings with defaults
- Add set_git_config(project_dir, config) function to save git settings

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: update progress - Feature leonvanzyl#2 git config helpers complete

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add Git REST API router for git workflow operations

Implements server/routers/git.py with 7 REST endpoints:
- GET /status: Returns git repo status (branch, uncommitted changes, remote)
- GET /config: Returns git workflow configuration
- PUT /config: Updates git workflow configuration (partial updates)
- GET /branches: Lists all local branches with tracking info
- GET /worktrees: Lists all worktrees with feature IDs
- DELETE /worktrees/{feature_id}: Removes worktree for a feature
- GET /prs: Lists pull requests from features.db

Follows existing router patterns from features.py with:
- Lazy imports to avoid circular dependencies
- Project path resolution via registry
- Database session context manager
- Proper error handling with HTTPException

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: update progress - Feature leonvanzyl#6 git router complete

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add PR watcher service for monitoring merged PRs

Implements background service that polls GitHub for merged PRs every
5 minutes (configurable). On merge detection:
- Updates feature.merged_at in database
- Removes git worktree
- Deletes remote branch

Key components:
- PRWatcher class with configurable poll_interval (default 300s)
- Async _check_merged_prs() queries features via gh CLI
- Async _watcher_loop() runs periodic checks
- start()/stop() for lifespan integration
- Module-level singleton with get_watcher() and cleanup_watcher()

Marks feature leonvanzyl#9 as passing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: update progress - Feature leonvanzyl#9 PR watcher service complete

Progress: 7/10 features passing (70%)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add Git MCP tools for agent git operations

- Add git_create_feature_branch(feature_id, branch_type='feature')
  Creates branch using generate_branch_name() and updates feature.branch_name, feature.branch_type

- Add git_commit_feature(feature_id, message)
  Commits changes in feature's worktree (or project dir) and updates feature.commit_sha

- Add git_create_pr(feature_id, title, target_branch='main')
  Pushes branch, creates PR via gh CLI, updates feature.pr_number, pr_url, pr_status

All tools follow existing MCP patterns with proper session handling,
error handling, and JSON return values.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: update progress - Feature leonvanzyl#8 Git MCP tools complete

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add git workflow integration to parallel orchestrator

- Add imports for git_workflow, worktree_manager, and project_config
- Load git config in __init__ with fallback to disabled config on error
- Add _update_feature_git_info() helper to update Feature git fields
- Modify _spawn_coding_agent() to create branch/worktree if git enabled
- Add _finalize_git_for_feature() to commit/push/PR after feature passes
- Modify _on_agent_complete() to call git finalization for passed features

Feature leonvanzyl#7: Orchestrator git hooks

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: register git router and PR watcher service

- Add git_router export to server/routers/__init__.py
- Import and include git_router in server/main.py
- Start PR watcher service in lifespan startup
- Stop PR watcher service in lifespan shutdown

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: update progress - Feature leonvanzyl#10 server registration complete

All 10/10 features now passing (100%)! Git workflow implementation is complete.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: security and reliability improvements from code review

- Add branch name validation (is_valid_branch_name) to prevent command injection
- Add feature_id type validation in worktree functions to prevent path traversal
- Replace deprecated asyncio.get_event_loop() with get_running_loop()
- Add thread-safe singleton pattern for PR watcher
- Add try-finally to MCP server lifespan for proper cleanup
- Add validation for pr_target_branch in schemas

Security improvements:
- Branch names now validated against [a-zA-Z0-9/_-]+ pattern
- Path traversal prevented by validating feature_id is positive integer
- Input validation added to all functions that accept user-provided branch names

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Admin <admin@localhost>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
devxalted added a commit to devxalted/autocoder that referenced this pull request Jan 23, 2026
* feat: add refinement config helpers to project_config.py

- Add RefinementPassesConfig TypedDict for pass settings (code_quality,
  edge_cases, performance, security, ux)
- Add RefinementConfig TypedDict with enabled, auto_transition, passes
- Add DEFAULT_REFINEMENT_CONFIG constant with all features enabled
- Add get_refinement_config() to load and merge config with defaults
- Add set_refinement_config() to validate and save refinement settings

Implements Feature leonvanzyl#2: Refinement config helpers

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add refinement tracking columns to Feature model

- Added 5 new columns to Feature model for MVP/Refinement workflow:
  - refinement_state: String(30), default='pending', indexed
    Values: pending, draft, refined_code, refined_edge, refined_perf, refined_security, polished
  - refinement_iterations: Integer, default=0
  - last_refined_at: DateTime, nullable
  - time_spent_drafting_ms: Integer, nullable
  - time_spent_refining_ms: Integer, nullable
- Updated to_dict() method to include all refinement fields
- Created _migrate_add_refinement_columns() migration function
- Registered migration in create_database() after _migrate_add_git_columns()

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add refinement Pydantic schemas

- Add RefinementPassesConfig for pass configuration (code_quality, edge_cases, etc.)
- Add RefinementConfig matching TypedDict from project_config
- Add RefinementConfigUpdate for partial updates (all fields Optional)
- Add RefinementPassInfo for pass metadata (name, enabled, description)
- Add RefinementStatusResponse with current_phase, total_features, draft_count, by_state
- Add RefinementTransitionRequest/Response for phase transitions
- Update FeatureResponse with refinement fields (refinement_state, iterations, times)

Implements Feature leonvanzyl#3: Refinement Pydantic schemas

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add refinement REST API router

Create server/routers/refinement.py with REST endpoints for refinement
workflow management:

- GET /status: Returns refinement status with phase, counts, passes
- POST /transition: Switch between MVP and refinement phases
- GET /config: Returns refinement configuration
- PUT /config: Updates refinement config (partial updates supported)
- POST /features/{id}/refine: Trigger refinement pass for feature

Includes helper functions for phase calculation, state counting, and
database access following existing router patterns from features.py.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: register refinement router in FastAPI app

- Add refinement_router import to server/routers/__init__.py
- Export refinement_router in __all__ list
- Import refinement_router in server/main.py
- Include refinement_router in app router registration

Implements Feature leonvanzyl#7: Server registration for refinement

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add refinement React hooks for UI

- Create useRefinement.ts with React Query hooks:
  - useRefinementStatus: GET /refinement/status
  - useRefinementConfig: GET /refinement/config
  - useUpdateRefinementConfig: PUT /refinement/config
  - useTransitionPhase: POST /refinement/transition
  - useTriggerRefinement: POST /refinement/features/{id}/refine
- Add type definitions to types.ts:
  - RefinementConfig, RefinementStatus, RefinementPassInfo
  - RefinementPassesConfig, RefinementConfigUpdate
  - RefinementPhase, RefinementTransitionRequest/Response
  - TriggerRefinementRequest/Response
- Add API functions to api.ts for all refinement endpoints
- All hooks use queryClient.invalidateQueries for cache updates
- Lint and TypeScript build pass

Implements Feature leonvanzyl#8: Refinement React hooks

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add refinement MCP tools for workflow management

Add 4 new MCP tools for the refinement workflow:

- feature_mark_draft: Mark feature as draft (MVP complete)
- feature_complete_refinement_pass: Complete a refinement pass on a feature
  - Supports pass_types: code_quality, edge_cases, performance, security, ux
  - State transitions: draft -> refined_code -> refined_edge -> refined_perf -> refined_security -> polished
- feature_get_for_refinement: Get features ready for a specific refinement pass
- feature_get_refinement_status: Get overall refinement progress

Also updated the module docstring to document all MCP tools including
Git tools and the new Refinement tools.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: integrate refinement workflow into orchestrator

Feature leonvanzyl#6: Orchestrator refinement integration

- Import get_refinement_config from project_config
- Load refinement config in __init__ with sensible defaults
- Add self.phase to track current development phase (mvp/refinement)
- Add _determine_phase() method to calculate phase based on feature states
- Add _check_mvp_complete() to check if all features have drafts
- Add _auto_transition_to_refinement() for automatic phase transition
- Add _mark_feature_draft() to mark features as draft when passing in MVP
- Modify _on_agent_complete() to handle MVP draft marking and auto-transition
- Add phase info to get_status() for WebSocket progress messages
- Add phase info to startup logs and debug output

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: update progress notes for Feature leonvanzyl#6

- Documented orchestrator refinement integration implementation
- Added session summary for 2026-01-23
- 8/10 features now passing (80%)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add PhaseIndicator component for MVP/Refinement phase display

- Create PhaseIndicator.tsx showing current development phase
- MVP phase: yellow/amber badge with Zap (lightning) icon
- Refinement phase: purple badge with Sparkles icon
- Display progress percentage for each phase
- Tooltip with detailed state breakdown and progress bar
- Integrate into App.tsx header section after ProjectSelector

Feature leonvanzyl#9 complete.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add RefinementDashboard component for phase progress and controls

- Create ui/src/components/RefinementDashboard.tsx with:
  - Phase toggle button (MVP <-> Refinement) using useTransitionPhase
  - Progress bars for each refinement state with color coding
  - Feature counts per state and summary statistics
  - Time tracking display placeholders
  - Auto-transition toggle from config
  - Collapsible pass settings section
- Integrate into App.tsx with 'R' keyboard shortcut
- Update KeyboardShortcutsHelp to include 'R' shortcut
- Wire up to useRefinementStatus and useRefinementConfig hooks
- Follow neobrutalism design patterns (neo-card, neo-btn, neo-badge)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: update progress notes for Feature leonvanzyl#10

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: address code review issues for refinement workflow

Security:
- Add column name validation against allowlist in database migrations
  to prevent SQL injection patterns (api/database.py)

Reliability:
- Add explicit rollback on exception in db session context manager
- Add Path validation (ge=1) for feature_id in REST endpoint
- Add null check for config.passes in RefinementDashboard

Code Quality:
- Create shared api/refinement_constants.py to eliminate duplicate
  REFINEMENT_STATES and PASS_STATE_TRANSITIONS definitions
- Import shared constants in MCP tools and REST router
- Remove unused time tracking UI (placeholder showing "--")
- Comment out formatDuration function for future use

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: address medium priority code review issues

Performance:
- Reduce refetchInterval from 5s to 15s in useRefinementStatus
  to lower API load and improve mobile battery life

Security:
- Add XSS sanitization in PhaseIndicator.formatStateName()
  for unknown state names from API responses

Reliability:
- Add periodic phase refresh (every 10 iterations) in orchestrator
  main loop to catch external state changes via API

Code Quality:
- Add Field with description and example for by_state in schemas
- Clarify intentional graceful degradation in project_config.py
  error handling with improved comments

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Admin <admin@localhost>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
devxalted added a commit to devxalted/autocoder that referenced this pull request Jan 23, 2026
* feat(database): Add Bug SQLAlchemy model for bug tracking

- Add Bug class with all required fields (severity, source, status, etc.)
- Add to_dict() method for JSON serialization
- Create _migrate_create_bugs_table() migration function
- Register migration in create_database()
- Add BUG_SEVERITIES, BUG_STATUSES, BUG_SOURCES, BUG_CATEGORIES constants

Feature #1: Bug database model - verified complete

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: update progress notes for Bug database model

Feature #1 complete - Bug SQLAlchemy model implemented

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(triage): Add bug triage engine for auto-triage and priority scoring

- Create api/bug_triage.py with pattern matching for severity and category
- SEVERITY_PATTERNS: critical, high, medium, low with regex patterns
- CATEGORY_PATTERNS: auth, api, database, ui, testing with regex patterns
- auto_triage_bug(): Analyze title/error/stack_trace to determine severity/category
- compute_priority_score(): Calculate priority from severity, age, and source factors

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: update progress notes for Bug triage engine

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(schemas): Add Bug Pydantic schemas for bug tracking API

Added complete set of Pydantic schemas for bug management:
- BugSeverity/BugStatus type aliases with Literal types
- BugCreate: request schema with auto-detect severity option
- BugUpdate: partial update schema with all optional fields
- BugResponse: response schema with all Bug model fields
- BugListResponse: paginated bug list with total count
- BugStatsResponse: statistics with counts by severity/status

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: update progress notes for Bug Pydantic schemas

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(api): Add Bug REST API router for bug tracking

- Create server/routers/bugs.py with full CRUD endpoints
- GET /: List bugs with filters (severity, status, limit, offset)
- POST /: Create bug with auto-triage support
- GET /stats: Return bug statistics
- GET/PATCH/DELETE /{bug_id}: Single bug operations
- POST /{bug_id}/retry: Reset bug to 'new' status
- POST /{bug_id}/escalate: Set severity to 'critical'
- Follow existing router patterns (lazy imports, get_db_session)
- Use HTTPException for proper error handling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix regression: Register bugs_router in server

- Added bugs_router import in server/routers/__init__.py
- Added bugs_router to __all__ exports
- Added bugs_router import in server/main.py
- Added app.include_router(bugs_router) to register endpoints

The Bug REST API router was implemented but never wired up to the
FastAPI application, making all /api/projects/{name}/bugs endpoints
inaccessible.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(ui): Add Bug React hooks for bug tracking API

- Add bug types to ui/src/lib/types.ts (Bug, BugCreate, BugUpdate, BugStats, BugFilters, BugListResponse)
- Add API functions to ui/src/lib/api.ts (getBugs, getBugStats, getBug, createBug, updateBug, deleteBug, retryBug, escalateBug)
- Create ui/src/hooks/useBugs.ts with React Query hooks:
  - useBugs: List bugs with optional filters (10s refetch)
  - useBugStats: Get bug statistics (10s refetch)
  - useBug: Get single bug by ID
  - useCreateBug: Create new bug report
  - useUpdateBug: Update existing bug
  - useDeleteBug: Delete a bug
  - useRetryBug: Reset bug to 'new' status
  - useEscalateBug: Set severity to 'critical'
- All hooks follow established patterns from useRefinement.ts
- Verified with TypeScript compiler (npm run build)

Implements Feature leonvanzyl#8

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: update progress notes for Bug React hooks (Feature leonvanzyl#8)

* feat(ui): Add BugSeverityBadge component for bug tracking

- Create BugSeverityBadge.tsx with severity-based color coding
- Support 'critical', 'high', 'medium', 'low' severity levels
- Show AlertTriangle icon for critical and high severity
- Use neo-badge classes with 'sm' and 'md' size variants
- Color mapping: critical=red, high=orange, medium=yellow, low=gray

Feature leonvanzyl#9: BugSeverityBadge component - PASSING

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: update progress notes for BugSeverityBadge (Feature leonvanzyl#9)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(service): Add BugWatcherService for background bug triage

- Create server/services/bug_watcher_service.py following pr_watcher.py pattern
- Implement BugWatcherService class with poll_interval=30s
- Add _poll_bugs() to auto-triage new bugs (severity/category detection)
- Add _check_stale_bugs() to detect bugs stuck >24h in investigating/fixing
- Implement start()/stop() async methods for lifespan integration
- Add module-level singleton: get_bug_watcher(), cleanup_bug_watcher()

Feature leonvanzyl#5 complete

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: update progress notes for Bug watcher service (Feature leonvanzyl#5)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(ui): Add BugCard component for bug list display

- Create BugCard.tsx following FeatureCard.tsx pattern
- Display bug severity badge (top-right), title with line-clamp-2
- Show status badge with color coding for all bug statuses
- Display category badge when present
- Show relative created time (e.g., "2h ago") using inline helper
- Show source indicator (API, Webhook, Regression, Test) if not manual
- Use neo-card styling with hover effect
- Feature leonvanzyl#10 marked as passing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(mcp): Add Bug MCP tools for bug management

Implemented 5 new MCP tools for bug tracking and agent assignment:
- bug_get_assigned: Get bug assigned to a specific agent
- bug_update_status: Update bug status with optional notes
- bug_mark_fixed: Mark bug as fixed and ready for testing
- bug_get_next: Get highest priority triaged bugs
- bug_claim: Claim a bug for investigation by an agent

All tools follow existing patterns with:
- @mcp.tool() decorator
- Annotated type hints with Field validation
- JSON return format
- Proper session handling and error rollback

Feature leonvanzyl#7 - Bug MCP tools - PASSING

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Update progress notes for Bug MCP tools (Feature leonvanzyl#7)

Progress: 9/12 features passing (75%)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(server): Register bug watcher service in FastAPI lifespan

- Import get_bug_watcher and cleanup_bug_watcher from bug_watcher_service
- Start bug watcher during lifespan startup (after PR watcher)
- Cleanup bug watcher during lifespan shutdown (after PR watcher cleanup)
- Bugs router was already registered in a previous commit

Feature leonvanzyl#6: Server registration for bugs - PASSING

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Update progress notes for Feature leonvanzyl#6

- Server registration for bugs now PASSING
- Bug watcher service registered in FastAPI lifespan
- Progress: 10/12 features (83.3%)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(ui): Add BugReportModal component for bug reporting

- Create modal form using Radix Dialog for accessibility
- Add form fields: title (required), error message, stack trace (monospace), reproduction steps
- Add optional severity and category selects with auto-detect option
- Use useCreateBug mutation with loading state and error handling
- Follow neobrutalism design with neo-input, neo-btn styling
- Reset form on close, prevent close during submission

Implements Feature leonvanzyl#12: BugReportModal component

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(ui): Add BugList component for bug list view

- Implements filterable bug list with severity and status filters
- Uses useBugs hook for data fetching with 10s auto-refresh
- Displays bugs in responsive grid (1/2/3 cols) using BugCard
- Shows loading skeleton while fetching (KanbanBoard pattern)
- Shows empty state when no bugs match filters
- Integrates BugReportModal for creating new bug reports
- TypeScript verified, build passing

Implements Feature leonvanzyl#11

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Update progress notes for Feature leonvanzyl#11 (BugList component)

All 12 features now passing (100% complete)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: address code review issues for bug watcher feature

Critical fixes:
- Add input validation for bug category field against BUG_CATEGORIES
- Add input validation for bug source field against BUG_SOURCES

High priority fixes:
- Add atomic locking to bug_claim MCP tool to prevent race conditions
- Add CHECK constraints to Bug model for data integrity (severity, status, source, category, priority_score)
- Add retry decorator for database lock errors in bugs router

Medium priority fixes:
- Optimize get_bug_stats to use SQL aggregates instead of loading all bugs
- Add text length limit in bug triage to prevent excessive processing
- Fix Path import conflict in refinement.py (pathlib.Path vs fastapi.Path)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Admin <admin@localhost>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant