|
| 1 | +# Configure AI Tools — Design Spec |
| 2 | + |
| 3 | +## Goal |
| 4 | + |
| 5 | +Replace the existing `setupWorkspace` command with `configureAiTools`: a command that lets developers install Cloudinary agent skills from the `cloudinary-devs/skills` GitHub repo into their project, and configure MCP servers. Wired to the "Configure AI Tools" button already present (currently disabled) in the homescreen webview. |
| 6 | + |
| 7 | +## Architecture |
| 8 | + |
| 9 | +- **New file**: `src/commands/configureAiTools.ts` — replaces `src/commands/setupWorkspace.ts` |
| 10 | +- **Update**: `src/commands/registerCommands.ts` — swap `registerSetupWorkspace` for `registerConfigureAiTools` |
| 11 | +- **Update**: `package.json` — rename command ID from `cloudinary.setupWorkspace` to `cloudinary.configureAiTools`, update title to "Configure AI Tools" |
| 12 | +- **Update**: `src/webview/homescreenView.ts` — handle `configureAiTools` message from webview |
| 13 | +- **Update**: `src/webview/client/homescreen.ts` — enable the "Configure AI Tools" button, send `configureAiTools` message on click |
| 14 | + |
| 15 | +## Command Flow |
| 16 | + |
| 17 | +1. User clicks "Configure AI Tools" in the homescreen (or runs the command from the palette) |
| 18 | +2. Require an open workspace folder; show error and return if none |
| 19 | +3. Show multi-select QuickPick: `[Skills ✓, MCP Config ✓]` |
| 20 | +4. If neither selected, return |
| 21 | +5. If **Skills** selected → run skills flow (see below) |
| 22 | +6. If **MCP Config** selected → run MCP config flow (see below) |
| 23 | + |
| 24 | +## Skills Flow |
| 25 | + |
| 26 | +### Fetching the skill list |
| 27 | + |
| 28 | +Use unauthenticated `fetch` against the GitHub Contents API (no token required once the repo is public; during development access requires existing `gh` auth outside the extension): |
| 29 | + |
| 30 | +``` |
| 31 | +GET https://api.github.com/repos/cloudinary-devs/skills/contents/skills |
| 32 | +``` |
| 33 | + |
| 34 | +Returns an array of directory entries. For each entry with `type === "dir"`, fetch its `SKILL.md` in parallel: |
| 35 | + |
| 36 | +``` |
| 37 | +GET https://api.github.com/repos/cloudinary-devs/skills/contents/skills/<name>/SKILL.md |
| 38 | +``` |
| 39 | + |
| 40 | +The response contains `content` (base64-encoded). Decode and parse the YAML frontmatter to extract `name` and `description`. |
| 41 | + |
| 42 | +### Picker |
| 43 | + |
| 44 | +Show a `canPickMany: true` QuickPick. Each item: |
| 45 | +- `label`: skill name (e.g. `cloudinary-docs`) |
| 46 | +- `description`: description from SKILL.md frontmatter |
| 47 | +- All items picked by default |
| 48 | + |
| 49 | +### IDE target selection |
| 50 | + |
| 51 | +After skill selection, ask which AI tool to install for (single-select QuickPick): |
| 52 | + |
| 53 | +| Option | Install location | |
| 54 | +|--------|-----------------| |
| 55 | +| Claude Code | `.claude/skills/<name>/SKILL.md` + `.claude/skills/<name>/references/<file>` | |
| 56 | +| Cursor | `.cursor/rules/<name>.mdc` | |
| 57 | +| VS Code (Copilot) | `.github/copilot-instructions.md` | |
| 58 | + |
| 59 | +### Downloading and writing files |
| 60 | + |
| 61 | +**Claude Code** |
| 62 | +- Write decoded `SKILL.md` content as-is to `.claude/skills/<name>/SKILL.md` |
| 63 | +- Fetch `GET .../contents/skills/<name>/references` (ignore 404 — no references dir) |
| 64 | +- For each file in references, fetch and write to `.claude/skills/<name>/references/<filename>` |
| 65 | + |
| 66 | +**Cursor** |
| 67 | +- Write a single `.cursor/rules/<name>.mdc` file |
| 68 | +- Content: SKILL.md content with `name:` line removed from frontmatter (Cursor only uses `description:`) |
| 69 | + |
| 70 | +**VS Code (Copilot)** |
| 71 | +- Target file: `.github/copilot-instructions.md` |
| 72 | +- Create if absent; append if present |
| 73 | +- Append each selected skill as: |
| 74 | + ``` |
| 75 | + ## <name> |
| 76 | + <skill body content — everything after frontmatter> |
| 77 | + ``` |
| 78 | +- Separate multiple appended skills with a blank line |
| 79 | + |
| 80 | +### Overwrite handling |
| 81 | + |
| 82 | +- Claude Code / Cursor: if the target file already exists, prompt "Overwrite?" before writing (same pattern as existing `setupWorkspace`) |
| 83 | +- VS Code Copilot: always appends; no overwrite prompt needed |
| 84 | + |
| 85 | +## MCP Config Flow |
| 86 | + |
| 87 | +Carry forward the existing `createMCPConfig` logic from `setupWorkspace.ts` unchanged. Uses the same editor-detection (`detectEditor()`) and path mapping for `.cursor/mcp.json`, `.vscode/mcp.json`, etc. |
| 88 | + |
| 89 | +## Success Feedback |
| 90 | + |
| 91 | +After all selected operations complete, show an information message: |
| 92 | +`✅ Configured AI tools: <comma-separated list of what was done>` |
| 93 | + |
| 94 | +Offer an "Open File" action that opens the first written file. |
| 95 | + |
| 96 | +## Error Handling |
| 97 | + |
| 98 | +- No workspace open: `showErrorMessage("Please open a workspace folder first.")` |
| 99 | +- Network failure fetching skill list: `showErrorMessage("Failed to fetch skills: <message>")` |
| 100 | +- Network failure downloading a skill file: skip that file, collect errors, show a warning after completion listing which files failed |
| 101 | + |
| 102 | +## File Map |
| 103 | + |
| 104 | +| Action | File | |
| 105 | +|--------|------| |
| 106 | +| Create | `src/commands/configureAiTools.ts` | |
| 107 | +| Delete | `src/commands/setupWorkspace.ts` | |
| 108 | +| Modify | `src/commands/registerCommands.ts` | |
| 109 | +| Modify | `package.json` | |
| 110 | +| Modify | `src/webview/homescreenView.ts` | |
| 111 | +| Modify | `src/webview/client/homescreen.ts` | |
0 commit comments