feat: implement tdd workflow (#1309)
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
93
apps/mcp/src/tools/autopilot/status.tool.ts
Normal file
93
apps/mcp/src/tools/autopilot/status.tool.ts
Normal file
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* @fileoverview autopilot-status MCP tool
|
||||
* Get comprehensive workflow status and progress information
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import {
|
||||
handleApiResult,
|
||||
withNormalizedProjectRoot
|
||||
} from '../../shared/utils.js';
|
||||
import type { MCPContext } from '../../shared/types.js';
|
||||
import { WorkflowService } from '@tm/core';
|
||||
import type { FastMCP } from 'fastmcp';
|
||||
|
||||
const StatusSchema = z.object({
|
||||
projectRoot: z
|
||||
.string()
|
||||
.describe('Absolute path to the project root directory')
|
||||
});
|
||||
|
||||
type StatusArgs = z.infer<typeof StatusSchema>;
|
||||
|
||||
/**
|
||||
* Register the autopilot_status tool with the MCP server
|
||||
*/
|
||||
export function registerAutopilotStatusTool(server: FastMCP) {
|
||||
server.addTool({
|
||||
name: 'autopilot_status',
|
||||
description:
|
||||
'Get comprehensive workflow status including current phase, progress, subtask details, and activity history.',
|
||||
parameters: StatusSchema,
|
||||
execute: withNormalizedProjectRoot(
|
||||
async (args: StatusArgs, context: MCPContext) => {
|
||||
const { projectRoot } = args;
|
||||
|
||||
try {
|
||||
context.log.info(`Getting workflow status for ${projectRoot}`);
|
||||
|
||||
const workflowService = new WorkflowService(projectRoot);
|
||||
|
||||
// Check if workflow exists
|
||||
if (!(await workflowService.hasWorkflow())) {
|
||||
return handleApiResult({
|
||||
result: {
|
||||
success: false,
|
||||
error: {
|
||||
message:
|
||||
'No active workflow found. Start a workflow with autopilot_start'
|
||||
}
|
||||
},
|
||||
log: context.log,
|
||||
projectRoot
|
||||
});
|
||||
}
|
||||
|
||||
// Resume to load state
|
||||
await workflowService.resumeWorkflow();
|
||||
|
||||
// Get status
|
||||
const status = workflowService.getStatus();
|
||||
|
||||
context.log.info(
|
||||
`Workflow status retrieved for task ${status.taskId}`
|
||||
);
|
||||
|
||||
return handleApiResult({
|
||||
result: {
|
||||
success: true,
|
||||
data: status
|
||||
},
|
||||
log: context.log,
|
||||
projectRoot
|
||||
});
|
||||
} catch (error: any) {
|
||||
context.log.error(`Error in autopilot-status: ${error.message}`);
|
||||
if (error.stack) {
|
||||
context.log.debug(error.stack);
|
||||
}
|
||||
return handleApiResult({
|
||||
result: {
|
||||
success: false,
|
||||
error: {
|
||||
message: `Failed to get workflow status: ${error.message}`
|
||||
}
|
||||
},
|
||||
log: context.log,
|
||||
projectRoot
|
||||
});
|
||||
}
|
||||
}
|
||||
)
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user