Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/AIView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { InterruptedBarrier } from "./Messages/InterruptedBarrier";
import { ChatInput } from "./ChatInput";
import { ChatMetaSidebar } from "./ChatMetaSidebar";
import type { DisplayedMessage, CmuxMessage } from "../types/message";
import { StreamingMessageAggregator } from "../utils/StreamingMessageAggregator";
import { shouldShowInterruptedBarrier } from "../utils/messageUtils";
import { StreamingMessageAggregator } from "../utils/messages/StreamingMessageAggregator";
import { shouldShowInterruptedBarrier } from "../utils/messages/messageUtils";
import { ChatProvider } from "../contexts/ChatContext";
import { ThinkingProvider } from "../contexts/ThinkingContext";
import { ModeProvider } from "../contexts/ModeContext";
Expand Down
4 changes: 2 additions & 2 deletions src/components/ChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import { usePersistedState } from "../hooks/usePersistedState";
import { ThinkingSliderComponent } from "./ThinkingSlider";
import { useThinkingLevel } from "../hooks/useThinkingLevel";
import { useMode } from "../contexts/ModeContext";
import { modeToToolPolicy } from "../utils/modeUtils";
import { modeToToolPolicy } from "../utils/ui/modeUtils";
import { ToggleGroup } from "./ToggleGroup";
import type { UIMode } from "../types/mode";
import {
getSlashCommandSuggestions,
type SlashSuggestion,
} from "../utils/slashCommands/suggestions";
import { TooltipWrapper, Tooltip, HelpIndicator } from "./Tooltip";
import { matchesKeybind, formatKeybind, KEYBINDS } from "../utils/keybinds";
import { matchesKeybind, formatKeybind, KEYBINDS } from "../utils/ui/keybinds";

const InputSection = styled.div`
position: relative;
Expand Down
8 changes: 4 additions & 4 deletions src/components/ChatMetaSidebar/CostsTab.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from "react";
import styled from "@emotion/styled";
import { useChatContext } from "../../contexts/ChatContext";
import { useChatContext } from "@/contexts/ChatContext";
import { TooltipWrapper, Tooltip, HelpIndicator } from "../Tooltip";
import { getModelStats } from "../../utils/modelStats";
import { sumUsageHistory } from "../../utils/tokenStatsCalculator";
import { usePersistedState } from "../../hooks/usePersistedState";
import { getModelStats } from "@/utils/tokens/modelStats";
import { sumUsageHistory } from "@/utils/tokens/tokenStatsCalculator";
import { usePersistedState } from "@/hooks/usePersistedState";
import { ToggleGroup, type ToggleOption } from "../ToggleGroup";

const Container = styled.div`
Expand Down
2 changes: 1 addition & 1 deletion src/components/Messages/AssistantMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from "react";
import styled from "@emotion/styled";
import type { DisplayedMessage } from "../../types/message";
import type { DisplayedMessage } from "@/types/message";
import { MarkdownRenderer } from "./MarkdownRenderer";
import { TypewriterMarkdown } from "./TypewriterMarkdown";
import type { ButtonConfig } from "./MessageWindow";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Messages/MessageRenderer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import type { DisplayedMessage } from "../../types/message";
import type { DisplayedMessage } from "@/types/message";
import { UserMessage } from "./UserMessage";
import { AssistantMessage } from "./AssistantMessage";
import { ToolMessage } from "./ToolMessage";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Messages/MessageWindow.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ReactNode } from "react";
import React, { useState } from "react";
import styled from "@emotion/styled";
import type { CmuxMessage, DisplayedMessage } from "../../types/message";
import type { CmuxMessage, DisplayedMessage } from "@/types/message";
import { HeaderButton } from "../tools/shared/ToolPrimitives";

