diff --git a/docs/cli/configuration.mdx b/docs/cli/configuration.mdx new file mode 100644 index 000000000..851dec6ba --- /dev/null +++ b/docs/cli/configuration.mdx @@ -0,0 +1,77 @@ +--- +title: "Configuration" +--- + +`cn` resolves its configuration (models, MCP servers, rules, etc.) from several sources, in this order: + +1. **`--config` flag** — a file path or hub assistant slug passed at launch +2. **Saved config** — the last-used configuration, persisted across sessions +3. **Default** — your first assistant from [Continue](https://continue.dev), or `~/.continue/config.yaml` if you're not logged in + +## `--config` flag + +Point `cn` at a local YAML file or a hub assistant: + +```bash +# Local file +cn --config ./my-config.yaml + +# Hub assistant +cn --config my-org/my-assistant +``` + +This overrides any saved preference for the current session. + +## Switching at runtime + +Use `/config` inside a TUI session to switch between available configurations: + +``` +> /config +``` + +This shows your available assistants and local configs. The selection is saved for next time. + +## `config.yaml` + +If you're not logged in to Continue, `cn` looks for `~/.continue/config.yaml`. This file uses the same format as the IDE extensions — see [config.yaml reference](/customize/deep-dives/configuration) for the full schema. + +## CLI-specific flags + +Several flags inject configuration at launch without editing a file: + +```bash +# Add models from the hub +cn --model my-org/claude-sonnet + +# Add MCP servers from the hub +cn --mcp my-org/github-mcp + +# Add rules (file path, hub slug, or inline string) +cn --rule ./rules/style.md +cn --rule my-org/code-review-rules +cn --rule "Always use TypeScript strict mode" + +# Load an agent file from the hub +cn --agent my-org/pr-reviewer +``` + +All of these are repeatable — pass them multiple times to add multiple items. + +## Organization + +If you belong to multiple organizations on Continue, use `--org` to specify which one: + +```bash +cn --org my-team -p "Review this PR" +``` + +In TUI mode, `/config` lets you switch organizations interactively. + +## Secrets + +Store sensitive values (API keys, tokens) in [Continue → Settings → Secrets](https://continue.dev/settings/secrets). Reference them in config with: + +```yaml +${{ secrets.MY_API_KEY }} +``` diff --git a/docs/cli/guides.mdx b/docs/cli/guides.mdx deleted file mode 100644 index 89e96b566..000000000 --- a/docs/cli/guides.mdx +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: "Guides" -url: "/guides/overview#mcp-integration-cookbooks" ---- \ No newline at end of file diff --git a/docs/cli/headless-mode.mdx b/docs/cli/headless-mode.mdx new file mode 100644 index 000000000..f493869ff --- /dev/null +++ b/docs/cli/headless-mode.mdx @@ -0,0 +1,86 @@ +--- +title: "Headless Mode" +--- + +Run `cn -p "your prompt"` to execute a single task without an interactive session. The agent runs to completion and prints its response to stdout. + +```bash +cn -p "Generate a conventional commit message for the staged changes" +``` + +## Piping + +Pipe data into `cn` to include it as context: + +```bash +git diff --staged | cn -p "Write a commit message for this diff" +cat error.log | cn -p "Explain what went wrong" +curl -s https://api.example.com/health | cn -p "Is this healthy?" +``` + +Pipe the output into other tools: + +```bash +cn -p "Generate a commit message" | git commit -F - +cn -p "List all TODO comments in src/" --silent > todos.txt +``` + +## Output options + +| Flag | Effect | +|------|--------| +| `--silent` | Strip `` tags and excess whitespace from output | +| `--format json` | Output structured JSON | + +`--silent` is useful when piping output into another program. `--format json` is useful for parsing results programmatically. + +## Tool permissions + +In headless mode, tools that would normally prompt for approval (`ask` permission) are automatically excluded — there's no one to approve them. To enable write operations, explicitly allow them: + +```bash +# Allow the agent to write files +cn -p "Fix the type errors in src/" --allow Write --allow Edit + +# Allow everything +cn -p "Set up the project" --allow "*" +``` + +See [tool permissions](/cli/tool-permissions) for the full policy system. + +## Authentication in CI + +Set `CONTINUE_API_KEY` instead of running `cn login`: + +```bash +export CONTINUE_API_KEY=your-key-here +cn -p "Review the PR for security issues" +``` + +Get an API key from [Continue → Settings → API Keys](https://continue.dev/settings/api-keys). Store it as a secret in your CI provider. + +## Resume in headless mode + +Resume a previous session without interactive input: + +```bash +cn -p --resume +``` + +This replays the previous session's history, which can be useful for inspecting past results in automation. + +## Examples + +```bash +# Git hooks +cn -p "Review staged changes for obvious bugs" --silent + +# CI pipeline — allow file writes for auto-fix +cn -p "Fix all ESLint errors in src/" --allow Write --allow Edit --allow Bash + +# Generate docs from code +cn -p "@src/api/ Generate OpenAPI documentation for these endpoints" --silent > api-docs.yaml + +# Use a specific assistant +cn -p "Triage this error log" --config my-org/error-triage-assistant +``` diff --git a/docs/cli/install.mdx b/docs/cli/install.mdx index 07bd47b56..0204cbde6 100644 --- a/docs/cli/install.mdx +++ b/docs/cli/install.mdx @@ -1,7 +1,5 @@ --- -title: "Install Continue CLI" -description: "Get Continue CLI installed and configured for command-line AI coding assistance and automation" -sidebarTitle: "Install" +title: "Install" --- import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx' @@ -9,132 +7,40 @@ import CLIInstall from '/snippets/cli-install.mdx' - - -## Installation - -## Two Ways to Use Continue CLI - - - **Quick Overview**: Continue CLI works in two modes - TUI for interactive - conversations or headless for automated commands. - - - - -**Interactive development sessions** - -Start a conversation with AI in your terminal: +Verify the installation: ```bash -cn -> @src/app.js Generate unit tests for this component +cn --version ``` -Perfect for exploration, debugging, and iterative development. +## Authentication - +### Log in with Continue - -**Automation and scripting** - -Single commands that return results: - -```bash -cn -p "Generate a commit message for current changes" -cn -p "Review the last 5 commits for issues" -``` - -Perfect for CI/CD, git hooks, and automated workflows. - - - - -## Setup - - - - -For interactive development and exploration: - - - ```bash cn login ``` -This will open your browser to authenticate with Continue Mission Control. - - -Start an interactive session: +This opens your browser to authenticate with [Continue](https://continue.dev). Once authenticated, `cn` can use your configured assistants, models, and MCP servers from the platform. + +### API key (headless / CI) + +For automation environments where there's no browser, set the `CONTINUE_API_KEY` environment variable: + ```bash -cn +export CONTINUE_API_KEY=your-key-here +cn -p "your prompt" ``` -Try asking a question: +Get an API key from [Continue → Settings → API Keys](https://continue.dev/settings/api-keys). -``` -> Tell me about the CLI -``` +### Local API key - - - - +If you don't want to use Continue, you can use an Anthropic API key directly. On first launch, `cn` will prompt you to choose between logging in with Continue or entering an Anthropic API key. -For automation workflows and scripting: +## Requirements - - -For automation workflows, get an API key: -1. Visit [Continue Mission Control API Keys](https://continue.dev/settings/api-keys) -2. Click **"+ New API Key"** -3. Copy the API key immediately (you won't see it again!) -4. Login using your Continue account - - - -Store secure credentials for CLI workflows: -1. Visit [Continue Mission Control Secrets](https://continue.dev/settings/secrets) -2. Add your API keys and sensitive data -3. Reference in configurations with `${{ secrets.SECRET_NAME }}` - - - -Try headless mode for automation: -```bash -cn -p "Generate a conventional commit message for the current git changes" -``` - - - - - -## What's Next? - - - - Learn basic usage with practical examples - - - - Build automated workflows with Continue CLI - - - -## Getting Help - -If you encounter issues: - -- Ask for help in [our discussions](https://github.com/continuedev/continue/discussions) -- Report bugs on [GitHub](https://github.com/continuedev/continue) +- **Node.js 20+** — needed for the npm install path. The shell installer bundles its own runtime. +- A [Continue](https://continue.dev) account, or an Anthropic API key. diff --git a/docs/cli/overview.mdx b/docs/cli/overview.mdx index eef5f44bd..4db3796b6 100644 --- a/docs/cli/overview.mdx +++ b/docs/cli/overview.mdx @@ -1,6 +1,5 @@ --- title: "Overview" -description: "Command-line interface for automated coding tasks, scripting, and headless development workflows with Continue's AI coding capabilities" --- import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx' @@ -8,227 +7,46 @@ import CLIInstall from '/snippets/cli-install.mdx' +Continue CLI (`cn`) is a terminal-based coding agent. It can edit files, run commands, and work through multi-step tasks — the same agent that powers the Continue IDE extensions, running in your terminal. + -## Get Started in 30 Seconds - -Prerequisites: - -- [Node.js 18 or newer](https://nodejs.org/en/download/) -- A [Continue Mission Control](https://continue.dev) account (recommended) or local configuration +## Install -Then navigate to your project and start coding: +## First run ```bash -cd your-awesome-project +cd your-project cn -# You'll be prompted to set up on first use ``` -That's it! You're ready to start automating with Continue CLI. +On first launch you'll be asked to log in with [Continue](https://continue.dev) or enter an Anthropic API key. After that, you're in a session and can start typing. -[Continue with CLI Quickstart →](/cli/quick-start) +## Two modes -## Two Ways to Use Continue CLI +**[TUI mode](/cli/tui-mode)** — run `cn` to start an interactive session. You type messages, reference files with `@`, approve tool calls, and iterate with the agent. This is the default. -Continue CLI offers two distinct modes designed for different workflows: +**[Headless mode](/cli/headless-mode)** — run `cn -p "your prompt"` for single-shot automation. The agent runs to completion and prints its response to stdout. Use this in scripts, CI/CD, and git hooks. -### TUI Mode: Interactive Development +## Common flags -**Perfect for exploration, debugging, and iterating on AI workflows** +| Flag | Effect | +|------|--------| +| `-p "prompt"` | Headless mode — run prompt and exit | +| `--config ` | Use a specific config file or assistant | +| `--resume` | Resume the most recent session | +| `--auto` | Allow all tools without prompting | +| `--readonly` | Plan mode — read-only tools only | +| `--allow ` | Allow a specific tool (repeatable) | +| `--exclude ` | Exclude a specific tool (repeatable) | +| `--rule ` | Add a rule — file path, hub slug, or string (repeatable) | +| `--mcp ` | Add an MCP server from the hub (repeatable) | +| `--model ` | Add a model from the hub (repeatable) | +| `--agent ` | Load an agent file from the hub | +| `--verbose` | Enable verbose logging | -```bash -cn -> @src/components/UserProfile.js Review this component for security issues -> Generate comprehensive unit tests -> Suggest performance improvements -``` - -- **Interactive conversations** with your codebase -- **Iterate and refine** prompts and approaches -- **Explore and understand** complex codebases -- **Perfect for experimentation** and learning - -### Headless Mode: Production Automation - -**Perfect for CI/CD, automation, and reliable workflows** - -```bash -cn -p "Generate a conventional commit message for staged changes" -cn -p "Review pull request changes for security vulnerabilities" -cn -p "Update documentation based on recent code changes" -``` - -- **Single-command execution** for automation -- **Reliable, repeatable results** for production use -- **CI/CD and pipeline integration** -- **Git hooks and automated workflows** - - - **Tool Permissions in TUI vs Headless Mode** - - Continue CLI tools have three permission levels: - - **allow**: Executes automatically without confirmation - - **ask**: Prompts for user confirmation before execution (e.g., `writeFile`, `runTerminalCommand`) - - **exclude**: Tool is not available to the AI - - **In headless mode**, tools with "ask" permission are automatically excluded to prevent the AI from seeing tools it cannot call. This ensures reliable automation without user intervention. - - **In TUI mode**, tools with "ask" permission are available and will prompt for confirmation when the AI attempts to use them. - - 💡 **Tip**: If your workflow requires tools that need confirmation (like file writes or terminal commands), use TUI mode. For fully automated workflows with read-only operations, use headless mode. - - -### Development Workflow: TUI → Headless - - - **Pro Tip**: Start in TUI mode to iterate on your AI agent. Once - you have a workflow that works reliably, deploy it as a Continuous AI - automation. - - -1. **Experiment in TUI mode** to perfect your agent -2. **Test different approaches** interactively until you get consistent results -3. **Convert successful workflows** to automated Continuous AI commands -4. **Deploy in production** with confidence in your proven approach - -## Why developers love Continue CLI - -- **Works in your terminal**: Not another chat window. Not another IDE. Continue CLI meets you where you already work, with the tools you already love. -- **Takes action**: Continue CLI can directly edit files, run commands, and create commits. Need more? Check out our [MCPs](/customize/deep-dives/mcp). -- **Automate tasks**: Create issues from PostHog data, automatically assign labels to issues, and more. Do all this in a single command from your developer machines, or automatically in CI. -- **Flexible development flow**: Start interactive, then automate proven workflows. - -## Key Capabilities - -### Context Engineering - -- Use `@` to reference files and provide context -- Use `/` to run slash commands for specific tasks -- Access the same context providers as IDE extensions - -### Tool Integration - -- File editing and creation -- Terminal command execution -- Codebase understanding and analysis -- Git integration -- Web search and documentation access - -### Model Flexibility - -- Switch between models with `/model` command -- Use any model configured in your `config.yaml` -- Access Continue Mission Control models and configurations - -## Continue Mission Control Integration - -Continue CLI integrates seamlessly with [Continue Mission Control](https://continue.dev) for: - -### API Access - -Get an API key for automation workflows: - -1. Visit [Continue Mission Control API Keys](https://continue.dev/settings/api-keys) -2. Create a new API key -3. Use with `cn login` or in your automation scripts - -### Secrets Management - -Store secure credentials for CLI workflows: - -1. Visit [Continue Mission Control Secrets](https://continue.dev/settings/secrets) -2. Add your API keys and sensitive data -3. Reference in configurations with `${{ secrets.SECRET_NAME }}` - -### Configuration Sync - -- Cloud-managed configurations automatically sync -- Share configurations across team members -- Version control for your AI workflows - -## Common Use Cases - -### TUI Mode Examples - -**Interactive development and exploration:** - - -```bash Codebase Exploration -# Start interactive session -cn -> @src/components Find all unused React components -> /explain How does authentication work in this codebase? -> @auth/ What security patterns are used here? -``` - -```bash Iterative Debugging -# Debug issues interactively -cn -> @tests/auth.test.js This test is failing, help me understand why -> @src/auth/middleware.js Let's examine this middleware -> /debug What could be causing the timeout error? -``` - -```bash Workflow Development -# Develop and test automation workflows -cn -> @package.json @CHANGELOG.md Generate a release notes template -> # Test and refine the approach -> # Once working, convert to: cn -p "Generate release notes" -``` - - - -### Headless Mode Examples - -**Production automation and scripting:** - - -```bash Git Automation -# Generate commit messages -cn -p "Generate a conventional commit message for the current changes" - -# Code review automation - -cn -p "Review the current git changes for bugs and suggest improvements" - -```` - -```bash CI/CD Integration -# In your pipeline scripts -cn -p "Analyze test failures and suggest fixes" - -# Automated documentation updates -cn -p "@README.md Update this documentation based on recent changes" -```` - -```bash Issue Management -# Create GitHub issues from PostHog data -cn -p "@posthog-data.json Create GitHub issues for UX problems found in this session data" - -# Automated security audits -cn -p "Scan the codebase for potential security vulnerabilities" -``` - - - -## Next Steps - - - - Learn basic commands and common workflows - - - - Install Continue CLI and set up your environment - - - - Task-specific tutorials and examples - - +Run `cn --help` for the full list. diff --git a/docs/cli/quick-start.mdx b/docs/cli/quick-start.mdx deleted file mode 100644 index dbda8ec50..000000000 --- a/docs/cli/quick-start.mdx +++ /dev/null @@ -1,186 +0,0 @@ ---- -title: "Continue CLI Quick Start" -description: "Get hands-on experience with Continue CLI through practical examples and common use cases" -sidebarTitle: "Quick Start" ---- - -Get hands-on experience with Continue CLI through practical development workflows. - - - - TUI Mode (`cn` command) is for **large development tasks** that require - agentic workflows with human oversight. Perfect for complex refactors, - feature implementation, or one-off automation tasks that need monitoring and - iteration. - - - Headless Mode (`-p` flag) is for **reliable, repeatable tasks** that no - longer need constant supervision. Perfect for CI/CD pipelines, git hooks, - and automated workflows you've already tested and refined. - - - -## TUI Mode: Large Development Tasks - -Make sure you have [Continue CLI installed](/cli/install) and are in a project directory. - -### Example: Implementing a New Feature - -```bash -# Navigate to your project directory -cd your-awesome-project - -# Start TUI Mode for complex development work -cn -``` - -**Example workflow for adding authentication:** - -``` -> I need to add JWT authentication to this Express app. Let me start by showing you the current structure. - -> @src/app.js @package.json Here's my current setup. Can you implement JWT auth with middleware, login/register routes, and user model? - -> [Agent analyzes codebase and implements auth system] -> [You review changes, test, and provide feedback] -> [Agent iterates based on your input until the feature is complete] -``` - -### Example: Complex Refactoring - -```bash -cn -``` - -**Refactoring a monolithic component:** - -``` -> @src/components/Dashboard.jsx This component is 800 lines and does too much. Help me break it into smaller, reusable components. - -> [Agent analyzes component structure] -> [Proposes component breakdown strategy] -> [You approve approach] -> [Agent implements the refactor with proper props and state management] -> [You test and request adjustments] -``` - -### When to Use TUI Mode - -✅ **Large development tasks** that need oversight -✅ **Complex refactors** requiring multiple steps -✅ **New feature implementation** with unknowns -✅ **One-off automation tasks** you haven't done before -✅ **Debugging complex issues** that need exploration - -## Headless Mode: Automated Workflows - -Once you've refined a workflow in TUI Mode, convert it to Continuous AI for automation. - -### Example: From REPL → Continuous AI - -**Step 1: Develop in TUI Mode** - -```bash -cn -> @package.json @CHANGELOG.md Generate release notes for version 2.1.0 -> [Test and refine the prompt until it works perfectly] -``` - -**Step 2: Convert to Continuous AI** - -```bash -# Now use the refined workflow in automation -cn -p "Generate release notes for the current version based on package.json and recent commits" -``` - -### Common Continuous AI Workflows - -```bash -# Git automation -cn -p "Generate a conventional commit message for staged changes" -cn -p "Review the last 3 commits for potential issues" - -# Code quality -cn -p "Fix all TypeScript errors in the src/ directory" -cn -p "Update outdated dependencies and fix breaking changes" - -# Documentation -cn -p "@README.md Update documentation based on recent changes" -cn -p "Generate API documentation from JSDoc comments" - -# CI/CD integration -cn -p "Analyze test failures and create GitHub issue with findings" -cn -p "Update version numbers and create release branch" -``` - -### When to Use Headless Mode - -✅ **Proven workflows** you've tested in TUI Mode -✅ **Repetitive tasks** that no longer need oversight -✅ **CI/CD automation** in pipelines -✅ **Git hooks** for automated checks -✅ **Scheduled tasks** that run unattended - - - **Tool Permission Differences Between Modes** - - Tools requiring user confirmation ("ask" permission) like `writeFile` and `runTerminalCommand` are: - - **Available in TUI mode** - AI can use them with your approval - - **Excluded in headless mode** - AI cannot see or call them - - This prevents the AI from attempting operations that require user interaction when running in automated environments. Choose TUI mode if your workflow needs tools that modify files or run commands. - - -### Available Slash Commands - -Common slash commands available in CLI: - -- `/clear` - Clear the chat history -- `/compact` - Summarize chat history into a compact form -- `/config` - Switch configuration or organization -- `/exit` - Exit the chat -- `/fork` - Start a forked chat session from the current history -- `/help` - Show help message -- `/info` - Show session information including usage statistics (cost, tokens, cache usage) -- `/init` - Create an AGENTS.md file -- `/login` - Authenticate with your account -- `/logout` - Sign out of your current session -- `/mcp` - Manage MCP server connections -- `/model` - Switch between available chat models -- `/resume` - Resume a previous chat session -- `/whoami` - Check who you're currently logged in as - -Use `/help` to see all available commands. - -## The Development Workflow - - - **Recommended Approach**: Start complex tasks in TUI Mode to iterate and - refine your approach. Once you have a reliable workflow, convert it to - Headless Mode for automation. - - -### Workflow Pattern - -1. **🔬 Experiment in TUI Mode** - - - Try complex development tasks with human oversight - - Iterate on prompts and approaches until they work reliably - - Test edge cases and refine the agent's behavior - -2. **⚡ Automate with Continuous AI** - - Convert proven REPL workflows to single commands - - Deploy in CI/CD, git hooks, or scheduled tasks - - Run with confidence knowing the approach is tested - -## Next Steps - - - - Build an automated PostHog to GitHub issues workflow - - - - Learn to build and deploy AI-powered development workflows - - diff --git a/docs/cli/tool-permissions.mdx b/docs/cli/tool-permissions.mdx new file mode 100644 index 000000000..5273a116d --- /dev/null +++ b/docs/cli/tool-permissions.mdx @@ -0,0 +1,92 @@ +--- +title: "Tool Permissions" +--- + +Every tool has one of three permission levels: + +| Permission | Behavior | +|------------|----------| +| `allow` | Runs automatically, no prompt | +| `ask` | Prompts for approval before running (TUI only) | +| `exclude` | Hidden from the agent entirely | + +## Defaults + +Read-only tools (`Read`, `List`, `Search`, `Fetch`, `Diff`) default to `allow`. Write tools (`Edit`, `MultiEdit`, `Write`) and `Bash` default to `ask`. In [headless mode](/cli/headless-mode), `ask` tools are excluded since there's no one to approve them. + +## Overriding with flags + +Use `--allow`, `--ask`, and `--exclude` to override defaults at launch: + +```bash +# Allow file writes without prompting +cn --allow Write --allow Edit + +# Exclude terminal commands +cn --exclude Bash + +# Allow everything (headless automation) +cn -p "Set up the project" --allow "*" +``` + +Flags take precedence over all other permission sources. + +## Tool matching patterns + +Flags accept tool matching patterns: + +- `Write` — matches any call to the `Write` tool +- `Write(*)` — same as above +- `Write(**/*.ts)` — matches `Write` calls where the primary argument matches the glob `**/*.ts` + +```bash +# Allow writing only to TypeScript files +cn --allow "Write(**/*.ts)" + +# Allow bash but not for install commands +cn --allow Bash --exclude "Bash(npm install*)" +``` + +## `permissions.yaml` + +Persistent permissions are stored in `~/.continue/permissions.yaml`. This file is updated when you choose "Continue + don't ask again" in the TUI approval prompt. + +```yaml +# ~/.continue/permissions.yaml +allow: + - Read(*) + - Write(**/*.ts) + +ask: + - Bash + +exclude: [] +``` + +You can edit this file directly, but it's primarily managed by the TUI. Changes take effect on the next session. + +## Precedence + +When multiple sources define a permission for the same tool, the highest-priority source wins: + +1. **Mode policies** — `--auto` and `--readonly` override everything (see below) +2. **CLI flags** — `--allow`, `--ask`, `--exclude` +3. **`permissions.yaml`** — persistent personal settings +4. **Defaults** — built-in policies + +## Modes + +Modes are a shorthand for common permission sets. Switch modes with `Shift+Tab` during a TUI session, or set them at launch: + +```bash +cn --auto # Allow all tools without prompting +cn --readonly # Plan mode — read-only tools only, no file writes +``` + +| Mode | Effect | +|------|--------| +| **normal** (default) | Uses configured permissions | +| **plan** (`--readonly`) | Excludes all write tools, allows reads and `Bash` | +| **auto** (`--auto`) | Allows everything — `*: allow` | + +Plan and auto modes are absolute overrides. They ignore `--allow`, `--exclude`, and `permissions.yaml` entirely. diff --git a/docs/docs.json b/docs/docs.json index 790e479f9..1374083c4 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -44,7 +44,14 @@ { "group": "CLI", "icon": "terminal", - "pages": ["cli/overview", "cli/install", "cli/quick-start"] + "pages": [ + "cli/overview", + "cli/install", + "cli/tui-mode", + "cli/headless-mode", + "cli/configuration", + "cli/tool-permissions" + ] } ] },