@@ -826,7 +826,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => {
826826 expect ( remoteCommand ) . toContain ( "openclaw_crabbox_bootstrap_macos_js" ) ;
827827 expect ( remoteCommand ) . toContain ( 'corepack enable --install-directory "$PNPM_HOME"' ) ;
828828 expect ( remoteCommand ) . toContain ( "pnpm --version >&2" ) ;
829- expectGroupedShellCommand ( remoteCommand , "/usr/bin/env pnpm --version" ) ;
829+ expectGroupedShellCommand ( remoteCommand , "openclaw_crabbox_env pnpm --version" ) ;
830830 } ) ;
831831
832832 it ( "bootstraps Corepack for raw AWS macOS env option pnpm commands" , ( ) => {
@@ -895,7 +895,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => {
895895 ) ;
896896 } ) ;
897897
898- it ( "does not bootstrap absolute env ignore-environment commands it cannot preserve " , ( ) => {
898+ it ( "bootstraps Corepack for raw AWS macOS absolute env ignore-environment commands" , ( ) => {
899899 const result = runWrapper (
900900 "provider: hetzner, aws, local-container, blacksmith-testbox, or cloudflare\n" ,
901901 [
@@ -913,6 +913,62 @@ describe.concurrent("scripts/crabbox-wrapper", () => {
913913 ] ,
914914 ) ;
915915
916+ const output = parseFakeCrabboxOutput ( result ) ;
917+ const remoteCommand = normalizeShellLineEndings ( output . args . at ( - 1 ) ?? "" ) ;
918+ expect ( result . status ) . toBe ( 0 ) ;
919+ expect ( output . args ) . toContain ( "--shell" ) ;
920+ expect ( remoteCommand ) . toContain ( "openclaw_crabbox_bootstrap_macos_js" ) ;
921+ expect ( remoteCommand ) . toContain ( "pnpm --version >&2" ) ;
922+ expectGroupedShellCommand (
923+ remoteCommand ,
924+ "openclaw_crabbox_env -i PATH=/usr/bin:/bin pnpm --version" ,
925+ ) ;
926+ } ) ;
927+
928+ it ( "injects the bootstrapped PATH for raw AWS macOS absolute env -i commands" , ( ) => {
929+ const result = runWrapper (
930+ "provider: hetzner, aws, local-container, blacksmith-testbox, or cloudflare\n" ,
931+ [
932+ "run" ,
933+ "--provider" ,
934+ "aws" ,
935+ "--target" ,
936+ "macos" ,
937+ "--" ,
938+ "/usr/bin/env" ,
939+ "-i" ,
940+ "pnpm" ,
941+ "--version" ,
942+ ] ,
943+ ) ;
944+
945+ const output = parseFakeCrabboxOutput ( result ) ;
946+ const remoteCommand = normalizeShellLineEndings ( output . args . at ( - 1 ) ?? "" ) ;
947+ expect ( result . status ) . toBe ( 0 ) ;
948+ expect ( remoteCommand ) . toContain ( "openclaw_crabbox_bootstrap_macos_js" ) ;
949+ expect ( remoteCommand ) . toContain (
950+ 'if [ "$openclaw_env_ignore" = "1" ] && [ "$openclaw_env_path_seen" = "0" ]; then openclaw_env_args+=("PATH=$PATH"); fi;' ,
951+ ) ;
952+ expectGroupedShellCommand ( remoteCommand , "openclaw_crabbox_env -i pnpm --version" ) ;
953+ } ) ;
954+
955+ it ( "does not rewrite custom env executables for raw AWS macOS ignore-environment commands" , ( ) => {
956+ const result = runWrapper (
957+ "provider: hetzner, aws, local-container, blacksmith-testbox, or cloudflare\n" ,
958+ [
959+ "run" ,
960+ "--provider" ,
961+ "aws" ,
962+ "--target" ,
963+ "macos" ,
964+ "--" ,
965+ "./tools/env" ,
966+ "-i" ,
967+ "pnpm" ,
968+ "--version" ,
969+ ] ,
970+ ) ;
971+
916972 const output = parseFakeCrabboxOutput ( result ) ;
917973 const remoteCommand = normalizeShellLineEndings ( output . args . at ( - 1 ) ?? "" ) ;
918974 expect ( result . status ) . toBe ( 0 ) ;
@@ -1027,7 +1083,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => {
10271083 expect ( remoteCommand . indexOf ( "-S|--split-string|-S*|--split-string=*)" ) ) . toBeLessThan (
10281084 remoteCommand . indexOf ( "-[!-]*i*)" ) ,
10291085 ) ;
1030- expectGroupedShellCommand ( remoteCommand , "/usr/bin/env -S 'pnpm --version'" ) ;
1086+ expectGroupedShellCommand ( remoteCommand , "openclaw_crabbox_env -S 'pnpm --version'" ) ;
10311087 } ) ;
10321088
10331089 it ( "bootstraps Corepack for AWS macOS node changed-gate commands" , ( ) => {
@@ -2324,6 +2380,48 @@ describe.concurrent("scripts/crabbox-wrapper", () => {
23242380 ) ;
23252381 } ) ;
23262382
2383+ it ( "preserves sparse changed-gate Git bootstrap for direct absolute env -i commands" , ( ) => {
2384+ const result = runWrapper (
2385+ "provider: hetzner, aws, local-container, blacksmith-testbox, or cloudflare\n" ,
2386+ [ "run" , "--provider" , "aws" , "--" , "/usr/bin/env" , "-i" , "pnpm" , "check:changed" ] ,
2387+ {
2388+ gitResponses : {
2389+ [ GIT_CONFIG_SPARSE_KEY ] : { stdout : "true\n" } ,
2390+ [ GIT_STATUS_PORCELAIN_KEY ] : { stdout : "" } ,
2391+ [ GIT_MERGE_BASE_MAIN_HEAD_KEY ] : { stdout : "abc123\n" } ,
2392+ } ,
2393+ } ,
2394+ ) ;
2395+
2396+ const output = parseFakeCrabboxOutput ( result ) ;
2397+ const remoteCommand = normalizeShellLineEndings ( output . args . at ( - 1 ) ?? "" ) ;
2398+ expect ( result . status ) . toBe ( 0 ) ;
2399+ expect ( output . args ) . toContain ( "--shell" ) ;
2400+ expect ( remoteCommand ) . toContain ( "git init -q" ) ;
2401+ expect ( remoteCommand ) . toMatch (
2402+ / & & \/ u s r \/ b i n \/ e n v - i O P E N C L A W _ C H E C K _ C H A N G E D _ R E M O T E _ C H I L D = 1 O P E N C L A W _ C H A N G E D _ L A N E S _ R A W _ S Y N C = 1 C I = 1 p n p m c h e c k : c h a n g e d $ / u,
2403+ ) ;
2404+ } ) ;
2405+
2406+ it ( "does not mark custom env executables outside the sanitized env" , ( ) => {
2407+ const result = runWrapper (
2408+ "provider: hetzner, aws, local-container, blacksmith-testbox, or cloudflare\n" ,
2409+ [ "run" , "--provider" , "aws" , "--" , "./tools/env" , "-i" , "pnpm" , "check:changed" ] ,
2410+ {
2411+ gitResponses : {
2412+ [ GIT_CONFIG_SPARSE_KEY ] : { stdout : "true\n" } ,
2413+ [ GIT_STATUS_PORCELAIN_KEY ] : { stdout : "" } ,
2414+ [ GIT_MERGE_BASE_MAIN_HEAD_KEY ] : { stdout : "abc123\n" } ,
2415+ } ,
2416+ } ,
2417+ ) ;
2418+
2419+ const output = parseFakeCrabboxOutput ( result ) ;
2420+ expect ( result . status ) . toBe ( 0 ) ;
2421+ expect ( output . args . join ( "\0" ) ) . not . toContain ( "OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1" ) ;
2422+ expect ( output . args . join ( "\0" ) ) . not . toContain ( "git init -q" ) ;
2423+ } ) ;
2424+
23272425 it ( "does not mark assignment-prefixed env -i changed gates outside the sanitized env" , ( ) => {
23282426 const result = runWrapper (
23292427 "provider: hetzner, aws, local-container, blacksmith-testbox, or cloudflare\n" ,
0 commit comments