feat(client): self-contained local service discovery and lifecycle

This commit is contained in:
Dax Raad 2026-07-03 01:19:43 -04:00
commit 1de3c6e4a6
27 changed files with 535 additions and 480 deletions

View file

@ -5,23 +5,19 @@ import { Effect } from "effect"
import fs from "node:fs/promises"
import os from "node:os"
import path from "node:path"
import { Daemon } from "../src/services/daemon"
import { Service } from "../src/services/service"
test("local channel stores service config with the local service filename", async () => {
const root = await fs.mkdtemp(path.join(os.tmpdir(), "opencode-daemon-"))
const root = await fs.mkdtemp(path.join(os.tmpdir(), "opencode-service-"))
try {
await Effect.runPromise(
Effect.gen(function* () {
const daemon = yield* Daemon.Service
yield* daemon.set("autostart", "false")
}).pipe(
Effect.provide(Daemon.layer),
Service.set("hostname", "127.0.0.2").pipe(
Effect.provide(Global.layerWith({ config: path.join(root, "config"), state: path.join(root, "state") })),
Effect.provide(NodeFileSystem.layer),
),
)
expect(await Bun.file(path.join(root, "config", "service-local.json")).json()).toEqual({
autostart: false,
hostname: "127.0.0.2",
})
expect(await Bun.file(path.join(root, "config", "service.json")).exists()).toBe(false)
} finally {