From 9a5f84db4e7b99550620d13d7163b59e8d6982f3 Mon Sep 17 00:00:00 2001 From: Victor Vogel Date: Mon, 23 Nov 2026 06:05:48 +0000 Subject: [PATCH] fix(cli): expand ~ paths in t3 thread --output-schema --- apps/server/src/cli/thread.test.ts | 16 ++++++++++++++++ apps/server/src/cli/thread.ts | 6 ++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/apps/server/src/cli/thread.test.ts b/apps/server/src/cli/thread.test.ts index bb0906a9c6919..3e38b6885e9d9 100644 --- a/apps/server/src/cli/thread.test.ts +++ b/apps/server/src/cli/thread.test.ts @@ -27,6 +27,7 @@ import { latestRunError, launchModelSelection, readLatestMessages, + readOutputSchema, resolveProject, threadCommand, type ThreadTools, @@ -524,6 +525,21 @@ it.effect("start rejects a repeated --option before reaching the server", () => ), ); +it.effect("--output-schema reads a ~/ path from the home directory", () => + Effect.gen(function* () { + const fs = yield* FileSystem.FileSystem; + const path = yield* Path.Path; + const home = yield* fs.makeTempDirectoryScoped({ prefix: "t3-thread-schema-" }); + yield* fs.writeFileString(path.join(home, "schema.json"), '{"type":"object"}'); + + const output = yield* readOutputSchema(Option.some("~/schema.json")).pipe( + Effect.provideService(HostProcess.HomeDirectory, home), + ); + + assert.deepStrictEqual(output, { outputSchema: { type: "object" } }); + }).pipe(Effect.provide(NodeServices.layer)), +); + /** Serves t3_thread_read pages the way the server does: positions count every item. */ const timelineTools = (types: ReadonlyArray) => { const items = types.map((type, position) => ({ position, itemId: `item-${position}`, type })); diff --git a/apps/server/src/cli/thread.ts b/apps/server/src/cli/thread.ts index 1d81dcc6bd7cb..f57f1eed163f4 100644 --- a/apps/server/src/cli/thread.ts +++ b/apps/server/src/cli/thread.ts @@ -846,14 +846,16 @@ const outputSchemaFlag = Flag.String("output-schema").pipe( const decodeOutputSchema = Schema.decodeUnknownEffect( Schema.fromJsonString(Schema.Record(Schema.String, Schema.Json)), ); -const readOutputSchema = Effect.fn("cli.thread.readOutputSchema")(function* ( +export const readOutputSchema = Effect.fn("cli.thread.readOutputSchema")(function* ( path: Option.Option, ) { if (Option.isNone(path)) return {}; const fileSystem = yield* FileSystem.FileSystem; const usage = () => new ThreadUsageError({ detail: `${path.value} does not hold a JSON Schema object.` }); - const text = yield* fileSystem.readFileString(path.value).pipe(Effect.mapError(usage)); + const text = yield* fileSystem + .readFileString(yield* expandHomePath(path.value)) + .pipe(Effect.mapError(usage)); return { outputSchema: yield* decodeOutputSchema(text).pipe(Effect.mapError(usage)) }; }); const messageArgument = Argument.String("message").pipe(