@auto-engineer/server-implementer 0.4.4 → 0.4.6
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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-format.log +16 -13
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +1 -1
- package/.turbo/turbo-type-check.log +1 -1
- package/dist/cli/implement-server.d.ts +3 -0
- package/dist/cli/implement-server.d.ts.map +1 -0
- package/dist/cli/implement-server.js +39 -0
- package/dist/cli/implement-server.js.map +1 -0
- package/dist/commands/implement-server.d.ts +16 -0
- package/dist/commands/implement-server.d.ts.map +1 -0
- package/dist/commands/implement-server.js +91 -0
- package/dist/commands/implement-server.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +7 -1
- package/src/cli/implement-server.ts +46 -0
- package/src/commands/implement-server.ts +130 -0
- package/src/index.ts +7 -0
package/.turbo/turbo-build.log
CHANGED
package/.turbo/turbo-format.log
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @auto-engineer/server-implementer@0.4.
|
|
3
|
+
> @auto-engineer/server-implementer@0.4.6 format /Users/sam/WebstormProjects/top/auto-engineer/packages/server-implementer
|
|
4
4
|
> prettier --write "**/*.{js,ts,json,md,yml,yaml}" --ignore-path ../../.prettierignore
|
|
5
5
|
|
|
6
|
-
CHANGELOG.md[2K[1G[90mCHANGELOG.md[39m
|
|
7
|
-
DEBUG.md[2K[1G[90mDEBUG.md[39m
|
|
8
|
-
package.json[2K[1G[90mpackage.json[39m
|
|
9
|
-
src/agent/runAllSlices.js[2K[1G[90msrc/agent/runAllSlices.js[39m
|
|
10
|
-
src/agent/runAllSlices.ts[2K[1G[90msrc/agent/runAllSlices.ts[39m
|
|
11
|
-
src/agent/runFlows.js[2K[1G[90msrc/agent/runFlows.js[39m
|
|
12
|
-
src/agent/runFlows.ts[2K[1G[90msrc/agent/runFlows.ts[39m
|
|
13
|
-
src/agent/runSlice.js[2K[1G[90msrc/agent/runSlice.js[39m
|
|
14
|
-
src/agent/runSlice.ts[2K[1G[90msrc/agent/runSlice.ts[39m
|
|
15
|
-
src/agent/runTests.js[2K[1G[90msrc/agent/runTests.js[39m
|
|
16
|
-
src/agent/runTests.ts[2K[1G[90msrc/agent/runTests.ts[39m
|
|
6
|
+
CHANGELOG.md[2K[1G[90mCHANGELOG.md[39m 20ms (unchanged)
|
|
7
|
+
DEBUG.md[2K[1G[90mDEBUG.md[39m 3ms (unchanged)
|
|
8
|
+
package.json[2K[1G[90mpackage.json[39m 14ms (unchanged)
|
|
9
|
+
src/agent/runAllSlices.js[2K[1G[90msrc/agent/runAllSlices.js[39m 10ms (unchanged)
|
|
10
|
+
src/agent/runAllSlices.ts[2K[1G[90msrc/agent/runAllSlices.ts[39m 23ms (unchanged)
|
|
11
|
+
src/agent/runFlows.js[2K[1G[90msrc/agent/runFlows.js[39m 3ms (unchanged)
|
|
12
|
+
src/agent/runFlows.ts[2K[1G[90msrc/agent/runFlows.ts[39m 6ms (unchanged)
|
|
13
|
+
src/agent/runSlice.js[2K[1G[90msrc/agent/runSlice.js[39m 20ms (unchanged)
|
|
14
|
+
src/agent/runSlice.ts[2K[1G[90msrc/agent/runSlice.ts[39m 24ms (unchanged)
|
|
15
|
+
src/agent/runTests.js[2K[1G[90msrc/agent/runTests.js[39m 5ms (unchanged)
|
|
16
|
+
src/agent/runTests.ts[2K[1G[90msrc/agent/runTests.ts[39m 7ms (unchanged)
|
|
17
|
+
src/cli/implement-server.ts[2K[1G[90msrc/cli/implement-server.ts[39m 2ms (unchanged)
|
|
17
18
|
src/cli/index.js[2K[1G[90msrc/cli/index.js[39m 1ms (unchanged)
|
|
18
19
|
src/cli/index.ts[2K[1G[90msrc/cli/index.ts[39m 2ms (unchanged)
|
|
19
|
-
src/
|
|
20
|
+
src/commands/implement-server.ts[2K[1G[90msrc/commands/implement-server.ts[39m 5ms (unchanged)
|
|
21
|
+
src/index.ts[2K[1G[90msrc/index.ts[39m 1ms (unchanged)
|
|
22
|
+
src/prompts/systemPrompt.js[2K[1G[90msrc/prompts/systemPrompt.js[39m 1ms (unchanged)
|
|
20
23
|
src/prompts/systemPrompt.ts[2K[1G[90msrc/prompts/systemPrompt.ts[39m 1ms (unchanged)
|
|
21
24
|
src/utils/extractCodeBlock.js[2K[1G[90msrc/utils/extractCodeBlock.js[39m 1ms (unchanged)
|
|
22
25
|
src/utils/extractCodeBlock.ts[2K[1G[90msrc/utils/extractCodeBlock.ts[39m 1ms (unchanged)
|
package/.turbo/turbo-lint.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @auto-engineer/server-implementer@0.4.
|
|
3
|
+
> @auto-engineer/server-implementer@0.4.6 lint /Users/sam/WebstormProjects/top/auto-engineer/packages/server-implementer
|
|
4
4
|
> eslint 'src/**/*.ts' --max-warnings 0 --config ../../eslint.config.ts
|
|
5
5
|
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @auto-engineer/server-implementer@0.4.
|
|
3
|
+
> @auto-engineer/server-implementer@0.4.6 test /Users/sam/WebstormProjects/top/auto-engineer/packages/server-implementer
|
|
4
4
|
> vitest run
|
|
5
5
|
|
|
6
6
|
[?25l
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @auto-engineer/server-implementer@0.4.
|
|
3
|
+
> @auto-engineer/server-implementer@0.4.6 type-check /Users/sam/WebstormProjects/top/auto-engineer/packages/server-implementer
|
|
4
4
|
> tsc --noEmit
|
|
5
5
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implement-server.d.ts","sourceRoot":"","sources":["../../src/cli/implement-server.ts"],"names":[],"mappings":";AACA,OAAO,eAAe,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import 'dotenv/config';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { implementServerCommandHandler } from '../commands/implement-server';
|
|
5
|
+
import createDebug from 'debug';
|
|
6
|
+
const debug = createDebug('server-impl:cli:implement');
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const isMain = process.argv[1] === __filename;
|
|
9
|
+
if (isMain) {
|
|
10
|
+
debug('CLI started with args: %o', process.argv.slice(2));
|
|
11
|
+
const serverDirectory = process.argv[2];
|
|
12
|
+
if (!serverDirectory) {
|
|
13
|
+
debug('ERROR: No server directory provided');
|
|
14
|
+
console.error('Usage: implement:server <server-directory>');
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
debug('Server directory argument: %s', serverDirectory);
|
|
18
|
+
// Create command and execute handler
|
|
19
|
+
const command = {
|
|
20
|
+
type: 'ImplementServer',
|
|
21
|
+
data: {
|
|
22
|
+
serverDirectory,
|
|
23
|
+
},
|
|
24
|
+
timestamp: new Date(),
|
|
25
|
+
requestId: `cli-${Date.now()}`,
|
|
26
|
+
};
|
|
27
|
+
debug('Executing command handler');
|
|
28
|
+
void implementServerCommandHandler
|
|
29
|
+
.handle(command)
|
|
30
|
+
.then(() => {
|
|
31
|
+
debug('Command completed successfully');
|
|
32
|
+
})
|
|
33
|
+
.catch((error) => {
|
|
34
|
+
debug('Command failed: %O', error);
|
|
35
|
+
console.error('Failed to execute command:', error);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=implement-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implement-server.js","sourceRoot":"","sources":["../../src/cli/implement-server.ts"],"names":[],"mappings":";AACA,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM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KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;QACnD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { type CommandHandler, type Command, type Event } from '@auto-engineer/message-bus';
|
|
3
|
+
export type ImplementServerCommand = Command<'ImplementServer', {
|
|
4
|
+
serverDirectory: string;
|
|
5
|
+
}>;
|
|
6
|
+
export type ServerImplementedEvent = Event<'ServerImplemented', {
|
|
7
|
+
serverDirectory: string;
|
|
8
|
+
flowsImplemented: number;
|
|
9
|
+
}>;
|
|
10
|
+
export type ServerImplementationFailedEvent = Event<'ServerImplementationFailed', {
|
|
11
|
+
serverDirectory: string;
|
|
12
|
+
error: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare function handleImplementServerCommand(command: ImplementServerCommand): Promise<ServerImplementedEvent | ServerImplementationFailedEvent>;
|
|
15
|
+
export declare const implementServerCommandHandler: CommandHandler<ImplementServerCommand>;
|
|
16
|
+
//# sourceMappingURL=implement-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implement-server.d.ts","sourceRoot":"","sources":["../../src/commands/implement-server.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAW3F,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAC1C,iBAAiB,EACjB;IACE,eAAe,EAAE,MAAM,CAAC;CACzB,CACF,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,KAAK,CACxC,mBAAmB,EACnB;IACE,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CACF,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG,KAAK,CACjD,4BAA4B,EAC5B;IACE,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf,CACF,CAAC;AAEF,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,sBAAsB,GAAG,+BAA+B,CAAC,CAwEnE;AAED,eAAO,MAAM,6BAA6B,EAAE,cAAc,CAAC,sBAAsB,CAkBhF,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { existsSync } from 'fs';
|
|
4
|
+
import { runFlows } from '../agent/runFlows';
|
|
5
|
+
import createDebug from 'debug';
|
|
6
|
+
const debug = createDebug('server-impl:command');
|
|
7
|
+
const debugHandler = createDebug('server-impl:command:handler');
|
|
8
|
+
const debugProcess = createDebug('server-impl:command:process');
|
|
9
|
+
const debugResult = createDebug('server-impl:command:result');
|
|
10
|
+
export async function handleImplementServerCommand(command) {
|
|
11
|
+
const { serverDirectory } = command.data;
|
|
12
|
+
debug('Handling ImplementServerCommand');
|
|
13
|
+
debug(' Server directory: %s', serverDirectory);
|
|
14
|
+
debug(' Request ID: %s', command.requestId);
|
|
15
|
+
debug(' Correlation ID: %s', command.correlationId ?? 'none');
|
|
16
|
+
try {
|
|
17
|
+
const serverRoot = path.resolve(serverDirectory);
|
|
18
|
+
const flowsDir = path.join(serverRoot, 'src', 'domain', 'flows');
|
|
19
|
+
debugHandler('Resolved paths:');
|
|
20
|
+
debugHandler(' Server root: %s', serverRoot);
|
|
21
|
+
debugHandler(' Flows directory: %s', flowsDir);
|
|
22
|
+
if (!existsSync(flowsDir)) {
|
|
23
|
+
debugHandler('ERROR: Flows directory not found at %s', flowsDir);
|
|
24
|
+
return {
|
|
25
|
+
type: 'ServerImplementationFailed',
|
|
26
|
+
data: {
|
|
27
|
+
serverDirectory,
|
|
28
|
+
error: `Flows directory not found at: ${flowsDir}`,
|
|
29
|
+
},
|
|
30
|
+
timestamp: new Date(),
|
|
31
|
+
requestId: command.requestId,
|
|
32
|
+
correlationId: command.correlationId,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
debugProcess('Starting flow runner for directory: %s', flowsDir);
|
|
36
|
+
// Run the flows directly without spawning
|
|
37
|
+
await runFlows(flowsDir);
|
|
38
|
+
debugProcess('Flow runner completed successfully');
|
|
39
|
+
// For now, we don't have a way to count flows, so we'll use 0
|
|
40
|
+
// This could be enhanced by having runFlows return statistics
|
|
41
|
+
const flowsImplemented = 0;
|
|
42
|
+
debugResult('Process succeeded');
|
|
43
|
+
debugResult('Flows implemented: %d', flowsImplemented);
|
|
44
|
+
const successEvent = {
|
|
45
|
+
type: 'ServerImplemented',
|
|
46
|
+
data: {
|
|
47
|
+
serverDirectory,
|
|
48
|
+
flowsImplemented,
|
|
49
|
+
},
|
|
50
|
+
timestamp: new Date(),
|
|
51
|
+
requestId: command.requestId,
|
|
52
|
+
correlationId: command.correlationId,
|
|
53
|
+
};
|
|
54
|
+
debugResult('Returning success event: ServerImplemented');
|
|
55
|
+
return successEvent;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
debug('ERROR: Exception caught: %O', error);
|
|
59
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
60
|
+
return {
|
|
61
|
+
type: 'ServerImplementationFailed',
|
|
62
|
+
data: {
|
|
63
|
+
serverDirectory,
|
|
64
|
+
error: errorMessage,
|
|
65
|
+
},
|
|
66
|
+
timestamp: new Date(),
|
|
67
|
+
requestId: command.requestId,
|
|
68
|
+
correlationId: command.correlationId,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export const implementServerCommandHandler = {
|
|
73
|
+
name: 'ImplementServer',
|
|
74
|
+
handle: async (command) => {
|
|
75
|
+
debug('CommandHandler executing for ImplementServer');
|
|
76
|
+
const result = await handleImplementServerCommand(command);
|
|
77
|
+
if (result.type === 'ServerImplemented') {
|
|
78
|
+
debug('Command handler completed: success');
|
|
79
|
+
console.log(`✅ Server implementation completed successfully`);
|
|
80
|
+
if (result.data.flowsImplemented > 0) {
|
|
81
|
+
console.log(` ${result.data.flowsImplemented} flows implemented`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
debug('Command handler completed: failure - %s', result.data.error);
|
|
86
|
+
console.error(`❌ Server implementation failed: ${result.data.error}`);
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=implement-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implement-server.js","sourceRoot":"","sources":["../../src/commands/implement-server.ts"],"names":[],"mappings":";AAEA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,WAAW,MAAM,OAAO,CAAC;AAEhC,MAAM,KAAK,GAAG,WAAW,CAAC,qBAAqB,CAAC,CAAC;AACjD,MAAM,YAAY,GAAG,WAAW,CAAC,6BAA6B,CAAC,CAAC;AAChE,MAAM,YAAY,GAAG,WAAW,CAAC,6BAA6B,CAAC,CAAC;AAChE,MAAM,WAAW,GAAG,WAAW,CAAC,4BAA4B,CAAC,CAAC;AAyB9D,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,OAA+B;IAE/B,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAEzC,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACzC,KAAK,CAAC,wBAAwB,EAAE,eAAe,CAAC,CAAC;IACjD,KAAK,CAAC,kBAAkB,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC7C,KAAK,CAAC,sBAAsB,EAAE,OAAO,CAAC,aAAa,IAAI,MAAM,CAAC,CAAC;IAE/D,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,IA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,CAAC;QAClB,CAAC;IACH,CAAC;CACF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,+BAA+B,GACrC,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,GAI7B,MAAM,6BAA6B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auto-engineer/server-implementer",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"implement-server": "./dist/cli/implement-server.js"
|
|
9
|
+
},
|
|
7
10
|
"publishConfig": {
|
|
8
11
|
"access": "public"
|
|
9
12
|
},
|
|
10
13
|
"dependencies": {
|
|
11
14
|
"@auto-engineer/ai-gateway": "^0.4.5",
|
|
15
|
+
"@auto-engineer/message-bus": "^0.3.4",
|
|
12
16
|
"@modelcontextprotocol/sdk": "^1.3.0",
|
|
17
|
+
"debug": "^4.3.4",
|
|
13
18
|
"fast-glob": "^3.3.3",
|
|
14
19
|
"vite": "^5.4.1"
|
|
15
20
|
},
|
|
@@ -25,6 +30,7 @@
|
|
|
25
30
|
},
|
|
26
31
|
"scripts": {
|
|
27
32
|
"implement": "tsx src/cli/index.ts",
|
|
33
|
+
"implement:server": "tsx src/cli/implement-server.ts",
|
|
28
34
|
"build": "tsc",
|
|
29
35
|
"dev": "tsc --watch",
|
|
30
36
|
"test": "vitest run",
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import 'dotenv/config';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { implementServerCommandHandler } from '../commands/implement-server';
|
|
5
|
+
import createDebug from 'debug';
|
|
6
|
+
|
|
7
|
+
const debug = createDebug('server-impl:cli:implement');
|
|
8
|
+
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
|
|
11
|
+
const isMain = process.argv[1] === __filename;
|
|
12
|
+
|
|
13
|
+
if (isMain) {
|
|
14
|
+
debug('CLI started with args: %o', process.argv.slice(2));
|
|
15
|
+
|
|
16
|
+
const serverDirectory = process.argv[2];
|
|
17
|
+
if (!serverDirectory) {
|
|
18
|
+
debug('ERROR: No server directory provided');
|
|
19
|
+
console.error('Usage: implement:server <server-directory>');
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
debug('Server directory argument: %s', serverDirectory);
|
|
24
|
+
|
|
25
|
+
// Create command and execute handler
|
|
26
|
+
const command = {
|
|
27
|
+
type: 'ImplementServer' as const,
|
|
28
|
+
data: {
|
|
29
|
+
serverDirectory,
|
|
30
|
+
},
|
|
31
|
+
timestamp: new Date(),
|
|
32
|
+
requestId: `cli-${Date.now()}`,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
debug('Executing command handler');
|
|
36
|
+
void implementServerCommandHandler
|
|
37
|
+
.handle(command)
|
|
38
|
+
.then(() => {
|
|
39
|
+
debug('Command completed successfully');
|
|
40
|
+
})
|
|
41
|
+
.catch((error) => {
|
|
42
|
+
debug('Command failed: %O', error);
|
|
43
|
+
console.error('Failed to execute command:', error);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { type CommandHandler, type Command, type Event } from '@auto-engineer/message-bus';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { existsSync } from 'fs';
|
|
5
|
+
import { runFlows } from '../agent/runFlows';
|
|
6
|
+
import createDebug from 'debug';
|
|
7
|
+
|
|
8
|
+
const debug = createDebug('server-impl:command');
|
|
9
|
+
const debugHandler = createDebug('server-impl:command:handler');
|
|
10
|
+
const debugProcess = createDebug('server-impl:command:process');
|
|
11
|
+
const debugResult = createDebug('server-impl:command:result');
|
|
12
|
+
|
|
13
|
+
export type ImplementServerCommand = Command<
|
|
14
|
+
'ImplementServer',
|
|
15
|
+
{
|
|
16
|
+
serverDirectory: string;
|
|
17
|
+
}
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
export type ServerImplementedEvent = Event<
|
|
21
|
+
'ServerImplemented',
|
|
22
|
+
{
|
|
23
|
+
serverDirectory: string;
|
|
24
|
+
flowsImplemented: number;
|
|
25
|
+
}
|
|
26
|
+
>;
|
|
27
|
+
|
|
28
|
+
export type ServerImplementationFailedEvent = Event<
|
|
29
|
+
'ServerImplementationFailed',
|
|
30
|
+
{
|
|
31
|
+
serverDirectory: string;
|
|
32
|
+
error: string;
|
|
33
|
+
}
|
|
34
|
+
>;
|
|
35
|
+
|
|
36
|
+
export async function handleImplementServerCommand(
|
|
37
|
+
command: ImplementServerCommand,
|
|
38
|
+
): Promise<ServerImplementedEvent | ServerImplementationFailedEvent> {
|
|
39
|
+
const { serverDirectory } = command.data;
|
|
40
|
+
|
|
41
|
+
debug('Handling ImplementServerCommand');
|
|
42
|
+
debug(' Server directory: %s', serverDirectory);
|
|
43
|
+
debug(' Request ID: %s', command.requestId);
|
|
44
|
+
debug(' Correlation ID: %s', command.correlationId ?? 'none');
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
const serverRoot = path.resolve(serverDirectory);
|
|
48
|
+
const flowsDir = path.join(serverRoot, 'src', 'domain', 'flows');
|
|
49
|
+
|
|
50
|
+
debugHandler('Resolved paths:');
|
|
51
|
+
debugHandler(' Server root: %s', serverRoot);
|
|
52
|
+
debugHandler(' Flows directory: %s', flowsDir);
|
|
53
|
+
|
|
54
|
+
if (!existsSync(flowsDir)) {
|
|
55
|
+
debugHandler('ERROR: Flows directory not found at %s', flowsDir);
|
|
56
|
+
return {
|
|
57
|
+
type: 'ServerImplementationFailed',
|
|
58
|
+
data: {
|
|
59
|
+
serverDirectory,
|
|
60
|
+
error: `Flows directory not found at: ${flowsDir}`,
|
|
61
|
+
},
|
|
62
|
+
timestamp: new Date(),
|
|
63
|
+
requestId: command.requestId,
|
|
64
|
+
correlationId: command.correlationId,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
debugProcess('Starting flow runner for directory: %s', flowsDir);
|
|
69
|
+
|
|
70
|
+
// Run the flows directly without spawning
|
|
71
|
+
await runFlows(flowsDir);
|
|
72
|
+
|
|
73
|
+
debugProcess('Flow runner completed successfully');
|
|
74
|
+
|
|
75
|
+
// For now, we don't have a way to count flows, so we'll use 0
|
|
76
|
+
// This could be enhanced by having runFlows return statistics
|
|
77
|
+
const flowsImplemented = 0;
|
|
78
|
+
|
|
79
|
+
debugResult('Process succeeded');
|
|
80
|
+
debugResult('Flows implemented: %d', flowsImplemented);
|
|
81
|
+
|
|
82
|
+
const successEvent: ServerImplementedEvent = {
|
|
83
|
+
type: 'ServerImplemented',
|
|
84
|
+
data: {
|
|
85
|
+
serverDirectory,
|
|
86
|
+
flowsImplemented,
|
|
87
|
+
},
|
|
88
|
+
timestamp: new Date(),
|
|
89
|
+
requestId: command.requestId,
|
|
90
|
+
correlationId: command.correlationId,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
debugResult('Returning success event: ServerImplemented');
|
|
94
|
+
return successEvent;
|
|
95
|
+
} catch (error) {
|
|
96
|
+
debug('ERROR: Exception caught: %O', error);
|
|
97
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
type: 'ServerImplementationFailed',
|
|
101
|
+
data: {
|
|
102
|
+
serverDirectory,
|
|
103
|
+
error: errorMessage,
|
|
104
|
+
},
|
|
105
|
+
timestamp: new Date(),
|
|
106
|
+
requestId: command.requestId,
|
|
107
|
+
correlationId: command.correlationId,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export const implementServerCommandHandler: CommandHandler<ImplementServerCommand> = {
|
|
113
|
+
name: 'ImplementServer',
|
|
114
|
+
handle: async (command: ImplementServerCommand): Promise<void> => {
|
|
115
|
+
debug('CommandHandler executing for ImplementServer');
|
|
116
|
+
const result = await handleImplementServerCommand(command);
|
|
117
|
+
|
|
118
|
+
if (result.type === 'ServerImplemented') {
|
|
119
|
+
debug('Command handler completed: success');
|
|
120
|
+
console.log(`✅ Server implementation completed successfully`);
|
|
121
|
+
if (result.data.flowsImplemented > 0) {
|
|
122
|
+
console.log(` ${result.data.flowsImplemented} flows implemented`);
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
debug('Command handler completed: failure - %s', result.data.error);
|
|
126
|
+
console.error(`❌ Server implementation failed: ${result.data.error}`);
|
|
127
|
+
process.exit(1);
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
};
|