fix(hooks): fix sisyphus-gpt-hephaestus-reminder never matching agent name
Use getAgentConfigKey() to normalize display names (e.g. 'Sisyphus (Ultraworker)') back to config keys before comparison. Update toast to 10s duration with clearer line-broken messaging.
This commit is contained in:
@@ -1,9 +1,32 @@
|
||||
import type { PluginInput } from "@opencode-ai/plugin"
|
||||
import { isGptModel } from "../../agents/types"
|
||||
import { getSessionAgent } from "../../features/claude-code-session-state"
|
||||
import { log } from "../../shared"
|
||||
import { getAgentConfigKey } from "../../shared/agent-display-names"
|
||||
|
||||
const TOAST_TITLE = "Use Hephaestus for GPT Models"
|
||||
const TOAST_MESSAGE = "Sisyphus is using a GPT model. Use Hephaestus and include 'ulw' in your prompt."
|
||||
const TOAST_TITLE = "NEVER Use Sisyphus with GPT"
|
||||
const TOAST_MESSAGE = [
|
||||
"Sisyphus is NOT designed for GPT models.",
|
||||
"Sisyphus + GPT performs worse than vanilla Codex.",
|
||||
"You are literally burning money.",
|
||||
"Use Hephaestus for GPT models instead.",
|
||||
].join("\n")
|
||||
|
||||
function showToast(ctx: PluginInput, sessionID: string): void {
|
||||
ctx.client.tui.showToast({
|
||||
body: {
|
||||
title: TOAST_TITLE,
|
||||
message: TOAST_MESSAGE,
|
||||
variant: "error",
|
||||
duration: 10000,
|
||||
},
|
||||
}).catch((error) => {
|
||||
log("[sisyphus-gpt-hephaestus-reminder] Failed to show toast", {
|
||||
sessionID,
|
||||
error,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function createSisyphusGptHephaestusReminderHook(ctx: PluginInput) {
|
||||
return {
|
||||
@@ -12,26 +35,13 @@ export function createSisyphusGptHephaestusReminderHook(ctx: PluginInput) {
|
||||
agent?: string
|
||||
model?: { providerID: string; modelID: string }
|
||||
}): Promise<void> => {
|
||||
const agentName = (input.agent ?? getSessionAgent(input.sessionID) ?? "").toLowerCase()
|
||||
const modelID = input.model?.modelID?.toLowerCase() ?? ""
|
||||
const rawAgent = input.agent ?? getSessionAgent(input.sessionID) ?? ""
|
||||
const agentKey = getAgentConfigKey(rawAgent)
|
||||
const modelID = input.model?.modelID
|
||||
|
||||
if (agentName !== "sisyphus" || !modelID.includes("gpt")) {
|
||||
return
|
||||
if (agentKey === "sisyphus" && modelID && isGptModel(modelID)) {
|
||||
showToast(ctx, input.sessionID)
|
||||
}
|
||||
|
||||
await ctx.client.tui.showToast({
|
||||
body: {
|
||||
title: TOAST_TITLE,
|
||||
message: TOAST_MESSAGE,
|
||||
variant: "error",
|
||||
duration: 5000,
|
||||
},
|
||||
}).catch((error) => {
|
||||
log("[sisyphus-gpt-hephaestus-reminder] Failed to show toast", {
|
||||
sessionID: input.sessionID,
|
||||
error,
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,51 +1,53 @@
|
||||
import { describe, expect, test, spyOn } from "bun:test"
|
||||
import { createSisyphusGptHephaestusReminderHook } from "./index"
|
||||
import { describe, expect, spyOn, test } from "bun:test"
|
||||
import { _resetForTesting, updateSessionAgent } from "../../features/claude-code-session-state"
|
||||
import { getAgentDisplayName } from "../../shared/agent-display-names"
|
||||
import { createSisyphusGptHephaestusReminderHook } from "./index"
|
||||
|
||||
const SISYPHUS_DISPLAY = getAgentDisplayName("sisyphus")
|
||||
const HEPHAESTUS_DISPLAY = getAgentDisplayName("hephaestus")
|
||||
|
||||
describe("sisyphus-gpt-hephaestus-reminder hook", () => {
|
||||
test("shows error toast when sisyphus uses gpt model", async () => {
|
||||
// given - sisyphus agent with gpt model
|
||||
const showToast = spyOn({
|
||||
fn: async () => ({}),
|
||||
}, "fn")
|
||||
test("shows toast on every chat.message when sisyphus uses gpt model", async () => {
|
||||
// given - sisyphus (display name) with gpt model
|
||||
const showToast = spyOn({ fn: async () => ({}) }, "fn")
|
||||
const hook = createSisyphusGptHephaestusReminderHook({
|
||||
client: {
|
||||
tui: { showToast },
|
||||
},
|
||||
client: { tui: { showToast } },
|
||||
} as any)
|
||||
|
||||
// when - chat.message runs
|
||||
// when - chat.message is called repeatedly with display name
|
||||
await hook["chat.message"]?.({
|
||||
sessionID: "ses_1",
|
||||
agent: "sisyphus",
|
||||
agent: SISYPHUS_DISPLAY,
|
||||
model: { providerID: "openai", modelID: "gpt-5.3-codex" },
|
||||
})
|
||||
await hook["chat.message"]?.({
|
||||
sessionID: "ses_1",
|
||||
agent: SISYPHUS_DISPLAY,
|
||||
model: { providerID: "openai", modelID: "gpt-5.3-codex" },
|
||||
})
|
||||
|
||||
// then - error toast is shown
|
||||
expect(showToast).toHaveBeenCalledTimes(1)
|
||||
// then - toast is shown for every message
|
||||
expect(showToast).toHaveBeenCalledTimes(2)
|
||||
expect(showToast.mock.calls[0]?.[0]).toMatchObject({
|
||||
body: {
|
||||
title: "Use Hephaestus for GPT Models",
|
||||
title: "NEVER Use Sisyphus with GPT",
|
||||
message: expect.stringContaining("burning money"),
|
||||
variant: "error",
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test("does not show toast for non-gpt model", async () => {
|
||||
// given - sisyphus agent with non-gpt model
|
||||
const showToast = spyOn({
|
||||
fn: async () => ({}),
|
||||
}, "fn")
|
||||
// given - sisyphus with claude model
|
||||
const showToast = spyOn({ fn: async () => ({}) }, "fn")
|
||||
const hook = createSisyphusGptHephaestusReminderHook({
|
||||
client: {
|
||||
tui: { showToast },
|
||||
},
|
||||
client: { tui: { showToast } },
|
||||
} as any)
|
||||
|
||||
// when - chat.message runs with claude model
|
||||
// when - chat.message runs
|
||||
await hook["chat.message"]?.({
|
||||
sessionID: "ses_2",
|
||||
agent: "sisyphus",
|
||||
agent: SISYPHUS_DISPLAY,
|
||||
model: { providerID: "anthropic", modelID: "claude-opus-4-6" },
|
||||
})
|
||||
|
||||
@@ -53,26 +55,40 @@ describe("sisyphus-gpt-hephaestus-reminder hook", () => {
|
||||
expect(showToast).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
test("uses session agent fallback when input agent is missing", async () => {
|
||||
// given - session agent saved as sisyphus
|
||||
_resetForTesting()
|
||||
updateSessionAgent("ses_3", "sisyphus")
|
||||
const showToast = spyOn({
|
||||
fn: async () => ({}),
|
||||
}, "fn")
|
||||
test("does not show toast for non-sisyphus agent", async () => {
|
||||
// given - hephaestus with gpt model
|
||||
const showToast = spyOn({ fn: async () => ({}) }, "fn")
|
||||
const hook = createSisyphusGptHephaestusReminderHook({
|
||||
client: {
|
||||
tui: { showToast },
|
||||
},
|
||||
client: { tui: { showToast } },
|
||||
} as any)
|
||||
|
||||
// when - chat.message runs
|
||||
await hook["chat.message"]?.({
|
||||
sessionID: "ses_3",
|
||||
agent: HEPHAESTUS_DISPLAY,
|
||||
model: { providerID: "openai", modelID: "gpt-5.2" },
|
||||
})
|
||||
|
||||
// then - no toast
|
||||
expect(showToast).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
test("uses session agent fallback when input agent is missing", async () => {
|
||||
// given - session agent saved with display name (as OpenCode stores it)
|
||||
_resetForTesting()
|
||||
updateSessionAgent("ses_4", SISYPHUS_DISPLAY)
|
||||
const showToast = spyOn({ fn: async () => ({}) }, "fn")
|
||||
const hook = createSisyphusGptHephaestusReminderHook({
|
||||
client: { tui: { showToast } },
|
||||
} as any)
|
||||
|
||||
// when - chat.message runs without input.agent
|
||||
await hook["chat.message"]?.({
|
||||
sessionID: "ses_3",
|
||||
sessionID: "ses_4",
|
||||
model: { providerID: "openai", modelID: "gpt-5.2" },
|
||||
})
|
||||
|
||||
// then - toast shown via fallback agent lookup
|
||||
// then - toast shown via session-agent fallback
|
||||
expect(showToast).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user