task-master-neo-sdlc
Version:
Enhanced task management system with Neo SDLC agents and MCP tools for comprehensive, AI-driven software development lifecycle management.
128 lines (108 loc) • 4.31 kB
JavaScript
import { KnowledgeGraph } from '../knowledge-graph';
import { AgentWorkflowSystem } from '../agent-workflow';
// Assume utilities for running specific build/analysis scripts
// import scriptRunner from '../../utils/scriptRunner';
// Assume utilities for file system operations
// import fsUtils from '../../utils/fsUtils';
export class ProjectSetupAgent {
constructor(knowledgeGraph, workflow) {
this.knowledgeGraph = knowledgeGraph;
this.workflow = workflow;
}
/**
* Generates the initial Knowledge Graph for a project.
* Corresponds to the generate_knowledge_graph step in /init_project.
* @param {string} projectType - e.g., 'React', 'Vue', 'Python'
* @param {string} projectRoot - Path to the project root.
* @returns {Promise<string>} Path to the generated knowledge graph file.
*/
async generateKnowledgeGraph(projectType, projectRoot) {
console.log(`Generating initial knowledge graph for ${projectType} project at ${projectRoot}`);
const outputPath = '.context/initial-knowledge-graph.json'; // As defined in YAML
// Placeholder: In reality, this would trigger the appropriate script
// based on projectType (e.g., node scripts/react_dependency_graph.js)
// await scriptRunner.run(projectType, projectRoot, outputPath);
const graphData = {
nodes: [{ id: 'placeholder_node', type: projectType }],
edges: []
};
// Simulate writing the file
// await fsUtils.writeFile(outputPath, JSON.stringify(graphData, null, 2));
console.log(`Placeholder knowledge graph generated at ${outputPath}`);
// Add basic info to the actual KG instance
await this.knowledgeGraph.addNode({ id: 'project_root', type: 'directory', data: { path: projectRoot, projectType } });
await this.knowledgeGraph.addNode({ id: 'generated_kg_file', type: 'file', data: { path: outputPath } });
return outputPath;
}
/**
* Sets up the .context directory structure and core files.
* Corresponds to the setup_context step in /init_project.
* @param {string} projectName - Name of the project.
* @param {string} projectDescription - Description of the project.
* @param {string} generatedKgPath - Path to the initially generated KG file.
* @returns {Promise<void>}
*/
async setupContextDirectory(projectName, projectDescription, generatedKgPath) {
console.log(`Setting up .context directory for project: ${projectName}`);
const contextRoot = '.context';
const dirsToCreate = [
`${contextRoot}/diagrams`,
`${contextRoot}/images`,
`${contextRoot}/docs`,
`${contextRoot}/knowledge_graph`
];
const filesToCreate = {
[`${contextRoot}/index.md`]: `---
module-name: "${projectName}"
description: "${projectDescription}"
technologies: []
related-modules: []
permissions: "read-write"
version: "1.0.0"
---
# ${projectName}
## Module Overview
## Architecture
## Domain Logic
## Integration Points
## Configuration`,
[`${contextRoot}/docs.md`]: `# Extended Documentation
## Tutorials
## Domain-Specific Guidance`,
[`${contextRoot}/.contextignore`]: `# Build outputs
dist/
build/
# Dependencies
node_modules/
# Test artifacts
**/__snapshots__/
*.test.js.snap
# Temporary files
*.tmp
*.log`
};
const linksToCreate = [
{ source: generatedKgPath, target: `${contextRoot}/knowledge_graph/current.json` }
];
const indexFile = `${contextRoot}/documentation_index.json`;
const indexEntries = [
'index.md',
'docs.md',
'knowledge_graph/current.json'
];
// Placeholder: Simulate file/dir operations
console.log('Simulating creation of directories:', dirsToCreate);
// await fsUtils.ensureDirs(dirsToCreate);
console.log('Simulating creation of files:', Object.keys(filesToCreate));
// for (const [path, content] of Object.entries(filesToCreate)) {
// await fsUtils.writeFile(path, content);
// }
console.log('Simulating creation of links:', linksToCreate);
// for (const link of linksToCreate) {
// await fsUtils.createLink(link.source, link.target);
// }
console.log(`Simulating update of index file: ${indexFile}`);
// await fsUtils.updateJsonFile(indexFile, { entries: indexEntries });
console.log('.context directory setup complete.');
}
}