@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
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types and interfaces for the refactored server architecture
|
|
3
|
+
*/
|
|
4
|
+
import { ConversationManager } from '@codemcp/workflows-core';
|
|
5
|
+
import { TransitionEngine } from '@codemcp/workflows-core';
|
|
6
|
+
import { PlanManager } from '@codemcp/workflows-core';
|
|
7
|
+
import { InstructionGenerator } from '@codemcp/workflows-core';
|
|
8
|
+
import { WorkflowManager } from '@codemcp/workflows-core';
|
|
9
|
+
import { InteractionLogger } from '@codemcp/workflows-core';
|
|
10
|
+
/**
|
|
11
|
+
* Server context shared across all handlers
|
|
12
|
+
* Contains all the core dependencies needed by tool and resource handlers
|
|
13
|
+
*/
|
|
14
|
+
export interface ServerContext {
|
|
15
|
+
conversationManager: ConversationManager;
|
|
16
|
+
transitionEngine: TransitionEngine;
|
|
17
|
+
planManager: PlanManager;
|
|
18
|
+
instructionGenerator: InstructionGenerator;
|
|
19
|
+
workflowManager: WorkflowManager;
|
|
20
|
+
interactionLogger?: InteractionLogger;
|
|
21
|
+
projectPath: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Standard result format for all handler operations
|
|
25
|
+
* Separates business logic results from MCP protocol concerns
|
|
26
|
+
*/
|
|
27
|
+
export interface HandlerResult<T = unknown> {
|
|
28
|
+
success: boolean;
|
|
29
|
+
data?: T;
|
|
30
|
+
error?: string;
|
|
31
|
+
metadata?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Resource content structure
|
|
35
|
+
*/
|
|
36
|
+
export interface ResourceContent {
|
|
37
|
+
uri: string;
|
|
38
|
+
text: string;
|
|
39
|
+
mimeType: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* MCP Tool Response format (compatible with MCP SDK)
|
|
43
|
+
*/
|
|
44
|
+
export interface McpToolResponse {
|
|
45
|
+
[x: string]: unknown;
|
|
46
|
+
content: Array<{
|
|
47
|
+
type: 'text';
|
|
48
|
+
text: string;
|
|
49
|
+
}>;
|
|
50
|
+
isError?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* MCP Resource Response format (compatible with MCP SDK)
|
|
54
|
+
*/
|
|
55
|
+
export interface McpResourceResponse {
|
|
56
|
+
[x: string]: unknown;
|
|
57
|
+
contents: Array<{
|
|
58
|
+
uri: string;
|
|
59
|
+
text: string;
|
|
60
|
+
mimeType: string;
|
|
61
|
+
}>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Tool handler interface
|
|
65
|
+
* All tool handlers must implement this interface
|
|
66
|
+
*/
|
|
67
|
+
export interface ToolHandler<TArgs = unknown, TResult = unknown> {
|
|
68
|
+
handle(args: TArgs, context: ServerContext): Promise<HandlerResult<TResult>>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Resource handler interface
|
|
72
|
+
* All resource handlers must implement this interface
|
|
73
|
+
*/
|
|
74
|
+
export interface ResourceHandler {
|
|
75
|
+
handle(uri: URL, context: ServerContext): Promise<HandlerResult<ResourceContent>>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Response renderer interface
|
|
79
|
+
* Handles translation between domain results and MCP protocol responses
|
|
80
|
+
*/
|
|
81
|
+
export interface ResponseRenderer {
|
|
82
|
+
renderToolResponse<T>(result: HandlerResult<T>): McpToolResponse;
|
|
83
|
+
renderResourceResponse(result: HandlerResult<ResourceContent>): McpResourceResponse;
|
|
84
|
+
renderError(error: Error | string): McpToolResponse;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Tool registry interface
|
|
88
|
+
* Manages registration and lookup of tool handlers
|
|
89
|
+
*/
|
|
90
|
+
export interface ToolRegistry {
|
|
91
|
+
register<T extends ToolHandler>(name: string, handler: T): void;
|
|
92
|
+
get(name: string): ToolHandler | undefined;
|
|
93
|
+
list(): string[];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Resource registry interface
|
|
97
|
+
* Manages registration and lookup of resource handlers
|
|
98
|
+
*/
|
|
99
|
+
export interface ResourceRegistry {
|
|
100
|
+
register(pattern: string, handler: ResourceHandler): void;
|
|
101
|
+
resolve(uri: string): ResourceHandler | undefined;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Server configuration options
|
|
105
|
+
*/
|
|
106
|
+
export interface ServerConfig {
|
|
107
|
+
/** Project path to operate on (defaults to process.cwd()) */
|
|
108
|
+
projectPath?: string;
|
|
109
|
+
/** Database path override */
|
|
110
|
+
databasePath?: string;
|
|
111
|
+
/** Enable interaction logging */
|
|
112
|
+
enableLogging?: boolean;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@codemcp/workflows",
|
|
3
|
+
"version": "3.1.21",
|
|
4
|
+
"description": "MCP server implementation for responsible-vibe",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"responsible-vibe-mcp": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@modelcontextprotocol/sdk": "1.17.5",
|
|
12
|
+
"@codemcp/workflows-core": "3.1.21"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/node": "^20.0.0",
|
|
16
|
+
"typescript": "^5.0.0",
|
|
17
|
+
"vitest": "3.2.4"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.build.json",
|
|
21
|
+
"clean:build": "rimraf ./dist",
|
|
22
|
+
"dev": "tsc --watch",
|
|
23
|
+
"test": "vitest --run",
|
|
24
|
+
"lint": "oxlint .",
|
|
25
|
+
"lint:fix": "oxlint --fix .",
|
|
26
|
+
"format:check": "prettier --check .",
|
|
27
|
+
"format": "prettier --write ."
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Vibe Feature MCP Server Entry Point
|
|
5
|
+
*
|
|
6
|
+
* Starts the MCP server with stdio transport for process-based usage.
|
|
7
|
+
* The core server logic is in server.ts for better testability.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
11
|
+
import { createResponsibleVibeMCPServer } from './server.js';
|
|
12
|
+
|
|
13
|
+
// Re-export for external use
|
|
14
|
+
export {
|
|
15
|
+
ResponsibleVibeMCPServer,
|
|
16
|
+
createResponsibleVibeMCPServer,
|
|
17
|
+
} from './server.js';
|
|
18
|
+
import { createLogger } from '@codemcp/workflows-core';
|
|
19
|
+
|
|
20
|
+
const logger = createLogger('Main');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Parse command line arguments and handle special flags
|
|
24
|
+
*/
|
|
25
|
+
function parseCliArgs(): { shouldStartServer: boolean } {
|
|
26
|
+
// Since routing is handled at root level, always start server when this module is loaded
|
|
27
|
+
return { shouldStartServer: true };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Main entry point for the MCP server process
|
|
32
|
+
*/
|
|
33
|
+
async function main() {
|
|
34
|
+
// Parse CLI arguments first
|
|
35
|
+
const { shouldStartServer } = parseCliArgs();
|
|
36
|
+
|
|
37
|
+
// If special flags were handled, exit gracefully
|
|
38
|
+
if (!shouldStartServer) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Normal MCP server startup
|
|
43
|
+
try {
|
|
44
|
+
const projectPath = process.env.PROJECT_PATH;
|
|
45
|
+
|
|
46
|
+
// Create server instance with project path configuration
|
|
47
|
+
const server = await createResponsibleVibeMCPServer({
|
|
48
|
+
projectPath: projectPath,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Initialize server
|
|
52
|
+
await server.initialize();
|
|
53
|
+
|
|
54
|
+
// Create stdio transport
|
|
55
|
+
const transport = new StdioServerTransport();
|
|
56
|
+
|
|
57
|
+
// Connect server to transport
|
|
58
|
+
await server.getMcpServer().connect(transport);
|
|
59
|
+
|
|
60
|
+
// Note: No logging here to ensure compatibility with Amazon Q CLI
|
|
61
|
+
// Amazon Q CLI expects no logging notifications before MCP initialization completes
|
|
62
|
+
|
|
63
|
+
// Handle graceful shutdown
|
|
64
|
+
process.on('SIGINT', async () => {
|
|
65
|
+
logger.info('Shutting down Vibe Feature MCP Server...');
|
|
66
|
+
await server.cleanup();
|
|
67
|
+
process.exit(0);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
process.on('SIGTERM', async () => {
|
|
71
|
+
logger.info('Shutting down Vibe Feature MCP Server...');
|
|
72
|
+
await server.cleanup();
|
|
73
|
+
process.exit(0);
|
|
74
|
+
});
|
|
75
|
+
} catch (error) {
|
|
76
|
+
logger.error('Failed to start server', error as Error);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Start the server if this file is run directly
|
|
82
|
+
// More robust check that works with npx and direct execution
|
|
83
|
+
const isMainModule =
|
|
84
|
+
import.meta.url === `file://${process.argv[1]}` ||
|
|
85
|
+
process.argv[1]?.endsWith('responsible-vibe-mcp') ||
|
|
86
|
+
process.argv[1]?.endsWith('index.js');
|
|
87
|
+
|
|
88
|
+
if (isMainModule) {
|
|
89
|
+
main().catch(error => {
|
|
90
|
+
logger.error('Unhandled error in main', error);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification Service
|
|
3
|
+
*
|
|
4
|
+
* Simple event system for notifying MCP client of changes
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
8
|
+
|
|
9
|
+
class NotificationService {
|
|
10
|
+
private mcpServer?: McpServer;
|
|
11
|
+
|
|
12
|
+
setMcpServer(server: McpServer): void {
|
|
13
|
+
this.mcpServer = server;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async notifyToolListChanged(): Promise<void> {
|
|
17
|
+
if (this.mcpServer) {
|
|
18
|
+
this.mcpServer.sendToolListChanged();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const notificationService = new NotificationService();
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation State Resource Handler
|
|
3
|
+
*
|
|
4
|
+
* Handles the conversation-state resource which provides access to current
|
|
5
|
+
* conversation state and phase information including conversation ID, project context,
|
|
6
|
+
* current development phase, and plan file location.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { createLogger } from '@codemcp/workflows-core';
|
|
10
|
+
import {
|
|
11
|
+
ResourceHandler,
|
|
12
|
+
ServerContext,
|
|
13
|
+
HandlerResult,
|
|
14
|
+
ResourceContent,
|
|
15
|
+
} from '../types.js';
|
|
16
|
+
import { safeExecute } from '../server-helpers.js';
|
|
17
|
+
|
|
18
|
+
const logger = createLogger('ConversationStateResourceHandler');
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Conversation State resource handler implementation
|
|
22
|
+
*/
|
|
23
|
+
export class ConversationStateResourceHandler implements ResourceHandler {
|
|
24
|
+
async handle(
|
|
25
|
+
uri: URL,
|
|
26
|
+
context: ServerContext
|
|
27
|
+
): Promise<HandlerResult<ResourceContent>> {
|
|
28
|
+
logger.debug('Processing conversation state resource request', {
|
|
29
|
+
uri: uri.href,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return safeExecute(async () => {
|
|
33
|
+
// Get conversation context
|
|
34
|
+
const conversationContext =
|
|
35
|
+
await context.conversationManager.getConversationContext();
|
|
36
|
+
|
|
37
|
+
// Build state information
|
|
38
|
+
const stateInfo = {
|
|
39
|
+
conversationId: conversationContext.conversationId,
|
|
40
|
+
projectPath: conversationContext.projectPath,
|
|
41
|
+
gitBranch: conversationContext.gitBranch,
|
|
42
|
+
currentPhase: conversationContext.currentPhase,
|
|
43
|
+
planFilePath: conversationContext.planFilePath,
|
|
44
|
+
timestamp: new Date().toISOString(),
|
|
45
|
+
description: 'Current state of the development workflow conversation',
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
uri: uri.href,
|
|
50
|
+
text: JSON.stringify(stateInfo, null, 2),
|
|
51
|
+
mimeType: 'application/json',
|
|
52
|
+
};
|
|
53
|
+
}, 'Failed to retrieve conversation state resource');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Development Plan Resource Handler
|
|
3
|
+
*
|
|
4
|
+
* Handles the development-plan resource which provides access to the current
|
|
5
|
+
* development plan document (markdown) that tracks project progress, tasks, and decisions.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { createLogger } from '@codemcp/workflows-core';
|
|
9
|
+
import {
|
|
10
|
+
ResourceHandler,
|
|
11
|
+
ServerContext,
|
|
12
|
+
HandlerResult,
|
|
13
|
+
ResourceContent,
|
|
14
|
+
} from '../types.js';
|
|
15
|
+
import { safeExecute } from '../server-helpers.js';
|
|
16
|
+
|
|
17
|
+
const logger = createLogger('DevelopmentPlanResourceHandler');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Development Plan resource handler implementation
|
|
21
|
+
*/
|
|
22
|
+
export class DevelopmentPlanResourceHandler implements ResourceHandler {
|
|
23
|
+
async handle(
|
|
24
|
+
uri: URL,
|
|
25
|
+
context: ServerContext
|
|
26
|
+
): Promise<HandlerResult<ResourceContent>> {
|
|
27
|
+
logger.debug('Processing development plan resource request', {
|
|
28
|
+
uri: uri.href,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return safeExecute(async () => {
|
|
32
|
+
// Get conversation context
|
|
33
|
+
const conversationContext =
|
|
34
|
+
await context.conversationManager.getConversationContext();
|
|
35
|
+
|
|
36
|
+
// Get plan file content
|
|
37
|
+
const planContent = await context.planManager.getPlanFileContent(
|
|
38
|
+
conversationContext.planFilePath
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
uri: uri.href,
|
|
43
|
+
text: planContent,
|
|
44
|
+
mimeType: 'text/markdown',
|
|
45
|
+
};
|
|
46
|
+
}, 'Failed to retrieve development plan resource');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource Handler Registry
|
|
3
|
+
*
|
|
4
|
+
* Central registry for all resource handlers. Provides registration and lookup
|
|
5
|
+
* functionality for resource handlers used by the MCP server.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { createLogger } from '@codemcp/workflows-core';
|
|
9
|
+
import { DevelopmentPlanResourceHandler } from './development-plan.js';
|
|
10
|
+
import { ConversationStateResourceHandler } from './conversation-state.js';
|
|
11
|
+
import { WorkflowResourceHandler } from './workflow-resource.js';
|
|
12
|
+
import { SystemPromptResourceHandler } from './system-prompt.js';
|
|
13
|
+
import { ResourceHandler, ResourceRegistry } from '../types.js';
|
|
14
|
+
|
|
15
|
+
const logger = createLogger('ResourceRegistry');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Default implementation of ResourceRegistry
|
|
19
|
+
*/
|
|
20
|
+
export class DefaultResourceRegistry implements ResourceRegistry {
|
|
21
|
+
private handlers = new Map<string, ResourceHandler>();
|
|
22
|
+
|
|
23
|
+
register(pattern: string, handler: ResourceHandler): void {
|
|
24
|
+
logger.debug('Registering resource handler', {
|
|
25
|
+
pattern,
|
|
26
|
+
handlerType: handler.constructor.name,
|
|
27
|
+
});
|
|
28
|
+
this.handlers.set(pattern, handler);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
resolve(uri: string): ResourceHandler | undefined {
|
|
32
|
+
// Simple pattern matching - could be enhanced with regex patterns
|
|
33
|
+
for (const [pattern, handler] of this.handlers.entries()) {
|
|
34
|
+
if (uri.includes(pattern)) {
|
|
35
|
+
logger.debug('Resolved resource handler', { uri, pattern });
|
|
36
|
+
return handler;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
logger.debug('No resource handler found for URI', { uri });
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Create and configure the default resource registry with all standard handlers
|
|
47
|
+
*/
|
|
48
|
+
export function createResourceRegistry(): ResourceRegistry {
|
|
49
|
+
const registry = new DefaultResourceRegistry();
|
|
50
|
+
|
|
51
|
+
// Register all standard resource handlers
|
|
52
|
+
registry.register('plan://current', new DevelopmentPlanResourceHandler());
|
|
53
|
+
registry.register('state://current', new ConversationStateResourceHandler());
|
|
54
|
+
registry.register('workflow://', new WorkflowResourceHandler());
|
|
55
|
+
registry.register('system-prompt://', new SystemPromptResourceHandler());
|
|
56
|
+
|
|
57
|
+
logger.info('Resource registry created with handlers', {
|
|
58
|
+
patterns: [
|
|
59
|
+
'plan://current',
|
|
60
|
+
'state://current',
|
|
61
|
+
'workflow://',
|
|
62
|
+
'system-prompt://',
|
|
63
|
+
],
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return registry;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Export all handler types for external use
|
|
70
|
+
export { DevelopmentPlanResourceHandler } from './development-plan.js';
|
|
71
|
+
export { ConversationStateResourceHandler } from './conversation-state.js';
|
|
72
|
+
export { WorkflowResourceHandler } from './workflow-resource.js';
|
|
73
|
+
export { SystemPromptResourceHandler } from './system-prompt.js';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System Prompt Resource Handler
|
|
3
|
+
*
|
|
4
|
+
* Handles the system-prompt resource which provides access to the complete
|
|
5
|
+
* system prompt for LLM integration. This allows programmatic access to the
|
|
6
|
+
* system prompt through the MCP protocol. The system prompt is workflow-independent.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { createLogger } from '@codemcp/workflows-core';
|
|
10
|
+
import {
|
|
11
|
+
ResourceHandler,
|
|
12
|
+
ServerContext,
|
|
13
|
+
HandlerResult,
|
|
14
|
+
ResourceContent,
|
|
15
|
+
} from '../types.js';
|
|
16
|
+
import { safeExecute } from '../server-helpers.js';
|
|
17
|
+
import { generateSystemPrompt } from '@codemcp/workflows-core';
|
|
18
|
+
import { StateMachineLoader } from '@codemcp/workflows-core';
|
|
19
|
+
|
|
20
|
+
const logger = createLogger('SystemPromptResourceHandler');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* System Prompt resource handler implementation
|
|
24
|
+
*/
|
|
25
|
+
export class SystemPromptResourceHandler implements ResourceHandler {
|
|
26
|
+
async handle(
|
|
27
|
+
uri: URL,
|
|
28
|
+
_context: ServerContext
|
|
29
|
+
): Promise<HandlerResult<ResourceContent>> {
|
|
30
|
+
logger.debug('Processing system prompt resource request', {
|
|
31
|
+
uri: uri.href,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return safeExecute(async () => {
|
|
35
|
+
// Use the default waterfall workflow for system prompt generation
|
|
36
|
+
// The system prompt is workflow-independent and uses a standard workflow
|
|
37
|
+
const loader = new StateMachineLoader();
|
|
38
|
+
const stateMachine = loader.loadStateMachine(process.cwd()); // Uses default waterfall workflow
|
|
39
|
+
|
|
40
|
+
// Generate the system prompt
|
|
41
|
+
const systemPrompt = generateSystemPrompt(stateMachine);
|
|
42
|
+
|
|
43
|
+
logger.debug('Generated system prompt for resource', {
|
|
44
|
+
promptLength: systemPrompt.length,
|
|
45
|
+
workflowName: stateMachine.name,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
uri: uri.href,
|
|
50
|
+
text: systemPrompt,
|
|
51
|
+
mimeType: 'text/plain',
|
|
52
|
+
};
|
|
53
|
+
}, 'Failed to retrieve system prompt resource');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow Resource Handler
|
|
3
|
+
*
|
|
4
|
+
* Handles MCP resources for individual workflows, returning the raw YAML content
|
|
5
|
+
* from workflow definition files.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import fs from 'node:fs';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
import { createLogger } from '@codemcp/workflows-core';
|
|
12
|
+
import {
|
|
13
|
+
ResourceHandler,
|
|
14
|
+
ServerContext,
|
|
15
|
+
HandlerResult,
|
|
16
|
+
ResourceContent,
|
|
17
|
+
} from '../types.js';
|
|
18
|
+
import { safeExecute } from '../server-helpers.js';
|
|
19
|
+
|
|
20
|
+
const logger = createLogger('WorkflowResourceHandler');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Resource handler for workflow:// URIs
|
|
24
|
+
* Returns raw YAML content from workflow definition files
|
|
25
|
+
*/
|
|
26
|
+
export class WorkflowResourceHandler implements ResourceHandler {
|
|
27
|
+
async handle(
|
|
28
|
+
uri: URL,
|
|
29
|
+
context: ServerContext
|
|
30
|
+
): Promise<HandlerResult<ResourceContent>> {
|
|
31
|
+
logger.debug('Processing workflow resource request', { uri: uri.href });
|
|
32
|
+
|
|
33
|
+
return safeExecute(async () => {
|
|
34
|
+
// Extract workflow name from URI (workflow://workflow-name)
|
|
35
|
+
const workflowName = uri.hostname;
|
|
36
|
+
|
|
37
|
+
if (!workflowName) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
'Invalid workflow URI: missing workflow name. Expected: workflow://workflow-name'
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
logger.info('Loading workflow resource', { workflowName, uri: uri.href });
|
|
44
|
+
|
|
45
|
+
let yamlContent: string;
|
|
46
|
+
let filePath: string;
|
|
47
|
+
|
|
48
|
+
// Try to get workflow from workflow manager
|
|
49
|
+
const workflow = context.workflowManager.getWorkflow(workflowName);
|
|
50
|
+
if (!workflow) {
|
|
51
|
+
throw new Error(`Workflow '${workflowName}' not found`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Handle predefined workflows
|
|
55
|
+
// Get the workflows directory path - more reliable approach
|
|
56
|
+
const currentFileUrl = import.meta.url;
|
|
57
|
+
const currentFilePath = fileURLToPath(currentFileUrl);
|
|
58
|
+
|
|
59
|
+
// Navigate from the compiled location to the project root
|
|
60
|
+
// From dist/server/resource-handlers/workflow-resource.js -> project root
|
|
61
|
+
let projectRoot: string;
|
|
62
|
+
if (currentFilePath.includes('/dist/')) {
|
|
63
|
+
// Running from compiled code - dist is one level down from project root
|
|
64
|
+
projectRoot = path.resolve(path.dirname(currentFilePath), '../../../');
|
|
65
|
+
} else {
|
|
66
|
+
// Running from source (development) - src is one level down from project root
|
|
67
|
+
projectRoot = path.resolve(path.dirname(currentFilePath), '../../../');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const workflowFile = path.join(
|
|
71
|
+
projectRoot,
|
|
72
|
+
'resources',
|
|
73
|
+
'workflows',
|
|
74
|
+
`${workflowName}.yaml`
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
if (!fs.existsSync(workflowFile)) {
|
|
78
|
+
// Try .yml extension
|
|
79
|
+
const workflowFileYml = path.join(
|
|
80
|
+
projectRoot,
|
|
81
|
+
'resources',
|
|
82
|
+
'workflows',
|
|
83
|
+
`${workflowName}.yml`
|
|
84
|
+
);
|
|
85
|
+
if (!fs.existsSync(workflowFileYml)) {
|
|
86
|
+
// Log debug info to help troubleshoot
|
|
87
|
+
logger.error(
|
|
88
|
+
'Workflow file not found',
|
|
89
|
+
new Error(`Workflow '${workflowName}' not found`),
|
|
90
|
+
{
|
|
91
|
+
workflowName,
|
|
92
|
+
currentFilePath,
|
|
93
|
+
projectRoot,
|
|
94
|
+
workflowFile,
|
|
95
|
+
workflowFileYml,
|
|
96
|
+
workflowsDir: path.join(projectRoot, 'resources', 'workflows'),
|
|
97
|
+
workflowsDirExists: fs.existsSync(
|
|
98
|
+
path.join(projectRoot, 'resources', 'workflows')
|
|
99
|
+
),
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
throw new Error(
|
|
103
|
+
`Workflow '${workflowName}' not found in resources/workflows/`
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
filePath = workflowFileYml;
|
|
107
|
+
} else {
|
|
108
|
+
filePath = workflowFile;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
yamlContent = fs.readFileSync(filePath, 'utf-8');
|
|
112
|
+
|
|
113
|
+
logger.info('Successfully loaded workflow resource', {
|
|
114
|
+
workflowName,
|
|
115
|
+
filePath,
|
|
116
|
+
contentLength: yamlContent.length,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
uri: uri.href,
|
|
121
|
+
text: yamlContent,
|
|
122
|
+
mimeType: 'application/x-yaml',
|
|
123
|
+
};
|
|
124
|
+
}, `Failed to load workflow resource: ${uri.href}`);
|
|
125
|
+
}
|
|
126
|
+
}
|