fix: clear session agent on /start-work to allow mode transition from Prometheus
When transitioning from Prometheus (Planner) to Sisyphus via /start-work, the session agent was not being cleared. This caused prometheus-md-only hook to continue injecting READ-ONLY constraints into sisyphus_task calls. - Add clearSessionAgent() call when start-work command is detected - Add TDD test verifying clearSessionAgent is called with sessionID
This commit is contained in:
parent
c7ca608b38
commit
75925d5433
@ -1,4 +1,4 @@
|
|||||||
import { describe, expect, test, beforeEach, afterEach } from "bun:test"
|
import { describe, expect, test, beforeEach, afterEach, spyOn } from "bun:test"
|
||||||
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs"
|
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs"
|
||||||
import { join } from "node:path"
|
import { join } from "node:path"
|
||||||
import { tmpdir, homedir } from "node:os"
|
import { tmpdir, homedir } from "node:os"
|
||||||
@ -8,6 +8,7 @@ import {
|
|||||||
clearBoulderState,
|
clearBoulderState,
|
||||||
} from "../../features/boulder-state"
|
} from "../../features/boulder-state"
|
||||||
import type { BoulderState } from "../../features/boulder-state"
|
import type { BoulderState } from "../../features/boulder-state"
|
||||||
|
import * as sessionState from "../../features/claude-code-session-state"
|
||||||
|
|
||||||
describe("start-work hook", () => {
|
describe("start-work hook", () => {
|
||||||
const TEST_DIR = join(tmpdir(), "start-work-test-" + Date.now())
|
const TEST_DIR = join(tmpdir(), "start-work-test-" + Date.now())
|
||||||
@ -380,4 +381,26 @@ feature-implementation
|
|||||||
expect(output.parts[0].text).toContain("Auto-Selected Plan")
|
expect(output.parts[0].text).toContain("Auto-Selected Plan")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("session agent management", () => {
|
||||||
|
test("should clear session agent when start-work command is triggered", async () => {
|
||||||
|
// #given - spy on clearSessionAgent
|
||||||
|
const clearSpy = spyOn(sessionState, "clearSessionAgent")
|
||||||
|
|
||||||
|
const hook = createStartWorkHook(createMockPluginInput())
|
||||||
|
const output = {
|
||||||
|
parts: [{ type: "text", text: "Start Sisyphus work session" }],
|
||||||
|
}
|
||||||
|
|
||||||
|
// #when - start-work command is processed
|
||||||
|
await hook["chat.message"](
|
||||||
|
{ sessionID: "ses-prometheus-to-sisyphus" },
|
||||||
|
output
|
||||||
|
)
|
||||||
|
|
||||||
|
// #then - clearSessionAgent should be called with the sessionID
|
||||||
|
expect(clearSpy).toHaveBeenCalledWith("ses-prometheus-to-sisyphus")
|
||||||
|
clearSpy.mockRestore()
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import {
|
|||||||
clearBoulderState,
|
clearBoulderState,
|
||||||
} from "../../features/boulder-state"
|
} from "../../features/boulder-state"
|
||||||
import { log } from "../../shared/logger"
|
import { log } from "../../shared/logger"
|
||||||
|
import { clearSessionAgent } from "../../features/claude-code-session-state"
|
||||||
|
|
||||||
export const HOOK_NAME = "start-work"
|
export const HOOK_NAME = "start-work"
|
||||||
|
|
||||||
@ -70,6 +71,9 @@ export function createStartWorkHook(ctx: PluginInput) {
|
|||||||
sessionID: input.sessionID,
|
sessionID: input.sessionID,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Clear previous session agent (e.g., Prometheus) to allow mode transition
|
||||||
|
clearSessionAgent(input.sessionID)
|
||||||
|
|
||||||
const existingState = readBoulderState(ctx.directory)
|
const existingState = readBoulderState(ctx.directory)
|
||||||
const sessionId = input.sessionID
|
const sessionId = input.sessionID
|
||||||
const timestamp = new Date().toISOString()
|
const timestamp = new Date().toISOString()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user