GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(core): run local Windows shell commands in the process daemon (#… · drpr/opencode@63dd3f1

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • bun.lock
  • packages
    • cli
      • package.json
    • core
      • package.json
      • src
        • shell.ts
      • test
        • persistent-pty-session.test.ts
        • session-execution.test.ts
        • shell-daemon.test.ts
        • shell-restart.test.ts
        • tool-shell.test.ts
    • server
      • package.json
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎bun.lock‎

Copy file name to clipboardExpand all lines: bun.lock
+12-12Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎packages/cli/package.json‎

Copy file name to clipboardExpand all lines: packages/cli/package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"@effect/platform-node": "catalog:",
3333
"@opencode/client": "workspace:*",
3434
"@opencode/plugin": "workspace:*",
35-
"@opencode/pty": "0.5.0",
35+
"@opencode/pty": "0.5.2",
3636
"@opencode/schema": "workspace:*",
3737
"@opencode/server": "workspace:*",
3838
"@opencode/tui": "workspace:*",
Collapse file

‎packages/core/package.json‎

Copy file name to clipboardExpand all lines: packages/core/package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"@modelcontextprotocol/client": "2.4.0",
105105
"@modelcontextprotocol/core": "2.4.0",
106106
"@modelcontextprotocol/server": "2.4.0",
107-
"@opencode/pty": "0.5.0",
107+
"@opencode/pty": "0.5.2",
108108
"@opencode/ai": "workspace:*",
109109
"@opencode/codemode": "workspace:*",
110110
"@opencode/plugin": "workspace:*",
Collapse file

‎packages/core/src/shell.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/shell.ts
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ type Ended = {
141141
* here; callers (e.g. `ShellTool`) own that association and store the shell ID.
142142
*
143143
* Local commands run in the process daemon when it is available (`Daemon`), so they outlive a planned server
144-
* restart: the next server takes them back. Remote workspaces, Windows and an unavailable daemon keep spawning
145-
* them from the server.
144+
* restart: the next server takes them back. Remote workspaces and an unavailable daemon keep spawning them from
145+
* the server.
146146
*/
147147
export interface Interface {
148148
readonly create: <E = never, R = never>(
@@ -615,12 +615,9 @@ const layer = () =>
615615
// Commands this server spawned for the Location; daemon commands live in `runs`, owned by the server.
616616
const commands = new Map<Shell.ID, Spawned>()
617617
const exitOrder: Shell.ID[] = []
618-
// Remote workspaces and Windows keep spawning commands from the server. Taken back before the service is
619-
// returned, so session restart recovery sees them.
618+
// Take local commands back before returning the service so session restart recovery sees them.
620619
const runs =
621-
location.workspaceID === undefined && process.platform !== "win32" && PersistentPty.available
622-
? yield* daemon.at(location)
623-
: undefined
620+
location.workspaceID === undefined && PersistentPty.available ? yield* daemon.at(location) : undefined
624621

625622
const outputDir = path.join(global.data, DIRECTORY, location.project.id)
626623
const { mkdir, unlink, stat } = yield* Effect.promise(() => import("fs/promises"))
Collapse file

‎packages/core/test/persistent-pty-session.test.ts‎

Copy file name to clipboardExpand all lines: packages/core/test/persistent-pty-session.test.ts
+25-31Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { describe, expect } from "bun:test"
2+
import path from "node:path"
23
import { Effect, Fiber, Layer, Option, Stream } from "effect"
34
import { AppNodeBuilder } from "@opencode/core/effect/app-node-builder"
45
import { LayerNode } from "@opencode/util/effect/layer-node"
@@ -110,25 +111,24 @@ describe("PersistentPty rename", () => {
110111
)
111112
})
112113

113-
// Pipe mode is Unix-only: Windows daemons reject create_pipe, so OpenCode keeps spawning shell commands there.
114-
describe.skipIf(process.platform === "win32")("PersistentPty pipe processes", () => {
115-
const input = {
116-
program: "/bin/sh",
117-
args: ["-c", "echo hi"],
118-
cwd: "/tmp",
119-
env: { PATH: "/usr/bin" },
120-
groupID: "proj_test",
121-
outputPath: "/tmp/sh_test.out",
122-
metadata: { id: "sh_test", command: "echo hi" },
123-
}
114+
const pipeInput = (cwd: string) => ({
115+
program: process.execPath,
116+
args: ["--version"],
117+
cwd,
118+
env: { TEST: "1" },
119+
groupID: "proj_test",
120+
outputPath: path.join(cwd, "sh_test.out"),
121+
metadata: { id: "sh_test", command: "--version" },
122+
})
124123

124+
describe("PersistentPty pipe processes", () => {
125125
it.live("knows a handoff is prepared until a shutdown or until its ticket expires", () =>
126126
Effect.gen(function* () {
127127
const daemon = yield* fakeDaemon()
128128
yield* Effect.gen(function* () {
129129
const pty = yield* PersistentPty.Service
130130
expect(pty.handoffPrepared()).toBe(false)
131-
yield* pty.createPipe(input)
131+
yield* pty.createPipe(pipeInput(daemon.options.root))
132132
expect(yield* pty.handoff()).not.toBeNull()
133133
expect(pty.handoffPrepared()).toBe(true)
134134
// Abandoned by a shutdown.
@@ -141,7 +141,7 @@ describe.skipIf(process.platform === "win32")("PersistentPty pipe processes", ()
141141
expiring.handoffTTL.ms = 50
142142
yield* Effect.gen(function* () {
143143
const pty = yield* PersistentPty.Service
144-
yield* pty.createPipe(input)
144+
yield* pty.createPipe(pipeInput(expiring.options.root))
145145
expect(yield* pty.handoff()).not.toBeNull()
146146
expect(pty.handoffPrepared()).toBe(true)
147147
yield* Effect.sleep(80)
@@ -155,20 +155,21 @@ describe.skipIf(process.platform === "win32")("PersistentPty pipe processes", ()
155155
const daemon = yield* fakeDaemon()
156156
yield* Effect.gen(function* () {
157157
const pty = yield* PersistentPty.Service
158+
const input = pipeInput(daemon.options.root)
158159
const created = yield* pty.createPipe(input)
159160
expect(daemon.requests.at(-1)).toEqual({
160161
op: "create_pipe",
161-
program: "/bin/sh",
162-
args: ["-c", "echo hi"],
163-
cwd: "/tmp",
164-
env: { PATH: "/usr/bin" },
162+
program: input.program,
163+
args: input.args,
164+
cwd: input.cwd,
165+
env: input.env,
165166
group_id: "proj_test",
166-
output_path: "/tmp/sh_test.out",
167-
metadata: { id: "sh_test", command: "echo hi" },
167+
output_path: input.outputPath,
168+
metadata: input.metadata,
168169
})
169170
expect(created).toMatchObject({
170171
groupID: "proj_test",
171-
outputPath: "/tmp/sh_test.out",
172+
outputPath: input.outputPath,
172173
lifecycle: { status: "running" },
173174
metadata: input.metadata,
174175
exitedAt: undefined,
@@ -210,7 +211,7 @@ describe.skipIf(process.platform === "win32")("PersistentPty pipe processes", ()
210211
title: "test",
211212
env: {},
212213
})
213-
const pipe = yield* pty.createPipe(input)
214+
const pipe = yield* pty.createPipe(pipeInput(directory.path))
214215

215216
expect((yield* pty.list()).map((item) => item.id)).toEqual([terminal.id])
216217
expect((yield* pty.listPipes()).map((item) => item.id)).toEqual([pipe.id])
@@ -225,6 +226,7 @@ describe.skipIf(process.platform === "win32")("PersistentPty pipe processes", ()
225226
const daemon = yield* fakeDaemon()
226227
yield* Effect.gen(function* () {
227228
const pty = yield* PersistentPty.Service
229+
const input = pipeInput(daemon.options.root)
228230
expect(yield* Effect.flip(pty.createPipe({ ...input, cwd: "relative" }))).toEqual(
229231
new PersistentPty.RequestError({ message: "cwd must be absolute" }),
230232
)
@@ -278,21 +280,13 @@ const layer = (daemon: { readonly options: PersistentPty.Options }) =>
278280
],
279281
)
280282

281-
describe.skipIf(process.platform === "win32")("PersistentPty handoff", () => {
283+
describe("PersistentPty handoff", () => {
282284
it.live("prepares a handoff more than once on the same owner connection", () =>
283285
Effect.gen(function* () {
284286
const daemon = yield* fakeDaemon()
285287
yield* Effect.gen(function* () {
286288
const pty = yield* PersistentPty.Service
287-
yield* pty.createPipe({
288-
program: "/bin/sh",
289-
args: ["-c", "echo hi"],
290-
cwd: "/tmp",
291-
env: {},
292-
groupID: "proj_test",
293-
outputPath: "/tmp/sh_handoff.out",
294-
metadata: {},
295-
})
289+
yield* pty.createPipe(pipeInput(daemon.options.root))
296290
expect(yield* pty.handoff()).toMatchObject({ ticket: "next" })
297291
expect(yield* pty.handoff()).toMatchObject({ ticket: "next" })
298292
}).pipe(Effect.provide(layer(daemon)))
Collapse file

‎packages/core/test/session-execution.test.ts‎

Copy file name to clipboardExpand all lines: packages/core/test/session-execution.test.ts
+5-8Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,6 @@ describe("SessionExecution lifecycle", () => {
438438
)
439439
})
440440

441-
// Shell commands only run in the process daemon off Windows (pipe mode is Unix-only), so the daemon shell cases skip there.
442-
const daemonLive = process.platform === "win32" ? it.live.skip : it.live
443-
444441
describe("SessionRestart background recovery", () => {
445442
it.effect("keeps shell owners idle until a user prompt delivers recovered notices exactly once", () =>
446443
Effect.gen(function* () {
@@ -530,7 +527,7 @@ describe("SessionRestart background recovery", () => {
530527
}),
531528
)
532529

533-
daemonLive("counts a suspended parent's restart attempt before its shell-woken child can wake it", () =>
530+
it.live("counts a suspended parent's restart attempt before its shell-woken child can wake it", () =>
534531
Effect.gen(function* () {
535532
const db = yield* Database.Service
536533
const jobs = yield* Job.Service
@@ -608,7 +605,7 @@ describe("SessionRestart background recovery", () => {
608605
}),
609606
)
610607

611-
daemonLive("watches shell jobs whose commands survived the restart", () =>
608+
it.live("watches shell jobs whose commands survived the restart", () =>
612609
Effect.gen(function* () {
613610
const database = yield* Database.Service
614611
const store = yield* SessionStore.Service
@@ -670,7 +667,7 @@ describe("SessionRestart background recovery", () => {
670667
}),
671668
)
672669

673-
daemonLive("settles a shell call a killed server left running as moved to the background", () =>
670+
it.live("settles a shell call a killed server left running as moved to the background", () =>
674671
Effect.gen(function* () {
675672
const database = yield* Database.Service
676673
const store = yield* SessionStore.Service
@@ -757,7 +754,7 @@ describe("SessionRestart background recovery", () => {
757754
)
758755

759756
for (const exited of [false, true])
760-
daemonLive(
757+
it.live(
761758
`reattaches once a ${exited ? "finished" : "running"} shell a killed server backgrounded without settling its call`,
762759
() =>
763760
Effect.gen(function* () {
@@ -818,7 +815,7 @@ describe("SessionRestart background recovery", () => {
818815
}),
819816
)
820817

821-
daemonLive("settles a recovered child's unsettled shell call before the child resumes", () =>
818+
it.live("settles a recovered child's unsettled shell call before the child resumes", () =>
822819
Effect.gen(function* () {
823820
const database = yield* Database.Service
824821
const store = yield* SessionStore.Service

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.