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:
parent
9b56b748ec
commit
27d5379215
@ -7,6 +7,7 @@ import {
|
|||||||
CategoryConfigSchema,
|
CategoryConfigSchema,
|
||||||
ExperimentalConfigSchema,
|
ExperimentalConfigSchema,
|
||||||
GitMasterConfigSchema,
|
GitMasterConfigSchema,
|
||||||
|
HookNameSchema,
|
||||||
OhMyOpenCodeConfigSchema,
|
OhMyOpenCodeConfigSchema,
|
||||||
} from "./schema"
|
} from "./schema"
|
||||||
|
|
||||||
@ -393,6 +394,19 @@ describe("BuiltinCategoryNameSchema", () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("HookNameSchema", () => {
|
||||||
|
test("rejects removed beast-mode-system hook name", () => {
|
||||||
|
//#given
|
||||||
|
const input = "beast-mode-system"
|
||||||
|
|
||||||
|
//#when
|
||||||
|
const result = HookNameSchema.safeParse(input)
|
||||||
|
|
||||||
|
//#then
|
||||||
|
expect(result.success).toBe(false)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("Sisyphus-Junior agent override", () => {
|
describe("Sisyphus-Junior agent override", () => {
|
||||||
test("schema accepts agents['Sisyphus-Junior'] and retains the key after parsing", () => {
|
test("schema accepts agents['Sisyphus-Junior'] and retains the key after parsing", () => {
|
||||||
// given
|
// given
|
||||||
|
|||||||
@ -25,7 +25,6 @@ export const HookNameSchema = z.enum([
|
|||||||
"interactive-bash-session",
|
"interactive-bash-session",
|
||||||
|
|
||||||
"thinking-block-validator",
|
"thinking-block-validator",
|
||||||
"beast-mode-system",
|
|
||||||
"ralph-loop",
|
"ralph-loop",
|
||||||
"category-skill-reminder",
|
"category-skill-reminder",
|
||||||
|
|
||||||
|
|||||||
@ -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 { createRuntimeFallbackHook, type RuntimeFallbackHook, type RuntimeFallbackOptions } from "./runtime-fallback";
|
||||||
export { createWriteExistingFileGuardHook } from "./write-existing-file-guard";
|
export { createWriteExistingFileGuardHook } from "./write-existing-file-guard";
|
||||||
export { createHashlineReadEnhancerHook } from "./hashline-read-enhancer";
|
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";
|
export { createJsonErrorRecoveryHook, JSON_ERROR_TOOL_EXCLUDE_LIST, JSON_ERROR_PATTERNS, JSON_ERROR_REMINDER } from "./json-error-recovery";
|
||||||
|
|||||||
@ -50,9 +50,7 @@ export function createPluginInterface(args: {
|
|||||||
hooks,
|
hooks,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
"experimental.chat.system.transform": createSystemTransformHandler({
|
"experimental.chat.system.transform": createSystemTransformHandler(),
|
||||||
hooks,
|
|
||||||
}),
|
|
||||||
|
|
||||||
config: managers.configHandler,
|
config: managers.configHandler,
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import {
|
|||||||
createClaudeCodeHooksHook,
|
createClaudeCodeHooksHook,
|
||||||
createKeywordDetectorHook,
|
createKeywordDetectorHook,
|
||||||
createThinkingBlockValidatorHook,
|
createThinkingBlockValidatorHook,
|
||||||
createBeastModeSystemHook,
|
|
||||||
} from "../../hooks"
|
} from "../../hooks"
|
||||||
import {
|
import {
|
||||||
contextCollector,
|
contextCollector,
|
||||||
@ -18,7 +17,6 @@ export type TransformHooks = {
|
|||||||
keywordDetector: ReturnType<typeof createKeywordDetectorHook> | null
|
keywordDetector: ReturnType<typeof createKeywordDetectorHook> | null
|
||||||
contextInjectorMessagesTransform: ReturnType<typeof createContextInjectorMessagesTransformHook>
|
contextInjectorMessagesTransform: ReturnType<typeof createContextInjectorMessagesTransformHook>
|
||||||
thinkingBlockValidator: ReturnType<typeof createThinkingBlockValidatorHook> | null
|
thinkingBlockValidator: ReturnType<typeof createThinkingBlockValidatorHook> | null
|
||||||
beastModeSystem: ReturnType<typeof createBeastModeSystemHook> | null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createTransformHooks(args: {
|
export function createTransformHooks(args: {
|
||||||
@ -65,19 +63,10 @@ export function createTransformHooks(args: {
|
|||||||
)
|
)
|
||||||
: null
|
: null
|
||||||
|
|
||||||
const beastModeSystem = isHookEnabled("beast-mode-system")
|
|
||||||
? safeCreateHook(
|
|
||||||
"beast-mode-system",
|
|
||||||
() => createBeastModeSystemHook(),
|
|
||||||
{ enabled: safeHookEnabled },
|
|
||||||
)
|
|
||||||
: null
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
claudeCodeHooks,
|
claudeCodeHooks,
|
||||||
keywordDetector,
|
keywordDetector,
|
||||||
contextInjectorMessagesTransform,
|
contextInjectorMessagesTransform,
|
||||||
thinkingBlockValidator,
|
thinkingBlockValidator,
|
||||||
beastModeSystem,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,6 @@
|
|||||||
import type { CreatedHooks } from "../create-hooks"
|
export function createSystemTransformHandler(): (
|
||||||
|
input: { sessionID: string },
|
||||||
export function createSystemTransformHandler(args: {
|
output: { system: string[] },
|
||||||
hooks: CreatedHooks
|
) => Promise<void> {
|
||||||
}): (input: { sessionID: string }, output: { system: string[] }) => Promise<void> {
|
return async (): Promise<void> => {}
|
||||||
return async (input, output): Promise<void> => {
|
|
||||||
await args.hooks.beastModeSystem?.["experimental.chat.system.transform"]?.(
|
|
||||||
input,
|
|
||||||
output,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user