From 2fd847d88dffed9f5504006c18516e90bd4002ee Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Tue, 10 Feb 2026 11:16:55 +0900 Subject: [PATCH] refactor: fix import path and update test fixtures - Fix import path in opencode-skill-loader/loader.ts - Update executor.test.ts fixtures --- src/features/opencode-skill-loader/loader.ts | 2 +- .../executor.test.ts | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/features/opencode-skill-loader/loader.ts b/src/features/opencode-skill-loader/loader.ts index 6caf4e73d..2eebc0077 100644 --- a/src/features/opencode-skill-loader/loader.ts +++ b/src/features/opencode-skill-loader/loader.ts @@ -1,5 +1,5 @@ import { join } from "path" -import { getClaudeConfigDir } from "../../shared" +import { getClaudeConfigDir } from "../../shared/claude-config-dir" import { getOpenCodeConfigDir } from "../../shared/opencode-config-dir" import type { CommandDefinition } from "../claude-code-command-loader/types" import type { LoadedSkill } from "./types" diff --git a/src/hooks/anthropic-context-window-limit-recovery/executor.test.ts b/src/hooks/anthropic-context-window-limit-recovery/executor.test.ts index ca6d383c8..aa1fea43e 100644 --- a/src/hooks/anthropic-context-window-limit-recovery/executor.test.ts +++ b/src/hooks/anthropic-context-window-limit-recovery/executor.test.ts @@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, mock, spyOn, test } from "bun: import { executeCompact } from "./executor" import type { AutoCompactState } from "./types" import * as storage from "./storage" +import * as messagesReader from "../session-recovery/storage/messages-reader" type TimerCallback = (...args: any[]) => void @@ -168,7 +169,8 @@ describe("executeCompact lock management", () => { }) test("clears lock when fixEmptyMessages path executes", async () => { - // given: Empty content error scenario + //#given - Empty content error scenario with no messages in storage + const readMessagesSpy = spyOn(messagesReader, "readMessages").mockReturnValue([]) autoCompactState.errorDataBySession.set(sessionID, { errorType: "non-empty content required", messageIndex: 0, @@ -176,16 +178,17 @@ describe("executeCompact lock management", () => { maxTokens: 200000, }) - // when: Execute compaction (fixEmptyMessages will be called) + //#when - Execute compaction (fixEmptyMessages will be called) await executeCompact(sessionID, msg, autoCompactState, mockClient, directory) - // then: Lock should be cleared + //#then - Lock should be cleared expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(false) + readMessagesSpy.mockRestore() }) test("clears lock when truncation is sufficient", async () => { - // given: Aggressive truncation scenario with sufficient truncation - // This test verifies the early return path in aggressive truncation + //#given - Aggressive truncation scenario with no messages in storage + const readMessagesSpy = spyOn(messagesReader, "readMessages").mockReturnValue([]) autoCompactState.errorDataBySession.set(sessionID, { errorType: "token_limit", currentTokens: 250000, @@ -197,7 +200,7 @@ describe("executeCompact lock management", () => { aggressive_truncation: true, } - // when: Execute compaction with experimental flag + //#when - Execute compaction with experimental flag await executeCompact( sessionID, msg, @@ -207,8 +210,9 @@ describe("executeCompact lock management", () => { experimental, ) - // then: Lock should be cleared even on early return + //#then - Lock should be cleared even on early return expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(false) + readMessagesSpy.mockRestore() }) test("prevents concurrent compaction attempts", async () => {