mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 21:03:08 +00:00
refactor: extract event, spec, and enhancement types to shared package
- Extract EventType and EventCallback to @automaker/types - Extract SpecOutput and specOutputSchema to @automaker/types - Extract EnhancementMode and EnhancementExample to @automaker/types - Update server files to import from shared types - Reduces server code duplication by ~123 lines 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,121 +5,9 @@
|
|||||||
* app specifications to ensure consistency across the application.
|
* app specifications to ensure consistency across the application.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
// Import and re-export spec types from shared package
|
||||||
* TypeScript interface for structured spec output
|
export type { SpecOutput } from "@automaker/types";
|
||||||
*/
|
export { specOutputSchema } from "@automaker/types";
|
||||||
export interface SpecOutput {
|
|
||||||
project_name: string;
|
|
||||||
overview: string;
|
|
||||||
technology_stack: string[];
|
|
||||||
core_capabilities: string[];
|
|
||||||
implemented_features: Array<{
|
|
||||||
name: string;
|
|
||||||
description: string;
|
|
||||||
file_locations?: string[];
|
|
||||||
}>;
|
|
||||||
additional_requirements?: string[];
|
|
||||||
development_guidelines?: string[];
|
|
||||||
implementation_roadmap?: Array<{
|
|
||||||
phase: string;
|
|
||||||
status: "completed" | "in_progress" | "pending";
|
|
||||||
description: string;
|
|
||||||
}>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JSON Schema for structured spec output
|
|
||||||
* Used with Claude's structured output feature for reliable parsing
|
|
||||||
*/
|
|
||||||
export const specOutputSchema = {
|
|
||||||
type: "object",
|
|
||||||
properties: {
|
|
||||||
project_name: {
|
|
||||||
type: "string",
|
|
||||||
description: "The name of the project",
|
|
||||||
},
|
|
||||||
overview: {
|
|
||||||
type: "string",
|
|
||||||
description:
|
|
||||||
"A comprehensive description of what the project does, its purpose, and key goals",
|
|
||||||
},
|
|
||||||
technology_stack: {
|
|
||||||
type: "array",
|
|
||||||
items: { type: "string" },
|
|
||||||
description:
|
|
||||||
"List of all technologies, frameworks, libraries, and tools used",
|
|
||||||
},
|
|
||||||
core_capabilities: {
|
|
||||||
type: "array",
|
|
||||||
items: { type: "string" },
|
|
||||||
description: "List of main features and capabilities the project provides",
|
|
||||||
},
|
|
||||||
implemented_features: {
|
|
||||||
type: "array",
|
|
||||||
items: {
|
|
||||||
type: "object",
|
|
||||||
properties: {
|
|
||||||
name: {
|
|
||||||
type: "string",
|
|
||||||
description: "Name of the implemented feature",
|
|
||||||
},
|
|
||||||
description: {
|
|
||||||
type: "string",
|
|
||||||
description: "Description of what the feature does",
|
|
||||||
},
|
|
||||||
file_locations: {
|
|
||||||
type: "array",
|
|
||||||
items: { type: "string" },
|
|
||||||
description: "File paths where this feature is implemented",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
required: ["name", "description"],
|
|
||||||
},
|
|
||||||
description: "Features that have been implemented based on code analysis",
|
|
||||||
},
|
|
||||||
additional_requirements: {
|
|
||||||
type: "array",
|
|
||||||
items: { type: "string" },
|
|
||||||
description: "Any additional requirements or constraints",
|
|
||||||
},
|
|
||||||
development_guidelines: {
|
|
||||||
type: "array",
|
|
||||||
items: { type: "string" },
|
|
||||||
description: "Development standards and practices",
|
|
||||||
},
|
|
||||||
implementation_roadmap: {
|
|
||||||
type: "array",
|
|
||||||
items: {
|
|
||||||
type: "object",
|
|
||||||
properties: {
|
|
||||||
phase: {
|
|
||||||
type: "string",
|
|
||||||
description: "Name of the implementation phase",
|
|
||||||
},
|
|
||||||
status: {
|
|
||||||
type: "string",
|
|
||||||
enum: ["completed", "in_progress", "pending"],
|
|
||||||
description: "Current status of this phase",
|
|
||||||
},
|
|
||||||
description: {
|
|
||||||
type: "string",
|
|
||||||
description: "Description of what this phase involves",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
required: ["phase", "status", "description"],
|
|
||||||
},
|
|
||||||
description: "Phases or roadmap items for implementation",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
required: [
|
|
||||||
"project_name",
|
|
||||||
"overview",
|
|
||||||
"technology_stack",
|
|
||||||
"core_capabilities",
|
|
||||||
"implemented_features",
|
|
||||||
],
|
|
||||||
additionalProperties: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Escape special XML characters
|
* Escape special XML characters
|
||||||
@@ -136,7 +24,7 @@ function escapeXml(str: string): string {
|
|||||||
/**
|
/**
|
||||||
* Convert structured spec output to XML format
|
* Convert structured spec output to XML format
|
||||||
*/
|
*/
|
||||||
export function specToXml(spec: SpecOutput): string {
|
export function specToXml(spec: import("@automaker/types").SpecOutput): string {
|
||||||
const indent = " ";
|
const indent = " ";
|
||||||
|
|
||||||
let xml = `<?xml version="1.0" encoding="UTF-8"?>
|
let xml = `<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|||||||
@@ -10,18 +10,10 @@
|
|||||||
* Uses chain-of-thought prompting with few-shot examples for consistent results.
|
* Uses chain-of-thought prompting with few-shot examples for consistent results.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
import type { EnhancementMode, EnhancementExample } from "@automaker/types";
|
||||||
* Available enhancement modes for transforming task descriptions
|
|
||||||
*/
|
|
||||||
export type EnhancementMode = "improve" | "technical" | "simplify" | "acceptance";
|
|
||||||
|
|
||||||
/**
|
// Re-export enhancement types from shared package
|
||||||
* Example input/output pair for few-shot learning
|
export type { EnhancementMode, EnhancementExample } from "@automaker/types";
|
||||||
*/
|
|
||||||
export interface EnhancementExample {
|
|
||||||
input: string;
|
|
||||||
output: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* System prompt for the "improve" enhancement mode.
|
* System prompt for the "improve" enhancement mode.
|
||||||
|
|||||||
@@ -2,42 +2,19 @@
|
|||||||
* Event emitter for streaming events to WebSocket clients
|
* Event emitter for streaming events to WebSocket clients
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export type EventType =
|
// Re-export event types from shared package
|
||||||
| "agent:stream"
|
export type { EventType, EventCallback } from "@automaker/types";
|
||||||
| "auto-mode:event"
|
|
||||||
| "auto-mode:started"
|
|
||||||
| "auto-mode:stopped"
|
|
||||||
| "auto-mode:idle"
|
|
||||||
| "auto-mode:error"
|
|
||||||
| "feature:started"
|
|
||||||
| "feature:completed"
|
|
||||||
| "feature:stopped"
|
|
||||||
| "feature:error"
|
|
||||||
| "feature:progress"
|
|
||||||
| "feature:tool-use"
|
|
||||||
| "feature:follow-up-started"
|
|
||||||
| "feature:follow-up-completed"
|
|
||||||
| "feature:verified"
|
|
||||||
| "feature:committed"
|
|
||||||
| "project:analysis-started"
|
|
||||||
| "project:analysis-progress"
|
|
||||||
| "project:analysis-completed"
|
|
||||||
| "project:analysis-error"
|
|
||||||
| "suggestions:event"
|
|
||||||
| "spec-regeneration:event";
|
|
||||||
|
|
||||||
export type EventCallback = (type: EventType, payload: unknown) => void;
|
|
||||||
|
|
||||||
export interface EventEmitter {
|
export interface EventEmitter {
|
||||||
emit: (type: EventType, payload: unknown) => void;
|
emit: (type: import("@automaker/types").EventType, payload: unknown) => void;
|
||||||
subscribe: (callback: EventCallback) => () => void;
|
subscribe: (callback: import("@automaker/types").EventCallback) => () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createEventEmitter(): EventEmitter {
|
export function createEventEmitter(): EventEmitter {
|
||||||
const subscribers = new Set<EventCallback>();
|
const subscribers = new Set<import("@automaker/types").EventCallback>();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
emit(type: EventType, payload: unknown) {
|
emit(type: import("@automaker/types").EventType, payload: unknown) {
|
||||||
for (const callback of subscribers) {
|
for (const callback of subscribers) {
|
||||||
try {
|
try {
|
||||||
callback(type, payload);
|
callback(type, payload);
|
||||||
@@ -47,7 +24,7 @@ export function createEventEmitter(): EventEmitter {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
subscribe(callback: EventCallback) {
|
subscribe(callback: import("@automaker/types").EventCallback) {
|
||||||
subscribers.add(callback);
|
subscribers.add(callback);
|
||||||
return () => {
|
return () => {
|
||||||
subscribers.delete(callback);
|
subscribers.delete(callback);
|
||||||
|
|||||||
16
libs/types/src/enhancement.ts
Normal file
16
libs/types/src/enhancement.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
* Enhancement types for AI-powered task description improvements
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Available enhancement modes for transforming task descriptions
|
||||||
|
*/
|
||||||
|
export type EnhancementMode = "improve" | "technical" | "simplify" | "acceptance";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example input/output pair for few-shot learning
|
||||||
|
*/
|
||||||
|
export interface EnhancementExample {
|
||||||
|
input: string;
|
||||||
|
output: string;
|
||||||
|
}
|
||||||
29
libs/types/src/event.ts
Normal file
29
libs/types/src/event.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/**
|
||||||
|
* Event types for AutoMaker event system
|
||||||
|
*/
|
||||||
|
|
||||||
|
export type EventType =
|
||||||
|
| "agent:stream"
|
||||||
|
| "auto-mode:event"
|
||||||
|
| "auto-mode:started"
|
||||||
|
| "auto-mode:stopped"
|
||||||
|
| "auto-mode:idle"
|
||||||
|
| "auto-mode:error"
|
||||||
|
| "feature:started"
|
||||||
|
| "feature:completed"
|
||||||
|
| "feature:stopped"
|
||||||
|
| "feature:error"
|
||||||
|
| "feature:progress"
|
||||||
|
| "feature:tool-use"
|
||||||
|
| "feature:follow-up-started"
|
||||||
|
| "feature:follow-up-completed"
|
||||||
|
| "feature:verified"
|
||||||
|
| "feature:committed"
|
||||||
|
| "project:analysis-started"
|
||||||
|
| "project:analysis-progress"
|
||||||
|
| "project:analysis-completed"
|
||||||
|
| "project:analysis-error"
|
||||||
|
| "suggestions:event"
|
||||||
|
| "spec-regeneration:event";
|
||||||
|
|
||||||
|
export type EventCallback = (type: EventType, payload: unknown) => void;
|
||||||
@@ -49,3 +49,23 @@ export {
|
|||||||
DEFAULT_MODELS,
|
DEFAULT_MODELS,
|
||||||
type ModelAlias,
|
type ModelAlias,
|
||||||
} from './model';
|
} from './model';
|
||||||
|
|
||||||
|
// Event types
|
||||||
|
export type {
|
||||||
|
EventType,
|
||||||
|
EventCallback,
|
||||||
|
} from './event';
|
||||||
|
|
||||||
|
// Spec types
|
||||||
|
export type {
|
||||||
|
SpecOutput,
|
||||||
|
} from './spec';
|
||||||
|
export {
|
||||||
|
specOutputSchema,
|
||||||
|
} from './spec';
|
||||||
|
|
||||||
|
// Enhancement types
|
||||||
|
export type {
|
||||||
|
EnhancementMode,
|
||||||
|
EnhancementExample,
|
||||||
|
} from './enhancement';
|
||||||
|
|||||||
119
libs/types/src/spec.ts
Normal file
119
libs/types/src/spec.ts
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/**
|
||||||
|
* App specification types
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TypeScript interface for structured spec output
|
||||||
|
*/
|
||||||
|
export interface SpecOutput {
|
||||||
|
project_name: string;
|
||||||
|
overview: string;
|
||||||
|
technology_stack: string[];
|
||||||
|
core_capabilities: string[];
|
||||||
|
implemented_features: Array<{
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
file_locations?: string[];
|
||||||
|
}>;
|
||||||
|
additional_requirements?: string[];
|
||||||
|
development_guidelines?: string[];
|
||||||
|
implementation_roadmap?: Array<{
|
||||||
|
phase: string;
|
||||||
|
status: "completed" | "in_progress" | "pending";
|
||||||
|
description: string;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSON Schema for structured spec output
|
||||||
|
* Used with Claude's structured output feature for reliable parsing
|
||||||
|
*/
|
||||||
|
export const specOutputSchema = {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
project_name: {
|
||||||
|
type: "string",
|
||||||
|
description: "The name of the project",
|
||||||
|
},
|
||||||
|
overview: {
|
||||||
|
type: "string",
|
||||||
|
description:
|
||||||
|
"A comprehensive description of what the project does, its purpose, and key goals",
|
||||||
|
},
|
||||||
|
technology_stack: {
|
||||||
|
type: "array",
|
||||||
|
items: { type: "string" },
|
||||||
|
description:
|
||||||
|
"List of all technologies, frameworks, libraries, and tools used",
|
||||||
|
},
|
||||||
|
core_capabilities: {
|
||||||
|
type: "array",
|
||||||
|
items: { type: "string" },
|
||||||
|
description: "List of main features and capabilities the project provides",
|
||||||
|
},
|
||||||
|
implemented_features: {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
name: {
|
||||||
|
type: "string",
|
||||||
|
description: "Name of the implemented feature",
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
type: "string",
|
||||||
|
description: "Description of what the feature does",
|
||||||
|
},
|
||||||
|
file_locations: {
|
||||||
|
type: "array",
|
||||||
|
items: { type: "string" },
|
||||||
|
description: "File paths where this feature is implemented",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
required: ["name", "description"],
|
||||||
|
},
|
||||||
|
description: "Features that have been implemented based on code analysis",
|
||||||
|
},
|
||||||
|
additional_requirements: {
|
||||||
|
type: "array",
|
||||||
|
items: { type: "string" },
|
||||||
|
description: "Any additional requirements or constraints",
|
||||||
|
},
|
||||||
|
development_guidelines: {
|
||||||
|
type: "array",
|
||||||
|
items: { type: "string" },
|
||||||
|
description: "Development standards and practices",
|
||||||
|
},
|
||||||
|
implementation_roadmap: {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
phase: {
|
||||||
|
type: "string",
|
||||||
|
description: "Name of the implementation phase",
|
||||||
|
},
|
||||||
|
status: {
|
||||||
|
type: "string",
|
||||||
|
enum: ["completed", "in_progress", "pending"],
|
||||||
|
description: "Current status of this phase",
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
type: "string",
|
||||||
|
description: "Description of what this phase involves",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
required: ["phase", "status", "description"],
|
||||||
|
},
|
||||||
|
description: "Phases or roadmap items for implementation",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
required: [
|
||||||
|
"project_name",
|
||||||
|
"overview",
|
||||||
|
"technology_stack",
|
||||||
|
"core_capabilities",
|
||||||
|
"implemented_features",
|
||||||
|
],
|
||||||
|
additionalProperties: false,
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user