fix(plugin): verify event hook compatibility with v1.4.0

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-04-08 13:08:03 +09:00
parent e52dd340c6
commit 78e6d780eb
15 changed files with 383 additions and 28 deletions
+57
View File
@@ -0,0 +1,57 @@
import { existsSync, readdirSync, readFileSync } from "node:fs"
import { join } from "node:path"
import { PART_STORAGE } from "./opencode-storage-paths"
type CompactionPartLike = {
type?: unknown
}
type CompactionMessageLike = {
agent?: unknown
info?: {
agent?: unknown
}
parts?: unknown
}
function isCompactionPart(part: unknown): boolean {
return typeof part === "object" && part !== null && (part as CompactionPartLike).type === "compaction"
}
export function isCompactionAgent(agent: unknown): boolean {
return typeof agent === "string" && agent.trim().toLowerCase() === "compaction"
}
export function hasCompactionPart(parts: unknown): boolean {
return Array.isArray(parts) && parts.some((part) => isCompactionPart(part))
}
export function isCompactionMessage(message: CompactionMessageLike): boolean {
return isCompactionAgent(message.info?.agent ?? message.agent) || hasCompactionPart(message.parts)
}
export function hasCompactionPartInStorage(messageID: string | undefined): boolean {
if (!messageID) {
return false
}
const partDir = join(PART_STORAGE, messageID)
if (!existsSync(partDir)) {
return false
}
try {
return readdirSync(partDir)
.filter((fileName) => fileName.endsWith(".json"))
.some((fileName) => {
try {
const content = readFileSync(join(partDir, fileName), "utf-8")
return isCompactionPart(JSON.parse(content))
} catch {
return false
}
})
} catch {
return false
}
}
+1
View File
@@ -68,6 +68,7 @@ export * from "./project-discovery-dirs"
export * from "./normalize-sdk-response"
export * from "./session-directory-resolver"
export * from "./prompt-tools"
export * from "./compaction-marker"
export * from "./internal-initiator-marker"
export * from "./plugin-command-discovery"
export { SessionCategoryRegistry } from "./session-category-registry"