diff --git a/README.md b/README.md index ddb2f05..1d06f16 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,8 @@ npx sam-agents npx sam-agents --platform claude # Claude Code npx sam-agents --platform cursor # Cursor IDE npx sam-agents --platform antigravity # Google Antigravity -npx sam-agents --platform all # All platforms +npx sam-agents --platform context7 # Context7 / Universal (.agents/skills/) +npx sam-agents --platform all # All platforms ``` ## Supported Platforms @@ -28,6 +29,7 @@ npx sam-agents --platform all # All platforms | **Claude Code** | `npx sam-agents --platform claude` | `/sam:` commands | | **Cursor** | `npx sam-agents --platform cursor` | `@agent` mentions | | **Antigravity** | `npx sam-agents --platform antigravity` | `/sam-` skills | +| **Context7** | `npx sam-agents --platform context7` | `.agents/skills/` (Universal — Gemini CLI, Copilot, etc.) | ## Why SAM? @@ -37,7 +39,7 @@ npx sam-agents --platform all # All platforms | **BYOA** | Use your own AI subscription | Pay per API call (5-10x cost) | | **Transparency** | Watch agents work in real-time | Black box | | **Autonomous** | Minimal intervention after PRD | Constant hand-holding | -| **Multi-Platform** | Claude Code + Cursor + Antigravity | Single platform lock-in | +| **Multi-Platform** | Claude Code + Cursor + Antigravity + Context7 | Single platform lock-in | ## Available Agents @@ -81,7 +83,8 @@ your-project/ │ └── core/workflows/ # TDD pipeline workflow ├── .claude/commands/sam/ # Claude Code skills ├── .cursor/rules/ # Cursor rules -└── .agent/skills/ # Antigravity skills +├── .agent/skills/ # Antigravity skills +└── .agents/skills/ # Context7 / Universal (Gemini CLI, Copilot, etc.) — see [docs/CONTEXT7.md](docs/CONTEXT7.md) ``` ## Requirements @@ -91,6 +94,7 @@ your-project/ - [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code) - [Cursor](https://cursor.com) - [Google Antigravity](https://antigravity.google) + - A Context7-compatible client (e.g. Gemini CLI, GitHub Copilot) — use `--platform context7`; see [docs/CONTEXT7.md](docs/CONTEXT7.md) for MCP and CLI usage. ## Contributing diff --git a/bin/cli.js b/bin/cli.js index e156353..7cac220 100644 --- a/bin/cli.js +++ b/bin/cli.js @@ -12,7 +12,7 @@ const RESET = '\x1b[0m'; const BOLD = '\x1b[1m'; const DIM = '\x1b[2m'; -const PLATFORMS = ['claude', 'cursor', 'antigravity', 'all']; +const PLATFORMS = ['claude', 'cursor', 'antigravity', 'context7', 'all']; function log(message, color = RESET) { console.log(`${color}${message}${RESET}`); @@ -58,19 +58,21 @@ function showHelp() { log(' Autonomous TDD Agent System\n', CYAN); log(' Usage: npx sam-agents [options] [target-directory]\n'); log(' Options:'); - log(' --platform Target platform: claude, cursor, antigravity, all'); + log(' --platform Target platform: claude, cursor, antigravity, context7, all'); log(' --help, -h Show this help message'); log(' --version, -v Show version number\n'); log(' Examples:'); log(' npx sam-agents Interactive mode'); log(' npx sam-agents --platform cursor Install for Cursor'); log(' npx sam-agents --platform antigravity Install for Antigravity'); - log(' npx sam-agents --platform all Install for all platforms'); + log(' npx sam-agents --platform context7 Install for Context7 (Universal .agents/skills/)'); + log(' npx sam-agents --platform all Install for all platforms'); log(' npx sam-agents ./myapp Install in ./myapp directory\n'); log(' Supported Platforms:'); log(' claude - Claude Code CLI (.claude/commands/)'); log(' cursor - Cursor IDE (.cursor/rules/)'); - log(' antigravity - Google Antigravity IDE (.agent/skills/)\n'); + log(' antigravity - Google Antigravity IDE (.agent/skills/)'); + log(' context7 - Context7 / Universal Agent Skills (.agents/skills/) — Gemini CLI, Copilot, etc.\n'); } function generateCursorRules(samDir, targetDir) { @@ -343,6 +345,87 @@ Provide a PRD or feature description to start the autonomous TDD pipeline. return skillsCount; } +function generateContext7Skills(samDir, targetDir) { + const skillsDir = path.join(targetDir, '.agents', 'skills'); + if (!fs.existsSync(skillsDir)) { + fs.mkdirSync(skillsDir, { recursive: true }); + } + + const agents = [ + { name: 'sam-orchestrator', file: 'core/agents/sam-master.md', display: 'SAM Orchestrator', description: 'Orchestrate autonomous TDD pipeline, coordinate SAM agents, manage RED-GREEN-REFACTOR workflow' }, + { name: 'sam-atlas', file: 'agents/architect.md', display: 'Atlas - System Architect', description: 'Architecture review, PRD validation, technical design, system design decisions' }, + { name: 'sam-titan', file: 'agents/test.md', display: 'Titan - Test Architect', description: 'Write failing tests, RED phase of TDD, test architecture, acceptance criteria validation' }, + { name: 'sam-dyna', file: 'agents/dev.md', display: 'Dyna - Developer', description: 'Implement code to pass tests, GREEN phase of TDD, minimal implementation' }, + { name: 'sam-argus', file: 'agents/reviewer.md', display: 'Argus - Code Reviewer', description: 'Code review, REFACTOR phase of TDD, quality improvement, best practices' }, + { name: 'sam-sage', file: 'agents/tech-writer.md', display: 'Sage - Technical Writer', description: 'Generate documentation, technical writing, API docs, README creation' }, + { name: 'sam-iris', file: 'agents/ux-designer.md', display: 'Iris - UX Designer', description: 'UX validation, user experience review, interface design feedback' }, + { name: 'sam-cosmo', file: 'agents/css-reviewer.md', display: 'Cosmo - CSS Consistency Reviewer', description: 'CSS consistency review for web apps, spacing scale violations, hardcoded values, styling anti-patterns' } + ]; + + let skillsCount = 0; + for (const agent of agents) { + const agentPath = path.join(samDir, agent.file); + if (fs.existsSync(agentPath)) { + const content = fs.readFileSync(agentPath, 'utf8'); + const skillDir = path.join(skillsDir, agent.name); + const referencesDir = path.join(skillDir, 'references'); + if (!fs.existsSync(referencesDir)) fs.mkdirSync(referencesDir, { recursive: true }); + const skillContent = `--- +name: ${agent.name} +description: ${agent.description} +--- + +# ${agent.display} + +This is a SAM (Smart Agent Manager) agent for autonomous TDD development. + +## When to Use +Invoke this skill when you need help with: ${agent.description.toLowerCase()}. + +## Instructions +Load and follow the detailed agent instructions from the references folder. + +See: references/agent.md for complete agent definition. +`; + fs.writeFileSync(path.join(skillDir, 'SKILL.md'), skillContent); + fs.writeFileSync(path.join(referencesDir, 'agent.md'), content); + skillsCount++; + } + } + + const pipelineDir = path.join(skillsDir, 'sam-tdd-pipeline'); + const pipelineRefsDir = path.join(pipelineDir, 'references'); + if (!fs.existsSync(pipelineRefsDir)) fs.mkdirSync(pipelineRefsDir, { recursive: true }); + const pipelineSkill = `--- +name: sam-tdd-pipeline +description: Autonomous TDD pipeline - transform PRD into working tested code using RED-GREEN-REFACTOR methodology +--- + +# SAM Autonomous TDD Pipeline + +This skill orchestrates a complete TDD development workflow using specialized SAM agents. + +## When to Use +Invoke this skill when you want to: transform a PRD into working, tested code; follow strict TDD (RED-GREEN-REFACTOR); use autonomous AI agents for development. + +## The Pipeline +### Phase 1: Validate PRD — sam-atlas, sam-iris +### Phase 2: Generate Stories +### Phase 3: TDD Loop — RED (sam-titan), GREEN (sam-dyna), REFACTOR (sam-argus), UI (sam-iris), CSS (sam-cosmo) +### Phase 4: Complete — sam-sage + +## Available Agents +sam-orchestrator, sam-atlas, sam-titan, sam-dyna, sam-argus, sam-cosmo, sam-sage, sam-iris +`; + fs.writeFileSync(path.join(pipelineDir, 'SKILL.md'), pipelineSkill); + skillsCount++; + const workflowPath = path.join(samDir, 'core/workflows/autonomous-tdd/workflow.md'); + if (fs.existsSync(workflowPath)) { + fs.copyFileSync(workflowPath, path.join(pipelineRefsDir, 'workflow.md')); + } + return skillsCount; +} + async function promptPlatform() { const rl = readline.createInterface({ input: process.stdin, @@ -356,10 +439,11 @@ async function promptPlatform() { log(' 1) Claude Code ' + DIM + '(.claude/commands/)' + RESET); log(' 2) Cursor ' + DIM + '(.cursor/rules/)' + RESET); log(' 3) Antigravity ' + DIM + '(.agent/skills/)' + RESET); - log(' 4) All ' + DIM + '(install for all platforms)' + RESET); + log(' 4) Context7 ' + DIM + '(.agents/skills/ — Universal: Gemini CLI, Copilot, etc.)' + RESET); + log(' 5) All ' + DIM + '(install for all platforms)' + RESET); log(''); - rl.question(' Enter choice [1-4]: ', (answer) => { + rl.question(' Enter choice [1-5]: ', (answer) => { rl.close(); const choice = answer.trim(); @@ -369,10 +453,11 @@ async function promptPlatform() { resolve('cursor'); } else if (choice === '3' || choice.toLowerCase() === 'antigravity') { resolve('antigravity'); - } else if (choice === '4' || choice.toLowerCase() === 'both' || choice.toLowerCase() === 'all') { + } else if (choice === '4' || choice.toLowerCase() === 'context7' || choice.toLowerCase() === 'context') { + resolve('context7'); + } else if (choice === '5' || choice.toLowerCase() === 'both' || choice.toLowerCase() === 'all') { resolve('all'); } else if (choice === '') { - // Default to claude resolve('claude'); } else { log('\n Invalid choice. Defaulting to Claude Code.\n', YELLOW); @@ -426,6 +511,11 @@ function install(platform, targetDir) { log(` ✓ Generated .agent/skills/ (${antigravitySkillsCount} skills)`, GREEN); } + if (platform === 'context7' || platform === 'all') { + const context7SkillsCount = generateContext7Skills(samDir, targetDir); + log(` ✓ Generated .agents/skills/ (${context7SkillsCount} skills)`, GREEN); + } + log('\n' + BOLD + ' Installation complete!' + RESET + '\n'); if (platform === 'claude' || platform === 'all') { @@ -467,6 +557,12 @@ function install(platform, targetDir) { log(' /sam-tdd-pipeline - Full TDD Pipeline\n'); } + if (platform === 'context7' || platform === 'all') { + log(' Context7 / Universal (.agents/skills/):', CYAN); + log(' Skills installed for Gemini CLI, GitHub Copilot, and other Context7-compatible clients.'); + log(' See docs/CONTEXT7.md for MCP and Context7 CLI usage.\n'); + } + if (platform === 'claude' || platform === 'all') { log(' Restart Claude Code to load the new skills.', YELLOW); } @@ -476,6 +572,9 @@ function install(platform, targetDir) { if (platform === 'antigravity' || platform === 'all') { log(' Antigravity will auto-detect skills in .agent/skills/', YELLOW); } + if (platform === 'context7' || platform === 'all') { + log(' Context7 clients use skills in .agents/skills/ — see docs/CONTEXT7.md', YELLOW); + } log(''); } diff --git a/docs/CONTEXT7.md b/docs/CONTEXT7.md new file mode 100644 index 0000000..792372f --- /dev/null +++ b/docs/CONTEXT7.md @@ -0,0 +1,69 @@ +# Using SAM with Context7 + +SAM can install its agents and TDD pipeline as **Context7 / Universal Agent Skills** so you can use them with the Context7 MCP server, Context7 CLI, and any client that supports the [Agent Skills](https://agentskills.io/) spec (e.g. Gemini CLI, GitHub Copilot, and other Context7-compatible tools). + +## Install SAM for Context7 + +Install SAM skills into the Universal path (`.agents/skills/`): + +```bash +npx sam-agents --platform context7 +# or into a specific directory: +npx sam-agents --platform context7 ./my-project +``` + +This creates `.agents/skills/` in your project with one directory per SAM agent and the `sam-tdd-pipeline` workflow, each containing a `SKILL.md` (Agent Skills format) and a `references/` folder with the full agent definition. + +## Where skills are installed + +| Target | Path | Used by | +|---------------|--------------------|--------| +| Project | `.agents/skills/` | Context7 CLI, Gemini CLI, GitHub Copilot, and other Universal clients | +| (Global) | `~/.config/agents/skills/` | When using Context7 CLI with `--global` | + +SAM only writes to the **project** directory (`.agents/skills/`). For global installs, use the [Context7 CLI](https://context7.com/docs/skills) after SAM has published skills to a registry, or symlink/copy `.agents/skills/` into `~/.config/agents/skills/` if your client reads from there. + +## Using Context7 MCP server with SAM + +The [Context7 MCP server](https://context7.com/docs) provides up-to-date documentation and code examples for libraries. You can use it **together** with SAM: + +1. **Install SAM skills** in the same project: + ```bash + npx sam-agents --platform context7 + ``` +2. **Enable the Context7 MCP server** in your IDE (Cursor, etc.) so the model can call `query-docs` / `resolve-library-id` for library docs. +3. When you run the SAM TDD pipeline or an agent (e.g. Dyna, Argus), the model can use Context7 tools to look up framework or library docs as needed. + +No extra config is required: SAM skills live in `.agents/skills/`, and Context7 MCP runs as a separate server. Your AI assistant can use both SAM instructions and Context7 documentation in the same session. + +## How to add Context7 support to your own project + +If you maintain a tool (like SAM) that wants to ship skills for Context7-compatible clients: + +1. **Use the Agent Skills format** + - Each skill is a directory with at least a `SKILL.md` file. + - `SKILL.md` must have YAML frontmatter with `name` and `description`, then markdown body for the assistant. + +2. **Install path** + - For **Universal** clients (Context7 CLI, Gemini CLI, Copilot, etc.): write skills to **`.agents/skills/`** in the project (or document `~/.config/agents/skills/` for global). + - Other clients: Context7 docs list [Claude Code `.claude/skills/`, Cursor `.cursor/skills/`, Antigravity `.agent/skills/`](https://context7.com/docs/skills#supported-clients). + +3. **Structure** + ``` + .agents/skills/ + ├── my-skill/ + │ ├── SKILL.md # required: name, description + instructions + │ └── references/ # optional: extra files the skill can refer to + │ └── agent.md + └── my-other-skill/ + └── SKILL.md + ``` + +4. **Publishing to Context7 registry (optional)** + To allow installs via `npx ctx7 skills install /org/repo skill-name`, your repo should follow the [Context7 Skills Registry](https://context7.com/docs/skills) expectations (skills in a standard layout so the registry can index them). + +## References + +- [Context7 Skills docs](https://context7.com/docs/skills) — install, search, and supported clients +- [Agent Skills spec](https://agentskills.io/) — open standard for skill format +- [Context7 CLI](https://context7.com/docs/skills#cli-commands) — `npx ctx7 skills search`, `npx ctx7 skills install`, etc.