mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 08:33:36 +00:00
refactor: extract auto-mode-service into modular services
Reduce auto-mode-service.ts from 1308 to 516 lines (60% reduction) by extracting reusable functionality into shared packages and services: - Add feature prompt builders to @automaker/prompts (buildFeaturePrompt, buildFollowUpPrompt, buildContinuationPrompt, extractTitleFromDescription) - Add planning prompts and task parsing to @automaker/prompts - Add stream processor utilities to @automaker/utils (sleep, processStream) - Add git commit utilities to @automaker/git-utils (commitAll, hasUncommittedChanges) - Create ProjectAnalyzer service for project analysis - Create FeatureVerificationService for verify/commit operations - Extend FeatureLoader with updateStatus, updatePlanSpec, getPending methods - Expand FeatureStatus type to include all used statuses - Add PlanSpec and ParsedTask types to @automaker/types 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
import type { PlanningMode } from './settings.js';
|
||||
import type { PlanSpec } from './planning.js';
|
||||
|
||||
export interface FeatureImagePath {
|
||||
id: string;
|
||||
@@ -41,20 +42,21 @@ export interface Feature {
|
||||
thinkingLevel?: string;
|
||||
planningMode?: PlanningMode;
|
||||
requirePlanApproval?: boolean;
|
||||
planSpec?: {
|
||||
status: 'pending' | 'generating' | 'generated' | 'approved' | 'rejected';
|
||||
content?: string;
|
||||
version: number;
|
||||
generatedAt?: string;
|
||||
approvedAt?: string;
|
||||
reviewedByUser: boolean;
|
||||
tasksCompleted?: number;
|
||||
tasksTotal?: number;
|
||||
};
|
||||
/** Specification state for spec-driven development modes */
|
||||
planSpec?: PlanSpec;
|
||||
error?: string;
|
||||
summary?: string;
|
||||
startedAt?: string;
|
||||
[key: string]: unknown; // Keep catch-all for extensibility
|
||||
}
|
||||
|
||||
export type FeatureStatus = 'pending' | 'running' | 'completed' | 'failed' | 'verified';
|
||||
export type FeatureStatus =
|
||||
| 'pending'
|
||||
| 'ready'
|
||||
| 'backlog'
|
||||
| 'in_progress'
|
||||
| 'running'
|
||||
| 'completed'
|
||||
| 'failed'
|
||||
| 'verified'
|
||||
| 'waiting_approval';
|
||||
|
||||
@@ -81,3 +81,15 @@ export {
|
||||
THINKING_LEVEL_LABELS,
|
||||
getModelDisplayName,
|
||||
} from './model-display.js';
|
||||
|
||||
// Planning types (spec-driven development)
|
||||
export type {
|
||||
TaskStatus,
|
||||
PlanSpecStatus,
|
||||
ParsedTask,
|
||||
PlanSpec,
|
||||
AutoModeEventType,
|
||||
AutoModeEventPayload,
|
||||
TaskProgressPayload,
|
||||
PlanApprovalPayload,
|
||||
} from './planning.js';
|
||||
|
||||
141
libs/types/src/planning.ts
Normal file
141
libs/types/src/planning.ts
Normal file
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* Planning Types - Types for spec-driven development and task execution
|
||||
*
|
||||
* These types support the planning/specification workflow in auto-mode:
|
||||
* - PlanningMode: skip, lite, spec, full
|
||||
* - ParsedTask: Individual tasks extracted from specs
|
||||
* - PlanSpec: Specification state and content
|
||||
* - AutoModeEventType: Type-safe event names for auto-mode
|
||||
*/
|
||||
|
||||
import type { PlanningMode } from './settings.js';
|
||||
|
||||
// Re-export PlanningMode for convenience
|
||||
export type { PlanningMode };
|
||||
|
||||
/**
|
||||
* TaskStatus - Status of an individual task within a spec
|
||||
*/
|
||||
export type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'failed';
|
||||
|
||||
/**
|
||||
* PlanSpecStatus - Status of a plan/specification document
|
||||
*/
|
||||
export type PlanSpecStatus = 'pending' | 'generating' | 'generated' | 'approved' | 'rejected';
|
||||
|
||||
/**
|
||||
* ParsedTask - A single task extracted from a generated specification
|
||||
*
|
||||
* Tasks are identified by ID (e.g., "T001") and may belong to a phase.
|
||||
* Format in spec: `- [ ] T###: Description | File: path/to/file`
|
||||
*/
|
||||
export interface ParsedTask {
|
||||
/** Task identifier, e.g., "T001", "T002" */
|
||||
id: string;
|
||||
/** Human-readable description of what the task accomplishes */
|
||||
description: string;
|
||||
/** Primary file affected by this task (optional) */
|
||||
filePath?: string;
|
||||
/** Phase this task belongs to, e.g., "Phase 1: Foundation" (for full mode) */
|
||||
phase?: string;
|
||||
/** Current execution status of the task */
|
||||
status: TaskStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* PlanSpec - Specification/plan state for a feature
|
||||
*
|
||||
* Tracks the generated spec content, approval status, and task progress.
|
||||
* Stored in feature.json as `planSpec` property.
|
||||
*/
|
||||
export interface PlanSpec {
|
||||
/** Current status of the spec */
|
||||
status: PlanSpecStatus;
|
||||
/** The spec/plan content (markdown) */
|
||||
content?: string;
|
||||
/** Version number, incremented on each revision */
|
||||
version: number;
|
||||
/** ISO timestamp when spec was first generated */
|
||||
generatedAt?: string;
|
||||
/** ISO timestamp when spec was approved */
|
||||
approvedAt?: string;
|
||||
/** Whether user has reviewed (approved/rejected) the spec */
|
||||
reviewedByUser: boolean;
|
||||
/** Number of tasks completed during execution */
|
||||
tasksCompleted?: number;
|
||||
/** Total number of tasks parsed from spec */
|
||||
tasksTotal?: number;
|
||||
/** ID of the task currently being executed */
|
||||
currentTaskId?: string;
|
||||
/** All parsed tasks from the spec */
|
||||
tasks?: ParsedTask[];
|
||||
}
|
||||
|
||||
/**
|
||||
* AutoModeEventType - Type-safe event names emitted by auto-mode service
|
||||
*
|
||||
* All events are wrapped as `auto-mode:event` with `type` field containing
|
||||
* one of these values.
|
||||
*/
|
||||
export type AutoModeEventType =
|
||||
// Auto-loop lifecycle events
|
||||
| 'auto_mode_started'
|
||||
| 'auto_mode_stopped'
|
||||
| 'auto_mode_idle'
|
||||
// Feature execution events
|
||||
| 'auto_mode_feature_start'
|
||||
| 'auto_mode_feature_complete'
|
||||
| 'auto_mode_progress'
|
||||
| 'auto_mode_tool'
|
||||
| 'auto_mode_error'
|
||||
// Task execution events (multi-agent)
|
||||
| 'auto_mode_task_started'
|
||||
| 'auto_mode_task_complete'
|
||||
| 'auto_mode_phase_complete'
|
||||
// Planning/spec events
|
||||
| 'planning_started'
|
||||
| 'plan_approval_required'
|
||||
| 'plan_approved'
|
||||
| 'plan_rejected'
|
||||
| 'plan_auto_approved'
|
||||
| 'plan_revision_requested';
|
||||
|
||||
/**
|
||||
* AutoModeEvent - Base event payload structure
|
||||
*/
|
||||
export interface AutoModeEventPayload {
|
||||
/** The specific event type */
|
||||
type: AutoModeEventType;
|
||||
/** Feature ID this event relates to */
|
||||
featureId?: string;
|
||||
/** Project path */
|
||||
projectPath?: string;
|
||||
/** Additional event-specific data */
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
/**
|
||||
* TaskProgressPayload - Event payload for task progress events
|
||||
*/
|
||||
export interface TaskProgressPayload {
|
||||
type: 'auto_mode_task_started' | 'auto_mode_task_complete';
|
||||
featureId: string;
|
||||
projectPath: string;
|
||||
taskId: string;
|
||||
taskDescription?: string;
|
||||
taskIndex: number;
|
||||
tasksTotal: number;
|
||||
tasksCompleted?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* PlanApprovalPayload - Event payload for plan approval events
|
||||
*/
|
||||
export interface PlanApprovalPayload {
|
||||
type: 'plan_approval_required';
|
||||
featureId: string;
|
||||
projectPath: string;
|
||||
planContent: string;
|
||||
planningMode: PlanningMode;
|
||||
planVersion: number;
|
||||
}
|
||||
Reference in New Issue
Block a user