From 284e7f5bc333158495c1b68eb6887f9ab013bd19 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sun, 28 Dec 2025 15:49:04 +0900 Subject: [PATCH] fix(anthropic-auto-compact): use correct MESSAGE_STORAGE path for session messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The DCP pruning modules were using a hardcoded path (~/.config/opencode/sessions) that doesn't exist. Sessions are actually stored at ~/.local/share/opencode/storage/message. All pruning modules now import MESSAGE_STORAGE from hook-message-injector, which uses the correct path via getOpenCodeStorageDir(). This fixes the issue where DCP would fail with 'message dir not found' when trying to recover from token limit errors. 🤖 Generated with assistance of OhMyOpenCode (https://github.com/code-yeongyu/oh-my-opencode) --- src/hooks/anthropic-auto-compact/pruning-deduplication.ts | 8 +------- src/hooks/anthropic-auto-compact/pruning-purge-errors.ts | 8 +------- src/hooks/anthropic-auto-compact/pruning-storage.ts | 8 +------- src/hooks/anthropic-auto-compact/pruning-supersede.ts | 8 +------- 4 files changed, 4 insertions(+), 28 deletions(-) diff --git a/src/hooks/anthropic-auto-compact/pruning-deduplication.ts b/src/hooks/anthropic-auto-compact/pruning-deduplication.ts index f2f1851..b3e8b52 100644 --- a/src/hooks/anthropic-auto-compact/pruning-deduplication.ts +++ b/src/hooks/anthropic-auto-compact/pruning-deduplication.ts @@ -3,19 +3,13 @@ import { join } from "node:path" import type { PruningState, ToolCallSignature } from "./pruning-types" import { estimateTokens } from "./pruning-types" import { log } from "../../shared/logger" +import { MESSAGE_STORAGE } from "../../features/hook-message-injector" export interface DeduplicationConfig { enabled: boolean protectedTools?: string[] } -const MESSAGE_STORAGE = join( - process.env.HOME || process.env.USERPROFILE || "", - ".config", - "opencode", - "sessions" -) - interface ToolPart { type: string callID?: string diff --git a/src/hooks/anthropic-auto-compact/pruning-purge-errors.ts b/src/hooks/anthropic-auto-compact/pruning-purge-errors.ts index 89f9444..0cb36d1 100644 --- a/src/hooks/anthropic-auto-compact/pruning-purge-errors.ts +++ b/src/hooks/anthropic-auto-compact/pruning-purge-errors.ts @@ -3,6 +3,7 @@ import { join } from "node:path" import type { PruningState, ErroredToolCall } from "./pruning-types" import { estimateTokens } from "./pruning-types" import { log } from "../../shared/logger" +import { MESSAGE_STORAGE } from "../../features/hook-message-injector" export interface PurgeErrorsConfig { enabled: boolean @@ -10,13 +11,6 @@ export interface PurgeErrorsConfig { protectedTools?: string[] } -const MESSAGE_STORAGE = join( - process.env.HOME || process.env.USERPROFILE || "", - ".config", - "opencode", - "sessions" -) - interface ToolPart { type: string callID?: string diff --git a/src/hooks/anthropic-auto-compact/pruning-storage.ts b/src/hooks/anthropic-auto-compact/pruning-storage.ts index 76bb500..462e1d5 100644 --- a/src/hooks/anthropic-auto-compact/pruning-storage.ts +++ b/src/hooks/anthropic-auto-compact/pruning-storage.ts @@ -3,13 +3,7 @@ import { join } from "node:path" import type { PruningState } from "./pruning-types" import { estimateTokens } from "./pruning-types" import { log } from "../../shared/logger" - -const MESSAGE_STORAGE = join( - process.env.HOME || process.env.USERPROFILE || "", - ".config", - "opencode", - "sessions" -) +import { MESSAGE_STORAGE } from "../../features/hook-message-injector" function getMessageDir(sessionID: string): string | null { if (!existsSync(MESSAGE_STORAGE)) return null diff --git a/src/hooks/anthropic-auto-compact/pruning-supersede.ts b/src/hooks/anthropic-auto-compact/pruning-supersede.ts index c2b2015..0a75d80 100644 --- a/src/hooks/anthropic-auto-compact/pruning-supersede.ts +++ b/src/hooks/anthropic-auto-compact/pruning-supersede.ts @@ -3,19 +3,13 @@ import { join } from "node:path" import type { PruningState, FileOperation } from "./pruning-types" import { estimateTokens } from "./pruning-types" import { log } from "../../shared/logger" +import { MESSAGE_STORAGE } from "../../features/hook-message-injector" export interface SupersedeWritesConfig { enabled: boolean aggressive: boolean } -const MESSAGE_STORAGE = join( - process.env.HOME || process.env.USERPROFILE || "", - ".config", - "opencode", - "sessions" -) - interface ToolPart { type: string callID?: string