@al76/tools-and-spec-workflow-mcp
Version:
MCP server for spec-driven development workflow with real-time web dashboard
81 lines (80 loc) • 3.2 kB
JavaScript
import { promises as fs } from 'fs';
import { join } from 'path';
import { PathUtils } from '../core/path-utils.js';
export const createSteeringDocTool = {
name: 'create-steering-doc',
description: `创建具有架构指导的项目指导文档。
# 说明
仅在用户明确批准创建指导文档后调用。规范工作流不需要。创建以下之一:product.md(愿景/目标)、tech.md(技术决策)或 structure.md(代码库组织)。首先使用 steering-guide 获取模板。`,
inputSchema: {
type: 'object',
properties: {
projectPath: {
type: 'string',
description: '项目根目录的绝对路径'
},
document: {
type: 'string',
enum: ['product', 'tech', 'structure'],
description: '要创建的指导文档:product、tech 或 structure'
},
content: {
type: 'string',
description: '指导文档的完整 markdown 内容'
}
},
required: ['projectPath', 'document', 'content']
}
};
export async function createSteeringDocHandler(args, context) {
const { projectPath, document, content } = args;
try {
// Ensure steering directory exists
const steeringDir = join(PathUtils.getWorkflowRoot(projectPath), 'steering');
await fs.mkdir(steeringDir, { recursive: true });
// Create the specific document
const filename = `${document}.md`;
const filePath = join(steeringDir, filename);
await fs.writeFile(filePath, content, 'utf-8');
const documentNames = {
product: 'Product Steering',
tech: 'Technical Steering',
structure: 'Structure Steering'
};
return {
success: true,
message: `${documentNames[document]} document created successfully`,
data: {
document,
filename,
filePath,
contentLength: content.length,
dashboardUrl: context.dashboardUrl
},
nextSteps: [
`Saved ${filename}`,
document === 'product' ? 'Next: Create tech.md' :
document === 'tech' ? 'Next: Create structure.md' :
'Steering complete. Use request-approval with category:"steering" and categoryName:"steering"',
context.dashboardUrl ? `Dashboard: ${context.dashboardUrl}` : 'Dashboard not available'
],
projectContext: {
projectPath,
workflowRoot: PathUtils.getWorkflowRoot(projectPath),
dashboardUrl: context.dashboardUrl
}
};
}
catch (error) {
return {
success: false,
message: `Failed to create ${document} steering document: ${error.message}`,
nextSteps: [
'Check project path exists',
'Verify markdown content',
'Retry with correct parameters'
]
};
}
}
//# sourceMappingURL=create-steering-doc.js.map