chore(context-injector): add debug logging for context injection tracing
Add DEBUG log statements to trace context injection flow: - Log message transform hook invocations - Log sessionID extraction from message info - Log hasPending checks for context collector - Log hook content registration to contextCollector 🤖 Generated with [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode) assistance
This commit is contained in:
@@ -78,6 +78,9 @@ export function createContextInjectorMessagesTransformHook(
|
||||
return {
|
||||
"experimental.chat.messages.transform": async (_input, output) => {
|
||||
const { messages } = output
|
||||
log("[DEBUG] experimental.chat.messages.transform called", {
|
||||
messageCount: messages.length,
|
||||
})
|
||||
if (messages.length === 0) {
|
||||
return
|
||||
}
|
||||
@@ -91,16 +94,28 @@ export function createContextInjectorMessagesTransformHook(
|
||||
}
|
||||
|
||||
if (lastUserMessageIndex === -1) {
|
||||
log("[DEBUG] No user message found in messages")
|
||||
return
|
||||
}
|
||||
|
||||
const lastUserMessage = messages[lastUserMessageIndex]
|
||||
const sessionID = (lastUserMessage.info as unknown as { sessionID?: string }).sessionID
|
||||
log("[DEBUG] Extracted sessionID from lastUserMessage.info", {
|
||||
sessionID,
|
||||
infoKeys: Object.keys(lastUserMessage.info),
|
||||
lastUserMessageInfo: JSON.stringify(lastUserMessage.info).slice(0, 200),
|
||||
})
|
||||
if (!sessionID) {
|
||||
log("[DEBUG] sessionID is undefined or empty")
|
||||
return
|
||||
}
|
||||
|
||||
if (!collector.hasPending(sessionID)) {
|
||||
const hasPending = collector.hasPending(sessionID)
|
||||
log("[DEBUG] Checking hasPending", {
|
||||
sessionID,
|
||||
hasPending,
|
||||
})
|
||||
if (!hasPending) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -169,6 +169,11 @@ export function createClaudeCodeHooksHook(
|
||||
log("UserPromptSubmit hooks prepended to first message parts directly", { sessionID: input.sessionID })
|
||||
}
|
||||
} else if (contextCollector) {
|
||||
log("[DEBUG] Registering hook content to contextCollector", {
|
||||
sessionID: input.sessionID,
|
||||
contentLength: hookContent.length,
|
||||
contentPreview: hookContent.slice(0, 100),
|
||||
})
|
||||
contextCollector.register(input.sessionID, {
|
||||
id: "hook-context",
|
||||
source: "custom",
|
||||
|
||||
Reference in New Issue
Block a user