diff --git a/extensions/cli/AGENTS.md b/extensions/cli/AGENTS.md
index 6fe536a46..bfe1f0d39 100644
--- a/extensions/cli/AGENTS.md
+++ b/extensions/cli/AGENTS.md
@@ -18,30 +18,25 @@ This is a CLI tool for Continue Dev that provides an interactive AI-assisted dev
### Core Components
1. **Entry Point** (`src/index.ts`): Main CLI logic with two modes:
-
- **Headless mode**: Non-interactive mode for automation/CI
- **TUI mode**: Terminal User Interface using Ink/React
- **Standard mode**: Traditional readline-based chat interface
2. **Authentication** (`src/auth/`): WorkOS-based authentication system
-
- `ensureAuth.ts`: Handles authentication flow
- `workos.ts`: WorkOS configuration and token management
3. **Continue SDK Integration** (`src/continueSDK.ts`): Initializes the Continue SDK client with:
-
- API key authentication
- Assistant configuration (slug-based)
- Organization support
4. **Terminal UI** (`src/ui/`): React/Ink-based TUI components
-
- `TUIChat.tsx`: Main chat interface component
- `UserInput.tsx`: Input handling with multi-line support
- `TextBuffer.ts`: Text display utilities
5. **Tools System** (`src/tools/`): Built-in development tools including:
-
- File operations (read, write, list)
- Code search functionality
- Terminal command execution
diff --git a/extensions/cli/smoke-test.mjs b/extensions/cli/smoke-test.mjs
index 62e71db37..b4cb6ba2c 100755
--- a/extensions/cli/smoke-test.mjs
+++ b/extensions/cli/smoke-test.mjs
@@ -94,12 +94,12 @@ runTest("Help command", () => {
// Test 5: Check bundle size
runTest("Bundle size is reasonable", () => {
const isWindows = process.platform === "win32";
- const command = isWindows
- ? `powershell -Command "(Get-Item dist/index.js).length / 1MB"`
+ const command = isWindows
+ ? `powershell -Command "(Get-Item dist/index.js).length / 1MB"`
: `ls -lh dist/index.js`;
-
+
let sizeInMB;
-
+
if (isWindows) {
try {
const output = execCommand(command);
diff --git a/extensions/cli/spec/config-loading.md b/extensions/cli/spec/config-loading.md
index 0f474b5a7..384b19809 100644
--- a/extensions/cli/spec/config-loading.md
+++ b/extensions/cli/spec/config-loading.md
@@ -23,13 +23,11 @@ This document specifies the behavior of the CLI's configuration loading system,
**When CLI is invoked, config source is determined in this order:**
1. **CLI `--config` Flag** (highest priority)
-
- File path (starts with `.`, `/`, `~`): Loads local YAML file
- Assistant slug (`owner/package`): Fetches from Continue platform
- Overrides any saved preferences
2. **Saved Config URI** (if no `--config` flag)
-
- Retrieved from authentication config
- Converts `file://` URIs back to file paths
- Converts `slug://` URIs back to assistant slugs
diff --git a/extensions/cli/spec/onboarding.md b/extensions/cli/spec/onboarding.md
index 523b9067e..9b3eaf22e 100644
--- a/extensions/cli/spec/onboarding.md
+++ b/extensions/cli/spec/onboarding.md
@@ -8,7 +8,6 @@ When a user first runs `cn` in interactive mode, they will be taken through "onb
1. If the --config flag is provided, load this config
2. Otherwise, we will present the user with two options:
-
- Log in with Continue: log them in, which will automatically create their assistant and then we can load the first assistant from the first org
- Enter your Anthropic API key: let them enter the key, and then either create a ~/.continue/config.yaml with the following contents OR update the existing config.yaml to add the model
diff --git a/extensions/cli/src/e2e/auth.test.ts b/extensions/cli/src/e2e/auth.test.ts
index 7d7e529a5..79f9352c5 100644
--- a/extensions/cli/src/e2e/auth.test.ts
+++ b/extensions/cli/src/e2e/auth.test.ts
@@ -31,7 +31,7 @@ describe("E2E: Authentication", () => {
JSON.stringify({
accessToken: "test-token",
user: { id: "test-user", email: "test@example.com" },
- })
+ }),
);
// Run logout
diff --git a/extensions/cli/src/e2e/config-switching.test.tsx b/extensions/cli/src/e2e/config-switching.test.tsx
index f9b7073aa..870c94008 100644
--- a/extensions/cli/src/e2e/config-switching.test.tsx
+++ b/extensions/cli/src/e2e/config-switching.test.tsx
@@ -1,115 +1,122 @@
-import { describe, expect, test } from 'vitest';
+import { describe, expect, test } from "vitest";
-describe('Config Switching Implementation Test', () => {
- test('ConfigService updateConfigPath method exists with correct signature', async () => {
- const { ConfigService } = await import('../services/ConfigService.js');
+describe("Config Switching Implementation Test", () => {
+ test("ConfigService updateConfigPath method exists with correct signature", async () => {
+ const { ConfigService } = await import("../services/ConfigService.js");
const configService = new ConfigService();
-
+
// Verify the method exists
expect(configService.updateConfigPath).toBeDefined();
- expect(typeof configService.updateConfigPath).toBe('function');
-
+ expect(typeof configService.updateConfigPath).toBe("function");
+
// Verify it takes 1 parameter (configPath: string | undefined)
expect(configService.updateConfigPath.length).toBe(1);
});
- test('ServiceContainer has required reactive methods', async () => {
- const { serviceContainer } = await import('../services/ServiceContainer.js');
-
+ test("ServiceContainer has required reactive methods", async () => {
+ const { serviceContainer } = await import(
+ "../services/ServiceContainer.js"
+ );
+
// Verify service container has all methods needed for reactive updates
- expect(typeof serviceContainer.set).toBe('function');
- expect(typeof serviceContainer.reload).toBe('function');
- expect(typeof serviceContainer.get).toBe('function');
-
+ expect(typeof serviceContainer.set).toBe("function");
+ expect(typeof serviceContainer.reload).toBe("function");
+ expect(typeof serviceContainer.get).toBe("function");
+
// These are the methods that enable reactive config switching
});
- test('SERVICE_NAMES constants exist for config switching', async () => {
- const { SERVICE_NAMES } = await import('../services/types.js');
-
+ test("SERVICE_NAMES constants exist for config switching", async () => {
+ const { SERVICE_NAMES } = await import("../services/types.js");
+
// Verify the service names our implementation uses (lowercase)
- expect(SERVICE_NAMES.CONFIG).toBe('config');
- expect(SERVICE_NAMES.MODEL).toBe('model');
- expect(SERVICE_NAMES.MCP).toBe('mcp');
- expect(SERVICE_NAMES.AUTH).toBe('auth');
- expect(SERVICE_NAMES.API_CLIENT).toBe('apiClient');
+ expect(SERVICE_NAMES.CONFIG).toBe("config");
+ expect(SERVICE_NAMES.MODEL).toBe("model");
+ expect(SERVICE_NAMES.MCP).toBe("mcp");
+ expect(SERVICE_NAMES.AUTH).toBe("auth");
+ expect(SERVICE_NAMES.API_CLIENT).toBe("apiClient");
});
- test('ConfigService implementation structure is correct', async () => {
- const { ConfigService } = await import('../services/ConfigService.js');
-
+ test("ConfigService implementation structure is correct", async () => {
+ const { ConfigService } = await import("../services/ConfigService.js");
+
// Create instance to verify it can be instantiated
const configService = new ConfigService();
-
+
// Verify it has the required methods for our reactive system
- expect(typeof configService.updateConfigPath).toBe('function');
- expect(typeof configService.getState).toBe('function');
- expect(typeof configService.initialize).toBe('function');
-
+ expect(typeof configService.updateConfigPath).toBe("function");
+ expect(typeof configService.getState).toBe("function");
+ expect(typeof configService.initialize).toBe("function");
+
// The updateConfigPath method is key to reactive config switching
});
- test('loadConfiguration function exists for configuration loading', async () => {
- const configLoaderModule = await import('../configLoader.js');
-
+ test("loadConfiguration function exists for configuration loading", async () => {
+ const configLoaderModule = await import("../configLoader.js");
+
// Verify loadConfiguration function exists and is callable
- expect(typeof configLoaderModule.loadConfiguration).toBe('function');
-
+ expect(typeof configLoaderModule.loadConfiguration).toBe("function");
+
// This is what ConfigService.updateConfigPath uses to load new configs
});
- test('auth functions exist for assistant slug management', async () => {
- const authModule = await import('../auth/workos.js');
-
+ test("auth functions exist for assistant slug management", async () => {
+ const authModule = await import("../auth/workos.js");
+
// Verify auth functions exist for assistant slug handling
- expect(typeof authModule.loadAuthConfig).toBe('function');
- expect(typeof authModule.updateAssistantSlug).toBe('function');
-
+ expect(typeof authModule.loadAuthConfig).toBe("function");
+ expect(typeof authModule.updateAssistantSlug).toBe("function");
+
// These are used by ConfigService.updateConfigPath for auth management
});
- test('expected config switching flow is documented', () => {
+ test("expected config switching flow is documented", () => {
// This test documents the expected behavior:
-
+
const configSwitchingFlow = {
- trigger: '/config command in TUI',
- userAction: 'select different configuration',
+ trigger: "/config command in TUI",
+ userAction: "select different configuration",
codeFlow: [
- 'useConfigSelector calls services.config.updateConfigPath(newPath)',
- 'ConfigService.updateConfigPath loads new config via loadConfiguration()',
- 'ConfigService calls serviceContainer.set(CONFIG, newState)',
- 'ConfigService calls serviceContainer.reload(MODEL)',
- 'ConfigService calls serviceContainer.reload(MCP)',
- 'MODEL service reloads with new model from new config',
- 'IntroMessage re-renders via useServices() reactive hook',
- 'IntroMessage displays new model name'
+ "useConfigSelector calls services.config.updateConfigPath(newPath)",
+ "ConfigService.updateConfigPath loads new config via loadConfiguration()",
+ "ConfigService calls serviceContainer.set(CONFIG, newState)",
+ "ConfigService calls serviceContainer.reload(MODEL)",
+ "ConfigService calls serviceContainer.reload(MCP)",
+ "MODEL service reloads with new model from new config",
+ "IntroMessage re-renders via useServices() reactive hook",
+ "IntroMessage displays new model name",
],
- expectedResult: 'IntroMessage shows model from newly selected config'
+ expectedResult: "IntroMessage shows model from newly selected config",
};
-
+
// Verify our flow documentation is complete
expect(configSwitchingFlow.codeFlow).toHaveLength(8);
- expect(configSwitchingFlow.expectedResult).toContain('IntroMessage shows model');
-
+ expect(configSwitchingFlow.expectedResult).toContain(
+ "IntroMessage shows model",
+ );
+
// The problem we're solving: step 4-5 (serviceContainer.reload calls)
// are what trigger the reactive updates to make IntroMessage update
});
- test('real implementation inspection', async () => {
+ test("real implementation inspection", async () => {
// This test inspects the actual implementation to verify it does what we expect
- const { ConfigService } = await import('../services/ConfigService.js');
-
+ const { ConfigService } = await import("../services/ConfigService.js");
+
// Get the source code of updateConfigPath to verify it contains the right calls
- const updateConfigPathSource = ConfigService.prototype.updateConfigPath.toString();
-
+ const updateConfigPathSource =
+ ConfigService.prototype.updateConfigPath.toString();
+
// Verify the implementation contains the key reactive method calls
- expect(updateConfigPathSource).toContain('serviceContainer.set');
- expect(updateConfigPathSource).toContain('serviceContainer.reload');
- expect(updateConfigPathSource).toContain('SERVICE_NAMES.MODEL');
- expect(updateConfigPathSource).toContain('SERVICE_NAMES.MCP');
- expect(updateConfigPathSource).toContain('loadConfiguration');
-
+ expect(updateConfigPathSource).toContain("serviceContainer.set");
+ expect(updateConfigPathSource).toContain("serviceContainer.reload");
+ expect(updateConfigPathSource).toContain("SERVICE_NAMES.MODEL");
+ expect(updateConfigPathSource).toContain("SERVICE_NAMES.MCP");
+ expect(updateConfigPathSource).toContain("loadConfiguration");
+
// This confirms our implementation has the right structure for reactive updates
- console.log('✅ ConfigService.updateConfigPath implementation contains required reactive calls');
+ console.log(
+ "✅ ConfigService.updateConfigPath implementation contains required reactive calls",
+ );
});
-});
\ No newline at end of file
+});
diff --git a/extensions/cli/src/e2e/headless-anthropic-api-key.test.ts b/extensions/cli/src/e2e/headless-anthropic-api-key.test.ts
index f4a990c12..a13823c69 100644
--- a/extensions/cli/src/e2e/headless-anthropic-api-key.test.ts
+++ b/extensions/cli/src/e2e/headless-anthropic-api-key.test.ts
@@ -63,7 +63,7 @@ models:
const result = await runCLI(context, {
args: ["-p", "--config", context.configPath, "Hi there"],
env: {
- ANTHROPIC_API_KEY: "test-api-key-from-env"
+ ANTHROPIC_API_KEY: "test-api-key-from-env",
},
timeout: 15000,
});
@@ -75,7 +75,7 @@ models:
// Find the user message in the request
const userMessage = mockServer.requests[0].body.messages.find(
- (m: any) => m.role === "user"
+ (m: any) => m.role === "user",
);
expect(userMessage.content).toBe("Hi there");
}, 20000);
@@ -83,12 +83,12 @@ models:
it("should create config and work with ANTHROPIC_API_KEY when no config exists", async () => {
// This test verifies that CLI automatically creates config from ANTHROPIC_API_KEY
// when no config file exists in headless mode
-
+
const result = await runCLI(context, {
args: ["-p", "test prompt"],
env: {
ANTHROPIC_API_KEY: "TEST-test-invalid-key-format",
- CONTINUE_GLOBAL_DIR: context.testDir + "/.continue"
+ CONTINUE_GLOBAL_DIR: context.testDir + "/.continue",
},
expectError: false, // Config creation succeeds even with invalid key
timeout: 15000,
@@ -97,19 +97,24 @@ models:
// The CLI should create config and exit successfully in headless mode
// (it doesn't actually make API calls unless there's a valid provider setup)
expect(result.exitCode).toBe(0);
-
+
// Should NOT contain the old error about service initialization
expect(result.stderr).not.toContain("Failed to initialize ConfigService");
// Verify config.yaml was automatically created
const configPath = path.join(context.testDir, ".continue", "config.yaml");
- const configExists = await fs.stat(configPath).then(() => true).catch(() => false);
+ const configExists = await fs
+ .stat(configPath)
+ .then(() => true)
+ .catch(() => false);
expect(configExists).toBe(true);
if (configExists) {
const configContent = await fs.readFile(configPath, "utf-8");
expect(configContent).toContain("anthropic/claude-4-sonnet");
- expect(configContent).toContain("ANTHROPIC_API_KEY: TEST-test-invalid-key-format");
+ expect(configContent).toContain(
+ "ANTHROPIC_API_KEY: TEST-test-invalid-key-format",
+ );
}
}, 20000);
-});
\ No newline at end of file
+});
diff --git a/extensions/cli/src/e2e/headless-dynamic-responses.test.ts b/extensions/cli/src/e2e/headless-dynamic-responses.test.ts
index 0414d0838..7109a0bd5 100644
--- a/extensions/cli/src/e2e/headless-dynamic-responses.test.ts
+++ b/extensions/cli/src/e2e/headless-dynamic-responses.test.ts
@@ -28,29 +28,31 @@ describe("E2E: Headless Mode with Dynamic Responses", () => {
afterEach(async () => {
// Clean up all extra servers first
if (extraServers.length > 0) {
- await Promise.all(extraServers.map(server => cleanupMockLLMServer(server)));
+ await Promise.all(
+ extraServers.map((server) => cleanupMockLLMServer(server)),
+ );
extraServers = [];
}
-
+
// Clean up main server
if (mockServer) {
await cleanupMockLLMServer(mockServer);
mockServer = undefined as any;
}
-
+
// Clean up context last
if (context) {
await cleanupTestContext(context);
context = undefined;
}
-
+
// Small delay to ensure cleanup completes
- await new Promise(resolve => setTimeout(resolve, 50));
+ await new Promise((resolve) => setTimeout(resolve, 50));
});
it("should respond dynamically based on prompt content", async () => {
context = await createTestContext();
-
+
// Create a mock server with dynamic responses
mockServer = await setupMockLLMTest(context, {
response: (prompt: string) => {
@@ -70,28 +72,33 @@ describe("E2E: Headless Mode with Dynamic Responses", () => {
timeout: 15000,
});
expect(weatherResult.stdout).toContain("It's sunny and 72°F today!");
-
+
// Test time query
const timeResult = await runCLI(context, {
args: ["-p", "--config", context.configPath, "What time is it?"],
timeout: 15000,
});
expect(timeResult.stdout).toContain("The current time is 3:30 PM.");
-
+
// Test unknown query
const unknownResult = await runCLI(context, {
- args: ["-p", "--config", context.configPath, "Tell me about quantum physics"],
+ args: [
+ "-p",
+ "--config",
+ context.configPath,
+ "Tell me about quantum physics",
+ ],
timeout: 15000,
});
expect(unknownResult.stdout).toContain("I don't understand your question.");
-
+
// Verify all requests were tracked
expect(mockServer.requests).toHaveLength(3);
});
it("should work with non-streaming responses", async () => {
context = await createTestContext();
-
+
mockServer = await setupMockLLMTest(context, {
response: "Non-streaming response",
streaming: false,
@@ -108,18 +115,18 @@ describe("E2E: Headless Mode with Dynamic Responses", () => {
it("should handle multiple mock servers for different models", async () => {
context = await createTestContext();
-
+
// Create two different mock servers and track them for cleanup
const gpt4Server = await createMockLLMServer({
response: "Response from GPT-4",
});
extraServers.push(gpt4Server);
-
+
const claudeServer = await createMockLLMServer({
response: "Response from Claude",
});
extraServers.push(claudeServer);
-
+
// Create a config with multiple models
const configContent = `name: Multi-Model Assistant
version: 1.0.0
@@ -138,49 +145,55 @@ models:
apiKey: test-key-2
apiBase: ${claudeServer.url}
`;
-
+
const configPath = path.join(context.testDir, "multi-model-config.yaml");
await fs.writeFile(configPath, configContent);
context.configPath = configPath;
-
+
// Create onboarding flag
- const onboardingFlagPath = path.join(context.testDir, ".continue", ".onboarding_complete");
+ const onboardingFlagPath = path.join(
+ context.testDir,
+ ".continue",
+ ".onboarding_complete",
+ );
await fs.mkdir(path.dirname(onboardingFlagPath), { recursive: true });
await fs.writeFile(onboardingFlagPath, new Date().toISOString());
-
+
// Test with the first model (GPT-4 should be default)
const result = await runCLI(context, {
args: ["-p", "--config", context.configPath, "Hello"],
timeout: 15000,
});
-
+
expect(result.stdout).toContain("Response from GPT-4");
expect(gpt4Server.requests).toHaveLength(1);
expect(claudeServer.requests).toHaveLength(0);
-
+
// Servers will be cleaned up in afterEach
});
it("should allow custom request handling", async () => {
context = await createTestContext();
-
+
let requestCount = 0;
const responses = ["First response", "Second response", "Third response"];
-
+
// Create server with custom handler
mockServer = await createMockLLMServer({
customHandler: (req, res) => {
if (req.method === "POST" && req.url === "/chat/completions") {
const response = responses[requestCount % responses.length];
requestCount++;
-
+
res.writeHead(200, {
"Content-Type": "text/event-stream",
"Cache-Control": "no-cache",
- "Connection": "keep-alive",
+ Connection: "keep-alive",
});
-
- res.write(`data: {"choices":[{"delta":{"content":"${response}"},"index":0}]}\n\n`);
+
+ res.write(
+ `data: {"choices":[{"delta":{"content":"${response}"},"index":0}]}\n\n`,
+ );
res.write(`data: [DONE]\n\n`);
res.end();
} else {
@@ -189,17 +202,21 @@ models:
}
},
});
-
+
// Set up the test environment
const configContent = createMockLLMConfig(mockServer);
const configPath = path.join(context.testDir, "test-config.yaml");
await fs.writeFile(configPath, configContent);
context.configPath = configPath;
-
- const onboardingFlagPath = path.join(context.testDir, ".continue", ".onboarding_complete");
+
+ const onboardingFlagPath = path.join(
+ context.testDir,
+ ".continue",
+ ".onboarding_complete",
+ );
await fs.mkdir(path.dirname(onboardingFlagPath), { recursive: true });
await fs.writeFile(onboardingFlagPath, new Date().toISOString());
-
+
// Make multiple requests
for (let i = 0; i < 3; i++) {
const result = await runCLI(context, {
@@ -209,4 +226,4 @@ models:
expect(result.stdout).toContain(responses[i]);
}
});
-});
\ No newline at end of file
+});
diff --git a/extensions/cli/src/e2e/headless-json-format.test.ts b/extensions/cli/src/e2e/headless-json-format.test.ts
index 9acd3a720..a8dc4d0ad 100644
--- a/extensions/cli/src/e2e/headless-json-format.test.ts
+++ b/extensions/cli/src/e2e/headless-json-format.test.ts
@@ -28,7 +28,7 @@ describe("E2E: Headless Mode with JSON Format", () => {
const validJsonResponse = {
response: "This is a JSON response",
status: "success",
- files: ["test.ts"]
+ files: ["test.ts"],
};
mockServer = await setupMockLLMTest(context, {
@@ -37,7 +37,14 @@ describe("E2E: Headless Mode with JSON Format", () => {
});
const result = await runCLI(context, {
- args: ["-p", "--format", "json", "--config", context.configPath, "Test prompt"],
+ args: [
+ "-p",
+ "--format",
+ "json",
+ "--config",
+ context.configPath,
+ "Test prompt",
+ ],
timeout: 15000,
});
@@ -56,7 +63,14 @@ describe("E2E: Headless Mode with JSON Format", () => {
});
const result = await runCLI(context, {
- args: ["-p", "--format", "json", "--config", context.configPath, "Test prompt"],
+ args: [
+ "-p",
+ "--format",
+ "json",
+ "--config",
+ context.configPath,
+ "Test prompt",
+ ],
timeout: 15000,
});
@@ -65,7 +79,9 @@ describe("E2E: Headless Mode with JSON Format", () => {
const parsedOutput = JSON.parse(result.stdout.trim());
expect(parsedOutput.response).toBe(nonJsonResponse);
expect(parsedOutput.status).toBe("success");
- expect(parsedOutput.note).toBe("Response was not valid JSON, so it was wrapped in a JSON object");
+ expect(parsedOutput.note).toBe(
+ "Response was not valid JSON, so it was wrapped in a JSON object",
+ );
expect(result.exitCode).toBe(0);
}, 20000);
@@ -81,11 +97,15 @@ describe("E2E: Headless Mode with JSON Format", () => {
expect(result.exitCode).toBe(0);
expect(mockServer.requests).toHaveLength(1);
-
+
// Find the system message
- const systemMessage = mockServer.requests[0].body.messages.find((m: any) => m.role === "system");
+ const systemMessage = mockServer.requests[0].body.messages.find(
+ (m: any) => m.role === "system",
+ );
expect(systemMessage.content).toContain("JSON output mode");
- expect(systemMessage.content).toContain("valid JSON that can be parsed by JSON.parse()");
+ expect(systemMessage.content).toContain(
+ "valid JSON that can be parsed by JSON.parse()",
+ );
}, 20000);
it("should fail validation when --format is used without -p flag", async () => {
@@ -95,7 +115,9 @@ describe("E2E: Headless Mode with JSON Format", () => {
expectError: true,
});
- expect(result.stderr).toContain("--format flag can only be used with -p/--print flag");
+ expect(result.stderr).toContain(
+ "--format flag can only be used with -p/--print flag",
+ );
expect(result.exitCode).toBe(1);
}, 10000);
@@ -109,4 +131,4 @@ describe("E2E: Headless Mode with JSON Format", () => {
expect(result.stderr).toContain("--format currently only supports 'json'");
expect(result.exitCode).toBe(1);
}, 10000);
-});
\ No newline at end of file
+});
diff --git a/extensions/cli/src/e2e/headless-minimal.test.ts b/extensions/cli/src/e2e/headless-minimal.test.ts
index 5e7ace9db..e799c2ad0 100644
--- a/extensions/cli/src/e2e/headless-minimal.test.ts
+++ b/extensions/cli/src/e2e/headless-minimal.test.ts
@@ -25,7 +25,7 @@ describe("E2E: Headless Mode (Minimal)", () => {
configPath,
`name: Test Assistant
model: gpt-4
-provider: openai`
+provider: openai`,
);
// For now, just test that it tries to load the config
diff --git a/extensions/cli/src/e2e/headless-missing-prompt.test.ts b/extensions/cli/src/e2e/headless-missing-prompt.test.ts
index a3e9c086a..18d38f7cd 100644
--- a/extensions/cli/src/e2e/headless-missing-prompt.test.ts
+++ b/extensions/cli/src/e2e/headless-missing-prompt.test.ts
@@ -1,4 +1,9 @@
-import { createTestContext, cleanupTestContext, runCLI, createTestConfig } from "../test-helpers/cli-helpers.js";
+import {
+ createTestContext,
+ cleanupTestContext,
+ runCLI,
+ createTestConfig,
+} from "../test-helpers/cli-helpers.js";
describe("E2E: Headless Mode - Missing Prompt", () => {
let context: any;
@@ -12,7 +17,9 @@ describe("E2E: Headless Mode - Missing Prompt", () => {
});
it("should exit with helpful error message when no prompt is provided with -p flag", async () => {
- await createTestConfig(context, `name: Test Assistant
+ await createTestConfig(
+ context,
+ `name: Test Assistant
version: 1.0.0
schema: v1
models:
@@ -20,7 +27,8 @@ models:
provider: openai
apiKey: test-key
roles:
- - chat`);
+ - chat`,
+ );
const result = await runCLI(context, {
args: ["-p", "--config", context.configPath],
@@ -31,17 +39,21 @@ models:
// Should exit with non-zero exit code
expect(result.exitCode).toBe(1);
-
+
// Should provide helpful error message
const output = result.stderr + result.stdout;
- expect(output).toContain("A prompt is required when using the -p/--print flag");
+ expect(output).toContain(
+ "A prompt is required when using the -p/--print flag",
+ );
expect(output).toContain('cn -p "please review my current git diff"');
expect(output).toContain('echo "hello" | cn -p');
expect(output).toContain('cn -p "analyze the code in src/"');
});
it("should work correctly when prompt is provided with -p flag", async () => {
- await createTestConfig(context, `name: Test Assistant
+ await createTestConfig(
+ context,
+ `name: Test Assistant
version: 1.0.0
schema: v1
models:
@@ -49,7 +61,8 @@ models:
provider: openai
apiKey: test-key
roles:
- - chat`);
+ - chat`,
+ );
const result = await runCLI(context, {
args: ["-p", "--config", context.configPath, "Hello assistant"],
@@ -60,17 +73,21 @@ models:
// Should attempt to process the prompt (will fail due to invalid API key)
expect(result.exitCode).not.toBe(0);
-
+
// Should NOT show the "prompt required" error message
const output = result.stderr + result.stdout;
- expect(output).not.toContain("A prompt is required when using the -p/--print flag");
+ expect(output).not.toContain(
+ "A prompt is required when using the -p/--print flag",
+ );
});
it("should work correctly when prompt is provided via stdin with -p flag", async () => {
// NOTE: In our current implementation, stdin reading is disabled in test environments
// for safety (to prevent hanging). This test verifies the expected behavior when
// stdin input is provided but cannot be read during tests.
- await createTestConfig(context, `name: Test Assistant
+ await createTestConfig(
+ context,
+ `name: Test Assistant
version: 1.0.0
schema: v1
models:
@@ -78,7 +95,8 @@ models:
provider: openai
apiKey: test-key
roles:
- - chat`);
+ - chat`,
+ );
const result = await runCLI(context, {
args: ["-p", "--config", context.configPath],
@@ -90,14 +108,18 @@ models:
// Should exit with error code due to missing prompt (stdin reading is disabled in tests)
expect(result.exitCode).toBe(1);
-
+
// Should show the "prompt required" error message since stdin reading is disabled in test env
const output = result.stderr + result.stdout;
- expect(output).toContain("A prompt is required when using the -p/--print flag");
+ expect(output).toContain(
+ "A prompt is required when using the -p/--print flag",
+ );
});
it("should prioritize command line prompt over stdin when both are provided", async () => {
- await createTestConfig(context, `name: Test Assistant
+ await createTestConfig(
+ context,
+ `name: Test Assistant
version: 1.0.0
schema: v1
models:
@@ -105,7 +127,8 @@ models:
provider: openai
apiKey: test-key
roles:
- - chat`);
+ - chat`,
+ );
const result = await runCLI(context, {
args: ["-p", "--config", context.configPath, "Command line prompt"],
@@ -117,9 +140,11 @@ models:
// Should use command line prompt over stdin
expect(result.exitCode).not.toBe(0);
-
+
// Should NOT show the "prompt required" error message
const output = result.stderr + result.stdout;
- expect(output).not.toContain("A prompt is required when using the -p/--print flag");
+ expect(output).not.toContain(
+ "A prompt is required when using the -p/--print flag",
+ );
});
-});
\ No newline at end of file
+});
diff --git a/extensions/cli/src/e2e/headless-mock-llm.test.ts b/extensions/cli/src/e2e/headless-mock-llm.test.ts
index c6480e0dd..afaafa696 100644
--- a/extensions/cli/src/e2e/headless-mock-llm.test.ts
+++ b/extensions/cli/src/e2e/headless-mock-llm.test.ts
@@ -46,13 +46,20 @@ describe("E2E: Headless Mode with Mock Server", () => {
expect(result.exitCode).toBe(0);
expect(mockServer.requests).toHaveLength(1);
// Find the user message (system message is first)
- const userMessage = mockServer.requests[0].body.messages.find((m: any) => m.role === "user");
+ const userMessage = mockServer.requests[0].body.messages.find(
+ (m: any) => m.role === "user",
+ );
expect(userMessage.content).toBe("Say hello");
}, 20000);
it("should work with longer prompts", async () => {
const result = await runCLI(context, {
- args: ["-p", "--config", context.configPath, "Please respond with exactly 'Hello World!' and nothing else"],
+ args: [
+ "-p",
+ "--config",
+ context.configPath,
+ "Please respond with exactly 'Hello World!' and nothing else",
+ ],
timeout: 15000,
});
@@ -60,7 +67,11 @@ describe("E2E: Headless Mode with Mock Server", () => {
expect(result.exitCode).toBe(0);
expect(mockServer.requests).toHaveLength(1);
// Find the user message (system message is first)
- const userMessage = mockServer.requests[0].body.messages.find((m: any) => m.role === "user");
- expect(userMessage.content).toBe("Please respond with exactly 'Hello World!' and nothing else");
+ const userMessage = mockServer.requests[0].body.messages.find(
+ (m: any) => m.role === "user",
+ );
+ expect(userMessage.content).toBe(
+ "Please respond with exactly 'Hello World!' and nothing else",
+ );
}, 20000);
-});
\ No newline at end of file
+});
diff --git a/extensions/cli/src/e2e/headless-org-flag.test.ts b/extensions/cli/src/e2e/headless-org-flag.test.ts
index 7cb167675..3cffb67fd 100644
--- a/extensions/cli/src/e2e/headless-org-flag.test.ts
+++ b/extensions/cli/src/e2e/headless-org-flag.test.ts
@@ -48,7 +48,7 @@ models:
expect(result.exitCode).not.toBe(0);
expect(result.stderr).toContain(
- "--org flag is only supported in headless mode (with -p/--print flag)"
+ "--org flag is only supported in headless mode (with -p/--print flag)",
);
});
@@ -71,7 +71,7 @@ models:
// Should fail for a different reason (no actual auth/API), not because of flag validation
expect(result.stderr).not.toContain(
- "--org flag is only supported in headless mode (with -p/--print flag)"
+ "--org flag is only supported in headless mode (with -p/--print flag)",
);
});
});
@@ -97,8 +97,8 @@ models:
// The org flag should be inherited and work in headless mode
expect(result.stderr).not.toContain(
- "--org flag is only supported in headless mode (with -p/--print flag)"
+ "--org flag is only supported in headless mode (with -p/--print flag)",
);
});
});
-});
\ No newline at end of file
+});
diff --git a/extensions/cli/src/e2e/headless-silent-flag.test.ts b/extensions/cli/src/e2e/headless-silent-flag.test.ts
index d2eec2c2a..0798d50df 100644
--- a/extensions/cli/src/e2e/headless-silent-flag.test.ts
+++ b/extensions/cli/src/e2e/headless-silent-flag.test.ts
@@ -39,7 +39,13 @@ echo "Hello World"`;
});
const result = await runCLI(context, {
- args: ["-p", "--silent", "--config", context.configPath, "Write a shell script"],
+ args: [
+ "-p",
+ "--silent",
+ "--config",
+ context.configPath,
+ "Write a shell script",
+ ],
timeout: 15000,
});
@@ -47,7 +53,7 @@ echo "Hello World"`;
expect(result.stdout).not.toContain("");
expect(result.stdout).not.toContain("");
expect(result.stdout).not.toContain("I need to write a shell script");
-
+
// Verify the actual content remains
expect(result.stdout).toContain("#!/bin/bash");
expect(result.stdout).toContain('echo "Hello World"');
@@ -84,7 +90,7 @@ Final content`;
expect(result.stdout).not.toContain("First thought block");
expect(result.stdout).not.toContain("Second thought block");
expect(result.stdout).not.toContain("More thinking...");
-
+
// Verify the actual content remains
expect(result.stdout).toContain("Some content here");
expect(result.stdout).toContain("Final content");
@@ -119,7 +125,7 @@ More content`;
expect(result.stdout).not.toContain("This will be removed");
expect(result.stdout).toContain("Content with lots of whitespace");
expect(result.stdout).toContain("More content");
-
+
// Verify no triple newlines exist (excess whitespace reduced)
expect(result.stdout).not.toMatch(/\n\s*\n\s*\n/);
expect(result.exitCode).toBe(0);
@@ -164,7 +170,13 @@ This is a simple script.`;
});
const result = await runCLI(context, {
- args: ["-p", "--silent", "--config", context.configPath, "Write a shell script"],
+ args: [
+ "-p",
+ "--silent",
+ "--config",
+ context.configPath,
+ "Write a shell script",
+ ],
timeout: 15000,
});
@@ -182,7 +194,9 @@ This is a simple script.`;
expectError: true,
});
- expect(result.stderr).toContain("--silent flag can only be used with -p/--print flag");
+ expect(result.stderr).toContain(
+ "--silent flag can only be used with -p/--print flag",
+ );
expect(result.exitCode).toBe(1);
}, 10000);
@@ -199,14 +213,22 @@ I should respond with JSON
});
const result = await runCLI(context, {
- args: ["-p", "--silent", "--format", "json", "--config", context.configPath, "Test prompt"],
+ args: [
+ "-p",
+ "--silent",
+ "--format",
+ "json",
+ "--config",
+ context.configPath,
+ "Test prompt",
+ ],
timeout: 15000,
});
// Verify think tags are stripped and JSON is valid
expect(result.stdout).not.toContain("");
expect(result.stdout).not.toContain("I should respond with JSON");
-
+
// Verify the output is valid JSON
expect(() => JSON.parse(result.stdout.trim())).not.toThrow();
const parsedOutput = JSON.parse(result.stdout.trim());
@@ -214,4 +236,4 @@ I should respond with JSON
expect(parsedOutput.status).toBe("success");
expect(result.exitCode).toBe(0);
}, 20000);
-});
\ No newline at end of file
+});
diff --git a/extensions/cli/src/e2e/headless-simple.test.ts b/extensions/cli/src/e2e/headless-simple.test.ts
index e191fb44d..a94a72977 100644
--- a/extensions/cli/src/e2e/headless-simple.test.ts
+++ b/extensions/cli/src/e2e/headless-simple.test.ts
@@ -1,4 +1,9 @@
-import { createTestContext, cleanupTestContext, runCLI, createTestConfig } from "../test-helpers/cli-helpers.js";
+import {
+ createTestContext,
+ cleanupTestContext,
+ runCLI,
+ createTestConfig,
+} from "../test-helpers/cli-helpers.js";
describe("E2E: Headless Mode (Simple)", () => {
let context: any;
@@ -35,14 +40,17 @@ models:
it("should fail gracefully when config is invalid", async () => {
// Test with invalid config
- await createTestConfig(context, `invalid: yaml
-no models here`);
-
+ await createTestConfig(
+ context,
+ `invalid: yaml
+no models here`,
+ );
+
const result = await runCLI(context, {
args: ["-p", "--config", context.configPath, "Test"],
expectError: true,
});
-
+
expect(result.exitCode).not.toBe(0);
});
@@ -52,26 +60,26 @@ no models here`);
it("should handle missing prompt in headless mode", async () => {
await createTestConfig(context, testConfig);
-
+
const result = await runCLI(context, {
args: ["-p", "--config", context.configPath],
env: testEnv,
expectError: true,
});
-
+
expect(result.exitCode).not.toBe(0);
});
it("should accept piped input with -p flag", async () => {
await createTestConfig(context, testConfig);
-
+
const result = await runCLI(context, {
args: ["-p", "--config", context.configPath],
env: testEnv,
input: "Hello from piped input",
expectError: true,
});
-
+
expect(result.stderr).not.toContain("You:");
expect(result.stdout).not.toContain("You:");
expect(result.exitCode).not.toBe(0);
@@ -79,14 +87,14 @@ no models here`);
it("should combine piped input with prompt argument", async () => {
await createTestConfig(context, testConfig);
-
+
const result = await runCLI(context, {
args: ["-p", "--config", context.configPath, "Command line argument"],
env: testEnv,
input: "Piped input to be combined",
expectError: true,
});
-
+
expect(result.stderr).not.toContain("You:");
expect(result.stdout).not.toContain("You:");
expect(result.exitCode).not.toBe(0);
@@ -94,16 +102,21 @@ no models here`);
it("should work with only prompt argument", async () => {
await createTestConfig(context, testConfig);
-
+
const result = await runCLI(context, {
- args: ["-p", "--config", context.configPath, "Only command line argument"],
+ args: [
+ "-p",
+ "--config",
+ context.configPath,
+ "Only command line argument",
+ ],
env: testEnv,
expectError: true,
});
-
+
expect(result.stderr).not.toContain("You:");
expect(result.stdout).not.toContain("You:");
expect(result.exitCode).not.toBe(0);
});
});
-});
\ No newline at end of file
+});
diff --git a/extensions/cli/src/e2e/headless-tool-calls.test.ts b/extensions/cli/src/e2e/headless-tool-calls.test.ts
index 0f2887f2b..dd7c8e843 100644
--- a/extensions/cli/src/e2e/headless-tool-calls.test.ts
+++ b/extensions/cli/src/e2e/headless-tool-calls.test.ts
@@ -48,15 +48,15 @@ describe("E2E: Headless Mode with Tool Calls", () => {
// Send only tool call (no text content)
res.write(
- `data: {"choices":[{"delta":{"tool_calls":[{"index":0,"id":"call_123","type":"function","function":{"name":"search_code"}}]},"index":0}]}\n\n`
+ `data: {"choices":[{"delta":{"tool_calls":[{"index":0,"id":"call_123","type":"function","function":{"name":"search_code"}}]},"index":0}]}\n\n`,
);
res.write(
- `data: {"choices":[{"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\\"pattern\\":\\"createTestContext\\"}"}}]},"index":0}]}\n\n`
+ `data: {"choices":[{"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\\"pattern\\":\\"createTestContext\\"}"}}]},"index":0}]}\n\n`,
);
// Send usage data
res.write(
- `data: {"usage":{"prompt_tokens":10,"completion_tokens":20}}\n\n`
+ `data: {"usage":{"prompt_tokens":10,"completion_tokens":20}}\n\n`,
);
// End the stream
diff --git a/extensions/cli/src/e2e/local-config-switching.test.tsx b/extensions/cli/src/e2e/local-config-switching.test.tsx
index 2a289566c..b82ee3e88 100644
--- a/extensions/cli/src/e2e/local-config-switching.test.tsx
+++ b/extensions/cli/src/e2e/local-config-switching.test.tsx
@@ -1,23 +1,23 @@
-import { describe, expect, test } from 'vitest';
+import { describe, expect, test } from "vitest";
-describe('Local Config Switching Investigation', () => {
- test('understands local vs remote config paths', () => {
+describe("Local Config Switching Investigation", () => {
+ test("understands local vs remote config paths", () => {
// Document the different types of config paths:
-
+
const configTypes = {
localFilePaths: [
- '~/.continue/config.yaml',
- './config.yaml',
- '/absolute/path/to/config.yaml'
+ "~/.continue/config.yaml",
+ "./config.yaml",
+ "/absolute/path/to/config.yaml",
],
remoteAssistantSlugs: [
- 'continuedev/default-agent',
- 'myorg/custom-assistant',
- 'user/my-assistant'
+ "continuedev/default-agent",
+ "myorg/custom-assistant",
+ "user/my-assistant",
],
- undefinedMeansDefault: undefined // Uses saved assistant slug or first assistant
+ undefinedMeansDefault: undefined, // Uses saved assistant slug or first assistant
};
-
+
// The isFilePath method checks for these patterns:
const isFilePath = (configPath: string) => {
return (
@@ -26,128 +26,135 @@ describe('Local Config Switching Investigation', () => {
configPath.startsWith("~")
);
};
-
+
// Verify our understanding
- configTypes.localFilePaths.forEach(path => {
+ configTypes.localFilePaths.forEach((path) => {
expect(isFilePath(path)).toBe(true);
});
-
- configTypes.remoteAssistantSlugs.forEach(slug => {
+
+ configTypes.remoteAssistantSlugs.forEach((slug) => {
expect(isFilePath(slug)).toBe(false);
});
});
- test('documents the local config switching problem', () => {
+ test("documents the local config switching problem", () => {
// User reported issue: "Switching configs always works except when I'm using a local config"
-
+
const problemScenarios = [
{
- name: 'Remote to Remote switching',
- from: 'continuedev/default-agent',
- to: 'myorg/custom-assistant',
+ name: "Remote to Remote switching",
+ from: "continuedev/default-agent",
+ to: "myorg/custom-assistant",
works: true,
- reason: 'Both are assistant slugs, normal flow works'
+ reason: "Both are assistant slugs, normal flow works",
},
{
- name: 'Remote to Local switching',
- from: 'continuedev/default-agent',
- to: '~/.continue/config.yaml',
+ name: "Remote to Local switching",
+ from: "continuedev/default-agent",
+ to: "~/.continue/config.yaml",
works: false, // This is the reported issue
- reason: 'UNKNOWN - this is what we need to debug'
+ reason: "UNKNOWN - this is what we need to debug",
},
{
- name: 'Local to Remote switching',
- from: '~/.continue/config.yaml',
- to: 'continuedev/default-agent',
+ name: "Local to Remote switching",
+ from: "~/.continue/config.yaml",
+ to: "continuedev/default-agent",
works: false, // Likely also broken
- reason: 'UNKNOWN - probably same root cause'
+ reason: "UNKNOWN - probably same root cause",
},
{
- name: 'Local to Local switching',
- from: '~/.continue/config.yaml',
- to: './other-config.yaml',
+ name: "Local to Local switching",
+ from: "~/.continue/config.yaml",
+ to: "./other-config.yaml",
works: false, // Likely also broken
- reason: 'UNKNOWN - probably same root cause'
- }
+ reason: "UNKNOWN - probably same root cause",
+ },
];
-
+
// The problem is specifically with local configs
- const brokenScenarios = problemScenarios.filter(s => !s.works);
+ const brokenScenarios = problemScenarios.filter((s) => !s.works);
expect(brokenScenarios.length).toBeGreaterThan(0);
-
+
// All broken scenarios involve local configs
- const allInvolveLocalConfigs = brokenScenarios.every(scenario =>
- scenario.from.includes('/') || scenario.from.includes('~') || scenario.from.includes('.') ||
- scenario.to.includes('/') || scenario.to.includes('~') || scenario.to.includes('.')
+ const allInvolveLocalConfigs = brokenScenarios.every(
+ (scenario) =>
+ scenario.from.includes("/") ||
+ scenario.from.includes("~") ||
+ scenario.from.includes(".") ||
+ scenario.to.includes("/") ||
+ scenario.to.includes("~") ||
+ scenario.to.includes("."),
);
expect(allInvolveLocalConfigs).toBe(true);
});
- test('hypothesis: local config loading has different behavior', async () => {
+ test("hypothesis: local config loading has different behavior", async () => {
// The loadConfiguration function has different code paths:
-
- const { loadConfiguration } = await import('../configLoader.js');
-
+
+ const { loadConfiguration } = await import("../configLoader.js");
+
// Path 1: Local file loading (lines 176-189 in config.ts)
// if (config.startsWith(".") || config.startsWith("/") || config.startsWith("~")) {
// const configYaml = await loadConfigYaml(authConfig?.accessToken ?? null, config, organizationId, apiClient);
// return configYaml;
// }
-
- // Path 2: Remote assistant slug loading (lines 190-203 in config.ts)
+
+ // Path 2: Remote assistant slug loading (lines 190-203 in config.ts)
// else {
// const [ownerSlug, packageSlug] = config.split("/");
// const resp = await apiClient.getAssistant({ ownerSlug, packageSlug, ... });
// return result.config;
// }
-
+
// Hypothesis: The loadConfiguration function works correctly, but something else is different
// about how local configs are handled in the ConfigService or service container
-
- expect(typeof loadConfiguration).toBe('function');
-
+
+ expect(typeof loadConfiguration).toBe("function");
+
// The issue might be:
// 1. Different state management for local vs remote configs
- // 2. Assistant slug handling interfering with local configs
+ // 2. Assistant slug handling interfering with local configs
// 3. Service container reload behavior differs for local configs
// 4. Some caching or memoization issue specific to file paths
});
- test('investigates assistant slug handling for local configs', async () => {
+ test("investigates assistant slug handling for local configs", async () => {
// When switching to a local config, we call updateAssistantSlug(null)
// When switching to a remote config, we call updateAssistantSlug(configPath)
-
- const { updateAssistantSlug, getAssistantSlug } = await import('../auth/workos.js');
-
- expect(typeof updateAssistantSlug).toBe('function');
- expect(typeof getAssistantSlug).toBe('function');
-
- // Question: Could the assistant slug clearing/setting be interfering
+
+ const { updateAssistantSlug, getAssistantSlug } = await import(
+ "../auth/workos.js"
+ );
+
+ expect(typeof updateAssistantSlug).toBe("function");
+ expect(typeof getAssistantSlug).toBe("function");
+
+ // Question: Could the assistant slug clearing/setting be interfering
// with the config loading process?
-
+
// In loadConfiguration, when config is undefined, it checks for saved assistant slug:
// const assistantSlug = getAssistantSlug(authConfig);
// if (assistantSlug) { config = assistantSlug; }
-
- // Potential issue: If we're switching TO a local config but the assistant slug
+
+ // Potential issue: If we're switching TO a local config but the assistant slug
// is still set from a previous remote config, could that interfere?
});
- test('checks if ConfigService state management differs for local configs', async () => {
- const { ConfigService } = await import('../services/ConfigService.js');
-
+ test("checks if ConfigService state management differs for local configs", async () => {
+ const { ConfigService } = await import("../services/ConfigService.js");
+
// The ConfigService.updateConfigPath method should work the same for both types:
// 1. Load new config via loadConfiguration(authConfig, newConfigPath, ...)
// 2. Update this.currentState = { config, configPath: newConfigPath }
// 3. Call serviceContainer.set(CONFIG, this.currentState)
// 4. Call serviceContainer.reload(MODEL) and serviceContainer.reload(MCP)
-
+
// But maybe there's a subtle difference in how the state is managed?
-
+
const configService = new ConfigService();
- expect(typeof configService.getState).toBe('function');
-
+ expect(typeof configService.getState).toBe("function");
+
// The state should be: { config: AssistantUnrolled, configPath: string | undefined }
// This should be the same regardless of whether configPath is a file or slug
});
-});
\ No newline at end of file
+});
diff --git a/extensions/cli/src/e2e/pipe-input-tui.test.ts b/extensions/cli/src/e2e/pipe-input-tui.test.ts
index 99932a6da..be02d4ec7 100644
--- a/extensions/cli/src/e2e/pipe-input-tui.test.ts
+++ b/extensions/cli/src/e2e/pipe-input-tui.test.ts
@@ -45,7 +45,9 @@ models:
// With explicit -p flag, should be in headless mode
// Should show headless mode error (no prompt provided when input is ignored in test)
- expect(result.stderr).toContain("A prompt is required when using the -p/--print flag");
+ expect(result.stderr).toContain(
+ "A prompt is required when using the -p/--print flag",
+ );
expect(result.exitCode).not.toBe(0);
});
@@ -62,9 +64,11 @@ models:
// With explicit -p flag and prompt, should attempt headless mode
// Will fail due to missing LLM configuration, but that's expected
expect(result.exitCode).not.toBe(0);
-
+
// Should not show the "prompt required" error since we provided one
- expect(result.stderr).not.toContain("A prompt is required when using the -p/--print flag");
+ expect(result.stderr).not.toContain(
+ "A prompt is required when using the -p/--print flag",
+ );
});
it("should try to start TUI mode when no explicit flags are provided", async () => {
@@ -81,8 +85,10 @@ models:
// Without -p flag, should attempt TUI mode
// In test environment, this will likely fail quickly due to stdin/TTY issues
// but the important thing is that it doesn't immediately error about missing prompt
- expect(result.stderr).not.toContain("A prompt is required when using the -p/--print flag");
-
+ expect(result.stderr).not.toContain(
+ "A prompt is required when using the -p/--print flag",
+ );
+
// Should exit with error due to test environment limitations
expect(result.exitCode).not.toBe(0);
});
@@ -103,10 +109,12 @@ models:
expect(result.exitCode).toBeDefined();
expect(typeof result.stdout).toBe("string");
expect(typeof result.stderr).toBe("string");
-
+
// On any platform, should not show headless-mode specific errors
// when no -p flag is provided
- expect(result.stderr).not.toContain("A prompt is required when using the -p/--print flag");
+ expect(result.stderr).not.toContain(
+ "A prompt is required when using the -p/--print flag",
+ );
});
});
@@ -210,17 +218,17 @@ models:
* Note: This test suite focuses on testing the CLI behavior within the constraints
* of the test environment. The actual pipe input detection cannot be fully tested
* here because:
- *
+ *
* 1. readStdinSync() returns null when CONTINUE_CLI_TEST=true to prevent hanging
* 2. TUI mode requires real TTY access which isn't available in test subprocesses
* 3. Cross-platform TTY behavior varies significantly
- *
+ *
* However, we test:
* - Backward compatibility with explicit flags
* - Proper argument processing
* - Error handling for various scenarios
* - Platform-agnostic behavior
- *
+ *
* For manual testing of the full pipe functionality, use:
* npm run build && echo "test" | node dist/index.js
- */
\ No newline at end of file
+ */
diff --git a/extensions/cli/src/e2e/resume-flag.test.ts b/extensions/cli/src/e2e/resume-flag.test.ts
index ccbdfecb2..5e560d0ab 100644
--- a/extensions/cli/src/e2e/resume-flag.test.ts
+++ b/extensions/cli/src/e2e/resume-flag.test.ts
@@ -34,7 +34,7 @@ describe("E2E: Resume Flag", () => {
args: ["-p", "--config", context.configPath, "hello"],
env: {
// Use a fixed session ID so both CLI calls use the same session
- CONTINUE_CLI_TEST_SESSION_ID: "test-session-123"
+ CONTINUE_CLI_TEST_SESSION_ID: "test-session-123",
},
timeout: 15000,
});
@@ -53,14 +53,18 @@ describe("E2E: Resume Flag", () => {
const sessionPath = path.join(sessionDir, sessionFile);
const sessionContent = await fs.readFile(sessionPath, "utf-8");
const sessionData = JSON.parse(sessionContent);
-
+
expect(sessionData.chatHistory).toBeDefined();
expect(sessionData.chatHistory.length).toBeGreaterThan(0);
-
+
// Should contain the user message and assistant response
- const userMessage = sessionData.chatHistory.find((msg: any) => msg.role === "user");
- const assistantMessage = sessionData.chatHistory.find((msg: any) => msg.role === "assistant");
-
+ const userMessage = sessionData.chatHistory.find(
+ (msg: any) => msg.role === "user",
+ );
+ const assistantMessage = sessionData.chatHistory.find(
+ (msg: any) => msg.role === "assistant",
+ );
+
expect(userMessage?.content).toBe("hello");
expect(assistantMessage?.content).toBe("Hello! Nice to meet you.");
@@ -68,14 +72,14 @@ describe("E2E: Resume Flag", () => {
const resumeResult = await runCLI(context, {
args: ["--resume", "--config", context.configPath],
env: {
- CONTINUE_CLI_TEST_SESSION_ID: "test-session-123"
+ CONTINUE_CLI_TEST_SESSION_ID: "test-session-123",
},
timeout: 15000,
});
// The resume command should complete successfully
expect(resumeResult.exitCode).toBe(0);
-
+
// In headless mode with no new prompt, it should just show existing messages
// This is a simplification for the test - the behavior may vary based on implementation
}, 30000);
@@ -85,7 +89,7 @@ describe("E2E: Resume Flag", () => {
const result = await runCLI(context, {
args: ["--resume", "--config", context.configPath],
env: {
- CONTINUE_CLI_TEST_SESSION_ID: "no-session-456"
+ CONTINUE_CLI_TEST_SESSION_ID: "no-session-456",
},
timeout: 15000,
});
@@ -97,13 +101,13 @@ describe("E2E: Resume Flag", () => {
it("should resume and allow new messages to be added", async () => {
// Setup mock to return different responses for different calls
let responseCount = 0;
-
+
// Clean up current server first
await cleanupMockLLMServer(mockServer);
-
+
// Wait a bit to ensure cleanup
- await new Promise(resolve => setTimeout(resolve, 100));
-
+ await new Promise((resolve) => setTimeout(resolve, 100));
+
// Create new server with dynamic response
mockServer = await setupMockLLMTest(context, {
response: (prompt: string) => {
@@ -113,7 +117,7 @@ describe("E2E: Resume Flag", () => {
} else {
return "Second response";
}
- }
+ },
});
const sessionId = "test-session-789";
@@ -122,19 +126,19 @@ describe("E2E: Resume Flag", () => {
const firstResult = await runCLI(context, {
args: ["-p", "--config", context.configPath, "first message"],
env: {
- CONTINUE_CLI_TEST_SESSION_ID: sessionId
+ CONTINUE_CLI_TEST_SESSION_ID: sessionId,
},
timeout: 15000,
});
expect(firstResult.exitCode).toBe(0);
expect(firstResult.stdout).toContain("First response");
-
+
// Verify the first session was saved correctly
const sessionDir = path.join(context.testDir, ".continue", "cli-sessions");
let sessionFiles = await fs.readdir(sessionDir);
expect(sessionFiles).toHaveLength(1);
-
+
let sessionFile = sessionFiles[0];
let sessionPath = path.join(sessionDir, sessionFile);
let sessionContent = await fs.readFile(sessionPath, "utf-8");
@@ -142,9 +146,15 @@ describe("E2E: Resume Flag", () => {
// Resume and add a new message with the SAME session ID
const resumeResult = await runCLI(context, {
- args: ["--resume", "-p", "--config", context.configPath, "second message"],
+ args: [
+ "--resume",
+ "-p",
+ "--config",
+ context.configPath,
+ "second message",
+ ],
env: {
- CONTINUE_CLI_TEST_SESSION_ID: sessionId
+ CONTINUE_CLI_TEST_SESSION_ID: sessionId,
},
timeout: 15000,
});
@@ -152,7 +162,7 @@ describe("E2E: Resume Flag", () => {
expect(resumeResult.exitCode).toBe(0);
// Should show the new response
expect(resumeResult.stdout).toContain("Second response");
-
+
// Verify both requests were made to the server
expect(mockServer.requests).toHaveLength(2);
@@ -162,10 +172,14 @@ describe("E2E: Resume Flag", () => {
sessionPath = path.join(sessionDir, sessionFile);
sessionContent = await fs.readFile(sessionPath, "utf-8");
sessionData = JSON.parse(sessionContent);
-
- const userMessages = sessionData.chatHistory.filter((msg: any) => msg.role === "user");
- const assistantMessages = sessionData.chatHistory.filter((msg: any) => msg.role === "assistant");
-
+
+ const userMessages = sessionData.chatHistory.filter(
+ (msg: any) => msg.role === "user",
+ );
+ const assistantMessages = sessionData.chatHistory.filter(
+ (msg: any) => msg.role === "assistant",
+ );
+
expect(userMessages).toHaveLength(2);
expect(assistantMessages).toHaveLength(2);
expect(userMessages[0].content).toBe("first message");
@@ -173,4 +187,4 @@ describe("E2E: Resume Flag", () => {
expect(assistantMessages[0].content).toBe("First response");
expect(assistantMessages[1].content).toBe("Second response");
}, 30000);
-});
\ No newline at end of file
+});
diff --git a/extensions/cli/src/streamChatResponse.ts b/extensions/cli/src/streamChatResponse.ts
index 6a703200e..c460abe9d 100644
--- a/extensions/cli/src/streamChatResponse.ts
+++ b/extensions/cli/src/streamChatResponse.ts
@@ -452,8 +452,8 @@ export async function streamChatResponse(
abortController: AbortController,
callbacks?: StreamCallbacks,
) {
- // Convert to legacy format for processing
- const legacyHistory = convertFromUnifiedHistory(chatHistory);
+ // Convert to OpenAI format for processing
+ const openaiHistory = convertFromUnifiedHistory(chatHistory);
logger.debug("streamChatResponse called", {
model,
@@ -483,7 +483,7 @@ export async function streamChatResponse(
// Get response from LLM
const { content, toolCalls, shouldContinue } =
await processStreamingResponse({
- chatHistory: legacyHistory,
+ chatHistory: openaiHistory,
model,
llmApi,
abortController,
@@ -508,7 +508,7 @@ export async function streamChatResponse(
// Handle tool calls and check for early return
const shouldReturn = await handleToolCalls(
toolCalls,
- legacyHistory,
+ openaiHistory,
content,
callbacks,
isHeadless,
@@ -521,7 +521,7 @@ export async function streamChatResponse(
// Check for auto-compaction after tool execution
if (shouldContinue) {
const { chatHistory: updatedChatHistory, compactionIndex } =
- await handleAutoCompaction(legacyHistory, model, llmApi, {
+ await handleAutoCompaction(openaiHistory, model, llmApi, {
isHeadless,
callbacks: {
onSystemMessage: callbacks?.onSystemMessage,
@@ -530,9 +530,9 @@ export async function streamChatResponse(
});
// Only update chat history if compaction actually occurred
- if (compactionIndex !== null && updatedChatHistory !== legacyHistory) {
- legacyHistory.length = 0;
- legacyHistory.push(...updatedChatHistory);
+ if (compactionIndex !== null && updatedChatHistory !== openaiHistory) {
+ openaiHistory.length = 0;
+ openaiHistory.push(...updatedChatHistory);
}
}
@@ -544,7 +544,7 @@ export async function streamChatResponse(
logger.debug("streamChatResponse complete", {
totalResponseLength: fullResponse.length,
- totalMessages: legacyHistory.length,
+ totalMessages: openaiHistory.length,
});
// For headless mode, we return only the final response
diff --git a/extensions/cli/src/ui/UserInput.tsx b/extensions/cli/src/ui/UserInput.tsx
index b0cf977f1..d4e0efe98 100644
--- a/extensions/cli/src/ui/UserInput.tsx
+++ b/extensions/cli/src/ui/UserInput.tsx
@@ -1,9 +1,12 @@
+/* eslint-disable max-lines */
import { type AssistantConfig } from "@continuedev/sdk";
import { Box, Text, useApp, useInput } from "ink";
import React, { useCallback, useState } from "react";
import { getAllSlashCommands } from "../commands/commands.js";
+import { useServices } from "../hooks/useService.js";
import type { PermissionMode } from "../permissions/types.js";
+import type { FileIndexServiceState } from "../services/FileIndexService.js";
import { SERVICE_NAMES, serviceContainer } from "../services/index.js";
import { modeService } from "../services/ModeService.js";
import { InputHistory } from "../util/inputHistory.js";
@@ -72,6 +75,11 @@ const UserInput: React.FC = ({
>([]);
const { exit } = useApp();
+ // Get file index service
+ const { services } = useServices<{
+ fileIndex: FileIndexServiceState;
+ }>(["fileIndex"]);
+
const getSlashCommands = () => {
if (assistant || isRemoteMode) {
return getAllSlashCommands(assistant || ({} as AssistantConfig), {
@@ -191,7 +199,27 @@ const UserInput: React.FC = ({
if (afterAt.includes(" ") || afterAt.includes("\n")) {
setShowFileSearch(false);
} else {
- // We're in a file search context
+ // We're in a file search context - check if there are matching files
+ const fileIndexService = services.fileIndex;
+ if (fileIndexService) {
+ const filteredFiles = fileIndexService.files.filter((file) => {
+ if (afterAt.length === 0) {
+ return true;
+ }
+ const lowerFilter = afterAt.toLowerCase();
+ return (
+ file.displayName.toLowerCase().includes(lowerFilter) ||
+ file.path.toLowerCase().includes(lowerFilter)
+ );
+ });
+
+ // If no files match, hide the dropdown to allow normal Enter behavior
+ if (filteredFiles.length === 0 && afterAt.length > 0) {
+ setShowFileSearch(false);
+ return;
+ }
+ }
+
setShowFileSearch(true);
setFileSearchFilter(afterAt);
setSelectedFileIndex(0);
diff --git a/extensions/cli/test-fixtures/model-switch-test-config.yaml b/extensions/cli/test-fixtures/model-switch-test-config.yaml
index 70dc69a91..471a9051f 100644
--- a/extensions/cli/test-fixtures/model-switch-test-config.yaml
+++ b/extensions/cli/test-fixtures/model-switch-test-config.yaml
@@ -15,4 +15,4 @@ models:
- name: Claude 3
provider: anthropic
model: claude-3-opus
- apiKey: test-api-key-3
\ No newline at end of file
+ apiKey: test-api-key-3