Skip to content

feat: add --target-dir flag to direct backend#37

Merged
dplakon merged 1 commit intomainfrom
add-target-dir-flag
Mar 24, 2026
Merged

feat: add --target-dir flag to direct backend#37
dplakon merged 1 commit intomainfrom
add-target-dir-flag

Conversation

@dplakon
Copy link
Copy Markdown
Contributor

@dplakon dplakon commented Mar 24, 2026

Summary

Add a --target-dir option for the direct backend that runs all tasks in a specified directory instead of creating per-task workspace subdirectories. This disables per-task workspace isolation for users who want the agent to operate against an existing directory (e.g. a pre-existing repo checkout).

Changes

  • internal/config/config.go: Add target_dir field to DirectConfig YAML schema.
  • internal/worker/direct.go:
    • Add TargetDir to DirectBackendConfig.
    • NewDirectBackend: validate target dir exists at startup; skip workspace root setup when target dir is set.
    • ExecuteTask: use target dir as working directory when set, skipping per-task subdirectory creation. Shared directory is never deleted on cleanup (teardown commands still run).
    • Shutdown: early-return when WorkspaceRoot is empty (target-dir mode) to avoid spurious warnings.
    • Extract runTeardownIfConfigured from cleanup to reuse in both code paths.
    • Add defer os.Remove(envFilePath) to clean up temp env files explicitly (previously relied on workspace dir removal).
  • main.go: Add --target-dir CLI flag, wire through mergeConfig with CLI > config file precedence.
  • internal/config/config_test.go: Add test for target_dir config parsing.

Usage

# CLI flag
oz-agent-worker --backend direct --target-dir /path/to/repo ...

# YAML config
backend:
  direct:
    target_dir: "/path/to/repo"

Testing

  • go build ./... — compiles cleanly.
  • go test ./... — all tests pass, including new TestLoadDirectConfigWithTargetDir.
  • Manual verification: when target_dir is set, no per-task subdirectory is created; when unset, behavior is unchanged.

Co-Authored-By: Oz oz-agent@warp.dev
Conversation

When set, all tasks run in the specified directory instead of creating
per-task workspace subdirectories. This disables per-task workspace
isolation while still supporting setup/teardown commands.

Configurable via CLI flag (--target-dir) or YAML config (target_dir
under backend.direct).

Co-Authored-By: Oz <oz-agent@warp.dev>
@dplakon dplakon requested a review from ianhodge March 24, 2026 15:38
@dplakon dplakon merged commit aad049b into main Mar 24, 2026
3 checks passed
@dplakon dplakon deleted the add-target-dir-flag branch March 24, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants