summaryrefslogtreecommitdiff
path: root/plugins/code-modernization/hooks/host.ts
diff options
context:
space:
mode:
authorMorgan Lunt <morganl@anthropic.com>2026-09-25 16:12:23 -0700
committerGitHub <noreply@github.com>2026-09-25 16:12:23 -0700
commitfa59bc9037741ecfa131aa27938272605710d7b2 (patch)
tree068d2fe6cb3f530c305d1e21bc129ab2c9b49dc6 /plugins/code-modernization/hooks/host.ts
parentca08d5e47d6402db586d37780c559a0c4c7ded9a (diff)
parentc8874f5ad883e26428f483ffa4d537cc81489e64 (diff)
Merge pull request #6309 from anthropics/morganl/code-modernization-consolidated
code-modernization: guided workflow with independent proof
Diffstat (limited to 'plugins/code-modernization/hooks/host.ts')
-rw-r--r--plugins/code-modernization/hooks/host.ts43
1 files changed, 43 insertions, 0 deletions
diff --git a/plugins/code-modernization/hooks/host.ts b/plugins/code-modernization/hooks/host.ts
new file mode 100644
index 00000000..9190a4cc
--- /dev/null
+++ b/plugins/code-modernization/hooks/host.ts
@@ -0,0 +1,43 @@
+import type {
+ CommandSpec,
+ PaneCloseArgs,
+ PaneOpenArgs,
+ PromptFillArgs,
+ PromptSubmitArgs,
+ TimerCall,
+ UiBlitArgs,
+ UiBlitResult,
+} from 'claude-code'
+
+import type { ReaderFs } from './reader/fs'
+
+/**
+ * What `$.ui.open` answers: drawn, or open but held back undrawn (unasked, on a terminal narrower than the engine docks a
+ * pane on) with the reason. A build that answers nothing has drawn it, as far as anyone can tell.
+ */
+export type OpenResult = { isPlaced: boolean; reason?: string } | void
+
+/**
+ * The engine as `session.start` bound it from its `$`: every later hook,
+ * timer and button press reaches the engine through this, so the rest of
+ * the module is plain functions over a small interface a test can stand in for.
+ */
+export type Host = {
+ fs: ReaderFs & { write: (path: string, text: string) => Promise<void> }
+ now: () => Promise<number>
+ after: TimerCall
+ every: TimerCall
+ storeGet: (key: string) => Promise<unknown>
+ storeSet: (key: string, value: unknown) => Promise<void>
+ invalidate: () => void
+ blit: (args: UiBlitArgs) => Promise<UiBlitResult>
+ status: (text: string | undefined) => void
+ toast: (text: string, timeoutMs?: number) => void
+ log: (text: string) => void
+ openPane: (pane: PaneOpenArgs) => Promise<OpenResult>
+ closePane: (pane: PaneCloseArgs) => Promise<void>
+ registerCommand: (spec: CommandSpec) => Promise<unknown>
+ fillPrompt: (input: PromptFillArgs) => Promise<{ isFilled: boolean }>
+ submitPrompt: (input: PromptSubmitArgs) => Promise<unknown>
+ abortTurn: (turnId: string) => Promise<void>
+}