feat(hook): add context window monitor for Anthropic token usage tracking

This commit is contained in:
YeonGyu-Kim
2025-12-03 13:28:41 +09:00
parent 9054973f23
commit 9a11901590
3 changed files with 110 additions and 2 deletions

View File

@@ -1,9 +1,10 @@
import type { Plugin } from "@opencode-ai/plugin"
import { builtinAgents } from "./agents"
import { createTodoContinuationEnforcer } from "./hooks"
import { createTodoContinuationEnforcer, createContextWindowMonitorHook } from "./hooks"
const OhMyOpenCodePlugin: Plugin = async (ctx) => {
const todoContinuationEnforcer = createTodoContinuationEnforcer(ctx)
const contextWindowMonitor = createContextWindowMonitorHook(ctx)
return {
config: async (config) => {
@@ -13,7 +14,12 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
}
},
event: todoContinuationEnforcer,
event: async (input) => {
await todoContinuationEnforcer(input)
await contextWindowMonitor.event(input)
},
"tool.execute.after": contextWindowMonitor["tool.execute.after"],
}
}