### Install Project Dependencies Source: https://github.com/builderio/micro-agent/blob/main/CONTRIBUTING.md Installs all project dependencies using npm. ```sh npm i ``` -------------------------------- ### Run CLI Locally Source: https://github.com/builderio/micro-agent/blob/main/CONTRIBUTING.md Starts the CLI locally without global installation using the start script. ```sh npm start ``` -------------------------------- ### Build the Project Source: https://github.com/builderio/micro-agent/blob/main/CONTRIBUTING.md Executes the build script to bundle the project using pkgroll. ```sh npm run build ``` -------------------------------- ### Install Node.js Version Source: https://github.com/builderio/micro-agent/blob/main/CONTRIBUTING.md Installs the Node.js version specified in the .nvmrc file using nvm. ```sh nvm i ``` -------------------------------- ### Install Micro Agent Source: https://github.com/builderio/micro-agent/blob/main/README.md Installs the Micro Agent globally using npm. Requires Node.js v18 or later. ```bash npm install -g @builder.io/micro-agent ``` -------------------------------- ### Running the Development Server Source: https://github.com/builderio/micro-agent/blob/main/test/nextjs-app/README.md Commands to start the Next.js development server using different package managers (npm, yarn, pnpm, bun). This allows for local development and testing. ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` -------------------------------- ### Next.js Page Component Example Source: https://github.com/builderio/micro-agent/blob/main/test/nextjs-app/README.md An example of a Next.js page component written in TypeScript. This file (`app/page.tsx`) is the entry point for the application's homepage and can be modified to change the displayed content. ```typescript // Example of app/page.tsx content (actual content not provided in source) // This file is where you start editing the page. // The page auto-updates as you edit the file. ``` -------------------------------- ### Visual Matching Example Source: https://github.com/builderio/micro-agent/blob/main/README.md Demonstrates how to use Micro Agent for visual matching by providing a local URL and the code file to edit. The agent will attempt to match a screenshot placed alongside the code. ```bash micro-agent ./app/about/page.tsx --visual localhost:3000/about ``` -------------------------------- ### Start Micro Agent Interactively Source: https://github.com/builderio/micro-agent/blob/main/README.md Launches Micro Agent in interactive mode, allowing users to provide prompts and receive feedback for code generation. ```bash micro-agent ``` -------------------------------- ### Fix Linting Errors Source: https://github.com/builderio/micro-agent/blob/main/CONTRIBUTING.md Runs the lint:fix script to automatically fix linting issues, recommended for VS Code users with the prettier-vscode extension. ```sh npm run lint:fix ``` -------------------------------- ### Run Angular Parser Test Locally Source: https://github.com/builderio/micro-agent/blob/main/src/tests/angular-parser/README.md This command executes the Angular parser test locally. It requires the 'npm start' command with specific arguments pointing to the test file and a test tag. ```bash npm start -- src/tests/angular-parser/parse.ts -t "npm test parser" ``` -------------------------------- ### Checking Micro Agent Version Source: https://github.com/builderio/micro-agent/blob/main/README.md Command to display the currently installed version of the Micro Agent CLI. ```bash micro-agent --version ``` -------------------------------- ### Run Micro Agent with Custom Test File and Prompt Source: https://github.com/builderio/micro-agent/blob/main/README.md Runs Micro Agent on a TypeScript file, specifying a custom test file (`./file-to-edit.spec.ts`) and a custom prompt file (`./path-to-prompt.prompt.md`) for guiding code generation. ```bash micro-agent ./file-to-edit.ts -t "npm test" -f ./file-to-edit.spec.ts -p ./path-to-prompt.prompt.md ``` -------------------------------- ### Setting Anthropic API Key Source: https://github.com/builderio/micro-agent/blob/main/README.md Instructions for configuring the Anthropic API key, which is recommended for visual matching due to its superior performance in this area compared to OpenAI. ```bash micro-agent config set ANTHROPIC_KEY= ``` -------------------------------- ### Accessing Configuration UI Source: https://github.com/builderio/micro-agent/blob/main/README.md Command to open an interactive, visual interface for managing Micro Agent's configuration options, such as API keys and default models. ```bash micro-agent config ``` -------------------------------- ### Run Ternary Simplification Test Source: https://github.com/builderio/micro-agent/blob/main/src/tests/ternary/README.md Executes the ternary simplification test using npm. It specifies the target TypeScript file and the test commands to run. ```bash npm start -- src/tests/ternary/simplify.ts -t "npm test ternary && npm run typecheck" ``` -------------------------------- ### Configure OpenAI API Key Source: https://github.com/builderio/micro-agent/blob/main/README.md Sets the OpenAI API key for Micro Agent to use. Replace `` with your actual API key. ```bash micro-agent config set OPENAI_KEY= ``` -------------------------------- ### Run Micro Agent with Unit Test Matching Source: https://github.com/builderio/micro-agent/blob/main/README.md Executes Micro Agent on a specified file (`./file-to-edit.ts`) and uses a command (`npm test`) to verify code correctness. The agent iterates until tests pass. ```bash micro-agent ./file-to-edit.ts -t "npm test" ``` -------------------------------- ### Updating Micro Agent Source: https://github.com/builderio/micro-agent/blob/main/README.md Instructions for updating the Micro Agent to the latest version, either manually or by using npm. ```bash micro-agent update ``` ```bash npm update -g @builder.io/micro-agent ``` -------------------------------- ### Micro Agent CLI Usage Source: https://github.com/builderio/micro-agent/blob/main/README.md Provides the basic structure for using the Micro Agent CLI, including commands for configuration and updates, as well as various flags for controlling agent behavior like maximum runs, prompts, and testing. ```bash Usage: micro-agent [flags...] micro-agent Commands: config Configure the CLI update Update Micro Agent to the latest version Flags: -h, --help Show help -m, --max-runs The maximum number of runs to attempt -p, --prompt Prompt to run -t, --test The test script to run -f, --test-file The test file to run -v, --visual Visual matching URL --thread Thread ID to resume --version Show version ``` -------------------------------- ### Setting OpenAI API Key Source: https://github.com/builderio/micro-agent/blob/main/README.md Command to set the OpenAI API key for use with the Micro Agent. ```bash micro-agent config set OPENAI_KEY= ``` -------------------------------- ### Configure Anthropic API Key Source: https://github.com/builderio/micro-agent/blob/main/README.md Sets the Anthropic API key for Micro Agent. Replace `` with your actual API key. ```bash micro-agent config set ANTHROPIC_KEY= ``` -------------------------------- ### Configure Custom OpenAI API Endpoint Source: https://github.com/builderio/micro-agent/blob/main/README.md Sets a custom API endpoint for OpenAI-compatible providers like Ollama or Groq. Replace `` with the actual endpoint URL. ```bash micro-agent config set OPENAI_API_ENDPOINT= ``` ```bash micro-agent config set OPENAI_API_ENDPOINT=https://api.groq.com/openai/v1 ``` -------------------------------- ### Overriding Model with Environment Variable Source: https://github.com/builderio/micro-agent/blob/main/README.md Demonstrates how to override the default model configuration by setting the MODEL environment variable before running a Micro Agent command. ```bash MODEL=gpt-3.5-turbo micro-agent ./file-to-edit.ts -t "npm test" ``` -------------------------------- ### Configuring Max Runs Source: https://github.com/builderio/micro-agent/blob/main/README.md Explains how to set the maximum number of runs Micro Agent will perform before stopping, using the -m flag. The default is 10 runs. ```bash micro-agent ./file-to-edit.ts -m 20 ``` -------------------------------- ### Set Default Model (OpenAI) Source: https://github.com/builderio/micro-agent/blob/main/README.md Configures Micro Agent to use a specific OpenAI model, such as 'gpt-4o'. ```bash micro-agent config set MODEL=gpt-4o ``` -------------------------------- ### Set Default Model (Anthropic) Source: https://github.com/builderio/micro-agent/blob/main/README.md Configures Micro Agent to use the 'claude' model from Anthropic. ```bash micro-agent config set MODEL=claude ``` -------------------------------- ### Configuring Default Model Source: https://github.com/builderio/micro-agent/blob/main/README.md How to set the default AI model for Micro Agent. By default, it uses 'gpt-4o', but this can be changed to other OpenAI or Anthropic models. ```bash micro-agent config set MODEL=gpt-3.5-turbo ``` ```bash micro-agent config set MODEL=claude ``` -------------------------------- ### Simplify Ternary Expression Source: https://github.com/builderio/micro-agent/blob/main/src/tests/ternary/simplify.prompt.md Converts a complex, redundant ternary expression into a simpler one. It analyzes the conditions and their outcomes, removing variables that do not influence the final result. This function is designed to work with TypeScript code. ```typescript function simplify(code: string): string { // Implementation details using TypeScript parser to analyze and simplify ternary expressions // Example transformation: // Input: // type === 'Default' && status === 'Default' ? '71px' : type === 'With Icon' && status === 'Default' ? '79px' : ... // Output: // type === 'With Icon' ? '79px' : '71px' return code; // Placeholder for actual implementation } ``` -------------------------------- ### Parse Angular Component Metadata Source: https://github.com/builderio/micro-agent/blob/main/src/tests/angular-parser/parse.prompt.md Parses a given Angular component's TypeScript code to extract its name, selector, and input properties. It infers the type of each input and includes enum values if the input type is an enum. This function is designed to be robust and handle different component structures. ```typescript import ts from 'typescript'; type Option = 'a' | 'b' | 'c'; @Component({ selector: 'example-component', template: `

{{ title }}

{{ description }}

`, }) export class ExampleComponent { @Input() title: string; @Input() description: string; @Input() options: Option; @Input() mode: number; } // Expected output: // { // name: 'ExampleComponent', // selector: 'example-component', // inputs: [ // { name: 'title', type: 'string' }, // { name: 'description', type: 'string' }, // { name: 'options', type: 'string', enum: ['a', 'b', 'c'] }, // { name: 'mode', type: 'number' }, // ], // } ``` ```typescript import { Component, Input } from '@angular/core'; type Foo = number; @Component({ selector: 'my-component', }) export class MyComponent { @Input() num: Foo; } // Expected output: // { // name: 'MyComponent', // selector: 'my-component', // inputs: [{ name: 'num', type: 'number' }], // } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.