refactor(hooks): remove beast-mode system integration
Remove the beast-mode-system hook and all transform wiring so Copilot-specific prompt injection is fully eliminated from the runtime pipeline.
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { clearSessionModel, setSessionModel } from "../../shared/session-model-state"
|
||||
import { createBeastModeSystemHook, BEAST_MODE_SYSTEM_PROMPT } from "./hook"
|
||||
|
||||
describe("beast-mode-system hook", () => {
|
||||
test("injects beast mode prompt for copilot gpt-4.1", async () => {
|
||||
//#given
|
||||
const sessionID = "ses_beast"
|
||||
setSessionModel(sessionID, { providerID: "github-copilot", modelID: "gpt-4.1" })
|
||||
const hook = createBeastModeSystemHook()
|
||||
const output = { system: [] as string[] }
|
||||
|
||||
//#when
|
||||
await hook["experimental.chat.system.transform"]?.({ sessionID }, output)
|
||||
|
||||
//#then
|
||||
expect(output.system[0]).toContain("Beast Mode")
|
||||
expect(output.system[0]).toContain(BEAST_MODE_SYSTEM_PROMPT.trim().slice(0, 20))
|
||||
|
||||
clearSessionModel(sessionID)
|
||||
})
|
||||
|
||||
test("does not inject for other models", async () => {
|
||||
//#given
|
||||
const sessionID = "ses_no_beast"
|
||||
setSessionModel(sessionID, { providerID: "anthropic", modelID: "gpt-5.3-codex" })
|
||||
const hook = createBeastModeSystemHook()
|
||||
const output = { system: [] as string[] }
|
||||
|
||||
//#when
|
||||
await hook["experimental.chat.system.transform"]?.({ sessionID }, output)
|
||||
|
||||
//#then
|
||||
expect(output.system.length).toBe(0)
|
||||
|
||||
clearSessionModel(sessionID)
|
||||
})
|
||||
|
||||
test("avoids duplicate insertion", async () => {
|
||||
//#given
|
||||
const sessionID = "ses_dupe"
|
||||
setSessionModel(sessionID, { providerID: "github-copilot", modelID: "gpt-4.1" })
|
||||
const hook = createBeastModeSystemHook()
|
||||
const output = { system: [BEAST_MODE_SYSTEM_PROMPT] }
|
||||
|
||||
//#when
|
||||
await hook["experimental.chat.system.transform"]?.({ sessionID }, output)
|
||||
|
||||
//#then
|
||||
expect(output.system.length).toBe(1)
|
||||
|
||||
clearSessionModel(sessionID)
|
||||
})
|
||||
})
|
||||
@@ -1,31 +0,0 @@
|
||||
import { getSessionModel } from "../../shared/session-model-state"
|
||||
|
||||
export const BEAST_MODE_SYSTEM_PROMPT = `Beast Mode (Copilot GPT-4.1)
|
||||
|
||||
You are an autonomous coding agent. Execute the task end-to-end.
|
||||
- Make a brief plan, then act.
|
||||
- Prefer concrete edits and verification over speculation.
|
||||
- Run relevant tests when feasible.
|
||||
- Do not ask the user to perform actions you can do yourself.
|
||||
- If blocked, state exactly what is needed to proceed.
|
||||
- Keep responses concise and actionable.`
|
||||
|
||||
function isBeastModeModel(model: { providerID: string; modelID: string } | undefined): boolean {
|
||||
return model?.providerID === "github-copilot" && model.modelID === "gpt-4.1"
|
||||
}
|
||||
|
||||
export function createBeastModeSystemHook() {
|
||||
return {
|
||||
"experimental.chat.system.transform": async (
|
||||
input: { sessionID: string },
|
||||
output: { system: string[] },
|
||||
): Promise<void> => {
|
||||
const model = getSessionModel(input.sessionID)
|
||||
if (!isBeastModeModel(model)) return
|
||||
|
||||
if (output.system.some((entry) => entry.includes("Beast Mode"))) return
|
||||
|
||||
output.system.unshift(BEAST_MODE_SYSTEM_PROMPT)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export { createBeastModeSystemHook, BEAST_MODE_SYSTEM_PROMPT } from "./hook"
|
||||
@@ -49,5 +49,4 @@ export { createTasksTodowriteDisablerHook } from "./tasks-todowrite-disabler";
|
||||
export { createRuntimeFallbackHook, type RuntimeFallbackHook, type RuntimeFallbackOptions } from "./runtime-fallback";
|
||||
export { createWriteExistingFileGuardHook } from "./write-existing-file-guard";
|
||||
export { createHashlineReadEnhancerHook } from "./hashline-read-enhancer";
|
||||
export { createBeastModeSystemHook, BEAST_MODE_SYSTEM_PROMPT } from "./beast-mode-system";
|
||||
export { createJsonErrorRecoveryHook, JSON_ERROR_TOOL_EXCLUDE_LIST, JSON_ERROR_PATTERNS, JSON_ERROR_REMINDER } from "./json-error-recovery";
|
||||
|
||||
Reference in New Issue
Block a user