initialize_agent_workspace
Set up AI agent development workspace with template files and project context for coding projects.
Instructions
Initialize AI agent workspace with template files and context
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | Path to the project directory | |
| projectName | Yes | Name of the project | |
| techStack | No | Optional tech stack configuration |
Implementation Reference
- Core handler function that initializes the agent workspace by creating and customizing essential template files like AGENT-CODING-TEMPLATE.md, AGENT-CONTEXT.md, AGENT-MEMORY.md, .context7.yaml, and CODEBASE-CONTEXT.md.export async function initializeAgentWorkspace( config: WorkspaceConfig ): Promise<InitializationResult> { const result: InitializationResult = { success: false, filesCreated: [], configuration: { templatePath: '', contextPath: '', memoryPath: '', context7Path: '', }, nextSteps: [], message: '', }; try { // Ensure project directory exists if (!existsSync(config.projectPath)) { mkdirSync(config.projectPath, { recursive: true }); } // Define file paths const templatePath = join(config.projectPath, 'AGENT-CODING-TEMPLATE.md'); const contextPath = join(config.projectPath, 'AGENT-CONTEXT.md'); const memoryPath = join(config.projectPath, 'AGENT-MEMORY.md'); const context7Path = join(config.projectPath, '.context7.yaml'); const codebaseContextPath = join(config.projectPath, 'CODEBASE-CONTEXT.md'); // Copy and customize AGENT-CODING-TEMPLATE.md if (!existsSync(templatePath)) { const templateContent = readFileSync( join(__dirname, '../../../AGENT-CODING-TEMPLATE.md'), 'utf-8' ); const customizedTemplate = customizeTemplate(templateContent, config); writeFileSync(templatePath, customizedTemplate); result.filesCreated.push('AGENT-CODING-TEMPLATE.md'); } // Copy and customize AGENT-CONTEXT.md if (!existsSync(contextPath)) { const contextContent = readFileSync( join(__dirname, '../../../AGENT-CONTEXT.md'), 'utf-8' ); const customizedContext = initializeContext(contextContent, config); writeFileSync(contextPath, customizedContext); result.filesCreated.push('AGENT-CONTEXT.md'); } // Copy AGENT-MEMORY.md if (!existsSync(memoryPath)) { const memoryContent = readFileSync( join(__dirname, '../../../AGENT-MEMORY.md'), 'utf-8' ); writeFileSync(memoryPath, memoryContent); result.filesCreated.push('AGENT-MEMORY.md'); } // Copy and customize .context7.yaml if (!existsSync(context7Path)) { const context7Content = readFileSync( join(__dirname, '../../../.context7.yaml'), 'utf-8' ); const customizedContext7 = customizeContext7(context7Content, config); writeFileSync(context7Path, customizedContext7); result.filesCreated.push('.context7.yaml'); } // Create initial CODEBASE-CONTEXT.md if it doesn't exist if (!existsSync(codebaseContextPath)) { const codebaseContext = generateInitialCodebaseContext(config); writeFileSync(codebaseContextPath, codebaseContext); result.filesCreated.push('CODEBASE-CONTEXT.md'); } // Set configuration paths result.configuration = { templatePath, contextPath, memoryPath, context7Path, }; // Define next steps result.nextSteps = [ '1. Review AGENT-CODING-TEMPLATE.md for your mission briefing', '2. Check CODEBASE-CONTEXT.md and customize for your project', '3. Update .context7.yaml with your specific library versions', '4. Start development with pre-flight checklist from template', '5. Use tracking tools to monitor performance', ]; result.success = true; result.message = `Workspace initialized successfully for ${config.projectName}. Agent memory system is now active!`; } catch (error) { result.success = false; result.message = `Failed to initialize workspace: ${error}`; } return result; }
- src/tools/index.ts:142-163 (handler)Dispatch handler in the main tool router that parses input arguments with Zod and delegates to the initializeAgentWorkspace implementation.case 'initialize_agent_workspace': { const params = z.object({ projectPath: z.string(), projectName: z.string(), techStack: z.object({ language: z.string().optional(), framework: z.string().optional(), uiLibrary: z.string().optional(), testFramework: z.string().optional(), }).optional(), }).parse(args); const result = await initializeAgentWorkspace(params); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- JSON schema definition for the tool's input parameters, used for validation and tool listing.{ name: 'initialize_agent_workspace', description: 'Initialize AI agent workspace with template files and context', inputSchema: { type: 'object', properties: { projectPath: { type: 'string', description: 'Path to the project directory', }, projectName: { type: 'string', description: 'Name of the project', }, techStack: { type: 'object', properties: { language: { type: 'string' }, framework: { type: 'string' }, uiLibrary: { type: 'string' }, testFramework: { type: 'string' }, }, description: 'Optional tech stack configuration', }, }, required: ['projectPath', 'projectName'], }, },
- src/tools/index.ts:27-30 (registration)Registration of the tool list handler that returns all tool definitions, including initialize_agent_workspace.server.setRequestHandler(ListToolsRequestSchema, async () => { console.error(`Handling tools/list request, returning ${toolDefinitions.length} tools`); return { tools: toolDefinitions }; });
- Helper function to customize the AGENT-CODING-TEMPLATE.md with project-specific details.function customizeTemplate(template: string, config: WorkspaceConfig): string { const now = new Date().toISOString(); return template .replace(/\[PROJECT_NAME\]/g, config.projectName) .replace(/\[PROJECT_PATH\]/g, config.projectPath) .replace(/\[DETECTED_LANGUAGE\]/g, config.techStack?.language || 'typescript') .replace(/\[DETECTED_FRAMEWORK\]/g, config.techStack?.framework || 'react') .replace(/\[DETECTED_UI_LIBRARY\]/g, config.techStack?.uiLibrary || 'tailwindcss') .replace(/\[DETECTED_TEST_FRAMEWORK\]/g, config.techStack?.testFramework || 'jest') .replace(/\[AUTO_UPDATE\]/g, now) .replace(/\[TIMESTAMP\]/g, now); }