Changesets · Branches · Tags · Compare
| Changeset | 73bd9e0b14aa4267374affe52bc9df705df82337a957eb7c64f68d000fe93431 |
|---|---|
| Author | Dallin Romney <dallinromney@gmail.com> · 2025-09-02 19:32 -07:00 |
| Committer | Dallin Romney <dallinromney@gmail.com> · 2025-09-02 19:32 -07:00 |
| Parents | 7fbb7af6157c |
8 files changed
modified extensions/cli/AGENTS.md +0 −5
| @@ -18,30 +18,25 @@ | ||
| 18 | 18 | ### Core Components |
| 19 | 19 | |
| 20 | 20 | 1. **Entry Point** (`src/index.ts`): Main CLI logic with two modes: |
| 21 | - | |
| 22 | 21 | - **Headless mode**: Non-interactive mode for automation/CI |
| 23 | 22 | - **TUI mode**: Terminal User Interface using Ink/React |
| 24 | 23 | - **Standard mode**: Traditional readline-based chat interface |
| 25 | 24 | |
| 26 | 25 | 2. **Authentication** (`src/auth/`): WorkOS-based authentication system |
| 27 | - | |
| 28 | 26 | - `ensureAuth.ts`: Handles authentication flow |
| 29 | 27 | - `workos.ts`: WorkOS configuration and token management |
| 30 | 28 | |
| 31 | 29 | 3. **Continue SDK Integration** (`src/continueSDK.ts`): Initializes the Continue SDK client with: |
| 32 | - | |
| 33 | 30 | - API key authentication |
| 34 | 31 | - Assistant configuration (slug-based) |
| 35 | 32 | - Organization support |
| 36 | 33 | |
| 37 | 34 | 4. **Terminal UI** (`src/ui/`): React/Ink-based TUI components |
| 38 | - | |
| 39 | 35 | - `TUIChat.tsx`: Main chat interface component |
| 40 | 36 | - `UserInput.tsx`: Input handling with multi-line support |
| 41 | 37 | - `TextBuffer.ts`: Text display utilities |
| 42 | 38 | |
| 43 | 39 | 5. **Tools System** (`src/tools/`): Built-in development tools including: |
| 44 | - | |
| 45 | 40 | - File operations (read, write, list) |
| 46 | 41 | - Code search functionality |
| 47 | 42 | - Terminal command execution |
modified extensions/cli/CHAT_HISTORY_SERVICE_MIGRATION_PLAN.md +0 −1
| @@ -299,7 +299,6 @@ | ||
| 299 | 299 | 1. **Streaming integration**: Most complex change |
| 300 | 300 | - Mitigation: Extensive testing, gradual rollout |
| 301 | 301 | 2. **Remote mode**: Different state management |
| 302 | - | |
| 303 | 302 | - Mitigation: Test thoroughly, maintain compatibility |
| 304 | 303 | |
| 305 | 304 | 3. **Performance**: Large histories might cause issues |
modified extensions/cli/spec/config-loading.md +0 −2
| @@ -23,13 +23,11 @@ | ||
| 23 | 23 | **When CLI is invoked, config source is determined in this order:** |
| 24 | 24 | |
| 25 | 25 | 1. **CLI `--config` Flag** (highest priority) |
| 26 | - | |
| 27 | 26 | - File path (starts with `.`, `/`, `~`): Loads local YAML file |
| 28 | 27 | - Assistant slug (`owner/package`): Fetches from Continue platform |
| 29 | 28 | - Overrides any saved preferences |
| 30 | 29 | |
| 31 | 30 | 2. **Saved Config URI** (if no `--config` flag) |
| 32 | - | |
| 33 | 31 | - Retrieved from authentication config |
| 34 | 32 | - Converts `file://` URIs back to file paths |
| 35 | 33 | - Converts `slug://` URIs back to assistant slugs |
modified extensions/cli/spec/onboarding.md +0 −1
| @@ -8,7 +8,6 @@ | ||
| 8 | 8 | |
| 9 | 9 | 1. If the --config flag is provided, load this config |
| 10 | 10 | 2. Otherwise, we will present the user with two options: |
| 11 | - | |
| 12 | 11 | - 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 |
| 13 | 12 | - 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 |
| 14 | 13 |
modified extensions/cli/src/ui/UserInput.tsx +92 −30
| @@ -19,6 +19,77 @@ | ||
| 19 | 19 | import { SlashCommandUI } from "./SlashCommandUI.js"; |
| 20 | 20 | import { TextBuffer } from "./TextBuffer.js"; |
| 21 | 21 | |
| 22 | +// Small presentational helpers to reduce cyclomatic complexity in UserInput | |
| 23 | +const InterruptedBanner: React.FC<{ wasInterrupted: boolean }> = ({ | |
| 24 | + wasInterrupted, | |
| 25 | +}) => { | |
| 26 | + if (!wasInterrupted) return null; | |
| 27 | + return ( | |
| 28 | + <Box paddingX={1} marginBottom={0}> | |
| 29 | + <Text color="yellow">⚠ Interrupted by user - Press enter to resume</Text> | |
| 30 | + </Box> | |
| 31 | + ); | |
| 32 | +}; | |
| 33 | + | |
| 34 | +const SlashCommandsMaybe: React.FC<{ | |
| 35 | + show: boolean; | |
| 36 | + inputMode: boolean; | |
| 37 | + hideNormalUI: boolean; | |
| 38 | + isRemoteMode: boolean; | |
| 39 | + assistant?: AssistantConfig; | |
| 40 | + filter: string; | |
| 41 | + selectedIndex: number; | |
| 42 | +}> = ({ | |
| 43 | + show, | |
| 44 | + inputMode, | |
| 45 | + hideNormalUI, | |
| 46 | + isRemoteMode, | |
| 47 | + assistant, | |
| 48 | + filter, | |
| 49 | + selectedIndex, | |
| 50 | +}) => { | |
| 51 | + if (!show || !inputMode || hideNormalUI || !(isRemoteMode || assistant)) | |
| 52 | + return null; | |
| 53 | + return ( | |
| 54 | + <SlashCommandUI | |
| 55 | + assistant={assistant} | |
| 56 | + filter={filter} | |
| 57 | + selectedIndex={selectedIndex} | |
| 58 | + isRemoteMode={isRemoteMode} | |
| 59 | + /> | |
| 60 | + ); | |
| 61 | +}; | |
| 62 | + | |
| 63 | +const FileSearchMaybe: React.FC<{ | |
| 64 | + show: boolean; | |
| 65 | + inputMode: boolean; | |
| 66 | + hideNormalUI: boolean; | |
| 67 | + isRemoteMode: boolean; | |
| 68 | + filter: string; | |
| 69 | + selectedIndex: number; | |
| 70 | + onSelect: (path: string) => void | Promise<void>; | |
| 71 | + onFilesUpdated: (files: Array<{ path: string; displayName: string }>) => void; | |
| 72 | +}> = ({ | |
| 73 | + show, | |
| 74 | + inputMode, | |
| 75 | + hideNormalUI, | |
| 76 | + isRemoteMode, | |
| 77 | + filter, | |
| 78 | + selectedIndex, | |
| 79 | + onSelect, | |
| 80 | + onFilesUpdated, | |
| 81 | +}) => { | |
| 82 | + if (!show || !inputMode || hideNormalUI || isRemoteMode) return null; | |
| 83 | + return ( | |
| 84 | + <FileSearchUI | |
| 85 | + filter={filter} | |
| 86 | + selectedIndex={selectedIndex} | |
| 87 | + onSelect={onSelect} | |
| 88 | + onFilesUpdated={onFilesUpdated} | |
| 89 | + /> | |
| 90 | + ); | |
| 91 | +}; | |
| 92 | + | |
| 22 | 93 | interface UserInputProps { |
| 23 | 94 | onSubmit: (message: string, imageMap?: Map<string, Buffer>) => void; |
| 24 | 95 | isWaitingForResponse: boolean; |
| @@ -702,14 +773,7 @@ | ||
| 702 | 773 | |
| 703 | 774 | return ( |
| 704 | 775 | <Box flexDirection="column"> |
| 705 | - {/* Interruption message - shown just above the input box */} | |
| 706 | - {wasInterrupted && ( | |
| 707 | - <Box paddingX={1} marginBottom={0}> | |
| 708 | - <Text color="yellow"> | |
| 709 | - ⚠ Interrupted by user - Press enter to resume | |
| 710 | - </Text> | |
| 711 | - </Box> | |
| 712 | - )} | |
| 776 | + <InterruptedBanner wasInterrupted={!!wasInterrupted} /> | |
| 713 | 777 | |
| 714 | 778 | {/* Input box */} |
| 715 | 779 | <Box |
| @@ -727,28 +791,26 @@ | ||
| 727 | 791 | {renderInputText()} |
| 728 | 792 | </Box> |
| 729 | 793 | |
| 730 | - {/* Slash command UI - show in remote mode OR when assistant is available */} | |
| 731 | - {showSlashCommands && | |
| 732 | - inputMode && | |
| 733 | - !hideNormalUI && | |
| 734 | - (isRemoteMode || assistant) && ( | |
| 735 | - <SlashCommandUI | |
| 736 | - assistant={assistant} | |
| 737 | - filter={slashCommandFilter} | |
| 738 | - selectedIndex={selectedCommandIndex} | |
| 739 | - isRemoteMode={isRemoteMode} | |
| 740 | - /> | |
| 741 | - )} | |
| 742 | - | |
| 743 | - {/* File search UI - only show in local mode */} | |
| 744 | - {showFileSearch && inputMode && !hideNormalUI && !isRemoteMode && ( | |
| 745 | - <FileSearchUI | |
| 746 | - filter={fileSearchFilter} | |
| 747 | - selectedIndex={selectedFileIndex} | |
| 748 | - onSelect={selectFile} | |
| 749 | - onFilesUpdated={setCurrentFiles} | |
| 750 | - /> | |
| 751 | - )} | |
| 794 | + <SlashCommandsMaybe | |
| 795 | + show={showSlashCommands} | |
| 796 | + inputMode={inputMode} | |
| 797 | + hideNormalUI={!!hideNormalUI} | |
| 798 | + isRemoteMode={!!isRemoteMode} | |
| 799 | + assistant={assistant} | |
| 800 | + filter={slashCommandFilter} | |
| 801 | + selectedIndex={selectedCommandIndex} | |
| 802 | + /> | |
| 803 | + | |
| 804 | + <FileSearchMaybe | |
| 805 | + show={showFileSearch} | |
| 806 | + inputMode={inputMode} | |
| 807 | + hideNormalUI={!!hideNormalUI} | |
| 808 | + isRemoteMode={!!isRemoteMode} | |
| 809 | + filter={fileSearchFilter} | |
| 810 | + selectedIndex={selectedFileIndex} | |
| 811 | + onSelect={selectFile} | |
| 812 | + onFilesUpdated={setCurrentFiles} | |
| 813 | + /> | |
| 752 | 814 | </Box> |
| 753 | 815 | ); |
| 754 | 816 | }; |
modified extensions/cli/src/ui/hooks/useChat.bashMode.test.ts +4 −4
| @@ -1,7 +1,10 @@ | ||
| 1 | -import { describe, it, expect, vi, beforeEach } from "vitest"; | |
| 2 | 1 | import { act } from "@testing-library/react"; |
| 2 | +import { describe, it, expect, vi, beforeEach } from "vitest"; | |
| 3 | 3 | |
| 4 | 4 | import { createMinimalTestContext } from "../../test-helpers/ui-test-context.js"; |
| 5 | +import { runTerminalCommandTool } from "../../tools/runTerminalCommand.js"; | |
| 6 | + | |
| 7 | +import { useChat } from "./useChat.js"; | |
| 5 | 8 | |
| 6 | 9 | // Mock the runTerminalCommandTool |
| 7 | 10 | vi.mock("../../tools/runTerminalCommand.js", () => ({ |
| @@ -10,9 +13,6 @@ | ||
| 10 | 13 | }, |
| 11 | 14 | })); |
| 12 | 15 | |
| 13 | -import { useChat } from "./useChat.js"; | |
| 14 | -import { runTerminalCommandTool } from "../../tools/runTerminalCommand.js"; | |
| 15 | - | |
| 16 | 16 | describe("useChat - Bash Mode", () => { |
| 17 | 17 | beforeEach(() => { |
| 18 | 18 | vi.clearAllMocks(); |
added extensions/cli/src/ui/hooks/useChat.bashMode.ts +51 −0
| @@ -0,0 +1,51 @@ | ||
| 1 | +import { services } from "../../services/index.js"; | |
| 2 | + | |
| 3 | +export const handleBashModeProcessing = async ( | |
| 4 | + message: string, | |
| 5 | +): Promise<string | null> => { | |
| 6 | + // Handle bash mode commands (starting with !) | |
| 7 | + if (!message.trimStart().startsWith("!")) { | |
| 8 | + return message; | |
| 9 | + } | |
| 10 | + | |
| 11 | + // Extract the command after the ! | |
| 12 | + const bashCommand = message.trimStart().slice(1).trim(); | |
| 13 | + | |
| 14 | + if (!bashCommand) { | |
| 15 | + return message; // No command provided, treat as regular message | |
| 16 | + } | |
| 17 | + | |
| 18 | + // Show tool call immediately, then run asynchronously and populate result | |
| 19 | + const toolCallId = `bash-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`; | |
| 20 | + const toolCall = { | |
| 21 | + id: toolCallId, | |
| 22 | + type: "function" as const, | |
| 23 | + function: { | |
| 24 | + name: "Bash", | |
| 25 | + arguments: JSON.stringify({ command: bashCommand }), | |
| 26 | + }, | |
| 27 | + }; | |
| 28 | + | |
| 29 | + // Add assistant message with tool call immediately | |
| 30 | + services.chatHistory.addAssistantMessage("", [toolCall as any]); | |
| 31 | + // Mark as calling for immediate UI feedback | |
| 32 | + services.chatHistory.updateToolStatus(toolCallId, "calling"); | |
| 33 | + | |
| 34 | + // Execute the bash command asynchronously - don't block UI | |
| 35 | + (async () => { | |
| 36 | + try { | |
| 37 | + const { runTerminalCommandTool } = await import( | |
| 38 | + "../../tools/runTerminalCommand.js" | |
| 39 | + ); | |
| 40 | + const result = await runTerminalCommandTool.run({ | |
| 41 | + command: bashCommand, | |
| 42 | + }); | |
| 43 | + services.chatHistory.addToolResult(toolCallId, result, "done"); | |
| 44 | + } catch (error: any) { | |
| 45 | + const errorMessage = `Bash command failed: ${error?.message || String(error)}`; | |
| 46 | + services.chatHistory.addToolResult(toolCallId, errorMessage, "errored"); | |
| 47 | + } | |
| 48 | + })(); | |
| 49 | + | |
| 50 | + return null; // Processed, no further message handling needed | |
| 51 | +}; |
modified extensions/cli/src/ui/hooks/useChat.ts +1 −50
| @@ -15,6 +15,7 @@ | ||
| 15 | 15 | import { formatError } from "../../util/formatError.js"; |
| 16 | 16 | import { logger } from "../../util/logger.js"; |
| 17 | 17 | |
| 18 | +import { handleBashModeProcessing } from "./useChat.bashMode.js"; | |
| 18 | 19 | import { |
| 19 | 20 | handleAutoCompaction, |
| 20 | 21 | handleCompactCommand, |
| @@ -339,56 +340,6 @@ | ||
| 339 | 340 | return false; |
| 340 | 341 | }; |
| 341 | 342 | |
| 342 | - const handleBashModeProcessing = async ( | |
| 343 | - message: string, | |
| 344 | - ): Promise<string | null> => { | |
| 345 | - // Handle bash mode commands (starting with !) | |
| 346 | - if (!message.trimStart().startsWith("!")) { | |
| 347 | - return message; | |
| 348 | - } | |
| 349 | - | |
| 350 | - // Extract the command after the ! | |
| 351 | - const bashCommand = message.trimStart().slice(1).trim(); | |
| 352 | - | |
| 353 | - if (!bashCommand) { | |
| 354 | - return message; // No command provided, treat as regular message | |
| 355 | - } | |
| 356 | - | |
| 357 | - // Show tool call immediately, then run asynchronously and populate result | |
| 358 | - const toolCallId = `bash-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`; | |
| 359 | - const toolCall = { | |
| 360 | - id: toolCallId, | |
| 361 | - type: "function" as const, | |
| 362 | - function: { | |
| 363 | - name: "Bash", | |
| 364 | - arguments: JSON.stringify({ command: bashCommand }), | |
| 365 | - }, | |
| 366 | - }; | |
| 367 | - | |
| 368 | - // Add assistant message with tool call immediately | |
| 369 | - services.chatHistory.addAssistantMessage("", [toolCall as any]); | |
| 370 | - // Mark as calling for immediate UI feedback | |
| 371 | - services.chatHistory.updateToolStatus(toolCallId, "calling"); | |
| 372 | - | |
| 373 | - // Execute the bash command asynchronously - don't block UI | |
| 374 | - (async () => { | |
| 375 | - try { | |
| 376 | - const { runTerminalCommandTool } = await import( | |
| 377 | - "../../tools/runTerminalCommand.js" | |
| 378 | - ); | |
| 379 | - const result = await runTerminalCommandTool.run({ | |
| 380 | - command: bashCommand, | |
| 381 | - }); | |
| 382 | - services.chatHistory.addToolResult(toolCallId, result, "done"); | |
| 383 | - } catch (error: any) { | |
| 384 | - const errorMessage = `Bash command failed: ${error?.message || String(error)}`; | |
| 385 | - services.chatHistory.addToolResult(toolCallId, errorMessage, "error"); | |
| 386 | - } | |
| 387 | - })(); | |
| 388 | - | |
| 389 | - return null; // Processed, no further message handling needed | |
| 390 | - }; | |
| 391 | - | |
| 392 | 343 | const handleSlashCommandProcessing = async ( |
| 393 | 344 | message: string, |
| 394 | 345 | ): Promise<string | null> => { |