Skip to content

Commit 89f433b

Browse files
committed
test(provider-core): verify Chocolatey Claude update boundaries
1 parent a2f7c6f commit 89f433b

3 files changed

Lines changed: 24 additions & 21 deletions

File tree

‎packages/provider-core/src/server/maintenance.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ export interface ProviderMaintenanceCapabilities {
1515
readonly compareVersions?: (current: string, latest: string) => number;
1616
/** Resolved executable path for advisories when no update command is proven. */
1717
readonly installPath?: string;
18-
/**
19-
* A command T3 Code shows but cannot run.
20-
*/
18+
/** Displayed for manual updates; never executed by T3 Code. */
2119
readonly manualCommand?: string;
2220
}
2321

‎packages/provider-core/src/server/maintenanceResolver.test.ts‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,13 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
498498
real: "D:\\Tools\\Choco\\lib\\claude-code\\tools\\claude.exe",
499499
env: { ChocolateyInstall: "D:\\Tools\\Choco" },
500500
},
501+
{
502+
name: "a mixed-case custom root with a trailing separator",
503+
resolved: "D:\\Tools\\Choco\\bin\\Claude.EXE",
504+
real: "D:\\Tools\\Choco\\bin\\Claude.EXE",
505+
env: { ChocolateyInstall: "d:/tools/choco/" },
506+
},
507+
{ name: "a native-looking alias", resolved: nativeClaude, real: chocolateyPackage },
501508
] as const)("keeps a Chocolatey Claude install manual-only through $name", (fixture) =>
502509
Effect.gen(function* () {
503510
const capabilities = yield* resolveInstall({ definition: claudeUpdate, ...fixture });
@@ -528,7 +535,7 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
528535
// report an update `choco upgrade` cannot install yet.
529536
it.effect("compares a Chocolatey Claude install against choco search", () =>
530537
Effect.gen(function* () {
531-
const probes: Array<string> = [];
538+
const probes: Array<{ command: string; args: ReadonlyArray<string> }> = [];
532539
const capabilities = yield* resolvePackageManagedProviderMaintenance(claudeUpdate, {
533540
binaryPath: "claude",
534541
resolvedCommandPath: chocolateyShim,
@@ -539,8 +546,8 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
539546
Effect.provideService(HostProcess.Platform, "win32"),
540547
Effect.provideService(
541548
ChildProcessSpawner.ChildProcessSpawner,
542-
stdoutSpawner((command) => {
543-
probes.push(command);
549+
stdoutSpawner((command, args) => {
550+
probes.push({ command, args });
544551
return "claude-code|2.1.304\r\n";
545552
}),
546553
),
@@ -556,9 +563,18 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
556563
);
557564

558565
expect(latest).toBe("2.1.304");
559-
expect(probes.map((command) => NodePath.basename(command).replace(/\.\w+$/, ""))).toEqual([
560-
"choco",
561-
]);
566+
expect(probes.map(({ command }) => NodePath.basename(command).replace(/\.\w+$/, ""))).toEqual(
567+
["choco"],
568+
);
569+
expect(probes[0]?.args).toEqual(["search", "claude-code", "--exact", "--limit-output"]);
570+
expect(
571+
createProviderVersionAdvisory({
572+
driver: driver("claudeAgent"),
573+
currentVersion: "2.1.304",
574+
latestVersion: latest,
575+
maintenanceCapabilities: capabilities,
576+
}),
577+
).toMatchObject({ status: "current", canUpdate: false, canInstallVersion: false });
562578
}).pipe(Effect.provide(NodeServices.layer)),
563579
);
564580

‎packages/provider-core/src/server/maintenanceResolver.ts‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,6 @@ export function makeManualOnlyProviderMaintenanceCapabilities(input: {
196196
readonly provider: ProviderDriverKind;
197197
readonly packageName: string | null;
198198
readonly installPath?: string;
199-
/**
200-
* The owning installer's own release, when it publishes behind npm. Without
201-
* it the npm registry is authoritative, and the advisory would keep asking
202-
* for a version the installer cannot provide yet.
203-
*/
204199
readonly lookupLatestVersion?: Effect.Effect<string | null>;
205200
readonly manualCommand?: string;
206201
}): ProviderMaintenanceCapabilities {
@@ -258,13 +253,7 @@ function isWinGetClaudeCommandPath(commandPath: string): boolean {
258253

259254
const CHOCOLATEY_CLAUDE_PACKAGE_ID = "claude-code";
260255

261-
/**
262-
* Chocolatey's Claude Code package: the shimgen shim in `<root>\bin` or the
263-
* binary it launches from `<root>\lib\claude-code\tools`. The default root's
264-
* directory is named `chocolatey`. A custom root is not, so those paths are
265-
* compared with `ChocolateyInstall`. The shim is a real executable rather than
266-
* a link, so following symlinks never reaches the package directory.
267-
*/
256+
// Chocolatey's executable shim is not a symlink, so realpath cannot prove its owner.
268257
const chocolateyClaudeCommandPath = /\/chocolatey\/(?:bin|lib\/claude-code\/tools)\/claude\.exe$/;
269258

270259
function isChocolateyClaudeCommandPath(commandPath: string, env: NodeJS.ProcessEnv): boolean {

0 commit comments

Comments
 (0)