Skip to content

Commit 343cb3b

Browse files
fix(server): Claude launch-arg file paths expand ~
`--settings ~/.claude/settings.json` and `--append-system-prompt-file ~/...` were resolved against the project cwd, so they read `<project>/~/...`. Expand a leading `~` with the existing expandHomePath and HostProcess.HomeDirectory before resolving, matching binaryPath. Relative paths still resolve against the cwd; absolute paths and inline JSON are unchanged. Fixes #26631 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 5ecb8f6 commit 343cb3b

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,9 +1599,9 @@ export function makeClaudeQueryOptions(input: {
15991599

16001600
/**
16011601
* Checks the append launch arguments the way the Claude CLI would and reads
1602-
* the file relative to the process cwd. makeClaudeQueryOptions folds these
1603-
* flags out of extraArgs, so a value the CLI would have rejected has to be
1604-
* rejected here or it silently disappears.
1602+
* the file relative to the process cwd, expanding a leading ~.
1603+
* makeClaudeQueryOptions folds these flags out of extraArgs, so a value the CLI
1604+
* would have rejected has to be rejected here or it silently disappears.
16051605
*/
16061606
const readClaudeAppendSystemPromptFile = Effect.fnUntraced(function* (input: {
16071607
readonly settings: ClaudeSettings | undefined;
@@ -1626,7 +1626,10 @@ const readClaudeAppendSystemPromptFile = Effect.fnUntraced(function* (input: {
16261626
flag: "--append-system-prompt-file",
16271627
});
16281628
}
1629-
const filePath = input.path.resolve(input.cwd ?? ".", file);
1629+
const filePath = input.path.resolve(
1630+
input.cwd ?? ".",
1631+
expandHomePath(file, yield* HostProcess.HomeDirectory),
1632+
);
16301633
return yield* input.fileSystem
16311634
.readFileString(filePath)
16321635
.pipe(
@@ -1640,8 +1643,8 @@ const decodeClaudeLaunchArgSettings = Schema.decodeUnknownEffect(
16401643

16411644
/**
16421645
* Reads the --settings launch argument: a value starting with a brace is inline
1643-
* JSON, anything else is a file path relative to the cwd. makeClaudeQueryOptions
1644-
* merges the result beneath T3's own settings.
1646+
* JSON, anything else is a file path relative to the cwd, expanding a leading ~.
1647+
* makeClaudeQueryOptions merges the result beneath T3's own settings.
16451648
*/
16461649
const readClaudeLaunchArgSettings = Effect.fn("ClaudeAdapterV2.readLaunchArgSettings")(
16471650
function* (input: {
@@ -1662,7 +1665,10 @@ const readClaudeLaunchArgSettings = Effect.fn("ClaudeAdapterV2.readLaunchArgSett
16621665
Effect.mapError((cause) => new ClaudeSettingsLaunchArgError({ cause })),
16631666
)) as ClaudeSdkSettings;
16641667
}
1665-
const filePath = input.path.resolve(input.cwd ?? ".", trimmed);
1668+
const filePath = input.path.resolve(
1669+
input.cwd ?? ".",
1670+
expandHomePath(trimmed, yield* HostProcess.HomeDirectory),
1671+
);
16661672
return (yield* input.fileSystem.readFileString(filePath).pipe(
16671673
Effect.flatMap(decodeClaudeLaunchArgSettings),
16681674
Effect.mapError((cause) => new ClaudeSettingsLaunchArgError({ path: filePath, cause })),

0 commit comments

Comments
 (0)