|
| 1 | +import { query } from "@anthropic-ai/claude-agent-sdk"; |
| 2 | + |
| 3 | +const toolName = 'uv'; |
| 4 | +const toolHomepage = 'https://docs.astral.sh/uv/#projects' |
| 5 | + |
| 6 | +const researchResults = [ |
| 7 | +`Here's a summary of the research and proposed design: |
| 8 | +
|
| 9 | +--- |
| 10 | +
|
| 11 | +## \`uv\` Resource Design |
| 12 | +
|
| 13 | +### What was researched |
| 14 | +- **uv** is a blazing-fast Python tool from Astral that replaces pip, pyenv, pipx, poetry, and virtualenv in one binary. |
| 15 | +
|
| 16 | +--- |
| 17 | +
|
| 18 | +### Installation |
| 19 | +| Platform | Method | |
| 20 | +|---|---| |
| 21 | +| macOS | \`brew install uv\` (Homebrew, preferred since Codify users likely have it) | |
| 22 | +| Linux | \`curl -LsSf https://astral.sh/uv/install.sh \\| sh\` with \`UV_NO_MODIFY_PATH=1\`, then manually add \`~/.local/bin\` to shell rc | |
| 23 | +
|
| 24 | +No Rust or Python required. No other OS-level dependencies beyond curl on Linux. |
| 25 | +
|
| 26 | +--- |
| 27 | +
|
| 28 | +### Proposed Resources |
| 29 | +
|
| 30 | +**One resource: \`uv\`** (located at \`src/resources/python/uv/\`) |
| 31 | +
|
| 32 | +| Parameter | Type | Description | |
| 33 | +|---|---|---| |
| 34 | +| \`pythonVersions\` | Stateful \`string[]\` | Python versions to install via \`uv python install\` (e.g. \`["3.12", "3.11"]\`) | |
| 35 | +| \`tools\` | Stateful \`string[]\` | CLI tools installed globally via \`uv tool install\` (e.g. \`["ruff", "black"]\`) | |
| 36 | +
|
| 37 | +This follows the same pattern as **pyenv** (install tool + manage Python versions) and **NVM** (install tool + manage versions as stateful parameter). |
| 38 | +
|
| 39 | +--- |
| 40 | +
|
| 41 | +### Key Design Decisions |
| 42 | +
|
| 43 | +1. **Homebrew dependency on macOS** — Declared via \`dependencies: ['homebrew']\` mirroring the \`asdf\` resource pattern. |
| 44 | +2. **Two stateful parameters** — \`pythonVersions\` (parsed from \`uv python list --only-installed\`) and \`tools\` (parsed from \`uv tool list\`). |
| 45 | +3. **Version prefix matching** — Desired \`"3.12"\` matches installed \`"3.12.3"\` using \`startsWith\` in \`isElementEqual\`. |
| 46 | +4. **No sub-resources** — Unlike asdf (which has \`asdf-plugin\` and \`asdf-install\` sub-resources), uv's tool and Python management is simple enough to handle as stateful parameters on the main resource. |
| 47 | +` |
| 48 | +]; |
| 49 | + |
| 50 | +// for await (const message of query({ |
| 51 | +// prompt: |
| 52 | +// `Research and design a Codify resource for ${toolName} (the homepage is: ${toolHomepage}) |
| 53 | +// |
| 54 | +// The research should include: |
| 55 | +// ** The installation method ** |
| 56 | +// - The installation method for the tool of application (in the case ${toolName}) |
| 57 | +// - The installation method should be the most standard installation method. |
| 58 | +// - Find the installation instructions for both macOS and Linux. |
| 59 | +// |
| 60 | +// ** Dependencies ** |
| 61 | +// - Any dependencies or prerequisites for installation |
| 62 | +// |
| 63 | +// ** Configuration ** |
| 64 | +// - Any configuration options or settings for the tool |
| 65 | +// - Any settings that we want the user to manage (which will later be exposed as parameters in the Codify resource) |
| 66 | +// - The default values for these settings |
| 67 | +// |
| 68 | +// ** Usages ** |
| 69 | +// - Examples of how the tool can be used |
| 70 | +// - Any common use cases or scenarios |
| 71 | +// - Any use case we want to manage via the Codify resource or sub-resources or stateful parameters |
| 72 | +// - For example: |
| 73 | +// - The homebrew resource installs homebrew but it also has the formulae and casks stateful parameters that manage installed packages. |
| 74 | +// - The asdf resource installs asdf, a tool version manager, but it also has the plugins stateful parameter that manages installed plugins. |
| 75 | +// - The asdf resource has sub resources for installing tool plugins and versions. |
| 76 | +// |
| 77 | +// The purpose of this research is to be used later by Claude to create the resources needed in code. Format the answer so that |
| 78 | +// it can be easily understood by Claude. |
| 79 | +// `, |
| 80 | +// options: { |
| 81 | +// settingSources: ['project'], |
| 82 | +// allowedTools: ["WebSearch", "WebFetch"], |
| 83 | +// mcpServers: {}, |
| 84 | +// permissionMode: 'plan', |
| 85 | +// cwd: '../' |
| 86 | +// } |
| 87 | +// })) { |
| 88 | +// // Print human-readable output |
| 89 | +// if (message.type === "assistant" && message.message?.content) { |
| 90 | +// for (const block of message.message.content) { |
| 91 | +// if ("text" in block) { |
| 92 | +// console.log(block.text); // Claude's reasoning |
| 93 | +// researchResults.push(block.text); |
| 94 | +// } else if ("name" in block) { |
| 95 | +// console.log(`Tool: ${block.name}`); // Tool being called |
| 96 | +// } |
| 97 | +// } |
| 98 | +// } else if (message.type === "result") { |
| 99 | +// console.log(`Done: ${message.subtype}`); // Final result |
| 100 | +// } |
| 101 | +// } |
| 102 | + |
| 103 | +// Checkout a new git branch |
| 104 | +// Launch a new docker container |
| 105 | + |
| 106 | +for await (const message of query({ |
| 107 | + prompt: `Use the research results to design a Codify resource for ${toolName} (the homepage is: ${toolHomepage}). |
| 108 | + |
| 109 | +Guidelines: |
| 110 | +- Follow the other tools in the project under @src/resources/** as a guideline |
| 111 | +- Prefer to use Zod over JSON Schema |
| 112 | +- Remember to write tests, follow the other test examples under @test/** as a guideline |
| 113 | +- Keep the resource simple and focused on the core functionality of ${toolName} |
| 114 | +- Use the research to guide the software design |
| 115 | +- Remember to split up functions if they get too long and complicated to understand. Create helper functions instead with idiomatic names. |
| 116 | +
|
| 117 | +Steps: |
| 118 | +- Write code to fulfill the requirements laid out in the research. |
| 119 | +- Add the resource to @src/index.ts so that it is visible |
| 120 | +- Write tests for the code to test ${toolName} |
| 121 | +- Ensure typescript is correct using tsx |
| 122 | +- Run the test using 'npm run test:integration:dev -- $PathToTheTestFile' |
| 123 | +- Do not try to test the code in any other ways. It may brick the current computer if you do. |
| 124 | +
|
| 125 | +Research: |
| 126 | +${researchResults.join('\n\n')} |
| 127 | + `, |
| 128 | + options: { |
| 129 | + settingSources: ['project'], |
| 130 | + permissionMode: "bypassPermissions", // Auto-approve file edits |
| 131 | + cwd: '../' |
| 132 | + } |
| 133 | +})) { |
| 134 | + // Print human-readable output |
| 135 | + if (message.type === "assistant" && message.message?.content) { |
| 136 | + for (const block of message.message.content) { |
| 137 | + if ("text" in block) { |
| 138 | + console.log(block.text); // Claude's reasoning |
| 139 | + } else if ("name" in block) { |
| 140 | + console.log(`Tool: ${block.name}`); // Tool being called |
| 141 | + } |
| 142 | + } |
| 143 | + } else if (message.type === "result") { |
| 144 | + console.log(`Done: ${message.subtype}`); // Final result |
| 145 | + } |
| 146 | +} |
0 commit comments