feat(hooks): add hashline-edit-diff-enhancer for TUI inline diff display
Capture file content before hashline edit execution and compute filediff metadata after, enabling opencode TUI to render inline diffs for the plugin's edit tool (which replaces the built-in EditTool).
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
createTasksTodowriteDisablerHook,
|
||||
createWriteExistingFileGuardHook,
|
||||
createHashlineReadEnhancerHook,
|
||||
createHashlineEditDiffEnhancerHook,
|
||||
} from "../../hooks"
|
||||
import {
|
||||
getOpenCodeVersion,
|
||||
@@ -31,6 +32,7 @@ export type ToolGuardHooks = {
|
||||
tasksTodowriteDisabler: ReturnType<typeof createTasksTodowriteDisablerHook> | null
|
||||
writeExistingFileGuard: ReturnType<typeof createWriteExistingFileGuardHook> | null
|
||||
hashlineReadEnhancer: ReturnType<typeof createHashlineReadEnhancerHook> | null
|
||||
hashlineEditDiffEnhancer: ReturnType<typeof createHashlineEditDiffEnhancerHook> | null
|
||||
}
|
||||
|
||||
export function createToolGuardHooks(args: {
|
||||
@@ -99,6 +101,10 @@ export function createToolGuardHooks(args: {
|
||||
? safeHook("hashline-read-enhancer", () => createHashlineReadEnhancerHook(ctx, { hashline_edit: { enabled: pluginConfig.experimental?.hashline_edit ?? true } }))
|
||||
: null
|
||||
|
||||
const hashlineEditDiffEnhancer = isHookEnabled("hashline-edit-diff-enhancer")
|
||||
? safeHook("hashline-edit-diff-enhancer", () => createHashlineEditDiffEnhancerHook({ hashline_edit: { enabled: pluginConfig.experimental?.hashline_edit ?? true } }))
|
||||
: null
|
||||
|
||||
return {
|
||||
commentChecker,
|
||||
toolOutputTruncator,
|
||||
@@ -109,5 +115,6 @@ export function createToolGuardHooks(args: {
|
||||
tasksTodowriteDisabler,
|
||||
writeExistingFileGuard,
|
||||
hashlineReadEnhancer,
|
||||
hashlineEditDiffEnhancer,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,5 +45,6 @@ export function createToolExecuteAfterHandler(args: {
|
||||
await hooks.atlasHook?.["tool.execute.after"]?.(input, output)
|
||||
await hooks.taskResumeInfo?.["tool.execute.after"]?.(input, output)
|
||||
await hooks.hashlineReadEnhancer?.["tool.execute.after"]?.(input, output)
|
||||
await hooks.hashlineEditDiffEnhancer?.["tool.execute.after"]?.(input, output)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ export function createToolExecuteBeforeHandler(args: {
|
||||
await hooks.prometheusMdOnly?.["tool.execute.before"]?.(input, output)
|
||||
await hooks.sisyphusJuniorNotepad?.["tool.execute.before"]?.(input, output)
|
||||
await hooks.atlasHook?.["tool.execute.before"]?.(input, output)
|
||||
await hooks.hashlineEditDiffEnhancer?.["tool.execute.before"]?.(input, output)
|
||||
if (input.tool === "task") {
|
||||
const argsObject = output.args
|
||||
const category = typeof argsObject.category === "string" ? argsObject.category : undefined
|
||||
|
||||
Reference in New Issue
Block a user