const MessageBlock = styled.div<{ borderColor: string; backgroundColor?: string }>`
Expand Down
2 changes: 1 addition & 1 deletion src/components/Messages/ReasoningMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect } from "react";
import styled from "@emotion/styled";
import type { DisplayedMessage } from "../../types/message";
import type { DisplayedMessage } from "@/types/message";
import { MarkdownRenderer } from "./MarkdownRenderer";
import { TypewriterMarkdown } from "./TypewriterMarkdown";

Expand Down
2 changes: 1 addition & 1 deletion src/components/Messages/StreamErrorMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import styled from "@emotion/styled";
import type { DisplayedMessage } from "../../types/message";
import type { DisplayedMessage } from "@/types/message";

const ErrorContainer = styled.div`
background: var(--color-error-bg);
Expand Down
4 changes: 2 additions & 2 deletions src/components/Messages/ToolMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import type { DisplayedMessage } from "../../types/message";
import type { DisplayedMessage } from "@/types/message";
import { GenericToolCall } from "../tools/GenericToolCall";
import { BashToolCall } from "../tools/BashToolCall";
import { FileEditToolCall } from "../tools/FileEditToolCall";
Expand All @@ -13,7 +13,7 @@ import type {
FileEditInsertToolResult,
ProposePlanToolArgs,
ProposePlanToolResult,
} from "../../types/tools";
} from "@/types/tools";

interface ToolMessageProps {
message: DisplayedMessage & { type: "tool" };
Expand Down
2 changes: 1 addition & 1 deletion src/components/Messages/UserMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from "react";
import styled from "@emotion/styled";
import type { DisplayedMessage } from "../../types/message";
import type { DisplayedMessage } from "@/types/message";
import type { ButtonConfig } from "./MessageWindow";
import { MessageWindow } from "./MessageWindow";
import { TerminalOutput } from "./TerminalOutput";
Expand Down
2 changes: 1 addition & 1 deletion src/components/NewWorkspaceModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect, useCallback } from "react";
import styled from "@emotion/styled";
import { matchesKeybind, KEYBINDS } from "../utils/keybinds";
import { matchesKeybind, KEYBINDS } from "../utils/ui/keybinds";

