Skip to content

Conversation

@aaronlippold
Copy link
Contributor

@aaronlippold aaronlippold commented Jan 27, 2026

PR: Add cn config Command for Model Management

Description

Adds a comprehensive cn config command group to the CLI for managing Continue configuration files. This enables users to verify, sync, and manage models in their config.yaml without manual editing.

Problem

Currently, users must manually edit config.yaml to add/remove models, and there's no way to verify that configured models actually exist on their provider. This leads to:

  • Configuration errors when models are deprecated or renamed
  • Manual work to discover available models
  • No tooling for CI/CD integration

Solution

The cn config command provides:

  • Validation: Verify configured models exist on the provider
  • Sync: Automatically remove unavailable models
  • Discovery: List available models from any OpenAI-compatible API
  • CRUD: Add/remove models programmatically
  • Generation: Bootstrap config from available models
  • Backup/Restore: Safe config management with automatic backups

Commands

Command Description
cn config verify Check if configured models exist on provider
cn config sync Remove unavailable models (supports --dry-run)
cn config validate Validate config file structure
cn config sections Show config sections
cn config list List available models from provider
cn config test Test each chat model with sample prompt
cn config add <model> Add a model with --name, --role options
cn config remove <model> Remove a model from config
cn config generate Bootstrap config from available models
cn config show Display current config
cn config diff Compare config vs available models
cn config backups List backup files
cn config restore <backup> Restore from backup

Global Options

Option Description
--json Output as JSON for CI/scripting
--provider <name> Use preset: openai, anthropic, azure, ollama, together, groq, mistral
--api-base <url> Custom API base URL
--api-key-env <var> Environment variable for API key
--auth-header <header> Custom auth header (default: Authorization)
--chat-only Filter to chat models only
--embed-only Filter to embedding models only
--rerank-only Filter to rerank models only
--filter <pattern> Filter models by pattern
--dry-run Preview changes without applying

Provider Presets

Provider API Base Auth Header Env Var
openai api.openai.com/v1 Authorization OPENAI_API_KEY
anthropic api.anthropic.com/v1 x-api-key ANTHROPIC_API_KEY
azure (user provided) api-key AZURE_API_KEY
ollama localhost:11434/v1 (none) -
together api.together.xyz/v1 Authorization TOGETHER_API_KEY
groq api.groq.com/openai/v1 Authorization GROQ_API_KEY
mistral api.mistral.ai/v1 Authorization MISTRAL_API_KEY

Example Usage

# Verify models exist on provider
cn config verify --provider openai

# Sync config - remove models that don't exist
cn config sync --provider openai --dry-run
cn config sync --provider openai

# List available models
cn config list --provider openai --chat-only
cn config list --provider ollama --filter llama

# Add a model
cn config add gpt-4o --provider openai --role chat

# Generate fresh config from available models
cn config generate --provider openai --chat-only

# Compare config to available models
cn config diff --provider openai --json

# Backup management
cn config backups
cn config restore config.backup-2026-01-27.yaml

Key Features

  • Comment preservation: Uses yaml package (eemeli/yaml) to preserve comments in config files
  • Safe writes: Atomic file operations with automatic backup before any modification
  • PRESERVED_SECTIONS: mcpServers, rules, prompts, context, data, docs are never modified by sync/generate
  • Provider-agnostic: Works with any OpenAI-compatible API
  • CI/CD friendly: --json output for programmatic use

Bug Fix

Also includes a fix for CLIPlatformClient.ts:

  • .env files are now checked BEFORE process.env, matching IDE behavior
  • Previously caused inconsistency between CLI and IDE environments

Checklist

  • I've read the contributing guide
  • The relevant docs, if any, have been updated or created
  • The relevant tests, if any, have been updated or created

Tests

File Tests Coverage
configModels.test.ts 63 Core functions
index.test.ts 8 Command handlers
CLIPlatformClient.test.ts 2 Env priority fix
Total new 73

All 1867 tests passing.

Screen recording or screenshot

CLI command - text output only, no UI changes.

$ cn config verify --provider openai
Checking 3 models against https://api.openai.com/v1...
✓ gpt-4o exists
✓ gpt-4o-mini exists
✗ gpt-3.5-turbo-0301 NOT FOUND
2 of 3 models verified

Continue Tasks: ▶️ 1 queued — View all


Summary by cubic

Adds a new cn config command group to manage models in config.yaml from the CLI, including verification, syncing, discovery, CRUD, and safe backups. Also fixes env loading to prefer .env over process.env for consistent behavior with the IDE.

  • New Features

    • Introduces cn config to manage models: verify/sync, list/test, add/remove, generate/diff/show, backups/restore, validate/sections.
    • Preserves comments and non-model sections; only models are modified. Atomic writes with automatic backups.
    • Works with any OpenAI-compatible API; presets for openai, anthropic, azure, ollama, together, groq, mistral.
    • Supports filters (chat/embed/rerank, pattern) and --json output for CI. Includes 73 new tests.
  • Bug Fixes

    • CLI now checks .env before process.env in CLIPlatformClient, matching IDE behavior.

