@@ -2,7 +2,7 @@ import assert from 'node:assert/strict';
22import { promises as fs } from 'node:fs' ;
33import path from 'node:path' ;
44import { afterEach , test , vi } from 'vitest' ;
5- import { runCmd } from '@agent-device/host-kit/command' ;
5+ import { runCmd , withCommandHost } from '@agent-device/host-kit/command' ;
66import { AppError } from '@agent-device/kernel/errors' ;
77import { asOptionalRecord } from '@agent-device/kernel/record' ;
88import {
@@ -141,6 +141,31 @@ test('the hub app resolver passes references through, uploads local files, and p
141141 }
142142} ) ;
143143
144+ test ( 'the hub app resolver resolves a relative app against the host working directory when no cwd is given' , async ( ) => {
145+ const hostDir = await mkdtempForTest ( 'agent-device-hub-host-cwd-' ) ;
146+ try {
147+ await fs . writeFile ( path . join ( hostDir , 'App.apk' ) , 'placeholder' ) ;
148+ const uploadFile = vi . fn ( async ( appPath : string ) => `hub://${ path . basename ( appPath ) } ` ) ;
149+
150+ const reference = await withCommandHost (
151+ { host : { env : { } , cwd : hostDir } , requestEnv : undefined } ,
152+ async ( ) =>
153+ await resolveHubAppReference ( {
154+ service : 'Hub' ,
155+ app : 'App.apk' ,
156+ referenceLabel : 'a hub:// app id' ,
157+ ...hubReferenceGrammar ,
158+ uploadFile,
159+ } ) ,
160+ ) ;
161+
162+ assert . equal ( reference , 'hub://App.apk' ) ;
163+ assert . deepEqual ( uploadFile . mock . calls , [ [ path . join ( hostDir , 'App.apk' ) , undefined ] ] ) ;
164+ } finally {
165+ await fs . rm ( hostDir , { recursive : true , force : true } ) ;
166+ }
167+ } ) ;
168+
144169test ( 'appFileUploadForm carries a regular app file and refuses anything else typed' , async ( ) => {
145170 const tempDir = await mkdtempForTest ( 'agent-device-upload-form-' ) ;
146171 try {
0 commit comments