Elffuss BraidHub

kikocis/continue public

chore: format
Changeseta84925a020033f98896e1e41116aef88976ba810b8f85846485a20b3a6edee56
AuthorNate <sestinj@gmail.com> · 2025-08-23 10:57 -07:00
CommitterNate <sestinj@gmail.com> · 2025-08-23 10:57 -07:00
Parents1c83b0b1adf2

Browse the files at this changeset

7 files changed

modified extensions/cli/src/commands/chat.ts +4 −1
@@ -174,7 +174,10 @@
174174 // Custom callbacks for headless mode console output
175175 const callbacks = {
176176 onSystemMessage: (message: string) => {
177- if (message.includes("Auto-compacting") || message.includes("Approaching")) {
177+ if (
178+ message.includes("Auto-compacting") ||
179+ message.includes("Approaching")
180+ ) {
178181 if (!isHeadless) {
179182 console.info(chalk.yellow(`\n${message}`));
180183 } else if (format === "json") {
modified extensions/cli/src/compaction.infiniteLoop.test.ts +37 −25
@@ -24,13 +24,15 @@
2424 defaultCompletionOptions: {
2525 maxTokens: 1000,
2626 contextLength: 4000,
27- }
27+ },
2828 } as ModelConfig;
2929
3030 const mockLlmApi = {} as BaseLlmApi;
3131
3232 it("should not loop infinitely when pruning doesn't reduce history size", async () => {
33- const { countChatHistoryTokens, getModelContextLimit } = await import("./util/tokenizer.js");
33+ const { countChatHistoryTokens, getModelContextLimit } = await import(
34+ "./util/tokenizer.js"
35+ );
3436 const mockStreamResponse = vi.mocked(streamChatResponse);
3537 const mockCountTokens = vi.mocked(countChatHistoryTokens);
3638 const mockGetContextLimit = vi.mocked(getModelContextLimit);
@@ -38,11 +40,13 @@
3840 // Setup mocks
3941 mockGetContextLimit.mockReturnValue(4000);
4042 mockCountTokens.mockReturnValue(5000); // Always too big
41- mockStreamResponse.mockImplementation(async (history, model, api, controller, callbacks) => {
42- callbacks?.onContent?.("Summary");
43- callbacks?.onContentComplete?.();
44- return "Summary";
45- });
43+ mockStreamResponse.mockImplementation(
44+ async (history, model, api, controller, callbacks) => {
45+ callbacks?.onContent?.("Summary");
46+ callbacks?.onContentComplete?.();
47+ return "Summary";
48+ },
49+ );
4650
4751 // History that can't be pruned further (only system message)
4852 const history: ChatCompletionMessageParam[] = [
@@ -51,14 +55,16 @@
5155
5256 // This should not hang - it should break out of the loop
5357 const result = await compactChatHistory(history, mockModel, mockLlmApi);
54-
58+
5559 // Should complete successfully even though token count is still too high
5660 expect(result.compactedHistory).toBeDefined();
5761 expect(mockCountTokens).toHaveBeenCalled();
5862 });
5963
6064 it("should not loop infinitely with history ending in assistant message", async () => {
61- const { countChatHistoryTokens, getModelContextLimit } = await import("./util/tokenizer.js");
65+ const { countChatHistoryTokens, getModelContextLimit } = await import(
66+ "./util/tokenizer.js"
67+ );
6268 const mockStreamResponse = vi.mocked(streamChatResponse);
6369 const mockCountTokens = vi.mocked(countChatHistoryTokens);
6470 const mockGetContextLimit = vi.mocked(getModelContextLimit);
@@ -66,11 +72,13 @@
6672 // Setup mocks
6773 mockGetContextLimit.mockReturnValue(4000);
6874 mockCountTokens.mockReturnValue(5000); // Always too big
69- mockStreamResponse.mockImplementation(async (history, model, api, controller, callbacks) => {
70- callbacks?.onContent?.("Summary");
71- callbacks?.onContentComplete?.();
72- return "Summary";
73- });
75+ mockStreamResponse.mockImplementation(
76+ async (history, model, api, controller, callbacks) => {
77+ callbacks?.onContent?.("Summary");
78+ callbacks?.onContentComplete?.();
79+ return "Summary";
80+ },
81+ );
7482
7583 // History that ends with assistant - pruning won't change it
7684 const history: ChatCompletionMessageParam[] = [
@@ -81,19 +89,21 @@
8189
8290 // This should not hang
8391 const result = await compactChatHistory(history, mockModel, mockLlmApi);
84-
92+
8593 expect(result.compactedHistory).toBeDefined();
8694 });
8795
8896 it("should successfully prune when pruning actually reduces size", async () => {
89- const { countChatHistoryTokens, getModelContextLimit } = await import("./util/tokenizer.js");
97+ const { countChatHistoryTokens, getModelContextLimit } = await import(
98+ "./util/tokenizer.js"
99+ );
90100 const mockStreamResponse = vi.mocked(streamChatResponse);
91101 const mockCountTokens = vi.mocked(countChatHistoryTokens);
92102 const mockGetContextLimit = vi.mocked(getModelContextLimit);
93103
94104 // Setup mocks
95105 mockGetContextLimit.mockReturnValue(4000);
96-
106+
97107 // Mock token counting to show reduction after pruning
98108 let callCount = 0;
99109 mockCountTokens.mockImplementation(() => {
@@ -102,13 +112,15 @@
102112 if (callCount === 2) return 3000; // After pruning, fits
103113 return 2000; // Subsequent calls
104114 });
105-
106- mockStreamResponse.mockImplementation(async (history, model, api, controller, callbacks) => {
107- callbacks?.onContent?.("Summary");
108- callbacks?.onContentComplete?.();
109- return "Summary";
110- });
111115
116+ mockStreamResponse.mockImplementation(
117+ async (history, model, api, controller, callbacks) => {
118+ callbacks?.onContent?.("Summary");
119+ callbacks?.onContentComplete?.();
120+ return "Summary";
121+ },
122+ );
123+
112124 // History that can be successfully pruned
113125 const history: ChatCompletionMessageParam[] = [
114126 { role: "system", content: "System message" },
@@ -118,9 +130,9 @@
118130 ];
119131
120132 const result = await compactChatHistory(history, mockModel, mockLlmApi);
121-
133+
122134 expect(result.compactedHistory).toBeDefined();
123135 // The function will call countTokens multiple times during the process
124136 expect(mockCountTokens).toHaveBeenCalled();
125137 });
126-});
No newline at the end of the file
138+});
modified extensions/cli/src/compaction.pruneLastMessage.test.ts +28 −12
@@ -53,16 +53,18 @@
5353 ];
5454
5555 const result = pruneLastMessage(history);
56- expect(result).toEqual([
57- { role: "system", content: "System" },
58- ]);
56+ expect(result).toEqual([{ role: "system", content: "System" }]);
5957 });
6058
6159 it("should remove assistant+tool sequence when second-to-last is assistant with tool calls", () => {
6260 const history: ChatCompletionMessageParam[] = [
6361 { role: "system", content: "System" },
6462 { role: "user", content: "Run command" },
65- { role: "assistant", content: "Running...", tool_calls: [{ id: "1" } as any] },
63+ {
64+ role: "assistant",
65+ content: "Running...",
66+ tool_calls: [{ id: "1" } as any],
67+ },
6668 { role: "tool", content: "Command output", tool_call_id: "1" },
6769 ];
6870
@@ -95,16 +97,18 @@
9597 ];
9698
9799 const result = pruneLastMessage(history);
98- expect(result).toEqual([
99- { role: "system", content: "System" },
100- ]);
100+ expect(result).toEqual([{ role: "system", content: "System" }]);
101101 });
102102
103103 it("should handle tool call sequences by removing user after tool", () => {
104104 const history: ChatCompletionMessageParam[] = [
105105 { role: "system", content: "System" },
106106 { role: "user", content: "Do something" },
107- { role: "assistant", content: "I'll help", tool_calls: [{ id: "1" } as any] },
107+ {
108+ role: "assistant",
109+ content: "I'll help",
110+ tool_calls: [{ id: "1" } as any],
111+ },
108112 { role: "tool", content: "Tool result", tool_call_id: "1" },
109113 { role: "user", content: "Follow up question" },
110114 ];
@@ -113,7 +117,11 @@
113117 expect(result).toEqual([
114118 { role: "system", content: "System" },
115119 { role: "user", content: "Do something" },
116- { role: "assistant", content: "I'll help", tool_calls: [{ id: "1" } as any] },
120+ {
121+ role: "assistant",
122+ content: "I'll help",
123+ tool_calls: [{ id: "1" } as any],
124+ },
117125 { role: "tool", content: "Tool result", tool_call_id: "1" },
118126 ]);
119127 });
@@ -134,7 +142,11 @@
134142 { role: "user", content: "Request 1" },
135143 { role: "assistant", content: "Response 1" },
136144 { role: "user", content: "Request 2" },
137- { role: "assistant", content: "Using tool", tool_calls: [{ id: "1" } as any] },
145+ {
146+ role: "assistant",
147+ content: "Using tool",
148+ tool_calls: [{ id: "1" } as any],
149+ },
138150 { role: "tool", content: "Tool result", tool_call_id: "1" },
139151 { role: "assistant", content: "Final response" },
140152 { role: "user", content: "Follow up 1" },
@@ -147,7 +159,11 @@
147159 { role: "user", content: "Request 1" },
148160 { role: "assistant", content: "Response 1" },
149161 { role: "user", content: "Request 2" },
150- { role: "assistant", content: "Using tool", tool_calls: [{ id: "1" } as any] },
162+ {
163+ role: "assistant",
164+ content: "Using tool",
165+ tool_calls: [{ id: "1" } as any],
166+ },
151167 { role: "tool", content: "Tool result", tool_call_id: "1" },
152168 { role: "assistant", content: "Final response" },
153169 ]);
@@ -166,4 +182,4 @@
166182 { role: "assistant", content: "Hi" },
167183 ]);
168184 });
169-});
No newline at the end of the file
185+});
modified extensions/cli/src/slashCommands.test.ts +93 −44
@@ -1,5 +1,12 @@
11 import type { AssistantUnrolled } from "@continuedev/config-yaml";
2-import { describe, it, expect, vi, beforeEach, type MockedFunction } from "vitest";
2+import {
3+ describe,
4+ it,
5+ expect,
6+ vi,
7+ beforeEach,
8+ type MockedFunction,
9+} from "vitest";
310
411 import type { AuthConfig, AuthenticatedConfig } from "./auth/workos.js";
512 import type { ConfigServiceState } from "./services/types.js";
@@ -9,58 +16,60 @@
916 vi.mock("./services/index.js", () => ({
1017 services: {
1118 config: {
12- getState: vi.fn()
13- }
19+ getState: vi.fn(),
20+ },
1421 },
1522 reloadService: vi.fn(),
1623 SERVICE_NAMES: {
17- AUTH: 'AUTH'
18- }
24+ AUTH: "AUTH",
25+ },
1926 }));
2027
2128 // Mock auth functions
2229 vi.mock("./auth/workos.js", () => ({
2330 isAuthenticated: vi.fn(),
2431 isAuthenticatedConfig: vi.fn(),
25- loadAuthConfig: vi.fn()
32+ loadAuthConfig: vi.fn(),
2633 }));
2734
2835 // Mock telemetry
2936 vi.mock("./telemetry/posthogService.js", () => ({
3037 posthogService: {
31- capture: vi.fn()
32- }
38+ capture: vi.fn(),
39+ },
3340 }));
3441
3542 // Mock commands
3643 vi.mock("./commands/commands.js", () => ({
37- getAllSlashCommands: vi.fn(() => [])
44+ getAllSlashCommands: vi.fn(() => []),
3845 }));
3946
4047 // Mock os and path
4148 vi.mock("os", () => ({
4249 default: {
43- homedir: vi.fn(() => "/home/test")
44- }
50+ homedir: vi.fn(() => "/home/test"),
51+ },
4552 }));
4653
4754 vi.mock("path", () => ({
4855 default: {
49- join: vi.fn((...parts) => parts.join("/"))
56+ join: vi.fn((...parts) => parts.join("/")),
5057 },
51- join: vi.fn((...parts) => parts.join("/"))
58+ join: vi.fn((...parts) => parts.join("/")),
5259 }));
5360
5461 // Mock session functions
5562 vi.mock("./session.js", () => ({
56- getSessionFilePath: vi.fn(() => "/home/test/.continue/cli-sessions/continue-cli-pid-12345.json"),
57- hasSession: vi.fn(() => false)
63+ getSessionFilePath: vi.fn(
64+ () => "/home/test/.continue/cli-sessions/continue-cli-pid-12345.json",
65+ ),
66+ hasSession: vi.fn(() => false),
5867 }));
5968
6069 describe("slashCommands", () => {
6170 const mockAssistant: AssistantUnrolled = {
6271 name: "test-assistant",
63- version: "1.0.0"
72+ version: "1.0.0",
6473 };
6574
6675 beforeEach(() => {
@@ -71,11 +80,17 @@
7180 it("should handle /info command when not authenticated", async () => {
7281 const { isAuthenticated } = await import("./auth/workos.js");
7382 const { services } = await import("./services/index.js");
74-
75- (isAuthenticated as MockedFunction<typeof isAuthenticated>).mockReturnValue(false);
76- (services.config.getState as MockedFunction<typeof services.config.getState>).mockReturnValue({
83+
84+ (
85+ isAuthenticated as MockedFunction<typeof isAuthenticated>
86+ ).mockReturnValue(false);
87+ (
88+ services.config.getState as MockedFunction<
89+ typeof services.config.getState
90+ >
91+ ).mockReturnValue({
7792 config: null,
78- configPath: "/test/config.yaml"
93+ configPath: "/test/config.yaml",
7994 } as ConfigServiceState);
8095
8196 const result = await handleSlashCommands("/info", mockAssistant);
@@ -91,46 +106,66 @@
91106 });
92107
93108 it("should handle /info command when authenticated via environment", async () => {
94- const { isAuthenticated, loadAuthConfig, isAuthenticatedConfig } = await import("./auth/workos.js");
109+ const { isAuthenticated, loadAuthConfig, isAuthenticatedConfig } =
110+ await import("./auth/workos.js");
95111 const { services } = await import("./services/index.js");
96-
97- (isAuthenticated as MockedFunction<typeof isAuthenticated>).mockReturnValue(true);
98- (loadAuthConfig as MockedFunction<typeof loadAuthConfig>).mockReturnValue({} as AuthConfig);
112+
113+ (
114+ isAuthenticated as MockedFunction<typeof isAuthenticated>
115+ ).mockReturnValue(true);
116+ (loadAuthConfig as MockedFunction<typeof loadAuthConfig>).mockReturnValue(
117+ {} as AuthConfig,
118+ );
99119 (isAuthenticatedConfig as any).mockReturnValue(false);
100- (services.config.getState as MockedFunction<typeof services.config.getState>).mockReturnValue({
120+ (
121+ services.config.getState as MockedFunction<
122+ typeof services.config.getState
123+ >
124+ ).mockReturnValue({
101125 config: null,
102- configPath: undefined
126+ configPath: undefined,
103127 } as ConfigServiceState);
104128
105129 const result = await handleSlashCommands("/info", mockAssistant);
106130
107131 expect(result).toBeDefined();
108132 expect(result?.output).toContain("Authentication:");
109- expect(result?.output).toContain("Authenticated via environment variable");
133+ expect(result?.output).toContain(
134+ "Authenticated via environment variable",
135+ );
110136 expect(result?.output).toContain("Configuration:");
111137 expect(result?.output).toContain("Config not found");
112138 expect(result?.exit).toBe(false);
113139 });
114140
115141 it("should handle /info command when authenticated with user config", async () => {
116- const { isAuthenticated, loadAuthConfig, isAuthenticatedConfig } = await import("./auth/workos.js");
142+ const { isAuthenticated, loadAuthConfig, isAuthenticatedConfig } =
143+ await import("./auth/workos.js");
117144 const { services } = await import("./services/index.js");
118-
145+
119146 const mockAuthConfig: AuthenticatedConfig = {
120147 userId: "test-user-id",
121148 userEmail: "test@example.com",
122149 accessToken: "test-token",
123150 refreshToken: "test-refresh-token",
124151 expiresAt: Date.now() + 3600000,
125- organizationId: "test-org-id"
152+ organizationId: "test-org-id",
126153 };
127154
128- (isAuthenticated as MockedFunction<typeof isAuthenticated>).mockReturnValue(true);
129- (loadAuthConfig as MockedFunction<typeof loadAuthConfig>).mockReturnValue(mockAuthConfig);
155+ (
156+ isAuthenticated as MockedFunction<typeof isAuthenticated>
157+ ).mockReturnValue(true);
158+ (loadAuthConfig as MockedFunction<typeof loadAuthConfig>).mockReturnValue(
159+ mockAuthConfig,
160+ );
130161 (isAuthenticatedConfig as any).mockReturnValue(true);
131- (services.config.getState as MockedFunction<typeof services.config.getState>).mockReturnValue({
162+ (
163+ services.config.getState as MockedFunction<
164+ typeof services.config.getState
165+ >
166+ ).mockReturnValue({
132167 config: null,
133- configPath: "/custom/config.yaml"
168+ configPath: "/custom/config.yaml",
134169 } as ConfigServiceState);
135170
136171 const result = await handleSlashCommands("/info", mockAssistant);
@@ -147,9 +182,15 @@
147182 it("should handle config service errors gracefully", async () => {
148183 const { isAuthenticated } = await import("./auth/workos.js");
149184 const { services } = await import("./services/index.js");
150-
151- (isAuthenticated as MockedFunction<typeof isAuthenticated>).mockReturnValue(false);
152- (services.config.getState as MockedFunction<typeof services.config.getState>).mockImplementation(() => {
185+
186+ (
187+ isAuthenticated as MockedFunction<typeof isAuthenticated>
188+ ).mockReturnValue(false);
189+ (
190+ services.config.getState as MockedFunction<
191+ typeof services.config.getState
192+ >
193+ ).mockImplementation(() => {
153194 throw new Error("Service not ready");
154195 });
155196
@@ -163,14 +204,22 @@
163204 const { isAuthenticated } = await import("./auth/workos.js");
164205 const { services } = await import("./services/index.js");
165206 const { getSessionFilePath } = await import("./session.js");
166-
207+
167208 // Mock the session path for this specific test
168- (getSessionFilePath as any).mockReturnValue("/test-home/.continue/cli-sessions/continue-cli-test-123.json");
169-
170- (isAuthenticated as MockedFunction<typeof isAuthenticated>).mockReturnValue(false);
171- (services.config.getState as MockedFunction<typeof services.config.getState>).mockReturnValue({
209+ (getSessionFilePath as any).mockReturnValue(
210+ "/test-home/.continue/cli-sessions/continue-cli-test-123.json",
211+ );
212+
213+ (
214+ isAuthenticated as MockedFunction<typeof isAuthenticated>
215+ ).mockReturnValue(false);
216+ (
217+ services.config.getState as MockedFunction<
218+ typeof services.config.getState
219+ >
220+ ).mockReturnValue({
172221 config: null,
173- configPath: undefined
222+ configPath: undefined,
174223 } as ConfigServiceState);
175224
176225 const result = await handleSlashCommands("/info", mockAssistant);
@@ -179,4 +228,4 @@
179228 expect(result?.output).toContain(".json");
180229 });
181230 });
182-});
No newline at the end of the file
231+});
modified extensions/cli/src/streamChatResponse.autoCompaction.test.ts +40 −23
@@ -72,17 +72,25 @@
7272 });
7373
7474 it("should perform auto-compaction when context limit is approaching", async () => {
75- const { shouldAutoCompact, getAutoCompactMessage } = await import("./util/tokenizer.js");
75+ const { shouldAutoCompact, getAutoCompactMessage } = await import(
76+ "./util/tokenizer.js"
77+ );
7678 const { compactChatHistory } = await import("./compaction.js");
7779 const { saveSession } = await import("./session.js");
7880
7981 vi.mocked(shouldAutoCompact).mockReturnValue(true);
8082 vi.mocked(getAutoCompactMessage).mockReturnValue("Auto-compacting...");
81-
83+
8284 const mockCompactionResult = {
8385 compactedHistory: [
84- { role: "system", content: "You are a helpful assistant." } as ChatCompletionMessageParam,
85- { role: "assistant", content: "[COMPACTED HISTORY]\nConversation summary..." } as ChatCompletionMessageParam,
86+ {
87+ role: "system",
88+ content: "You are a helpful assistant.",
89+ } as ChatCompletionMessageParam,
90+ {
91+ role: "assistant",
92+ content: "[COMPACTED HISTORY]\nConversation summary...",
93+ } as ChatCompletionMessageParam,
8694 ],
8795 compactionIndex: 1,
8896 compactionContent: "Conversation summary...",
@@ -112,10 +120,16 @@
112120 mockLlmApi,
113121 expect.any(Object),
114122 );
115- expect(saveSession).toHaveBeenCalledWith(mockCompactionResult.compactedHistory);
116-
117- expect(mockCallbacks.onSystemMessage).toHaveBeenCalledWith("Auto-compacting...");
118- expect(mockCallbacks.onSystemMessage).toHaveBeenCalledWith("✓ Chat history auto-compacted successfully.");
123+ expect(saveSession).toHaveBeenCalledWith(
124+ mockCompactionResult.compactedHistory,
125+ );
126+
127+ expect(mockCallbacks.onSystemMessage).toHaveBeenCalledWith(
128+ "Auto-compacting...",
129+ );
130+ expect(mockCallbacks.onSystemMessage).toHaveBeenCalledWith(
131+ "✓ Chat history auto-compacted successfully.",
132+ );
119133
120134 expect(result).toEqual({
121135 chatHistory: mockCompactionResult.compactedHistory,
@@ -124,13 +138,17 @@
124138 });
125139
126140 it("should handle compaction errors gracefully", async () => {
127- const { shouldAutoCompact, getAutoCompactMessage } = await import("./util/tokenizer.js");
141+ const { shouldAutoCompact, getAutoCompactMessage } = await import(
142+ "./util/tokenizer.js"
143+ );
128144 const { compactChatHistory } = await import("./compaction.js");
129145 const { logger } = await import("./util/logger.js");
130146
131147 vi.mocked(shouldAutoCompact).mockReturnValue(true);
132148 vi.mocked(getAutoCompactMessage).mockReturnValue("Auto-compacting...");
133- vi.mocked(compactChatHistory).mockRejectedValue(new Error("Compaction failed"));
149+ vi.mocked(compactChatHistory).mockRejectedValue(
150+ new Error("Compaction failed"),
151+ );
134152
135153 const mockCallbacks = {
136154 onSystemMessage: vi.fn(),
@@ -161,14 +179,18 @@
161179 });
162180
163181 it("should not call system message callback in headless mode", async () => {
164- const { shouldAutoCompact, getAutoCompactMessage } = await import("./util/tokenizer.js");
182+ const { shouldAutoCompact, getAutoCompactMessage } = await import(
183+ "./util/tokenizer.js"
184+ );
165185 const { compactChatHistory } = await import("./compaction.js");
166186
167187 vi.mocked(shouldAutoCompact).mockReturnValue(true);
168188 vi.mocked(getAutoCompactMessage).mockReturnValue("Auto-compacting...");
169-
189+
170190 const mockCompactionResult = {
171- compactedHistory: [{ role: "system", content: "System" } as ChatCompletionMessageParam],
191+ compactedHistory: [
192+ { role: "system", content: "System" } as ChatCompletionMessageParam,
193+ ],
172194 compactionIndex: 0,
173195 compactionContent: "Summary",
174196 };
@@ -179,15 +201,10 @@
179201 onSystemMessage: vi.fn(),
180202 };
181203
182- await handleAutoCompaction(
183- mockChatHistory,
184- mockModel,
185- mockLlmApi,
186- {
187- isHeadless: true,
188- callbacks: mockCallbacks,
189- },
190- );
204+ await handleAutoCompaction(mockChatHistory, mockModel, mockLlmApi, {
205+ isHeadless: true,
206+ callbacks: mockCallbacks,
207+ });
191208
192209 expect(mockCallbacks.onSystemMessage).not.toHaveBeenCalled();
193210 });
@@ -205,4 +222,4 @@
205222 compactionIndex: null,
206223 });
207224 });
208-});
No newline at the end of the file
225+});
modified extensions/cli/src/streamChatResponse.autoCompaction.ts +19 −15
@@ -8,21 +8,20 @@
88 import { DisplayMessage } from "./ui/types.js";
99 import { formatError } from "./util/formatError.js";
1010 import { logger } from "./util/logger.js";
11-import {
12- getAutoCompactMessage,
13- shouldAutoCompact,
14-} from "./util/tokenizer.js";
11+import { getAutoCompactMessage, shouldAutoCompact } from "./util/tokenizer.js";
1512
1613 interface AutoCompactionCallbacks {
1714 // For streaming mode
1815 onSystemMessage?: (message: string) => void;
1916 onContent?: (content: string) => void;
20-
17+
2118 // For TUI mode
2219 setMessages?: React.Dispatch<React.SetStateAction<DisplayMessage[]>>;
23- setChatHistory?: React.Dispatch<React.SetStateAction<ChatCompletionMessageParam[]>>;
20+ setChatHistory?: React.Dispatch<
21+ React.SetStateAction<ChatCompletionMessageParam[]>
22+ >;
2423 setCompactionIndex?: React.Dispatch<React.SetStateAction<number | null>>;
25-
24+
2625 // For headless mode - no callbacks needed, just return values
2726 }
2827
@@ -41,7 +40,7 @@
4140 callbacks?: AutoCompactionCallbacks,
4241 ) {
4342 if (isHeadless) return;
44-
43+
4544 if (callbacks?.onSystemMessage) {
4645 callbacks.onSystemMessage(message);
4746 } else if (callbacks?.setMessages) {
@@ -65,12 +64,16 @@
6564 callbacks?: AutoCompactionCallbacks,
6665 ) {
6766 if (isHeadless) return;
68-
67+
6968 const successMessage = "✓ Chat history auto-compacted successfully.";
70-
69+
7170 if (callbacks?.onSystemMessage) {
7271 callbacks.onSystemMessage(successMessage);
73- } else if (callbacks?.setMessages && callbacks?.setChatHistory && callbacks?.setCompactionIndex) {
72+ } else if (
73+ callbacks?.setMessages &&
74+ callbacks?.setChatHistory &&
75+ callbacks?.setCompactionIndex
76+ ) {
7477 callbacks.setChatHistory(result.compactedHistory);
7578 callbacks.setCompactionIndex(result.compactionIndex);
7679 callbacks.setMessages((prev) => [
@@ -96,9 +99,9 @@
9699 logger.error(errorMessage);
97100
98101 if (isHeadless) return;
99-
102+
100103 const warningMessage = `Warning: ${errorMessage}. Continuing without compaction...`;
101-
104+
102105 if (callbacks?.onSystemMessage) {
103106 callbacks.onSystemMessage(warningMessage);
104107 } else if (callbacks?.setMessages) {
@@ -136,7 +139,9 @@
136139 return { chatHistory, compactionIndex: null };
137140 }
138141
139- logger.info(`Auto-compaction triggered${isHeadless ? ' in headless mode' : ''}`);
142+ logger.info(
143+ `Auto-compaction triggered${isHeadless ? " in headless mode" : ""}`,
144+ );
140145
141146 // Notify about compaction start
142147 notifyCompactionStart(getAutoCompactMessage(model), isHeadless, callbacks);
@@ -173,4 +178,3 @@
173178 return { chatHistory, compactionIndex: null };
174179 }
175180 }
176-
modified extensions/cli/src/tools/readFile.ts +4 −4
@@ -39,13 +39,13 @@
3939 const content = fs.readFileSync(args.filepath, "utf-8");
4040 // Mark this file as read for the edit tool
4141 markFileAsRead(args.filepath);
42-
43- const lines = content.split('\n');
42+
43+ const lines = content.split("\n");
4444 if (lines.length > 5000) {
45- const truncatedContent = lines.slice(0, 5000).join('\n');
45+ const truncatedContent = lines.slice(0, 5000).join("\n");
4646 return `Content of ${args.filepath} (truncated to first 5000 lines of ${lines.length} total):\n${truncatedContent}`;
4747 }
48-
48+
4949 return `Content of ${args.filepath}:\n${content}`;
5050 } catch (error) {
5151 return `Error reading file: ${