// Styled Components
const ModalOverlay = styled.div`
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProjectSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { css } from "@emotion/react";
import type { ProjectConfig } from "../config";
import type { WorkspaceMetadata } from "../types/workspace";
import { usePersistedState } from "../hooks/usePersistedState";
import { matchesKeybind, formatKeybind, KEYBINDS } from "../utils/keybinds";
import { matchesKeybind, formatKeybind, KEYBINDS } from "../utils/ui/keybinds";

// Styled Components
const SidebarContainer = styled.div`
Expand Down
2 changes: 1 addition & 1 deletion src/components/tools/BashToolCall.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect, useRef } from "react";
import styled from "@emotion/styled";
import type { BashToolArgs, BashToolResult } from "../../types/tools";
import type { BashToolArgs, BashToolResult } from "@/types/tools";
import {
ToolContainer,
ToolHeader,
Expand Down
2 changes: 1 addition & 1 deletion src/components/tools/FileEditToolCall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
FileEditReplaceToolResult,
FileEditInsertToolArgs,
FileEditInsertToolResult,
} from "../../types/tools";
} from "@/types/tools";
import {
ToolContainer,
ToolHeader,
Expand Down
4 changes: 2 additions & 2 deletions src/components/tools/ProposePlanToolCall.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from "react";
import styled from "@emotion/styled";
import type { ProposePlanToolArgs, ProposePlanToolResult } from "../../types/tools";
import type { ProposePlanToolArgs, ProposePlanToolResult } from "@/types/tools";
import {
ToolContainer,
ToolHeader,
Expand All @@ -11,7 +11,7 @@ import {
} from "./shared/ToolPrimitives";
import { useToolExpansion, getStatusDisplay, type ToolStatus } from "./shared/toolUtils";
import { MarkdownRenderer } from "../Messages/MarkdownRenderer";
import { formatKeybind, KEYBINDS } from "../../utils/keybinds";
import { formatKeybind, KEYBINDS } from "@/utils/ui/keybinds";

const PlanContainer = styled.div`
padding: 12px;
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/ChatContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ReactNode } from "react";
import React, { createContext, useContext, useState, useEffect, useRef } from "react";
import type { CmuxMessage, DisplayedMessage } from "../types/message";
import type { ChatStats } from "../types/chatStats";
import { TokenStatsWorker } from "../utils/TokenStatsWorker";
import { TokenStatsWorker } from "../utils/tokens/TokenStatsWorker";

interface ChatContextType {
messages: DisplayedMessage[];
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/ModeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ReactNode } from "react";
import React, { createContext, useContext, useEffect } from "react";
import type { UIMode } from "../types/mode";
import { usePersistedState } from "../hooks/usePersistedState";
import { matchesKeybind, KEYBINDS } from "../utils/keybinds";
import { matchesKeybind, KEYBINDS } from "../utils/ui/keybinds";

type ModeContextType = [UIMode, (mode: UIMode) => void];

Expand Down
2 changes: 1 addition & 1 deletion src/debug/costs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as fs from "fs";
import * as path from "path";
import { defaultConfig } from "../config";
import type { CmuxMessage } from "../types/message";
import { calculateTokenStats } from "../utils/tokenStatsCalculator";
import { calculateTokenStats } from "../utils/tokens/tokenStatsCalculator";

/**
* Debug command to display cost/token statistics for a workspace
Expand Down
12 changes: 6 additions & 6 deletions src/services/aiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ import { createCmuxMessage } from "../types/message";
import type { Config } from "../config";
import { StreamManager } from "./streamManager";
import type { SendMessageError } from "../types/errors";
import { getToolsForModel } from "../utils/tools";
import { getToolsForModel } from "../utils/tools/tools";
import { log } from "./log";
import {
transformModelMessages,
validateAnthropicCompliance,
addInterruptedSentinel,
filterEmptyAssistantMessages,
} from "../utils/modelMessageTransform";
import { applyCacheControl } from "../utils/cacheStrategy";
} from "../utils/messages/modelMessageTransform";
import { applyCacheControl } from "../utils/ai/cacheStrategy";
import type { HistoryService } from "./historyService";
import type { PartialService } from "./partialService";
import { buildSystemMessage } from "./systemMessage";
import { getTokenizerForModel } from "../utils/tokenizer";
import { buildProviderOptions } from "../utils/providerOptions";
import { getTokenizerForModel } from "../utils/tokens/tokenizer";
import { buildProviderOptions } from "../utils/ai/providerOptions";
import type { ThinkingLevel } from "../types/thinking";
import { createOpenAI } from "@ai-sdk/openai";
import type { StreamAbortEvent } from "../types/stream";
import { applyToolPolicy, type ToolPolicy } from "../utils/toolPolicy";
import { applyToolPolicy, type ToolPolicy } from "../utils/tools/toolPolicy";

// Export a standalone version of getToolsForModel for use in backend

Expand Down
4 changes: 2 additions & 2 deletions src/services/historyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import type { Result } from "../types/result";
import { Ok, Err } from "../types/result";
import type { CmuxMessage } from "../types/message";
import type { Config } from "../config";
import { MutexMap } from "../utils/mutexMap";
import { MutexMap } from "../utils/concurrency/mutexMap";
import { log } from "./log";
import { getTokenizerForModel } from "../utils/tokenizer";
import { getTokenizerForModel } from "../utils/tokens/tokenizer";

/**
* HistoryService - Manages chat history persistence and sequence numbering
Expand Down
2 changes: 1 addition & 1 deletion src/services/ipcMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { IPC_CHANNELS, getChatChannel } from "../constants/ipc-constants";
import type { SendMessageError } from "../types/errors";
import type { StreamErrorMessage, SendMessageOptions, DeleteMessage } from "../types/ipc";
import { Ok, Err } from "../types/result";
import { validateWorkspaceName } from "../utils/workspaceValidation";
import { validateWorkspaceName } from "../utils/validation/workspaceValidation";

const createUnknownSendMessageError = (raw: string): SendMessageError => ({
type: "unknown",
Expand Down
2 changes: 1 addition & 1 deletion src/services/partialService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Ok, Err } from "../types/result";
import type { CmuxMessage } from "../types/message";
import type { Config } from "../config";
import type { HistoryService } from "./historyService";
import { MutexMap } from "../utils/mutexMap";
import { MutexMap } from "../utils/concurrency/mutexMap";

/**
* PartialService - Manages partial message persistence for interrupted streams
Expand Down
2 changes: 1 addition & 1 deletion src/services/streamManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import type { SendMessageError, StreamErrorType } from "../types/errors";
import type { CmuxMetadata, CmuxMessage } from "../types/message";
import type { PartialService } from "./partialService";
import type { HistoryService } from "./historyService";
import { AsyncMutex } from "../utils/asyncMutex";
import { AsyncMutex } from "../utils/concurrency/asyncMutex";

// Type definitions for stream parts with extended properties
interface ReasoningDeltaPart {
Expand Down
2 changes: 1 addition & 1 deletion src/services/tools/bash.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect } from "bun:test";
import { createBashTool } from "./bash";
import type { BashToolArgs, BashToolResult } from "../../types/tools";
import type { BashToolArgs, BashToolResult } from "@/types/tools";
import type { ToolCallOptions } from "ai";

// Mock ToolCallOptions for testing
Expand Down
6 changes: 3 additions & 3 deletions src/services/tools/bash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { tool } from "ai";
import { spawn } from "child_process";
import type { ChildProcess } from "child_process";
import { createInterface } from "readline";
import type { BashToolResult } from "../../types/tools";
import type { ToolConfiguration, ToolFactory } from "../../utils/tools";
import { TOOL_DEFINITIONS } from "../../utils/toolDefinitions";
import type { BashToolResult } from "@/types/tools";
import type { ToolConfiguration, ToolFactory } from "@/utils/tools/tools";
import { TOOL_DEFINITIONS } from "@/utils/tools/toolDefinitions";

/**
* Wraps a ChildProcess to make it disposable for use with `using` statements
Expand Down
2 changes: 1 addition & 1 deletion src/services/tools/file_edit_insert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as path from "path";
import * as os from "os";
import { createFileEditInsertTool } from "./file_edit_insert";
import { leaseFromStat } from "./fileCommon";
import type { FileEditInsertToolArgs, FileEditInsertToolResult } from "../../types/tools";
import type { FileEditInsertToolArgs, FileEditInsertToolResult } from "@/types/tools";
import type { ToolCallOptions } from "ai";

// Mock ToolCallOptions for testing
Expand Down
6 changes: 3 additions & 3 deletions src/services/tools/file_edit_insert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { tool } from "ai";
import * as fs from "fs/promises";
import * as path from "path";
import writeFileAtomic from "write-file-atomic";
import type { FileEditInsertToolResult } from "../../types/tools";
import type { ToolConfiguration, ToolFactory } from "../../utils/tools";
import { TOOL_DEFINITIONS } from "../../utils/toolDefinitions";
import type { FileEditInsertToolResult } from "@/types/tools";
import type { ToolConfiguration, ToolFactory } from "@/utils/tools/tools";
import { TOOL_DEFINITIONS } from "@/utils/tools/toolDefinitions";
import { leaseFromStat, generateDiff, validatePathInCwd } from "./fileCommon";

/**
Expand Down
2 changes: 1 addition & 1 deletion src/services/tools/file_edit_replace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as path from "path";
import * as os from "os";
import { createFileEditReplaceTool } from "./file_edit_replace";
import { leaseFromStat } from "./fileCommon";
import type { FileEditReplaceToolArgs, FileEditReplaceToolResult } from "../../types/tools";
import type { FileEditReplaceToolArgs, FileEditReplaceToolResult } from "@/types/tools";
import type { ToolCallOptions } from "ai";

// Mock ToolCallOptions for testing
Expand Down
6 changes: 3 additions & 3 deletions src/services/tools/file_edit_replace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { tool } from "ai";
import * as fs from "fs/promises";
import * as path from "path";
import writeFileAtomic from "write-file-atomic";
import type { FileEditReplaceToolResult } from "../../types/tools";
import type { ToolConfiguration, ToolFactory } from "../../utils/tools";
import { TOOL_DEFINITIONS } from "../../utils/toolDefinitions";
import type { FileEditReplaceToolResult } from "@/types/tools";
import type { ToolConfiguration, ToolFactory } from "@/utils/tools/tools";
import { TOOL_DEFINITIONS } from "@/utils/tools/toolDefinitions";
import { leaseFromStat, generateDiff, validatePathInCwd } from "./fileCommon";

/**
Expand Down
2 changes: 1 addition & 1 deletion src/services/tools/file_read.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as fs from "fs/promises";
import * as path from "path";
import * as os from "os";
import { createFileReadTool } from "./file_read";
import type { FileReadToolArgs, FileReadToolResult } from "../../types/tools";
import type { FileReadToolArgs, FileReadToolResult } from "@/types/tools";
import type { ToolCallOptions } from "ai";

// Mock ToolCallOptions for testing
Expand Down
6 changes: 3 additions & 3 deletions src/services/tools/file_read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { tool } from "ai";
import * as fs from "fs/promises";
import * as path from "path";
import * as readline from "readline";
import type { FileReadToolResult } from "../../types/tools";
import type { ToolConfiguration, ToolFactory } from "../../utils/tools";
import { TOOL_DEFINITIONS } from "../../utils/toolDefinitions";
import type { FileReadToolResult } from "@/types/tools";
import type { ToolConfiguration, ToolFactory } from "@/utils/tools/tools";
import { TOOL_DEFINITIONS } from "@/utils/tools/toolDefinitions";
import { leaseFromStat, validatePathInCwd } from "./fileCommon";

/**
Expand Down
4 changes: 2 additions & 2 deletions src/services/tools/propose_plan.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { tool } from "ai";
import type { ToolFactory } from "../../utils/tools";
import { TOOL_DEFINITIONS } from "../../utils/toolDefinitions";
import type { ToolFactory } from "@/utils/tools/tools";
import { TOOL_DEFINITIONS } from "@/utils/tools/toolDefinitions";

/**
* Propose plan tool factory for AI assistant
Expand Down
2 changes: 1 addition & 1 deletion src/types/chatStats.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ChatUsageDisplay } from "../utils/tokenStatsCalculator";
import type { ChatUsageDisplay } from "../utils/tokens/tokenStatsCalculator";

export interface TokenConsumer {
name: string; // "User", "Assistant", "bash", "readFile", etc.
Expand Down
2 changes: 1 addition & 1 deletion src/types/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { CmuxMessage } from "./message";
import type { ProjectConfig } from "../config";
import type { SendMessageError, StreamErrorType } from "./errors";
import type { ThinkingLevel } from "./thinking";
import type { ToolPolicy } from "../utils/toolPolicy";
import type { ToolPolicy } from "../utils/tools/toolPolicy";
import type {
StreamStartEvent,
StreamDeltaEvent,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

import type { AnthropicProviderOptions } from "@ai-sdk/anthropic";
import type { OpenAIResponsesProviderOptions } from "@ai-sdk/openai";
import type { ThinkingLevel } from "../types/thinking";
import { ANTHROPIC_THINKING_BUDGETS, OPENAI_REASONING_EFFORT } from "../types/thinking";
import { log } from "../services/log";
import type { CmuxMessage } from "../types/message";
import type { ThinkingLevel } from "@/types/thinking";
import { ANTHROPIC_THINKING_BUDGETS, OPENAI_REASONING_EFFORT } from "@/types/thinking";
import { log } from "@/services/log";
import type { CmuxMessage } from "@/types/message";

/**
* Provider-specific options structure for AI SDK
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, it, expect } from "bun:test";
import { StreamingMessageAggregator } from "./StreamingMessageAggregator";
import type { StreamEndEvent } from "../types/stream";
import type { DynamicToolPart } from "../types/toolParts";
import type { StreamEndEvent } from "@/types/stream";
import type { DynamicToolPart } from "@/types/toolParts";

describe("StreamingMessageAggregator", () => {
it("should preserve temporal ordering of text and tool parts", () => {
Expand Down
Loading