@opencode-ai/util 0.0.0-dev-18636 → 0.0.0-dev-18650

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/dist/bom.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * as Bom from "./bom.js";
2
2
  import { Effect } from "effect";
3
- import { FSUtil } from "./fs-util.js";
3
+ import type { FSUtil } from "./fs-util.js";
4
4
  export declare function split(text: string): {
5
5
  bom: boolean;
6
6
  text: string;
package/dist/bom.js CHANGED
@@ -1,6 +1,5 @@
1
1
  export * as Bom from "./bom.js";
2
2
  import { Effect } from "effect";
3
- import { FSUtil } from "./fs-util.js";
4
3
  const code = 0xfeff;
5
4
  const value = String.fromCharCode(code);
6
5
  export function split(text) {
@@ -1,3 +1,4 @@
1
+ import { isArrayNonEmpty } from "effect/Array";
1
2
  import * as NodeSink from "@effect/platform-node/NodeSink";
2
3
  import * as NodeStream from "@effect/platform-node/NodeStream";
3
4
  import { Deferred, Effect, Exit, FileSystem, Layer, Path, PlatformError, Predicate, Sink, Stream } from "effect";
@@ -46,11 +47,10 @@ const flatten = (command) => {
46
47
  }
47
48
  };
48
49
  walk(command);
49
- if (commands.length === 0)
50
+ if (!isArrayNonEmpty(commands))
50
51
  throw new Error("flatten produced empty commands array");
51
- const [head, ...tail] = commands;
52
52
  return {
53
- commands: [head, ...tail],
53
+ commands,
54
54
  opts,
55
55
  };
56
56
  };
@@ -171,9 +171,10 @@ export var EffectFlock;
171
171
  // acquireRelease: acquire is uninterruptible, release is guaranteed
172
172
  const handle = yield* Effect.acquireRelease(acquireHandle(lockfile, key, { staleMs, timeoutMs }), (handle) => release(handle));
173
173
  // Heartbeat fiber — scoped, so it's interrupted before release runs
174
- yield* fs
175
- .utimes(handle.heartbeatPath, new Date(), new Date())
176
- .pipe(Effect.ignore, Effect.repeat(Schedule.spaced(Math.max(100, Math.floor(staleMs / 3)))), Effect.forkScoped);
174
+ yield* Effect.suspend(() => {
175
+ const now = new Date();
176
+ return fs.utimes(handle.heartbeatPath, now, now);
177
+ }).pipe(Effect.ignore, Effect.repeat(Schedule.spaced(Math.max(100, Math.floor(staleMs / 3)))), Effect.forkScoped);
177
178
  });
178
179
  const withLock = Function.dual((args) => Effect.isEffect(args[0]), (body, key, dir) => Effect.scoped(Effect.gen(function* () {
179
180
  yield* acquire(key, dir);
package/dist/process.js CHANGED
@@ -115,7 +115,7 @@ const layer = Layer.effect(Service, Effect.gen(function* () {
115
115
  const aborted = options?.signal
116
116
  ? timed.pipe(Effect.raceFirst(waitForAbort(options.signal).pipe(Effect.mapError((cause) => wrapError(description, cause)))))
117
117
  : timed;
118
- return aborted.pipe(Effect.catch((cause) => Effect.fail(wrapError(description, cause))));
118
+ return aborted.pipe(Effect.mapError((cause) => wrapError(description, cause)));
119
119
  };
120
120
  const run = Effect.fn("AppProcess.run")(function* (command, options) {
121
121
  if (options?.stdin === undefined)
@@ -137,9 +137,14 @@ const layer = Layer.effect(Service, Effect.gen(function* () {
137
137
  const okExitCodes = options?.okExitCodes;
138
138
  const built = Stream.unwrap(Effect.gen(function* () {
139
139
  const handle = yield* spawner.spawn(command);
140
- const stderrFiber = yield* Effect.forkScoped(collectStream(handle.stderr, options?.maxErrorBytes).pipe(Effect.map((x) => x.buffer.toString("utf8"))));
141
- const source = options?.includeStderr === true ? handle.all : handle.stdout;
142
- const lines = source.pipe(Stream.decodeText, Stream.splitLines, Stream.filter((line) => line.length > 0));
140
+ const streams = options?.includeStderr === true
141
+ ? yield* handle.stderr.pipe(Stream.broadcastN({ n: 2, capacity: 16 }), Effect.map((copies) => ({
142
+ source: Stream.merge(handle.stdout, copies[0]),
143
+ diagnostics: copies[1],
144
+ })))
145
+ : { source: handle.stdout, diagnostics: handle.stderr };
146
+ const stderrFiber = yield* Effect.forkScoped(collectStream(streams.diagnostics, options?.maxErrorBytes).pipe(Effect.map((x) => x.buffer.toString("utf8"))));
147
+ const lines = streams.source.pipe(Stream.decodeText, Stream.splitLines, Stream.filter((line) => line.length > 0));
143
148
  const tail = Stream.unwrap(Effect.gen(function* () {
144
149
  const code = yield* handle.exitCode;
145
150
  if (okExitCodes && okExitCodes.length > 0 && !okExitCodes.includes(code)) {
@@ -150,7 +155,7 @@ const layer = Layer.effect(Service, Effect.gen(function* () {
150
155
  }));
151
156
  return Stream.concat(lines, tail);
152
157
  }));
153
- const mapped = built.pipe(Stream.catch((cause) => Stream.fail(wrapError(description, cause))));
158
+ const mapped = built.pipe(Stream.mapError((cause) => wrapError(description, cause)));
154
159
  if (!options?.signal)
155
160
  return mapped;
156
161
  const signal = options.signal;
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-dev-18636",
4
+ "version": "0.0.0-dev-18650",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {