mirror of
https://github.com/leonvanzyl/autocoder.git
synced 2026-01-30 06:12:06 +00:00
Implements feature locking to prevent multiple agent sessions from working on the same feature simultaneously. This is essential for parallel agent execution. Database changes: - Add `in_progress` boolean column to Feature model - Add migration function to handle existing databases MCP Server tools: - Add `feature_mark_in_progress` - lock feature when starting work - Add `feature_clear_in_progress` - unlock feature when abandoning - Update `feature_get_next` to skip in-progress features - Update `feature_get_stats` to include in_progress count - Update `feature_mark_passing` and `feature_skip` to clear in_progress Backend updates: - Update progress.py to track and display in_progress count - Update features router to properly categorize in-progress features - Update WebSocket to broadcast in_progress in progress updates - Add in_progress to FeatureResponse schema Frontend updates: - Add in_progress to TypeScript types (Feature, ProjectStats, WSProgressMessage) - Update useWebSocket hook to track in_progress state Prompt template: - Add instructions for agents to mark features in-progress immediately - Document new MCP tools in allowed tools section Also fixes spec_chat_session.py to use absolute project path instead of relative path for consistency with CLI behavior. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
154 lines
3.8 KiB
Python
154 lines
3.8 KiB
Python
"""
|
|
Pydantic Schemas
|
|
================
|
|
|
|
Request/Response models for the API endpoints.
|
|
"""
|
|
|
|
from datetime import datetime
|
|
from typing import Literal
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
# ============================================================================
|
|
# Project Schemas
|
|
# ============================================================================
|
|
|
|
class ProjectCreate(BaseModel):
|
|
"""Request schema for creating a new project."""
|
|
name: str = Field(..., min_length=1, max_length=50, pattern=r'^[a-zA-Z0-9_-]+$')
|
|
spec_method: Literal["claude", "manual"] = "claude"
|
|
|
|
|
|
class ProjectStats(BaseModel):
|
|
"""Project statistics."""
|
|
passing: int = 0
|
|
total: int = 0
|
|
percentage: float = 0.0
|
|
|
|
|
|
class ProjectSummary(BaseModel):
|
|
"""Summary of a project for list view."""
|
|
name: str
|
|
has_spec: bool
|
|
stats: ProjectStats
|
|
|
|
|
|
class ProjectDetail(BaseModel):
|
|
"""Detailed project information."""
|
|
name: str
|
|
has_spec: bool
|
|
stats: ProjectStats
|
|
prompts_dir: str
|
|
|
|
|
|
class ProjectPrompts(BaseModel):
|
|
"""Project prompt files content."""
|
|
app_spec: str = ""
|
|
initializer_prompt: str = ""
|
|
coding_prompt: str = ""
|
|
|
|
|
|
class ProjectPromptsUpdate(BaseModel):
|
|
"""Request schema for updating project prompts."""
|
|
app_spec: str | None = None
|
|
initializer_prompt: str | None = None
|
|
coding_prompt: str | None = None
|
|
|
|
|
|
# ============================================================================
|
|
# Feature Schemas
|
|
# ============================================================================
|
|
|
|
class FeatureBase(BaseModel):
|
|
"""Base feature attributes."""
|
|
category: str
|
|
name: str
|
|
description: str
|
|
steps: list[str]
|
|
|
|
|
|
class FeatureCreate(FeatureBase):
|
|
"""Request schema for creating a new feature."""
|
|
priority: int | None = None
|
|
|
|
|
|
class FeatureResponse(FeatureBase):
|
|
"""Response schema for a feature."""
|
|
id: int
|
|
priority: int
|
|
passes: bool
|
|
in_progress: bool
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class FeatureListResponse(BaseModel):
|
|
"""Response containing list of features organized by status."""
|
|
pending: list[FeatureResponse]
|
|
in_progress: list[FeatureResponse]
|
|
done: list[FeatureResponse]
|
|
|
|
|
|
# ============================================================================
|
|
# Agent Schemas
|
|
# ============================================================================
|
|
|
|
class AgentStatus(BaseModel):
|
|
"""Current agent status."""
|
|
status: Literal["stopped", "running", "paused", "crashed"]
|
|
pid: int | None = None
|
|
started_at: datetime | None = None
|
|
|
|
|
|
class AgentActionResponse(BaseModel):
|
|
"""Response for agent control actions."""
|
|
success: bool
|
|
status: str
|
|
message: str = ""
|
|
|
|
|
|
# ============================================================================
|
|
# Setup Schemas
|
|
# ============================================================================
|
|
|
|
class SetupStatus(BaseModel):
|
|
"""System setup status."""
|
|
claude_cli: bool
|
|
credentials: bool
|
|
node: bool
|
|
npm: bool
|
|
|
|
|
|
# ============================================================================
|
|
# WebSocket Message Schemas
|
|
# ============================================================================
|
|
|
|
class WSProgressMessage(BaseModel):
|
|
"""WebSocket message for progress updates."""
|
|
type: Literal["progress"] = "progress"
|
|
passing: int
|
|
total: int
|
|
percentage: float
|
|
|
|
|
|
class WSFeatureUpdateMessage(BaseModel):
|
|
"""WebSocket message for feature status updates."""
|
|
type: Literal["feature_update"] = "feature_update"
|
|
feature_id: int
|
|
passes: bool
|
|
|
|
|
|
class WSLogMessage(BaseModel):
|
|
"""WebSocket message for agent log output."""
|
|
type: Literal["log"] = "log"
|
|
line: str
|
|
timestamp: datetime
|
|
|
|
|
|
class WSAgentStatusMessage(BaseModel):
|
|
"""WebSocket message for agent status changes."""
|
|
type: Literal["agent_status"] = "agent_status"
|
|
status: str
|