@codemcp/workflows 5.0.1 → 5.1.1

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.
Files changed (77) hide show
  1. package/package.json +6 -2
  2. package/skill/SKILL.md +23 -0
  3. package/.prettierignore +0 -2
  4. package/.turbo/turbo-build.log +0 -4
  5. package/.vibe/conversation-state.sqlite +0 -0
  6. package/src/components/beads/beads-instruction-generator.ts +0 -230
  7. package/src/components/beads/beads-plan-manager.ts +0 -333
  8. package/src/components/beads/beads-task-backend-client.ts +0 -229
  9. package/src/index.ts +0 -93
  10. package/src/notification-service.ts +0 -23
  11. package/src/plugin-system/beads-plugin.ts +0 -649
  12. package/src/plugin-system/commit-plugin.ts +0 -252
  13. package/src/plugin-system/index.ts +0 -20
  14. package/src/plugin-system/plugin-interfaces.ts +0 -153
  15. package/src/plugin-system/plugin-registry.ts +0 -190
  16. package/src/resource-handlers/conversation-state.ts +0 -55
  17. package/src/resource-handlers/development-plan.ts +0 -48
  18. package/src/resource-handlers/index.ts +0 -73
  19. package/src/resource-handlers/system-prompt.ts +0 -55
  20. package/src/resource-handlers/workflow-resource.ts +0 -132
  21. package/src/response-renderer.ts +0 -116
  22. package/src/server-config.ts +0 -760
  23. package/src/server-helpers.ts +0 -245
  24. package/src/server-implementation.ts +0 -277
  25. package/src/server.ts +0 -9
  26. package/src/tool-handlers/base-tool-handler.ts +0 -151
  27. package/src/tool-handlers/conduct-review.ts +0 -190
  28. package/src/tool-handlers/get-tool-info.ts +0 -273
  29. package/src/tool-handlers/index.ts +0 -115
  30. package/src/tool-handlers/list-workflows.ts +0 -78
  31. package/src/tool-handlers/no-idea.ts +0 -47
  32. package/src/tool-handlers/proceed-to-phase.ts +0 -296
  33. package/src/tool-handlers/reset-development.ts +0 -90
  34. package/src/tool-handlers/resume-workflow.ts +0 -378
  35. package/src/tool-handlers/setup-project-docs.ts +0 -232
  36. package/src/tool-handlers/start-development.ts +0 -746
  37. package/src/tool-handlers/whats-next.ts +0 -246
  38. package/src/types.ts +0 -135
  39. package/src/version-info.ts +0 -213
  40. package/test/e2e/beads-plugin-integration.test.ts +0 -1623
  41. package/test/e2e/commit-plugin-integration.test.ts +0 -222
  42. package/test/e2e/core-functionality.test.ts +0 -167
  43. package/test/e2e/git-branch-detection.test.ts +0 -351
  44. package/test/e2e/mcp-contract.test.ts +0 -509
  45. package/test/e2e/plan-management.test.ts +0 -334
  46. package/test/e2e/plugin-system-integration.test.ts +0 -1410
  47. package/test/e2e/state-management.test.ts +0 -387
  48. package/test/e2e/workflow-integration.test.ts +0 -498
  49. package/test/unit/beads-instruction-generator.test.ts +0 -979
  50. package/test/unit/beads-phase-task-id-integration.test.ts +0 -535
  51. package/test/unit/beads-plugin-behavioral.test.ts +0 -545
  52. package/test/unit/beads-plugin.test.ts +0 -117
  53. package/test/unit/commit-plugin.test.ts +0 -196
  54. package/test/unit/conduct-review.test.ts +0 -151
  55. package/test/unit/conversation-not-found-error.test.ts +0 -120
  56. package/test/unit/plugin-error-handling.test.ts +0 -240
  57. package/test/unit/proceed-to-phase-plugin-integration.test.ts +0 -150
  58. package/test/unit/reset-functionality.test.ts +0 -72
  59. package/test/unit/resume-workflow.test.ts +0 -193
  60. package/test/unit/server-config-plugin-registry.test.ts +0 -99
  61. package/test/unit/server-tools.test.ts +0 -310
  62. package/test/unit/setup-project-docs-handler.test.ts +0 -268
  63. package/test/unit/start-development-artifact-detection.test.ts +0 -387
  64. package/test/unit/start-development-gitignore.test.ts +0 -178
  65. package/test/unit/start-development-goal-extraction.test.ts +0 -226
  66. package/test/unit/system-prompt-resource.test.ts +0 -102
  67. package/test/unit/tool-handlers/no-idea.test.ts +0 -40
  68. package/test/utils/e2e-test-setup.ts +0 -451
  69. package/test/utils/run-server-in-dir.sh +0 -27
  70. package/test/utils/temp-files.ts +0 -320
  71. package/test/utils/test-access.ts +0 -79
  72. package/test/utils/test-helpers.ts +0 -288
  73. package/test/utils/test-setup.ts +0 -77
  74. package/tsconfig.build.json +0 -10
  75. package/tsconfig.build.tsbuildinfo +0 -1
  76. package/tsconfig.json +0 -12
  77. package/vitest.config.ts +0 -19
