fix(cli): stop doubling the log directory in rotating-file-stream history path

On every kilo CLI startup the process writes an error like:

    log stream error: ENOENT: no such file or directory, open
    '<log-dir>/<log-dir>/.log-history'

Log rotation is effectively disabled because rotating-file-stream cannot
open its history file.

Root cause: rotating-file-stream (3.2.x) treats the `history` option as
a filename resolved against the `path` option. In
`packages/opencode/src/util/log.ts` we were passing an absolute path
(`path.join(dir, '.log-history')`) for `history` while also setting
`path: dir`, so the library concatenated the two and produced the
`<dir>/<dir>/.log-history` path that ENOENTs.

Passing the relative filename `.log-history` lets the library resolve
the history file under the configured `path` directory, matches the
docs, and restores the 50 MB / 10-file rotation cap.

Fixes #8252
Fixes #8275
Fixes #9321
This commit is contained in:
Vishal Kumar Singh
2026-04-23 13:07:01 +05:30
parent 74df868527
commit 03a1285c69
+1 -1
View File
@@ -71,7 +71,7 @@ export async function init(options: Options) {
const stream = createStream(path.basename(logpath), {
size: "50M",
maxFiles: 10,
history: path.join(dir, ".log-history"),
history: ".log-history",
path: dir,
})
stream.on("error", (err: Error) => {