Written for commit 4609b83. Summary will update on new commits.

.env files are now checked BEFORE process.env, matching IDE behavior.
Previously, process.env took priority which caused inconsistency
between CLI and IDE environments.

Added tests to verify correct priority order.

Authored by: Aaron Lippold<lippold@gmail.com>
Core model management functions for config command:
- loadConfigFile/saveConfigFile: YAML handling with comment preservation
- getAvailableModels: Fetch models from OpenAI-compatible API
- verifyModelsExist: Check if config models exist on provider
- syncModelsInConfig: Remove unavailable models from config
- addModelToConfig/removeModelFromConfig: CRUD operations
- generateConfig: Bootstrap config from available models
- diffModels: Compare config vs available models
- listBackups/restoreBackup: Backup management
- getProviderPreset: Pre-configured provider settings
- filterModels: Filter by pattern and type
- formatAsJson: JSON output for CI/scripting

Features:
- PRESERVED_SECTIONS ensures mcpServers, rules, prompts, etc. are never modified
- Atomic writes using temp file + rename
- Auto-backup before any modification
- Provider presets for openai, anthropic, azure, ollama, together, groq, mistral

63 unit tests included.

Authored by: Aaron Lippold<lippold@gmail.com>
Commander.js command handlers for config subcommands:

Validation commands:
- cn config verify    - Check if models are available from provider
- cn config sync      - Remove unavailable models (--dry-run supported)
- cn config validate  - Validate config structure
- cn config sections  - Show config sections

Discovery commands:
- cn config list      - List available models from provider
- cn config test      - Test each chat model with sample prompt

Model management:
- cn config add       - Add model with --name, --role options
- cn config remove    - Remove model from config
- cn config generate  - Bootstrap config from available models

Inspection commands:
- cn config show      - Display current config
- cn config diff      - Compare config vs available models
- cn config backups   - List backup files
- cn config restore   - Restore from backup

Global options:
- --json              - Output as JSON for CI/scripting
- --provider          - Presets: openai, anthropic, azure, ollama, together, groq, mistral
- --chat-only, --embed-only, --rerank-only - Filter by model type
- --filter <pattern>  - Filter by pattern

8 integration tests included.

Authored by: Aaron Lippold<lippold@gmail.com>
Adds import and registration for the config command group.

Authored by: Aaron Lippold<lippold@gmail.com>
@aaronlippold aaronlippold requested a review from a team as a code owner January 27, 2026 19:47
@aaronlippold aaronlippold requested review from sestinj and removed request for a team January 27, 2026 19:47
@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Jan 27, 2026
Documents the config command group in the CLI README:
- All 13 subcommands with descriptions
- Example usage for common workflows
- Provider presets and filter options

Authored by: Aaron Lippold<lippold@gmail.com>
Use path.join() in test expectations for getConfigPath and getEnvPath
tests to handle Windows backslash path separators.

Authored by: Aaron Lippold<lippold@gmail.com>
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 7 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="extensions/cli/src/commands/config/index.ts">

<violation number="1" location="extensions/cli/src/commands/config/index.ts:127">
P1: Rule violated: **Don't use console.log**

Replace console.log/error with the standard logger (e.g., logger.info/error) per the no-console rule.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

* Verify command - Check if config models are available
*/
async function runVerify(options: ConfigCommandOptions): Promise<void> {
console.log("Verifying config against available models...\n");
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Rule violated: Don't use console.log

Replace console.log/error with the standard logger (e.g., logger.info/error) per the no-console rule.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At extensions/cli/src/commands/config/index.ts, line 127:

<comment>Replace console.log/error with the standard logger (e.g., logger.info/error) per the no-console rule.</comment>

<file context>
@@ -0,0 +1,891 @@
+ * Verify command - Check if config models are available
+ */
+async function runVerify(options: ConfigCommandOptions): Promise<void> {
+  console.log("Verifying config against available models...\n");
+
+  const continueHome = getContinueHome(options.continueHome);
</file context>
Fix with Cubic

- Fix config path resolution test for Windows (use path.join)
- Fix TUI special characters test to avoid @ triggering file search
- Improve waitForCondition using vi.waitFor for better CI reliability
- Increase waitForNextRender delay for slower CI environments
- Skip network-dependent hub integration tests in CI

Authored by: Aaron Lippold<lippold@gmail.com>
@aaronlippold aaronlippold force-pushed the feat/cli-config-command branch from eb0fc5f to 4609b83 Compare January 27, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant