@@ -4,7 +4,11 @@ import fs from "node:fs";
44import os from "node:os" ;
55import path from "node:path" ;
66import { afterEach , describe , expect , it } from "vitest" ;
7- import { appendWorkspaceMountArgs } from "./workspace-mounts.js" ;
7+ import {
8+ appendWorkspaceMountArgs ,
9+ resolveReadOnlyWorkspaceSkillMounts ,
10+ } from "./workspace-mounts.js" ;
11+ import { ensureSandboxWorkspace } from "./workspace.js" ;
812
913const tmpDirs : string [ ] = [ ] ;
1014
@@ -249,4 +253,33 @@ describe("appendWorkspaceMountArgs", () => {
249253 `${ path . join ( sandboxWorkspaceDir , "skills" ) } :/workspace/skills:ro,z` ,
250254 ) ;
251255 } ) ;
256+
257+ it ( "creates skills directories so read-only overlays are always resolved" , async ( ) => {
258+ // When a new sandbox workspace is created without pre-existing skills
259+ // directories, ensureSandboxWorkspace must create them so that
260+ // resolveReadOnlyWorkspaceSkillMounts finds existing sources.
261+ const agentWorkspaceDir = makeTempWorkspace ( ) ;
262+
263+ await ensureSandboxWorkspace ( agentWorkspaceDir , undefined , true ) ;
264+
265+ // Directories must exist after workspace setup.
266+ const skillsDir = path . join ( agentWorkspaceDir , "skills" ) ;
267+ const agentsSkillsDir = path . join ( agentWorkspaceDir , ".agents" , "skills" ) ;
268+ expect ( fs . existsSync ( skillsDir ) ) . toBe ( true ) ;
269+ expect ( fs . existsSync ( agentsSkillsDir ) ) . toBe ( true ) ;
270+
271+ // Mount resolution must find them and include the read-only overlays.
272+ const mounts = resolveReadOnlyWorkspaceSkillMounts ( {
273+ workspaceDir : agentWorkspaceDir ,
274+ agentWorkspaceDir,
275+ workdir : "/workspace" ,
276+ workspaceAccess : "rw" ,
277+ } ) ;
278+ expect ( mounts ) . toEqual (
279+ expect . arrayContaining ( [
280+ expect . objectContaining ( { containerPath : "/workspace/skills" } ) ,
281+ expect . objectContaining ( { containerPath : "/workspace/.agents/skills" } ) ,
282+ ] ) ,
283+ ) ;
284+ } ) ;
252285} ) ;
0 commit comments