@codemcp/workflows 3.1.21
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 +4 -0
- package/.vibe/conversation-state.sqlite +0 -0
- package/LICENSE +674 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +74 -0
- package/dist/index.js.map +1 -0
- package/dist/notification-service.d.ts +14 -0
- package/dist/notification-service.d.ts.map +1 -0
- package/dist/notification-service.js +18 -0
- package/dist/notification-service.js.map +1 -0
- package/dist/resource-handlers/conversation-state.d.ts +15 -0
- package/dist/resource-handlers/conversation-state.d.ts.map +1 -0
- package/dist/resource-handlers/conversation-state.js +40 -0
- package/dist/resource-handlers/conversation-state.js.map +1 -0
- package/dist/resource-handlers/development-plan.d.ts +14 -0
- package/dist/resource-handlers/development-plan.d.ts.map +1 -0
- package/dist/resource-handlers/development-plan.js +31 -0
- package/dist/resource-handlers/development-plan.js.map +1 -0
- package/dist/resource-handlers/index.d.ts +24 -0
- package/dist/resource-handlers/index.d.ts.map +1 -0
- package/dist/resource-handlers/index.js +62 -0
- package/dist/resource-handlers/index.js.map +1 -0
- package/dist/resource-handlers/system-prompt.d.ts +15 -0
- package/dist/resource-handlers/system-prompt.d.ts.map +1 -0
- package/dist/resource-handlers/system-prompt.js +40 -0
- package/dist/resource-handlers/system-prompt.js.map +1 -0
- package/dist/resource-handlers/workflow-resource.d.ts +15 -0
- package/dist/resource-handlers/workflow-resource.d.ts.map +1 -0
- package/dist/resource-handlers/workflow-resource.js +85 -0
- package/dist/resource-handlers/workflow-resource.js.map +1 -0
- package/dist/response-renderer.d.ts +30 -0
- package/dist/response-renderer.d.ts.map +1 -0
- package/dist/response-renderer.js +94 -0
- package/dist/response-renderer.js.map +1 -0
- package/dist/server-config.d.ts +34 -0
- package/dist/server-config.d.ts.map +1 -0
- package/dist/server-config.js +486 -0
- package/dist/server-config.js.map +1 -0
- package/dist/server-helpers.d.ts +62 -0
- package/dist/server-helpers.d.ts.map +1 -0
- package/dist/server-helpers.js +156 -0
- package/dist/server-helpers.js.map +1 -0
- package/dist/server-implementation.d.ts +74 -0
- package/dist/server-implementation.d.ts.map +1 -0
- package/dist/server-implementation.js +201 -0
- package/dist/server-implementation.js.map +1 -0
- package/dist/server.d.ts +6 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +5 -0
- package/dist/server.js.map +1 -0
- package/dist/tool-handlers/base-tool-handler.d.ts +50 -0
- package/dist/tool-handlers/base-tool-handler.d.ts.map +1 -0
- package/dist/tool-handlers/base-tool-handler.js +74 -0
- package/dist/tool-handlers/base-tool-handler.js.map +1 -0
- package/dist/tool-handlers/conduct-review.d.ts +49 -0
- package/dist/tool-handlers/conduct-review.d.ts.map +1 -0
- package/dist/tool-handlers/conduct-review.js +105 -0
- package/dist/tool-handlers/conduct-review.js.map +1 -0
- package/dist/tool-handlers/get-tool-info.d.ts +76 -0
- package/dist/tool-handlers/get-tool-info.d.ts.map +1 -0
- package/dist/tool-handlers/get-tool-info.js +168 -0
- package/dist/tool-handlers/get-tool-info.js.map +1 -0
- package/dist/tool-handlers/index.d.ts +42 -0
- package/dist/tool-handlers/index.d.ts.map +1 -0
- package/dist/tool-handlers/index.js +74 -0
- package/dist/tool-handlers/index.js.map +1 -0
- package/dist/tool-handlers/install-workflow.d.ts +48 -0
- package/dist/tool-handlers/install-workflow.d.ts.map +1 -0
- package/dist/tool-handlers/install-workflow.js +131 -0
- package/dist/tool-handlers/install-workflow.js.map +1 -0
- package/dist/tool-handlers/list-workflows.d.ts +47 -0
- package/dist/tool-handlers/list-workflows.d.ts.map +1 -0
- package/dist/tool-handlers/list-workflows.js +58 -0
- package/dist/tool-handlers/list-workflows.js.map +1 -0
- package/dist/tool-handlers/no-idea.d.ts +41 -0
- package/dist/tool-handlers/no-idea.d.ts.map +1 -0
- package/dist/tool-handlers/no-idea.js +29 -0
- package/dist/tool-handlers/no-idea.js.map +1 -0
- package/dist/tool-handlers/proceed-to-phase.d.ts +39 -0
- package/dist/tool-handlers/proceed-to-phase.d.ts.map +1 -0
- package/dist/tool-handlers/proceed-to-phase.js +109 -0
- package/dist/tool-handlers/proceed-to-phase.js.map +1 -0
- package/dist/tool-handlers/reset-development.d.ts +31 -0
- package/dist/tool-handlers/reset-development.d.ts.map +1 -0
- package/dist/tool-handlers/reset-development.js +48 -0
- package/dist/tool-handlers/reset-development.js.map +1 -0
- package/dist/tool-handlers/resume-workflow.d.ts +88 -0
- package/dist/tool-handlers/resume-workflow.d.ts.map +1 -0
- package/dist/tool-handlers/resume-workflow.js +213 -0
- package/dist/tool-handlers/resume-workflow.js.map +1 -0
- package/dist/tool-handlers/setup-project-docs.d.ts +36 -0
- package/dist/tool-handlers/setup-project-docs.d.ts.map +1 -0
- package/dist/tool-handlers/setup-project-docs.js +136 -0
- package/dist/tool-handlers/setup-project-docs.js.map +1 -0
- package/dist/tool-handlers/start-development.d.ts +82 -0
- package/dist/tool-handlers/start-development.d.ts.map +1 -0
- package/dist/tool-handlers/start-development.js +448 -0
- package/dist/tool-handlers/start-development.js.map +1 -0
- package/dist/tool-handlers/whats-next.d.ts +42 -0
- package/dist/tool-handlers/whats-next.d.ts.map +1 -0
- package/dist/tool-handlers/whats-next.js +118 -0
- package/dist/tool-handlers/whats-next.js.map +1 -0
- package/dist/types.d.ts +114 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +29 -0
- package/src/index.ts +93 -0
- package/src/notification-service.ts +23 -0
- package/src/resource-handlers/conversation-state.ts +55 -0
- package/src/resource-handlers/development-plan.ts +48 -0
- package/src/resource-handlers/index.ts +73 -0
- package/src/resource-handlers/system-prompt.ts +55 -0
- package/src/resource-handlers/workflow-resource.ts +126 -0
- package/src/response-renderer.ts +116 -0
- package/src/server-config.ts +744 -0
- package/src/server-helpers.ts +225 -0
- package/src/server-implementation.ts +277 -0
- package/src/server.ts +9 -0
- package/src/tool-handlers/base-tool-handler.ts +141 -0
- package/src/tool-handlers/conduct-review.ts +191 -0
- package/src/tool-handlers/get-tool-info.ts +274 -0
- package/src/tool-handlers/index.ts +117 -0
- package/src/tool-handlers/install-workflow.ts +185 -0
- package/src/tool-handlers/list-workflows.ts +94 -0
- package/src/tool-handlers/no-idea.ts +47 -0
- package/src/tool-handlers/proceed-to-phase.ts +205 -0
- package/src/tool-handlers/reset-development.ts +90 -0
- package/src/tool-handlers/resume-workflow.ts +380 -0
- package/src/tool-handlers/setup-project-docs.ts +226 -0
- package/src/tool-handlers/start-development.ts +685 -0
- package/src/tool-handlers/whats-next.ts +235 -0
- package/src/types.ts +130 -0
- package/test/e2e/core-functionality.test.ts +176 -0
- package/test/e2e/mcp-contract.test.ts +540 -0
- package/test/e2e/plan-management.test.ts +331 -0
- package/test/e2e/state-management.test.ts +392 -0
- package/test/e2e/workflow-integration.test.ts +506 -0
- package/test/unit/commit-behaviour-interface.test.ts +244 -0
- package/test/unit/conduct-review.test.ts +151 -0
- package/test/unit/reset-functionality.test.ts +72 -0
- package/test/unit/resume-workflow.test.ts +192 -0
- package/test/unit/server-tools.test.ts +311 -0
- package/test/unit/setup-project-docs-handler.test.ts +267 -0
- package/test/unit/start-development-artifact-detection.test.ts +387 -0
- package/test/unit/start-development-gitignore.test.ts +178 -0
- package/test/unit/system-prompt-resource.test.ts +101 -0
- package/test/unit/tool-handlers/no-idea.test.ts +40 -0
- package/test/utils/e2e-test-setup.ts +453 -0
- package/test/utils/run-server-in-dir.sh +27 -0
- package/test/utils/temp-files.ts +308 -0
- package/test/utils/test-access.ts +79 -0
- package/test/utils/test-helpers.ts +286 -0
- package/test/utils/test-setup.ts +78 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +12 -0
- package/vitest.config.ts +17 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server Helper Functions
|
|
3
|
+
*
|
|
4
|
+
* Common utility functions used across the server implementation.
|
|
5
|
+
* These are pure functions that don't depend on server state.
|
|
6
|
+
*/
|
|
7
|
+
import { HandlerResult } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Normalize and validate project path
|
|
10
|
+
* Ensures we have a valid project path, defaulting to home directory if needed
|
|
11
|
+
*/
|
|
12
|
+
export declare function normalizeProjectPath(projectPath?: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Create a standardized success result
|
|
15
|
+
*/
|
|
16
|
+
export declare function createSuccessResult<T>(data: T, metadata?: Record<string, unknown>): HandlerResult<T>;
|
|
17
|
+
/**
|
|
18
|
+
* Create a standardized error result
|
|
19
|
+
*/
|
|
20
|
+
export declare function createErrorResult(error: string | Error, metadata?: Record<string, unknown>): HandlerResult<never>;
|
|
21
|
+
/**
|
|
22
|
+
* Safely execute an async operation and return a HandlerResult
|
|
23
|
+
* This provides consistent error handling across all handlers
|
|
24
|
+
*/
|
|
25
|
+
export declare function safeExecute<T>(operation: () => Promise<T>, errorContext?: string): Promise<HandlerResult<T>>;
|
|
26
|
+
/**
|
|
27
|
+
* Validate required arguments for tool handlers
|
|
28
|
+
* Throws an error if any required arguments are missing
|
|
29
|
+
*/
|
|
30
|
+
export declare function validateRequiredArgs(args: unknown, requiredFields: string[]): void;
|
|
31
|
+
/**
|
|
32
|
+
* Check if a conversation exists and provide helpful error if not
|
|
33
|
+
*/
|
|
34
|
+
export declare function createConversationNotFoundResult(availableWorkflows?: string[]): HandlerResult<never>;
|
|
35
|
+
/**
|
|
36
|
+
* Extract workflow names for enum generation
|
|
37
|
+
* Used by server configuration to build Zod schemas
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildWorkflowEnum(workflowNames: string[]): [string, ...string[]];
|
|
40
|
+
/**
|
|
41
|
+
* Generate workflow description for tool schemas
|
|
42
|
+
*/
|
|
43
|
+
export declare function generateWorkflowDescription(workflows: Array<{
|
|
44
|
+
name: string;
|
|
45
|
+
displayName: string;
|
|
46
|
+
description: string;
|
|
47
|
+
metadata?: {
|
|
48
|
+
complexity?: 'low' | 'medium' | 'high';
|
|
49
|
+
bestFor?: string[];
|
|
50
|
+
useCases?: string[];
|
|
51
|
+
examples?: string[];
|
|
52
|
+
};
|
|
53
|
+
}>): string;
|
|
54
|
+
/**
|
|
55
|
+
* Log handler execution for debugging
|
|
56
|
+
*/
|
|
57
|
+
export declare function logHandlerExecution(handlerName: string, args: unknown): void;
|
|
58
|
+
/**
|
|
59
|
+
* Log handler completion for debugging
|
|
60
|
+
*/
|
|
61
|
+
export declare function logHandlerCompletion(handlerName: string, result: HandlerResult<unknown>): void;
|
|
62
|
+
//# sourceMappingURL=server-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-helpers.d.ts","sourceRoot":"","sources":["../src/server-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAI3C;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAajE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,IAAI,EAAE,CAAC,EACP,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,aAAa,CAAC,CAAC,CAAC,CAMlB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,GAAG,KAAK,EACrB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,aAAa,CAAC,KAAK,CAAC,CAQtB;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,CAAC,EACjC,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAc3B;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,OAAO,EACb,cAAc,EAAE,MAAM,EAAE,GACvB,IAAI,CAUN;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAC9C,kBAAkB,GAAE,MAAM,EAAO,GAChC,aAAa,CAAC,KAAK,CAAC,CAoBtB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,MAAM,EAAE,GACtB,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CASvB;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,KAAK,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE;QACT,UAAU,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;QACvC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;CACH,CAAC,GACD,MAAM,CAoCR;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAK5E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,GAC7B,IAAI,CAON"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server Helper Functions
|
|
3
|
+
*
|
|
4
|
+
* Common utility functions used across the server implementation.
|
|
5
|
+
* These are pure functions that don't depend on server state.
|
|
6
|
+
*/
|
|
7
|
+
import { homedir } from 'node:os';
|
|
8
|
+
import { createLogger } from '@codemcp/workflows-core';
|
|
9
|
+
const logger = createLogger('ServerHelpers');
|
|
10
|
+
/**
|
|
11
|
+
* Normalize and validate project path
|
|
12
|
+
* Ensures we have a valid project path, defaulting to home directory if needed
|
|
13
|
+
*/
|
|
14
|
+
export function normalizeProjectPath(projectPath) {
|
|
15
|
+
const path = projectPath || process.cwd();
|
|
16
|
+
if (path === '/' || path === '') {
|
|
17
|
+
const homePath = homedir();
|
|
18
|
+
logger.info('Invalid project path detected, using home directory', {
|
|
19
|
+
originalPath: path,
|
|
20
|
+
normalizedPath: homePath,
|
|
21
|
+
});
|
|
22
|
+
return homePath;
|
|
23
|
+
}
|
|
24
|
+
return path;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create a standardized success result
|
|
28
|
+
*/
|
|
29
|
+
export function createSuccessResult(data, metadata) {
|
|
30
|
+
return {
|
|
31
|
+
success: true,
|
|
32
|
+
data,
|
|
33
|
+
metadata,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create a standardized error result
|
|
38
|
+
*/
|
|
39
|
+
export function createErrorResult(error, metadata) {
|
|
40
|
+
const errorMessage = error instanceof Error ? error.message : error;
|
|
41
|
+
return {
|
|
42
|
+
success: false,
|
|
43
|
+
error: errorMessage,
|
|
44
|
+
metadata,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Safely execute an async operation and return a HandlerResult
|
|
49
|
+
* This provides consistent error handling across all handlers
|
|
50
|
+
*/
|
|
51
|
+
export async function safeExecute(operation, errorContext) {
|
|
52
|
+
try {
|
|
53
|
+
const result = await operation();
|
|
54
|
+
return createSuccessResult(result);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
58
|
+
const contextualError = errorContext
|
|
59
|
+
? `${errorContext}: ${errorMessage}`
|
|
60
|
+
: errorMessage;
|
|
61
|
+
logger.error('Operation failed', error, { errorContext });
|
|
62
|
+
return createErrorResult(contextualError);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Validate required arguments for tool handlers
|
|
67
|
+
* Throws an error if any required arguments are missing
|
|
68
|
+
*/
|
|
69
|
+
export function validateRequiredArgs(args, requiredFields) {
|
|
70
|
+
const missingFields = requiredFields.filter(field => args[field] === undefined ||
|
|
71
|
+
args[field] === null);
|
|
72
|
+
if (missingFields.length > 0) {
|
|
73
|
+
throw new Error(`Missing required arguments: ${missingFields.join(', ')}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Check if a conversation exists and provide helpful error if not
|
|
78
|
+
*/
|
|
79
|
+
export function createConversationNotFoundResult(availableWorkflows = []) {
|
|
80
|
+
if (availableWorkflows.length === 0) {
|
|
81
|
+
return createErrorResult('No development conversation has been started for this project and no workflows are available. Please install a workflow first or adjust the VIBE_WORKFLOW_DOMAINS environment variable.', {
|
|
82
|
+
suggestion: 'install_workflow({ source: "waterfall" }) or set VIBE_WORKFLOW_DOMAINS=code,architecture,office',
|
|
83
|
+
availableWorkflows: [],
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const firstWorkflow = availableWorkflows[0];
|
|
87
|
+
return createErrorResult('No development conversation has been started for this project. Please use the start_development tool first to initialize development with a workflow.', {
|
|
88
|
+
suggestion: `start_development({ workflow: "${firstWorkflow}" })`,
|
|
89
|
+
availableWorkflows,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Extract workflow names for enum generation
|
|
94
|
+
* Used by server configuration to build Zod schemas
|
|
95
|
+
*/
|
|
96
|
+
export function buildWorkflowEnum(workflowNames) {
|
|
97
|
+
const allWorkflows = [...workflowNames, 'custom'];
|
|
98
|
+
// Ensure we have at least one element for TypeScript
|
|
99
|
+
if (allWorkflows.length === 0) {
|
|
100
|
+
return ['waterfall'];
|
|
101
|
+
}
|
|
102
|
+
return allWorkflows;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Generate workflow description for tool schemas
|
|
106
|
+
*/
|
|
107
|
+
export function generateWorkflowDescription(workflows) {
|
|
108
|
+
let description = 'Choose your development workflow:\n\n';
|
|
109
|
+
for (const workflow of workflows) {
|
|
110
|
+
description += `• **${workflow.name}**: ${workflow.displayName} - ${workflow.description}`;
|
|
111
|
+
// Add enhanced metadata if available
|
|
112
|
+
if (workflow.metadata) {
|
|
113
|
+
const meta = workflow.metadata;
|
|
114
|
+
// Add complexity
|
|
115
|
+
if (meta.complexity) {
|
|
116
|
+
description += `\n Complexity: ${meta.complexity}`;
|
|
117
|
+
}
|
|
118
|
+
// Add best for information
|
|
119
|
+
if (meta.bestFor && meta.bestFor.length > 0) {
|
|
120
|
+
description += `\n Best for: ${meta.bestFor.join(', ')}`;
|
|
121
|
+
}
|
|
122
|
+
// Add examples
|
|
123
|
+
if (meta.examples && meta.examples.length > 0) {
|
|
124
|
+
description += `\n Examples: ${meta.examples.slice(0, 2).join(', ')}`;
|
|
125
|
+
if (meta.examples.length > 2) {
|
|
126
|
+
description += `, and ${meta.examples.length - 2} more`;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
description += '\n';
|
|
131
|
+
}
|
|
132
|
+
description +=
|
|
133
|
+
'• **custom**: Use custom workflow from .vibe/workflows in your project\n\n';
|
|
134
|
+
return description;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Log handler execution for debugging
|
|
138
|
+
*/
|
|
139
|
+
export function logHandlerExecution(handlerName, args) {
|
|
140
|
+
logger.debug(`Executing ${handlerName} handler`, {
|
|
141
|
+
handlerName,
|
|
142
|
+
argsKeys: Object.keys(args || {}),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Log handler completion for debugging
|
|
147
|
+
*/
|
|
148
|
+
export function logHandlerCompletion(handlerName, result) {
|
|
149
|
+
logger.debug(`Completed ${handlerName} handler`, {
|
|
150
|
+
handlerName,
|
|
151
|
+
success: result.success,
|
|
152
|
+
hasData: !!result.data,
|
|
153
|
+
hasError: !!result.error,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=server-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-helpers.js","sourceRoot":"","sources":["../src/server-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD,MAAM,MAAM,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC;AAE7C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,WAAoB;IACvD,MAAM,IAAI,GAAG,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAE1C,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,OAAO,EAAE,CAAC;QAC3B,MAAM,CAAC,IAAI,CAAC,qDAAqD,EAAE;YACjE,YAAY,EAAE,IAAI;YAClB,cAAc,EAAE,QAAQ;SACzB,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAO,EACP,QAAkC;IAElC,OAAO;QACL,OAAO,EAAE,IAAI;QACb,IAAI;QACJ,QAAQ;KACT,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAAqB,EACrB,QAAkC;IAElC,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAEpE,OAAO;QACL,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,YAAY;QACnB,QAAQ;KACT,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,SAA2B,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QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACvE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC7B,WAAW,IAAI,SAAS,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,OAAO,CAAC;gBAC1D,CAAC;YACH,CAAC;QACH,CAAC;QAED,WAAW,IAAI,IAAI,CAAC;IACtB,CAAC;IAED,WAAW;QACT,4EAA4E,CAAC;IAE/E,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,WAAmB,EAAE,IAAa;IACpE,MAAM,CAAC,KAAK,CAAC,aAAa,WAAW,UAAU,EAAE;QAC/C,WAAW;QACX,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;KAClC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,WAAmB,EACnB,MAA8B;IAE9B,MAAM,CAAC,KAAK,CAAC,aAAa,WAAW,UAAU,EAAE;QAC/C,WAAW;QACX,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI;QACtB,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK;KACzB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refactored Vibe Feature MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Main server orchestrator that brings together all the modular components.
|
|
5
|
+
* This replaces the monolithic server.ts with a clean, modular architecture.
|
|
6
|
+
*/
|
|
7
|
+
import { ServerConfig } from './types.js';
|
|
8
|
+
import { ServerComponents } from './server-config.js';
|
|
9
|
+
import type { ProceedToPhaseArgs, ProceedToPhaseResult, StartDevelopmentArgs, StartDevelopmentResult, ResumeWorkflowArgs, ResumeWorkflowResult, ResetDevelopmentArgs, ResetDevelopmentResult } from './tool-handlers/index.js';
|
|
10
|
+
/**
|
|
11
|
+
* Factory function to create a server with real components
|
|
12
|
+
*/
|
|
13
|
+
export declare function createResponsibleVibeMCPServer(config?: ServerConfig): Promise<ResponsibleVibeMCPServer>;
|
|
14
|
+
/**
|
|
15
|
+
* Main server class that orchestrates all components
|
|
16
|
+
* Can be used both as a standalone process and in-process for testing
|
|
17
|
+
*/
|
|
18
|
+
export declare class ResponsibleVibeMCPServer {
|
|
19
|
+
private config;
|
|
20
|
+
private serverComponents;
|
|
21
|
+
private components;
|
|
22
|
+
constructor(config: ServerConfig, serverComponents: ServerComponents);
|
|
23
|
+
/**
|
|
24
|
+
* Initialize the server and all its components
|
|
25
|
+
*/
|
|
26
|
+
initialize(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Get the underlying MCP server instance
|
|
29
|
+
* This allows for both transport-based and direct testing
|
|
30
|
+
*/
|
|
31
|
+
getMcpServer(): import("@modelcontextprotocol/sdk/server/mcp.js").McpServer;
|
|
32
|
+
/**
|
|
33
|
+
* Get project path
|
|
34
|
+
*/
|
|
35
|
+
getProjectPath(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Get conversation manager (for testing)
|
|
38
|
+
*/
|
|
39
|
+
getConversationManager(): import("@codemcp/workflows-core").ConversationManager;
|
|
40
|
+
/**
|
|
41
|
+
* Get plan manager (for testing)
|
|
42
|
+
*/
|
|
43
|
+
getPlanManager(): import("@codemcp/workflows-core").PlanManager;
|
|
44
|
+
/**
|
|
45
|
+
* Direct access to tool handlers for testing
|
|
46
|
+
*/
|
|
47
|
+
handleWhatsNext(args: unknown): Promise<unknown>;
|
|
48
|
+
/**
|
|
49
|
+
* Direct access to tool handlers for testing
|
|
50
|
+
*/
|
|
51
|
+
handleProceedToPhase(args: ProceedToPhaseArgs): Promise<ProceedToPhaseResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Direct access to tool handlers for testing
|
|
54
|
+
*/
|
|
55
|
+
handleStartDevelopment(args: StartDevelopmentArgs): Promise<StartDevelopmentResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Direct access to tool handlers for testing
|
|
58
|
+
*/
|
|
59
|
+
handleResumeWorkflow(args: ResumeWorkflowArgs): Promise<ResumeWorkflowResult>;
|
|
60
|
+
/**
|
|
61
|
+
* Direct access to tool handlers for testing
|
|
62
|
+
*/
|
|
63
|
+
handleResetDevelopment(args: ResetDevelopmentArgs): Promise<ResetDevelopmentResult>;
|
|
64
|
+
/**
|
|
65
|
+
* Cleanup server resources
|
|
66
|
+
*/
|
|
67
|
+
cleanup(): Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
export * from './types.js';
|
|
70
|
+
export * from './server-helpers.js';
|
|
71
|
+
export * from './response-renderer.js';
|
|
72
|
+
export * from './tool-handlers/index.js';
|
|
73
|
+
export * from './resource-handlers/index.js';
|
|
74
|
+
//# sourceMappingURL=server-implementation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-implementation.d.ts","sourceRoot":"","sources":["../src/server-implementation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAIL,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAIlC;;GAEG;AACH,wBAAsB,8BAA8B,CAClD,MAAM,GAAE,YAAiB,GACxB,OAAO,CAAC,wBAAwB,CAAC,CAGnC;AAED;;;GAGG;AACH,qBAAa,wBAAwB;IAIjC,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,gBAAgB;IAJ1B,OAAO,CAAC,UAAU,CAAiC;gBAGzC,MAAM,EAAE,YAAY,EACpB,gBAAgB,EAAE,gBAAgB;IAO5C;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA2CjC;;;OAGG;IACI,YAAY;IAOnB;;OAEG;IACI,cAAc,IAAI,MAAM;IAO/B;;OAEG;IACI,sBAAsB;IAO7B;;OAEG;IACI,cAAc;IAOrB;;OAEG;IACU,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAkB7D;;OAEG;IACU,oBAAoB,CAC/B,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,oBAAoB,CAAC;IAkBhC;;OAEG;IACU,sBAAsB,CACjC,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC,sBAAsB,CAAC;IAkBlC;;OAEG;IACU,oBAAoB,CAC/B,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,oBAAoB,CAAC;IAkBhC;;OAEG;IACU,sBAAsB,CACjC,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC,sBAAsB,CAAC;IAkBlC;;OAEG;IACU,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAStC;AAGD,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refactored Vibe Feature MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Main server orchestrator that brings together all the modular components.
|
|
5
|
+
* This replaces the monolithic server.ts with a clean, modular architecture.
|
|
6
|
+
*/
|
|
7
|
+
import { setMcpServerForLogging, createLogger } from '@codemcp/workflows-core';
|
|
8
|
+
import { initializeServerComponents, registerMcpTools, registerMcpResources, } from './server-config.js';
|
|
9
|
+
import { createToolRegistry } from './tool-handlers/index.js';
|
|
10
|
+
import { createResourceRegistry } from './resource-handlers/index.js';
|
|
11
|
+
import { createResponseRenderer } from './response-renderer.js';
|
|
12
|
+
const logger = createLogger('ResponsibleVibeMCPServer');
|
|
13
|
+
/**
|
|
14
|
+
* Factory function to create a server with real components
|
|
15
|
+
*/
|
|
16
|
+
export async function createResponsibleVibeMCPServer(config = {}) {
|
|
17
|
+
const components = await initializeServerComponents(config);
|
|
18
|
+
return new ResponsibleVibeMCPServer(config, components);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Main server class that orchestrates all components
|
|
22
|
+
* Can be used both as a standalone process and in-process for testing
|
|
23
|
+
*/
|
|
24
|
+
export class ResponsibleVibeMCPServer {
|
|
25
|
+
config;
|
|
26
|
+
serverComponents;
|
|
27
|
+
components = null;
|
|
28
|
+
constructor(config, serverComponents) {
|
|
29
|
+
this.config = config;
|
|
30
|
+
this.serverComponents = serverComponents;
|
|
31
|
+
logger.debug('ResponsibleVibeMCPServer created', {
|
|
32
|
+
config: JSON.stringify(this.config),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Initialize the server and all its components
|
|
37
|
+
*/
|
|
38
|
+
async initialize() {
|
|
39
|
+
logger.debug('Initializing ResponsibleVibeMCPServer');
|
|
40
|
+
try {
|
|
41
|
+
// Use injected components
|
|
42
|
+
this.components = this.serverComponents;
|
|
43
|
+
// Create registries and renderer
|
|
44
|
+
const toolRegistry = createToolRegistry();
|
|
45
|
+
const resourceRegistry = createResourceRegistry();
|
|
46
|
+
const responseRenderer = createResponseRenderer();
|
|
47
|
+
// Update components with registries and renderer
|
|
48
|
+
this.components.toolRegistry = toolRegistry;
|
|
49
|
+
this.components.resourceRegistry = resourceRegistry;
|
|
50
|
+
this.components.responseRenderer = responseRenderer;
|
|
51
|
+
// Register MCP server for logging notifications
|
|
52
|
+
setMcpServerForLogging(this.components.mcpServer);
|
|
53
|
+
// Register tools and resources with MCP server
|
|
54
|
+
await registerMcpTools(this.components.mcpServer, toolRegistry, responseRenderer, this.components.context);
|
|
55
|
+
registerMcpResources(this.components.mcpServer, resourceRegistry, responseRenderer, this.components.context);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
logger.error('Failed to initialize ResponsibleVibeMCPServer', error);
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get the underlying MCP server instance
|
|
64
|
+
* This allows for both transport-based and direct testing
|
|
65
|
+
*/
|
|
66
|
+
getMcpServer() {
|
|
67
|
+
if (!this.components) {
|
|
68
|
+
throw new Error('Server not initialized. Call initialize() first.');
|
|
69
|
+
}
|
|
70
|
+
return this.components.mcpServer;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get project path
|
|
74
|
+
*/
|
|
75
|
+
getProjectPath() {
|
|
76
|
+
if (!this.components) {
|
|
77
|
+
throw new Error('Server not initialized. Call initialize() first.');
|
|
78
|
+
}
|
|
79
|
+
return this.components.context.projectPath;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get conversation manager (for testing)
|
|
83
|
+
*/
|
|
84
|
+
getConversationManager() {
|
|
85
|
+
if (!this.components) {
|
|
86
|
+
throw new Error('Server not initialized. Call initialize() first.');
|
|
87
|
+
}
|
|
88
|
+
return this.components.context.conversationManager;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get plan manager (for testing)
|
|
92
|
+
*/
|
|
93
|
+
getPlanManager() {
|
|
94
|
+
if (!this.components) {
|
|
95
|
+
throw new Error('Server not initialized. Call initialize() first.');
|
|
96
|
+
}
|
|
97
|
+
return this.components.context.planManager;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Direct access to tool handlers for testing
|
|
101
|
+
*/
|
|
102
|
+
async handleWhatsNext(args) {
|
|
103
|
+
if (!this.components) {
|
|
104
|
+
throw new Error('Server not initialized. Call initialize() first.');
|
|
105
|
+
}
|
|
106
|
+
const handler = this.components.toolRegistry.get('whats_next');
|
|
107
|
+
if (!handler) {
|
|
108
|
+
throw new Error('whats_next handler not found');
|
|
109
|
+
}
|
|
110
|
+
const result = await handler.handle(args, this.components.context);
|
|
111
|
+
if (!result.success) {
|
|
112
|
+
throw new Error(result.error || 'Handler execution failed');
|
|
113
|
+
}
|
|
114
|
+
return result.data;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Direct access to tool handlers for testing
|
|
118
|
+
*/
|
|
119
|
+
async handleProceedToPhase(args) {
|
|
120
|
+
if (!this.components) {
|
|
121
|
+
throw new Error('Server not initialized. Call initialize() first.');
|
|
122
|
+
}
|
|
123
|
+
const handler = this.components.toolRegistry.get('proceed_to_phase');
|
|
124
|
+
if (!handler) {
|
|
125
|
+
throw new Error('proceed_to_phase handler not found');
|
|
126
|
+
}
|
|
127
|
+
const result = await handler.handle(args, this.components.context);
|
|
128
|
+
if (!result.success) {
|
|
129
|
+
throw new Error(result.error || 'Handler execution failed');
|
|
130
|
+
}
|
|
131
|
+
return result.data;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Direct access to tool handlers for testing
|
|
135
|
+
*/
|
|
136
|
+
async handleStartDevelopment(args) {
|
|
137
|
+
if (!this.components) {
|
|
138
|
+
throw new Error('Server not initialized. Call initialize() first.');
|
|
139
|
+
}
|
|
140
|
+
const handler = this.components.toolRegistry.get('start_development');
|
|
141
|
+
if (!handler) {
|
|
142
|
+
throw new Error('start_development handler not found');
|
|
143
|
+
}
|
|
144
|
+
const result = await handler.handle(args, this.components.context);
|
|
145
|
+
if (!result.success) {
|
|
146
|
+
throw new Error(result.error || 'Handler execution failed');
|
|
147
|
+
}
|
|
148
|
+
return result.data;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Direct access to tool handlers for testing
|
|
152
|
+
*/
|
|
153
|
+
async handleResumeWorkflow(args) {
|
|
154
|
+
if (!this.components) {
|
|
155
|
+
throw new Error('Server not initialized. Call initialize() first.');
|
|
156
|
+
}
|
|
157
|
+
const handler = this.components.toolRegistry.get('resume_workflow');
|
|
158
|
+
if (!handler) {
|
|
159
|
+
throw new Error('resume_workflow handler not found');
|
|
160
|
+
}
|
|
161
|
+
const result = await handler.handle(args, this.components.context);
|
|
162
|
+
if (!result.success) {
|
|
163
|
+
throw new Error(result.error || 'Handler execution failed');
|
|
164
|
+
}
|
|
165
|
+
return result.data;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Direct access to tool handlers for testing
|
|
169
|
+
*/
|
|
170
|
+
async handleResetDevelopment(args) {
|
|
171
|
+
if (!this.components) {
|
|
172
|
+
throw new Error('Server not initialized. Call initialize() first.');
|
|
173
|
+
}
|
|
174
|
+
const handler = this.components.toolRegistry.get('reset_development');
|
|
175
|
+
if (!handler) {
|
|
176
|
+
throw new Error('reset_development handler not found');
|
|
177
|
+
}
|
|
178
|
+
const result = await handler.handle(args, this.components.context);
|
|
179
|
+
if (!result.success) {
|
|
180
|
+
throw new Error(result.error || 'Handler execution failed');
|
|
181
|
+
}
|
|
182
|
+
return result.data;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Cleanup server resources
|
|
186
|
+
*/
|
|
187
|
+
async cleanup() {
|
|
188
|
+
logger.debug('Cleaning up server resources');
|
|
189
|
+
if (this.components?.database) {
|
|
190
|
+
await this.components.database.close();
|
|
191
|
+
}
|
|
192
|
+
logger.info('Server cleanup completed');
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
// Export all types and utilities for external use
|
|
196
|
+
export * from './types.js';
|
|
197
|
+
export * from './server-helpers.js';
|
|
198
|
+
export * from './response-renderer.js';
|
|
199
|
+
export * from './tool-handlers/index.js';
|
|
200
|
+
export * from './resource-handlers/index.js';
|
|
201
|
+
//# sourceMappingURL=server-implementation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-implementation.js","sourceRoot":"","sources":["../src/server-implementation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,sBAAsB,E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,CAAC,0BAA0B,CAAC,CAAC;IAC1C,CAAC;CACF;AAED,kDAAkD;AAClD,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Tool Handler
|
|
3
|
+
*
|
|
4
|
+
* Provides common functionality for all tool handlers including
|
|
5
|
+
* error handling, logging, and conversation state management.
|
|
6
|
+
*/
|
|
7
|
+
import { createLogger } from '@codemcp/workflows-core';
|
|
8
|
+
import { ToolHandler, ServerContext, HandlerResult } from '../types.js';
|
|
9
|
+
import type { ConversationContext } from '@codemcp/workflows-core';
|
|
10
|
+
/**
|
|
11
|
+
* Abstract base class for tool handlers
|
|
12
|
+
* Provides common functionality and enforces consistent patterns
|
|
13
|
+
*/
|
|
14
|
+
export declare abstract class BaseToolHandler<TArgs = unknown, TResult = unknown> implements ToolHandler<TArgs, TResult> {
|
|
15
|
+
protected readonly logger: ReturnType<typeof createLogger>;
|
|
16
|
+
constructor();
|
|
17
|
+
/**
|
|
18
|
+
* Main handler method - implements consistent error handling and logging
|
|
19
|
+
*/
|
|
20
|
+
handle(args: TArgs, context: ServerContext): Promise<HandlerResult<TResult>>;
|
|
21
|
+
/**
|
|
22
|
+
* Abstract method that subclasses must implement
|
|
23
|
+
* Contains the actual business logic for the tool
|
|
24
|
+
*/
|
|
25
|
+
protected abstract executeHandler(args: TArgs, context: ServerContext): Promise<TResult>;
|
|
26
|
+
/**
|
|
27
|
+
* Helper method to get conversation context with proper error handling
|
|
28
|
+
*/
|
|
29
|
+
protected getConversationContext(context: ServerContext): Promise<ConversationContext>;
|
|
30
|
+
/**
|
|
31
|
+
* Helper method to ensure state machine is loaded for a project
|
|
32
|
+
*/
|
|
33
|
+
protected ensureStateMachineForProject(context: ServerContext, projectPath: string, workflowName?: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* Helper method to log interactions if logger is available
|
|
36
|
+
*/
|
|
37
|
+
protected logInteraction(context: ServerContext, conversationId: string, toolName: string, args: unknown, response: unknown, phase: string): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Base class for tool handlers that require an existing conversation
|
|
41
|
+
* Automatically handles the conversation-not-found case
|
|
42
|
+
*/
|
|
43
|
+
export declare abstract class ConversationRequiredToolHandler<TArgs = unknown, TResult = unknown> extends BaseToolHandler<TArgs, TResult> {
|
|
44
|
+
protected executeHandler(args: TArgs, context: ServerContext): Promise<TResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Abstract method for handlers that need conversation context
|
|
47
|
+
*/
|
|
48
|
+
protected abstract executeWithConversation(args: TArgs, context: ServerContext, conversationContext: ConversationContext): Promise<TResult>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=base-tool-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-tool-handler.d.ts","sourceRoot":"","sources":["../../src/tool-handlers/base-tool-handler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,aA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