Repository navigation
feat: auto-materialise static workspace when path is empty or missing #516
Description
Objective
When workspace.mode=static with a workspace.path, the orchestrator should auto-materialise the workspace (template + repos) at the defined path if the directory doesn't exist or is empty — reusing it as-is when it already has content.
Currently, static mode sets sharedWorkspacePath = configuredStaticPath unconditionally and skips all materialisation. This means a fresh static path with no pre-existing content gets no template copy, no repo cloning, and no setup hooks — the agent runs against an empty directory.
Current behaviour
orchestrator.ts ~L519:
if (useStaticWorkspace && configuredStaticPath) {
sharedWorkspacePath = configuredStaticPath;
setupLog(`using static workspace: ${configuredStaticPath}`);
}
No existence/emptiness check. No template or repo materialisation.
Desired behaviour
Follow a workflow similar to pooled mode:
- Path exists and has content → reuse as-is (current behaviour, no change)
- Path does not exist →
mkdir -p, then materialise (copy template, clone repos, run setup hooks) at that path - Path exists but is empty → materialise in place (copy template, clone repos, run setup hooks)
This mirrors how WorkspacePoolManager.acquireWorkspace conditionally creates/reuses pool slots, but applied to a user-specified static path.
Hooks in static mode
Setup hooks (workspace.hooks.before_all, before_each, etc.) run by default on static workspaces — both on initial materialisation and on reuse. This ensures consistent workspace state across runs.
A workspace.hooks.enabled option (default: true) allows disabling hooks for static workspaces when the user manages workspace state externally or wants to skip redundant setup on reuse.
workspace:
mode: static
path: /my/workspace
hooks:
enabled: false # skip all workspace hooks
before_all:
command: [setup.sh]When hooks.enabled: false, no workspace hooks fire regardless of whether the workspace is freshly materialised or reused.
Design latitude
- Reuse the existing
createTempWorkspace/ template-copy logic but target the static path instead of a generated temp dir - Repo cloning via
RepoManagershould work identically to pooled mode - An empty directory can be detected by checking for zero entries (excluding
.and..) - Should log clearly whether the static workspace was reused or materialised
hooks.enabledonly needs to apply to static mode initially; pooled/temp always run hooks
Acceptance signals
workspace.mode=static+workspace.path=/some/new/path+workspace.template→ template is copied to/some/new/path, repos cloned, setup hooks runworkspace.mode=static+workspace.path=/some/existing/populated/path→ reused, hooks still run by defaultworkspace.mode=static+workspace.path=/some/empty/dir→ materialised in placeworkspace.hooks.enabled: false→ no hooks fire on static workspace (materialised or reused)workspace.hooks.enabledomitted ortrue→ hooks fire normally (default)- Tests cover all three materialisation cases + hooks enabled/disabled
- Existing static workspace tests continue to pass
Non-goals
- Changing pooled or temp mode behaviour
- Adding cleanup/retention logic to static workspaces (they persist by definition)
- Changing the validation rules from feat: canonical workspace.mode + workspace.path model #515 (path implies static, conflicts hard-error, etc.)
Related
- feat: canonical workspace.mode + workspace.path model #515 — canonical
workspace.mode+workspace.pathmodel (merged) - feat: workspace.static soft override with env-var fallback #514 — workspace config design
Activity
feat(workspace): auto-materialise static workspace when path is empty…
feat(workspace): auto-materialise static workspace when path is empty…
docs: update workspace docs for static auto-materialise and hooks.ena…
docs: update workspace docs for static auto-materialise and hooks.ena…