Skip to content

Commit a82afea

Browse files
fix(cli): t3 pair's protocol mismatch hint keeps --base-dir
The matching-version command dropped an explicit --base-dir, so running it as printed searched the default T3 home. Append the selected home, quoted for the host shell, like the no-running-server hint already does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 00ca2d4 commit a82afea

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

‎apps/server/src/cli/invocation.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ const powershellWord = (value: string) =>
145145
.replaceAll("$", "`$")
146146
.replace(/["\u201C\u201D\u201E]/g, "$&$&")}"`;
147147

148-
const hostShellWord = (platform: NodeJS.Platform, value: string) =>
148+
export const hostShellWord = (platform: NodeJS.Platform, value: string) =>
149149
platform === "win32" ? powershellWord(value) : shellWord(value);
150150

151151
/** Script installs have no single launcher; desktop shims and standalone binaries do. */

‎apps/server/src/cli/pair.ts‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import {
4848
} from "../startupAccess.ts";
4949
import { authScopesFlag } from "./authScopes.ts";
5050
import { baseDirFlag, DurationFromString } from "./config.ts";
51-
import { resolveHostCliCommand } from "./invocation.ts";
51+
import { hostShellWord, resolveHostCliCommand } from "./invocation.ts";
5252

5353
const WELL_KNOWN_ENVIRONMENT_PATH = "/.well-known/t3/environment";
5454
const PAIR_PROBE_TIMEOUT = Duration.millis(2_500);
@@ -84,12 +84,16 @@ export class NoRunningServerError extends Schema.TaggedError<NoRunningServerErro
8484

8585
export class IncompatibleServerProtocolError extends Schema.TaggedError<IncompatibleServerProtocolError>()(
8686
"IncompatibleServerProtocolError",
87-
{ serverVersion: Schema.String, serverProtocolVersion: Schema.Number },
87+
{
88+
serverVersion: Schema.String,
89+
serverProtocolVersion: Schema.Number,
90+
pairCommand: Schema.String,
91+
},
8892
) {
8993
override get message(): string {
9094
return [
9195
`The running T3 Code server (${this.serverVersion}) speaks orchestration protocol ${String(this.serverProtocolVersion)}, but this CLI speaks protocol ${String(ORCHESTRATION_PROTOCOL_VERSION)}.`,
92-
`Pair with the matching CLI instead: \`npx t3@${this.serverVersion} pair\`.`,
96+
`Pair with the matching CLI instead: \`${this.pairCommand}\`.`,
9397
].join("\n");
9498
}
9599
}
@@ -521,15 +525,22 @@ export const pairCommand = Command.make("pair", {
521525
const cliLogLevel = yield* GlobalFlag.LogLevel;
522526
const logLevel = Option.getOrElse(cliLogLevel, () => "Warn" as const);
523527

524-
const target = yield* discoverPairTarget(Option.getOrUndefined(flags.baseDir));
528+
const explicitBaseDir = Option.getOrUndefined(flags.baseDir);
529+
const target = yield* discoverPairTarget(explicitBaseDir);
525530
// Each protocol keeps auth in its own database, so a token minted here
526531
// for another protocol's server would never be accepted by it. Refuse
527532
// before any local layer opens (and migrates) that database.
528533
const serverProtocolVersion = target.descriptor.orchestrationProtocolVersion ?? 1;
529534
if (serverProtocolVersion !== ORCHESTRATION_PROTOCOL_VERSION) {
535+
const platform = yield* HostProcess.Platform;
536+
const baseDirArgs =
537+
explicitBaseDir !== undefined && explicitBaseDir.trim().length > 0
538+
? ` --base-dir ${hostShellWord(platform, explicitBaseDir)}`
539+
: "";
530540
return yield* new IncompatibleServerProtocolError({
531541
serverVersion: target.descriptor.serverVersion,
532542
serverProtocolVersion,
543+
pairCommand: `npx t3@${target.descriptor.serverVersion} pair${baseDirArgs}`,
533544
});
534545
}
535546

0 commit comments

Comments
 (0)