mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
Merge pull request #11913 from Kilo-Org/understood-meerkat
fix(cli): retain shell output for fast-exiting commands
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Effect, Stream } from "effect"
|
||||
import { Effect, Fiber, Stream } from "effect" // kilocode_change - Fiber
|
||||
import os from "os"
|
||||
import { createWriteStream } from "node:fs"
|
||||
import * as Tool from "./tool"
|
||||
@@ -548,7 +548,7 @@ export const ShellTool = Tool.define(
|
||||
yield* Effect.addFinalizer(closeSink)
|
||||
const handle = yield* spawner.spawn(cmd(input.shell, input.command, input.cwd, input.env))
|
||||
|
||||
yield* Effect.forkScoped(
|
||||
const reader = yield* Effect.forkScoped( // kilocode_change - keep the fiber so trailing output can be drained
|
||||
Stream.runForEach(Stream.decodeText(handle.all), (chunk) => {
|
||||
const size = Buffer.byteLength(chunk, "utf-8")
|
||||
list.push({ text: chunk, size })
|
||||
@@ -621,6 +621,12 @@ export const ShellTool = Tool.define(
|
||||
yield* handle.kill({ forceKillAfter: "3 seconds" }).pipe(Effect.orDie)
|
||||
}
|
||||
|
||||
// kilocode_change start - closing the scope interrupts the reader fiber, which can drop
|
||||
// buffered output that arrived just before the process exited. Wait for the stream to
|
||||
// finish (it ends once stdio closes) so fast commands do not lose their final chunks.
|
||||
yield* Fiber.await(reader).pipe(Effect.timeout("3 seconds"), Effect.ignore)
|
||||
// kilocode_change end
|
||||
|
||||
return exit.kind === "exit" ? exit.code : null
|
||||
}),
|
||||
).pipe(Effect.orDie)
|
||||
|
||||
Reference in New Issue
Block a user