From f4fcb6cda90f0788b23f7e5da2b83dccfe91e2af Mon Sep 17 00:00:00 2001 From: lex Date: Sun, 9 Aug 2026 17:47:28 +0800 Subject: [PATCH] test(opencode): isolate memory in cli fixtures --- packages/opencode/test/lib/cli-process.ts | 24 +++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/opencode/test/lib/cli-process.ts b/packages/opencode/test/lib/cli-process.ts index f6f5b1e574..c295d761f5 100644 --- a/packages/opencode/test/lib/cli-process.ts +++ b/packages/opencode/test/lib/cli-process.ts @@ -201,6 +201,23 @@ export function withCliFixture( const configJson = JSON.stringify(testProviderConfig(llm.url)) const env = isolatedEnv(home, configJson) + const memoryConfigDir = path.join(home, ".config/opencode") + yield* fs.makeDirectory(memoryConfigDir, { recursive: true }) + // CLI tests own the provider response queue, while dedicated MEMORY tests + // cover first-run model selection. Seed a valid global config so unrelated + // background initialization cannot consume a CLI test's prompt response. + yield* fs.writeFileString( + path.join(memoryConfigDir, "memory.jsonc"), + JSON.stringify({ + schema_version: 1, + enabled: true, + model: testModelID, + topic_limit: 10, + topic_limit_floor: 10, + turn_interval: 5, + injection: { max_topics: 3, max_tokens: 1_200 }, + }), + ) const spawn = Effect.fn("opencode.spawn")(function* (args: string[], opts?: SpawnOpts) { const start = Date.now() @@ -532,10 +549,5 @@ export const cliIt = { name: string, body: (input: CliFixture) => Effect.Effect, opts?: number | TestOptions, - ) => - test( - name, - () => Effect.runPromise(Effect.scoped(withCliFixture(body))), - opts, - ), + ) => test(name, () => Effect.runPromise(Effect.scoped(withCliFixture(body))), opts), }