@codemafia0000/d0
Version:
Claude Multi-Agent Automated Development AI - Revolutionary development environment where multiple AI agents collaborate to automate software development
78 lines (66 loc) ⢠2.86 kB
JavaScript
const fs = require('fs');
const path = require('path');
const chalk = require('chalk');
const CONSTANTS = require('../constants');
const { isProjectSetup } = require('../setup/project-setup');
// Context command handler
function handleContext(agent) {
if (!isProjectSetup()) {
console.log(chalk.red('ā Claude agents environment not found.'));
console.log(chalk.yellow('Run "d0 init" first.'));
return;
}
if (!agent) {
// Show all available context files
console.log(chalk.blue('š Available Agent Contexts'));
console.log('ā'.repeat(40));
const contextDir = CONSTANTS.getTmpPath('context');
if (!fs.existsSync(contextDir)) {
console.log(chalk.yellow('š No context files found. Send a message to an agent first.'));
return;
}
const contextFiles = fs.readdirSync(contextDir);
if (contextFiles.length === 0) {
console.log(chalk.yellow('š No context files found. Send a message to an agent first.'));
return;
}
contextFiles.forEach(file => {
const agentName = file.replace('_context.md', '').toUpperCase();
const filePath = path.join(contextDir, file);
const stats = fs.statSync(filePath);
console.log(chalk.green(` ⢠${agentName}`));
console.log(chalk.gray(` File: ${file}`));
console.log(chalk.gray(` Updated: ${stats.mtime.toLocaleString()}`));
console.log(chalk.cyan(` View: d0 context ${agentName.toLowerCase()}`));
console.log('');
});
console.log(chalk.yellow('š” Usage:'));
console.log(chalk.gray(' d0 context boss - View BOSS context'));
console.log(chalk.gray(' d0 context worker1 - View WORKER1 context'));
return;
}
// Show specific agent context
const contextFile = CONSTANTS.getTmpPath(`context/${agent.toLowerCase()}_context.md`);
if (!fs.existsSync(contextFile)) {
console.log(chalk.red(`ā Context file not found for ${agent.toUpperCase()}`));
console.log(chalk.yellow('Send a message to this agent first to generate context.'));
console.log(chalk.gray(`Expected file: ${contextFile}`));
return;
}
const content = fs.readFileSync(contextFile, 'utf8');
const stats = fs.statSync(contextFile);
console.log(chalk.blue(`š Context for ${agent.toUpperCase()}`));
console.log(chalk.gray(`File: ${contextFile}`));
console.log(chalk.gray(`Updated: ${stats.mtime.toLocaleString()}`));
console.log('ā'.repeat(60));
console.log(content);
console.log('ā'.repeat(60));
console.log(chalk.yellow('\nš To start working as this agent:'));
console.log(chalk.gray(' 1. Open a new terminal'));
console.log(chalk.gray(` 2. cd ${CONSTANTS.PROJECT_ROOT}`));
console.log(chalk.gray(' 3. claude'));
console.log(chalk.cyan(` 4. Copy and paste the context above`));
}
module.exports = {
handleContext
};