@opencode-ai/util 0.0.0-next-17317 → 0.0.0-next-17330

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.
@@ -1,4 +1,7 @@
1
- import { NodeFileSystem, NodePath, NodeSink, NodeStream } from "@effect/platform-node";
1
+ import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
2
+ import * as NodePath from "@effect/platform-node/NodePath";
3
+ import * as NodeSink from "@effect/platform-node/NodeSink";
4
+ import * as NodeStream from "@effect/platform-node/NodeStream";
2
5
  import { Deferred, Effect, Exit, FileSystem, Layer, Path, PlatformError, Predicate, Sink, Stream } from "effect";
3
6
  import { ChildProcess } from "effect/unstable/process";
4
7
  import { ChildProcessSpawner, ExitCode, make, makeHandle, ProcessId, } from "effect/unstable/process/ChildProcessSpawner";
@@ -1,4 +1,7 @@
1
- import { NodeFileSystem, NodePath } from "@effect/platform-node";
1
+ // Deep imports: the @effect/platform-node barrel eagerly pulls in undici,
2
+ // ioredis, and node:sqlite, which runtimes such as workerd cannot load.
3
+ import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
4
+ import * as NodePath from "@effect/platform-node/NodePath";
2
5
  import { FileSystem, Path } from "effect";
3
6
  import { FetchHttpClient, HttpClient } from "effect/unstable/http";
4
7
  import { makeGlobalNode } from "./app-node.js";
package/dist/fs-util.js CHANGED
@@ -1,4 +1,4 @@
1
- import { NodeFileSystem } from "@effect/platform-node";
1
+ import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
2
2
  import path, { dirname, isAbsolute, join, relative, sep } from "path";
3
3
  import { realpathSync } from "fs";
4
4
  import { readdir } from "fs/promises";
@@ -0,0 +1,8 @@
1
+ /** The XDG base directories that root opencode's global paths. */
2
+ export declare function roots(app: string): {
3
+ data: string;
4
+ cache: string;
5
+ config: string;
6
+ state: string;
7
+ tmp: string;
8
+ };
@@ -0,0 +1,13 @@
1
+ import os from "os";
2
+ import path from "path";
3
+ import { xdgCache, xdgConfig, xdgData, xdgState } from "xdg-basedir";
4
+ /** The XDG base directories that root opencode's global paths. */
5
+ export function roots(app) {
6
+ return {
7
+ data: path.join(xdgData, app),
8
+ cache: path.join(xdgCache, app),
9
+ config: path.join(xdgConfig, app),
10
+ state: path.join(xdgState, app),
11
+ tmp: path.join(os.tmpdir(), app),
12
+ };
13
+ }
@@ -0,0 +1,7 @@
1
+ export declare function roots(app: string): {
2
+ data: string;
3
+ cache: string;
4
+ config: string;
5
+ state: string;
6
+ tmp: string;
7
+ };
@@ -0,0 +1,15 @@
1
+ import os from "os";
2
+ import path from "path";
3
+ // workerd has no home directory or XDG base dirs and only tmp is writable, so
4
+ // every global path roots under one directory there. Nothing durable lives in
5
+ // these: on workerd the database is on Durable Object storage.
6
+ export function roots(app) {
7
+ const root = path.join(os.tmpdir(), app);
8
+ return {
9
+ data: path.join(root, "data"),
10
+ cache: path.join(root, "cache"),
11
+ config: path.join(root, "config"),
12
+ state: path.join(root, "state"),
13
+ tmp: path.join(root, "tmp"),
14
+ };
15
+ }
package/dist/global.js CHANGED
@@ -1,16 +1,15 @@
1
1
  import path from "path";
2
2
  import fs from "fs";
3
- import { xdgData, xdgCache, xdgConfig, xdgState } from "xdg-basedir";
4
3
  import os from "os";
5
4
  import { Context, Effect, Layer } from "effect";
5
+ // XDG on runtimes with a home directory; one tmp-rooted directory on workerd.
6
+ // The variants resolve through the `workerd` bundle condition, like the
7
+ // native-module stubs, so no runtime sniffing happens here.
8
+ import { roots } from "#global-roots";
6
9
  import { Flock } from "./flock.js";
7
10
  import { makeGlobalNode } from "./effect/app-node.js";
8
11
  const app = "opencode";
9
- const data = path.join(xdgData, app);
10
- const cache = path.join(xdgCache, app);
11
- const config = path.join(xdgConfig, app);
12
- const state = path.join(xdgState, app);
13
- const tmp = path.join(os.tmpdir(), app);
12
+ const { data, cache, config, state, tmp } = roots(app);
14
13
  const paths = {
15
14
  get home() {
16
15
  return process.env.OPENCODE_TEST_HOME ?? os.homedir();
package/dist/npm.js CHANGED
@@ -2,7 +2,7 @@ export * as Npm from "./npm.js";
2
2
  import path from "path";
3
3
  import npa from "npm-package-arg";
4
4
  import { Effect, Schema, Context, Layer, Option, FileSystem } from "effect";
5
- import { NodeFileSystem } from "@effect/platform-node";
5
+ import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
6
6
  import { FSUtil } from "./fs-util.js";
7
7
  import { Global } from "./global.js";
8
8
  import { EffectFlock } from "./effect-flock.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode-ai/util",
4
- "version": "0.0.0-next-17317",
4
+ "version": "0.0.0-next-17330",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -26,7 +26,12 @@
26
26
  }
27
27
  },
28
28
  "imports": {
29
+ "#global-roots": {
30
+ "workerd": "./dist/global-roots.workerd.js",
31
+ "default": "./dist/global-roots.js"
32
+ },
29
33
  "#runtime-import": {
34
+ "workerd": "./dist/runtime/import.bun.js",
30
35
  "bun": "./dist/runtime/import.bun.js",
31
36
  "node": "./dist/runtime/import.node.js",
32
37
  "default": "./dist/runtime/import.bun.js"