vibeman 0.0.2 → 0.0.5
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/dist/index.js +3 -3
- package/dist/runtime/api/.tsbuildinfo +1 -1
- package/dist/runtime/api/agent/agent-service.d.ts +11 -6
- package/dist/runtime/api/agent/agent-service.js +97 -29
- package/dist/runtime/api/agent/ai-providers/amp-cli-provider.d.ts +38 -0
- package/dist/runtime/api/agent/ai-providers/amp-cli-provider.js +268 -0
- package/dist/runtime/api/agent/ai-providers/codex-cli-provider.d.ts +2 -0
- package/dist/runtime/api/agent/ai-providers/codex-cli-provider.js +92 -32
- package/dist/runtime/api/agent/ai-providers/gemini-cli-provider.d.ts +24 -0
- package/dist/runtime/api/agent/ai-providers/gemini-cli-provider.js +291 -0
- package/dist/runtime/api/agent/ai-providers/index.d.ts +3 -3
- package/dist/runtime/api/agent/ai-providers/index.js +3 -1
- package/dist/runtime/api/agent/ai-providers/types.d.ts +5 -2
- package/dist/runtime/api/agent/amp-cli-provider.test.js +99 -0
- package/dist/runtime/api/agent/codex-cli-provider.test.js +54 -7
- package/dist/runtime/api/agent/prompt-service.js +108 -105
- package/dist/runtime/api/agent/prompt-service.test.js +35 -0
- package/dist/runtime/api/agent/routing-policy.d.ts +13 -30
- package/dist/runtime/api/agent/routing-policy.js +82 -132
- package/dist/runtime/api/agent/routing-policy.test.js +63 -0
- package/dist/runtime/api/api/routers/ai.d.ts +15 -3
- package/dist/runtime/api/api/routers/ai.js +7 -6
- package/dist/runtime/api/api/routers/executions.d.ts +3 -8
- package/dist/runtime/api/api/routers/executions.js +2 -2
- package/dist/runtime/api/api/routers/provider-config.d.ts +34 -0
- package/dist/runtime/api/api/routers/settings.d.ts +19 -0
- package/dist/runtime/api/api/routers/settings.js +16 -0
- package/dist/runtime/api/api/routers/tasks.d.ts +10 -10
- package/dist/runtime/api/api/routers/workflows.d.ts +20 -12
- package/dist/runtime/api/api/routers/workflows.js +2 -1
- package/dist/runtime/api/api/routers/worktrees.d.ts +2 -2
- package/dist/runtime/api/api/trpc.d.ts +18 -18
- package/dist/runtime/api/lib/local-config.d.ts +94 -4
- package/dist/runtime/api/lib/local-config.js +16 -0
- package/dist/runtime/api/lib/provider-detection.d.ts +2 -0
- package/dist/runtime/api/lib/provider-detection.js +83 -1
- package/dist/runtime/api/lib/server/vibeman-info.d.ts +5 -0
- package/dist/runtime/api/lib/server/vibeman-info.js +85 -0
- package/dist/runtime/api/lib/trpc/server.d.ts +85 -35
- package/dist/runtime/api/persistence/execution-log-persistence.d.ts +1 -1
- package/dist/runtime/api/persistence/execution-log-persistence.js +19 -3
- package/dist/runtime/api/router.d.ts +85 -35
- package/dist/runtime/api/settings-service.js +70 -5
- package/dist/runtime/api/tasks/task-file-parser.d.ts +1 -0
- package/dist/runtime/api/tasks/task-file-parser.js +20 -1
- package/dist/runtime/api/tasks/task-updater.d.ts +62 -0
- package/dist/runtime/api/tasks/task-updater.js +260 -0
- package/dist/runtime/api/tasks/task-updater.test.d.ts +1 -0
- package/dist/runtime/api/tasks/task-updater.test.js +303 -0
- package/dist/runtime/api/types/index.d.ts +9 -2
- package/dist/runtime/api/types/settings.d.ts +29 -5
- package/dist/runtime/api/vcs/git-service.d.ts +9 -0
- package/dist/runtime/api/vcs/git-service.js +23 -0
- package/dist/runtime/api/vcs/worktree-service.d.ts +1 -1
- package/dist/runtime/api/vcs/worktree-service.js +22 -10
- package/dist/runtime/api/workflows/quality-pipeline.js +2 -1
- package/dist/runtime/api/workflows/vibing-orchestrator.d.ts +93 -5
- package/dist/runtime/api/workflows/vibing-orchestrator.js +806 -204
- package/dist/runtime/api/workflows/workflow-effects.d.ts +45 -0
- package/dist/runtime/api/workflows/workflow-effects.js +49 -0
- package/dist/runtime/api/workflows/workflow-reconciler.d.ts +65 -0
- package/dist/runtime/api/workflows/workflow-reconciler.js +226 -0
- package/dist/runtime/api/workflows/workflow-reducer.d.ts +26 -0
- package/dist/runtime/api/workflows/workflow-reducer.js +288 -0
- package/dist/runtime/api/workflows/workflow-reducer.test.d.ts +1 -0
- package/dist/runtime/api/workflows/workflow-reducer.test.js +247 -0
- package/dist/runtime/api/workflows/workflow-schema.d.ts +546 -0
- package/dist/runtime/api/workflows/workflow-schema.js +256 -0
- package/dist/runtime/web/.next/BUILD_ID +1 -1
- package/dist/runtime/web/.next/app-build-manifest.json +51 -44
- package/dist/runtime/web/.next/app-path-routes-manifest.json +2 -1
- package/dist/runtime/web/.next/build-manifest.json +14 -14
- package/dist/runtime/web/.next/prerender-manifest.json +10 -10
- package/dist/runtime/web/.next/react-loadable-manifest.json +2 -33
- package/dist/runtime/web/.next/required-server-files.json +5 -5
- package/dist/runtime/web/.next/routes-manifest.json +8 -0
- package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route.js +1 -0
- package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route.js.nft.json +1 -0
- package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route_client-reference-manifest.js +1 -0
- package/dist/runtime/web/.next/server/app/_not-found/page.js +2 -2
- package/dist/runtime/web/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/dist/runtime/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/runtime/web/.next/server/app/_not-found.html +2 -2
- package/dist/runtime/web/.next/server/app/_not-found.rsc +12 -12
- package/dist/runtime/web/.next/server/app/api/health/route.js +1 -1
- package/dist/runtime/web/.next/server/app/api/health/route.js.nft.json +1 -1
- package/dist/runtime/web/.next/server/app/api/health/route_client-reference-manifest.js +1 -1
- package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js +1 -1
- package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js.nft.json +1 -1
- package/dist/runtime/web/.next/server/app/api/images/[...path]/route_client-reference-manifest.js +1 -1
- package/dist/runtime/web/.next/server/app/api/upload/route.js +1 -1
- package/dist/runtime/web/.next/server/app/api/upload/route.js.nft.json +1 -1
- package/dist/runtime/web/.next/server/app/api/upload/route_client-reference-manifest.js +1 -1
- package/dist/runtime/web/.next/server/app/index.html +2 -2
- package/dist/runtime/web/.next/server/app/index.rsc +15 -15
- package/dist/runtime/web/.next/server/app/page.js +27 -62
- package/dist/runtime/web/.next/server/app/page.js.nft.json +1 -1
- package/dist/runtime/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/runtime/web/.next/server/app-paths-manifest.json +2 -1
- package/dist/runtime/web/.next/server/chunks/210.js +1 -0
- package/dist/runtime/web/.next/server/chunks/291.js +18 -0
- package/dist/runtime/web/.next/server/chunks/552.js +22 -0
- package/dist/runtime/web/.next/server/chunks/780.js +1 -0
- package/dist/runtime/web/.next/server/chunks/905.js +6 -0
- package/dist/runtime/web/.next/server/chunks/98.js +1 -0
- package/dist/runtime/web/.next/server/middleware-build-manifest.js +1 -1
- package/dist/runtime/web/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/dist/runtime/web/.next/server/pages/404.html +2 -2
- package/dist/runtime/web/.next/server/pages/500.html +1 -1
- package/dist/runtime/web/.next/server/pages/_app.js +1 -1
- package/dist/runtime/web/.next/server/pages/_app.js.nft.json +1 -1
- package/dist/runtime/web/.next/server/pages/_document.js +1 -1
- package/dist/runtime/web/.next/server/pages/_document.js.nft.json +1 -1
- package/dist/runtime/web/.next/server/pages/_error.js +9 -9
- package/dist/runtime/web/.next/server/pages/_error.js.nft.json +1 -1
- package/dist/runtime/web/.next/server/pages-manifest.json +1 -1
- package/dist/runtime/web/.next/server/server-reference-manifest.json +1 -1
- package/dist/runtime/web/.next/server/webpack-runtime.js +1 -1
- package/dist/runtime/web/.next/static/LJFZk_8tvKFN_Ee4HqUuM/_buildManifest.js +1 -0
- package/dist/runtime/web/.next/static/chunks/05c91ade-7d09b2b280adffd1.js +1 -0
- package/dist/runtime/web/.next/static/chunks/201-51bef3fa8c832e2e.js +1 -0
- package/dist/runtime/web/.next/static/chunks/524-89747ed9b0294f8a.js +1 -0
- package/dist/runtime/web/.next/static/chunks/554-8bec6e9cca6acc67.js +1 -0
- package/dist/runtime/web/.next/static/chunks/764.86e9503a69d45a85.js +1 -0
- package/dist/runtime/web/.next/static/chunks/{87c73c54-09e1ba5c70e60a51.js → 7ab4dc20-239138e0ae7af24a.js} +1 -1
- package/dist/runtime/web/.next/static/chunks/905-342391e3d3a3678f.js +20 -0
- package/dist/runtime/web/.next/static/chunks/a8a5ce16-4edea7df2d9b544a.js +79 -0
- package/dist/runtime/web/.next/static/chunks/{8bb4d8db-3e2aa02b0a2384b9.js → ad74d572-4c1b162e2c15acaa.js} +1 -1
- package/dist/runtime/web/.next/static/chunks/app/.vibeman/assets/images/[...path]/route-7b752a8641f96c1f.js +1 -0
- package/dist/runtime/web/.next/static/chunks/app/_not-found/page-34e66b251c2b5044.js +1 -0
- package/dist/runtime/web/.next/static/chunks/app/api/health/route-7b752a8641f96c1f.js +1 -0
- package/dist/runtime/web/.next/static/chunks/app/api/images/[...path]/route-7b752a8641f96c1f.js +1 -0
- package/dist/runtime/web/.next/static/chunks/app/api/upload/route-7b752a8641f96c1f.js +1 -0
- package/dist/runtime/web/.next/static/chunks/app/layout-df9ac93cb02b2385.js +1 -0
- package/dist/runtime/web/.next/static/chunks/app/page-6610743f7de5f92a.js +1 -0
- package/dist/runtime/web/.next/static/chunks/c25e0690-e9b798b8de667da1.js +1 -0
- package/dist/runtime/web/.next/static/chunks/framework-57157ec4d37f64aa.js +1 -0
- package/dist/runtime/web/.next/static/chunks/main-app-156cc0c60371bd78.js +1 -0
- package/dist/runtime/web/.next/static/chunks/main-df25d367c47b1fec.js +1 -0
- package/dist/runtime/web/.next/static/chunks/pages/_app-9f629a5e1131d19f.js +1 -0
- package/dist/runtime/web/.next/static/chunks/pages/_error-9238238274c7efcd.js +1 -0
- package/dist/runtime/web/.next/static/chunks/webpack-cd50e39b423d1808.js +1 -0
- package/dist/runtime/web/.next/static/css/4fbf378a264bd4ea.css +1 -0
- package/dist/runtime/web/package.json +8 -8
- package/dist/runtime/web/server.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -37
- package/dist/runtime/api/lib/image-paste-drop-extension.d.ts +0 -26
- package/dist/runtime/api/lib/image-paste-drop-extension.js +0 -125
- package/dist/runtime/api/lib/markdown-utils.d.ts +0 -8
- package/dist/runtime/api/lib/markdown-utils.js +0 -282
- package/dist/runtime/api/lib/markdown-utils.test.js +0 -348
- package/dist/runtime/api/lib/tiptap-utils.clamp-selection.test.js +0 -27
- package/dist/runtime/api/lib/tiptap-utils.d.ts +0 -130
- package/dist/runtime/api/lib/tiptap-utils.js +0 -327
- package/dist/runtime/api/lib/trpc/client.d.ts +0 -1
- package/dist/runtime/api/lib/trpc/client.js +0 -5
- package/dist/runtime/web/.next/server/chunks/217.js +0 -1
- package/dist/runtime/web/.next/server/chunks/383.js +0 -6
- package/dist/runtime/web/.next/server/chunks/458.js +0 -1
- package/dist/runtime/web/.next/server/chunks/576.js +0 -18
- package/dist/runtime/web/.next/server/chunks/635.js +0 -22
- package/dist/runtime/web/.next/server/chunks/761.js +0 -1
- package/dist/runtime/web/.next/server/chunks/777.js +0 -3
- package/dist/runtime/web/.next/server/chunks/825.js +0 -1
- package/dist/runtime/web/.next/server/chunks/838.js +0 -1
- package/dist/runtime/web/.next/server/chunks/973.js +0 -15
- package/dist/runtime/web/.next/static/chunks/18-15c10d3288afef2e.js +0 -1
- package/dist/runtime/web/.next/static/chunks/1c0ca389.537bbe362e3ffbd9.js +0 -3
- package/dist/runtime/web/.next/static/chunks/22747d63-ad5da0c19f4cfe41.js +0 -71
- package/dist/runtime/web/.next/static/chunks/277-0142a939f08738c3.js +0 -63
- package/dist/runtime/web/.next/static/chunks/355.056c2645878a799a.js +0 -1
- package/dist/runtime/web/.next/static/chunks/420.a5ccf151c9e2b2f1.js +0 -1
- package/dist/runtime/web/.next/static/chunks/439.1be0c6242fd248d5.js +0 -15
- package/dist/runtime/web/.next/static/chunks/440.c52e7c0f797e22b2.js +0 -1
- package/dist/runtime/web/.next/static/chunks/575-e2478287c27da87b.js +0 -1
- package/dist/runtime/web/.next/static/chunks/691.920d88c115087314.js +0 -1
- package/dist/runtime/web/.next/static/chunks/765-e838910065b50c3d.js +0 -1
- package/dist/runtime/web/.next/static/chunks/891cff7f.0f71fc028f87e683.js +0 -1
- package/dist/runtime/web/.next/static/chunks/9af238c7-271a911d4e99ab18.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/_not-found/page-1cb74d1cba27d0ab.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/api/health/route-105a61ae865ba536.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/api/images/[...path]/route-105a61ae865ba536.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/api/upload/route-105a61ae865ba536.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/layout-8435322f09fd0975.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/page-8c3ba579efc6f918.js +0 -1
- package/dist/runtime/web/.next/static/chunks/cac567b0-5b77dd12911823cd.js +0 -1
- package/dist/runtime/web/.next/static/chunks/framework-2518f1345b5b2806.js +0 -1
- package/dist/runtime/web/.next/static/chunks/main-17665e5e39de9a8a.js +0 -1
- package/dist/runtime/web/.next/static/chunks/main-app-c0b0f5ba4f7f9d75.js +0 -1
- package/dist/runtime/web/.next/static/chunks/pages/_app-d6f6b3bbc3d81ee1.js +0 -1
- package/dist/runtime/web/.next/static/chunks/pages/_error-75a96cf1997cc3b9.js +0 -1
- package/dist/runtime/web/.next/static/chunks/webpack-c8de37305b4635cf.js +0 -1
- package/dist/runtime/web/.next/static/css/08c950681f1a9a92.css +0 -1
- package/dist/runtime/web/.next/static/mRpNgPfbYR_0wrODzlg_4/_buildManifest.js +0 -1
- /package/dist/runtime/api/{lib/markdown-utils.test.d.ts → agent/amp-cli-provider.test.d.ts} +0 -0
- /package/dist/runtime/api/{lib/tiptap-utils.clamp-selection.test.d.ts → agent/routing-policy.test.d.ts} +0 -0
- /package/dist/runtime/web/.next/static/{mRpNgPfbYR_0wrODzlg_4 → LJFZk_8tvKFN_Ee4HqUuM}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { reduce, computeNextAction, createInitialState } from './workflow-reducer.js';
|
|
3
|
+
const defaultConfig = {
|
|
4
|
+
autoQualityChecks: true,
|
|
5
|
+
requireHumanApproval: true,
|
|
6
|
+
aiCodeReview: true,
|
|
7
|
+
stepByStepMode: false,
|
|
8
|
+
autoCommit: false,
|
|
9
|
+
retryPolicy: { maxImplementationAttempts: 3 },
|
|
10
|
+
};
|
|
11
|
+
function createTestState(overrides = {}) {
|
|
12
|
+
const base = createInitialState('wf-test-1', 'task-test-1', defaultConfig);
|
|
13
|
+
return { ...base, ...overrides, config: { ...base.config, ...overrides.config } };
|
|
14
|
+
}
|
|
15
|
+
describe('workflow-reducer', () => {
|
|
16
|
+
describe('reduce()', () => {
|
|
17
|
+
describe('START event', () => {
|
|
18
|
+
it('transitions from draft to implementing', () => {
|
|
19
|
+
const state = createTestState({ phase: 'draft' });
|
|
20
|
+
const event = { type: 'START' };
|
|
21
|
+
const result = reduce(state, event);
|
|
22
|
+
expect(result.state.phase).toBe('implementing');
|
|
23
|
+
expect(result.effects).toContainEqual({ type: 'EXECUTE_IMPLEMENTATION' });
|
|
24
|
+
expect(result.effects).toContainEqual({ type: 'SAVE_WORKFLOW' });
|
|
25
|
+
});
|
|
26
|
+
it('does nothing if already implementing', () => {
|
|
27
|
+
const state = createTestState({ phase: 'implementing' });
|
|
28
|
+
const event = { type: 'START' };
|
|
29
|
+
const result = reduce(state, event);
|
|
30
|
+
expect(result.state.phase).toBe('implementing');
|
|
31
|
+
expect(result.effects).toHaveLength(0);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
describe('IMPL_SUCCESS event', () => {
|
|
35
|
+
it('transitions from implementing to validating', () => {
|
|
36
|
+
const state = createTestState({ phase: 'implementing' });
|
|
37
|
+
const event = { type: 'IMPL_SUCCESS', executionId: 'exec-1' };
|
|
38
|
+
const result = reduce(state, event);
|
|
39
|
+
expect(result.state.phase).toBe('validating');
|
|
40
|
+
expect(result.state.executionIds.implementing).toContain('exec-1');
|
|
41
|
+
});
|
|
42
|
+
it('triggers validation in non-step-by-step mode', () => {
|
|
43
|
+
const state = createTestState({ phase: 'implementing' });
|
|
44
|
+
const event = { type: 'IMPL_SUCCESS' };
|
|
45
|
+
const result = reduce(state, event);
|
|
46
|
+
expect(result.effects).toContainEqual({ type: 'EXECUTE_VALIDATION' });
|
|
47
|
+
});
|
|
48
|
+
it('does not trigger validation in step-by-step mode', () => {
|
|
49
|
+
const state = createTestState({
|
|
50
|
+
phase: 'implementing',
|
|
51
|
+
config: { ...defaultConfig, stepByStepMode: true },
|
|
52
|
+
});
|
|
53
|
+
const event = { type: 'IMPL_SUCCESS' };
|
|
54
|
+
const result = reduce(state, event);
|
|
55
|
+
expect(result.effects).not.toContainEqual({ type: 'EXECUTE_VALIDATION' });
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
describe('IMPL_FAIL event', () => {
|
|
59
|
+
it('retries if under max attempts', () => {
|
|
60
|
+
const state = createTestState({
|
|
61
|
+
phase: 'implementing',
|
|
62
|
+
attempts: { implementing: 0 },
|
|
63
|
+
});
|
|
64
|
+
const event = { type: 'IMPL_FAIL', error: 'Test error', canRetry: true };
|
|
65
|
+
const result = reduce(state, event);
|
|
66
|
+
expect(result.state.phase).toBe('implementing');
|
|
67
|
+
expect(result.state.attempts.implementing).toBe(1);
|
|
68
|
+
expect(result.state.rerunContext?.reason).toBe('Test error');
|
|
69
|
+
});
|
|
70
|
+
it('fails if max attempts exceeded', () => {
|
|
71
|
+
const state = createTestState({
|
|
72
|
+
phase: 'implementing',
|
|
73
|
+
attempts: { implementing: 2 },
|
|
74
|
+
});
|
|
75
|
+
const event = { type: 'IMPL_FAIL', error: 'Test error', canRetry: true };
|
|
76
|
+
const result = reduce(state, event);
|
|
77
|
+
expect(result.state.terminalStatus).toBe('failed');
|
|
78
|
+
expect(result.state.error).toBe('Test error');
|
|
79
|
+
});
|
|
80
|
+
it('fails immediately if canRetry is false', () => {
|
|
81
|
+
const state = createTestState({
|
|
82
|
+
phase: 'implementing',
|
|
83
|
+
attempts: { implementing: 0 },
|
|
84
|
+
});
|
|
85
|
+
const event = { type: 'IMPL_FAIL', error: 'Test error', canRetry: false };
|
|
86
|
+
const result = reduce(state, event);
|
|
87
|
+
expect(result.state.terminalStatus).toBe('failed');
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
describe('VALID_SUCCESS event', () => {
|
|
91
|
+
it('transitions to approved when AI review is enabled', () => {
|
|
92
|
+
const state = createTestState({
|
|
93
|
+
phase: 'validating',
|
|
94
|
+
config: { ...defaultConfig, aiCodeReview: true },
|
|
95
|
+
});
|
|
96
|
+
const event = {
|
|
97
|
+
type: 'VALID_SUCCESS',
|
|
98
|
+
results: { overall: true, timestamp: new Date().toISOString(), details: {}, outputs: {} },
|
|
99
|
+
};
|
|
100
|
+
const result = reduce(state, event);
|
|
101
|
+
expect(result.state.phase).toBe('approved');
|
|
102
|
+
expect(result.state.qualityResults?.overall).toBe(true);
|
|
103
|
+
});
|
|
104
|
+
it('transitions to merging when no approval needed', () => {
|
|
105
|
+
const state = createTestState({
|
|
106
|
+
phase: 'validating',
|
|
107
|
+
config: { ...defaultConfig, aiCodeReview: false, requireHumanApproval: false },
|
|
108
|
+
});
|
|
109
|
+
const event = {
|
|
110
|
+
type: 'VALID_SUCCESS',
|
|
111
|
+
results: { overall: true, timestamp: new Date().toISOString(), details: {}, outputs: {} },
|
|
112
|
+
};
|
|
113
|
+
const result = reduce(state, event);
|
|
114
|
+
expect(result.state.phase).toBe('merging');
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
describe('PAUSE event', () => {
|
|
118
|
+
it('sets terminal status to paused from any active phase', () => {
|
|
119
|
+
const state = createTestState({ phase: 'implementing' });
|
|
120
|
+
const event = { type: 'PAUSE' };
|
|
121
|
+
const result = reduce(state, event);
|
|
122
|
+
expect(result.state.terminalStatus).toBe('paused');
|
|
123
|
+
expect(result.effects).toContainEqual({ type: 'STOP_EXECUTION' });
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
describe('RESUME event', () => {
|
|
127
|
+
it('clears terminal status and restores phase', () => {
|
|
128
|
+
const state = createTestState({
|
|
129
|
+
phase: 'implementing',
|
|
130
|
+
terminalStatus: 'paused',
|
|
131
|
+
});
|
|
132
|
+
const event = { type: 'RESUME' };
|
|
133
|
+
const result = reduce(state, event);
|
|
134
|
+
expect(result.state.terminalStatus).toBeNull();
|
|
135
|
+
expect(result.state.phase).toBe('implementing');
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
describe('APPROVE event', () => {
|
|
139
|
+
it('transitions from approved to merging', () => {
|
|
140
|
+
const state = createTestState({ phase: 'approved' });
|
|
141
|
+
const event = { type: 'APPROVE' };
|
|
142
|
+
const result = reduce(state, event);
|
|
143
|
+
expect(result.state.phase).toBe('merging');
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
describe('REJECT event', () => {
|
|
147
|
+
it('transitions from approved back to implementing', () => {
|
|
148
|
+
const state = createTestState({ phase: 'approved' });
|
|
149
|
+
const event = { type: 'REJECT', feedback: 'Please fix X' };
|
|
150
|
+
const result = reduce(state, event);
|
|
151
|
+
expect(result.state.phase).toBe('implementing');
|
|
152
|
+
expect(result.state.rerunContext?.feedback).toBe('Please fix X');
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
describe('MERGE_SUCCESS event', () => {
|
|
156
|
+
it('transitions from merging to done', () => {
|
|
157
|
+
const state = createTestState({ phase: 'merging' });
|
|
158
|
+
const event = {
|
|
159
|
+
type: 'MERGE_SUCCESS',
|
|
160
|
+
prUrl: 'https://github.com/pr/1',
|
|
161
|
+
prNumber: 1,
|
|
162
|
+
};
|
|
163
|
+
const result = reduce(state, event);
|
|
164
|
+
expect(result.state.phase).toBe('done');
|
|
165
|
+
expect(result.state.links.prUrl).toBe('https://github.com/pr/1');
|
|
166
|
+
expect(result.state.links.prNumber).toBe(1);
|
|
167
|
+
expect(result.state.endTime).toBeDefined();
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
describe('RETRY event', () => {
|
|
171
|
+
it('returns to implementing from failed state', () => {
|
|
172
|
+
const state = createTestState({
|
|
173
|
+
phase: 'implementing',
|
|
174
|
+
terminalStatus: 'failed',
|
|
175
|
+
});
|
|
176
|
+
const event = { type: 'RETRY' };
|
|
177
|
+
const result = reduce(state, event);
|
|
178
|
+
expect(result.state.phase).toBe('implementing');
|
|
179
|
+
expect(result.state.terminalStatus).toBeNull();
|
|
180
|
+
expect(result.effects).toContainEqual({ type: 'EXECUTE_IMPLEMENTATION' });
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
describe('computeNextAction()', () => {
|
|
185
|
+
it('returns implementing for draft phase', () => {
|
|
186
|
+
const state = createTestState({ phase: 'draft' });
|
|
187
|
+
const action = computeNextAction(state);
|
|
188
|
+
expect(action).toEqual({ action: 'implementing' });
|
|
189
|
+
});
|
|
190
|
+
it('returns validating for validating phase', () => {
|
|
191
|
+
const state = createTestState({ phase: 'validating' });
|
|
192
|
+
const action = computeNextAction(state);
|
|
193
|
+
expect(action).toEqual({ action: 'validating' });
|
|
194
|
+
});
|
|
195
|
+
it('returns ai-reviewing for approved phase with aiCodeReview enabled and no result', () => {
|
|
196
|
+
const state = createTestState({
|
|
197
|
+
phase: 'approved',
|
|
198
|
+
config: { ...defaultConfig, aiCodeReview: true },
|
|
199
|
+
});
|
|
200
|
+
const action = computeNextAction(state);
|
|
201
|
+
expect(action).toEqual({ action: 'ai-reviewing' });
|
|
202
|
+
});
|
|
203
|
+
it('returns awaiting-approval for approved phase with humanApproval required', () => {
|
|
204
|
+
const state = createTestState({
|
|
205
|
+
phase: 'approved',
|
|
206
|
+
config: { ...defaultConfig, aiCodeReview: false, requireHumanApproval: true },
|
|
207
|
+
});
|
|
208
|
+
const action = computeNextAction(state);
|
|
209
|
+
expect(action).toEqual({ action: 'awaiting-approval' });
|
|
210
|
+
});
|
|
211
|
+
it('returns merging for approved phase without approval requirements', () => {
|
|
212
|
+
const state = createTestState({
|
|
213
|
+
phase: 'approved',
|
|
214
|
+
config: { ...defaultConfig, aiCodeReview: false, requireHumanApproval: false },
|
|
215
|
+
});
|
|
216
|
+
const action = computeNextAction(state);
|
|
217
|
+
expect(action).toEqual({ action: 'merging' });
|
|
218
|
+
});
|
|
219
|
+
it('returns none for done phase', () => {
|
|
220
|
+
const state = createTestState({ phase: 'done' });
|
|
221
|
+
const action = computeNextAction(state);
|
|
222
|
+
expect(action).toEqual({ action: 'none', reason: 'Workflow completed' });
|
|
223
|
+
});
|
|
224
|
+
it('returns implementing with feedback for paused state', () => {
|
|
225
|
+
const state = createTestState({
|
|
226
|
+
phase: 'implementing',
|
|
227
|
+
terminalStatus: 'paused',
|
|
228
|
+
rerunContext: { reason: 'test', feedback: 'Fix the bug' },
|
|
229
|
+
});
|
|
230
|
+
const action = computeNextAction(state);
|
|
231
|
+
expect(action).toEqual({ action: 'implementing', feedback: 'Fix the bug' });
|
|
232
|
+
});
|
|
233
|
+
it('returns implementing with error for failed state', () => {
|
|
234
|
+
const state = createTestState({
|
|
235
|
+
phase: 'implementing',
|
|
236
|
+
terminalStatus: 'failed',
|
|
237
|
+
failureContext: {
|
|
238
|
+
atPhase: 'implementing',
|
|
239
|
+
error: 'Build failed',
|
|
240
|
+
timestamp: new Date().toISOString(),
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
const action = computeNextAction(state);
|
|
244
|
+
expect(action).toEqual({ action: 'implementing', feedback: 'Build failed' });
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
});
|