fix: store session agent in chat.message for prometheus-md-only hook

The prometheus-md-only hook was not enforcing file restrictions because
getSessionAgent() returned undefined - setSessionAgent was only called
in message.updated event which doesn't always provide agent info.

- Add setSessionAgent call in chat.message hook when input.agent exists
- Add session state tests for setSessionAgent/getSessionAgent
- Add clearSessionAgent cleanup to prometheus-md-only tests

This ensures prometheus-md-only hook can reliably identify Prometheus
sessions and enforce .sisyphus/*.md write restrictions.
This commit is contained in:
justsisyphus
2026-01-16 11:33:25 +09:00
parent 75925d5433
commit c282244439
3 changed files with 133 additions and 0 deletions
@@ -4,6 +4,7 @@ import { join } from "node:path"
import { createPrometheusMdOnlyHook } from "./index"
import { MESSAGE_STORAGE } from "../../features/hook-message-injector"
import { SYSTEM_DIRECTIVE_PREFIX, createSystemDirective, SystemDirectiveTypes } from "../../shared/system-directive"
import { clearSessionAgent } from "../../features/claude-code-session-state"
describe("prometheus-md-only", () => {
const TEST_SESSION_ID = "test-session-prometheus"
@@ -30,6 +31,7 @@ describe("prometheus-md-only", () => {
}
afterEach(() => {
clearSessionAgent(TEST_SESSION_ID)
if (testMessageDir) {
try {
rmSync(testMessageDir, { recursive: true, force: true })