@@ -1,48 +0,0 @@
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
- }
@@ -1,73 +0,0 @@
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';
@@ -1,55 +0,0 @@
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
- }
@@ -1,132 +0,0 @@
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 - from packages/mcp-server/dist/resource-handlers/ to project root is 4 levels up
64
- projectRoot = path.resolve(
65
- path.dirname(currentFilePath),
66
- '../../../../'
67
- );
68
- } else {
69
- // Running from source (development) - src is 4 levels down from project root
70
- projectRoot = path.resolve(
71
- path.dirname(currentFilePath),
72
- '../../../../'
73
- );
74
- }
75
-
76
- const workflowFile = path.join(
77
- projectRoot,
78
- 'resources',
79
- 'workflows',
80
- `${workflowName}.yaml`
81
- );
82
-
83
- if (!fs.existsSync(workflowFile)) {
84
- // Try .yml extension
85
- const workflowFileYml = path.join(
86
- projectRoot,
87
- 'resources',
88
- 'workflows',
89
- `${workflowName}.yml`
90
- );
91
- if (!fs.existsSync(workflowFileYml)) {
92
- // Log debug info to help troubleshoot
93
- logger.error(
94
- 'Workflow file not found',
95
- new Error(`Workflow '${workflowName}' not found`),
96
- {
97
- workflowName,
98
- currentFilePath,
99
- projectRoot,
100
- workflowFile,
101
- workflowFileYml,
102
- workflowsDir: path.join(projectRoot, 'resources', 'workflows'),
103
- workflowsDirExists: fs.existsSync(
104
- path.join(projectRoot, 'resources', 'workflows')
105
- ),
106
- }
107
- );
108
- throw new Error(
109
- `Workflow '${workflowName}' not found in resources/workflows/`
110
- );
111
- }
112
- filePath = workflowFileYml;
113
- } else {
114
- filePath = workflowFile;
115
- }
116
-
117
- yamlContent = fs.readFileSync(filePath, 'utf-8');
118
-
119
- logger.info('Successfully loaded workflow resource', {
120
- workflowName,
121
- filePath,
122
- contentLength: yamlContent.length,
123
- });
124
-
125
- return {
126
- uri: uri.href,
127
- text: yamlContent,
128
- mimeType: 'application/x-yaml',
129
- };
130
- }, `Failed to load workflow resource: ${uri.href}`);
131
- }
132
- }
@@ -1,116 +0,0 @@
1
- /**
2
- * Response Renderer
3
- *
4
- * Handles translation between domain handler results and MCP protocol responses.
5
- * This provides clean separation between business logic and protocol concerns.
6
- */
7
-
8
- import { createLogger } from '@codemcp/workflows-core';
9
- import {
10
- ResponseRenderer,
11
- HandlerResult,
12
- ResourceContent,
13
- McpToolResponse,
14
- McpResourceResponse,
15
- } from './types.js';
16
-
17
- const logger = createLogger('ResponseRenderer');
18
-
19
- /**
20
- * Default implementation of ResponseRenderer
21
- * Converts domain results to MCP protocol format
22
- */
23
- export class DefaultResponseRenderer implements ResponseRenderer {
24
- /**
25
- * Render a tool handler result as an MCP tool response
26
- */
27
- renderToolResponse<T>(result: HandlerResult<T>): McpToolResponse {
28
- logger.debug('Rendering tool response', {
29
- success: result.success,
30
- hasData: !!result.data,
31
- hasError: !!result.error,
32
- });
33
-
34
- if (!result.success && result.error) {
35
- return this.renderError(result.error);
36
- }
37
-
38
- // Convert data to JSON string for MCP protocol
39
- const responseText = result.data
40
- ? JSON.stringify(result.data, null, 2)
41
- : '';
42
-
43
- return {
44
- content: [
45
- {
46
- type: 'text' as const,
47
- text: responseText,
48
- },
49
- ],
50
- };
51
- }
52
-
53
- /**
54
- * Render a resource handler result as an MCP resource response
55
- */
56
- renderResourceResponse(
57
- result: HandlerResult<ResourceContent>
58
- ): McpResourceResponse {
59
- logger.debug('Rendering resource response', {
60
- success: result.success,
61
- hasData: !!result.data,
62
- });
63
-
64
- if (!result.success || !result.data) {
65
- // For resources, we still need to return a valid response structure
66
- // but with error content
67
- const errorText = result.error || 'Resource not available';
68
-
69
- return {
70
- contents: [
71
- {
72
- uri: result.data?.uri || 'error://unknown',
73
- text: `Error: ${errorText}`,
74
- mimeType: 'text/plain',
75
- },
76
- ],
77
- };
78
- }
79
-
80
- return {
81
- contents: [
82
- {
83
- uri: result.data.uri,
84
- text: result.data.text,
85
- mimeType: result.data.mimeType,
86
- },
87
- ],
88
- };
89
- }
90
-
91
- /**
92
- * Render an error as an MCP tool response
93
- */
94
- renderError(error: Error | string): McpToolResponse {
95
- const errorMessage = error instanceof Error ? error.message : error;
96
-
97
- logger.debug('Rendering error response', { errorMessage });
98
-
99
- return {
100
- content: [
101
- {
102
- type: 'text' as const,
103
- text: `Error: ${errorMessage}`,
104
- },
105
- ],
106
- isError: true,
107
- };
108
- }
109
- }
110
-
111
- /**
112
- * Create a default response renderer instance
113
- */
114
- export function createResponseRenderer(): ResponseRenderer {
115
- return new DefaultResponseRenderer();
116
- }