Files
Kilo-Org_kilocode/packages/opencode/test/fixture/log-init-worker.ts
T
Mark IJbema 5d5fab36bb fix(cli): repair broken imports and typecheck after opencode v1.14.29 merge
Fixes 257 typecheck errors surfaced after the upstream merge:

- Update imports to new module paths after upstream PR #24554 removed
  module barrel files (@/config, @/session, @/util, etc.) and PR #24309
  renamed @opencode-ai/shared to @opencode-ai/core.
- Migrate loadMode to use Info.zod.safeParse for consistency with
  loadAgents and ConfigCommand (unblocks KilocodeConfig.handleInvalid).
- Drop removed Npm.outdated mock from tests.
- Add missing Config.defaultLayer to bash-permission-metadata test runtime.
- Fix Tips component signature (kilocode drops upstream's 'connected' prop).
- Fix toast.tsx undefined 'duration' reference (should be toastOptions.duration).
- Move filesystem-containment test from deleted shared package to core.
2026-04-30 17:16:31 +02:00

64 lines
1.4 KiB
TypeScript

// kilocode_change - new file
import fs from "fs/promises"
import path from "path"
const dir = process.argv[2]
const mode = process.argv[3]
if (!dir) {
throw new Error("missing temp dir")
}
process.env.XDG_DATA_HOME = path.join(dir, "share")
process.env.XDG_CACHE_HOME = path.join(dir, "cache")
process.env.XDG_CONFIG_HOME = path.join(dir, "config")
process.env.XDG_STATE_HOME = path.join(dir, "state")
process.env.KILO_TEST_HOME = path.join(dir, "home")
const Log = await import("@opencode-ai/core/util/log")
async function bytes(file: string) {
return fs
.stat(file)
.then((stat) => stat.size)
.catch(() => 0)
}
async function wait(file: string, need: number) {
for (let i = 0; i < 500; i++) {
if ((await bytes(file)) >= need) return
await Bun.sleep(10)
}
throw new Error(`log file did not reach ${need} bytes before missing-file test`)
}
await Log.init({
print: false,
dev: true,
level: "DEBUG",
})
const log = Log.create({ service: "test" })
const msg = "x".repeat(1024 * 1024)
const first = mode === "missing" ? 10 : 55
await fs.mkdir(path.join(dir, "share", "kilo", "log"), { recursive: true })
for (const _ of Array.from({ length: first })) {
log.info(msg)
}
if (mode === "missing") {
await wait(Log.file(), first * msg.length)
await fs.unlink(Log.file())
for (const _ of Array.from({ length: 45 })) {
log.info(msg)
}
}
await Bun.sleep(300)
process.stdout.write(Log.file())