@@ -22,10 +22,12 @@ import {
2222 homebrewOwnershipFromCommandPath ,
2323 invalidateLatestProviderVersion ,
2424 makeCachedProviderMaintenanceResolution ,
25+ makeManualOnlyProviderMaintenanceCapabilities ,
2526 makePackageManagedProviderMaintenanceResolver ,
2627 makeProviderMaintenanceCapabilities ,
2728 normalizeCommandPath ,
2829 npmGlobalPrefixFromCommandPath ,
30+ parseChocolateyLatestVersion ,
2931 parseHomebrewLatestVersion ,
3032 resolveLatestProviderVersion ,
3133 resolvePackageManagedProviderMaintenance ,
@@ -254,6 +256,26 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
254256 } ) ;
255257 } ) ;
256258
259+ it ( "shows the Chocolatey upgrade command without offering to run it" , ( ) => {
260+ expect (
261+ createProviderVersionAdvisory ( {
262+ driver : driver ( "claudeAgent" ) ,
263+ currentVersion : "2.1.304" ,
264+ latestVersion : "2.1.306" ,
265+ maintenanceCapabilities : makeManualOnlyProviderMaintenanceCapabilities ( {
266+ provider : driver ( "claudeAgent" ) ,
267+ packageName : "@anthropic-ai/claude-code" ,
268+ installPath : "C:\\ProgramData\\chocolatey\\bin\\claude.exe" ,
269+ manualCommand : "choco upgrade claude-code" ,
270+ } ) ,
271+ } ) ,
272+ ) . toMatchObject ( {
273+ canUpdate : false ,
274+ canInstallVersion : false ,
275+ updateCommand : "choco upgrade claude-code" ,
276+ } ) ;
277+ } ) ;
278+
257279 it . effect ( "stays manual-only when the binary cannot be located" , ( ) =>
258280 resolveProviderMaintenanceCapabilitiesEffect ( packageToolUpdate , {
259281 binaryPath : "package-tool" ,
@@ -390,12 +412,13 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
390412 readonly resolved : string ;
391413 readonly real : string ;
392414 readonly platform ?: NodeJS . Platform ;
415+ readonly env ?: NodeJS . ProcessEnv ;
393416 } ) =>
394417 resolvePackageManagedProviderMaintenance ( input . definition , {
395418 binaryPath : "claude" ,
396419 resolvedCommandPath : input . resolved ,
397420 realCommandPath : input . real ,
398- env : { } ,
421+ env : input . env ?? { } ,
399422 platform : input . platform ?? "win32" ,
400423 } ) . pipe (
401424 Effect . provideService ( HostProcess . Platform , input . platform ?? "win32" ) ,
@@ -428,6 +451,113 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
428451 } ) ,
429452 ) ;
430453
454+ const chocolateyShim = "C:\\ProgramData\\chocolatey\\bin\\claude.exe" ;
455+ const chocolateyPackage = "C:\\ProgramData\\chocolatey\\lib\\claude-code\\tools\\claude.exe" ;
456+
457+ it . effect . each ( [
458+ { name : "the shimgen shim" , resolved : chocolateyShim , real : chocolateyShim } ,
459+ { name : "the package binary" , resolved : chocolateyPackage , real : chocolateyPackage } ,
460+ {
461+ name : "a custom root" ,
462+ resolved : "D:\\Tools\\Choco\\bin\\claude.exe" ,
463+ real : "D:\\Tools\\Choco\\bin\\claude.exe" ,
464+ env : { ChocolateyInstall : "D:\\Tools\\Choco" } ,
465+ } ,
466+ ] as const ) ( "keeps a Chocolatey Claude install manual-only through $name" , ( fixture ) =>
467+ Effect . gen ( function * ( ) {
468+ const capabilities = yield * resolveInstall ( { definition : claudeUpdate , ...fixture } ) ;
469+
470+ expect ( capabilities . update ) . toBeNull ( ) ;
471+ expect ( capabilities . installPath ) . toBe ( fixture . real ) ;
472+ expect ( capabilities . latestVersion ) . toBeNull ( ) ;
473+ expect ( capabilities . lookupLatestVersion ) . toBeDefined ( ) ;
474+ expect ( capabilities . manualCommand ) . toBe ( "choco upgrade claude-code" ) ;
475+ } ) ,
476+ ) ;
477+
478+ it . effect ( "keeps a Chocolatey-shaped path off Windows on the native updater" , ( ) =>
479+ Effect . gen ( function * ( ) {
480+ const commandPath = "/home/me/chocolatey/bin/claude.exe" ;
481+ const capabilities = yield * resolveInstall ( {
482+ definition : claudeUpdate ,
483+ resolved : commandPath ,
484+ real : commandPath ,
485+ platform : "linux" ,
486+ } ) ;
487+
488+ expect ( capabilities . update ) . toMatchObject ( { lockKey : "claudeAgent-native" } ) ;
489+ } ) ,
490+ ) ;
491+
492+ // Chocolatey publishes behind npm, so comparing against the registry would
493+ // report an update `choco upgrade` cannot install yet.
494+ it . effect ( "compares a Chocolatey Claude install against choco search" , ( ) =>
495+ Effect . gen ( function * ( ) {
496+ const probes : Array < string > = [ ] ;
497+ const capabilities = yield * resolvePackageManagedProviderMaintenance ( claudeUpdate , {
498+ binaryPath : "claude" ,
499+ resolvedCommandPath : chocolateyShim ,
500+ realCommandPath : chocolateyShim ,
501+ env : { } ,
502+ platform : "win32" ,
503+ } ) . pipe (
504+ Effect . provideService ( HostProcess . Platform , "win32" ) ,
505+ Effect . provideService (
506+ ChildProcessSpawner . ChildProcessSpawner ,
507+ stdoutSpawner ( ( command ) => {
508+ probes . push ( command ) ;
509+ return "claude-code|2.1.304\r\n" ;
510+ } ) ,
511+ ) ,
512+ ) ;
513+ expect ( probes ) . toEqual ( [ ] ) ;
514+
515+ const latest = yield * resolveLatestProviderVersion ( capabilities ) . pipe (
516+ Effect . provide ( ProviderLatestVersions . layer ) ,
517+ Effect . provideService (
518+ HttpClient . HttpClient ,
519+ HttpClient . make ( ( ) => Effect . die ( "the installer's latest should not come from npm" ) ) ,
520+ ) ,
521+ ) ;
522+
523+ expect ( latest ) . toBe ( "2.1.304" ) ;
524+ expect ( probes . map ( ( command ) => NodePath . basename ( command ) . replace ( / \. \w + $ / , "" ) ) ) . toEqual ( [
525+ "choco" ,
526+ ] ) ;
527+ } ) . pipe ( Effect . provide ( NodeServices . layer ) ) ,
528+ ) ;
529+
530+ it . effect ( "stays unknown when choco search fails instead of asking npm" , ( ) =>
531+ Effect . gen ( function * ( ) {
532+ const capabilities = yield * resolvePackageManagedProviderMaintenance ( claudeUpdate , {
533+ binaryPath : "claude" ,
534+ resolvedCommandPath : chocolateyShim ,
535+ realCommandPath : chocolateyShim ,
536+ env : { } ,
537+ platform : "win32" ,
538+ } ) . pipe (
539+ Effect . provideService ( HostProcess . Platform , "win32" ) ,
540+ Effect . provideService (
541+ ChildProcessSpawner . ChildProcessSpawner ,
542+ stdoutSpawner (
543+ ( ) => "" ,
544+ ( ) => 1 ,
545+ ) ,
546+ ) ,
547+ ) ;
548+
549+ const latest = yield * resolveLatestProviderVersion ( capabilities ) . pipe (
550+ Effect . provide ( ProviderLatestVersions . layer ) ,
551+ Effect . provideService (
552+ HttpClient . HttpClient ,
553+ HttpClient . make ( ( ) => Effect . die ( "a failed choco search should not fall back to npm" ) ) ,
554+ ) ,
555+ ) ;
556+
557+ expect ( latest ) . toBeNull ( ) ;
558+ } ) . pipe ( Effect . provide ( NodeServices . layer ) ) ,
559+ ) ;
560+
431561 it . effect . each ( [
432562 {
433563 name : "a native install" ,
@@ -863,6 +993,13 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
863993 } ) ,
864994 ) ;
865995
996+ it ( "reads the Chocolatey package version from choco search --limit-output" , ( ) => {
997+ expect ( parseChocolateyLatestVersion ( "claude-code|2.1.304\r\n" , "claude-code" ) ) . toBe ( "2.1.304" ) ;
998+ expect ( parseChocolateyLatestVersion ( "Claude-Code|2.1.304\r\n" , "claude-code" ) ) . toBe ( "2.1.304" ) ;
999+ expect ( parseChocolateyLatestVersion ( "claude-code-other|9.9.9\r\n" , "claude-code" ) ) . toBeNull ( ) ;
1000+ expect ( parseChocolateyLatestVersion ( "" , "claude-code" ) ) . toBeNull ( ) ;
1001+ } ) ;
1002+
8661003 it ( "recognizes Homebrew kegs and casks from the real executable path" , ( ) => {
8671004 expect (
8681005 homebrewOwnershipFromCommandPath ( "/opt/homebrew/Cellar/claude-code@latest/2.1.0/bin/claude" ) ,
0 commit comments