opencode-drive 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "opencode-drive",
4
- "version": "0.1.5",
4
+ "version": "0.1.7",
5
5
  "description": "Drive real and simulated OpenCode instances",
6
6
  "license": "MIT",
7
7
  "type": "module",
package/src/cli/index.ts CHANGED
@@ -3,7 +3,6 @@ import { NodeRuntime, NodeServices } from "@effect/platform-node"
3
3
  import { Effect, Option } from "effect"
4
4
  import { Command, Flag } from "effect/unstable/cli"
5
5
  import packageJson from "../../package.json" with { type: "json" }
6
- import { api } from "./api.js"
7
6
  import { extractCommands } from "./parse.js"
8
7
  import { list } from "./list.js"
9
8
  import { logs } from "./logs.js"
@@ -29,6 +28,7 @@ const startCommand = Command.make(
29
28
  {
30
29
  name: startName,
31
30
  daemon: Flag.boolean("daemon").pipe(
31
+ Flag.withHidden,
32
32
  Flag.withDescription("Run as detached instance owner"),
33
33
  ),
34
34
  script: Flag.string("script").pipe(
@@ -90,9 +90,41 @@ const sendCommand = Command.make("send", { name }, (config) =>
90
90
  ]),
91
91
  )
92
92
 
93
- const apiCommand = Command.make("api", {}, () => execute(api)).pipe(
94
- Command.withDescription("Print the OpenCode drive UI protocol"),
95
- )
93
+ const screenshotCommand = Command.make("screenshot", { name }, (config) =>
94
+ execute(() =>
95
+ send({
96
+ kind: "send",
97
+ name: Option.getOrUndefined(config.name),
98
+ commands: [{ operation: "ui.screenshot" }],
99
+ }),
100
+ ),
101
+ ).pipe(Command.withDescription("Take a screenshot and print its path"))
102
+
103
+ const startRecordingCommand = Command.make(
104
+ "record-start",
105
+ { name },
106
+ (config) =>
107
+ execute(() =>
108
+ send({
109
+ kind: "send",
110
+ name: Option.getOrUndefined(config.name),
111
+ commands: [{ operation: "ui.start-record" }],
112
+ }),
113
+ ),
114
+ ).pipe(Command.withDescription("Start recording the UI"))
115
+
116
+ const endRecordingCommand = Command.make(
117
+ "record-end",
118
+ { name },
119
+ (config) =>
120
+ execute(() =>
121
+ send({
122
+ kind: "send",
123
+ name: Option.getOrUndefined(config.name),
124
+ commands: [{ operation: "ui.end-record" }],
125
+ }),
126
+ ),
127
+ ).pipe(Command.withDescription("Stop recording and print its path"))
96
128
 
97
129
  const restartCommand = Command.make("restart", { name }, (config) =>
98
130
  execute(() => restart(Option.getOrUndefined(config.name))),
@@ -142,12 +174,14 @@ const root = Command.make("opencode-drive").pipe(
142
174
  Command.withSubcommands([
143
175
  startCommand,
144
176
  sendCommand,
177
+ screenshotCommand,
178
+ startRecordingCommand,
179
+ endRecordingCommand,
145
180
  listCommand,
146
181
  responsesCommand,
147
182
  logsCommand,
148
183
  restartCommand,
149
184
  stopCommand,
150
- apiCommand,
151
185
  ]),
152
186
  )
153
187
 
package/src/cli/api.ts DELETED
@@ -1,5 +0,0 @@
1
- import { resolve } from "node:path"
2
-
3
- export async function api() {
4
- process.stdout.write(await Bun.file(resolve(import.meta.dir, "..", "client", "protocol.types.ts")).text())
5
- }
@@ -1,62 +0,0 @@
1
- // CLI command contract for `opencode-drive send`.
2
-
3
- export type Json =
4
- null | boolean | number | string | Json[] | { [key: string]: Json }
5
-
6
- export type KeyModifiers = {
7
- ctrl?: boolean
8
- shift?: boolean
9
- meta?: boolean
10
- super?: boolean
11
- hyper?: boolean
12
- }
13
-
14
- export type Element = {
15
- id: string
16
- num: number
17
- x: number
18
- y: number
19
- width: number
20
- height: number
21
- focusable: boolean
22
- focused: boolean
23
- clickable: boolean
24
- editor: boolean
25
- }
26
-
27
- export type State = {
28
- focused: {
29
- renderable?: number
30
- editor: boolean
31
- }
32
- elements: Element[]
33
- }
34
-
35
- export type Command =
36
- | { name: "ui.type"; params: { text: string }; result: State }
37
- | {
38
- name: "ui.press"
39
- params: { key: string; modifiers?: KeyModifiers }
40
- result: State
41
- }
42
- | { name: "ui.enter"; result: State }
43
- | {
44
- name: "ui.arrow"
45
- params: { direction: "up" | "down" | "left" | "right" }
46
- result: State
47
- }
48
- | { name: "ui.focus"; params: { target: number }; result: State }
49
- | {
50
- name: "ui.click"
51
- params: { target: number; x: number; y: number }
52
- result: State
53
- }
54
- | { name: "ui.screenshot"; result: string }
55
- | { name: "ui.state"; result: State }
56
- | { name: "ui.start-record"; result: { recording: true } }
57
- | { name: "ui.end-record"; result: string }
58
-
59
- // Commands with `params` take one JSON argument:
60
- // --command.ui.type '{"text":"hello"}'
61
- // Commands without `params` are flags:
62
- // --command.ui.enter