diff --git a/agents/architect.yaml b/agents/architect.yaml index ad7e4f0723..65dd20f042 100644 --- a/agents/architect.yaml +++ b/agents/architect.yaml @@ -8,4 +8,4 @@ capabilities: optimizations: - context-caching - memory-persistence -createdAt: "2026-02-07T16:18:31.586Z" +createdAt: "2026-02-07T16:20:39.602Z" diff --git a/agents/coder.yaml b/agents/coder.yaml index 32e1f316b9..6d0051c5ec 100644 --- a/agents/coder.yaml +++ b/agents/coder.yaml @@ -8,4 +8,4 @@ capabilities: optimizations: - flash-attention - token-reduction -createdAt: "2026-02-07T16:18:30.874Z" +createdAt: "2026-02-07T16:20:39.602Z" diff --git a/agents/reviewer.yaml b/agents/reviewer.yaml index 42e86ba3ad..3c2fa0f680 100644 --- a/agents/reviewer.yaml +++ b/agents/reviewer.yaml @@ -7,4 +7,4 @@ capabilities: - best-practices optimizations: - incremental-analysis -createdAt: "2026-02-07T16:18:33.416Z" +createdAt: "2026-02-07T16:20:39.602Z" diff --git a/agents/security-architect.yaml b/agents/security-architect.yaml index 2e88bc8d8f..bcc75f996e 100644 --- a/agents/security-architect.yaml +++ b/agents/security-architect.yaml @@ -7,4 +7,4 @@ capabilities: - security-review optimizations: - pattern-matching -createdAt: "2026-02-07T16:18:33.218Z" +createdAt: "2026-02-07T16:20:39.602Z" diff --git a/agents/tester.yaml b/agents/tester.yaml index d01dc8d13d..c3bf364893 100644 --- a/agents/tester.yaml +++ b/agents/tester.yaml @@ -7,4 +7,4 @@ capabilities: - coverage optimizations: - parallel-execution -createdAt: "2026-02-07T16:18:33.006Z" +createdAt: "2026-02-07T16:20:39.602Z" diff --git a/v3/@claude-flow/codex/src/generators/agents-md.ts b/v3/@claude-flow/codex/src/generators/agents-md.ts new file mode 100644 index 0000000000..95658ef7f6 --- /dev/null +++ b/v3/@claude-flow/codex/src/generators/agents-md.ts @@ -0,0 +1,347 @@ +/** + * @claude-flow/codex - AGENTS.md Generator + * + * Generates AGENTS.md files for OpenAI Codex CLI + * Following the Agentic AI Foundation standard + */ + +import type { AgentsMdOptions, AgentsMdTemplate } from '../types.js'; +import { BUILT_IN_SKILLS } from '../templates/index.js'; + +/** + * Generate an AGENTS.md file based on the provided options + */ +export async function generateAgentsMd(options: AgentsMdOptions): Promise { + const template = options.template ?? 'default'; + + switch (template) { + case 'minimal': + return generateMinimal(options); + case 'full': + return generateFull(options); + case 'enterprise': + return generateEnterprise(options); + case 'default': + default: + return generateDefault(options); + } +} + +/** + * Generate minimal AGENTS.md template + */ +function generateMinimal(options: AgentsMdOptions): string { + const { projectName, buildCommand = 'npm run build', testCommand = 'npm test' } = options; + + return `# ${projectName} + +## Setup +\`\`\`bash +npm install && ${buildCommand} +\`\`\` + +## Test +\`\`\`bash +${testCommand} +\`\`\` + +## Code Standards +- Files under 500 lines +- No hardcoded secrets +- Input validation at boundaries + +## Skills +- \`$swarm-orchestration\` - Multi-agent tasks +- \`$memory-management\` - Pattern storage + +## Security +- Never commit .env files +- Validate all inputs +- Prevent path traversal +`; +} + +/** + * Generate default AGENTS.md template + */ +function generateDefault(options: AgentsMdOptions): string { + const { + projectName, + description = 'A Claude Flow powered project', + techStack = 'TypeScript, Node.js', + buildCommand = 'npm run build', + testCommand = 'npm test', + devCommand = 'npm run dev', + skills = ['swarm-orchestration', 'memory-management', 'sparc-methodology', 'security-audit'], + } = options; + + const skillsTable = skills + .map((skill) => { + const info = BUILT_IN_SKILLS[skill as keyof typeof BUILT_IN_SKILLS]; + return info + ? `| \`$${skill}\` | ${info.description} |` + : `| \`$${skill}\` | Custom skill |`; + }) + .join('\n'); + + return `# ${projectName} + +> Multi-agent orchestration framework for agentic coding + +## Project Overview + +${description} + +**Tech Stack**: ${techStack} +**Architecture**: Domain-Driven Design with bounded contexts + +## Quick Start + +### Installation +\`\`\`bash +npm install +\`\`\` + +### Build +\`\`\`bash +${buildCommand} +\`\`\` + +### Test +\`\`\`bash +${testCommand} +\`\`\` + +### Development +\`\`\`bash +${devCommand} +\`\`\` + +## Agent Coordination + +### Swarm Configuration + +This project uses hierarchical swarm coordination for complex tasks: + +| Setting | Value | Purpose | +|---------|-------|---------| +| Topology | \`hierarchical\` | Queen-led coordination (anti-drift) | +| Max Agents | 8 | Optimal team size | +| Strategy | \`specialized\` | Clear role boundaries | +| Consensus | \`raft\` | Leader-based consistency | + +### When to Use Swarms + +**Invoke swarm for:** +- Multi-file changes (3+ files) +- New feature implementation +- Cross-module refactoring +- API changes with tests +- Security-related changes +- Performance optimization + +**Skip swarm for:** +- Single file edits +- Simple bug fixes (1-2 lines) +- Documentation updates +- Configuration changes + +### Available Skills + +Use \`$skill-name\` syntax to invoke: + +| Skill | Use Case | +|-------|----------| +${skillsTable} + +### Agent Types + +| Type | Role | Use Case | +|------|------|----------| +| \`researcher\` | Requirements analysis | Understanding scope | +| \`architect\` | System design | Planning structure | +| \`coder\` | Implementation | Writing code | +| \`tester\` | Test creation | Quality assurance | +| \`reviewer\` | Code review | Security and quality | + +## Code Standards + +### File Organization +- **NEVER** save to root folder +- \`/src\` - Source code files +- \`/tests\` - Test files +- \`/docs\` - Documentation +- \`/config\` - Configuration files + +### Quality Rules +- Files under 500 lines +- No hardcoded secrets +- Input validation at boundaries +- Typed interfaces for public APIs +- TDD London School (mock-first) preferred + +### Commit Messages +\`\`\` +(): + +[optional body] + +Co-Authored-By: claude-flow +\`\`\` + +Types: \`feat\`, \`fix\`, \`docs\`, \`style\`, \`refactor\`, \`perf\`, \`test\`, \`chore\` + +## Security + +### Critical Rules +- NEVER commit secrets, credentials, or .env files +- NEVER hardcode API keys +- Always validate user input +- Use parameterized queries for SQL +- Sanitize output to prevent XSS + +### Path Security +- Validate all file paths +- Prevent directory traversal (../) +- Use absolute paths internally + +## Memory System + +### Storing Patterns +\`\`\`bash +npx @claude-flow/cli memory store \\ + --key "pattern-name" \\ + --value "pattern description" \\ + --namespace patterns +\`\`\` + +### Searching Memory +\`\`\`bash +npx @claude-flow/cli memory search \\ + --query "search terms" \\ + --namespace patterns +\`\`\` + +## Links + +- Documentation: https://github.com/ruvnet/claude-flow +- Issues: https://github.com/ruvnet/claude-flow/issues +`; +} + +/** + * Generate full AGENTS.md template with all sections + */ +function generateFull(options: AgentsMdOptions): string { + const base = generateDefault(options); + + const additionalSections = ` +## Performance Targets + +| Metric | Target | Notes | +|--------|--------|-------| +| HNSW Search | 150x-12,500x faster | Vector operations | +| Memory Reduction | 50-75% | Int8 quantization | +| MCP Response | <100ms | API latency | +| CLI Startup | <500ms | Cold start | + +## Testing + +### Running Tests +\`\`\`bash +# Unit tests +npm test + +# Integration tests +npm run test:integration + +# Coverage +npm run test:coverage +\`\`\` + +### Test Philosophy +- TDD London School (mock-first) +- Unit tests for business logic +- Integration tests for boundaries +- E2E tests for critical paths + +## MCP Integration + +Claude Flow exposes tools via MCP: + +\`\`\`bash +# Start MCP server +npx @claude-flow/cli mcp start +\`\`\` + +### Available Tools +- \`swarm_init\` - Initialize swarm coordination +- \`agent_spawn\` - Spawn new agents +- \`memory_store\` - Store in AgentDB +- \`memory_search\` - Semantic search +- \`task_orchestrate\` - Task coordination + +## Hooks System + +Claude Flow uses hooks for automation: + +| Hook | Purpose | +|------|---------| +| \`pre-task\` | Get context before starting | +| \`post-task\` | Record completion for learning | +| \`pre-edit\` | Validate before file changes | +| \`post-edit\` | Train neural patterns | + +### Example +\`\`\`bash +npx @claude-flow/cli hooks pre-task \\ + --description "implementing authentication" +\`\`\` +`; + + return base + additionalSections; +} + +/** + * Generate enterprise AGENTS.md template with governance + */ +function generateEnterprise(options: AgentsMdOptions): string { + const full = generateFull(options); + + const enterpriseSections = ` +## Governance + +### Approval Workflow +All significant changes require: +1. Code review by designated reviewer +2. Security scan passing +3. Test coverage > 80% +4. Documentation update + +### Audit Trail +All agent actions are logged to: +- \`/logs/agent-actions.log\` +- Central audit system (if configured) + +### Compliance +- SOC2 compatible logging +- GDPR data handling patterns +- PCI-DSS security controls (if applicable) + +## Incident Response + +### On Security Issue +1. Immediately stop affected agents +2. Isolate compromised resources +3. Document timeline +4. Notify security team + +### On Production Bug +1. Roll back if safe +2. Document reproduction steps +3. Create hotfix branch +4. Deploy with expedited review +`; + + return full + enterpriseSections; +}