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:
parent
c074da0b93
commit
24e983eac7
@ -78,6 +78,9 @@ export function createContextInjectorMessagesTransformHook(
|
|||||||
return {
|
return {
|
||||||
"experimental.chat.messages.transform": async (_input, output) => {
|
"experimental.chat.messages.transform": async (_input, output) => {
|
||||||
const { messages } = output
|
const { messages } = output
|
||||||
|
log("[DEBUG] experimental.chat.messages.transform called", {
|
||||||
|
messageCount: messages.length,
|
||||||
|
})
|
||||||
if (messages.length === 0) {
|
if (messages.length === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -91,16 +94,28 @@ export function createContextInjectorMessagesTransformHook(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lastUserMessageIndex === -1) {
|
if (lastUserMessageIndex === -1) {
|
||||||
|
log("[DEBUG] No user message found in messages")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const lastUserMessage = messages[lastUserMessageIndex]
|
const lastUserMessage = messages[lastUserMessageIndex]
|
||||||
const sessionID = (lastUserMessage.info as unknown as { sessionID?: string }).sessionID
|
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) {
|
if (!sessionID) {
|
||||||
|
log("[DEBUG] sessionID is undefined or empty")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!collector.hasPending(sessionID)) {
|
const hasPending = collector.hasPending(sessionID)
|
||||||
|
log("[DEBUG] Checking hasPending", {
|
||||||
|
sessionID,
|
||||||
|
hasPending,
|
||||||
|
})
|
||||||
|
if (!hasPending) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -169,6 +169,11 @@ export function createClaudeCodeHooksHook(
|
|||||||
log("UserPromptSubmit hooks prepended to first message parts directly", { sessionID: input.sessionID })
|
log("UserPromptSubmit hooks prepended to first message parts directly", { sessionID: input.sessionID })
|
||||||
}
|
}
|
||||||
} else if (contextCollector) {
|
} 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, {
|
contextCollector.register(input.sessionID, {
|
||||||
id: "hook-context",
|
id: "hook-context",
|
||||||
source: "custom",
|
source: "custom",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user