### Start using Kiro CLI in a project Source: https://kiro.dev/docs/cli/code-intelligence/docs/cli After installing the Kiro CLI, navigate to your project directory and run the 'kiro-cli' command to start interacting with the tool. This assumes you have a project set up. ```bash cd my-project kiro-cli ``` -------------------------------- ### Install C/C++ Language Server (Clangd) Source: https://kiro.dev/docs/cli/code-intelligence/index Instructions for installing the Clangd language server for C/C++ projects on macOS and Linux. It can be installed via Homebrew, apt, or pacman depending on the distribution. ```bash # macOS brew install llvm # or brew install clangd # Linux (Debian/Ubuntu) sudo apt install clangd # Linux (Arch) sudo pacman -S clang ``` -------------------------------- ### Install Go Language Server (gopls) Source: https://kiro.dev/docs/cli/code-intelligence/index Command to install the Go language server (`gopls`) using the Go toolchain. This enables LSP features for Go projects. ```bash go install golang.org/x/tools/gopls@latest ``` -------------------------------- ### Install Kotlin Language Server Source: https://kiro.dev/docs/cli/code-intelligence/index Command to install the Kotlin language server on macOS using Homebrew. This enables LSP features for Kotlin projects. ```bash brew install kotlin-language-server ``` -------------------------------- ### Install Pyright for Python LSP Source: https://kiro.dev/docs/cli/code-intelligence/index Instructions to install the Pyright language server for Python projects. It provides two methods: using `pip` or the recommended `pipx` for better isolation. ```bash pip install pyright # or with pipx (recommended for isolation) pipx install pyright ``` -------------------------------- ### Install Rust Analyzer (Rust) Source: https://kiro.dev/docs/cli/code-intelligence/index Command to install the Rust language server (`rust-analyzer`) using `rustup`. This enables advanced code intelligence features for Rust projects. ```bash rustup component add rust-analyzer ``` -------------------------------- ### Install Ruby Language Server (Solargraph) Source: https://kiro.dev/docs/cli/code-intelligence/index Command to install the Solargraph language server for Ruby projects using RubyGems. This provides LSP support for Ruby development. ```bash gem install solargraph ``` -------------------------------- ### Install TypeScript Language Server (Node.js) Source: https://kiro.dev/docs/cli/code-intelligence/index Command to install the TypeScript language server globally using npm. This is a prerequisite for enabling LSP features for TypeScript/JavaScript projects within Kiro CLI. ```bash npm install -g typescript-language-server typescript ``` -------------------------------- ### Install Kiro CLI on macOS and Linux Source: https://kiro.dev/docs/cli/code-intelligence/docs/cli This command downloads and executes the Kiro CLI installation script using curl. It's designed for macOS and Linux systems. Ensure you have bash and curl installed. ```bash curl -fsSL https://cli.kiro.dev/install | bash ``` -------------------------------- ### Initialize LSP in Kiro CLI Source: https://kiro.dev/docs/cli/code-intelligence/index Slash command to initialize the Language Server Protocol (LSP) integration within a project. This creates an `lsp.json` configuration file and starts the necessary language servers. ```bash /code init ``` -------------------------------- ### Install Java Language Server (jdtls) on macOS Source: https://kiro.dev/docs/cli/code-intelligence/index Command to install the Java Development Tools Language Server (jdtls) on macOS using Homebrew. For Linux, users need to download it manually. ```bash # macOS brew install jdtls # Linux - download from https://download.eclipse.org/jdtls/snapshots/ # Extract and add to PATH ``` -------------------------------- ### Get Hover Documentation with Language Server Source: https://kiro.dev/docs/cli/code-intelligence/index Retrieves documentation for a symbol when hovering over it. This provides inline information about the symbol's type, description, parameters, and potential exceptions. ```text > What's the documentation for the authenticate method in AuthService? Type: (credentials: Credentials) => Promise Documentation: Authenticates a user with the provided credentials. Returns an AuthResult containing the user token and profile. @param credentials - User login credentials @throws AuthenticationError if credentials are invalid ``` -------------------------------- ### Search for Async Functions (TypeScript) Source: https://kiro.dev/docs/cli/code-intelligence/index An example of using Kiro CLI's pattern search to identify all asynchronous functions in TypeScript code. It demonstrates the use of metavariables like `$$$` for matching zero or more nodes. ```typescript // Find all async functions pattern: async function $NAME($$$PARAMS) { $$$ } language: typescript ``` -------------------------------- ### Search for .unwrap() Calls (Rust) Source: https://kiro.dev/docs/cli/code-intelligence/index An example of using Kiro CLI's pattern search to locate all `.unwrap()` method calls in Rust code. This highlights the ability to match method calls on any expression. ```rust // Find all .unwrap() calls pattern: $E.unwrap() language: rust ``` -------------------------------- ### Get Diagnostics with Language Server Source: https://kiro.dev/docs/cli/code-intelligence/index Fetches diagnostic information (errors and warnings) for a given file. This helps in identifying and fixing code quality issues. ```text > Get diagnostics for main.ts 1. Error line 15:10: Cannot find name 'undefined_var' 2. Warning line 42:5: 'result' is declared but never used ``` -------------------------------- ### Search for Console Log Calls (JavaScript) Source: https://kiro.dev/docs/cli/code-intelligence/index An example of using Kiro CLI's pattern search to find all occurrences of `console.log` calls in JavaScript code. This utilizes Abstract Syntax Tree (AST) based matching. ```javascript // Find all console.log calls pattern: console.log($ARG) language: javascript ``` -------------------------------- ### Get File Symbols with Language Server Source: https://kiro.dev/docs/cli/code-intelligence/index Retrieves a list of all symbols (classes, functions, variables) defined within a specified file. This provides a quick overview of the contents of a file. ```text > What symbols are in auth.service.ts? Getting symbols from: auth.service.ts 1. Class AuthService at auth.service.ts:12:1 2. Function login at auth.service.ts:25:3 3. Function logout at auth.service.ts:45:3 4. Function validateToken at auth.service.ts:62:3 ``` -------------------------------- ### Modernize hasOwnProperty (JavaScript) Source: https://kiro.dev/docs/cli/code-intelligence/index An example of refactoring JavaScript code to use the modern `Object.hasOwn()` method instead of the older `Object.prototype.hasOwnProperty.call()`. This improves code readability and maintainability. ```javascript // Modernize hasOwnProperty pattern: $O.hasOwnProperty($P) replacement: Object.hasOwn($O, $P) language: javascript ``` -------------------------------- ### Generate Code Documentation Source: https://kiro.dev/docs/cli/code-intelligence/index Initiates an interactive session to generate documentation for your codebase. Users can select output formats like AGENTS.md, README.md, or CONTRIBUTING.md. The generation is based on codebase analysis. ```bash /code summary ``` -------------------------------- ### Discover Available Methods with Language Server Source: https://kiro.dev/docs/cli/code-intelligence/index Lists available methods or completions for a given object or instance. This is useful for code completion and discovering the API of an object. ```text > What methods are available on the s3Client instance? Available completions: 1. putObject - Function: (params: PutObjectRequest) => Promise 2. getObject - Function: (params: GetObjectRequest) => Promise 3. deleteObject - Function: (params: DeleteObjectRequest) => Promise 4. listObjects - Function: (params: ListObjectsRequest) => Promise 5. headObject - Function: (params: HeadObjectRequest) => Promise ``` -------------------------------- ### Go to Definition with Language Server Source: https://kiro.dev/docs/cli/code-intelligence/index Navigates to the definition of a symbol. This feature helps in understanding the implementation details of functions, classes, or variables by directly jumping to their declaration. ```text > Find the definition of UserService src/services/user.service.ts:42:1: export class UserService { ... ``` -------------------------------- ### Configure Custom Language Server (lsp.json) Source: https://kiro.dev/docs/cli/code-intelligence/index Defines custom language servers by editing the `lsp.json` file in the project root. This configuration allows Kiro CLI to integrate with language servers for custom or less common programming languages. ```json { "languages": { "mylang": { "name": "my-language-server", "command": "my-lsp-binary", "args": ["--stdio"], "file_extensions": ["mylang", "ml"], "project_patterns": ["mylang.config"], "exclude_patterns": ["**/build/**"], "multi_workspace": false, "initialization_options": { "custom": "options" }, "request_timeout_secs": 60 } } } ``` -------------------------------- ### Find All References with Language Server Source: https://kiro.dev/docs/cli/code-intelligence/index Locates all occurrences of a given symbol across the entire project. This is useful for understanding the impact of changes or tracing data flow. The output includes the file path, line number, and a snippet of the code where the reference is found. ```text > Find references of Person class Finding all references at: auth.ts:42:10 1. src/auth.ts:42:10 - export function authenticate(...) 2. src/handlers/login.ts:15:5 - authenticate(credentials) 3. src/handlers/api.ts:89:12 - await authenticate(token) ``` -------------------------------- ### Force Restart LSP Servers in Kiro CLI Source: https://kiro.dev/docs/cli/code-intelligence/index Command to force a restart of LSP servers if they become unresponsive or shut down unexpectedly. This is done by re-initializing the LSP configuration. ```bash /code init -f ``` -------------------------------- ### Convert unwrap to expect (Rust) Source: https://kiro.dev/docs/cli/code-intelligence/index Shows a pattern rewrite in Rust to replace `.unwrap()` calls with `.expect()`, providing a custom error message. This is crucial for handling `Option` or `Result` types more robustly. ```rust // Convert unwrap to expect pattern: $E.unwrap() replacement: $E.expect("unexpected None") language: rust ``` -------------------------------- ### Kiro CLI Slash Commands for Code Intelligence Source: https://kiro.dev/docs/cli/code-intelligence/index Provides a set of slash commands for managing code intelligence features within Kiro CLI. These commands allow users to initialize, check status, and view logs related to language servers. ```bash /code logs # Show last 20 ERROR logs /code logs -l INFO # Show INFO level and above /code logs -n 50 # Show last 50 entries /code logs -l DEBUG -n 100 # Show last 100 DEBUG+ logs /code logs -p ./lsp-logs.json # Export logs to JSON file ``` -------------------------------- ### Dry Run Rename with Language Server Source: https://kiro.dev/docs/cli/code-intelligence/index Simulates a rename operation for a symbol across the project without actually modifying any files. This allows users to preview the impact of a rename before committing to it. ```text > Dry run: rename the method "FetchUser" to "fetchUserData" Dry run: Would rename 12 occurrences in 5 files ``` -------------------------------- ### Convert 'var' to 'const' (JavaScript) Source: https://kiro.dev/docs/cli/code-intelligence/index Demonstrates a pattern rewrite in JavaScript to convert variable declarations from `var` to `const`. This is useful for modernizing code and enforcing immutability where appropriate. ```javascript // Convert var to const pattern: var $N = $V replacement: const $N = $V language: javascript ``` -------------------------------- ### Find Symbol with Language Server Source: https://kiro.dev/docs/cli/code-intelligence/index Searches for a specific symbol (e.g., a class, function, or variable) within the codebase using a language server. It returns the symbol's name, type, and location. ```text > Find the UserRepository class Searching for symbols matching: "UserRepository" 1. Class UserRepository at src/repositories/user.repository.ts:15:1 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.