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

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,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
  };
package/dist/process.js CHANGED
@@ -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)) {
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-18639",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {