@hyperdrive.bot/bmad-workflow 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1017 -0
- package/bin/dev +5 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +5 -0
- package/bin/run +5 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +5 -0
- package/dist/commands/config/show.d.ts +34 -0
- package/dist/commands/config/show.js +108 -0
- package/dist/commands/config/validate.d.ts +29 -0
- package/dist/commands/config/validate.js +131 -0
- package/dist/commands/decompose.d.ts +79 -0
- package/dist/commands/decompose.js +327 -0
- package/dist/commands/demo.d.ts +18 -0
- package/dist/commands/demo.js +107 -0
- package/dist/commands/epics/create.d.ts +123 -0
- package/dist/commands/epics/create.js +459 -0
- package/dist/commands/epics/list.d.ts +120 -0
- package/dist/commands/epics/list.js +280 -0
- package/dist/commands/hello/index.d.ts +12 -0
- package/dist/commands/hello/index.js +34 -0
- package/dist/commands/hello/world.d.ts +8 -0
- package/dist/commands/hello/world.js +24 -0
- package/dist/commands/prd/fix.d.ts +39 -0
- package/dist/commands/prd/fix.js +140 -0
- package/dist/commands/prd/validate.d.ts +112 -0
- package/dist/commands/prd/validate.js +302 -0
- package/dist/commands/stories/create.d.ts +95 -0
- package/dist/commands/stories/create.js +431 -0
- package/dist/commands/stories/develop.d.ts +91 -0
- package/dist/commands/stories/develop.js +460 -0
- package/dist/commands/stories/list.d.ts +84 -0
- package/dist/commands/stories/list.js +291 -0
- package/dist/commands/stories/move.d.ts +66 -0
- package/dist/commands/stories/move.js +273 -0
- package/dist/commands/stories/qa.d.ts +99 -0
- package/dist/commands/stories/qa.js +530 -0
- package/dist/commands/workflow.d.ts +97 -0
- package/dist/commands/workflow.js +390 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/models/agent-options.d.ts +50 -0
- package/dist/models/agent-options.js +1 -0
- package/dist/models/agent-result.d.ts +29 -0
- package/dist/models/agent-result.js +1 -0
- package/dist/models/index.d.ts +10 -0
- package/dist/models/index.js +10 -0
- package/dist/models/phase-result.d.ts +65 -0
- package/dist/models/phase-result.js +7 -0
- package/dist/models/provider.d.ts +28 -0
- package/dist/models/provider.js +18 -0
- package/dist/models/story.d.ts +154 -0
- package/dist/models/story.js +18 -0
- package/dist/models/workflow-config.d.ts +148 -0
- package/dist/models/workflow-config.js +1 -0
- package/dist/models/workflow-result.d.ts +164 -0
- package/dist/models/workflow-result.js +7 -0
- package/dist/services/agents/agent-runner-factory.d.ts +31 -0
- package/dist/services/agents/agent-runner-factory.js +44 -0
- package/dist/services/agents/agent-runner.d.ts +46 -0
- package/dist/services/agents/agent-runner.js +29 -0
- package/dist/services/agents/claude-agent-runner.d.ts +81 -0
- package/dist/services/agents/claude-agent-runner.js +332 -0
- package/dist/services/agents/gemini-agent-runner.d.ts +82 -0
- package/dist/services/agents/gemini-agent-runner.js +350 -0
- package/dist/services/agents/index.d.ts +7 -0
- package/dist/services/agents/index.js +7 -0
- package/dist/services/file-system/file-manager.d.ts +110 -0
- package/dist/services/file-system/file-manager.js +223 -0
- package/dist/services/file-system/glob-matcher.d.ts +75 -0
- package/dist/services/file-system/glob-matcher.js +126 -0
- package/dist/services/file-system/path-resolver.d.ts +183 -0
- package/dist/services/file-system/path-resolver.js +400 -0
- package/dist/services/logging/workflow-logger.d.ts +232 -0
- package/dist/services/logging/workflow-logger.js +552 -0
- package/dist/services/orchestration/batch-processor.d.ts +113 -0
- package/dist/services/orchestration/batch-processor.js +187 -0
- package/dist/services/orchestration/dependency-graph-executor.d.ts +60 -0
- package/dist/services/orchestration/dependency-graph-executor.js +447 -0
- package/dist/services/orchestration/index.d.ts +10 -0
- package/dist/services/orchestration/index.js +8 -0
- package/dist/services/orchestration/input-detector.d.ts +125 -0
- package/dist/services/orchestration/input-detector.js +381 -0
- package/dist/services/orchestration/story-queue.d.ts +94 -0
- package/dist/services/orchestration/story-queue.js +170 -0
- package/dist/services/orchestration/story-type-detector.d.ts +80 -0
- package/dist/services/orchestration/story-type-detector.js +258 -0
- package/dist/services/orchestration/task-decomposition-service.d.ts +67 -0
- package/dist/services/orchestration/task-decomposition-service.js +607 -0
- package/dist/services/orchestration/workflow-orchestrator.d.ts +659 -0
- package/dist/services/orchestration/workflow-orchestrator.js +2201 -0
- package/dist/services/parsers/epic-parser.d.ts +117 -0
- package/dist/services/parsers/epic-parser.js +264 -0
- package/dist/services/parsers/prd-fixer.d.ts +86 -0
- package/dist/services/parsers/prd-fixer.js +194 -0
- package/dist/services/parsers/prd-parser.d.ts +123 -0
- package/dist/services/parsers/prd-parser.js +286 -0
- package/dist/services/parsers/standalone-story-parser.d.ts +114 -0
- package/dist/services/parsers/standalone-story-parser.js +255 -0
- package/dist/services/parsers/story-parser-factory.d.ts +81 -0
- package/dist/services/parsers/story-parser-factory.js +108 -0
- package/dist/services/parsers/story-parser.d.ts +122 -0
- package/dist/services/parsers/story-parser.js +262 -0
- package/dist/services/scaffolding/decompose-session-scaffolder.d.ts +74 -0
- package/dist/services/scaffolding/decompose-session-scaffolder.js +315 -0
- package/dist/services/scaffolding/file-scaffolder.d.ts +94 -0
- package/dist/services/scaffolding/file-scaffolder.js +314 -0
- package/dist/services/validation/config-validator.d.ts +88 -0
- package/dist/services/validation/config-validator.js +167 -0
- package/dist/types/task-graph.d.ts +142 -0
- package/dist/types/task-graph.js +5 -0
- package/dist/utils/colors.d.ts +49 -0
- package/dist/utils/colors.js +50 -0
- package/dist/utils/error-formatter.d.ts +64 -0
- package/dist/utils/error-formatter.js +279 -0
- package/dist/utils/errors.d.ts +170 -0
- package/dist/utils/errors.js +233 -0
- package/dist/utils/formatters.d.ts +84 -0
- package/dist/utils/formatters.js +162 -0
- package/dist/utils/logger.d.ts +63 -0
- package/dist/utils/logger.js +78 -0
- package/dist/utils/progress.d.ts +104 -0
- package/dist/utils/progress.js +161 -0
- package/dist/utils/retry.d.ts +114 -0
- package/dist/utils/retry.js +160 -0
- package/dist/utils/shared-flags.d.ts +28 -0
- package/dist/utils/shared-flags.js +43 -0
- package/package.json +119 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Provider types and configuration
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Supported AI providers
|
|
6
|
+
*/
|
|
7
|
+
export type AIProvider = 'claude' | 'gemini';
|
|
8
|
+
/**
|
|
9
|
+
* Provider-specific configuration
|
|
10
|
+
*/
|
|
11
|
+
export interface ProviderConfig {
|
|
12
|
+
/**
|
|
13
|
+
* The CLI command to execute
|
|
14
|
+
*/
|
|
15
|
+
command: string;
|
|
16
|
+
/**
|
|
17
|
+
* Default flags to pass to the CLI
|
|
18
|
+
*/
|
|
19
|
+
flags: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Whether this provider supports @file references natively
|
|
22
|
+
*/
|
|
23
|
+
supportsFileReferences: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Default provider configurations
|
|
27
|
+
*/
|
|
28
|
+
export declare const PROVIDER_CONFIGS: Record<AIProvider, ProviderConfig>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Provider types and configuration
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Default provider configurations
|
|
6
|
+
*/
|
|
7
|
+
export const PROVIDER_CONFIGS = {
|
|
8
|
+
claude: {
|
|
9
|
+
command: 'claude',
|
|
10
|
+
flags: ['--dangerously-skip-permissions', '--print'],
|
|
11
|
+
supportsFileReferences: true,
|
|
12
|
+
},
|
|
13
|
+
gemini: {
|
|
14
|
+
command: 'gemini',
|
|
15
|
+
flags: ['-p', '--yolo'],
|
|
16
|
+
supportsFileReferences: false,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Story Model
|
|
3
|
+
*
|
|
4
|
+
* Represents a user story within an epic that can be implemented by the dev agent.
|
|
5
|
+
* Stories are extracted from epic markdown files and tracked through their lifecycle.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Story status values
|
|
9
|
+
*/
|
|
10
|
+
export type StoryStatus = 'Done' | 'Draft' | 'Failed' | 'InProgress' | 'Ready';
|
|
11
|
+
/**
|
|
12
|
+
* Represents a user story extracted from an epic
|
|
13
|
+
*/
|
|
14
|
+
export interface Story {
|
|
15
|
+
/**
|
|
16
|
+
* Parent epic number
|
|
17
|
+
*/
|
|
18
|
+
epicNumber: number;
|
|
19
|
+
/**
|
|
20
|
+
* Path to story markdown file (optional, set by commands)
|
|
21
|
+
*/
|
|
22
|
+
filePath?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Complete story ID (e.g., "1.2", "2.1")
|
|
25
|
+
*/
|
|
26
|
+
fullNumber: string;
|
|
27
|
+
/**
|
|
28
|
+
* Story number within epic (e.g., 1, 2, 3)
|
|
29
|
+
*/
|
|
30
|
+
number: number;
|
|
31
|
+
/**
|
|
32
|
+
* Current story status (optional, extracted from story file)
|
|
33
|
+
*/
|
|
34
|
+
status?: StoryStatus;
|
|
35
|
+
/**
|
|
36
|
+
* Story title from header
|
|
37
|
+
*/
|
|
38
|
+
title: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Story type discriminator
|
|
42
|
+
*/
|
|
43
|
+
export type StoryType = 'epic-based' | 'standalone';
|
|
44
|
+
/**
|
|
45
|
+
* Base metadata shared by all story types
|
|
46
|
+
*/
|
|
47
|
+
export interface BaseStoryMetadata {
|
|
48
|
+
/**
|
|
49
|
+
* Full path to story file
|
|
50
|
+
*/
|
|
51
|
+
filePath: string;
|
|
52
|
+
/**
|
|
53
|
+
* Unique identifier for the story
|
|
54
|
+
*/
|
|
55
|
+
id: string;
|
|
56
|
+
/**
|
|
57
|
+
* Current story status
|
|
58
|
+
*/
|
|
59
|
+
status: StoryStatus;
|
|
60
|
+
/**
|
|
61
|
+
* Story title extracted from H1 header
|
|
62
|
+
*/
|
|
63
|
+
title: string;
|
|
64
|
+
/**
|
|
65
|
+
* Story type discriminator
|
|
66
|
+
*/
|
|
67
|
+
type: StoryType;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Metadata for epic-based stories (e.g., PREFIX-2.3-story.md)
|
|
71
|
+
*
|
|
72
|
+
* Stories that follow the epic.story numbering pattern and are part
|
|
73
|
+
* of a larger epic workflow.
|
|
74
|
+
*/
|
|
75
|
+
export interface EpicStoryMetadata extends BaseStoryMetadata {
|
|
76
|
+
/**
|
|
77
|
+
* Parent epic number (e.g., 2)
|
|
78
|
+
*/
|
|
79
|
+
epicNumber: number;
|
|
80
|
+
/**
|
|
81
|
+
* Complete story number as string (e.g., "2.3")
|
|
82
|
+
*/
|
|
83
|
+
number: string;
|
|
84
|
+
/**
|
|
85
|
+
* Story number within epic (e.g., 3)
|
|
86
|
+
*/
|
|
87
|
+
storyNumber: number;
|
|
88
|
+
/**
|
|
89
|
+
* Type discriminator
|
|
90
|
+
*/
|
|
91
|
+
type: 'epic-based';
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Metadata for standalone stories (e.g., JIRA-SIGN-10.md, fix-bug.md)
|
|
95
|
+
*
|
|
96
|
+
* Stories that don't follow epic numbering and are tracked independently.
|
|
97
|
+
*/
|
|
98
|
+
export interface StandaloneStoryMetadata extends BaseStoryMetadata {
|
|
99
|
+
/**
|
|
100
|
+
* Optional category/prefix (e.g., "JIRA-SIGN", "bugfix")
|
|
101
|
+
*/
|
|
102
|
+
category?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Type discriminator
|
|
105
|
+
*/
|
|
106
|
+
type: 'standalone';
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Union type for all story metadata
|
|
110
|
+
*
|
|
111
|
+
* Use type guards to discriminate between epic-based and standalone stories.
|
|
112
|
+
*/
|
|
113
|
+
export type StoryMetadata = EpicStoryMetadata | StandaloneStoryMetadata;
|
|
114
|
+
/**
|
|
115
|
+
* Metadata extracted from a story file (legacy - kept for backward compatibility)
|
|
116
|
+
*
|
|
117
|
+
* @deprecated Use EpicStoryMetadata instead
|
|
118
|
+
* Used by StoryParser to return detailed information about a story,
|
|
119
|
+
* including both structural data (epic/story numbers) and content (title, status).
|
|
120
|
+
*/
|
|
121
|
+
export interface LegacyStoryMetadata {
|
|
122
|
+
/**
|
|
123
|
+
* Parent epic number (e.g., 2)
|
|
124
|
+
*/
|
|
125
|
+
epicNumber: number;
|
|
126
|
+
/**
|
|
127
|
+
* Full path to story file
|
|
128
|
+
*/
|
|
129
|
+
filePath: string;
|
|
130
|
+
/**
|
|
131
|
+
* Complete story number as string (e.g., "2.3")
|
|
132
|
+
*/
|
|
133
|
+
number: string;
|
|
134
|
+
/**
|
|
135
|
+
* Current story status
|
|
136
|
+
*/
|
|
137
|
+
status: StoryStatus;
|
|
138
|
+
/**
|
|
139
|
+
* Story number within epic (e.g., 3)
|
|
140
|
+
*/
|
|
141
|
+
storyNumber: number;
|
|
142
|
+
/**
|
|
143
|
+
* Story title extracted from H1 header
|
|
144
|
+
*/
|
|
145
|
+
title: string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Type guard to check if metadata is epic-based
|
|
149
|
+
*/
|
|
150
|
+
export declare function isEpicStory(metadata: StoryMetadata): metadata is EpicStoryMetadata;
|
|
151
|
+
/**
|
|
152
|
+
* Type guard to check if metadata is standalone
|
|
153
|
+
*/
|
|
154
|
+
export declare function isStandaloneStory(metadata: StoryMetadata): metadata is StandaloneStoryMetadata;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Story Model
|
|
3
|
+
*
|
|
4
|
+
* Represents a user story within an epic that can be implemented by the dev agent.
|
|
5
|
+
* Stories are extracted from epic markdown files and tracked through their lifecycle.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Type guard to check if metadata is epic-based
|
|
9
|
+
*/
|
|
10
|
+
export function isEpicStory(metadata) {
|
|
11
|
+
return metadata.type === 'epic-based';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Type guard to check if metadata is standalone
|
|
15
|
+
*/
|
|
16
|
+
export function isStandaloneStory(metadata) {
|
|
17
|
+
return metadata.type === 'standalone';
|
|
18
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for workflow execution across all phases
|
|
3
|
+
*
|
|
4
|
+
* Controls workflow behavior including which phases to execute,
|
|
5
|
+
* parallelization settings, and additional context for AI agents.
|
|
6
|
+
*/
|
|
7
|
+
export interface WorkflowConfig {
|
|
8
|
+
/**
|
|
9
|
+
* Auto-fix PRD format using AI when parsing fails
|
|
10
|
+
*
|
|
11
|
+
* When true, if the PRD parser fails to extract epics, the workflow
|
|
12
|
+
* will use Claude to automatically reformat the PRD to match expected
|
|
13
|
+
* patterns before retrying. Creates a backup (.bak) before modifying.
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
autoFix?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Working directory for agent execution
|
|
19
|
+
*
|
|
20
|
+
* When specified, this path is included in prompts to tell agents
|
|
21
|
+
* which directory to operate in. Does not affect CLI path resolution.
|
|
22
|
+
* @example '/path/to/project'
|
|
23
|
+
*/
|
|
24
|
+
cwd?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Preview actions without execution
|
|
27
|
+
*
|
|
28
|
+
* When true, workflow logs intended actions but doesn't execute them.
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
dryRun: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Seconds between story creation batches
|
|
34
|
+
*
|
|
35
|
+
* Controls rate limiting when creating multiple stories.
|
|
36
|
+
* @default 60
|
|
37
|
+
*/
|
|
38
|
+
epicInterval: number;
|
|
39
|
+
/**
|
|
40
|
+
* Input file path or pattern
|
|
41
|
+
*
|
|
42
|
+
* Can be:
|
|
43
|
+
* - PRD file path (e.g., 'docs/PRD-feature.md')
|
|
44
|
+
* - Epic file path (e.g., 'docs/epics/epic-1.md')
|
|
45
|
+
* - Story file pattern (e.g., 'docs/stories/STORY-1.*')
|
|
46
|
+
*/
|
|
47
|
+
input: string;
|
|
48
|
+
/**
|
|
49
|
+
* Max concurrent epic/story creations
|
|
50
|
+
*
|
|
51
|
+
* Controls parallelization for epic and story creation phases.
|
|
52
|
+
* Development phase is always sequential.
|
|
53
|
+
* @default 3
|
|
54
|
+
*/
|
|
55
|
+
parallel: number;
|
|
56
|
+
/**
|
|
57
|
+
* Enable pipelined workflow execution
|
|
58
|
+
*
|
|
59
|
+
* When true, story and dev phases run concurrently using StoryQueue.
|
|
60
|
+
* When false, executes phases sequentially (backward compatibility).
|
|
61
|
+
* @default true
|
|
62
|
+
*/
|
|
63
|
+
pipeline: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Seconds between epic creation batches
|
|
66
|
+
*
|
|
67
|
+
* Controls rate limiting when creating multiple epics.
|
|
68
|
+
* @default 60
|
|
69
|
+
*/
|
|
70
|
+
prdInterval: number;
|
|
71
|
+
/**
|
|
72
|
+
* Filename prefix for generated files
|
|
73
|
+
*
|
|
74
|
+
* Used for epic and story file naming.
|
|
75
|
+
* @example 'PROJ-123' -> 'PROJ-123-epic-1.md'
|
|
76
|
+
*/
|
|
77
|
+
prefix: string;
|
|
78
|
+
/**
|
|
79
|
+
* AI provider to use for agent execution
|
|
80
|
+
*
|
|
81
|
+
* @default 'claude'
|
|
82
|
+
*/
|
|
83
|
+
provider?: 'claude' | 'gemini';
|
|
84
|
+
/**
|
|
85
|
+
* Run QA workflow after development completes
|
|
86
|
+
*
|
|
87
|
+
* When true, stories are run through QA workflow after dev phase.
|
|
88
|
+
* @default false
|
|
89
|
+
*/
|
|
90
|
+
qa?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Custom prompt/instructions for QA review phase
|
|
93
|
+
*
|
|
94
|
+
* Optional additional instructions passed to the QA agent.
|
|
95
|
+
*/
|
|
96
|
+
qaPrompt?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Maximum QA → Dev fix cycles
|
|
99
|
+
*
|
|
100
|
+
* Controls how many times a story can go through fix cycles
|
|
101
|
+
* when QA finds issues. Only used with qa=true.
|
|
102
|
+
* @default 2
|
|
103
|
+
*/
|
|
104
|
+
qaRetries?: number;
|
|
105
|
+
/**
|
|
106
|
+
* Additional context files for AI agents
|
|
107
|
+
*
|
|
108
|
+
* File paths to include as reference material when creating
|
|
109
|
+
* epics, stories, or during development.
|
|
110
|
+
* @example ['docs/architecture.md', 'docs/tech-stack.md']
|
|
111
|
+
*/
|
|
112
|
+
references: string[];
|
|
113
|
+
/**
|
|
114
|
+
* Skip development phase
|
|
115
|
+
*
|
|
116
|
+
* When true, workflow stops after epic/story creation.
|
|
117
|
+
* @default false
|
|
118
|
+
*/
|
|
119
|
+
skipDev: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Skip epic creation phase
|
|
122
|
+
*
|
|
123
|
+
* When true, workflow starts from story or dev phase.
|
|
124
|
+
* @default false
|
|
125
|
+
*/
|
|
126
|
+
skipEpics: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Skip story creation phase
|
|
129
|
+
*
|
|
130
|
+
* When true, workflow skips story creation and goes directly to dev.
|
|
131
|
+
* @default false
|
|
132
|
+
*/
|
|
133
|
+
skipStories: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Seconds between story development
|
|
136
|
+
*
|
|
137
|
+
* Controls rate limiting when developing multiple stories sequentially.
|
|
138
|
+
* @default 60
|
|
139
|
+
*/
|
|
140
|
+
storyInterval: number;
|
|
141
|
+
/**
|
|
142
|
+
* Detailed output mode
|
|
143
|
+
*
|
|
144
|
+
* When true, additional debug information is logged.
|
|
145
|
+
* @default false
|
|
146
|
+
*/
|
|
147
|
+
verbose: boolean;
|
|
148
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow Result
|
|
3
|
+
*
|
|
4
|
+
* Aggregates results from all workflow phases and provides
|
|
5
|
+
* overall execution metrics.
|
|
6
|
+
*/
|
|
7
|
+
import type { PhaseResult } from './phase-result.js';
|
|
8
|
+
/**
|
|
9
|
+
* Input type classification
|
|
10
|
+
*/
|
|
11
|
+
export type InputType = 'epic' | 'prd' | 'story-pattern';
|
|
12
|
+
/**
|
|
13
|
+
* Metadata about the detection process and results
|
|
14
|
+
*/
|
|
15
|
+
export interface DetectionMetadata {
|
|
16
|
+
/**
|
|
17
|
+
* Additional type-specific metadata
|
|
18
|
+
*/
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
/**
|
|
21
|
+
* Explanation of why detection was ambiguous (for low confidence)
|
|
22
|
+
*/
|
|
23
|
+
ambiguityReason?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Epic count (for PRD type)
|
|
26
|
+
*/
|
|
27
|
+
epicCount?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Epic number extracted from filename (for epic type)
|
|
30
|
+
*/
|
|
31
|
+
epicNumber?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Filename that was analyzed
|
|
34
|
+
*/
|
|
35
|
+
filename?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Markers found during detection (e.g., PRD section headers)
|
|
38
|
+
*/
|
|
39
|
+
markers?: string[];
|
|
40
|
+
/**
|
|
41
|
+
* Matched files (for story pattern type)
|
|
42
|
+
*/
|
|
43
|
+
matchedFiles?: string[];
|
|
44
|
+
/**
|
|
45
|
+
* Story count (for epic type)
|
|
46
|
+
*/
|
|
47
|
+
storyCount?: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Internal detection check result
|
|
51
|
+
* Used for calculating confidence scores
|
|
52
|
+
*/
|
|
53
|
+
export interface DetectionCheck {
|
|
54
|
+
/**
|
|
55
|
+
* Evidence found during check
|
|
56
|
+
*/
|
|
57
|
+
evidence?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Name of the check performed
|
|
60
|
+
*/
|
|
61
|
+
name: string;
|
|
62
|
+
/**
|
|
63
|
+
* Whether the check passed
|
|
64
|
+
*/
|
|
65
|
+
passed: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Weight of this check (0.0 to 1.0)
|
|
68
|
+
*/
|
|
69
|
+
weight: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Input detection result
|
|
73
|
+
*
|
|
74
|
+
* Determines which phase the workflow should start from
|
|
75
|
+
* based on the input file type.
|
|
76
|
+
*/
|
|
77
|
+
export interface InputDetectionResult {
|
|
78
|
+
/**
|
|
79
|
+
* Confidence score (0.0 to 1.0) indicating detection certainty
|
|
80
|
+
*
|
|
81
|
+
* - 1.0: High confidence (multiple indicators match)
|
|
82
|
+
* - 0.7: Medium confidence (single strong indicator)
|
|
83
|
+
* - 0.5: Low confidence (weak or conflicting indicators)
|
|
84
|
+
*/
|
|
85
|
+
confidence: number;
|
|
86
|
+
/**
|
|
87
|
+
* Error message if detection failed
|
|
88
|
+
*/
|
|
89
|
+
error?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Resolved file path for the input
|
|
92
|
+
*
|
|
93
|
+
* Absolute path to the input file or pattern.
|
|
94
|
+
*/
|
|
95
|
+
filePath: string;
|
|
96
|
+
/**
|
|
97
|
+
* Additional metadata about the detected input
|
|
98
|
+
*
|
|
99
|
+
* For PRD: { epicCount: number, markers: string[] }
|
|
100
|
+
* For epic: { epicNumber: number, storyCount: number }
|
|
101
|
+
* For story pattern: { matchedFiles: string[] }
|
|
102
|
+
*/
|
|
103
|
+
metadata?: DetectionMetadata;
|
|
104
|
+
/**
|
|
105
|
+
* Type of input detected, or null if detection failed
|
|
106
|
+
*
|
|
107
|
+
* - 'prd': Product Requirements Document (start from epic phase)
|
|
108
|
+
* - 'epic': Epic markdown file (start from story phase)
|
|
109
|
+
* - 'story-pattern': Story file pattern (start from dev phase)
|
|
110
|
+
*/
|
|
111
|
+
type: InputType | null;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Aggregated result of complete workflow execution
|
|
115
|
+
*
|
|
116
|
+
* Contains phase results, overall metrics, and success indicators.
|
|
117
|
+
*/
|
|
118
|
+
export interface WorkflowResult {
|
|
119
|
+
/**
|
|
120
|
+
* Development phase result
|
|
121
|
+
*
|
|
122
|
+
* Undefined if dev phase was skipped or not executed.
|
|
123
|
+
*/
|
|
124
|
+
devPhase?: PhaseResult;
|
|
125
|
+
/**
|
|
126
|
+
* Epic creation phase result
|
|
127
|
+
*
|
|
128
|
+
* Undefined if epic phase was skipped or not executed.
|
|
129
|
+
*/
|
|
130
|
+
epicPhase?: PhaseResult;
|
|
131
|
+
/**
|
|
132
|
+
* All executed phases succeeded
|
|
133
|
+
*
|
|
134
|
+
* True if all executed phases completed without any failures.
|
|
135
|
+
* Skipped phases do not affect this value.
|
|
136
|
+
*/
|
|
137
|
+
overallSuccess: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* QA phase result
|
|
140
|
+
*
|
|
141
|
+
* Undefined if QA phase was skipped or not executed.
|
|
142
|
+
*/
|
|
143
|
+
qaPhase?: PhaseResult;
|
|
144
|
+
/**
|
|
145
|
+
* Story creation phase result
|
|
146
|
+
*
|
|
147
|
+
* Undefined if story phase was skipped or not executed.
|
|
148
|
+
*/
|
|
149
|
+
storyPhase?: PhaseResult;
|
|
150
|
+
/**
|
|
151
|
+
* Total workflow duration in milliseconds
|
|
152
|
+
*
|
|
153
|
+
* Sum of all executed phase durations.
|
|
154
|
+
*/
|
|
155
|
+
totalDuration: number;
|
|
156
|
+
/**
|
|
157
|
+
* Total number of failures across all phases
|
|
158
|
+
*/
|
|
159
|
+
totalFailures: number;
|
|
160
|
+
/**
|
|
161
|
+
* Total number of files created/modified across all phases
|
|
162
|
+
*/
|
|
163
|
+
totalFilesProcessed: number;
|
|
164
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Runner Factory
|
|
3
|
+
*
|
|
4
|
+
* Creates the appropriate AIProviderRunner based on provider configuration.
|
|
5
|
+
*/
|
|
6
|
+
import type pino from 'pino';
|
|
7
|
+
import type { AIProvider } from '../../models/provider.js';
|
|
8
|
+
import type { AIProviderRunner } from './agent-runner.js';
|
|
9
|
+
/**
|
|
10
|
+
* Create an AI provider runner for the specified provider
|
|
11
|
+
*
|
|
12
|
+
* @param provider - The AI provider to create a runner for
|
|
13
|
+
* @param logger - Logger instance for structured logging
|
|
14
|
+
* @returns An AIProviderRunner instance for the specified provider
|
|
15
|
+
* @throws Error if the provider is not supported
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const logger = createLogger({ namespace: 'agent-runner' })
|
|
20
|
+
* const runner = createAgentRunner('claude', logger)
|
|
21
|
+
* const result = await runner.runAgent('Hello', { agentType: 'dev' })
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function createAgentRunner(provider: AIProvider, logger: pino.Logger): AIProviderRunner;
|
|
25
|
+
/**
|
|
26
|
+
* Check if a provider is supported
|
|
27
|
+
*
|
|
28
|
+
* @param provider - The provider to check
|
|
29
|
+
* @returns true if the provider is supported
|
|
30
|
+
*/
|
|
31
|
+
export declare function isProviderSupported(provider: string): provider is AIProvider;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Runner Factory
|
|
3
|
+
*
|
|
4
|
+
* Creates the appropriate AIProviderRunner based on provider configuration.
|
|
5
|
+
*/
|
|
6
|
+
import { ClaudeAgentRunner } from './claude-agent-runner.js';
|
|
7
|
+
import { GeminiAgentRunner } from './gemini-agent-runner.js';
|
|
8
|
+
/**
|
|
9
|
+
* Create an AI provider runner for the specified provider
|
|
10
|
+
*
|
|
11
|
+
* @param provider - The AI provider to create a runner for
|
|
12
|
+
* @param logger - Logger instance for structured logging
|
|
13
|
+
* @returns An AIProviderRunner instance for the specified provider
|
|
14
|
+
* @throws Error if the provider is not supported
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const logger = createLogger({ namespace: 'agent-runner' })
|
|
19
|
+
* const runner = createAgentRunner('claude', logger)
|
|
20
|
+
* const result = await runner.runAgent('Hello', { agentType: 'dev' })
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function createAgentRunner(provider, logger) {
|
|
24
|
+
switch (provider) {
|
|
25
|
+
case 'claude': {
|
|
26
|
+
return new ClaudeAgentRunner(logger);
|
|
27
|
+
}
|
|
28
|
+
case 'gemini': {
|
|
29
|
+
return new GeminiAgentRunner(logger);
|
|
30
|
+
}
|
|
31
|
+
default: {
|
|
32
|
+
throw new Error(`Unsupported AI provider: ${provider}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Check if a provider is supported
|
|
38
|
+
*
|
|
39
|
+
* @param provider - The provider to check
|
|
40
|
+
* @returns true if the provider is supported
|
|
41
|
+
*/
|
|
42
|
+
export function isProviderSupported(provider) {
|
|
43
|
+
return provider === 'claude' || provider === 'gemini';
|
|
44
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AIProviderRunner Interface
|
|
3
|
+
*
|
|
4
|
+
* Abstract interface for AI provider runners. Each provider (Claude, Gemini, etc.)
|
|
5
|
+
* implements this interface to provide consistent agent execution across providers.
|
|
6
|
+
*/
|
|
7
|
+
import type pino from 'pino';
|
|
8
|
+
import type { AgentOptions, AgentResult } from '../../models/index.js';
|
|
9
|
+
import type { AIProvider } from '../../models/provider.js';
|
|
10
|
+
/**
|
|
11
|
+
* Interface for AI provider runners
|
|
12
|
+
*/
|
|
13
|
+
export interface AIProviderRunner {
|
|
14
|
+
/**
|
|
15
|
+
* Get the count of active processes
|
|
16
|
+
*
|
|
17
|
+
* @returns Number of currently active child processes
|
|
18
|
+
*/
|
|
19
|
+
getActiveProcessCount(): number;
|
|
20
|
+
/**
|
|
21
|
+
* The provider type this runner handles
|
|
22
|
+
*/
|
|
23
|
+
readonly provider: AIProvider;
|
|
24
|
+
/**
|
|
25
|
+
* Execute an AI agent with the specified prompt and options
|
|
26
|
+
*
|
|
27
|
+
* @param prompt - The prompt to execute with the agent
|
|
28
|
+
* @param options - Agent execution options (without prompt)
|
|
29
|
+
* @returns AgentResult with success status, output, errors, and metadata
|
|
30
|
+
*/
|
|
31
|
+
runAgent(prompt: string, options: Omit<AgentOptions, 'prompt'>): Promise<AgentResult>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Base class with shared functionality for AI provider runners
|
|
35
|
+
*/
|
|
36
|
+
export declare abstract class BaseAgentRunner implements AIProviderRunner {
|
|
37
|
+
protected readonly logger: pino.Logger;
|
|
38
|
+
abstract readonly provider: AIProvider;
|
|
39
|
+
constructor(logger: pino.Logger);
|
|
40
|
+
abstract getActiveProcessCount(): number;
|
|
41
|
+
/**
|
|
42
|
+
* Invoke onResponse callback and return result
|
|
43
|
+
*/
|
|
44
|
+
protected returnWithCallback(result: AgentResult, onResponse?: (result: AgentResult) => Promise<void> | void): Promise<AgentResult>;
|
|
45
|
+
abstract runAgent(prompt: string, options: Omit<AgentOptions, 'prompt'>): Promise<AgentResult>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AIProviderRunner Interface
|
|
3
|
+
*
|
|
4
|
+
* Abstract interface for AI provider runners. Each provider (Claude, Gemini, etc.)
|
|
5
|
+
* implements this interface to provide consistent agent execution across providers.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Base class with shared functionality for AI provider runners
|
|
9
|
+
*/
|
|
10
|
+
export class BaseAgentRunner {
|
|
11
|
+
logger;
|
|
12
|
+
constructor(logger) {
|
|
13
|
+
this.logger = logger;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Invoke onResponse callback and return result
|
|
17
|
+
*/
|
|
18
|
+
async returnWithCallback(result, onResponse) {
|
|
19
|
+
if (onResponse) {
|
|
20
|
+
try {
|
|
21
|
+
await onResponse(result);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
this.logger.warn({ error: error.message }, 'Error in onResponse callback');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
}
|