Skip to content

feat: add --dir flag to /run, /chain, /parallel commands#47

Open
vedang wants to merge 8 commits intonicobailon:mainfrom
vedang:push-knkotrvoyqlt
Open

feat: add --dir flag to /run, /chain, /parallel commands#47
vedang wants to merge 8 commits intonicobailon:mainfrom
vedang:push-knkotrvoyqlt

Conversation

@vedang
Copy link

@vedang vedang commented Mar 6, 2026

Summary

Adds optional --dir <path> flag to /run, /chain, and /parallel slash commands to control working directories and isolate artifacts in task-specific folders.

Changes

  • index.ts:
    • Added extractTrailingFlags() helper to parse --dir and --bg flags with quote-aware reverse-scanning
    • Added stripSurroundingQuotes() to handle quoted path values
    • Added takeTrailingArg() for robust argument extraction
    • Added applyInlineConfigToStep(), buildChainStep(), buildParallelTask() helpers to reduce duplication
    • Updated /run handler to set cwd when --dir provided
    • Updated /chain handler to inject chainDir when --dir provided
    • Updated /parallel handler to inject chainDir when --dir provided
    • Updated command descriptions to include --dir flag
  • path-handling.test.ts: Added 11 comprehensive tests for slash command parsing
  • README.md: Added documentation and examples for --dir usage
  • Added investigation document session-persistence-investigation.md for reference

Behavior

  • /run ... --dir <path>: Sets cwd parameter for the subagent run
  • /chain ... --dir <path>: Injects chainDir for chain artifacts
  • /parallel ... --dir <path>: Injects chainDir for parallel artifacts
  • Relative paths resolved against ctx.cwd
  • When --dir omitted, existing default behavior preserved
  • Quoted task text containing --dir or --bg substrings correctly handled

Examples

# Isolate outputs in task-specific directory
/run scout "analyze auth system" --dir 20260304T145245--auth-audit/

# Chain with artifacts in workspace directory
/chain scout "collect context" -> planner "draft plan" --dir task-123/

# Parallel runs with shared directory
/parallel scout "scan frontend" -> reviewer "check security" --dir code-review/

Related Issue

Closes: #45

nicobailon added a commit that referenced this pull request Mar 12, 2026
Add --no-skills to the async runner so background subagents with explicit
skills don't get the full catalog injected (PR #41 only fixed the sync
path). Expand ~ in sessionDir and defaultSessionDir config values.
Append runId to defaultSessionDir to prevent collisions across multiple
subagent calls.

Remove dead resolveSessionRoot() whose contract diverged from the inline
logic, along with PR #47 scaffolding and tests from path-handling.test.ts.
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.

Add --dir flag to slash commands to specify the working directory

1 participant