File size: 2,280 Bytes
bdbd3b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import type {
  CommandSpec,
  EngineInterface,
  FsEntry,
  FsStat,
  PaneCloseArgs,
  PaneOpenArgs,
  ProcessRunInit,
  ProcessRunResult,
  SessionMessage,
  TimerCall,
} from 'claude-code'

/**
 * The engine as `session.start` bound it from its `$`, each member spelled
 * `$.noun.event(...)` there; used by every later hook, timer and press.
 */
export type Host = {
  /**
   * `$.clock.now`.
   */
  now: () => Promise<number>

  /**
   * `$.clock.after`.
   */
  after: TimerCall

  /**
   * `$.clock.every`.
   */
  every: TimerCall

  /**
   * `$.process.run`.
   */
  run: (
    argv: readonly string[],
    init: ProcessRunInit,
  ) => Promise<ProcessRunResult>

  /**
   * `$.fs.stat`.
   */
  stat: (path: string) => Promise<FsStat>

  /**
   * `$.fs.list`: a directory's entries by kind, links never followed.
   */
  listDir: (path: string) => Promise<FsEntry[]>

  /**
   * `$.fs.read`.
   */
  readFile: (path: string) => Promise<string>

  /**
   * Reads the plugin's store (`$.store.get`).
   */
  storeGet: (key: string) => Promise<unknown>

  /**
   * Writes the plugin's store (`$.store.set`).
   */
  storeSet: (key: string, value: unknown) => Promise<void>

  /**
   * `$.session.messages`.
   */
  messages: () => Promise<SessionMessage[]>

  /**
   * `$.ui.invalidate("ui.render")`: every pane instance draws again.
   */
  invalidate: () => void

  /**
   * `$.ui.status`: the plugin's line under the prompt.
   */
  status: (text: string | undefined) => void

  /**
   * One debug line under the plugin's name (`$.ui.log`).
   */
  uiLog: (text: string) => void

  /**
   * `$.ui.open`.
   */
  openPane: (pane: PaneOpenArgs) => Promise<void>

  /**
   * `$.ui.close`.
   */
  closePane: (pane: PaneCloseArgs) => Promise<void>

  /**
   * `$.command.register`; rejects while another `/diff` is listed.
   */
  registerCommand: (spec: CommandSpec) => Promise<unknown>

  /**
   * Which session the pane-shown row is latched to, as `$.session.id` says.
   */
  sessionId: () => Promise<string>

  /**
   * `$.telemetry.mark`; rejects where the telemetry built-in is absent.
   */
  mark: EngineInterface['telemetry']['mark']

  /**
   * `$.telemetry.log`; rejects where the telemetry built-in is absent.
   */
  log: EngineInterface['telemetry']['log']
}