Update Micro Agent
mainTo update to the latest version, you can use the built-in update command or npm:
micro-agent update
# OR
npm update -g @builder.io/micro-agentrepository·main·Indexed 26 days ago
https://github.com/builderio/micro-agentAn AI-driven CLI tool (@builder.io/micro-agent) that writes and fixes code by generating tests and iterating on implementations until they pass. It supports unit test matching, experimental visual matching via screenshots, and integrates with Claude, OpenAI, Ollama, and other OpenAI-compatible providers.
To update to the latest version, you can use the built-in update command or npm:
micro-agent update
# OR
npm update -g @builder.io/micro-agentRun Micro Agent on a specific file and iterate until a provided test script passes.
Default behavior:
Micro Agent looks for a test file with the same name as the target file but with .test.ts appended (e.g., ./file.ts looks for ./file.test.ts).
Flags:
-t, --test <string>: The test script to run (e.g., npm test).-f, --test-file <string>: Specify a custom test file path.-p, --prompt <string>: Specify a custom prompt file path (defaults to <filename>.prompt.md).Micro Agent requires Node.js v18 or later. Install the CLI globally using npm:
npm install -g @builder.io/micro-agentTo start Micro Agent in interactive mode, where it will ask you questions about the code it generates and use your feedback to improve it, run the command without arguments:
micro-agentMicro Agent supports Claude, OpenAI, Ollama, or any OpenAI compatible provider (like Groq). Use the config set command to configure your environment.
For OpenAI/Compatible providers:
OPENAI_KEYMODEL (defaults to gpt-4o)OPENAI_API_ENDPOINTFor Claude:
ANTHROPIC_KEYMODEL (use claude as an alias for claude-3-5-sonnet-20241022)# OpenAI configuration
micro-agent config set OPENAI_KEY=<your token>
micro-agent config set MODEL=gpt-4o
micro-agent config set OPENAI_API_ENDPOINT=https://api.groq.com/openai/v1
# Claude configuration
micro-agent config set ANTHROPIC_KEY=<your token>
micro-agent config set MODEL=claudeMatch a design by providing a design image and a local URL to your rendered code. Micro Agent will iterate until the rendered output matches the screenshot.
Requirements:
./app/about/page.png for ./app/about/page.tsx).Flags:
--visual <string>: The local URL of your rendered code (e.g., localhost:3000/about).micro-agent ./app/about/page.tsx --visual localhost:3000/aboutYou can manage settings using the config command.
micro-agent config to open a visual interface for setting keys and models.MODEL=gpt-3.5-turbo micro-agent ...).-m flag to change the maximum number of iteration attempts (default is 10).Full list of available commands and flags:
Commands:
config: Configure the CLIupdate: Update Micro Agent to the latest versionFlags:
-h, --help: Show help-m, --max-runs <number>: The maximum number of runs to attempt-p, --prompt <string>: Prompt to run-t, --test <string>: The test script to run-f, --test-file <string>: The test file to run-v, --visual <string>: Visual matching URL--thread <string>: Thread ID to resume--version: Show versionThe interactiveMode function starts a CLI-based interactive session. It guides the user through:
OPENAI_KEY if one is not already configured.It accepts a Partial<RunOptions> object to configure the session.
The getConfig function retrieves the current configuration. It follows a priority order:
cliConfig (as a RawConfig object).~/.micro-agent).Returns a ValidConfig object where all values have been parsed according to their specific types (e.g., booleans are converted from strings, models have defaults).
createCommandString() to generate a formatted shell command string based on your current RunOptions. This is useful for providing a 'resume' command to the user if the agent reaches the maximum number of runs without passing tests.The isInvalidCommand function identifies if a command execution failed because the command itself was not found or the script is missing. It checks for the following substrings in the output:
command not found:command_not_found:npm ERR! Missing script: