Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ type Agent interface {
Name() string
}

// GlobalWorkDir is the target codebase directory for agent subprocesses.
// Set this before running agents to ensure they operate on the correct codebase.
var GlobalWorkDir string

// shellQuote quotes a string for safe use in shell commands
func shellQuote(s string) string {
// Use single quotes and escape any single quotes in the string
Expand Down
3 changes: 3 additions & 0 deletions internal/agent/claude.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ func (a *ClaudeAgent) Run(ctx context.Context, prompt string) (<-chan string, <-
claudeArgs += " -p " + shellQuote(prompt)

cmd := exec.CommandContext(ctx, "bash", "-lc", claudeArgs)
if GlobalWorkDir != "" {
cmd.Dir = GlobalWorkDir
}

stdout, err := cmd.StdoutPipe()
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions internal/agent/codex.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ func (a *CodexAgent) Run(ctx context.Context, prompt string) (<-chan string, <-c
codexArgs += " -"

cmd := exec.CommandContext(ctx, "bash", "-lc", codexArgs)
if GlobalWorkDir != "" {
cmd.Dir = GlobalWorkDir
}
cmd.Stdin = strings.NewReader(prompt)

stdout, err := cmd.StdoutPipe()
Expand Down
3 changes: 3 additions & 0 deletions internal/agent/gemini.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ func (a *GeminiAgent) Run(ctx context.Context, prompt string) (<-chan string, <-
}

cmd := exec.CommandContext(ctx, "bash", "-lc", geminiArgs)
if GlobalWorkDir != "" {
cmd.Dir = GlobalWorkDir
}
cmd.Stdin = strings.NewReader(prompt)

stdout, err := cmd.StdoutPipe()
Expand Down
5 changes: 5 additions & 0 deletions internal/cli/assess.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ func runAssess(cmd *cobra.Command, args []string) error {
return fmt.Errorf("failed to load plan: %w", err)
}

// Set working directory for agent subprocesses from plan
if p.CodebaseRoot != "" {
agent.GlobalWorkDir = p.CodebaseRoot
}

display.PrintHeader("ASSESS")
display.PrintStatus("Plan: %s", p.Name)

Expand Down
5 changes: 5 additions & 0 deletions internal/cli/complete.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ func runComplete(cmd *cobra.Command, args []string) error {
return fmt.Errorf("failed to load plan: %w", err)
}

// Set working directory for agent subprocesses from plan
if p.CodebaseRoot != "" {
agent.GlobalWorkDir = p.CodebaseRoot
}

display.PrintHeader("SYNTHESIZE")
display.PrintStatus("Plan: %s", p.Name)
display.PrintStatus("Subsystem: %s", completeSubsystem)
Expand Down
5 changes: 5 additions & 0 deletions internal/cli/convene.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ func runConvene(cmd *cobra.Command, args []string) error {
return fmt.Errorf("failed to load plan: %w", err)
}

// Set working directory for agent subprocesses from plan
if p.CodebaseRoot != "" {
agent.GlobalWorkDir = p.CodebaseRoot
}

display.PrintHeader("CONVENE")
display.PrintStatus("Plan: %s", p.Name)
display.PrintStatus("Subsystem: %s", conveneSubsystem)
Expand Down
3 changes: 3 additions & 0 deletions internal/cli/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ func runPlan(cmd *cobra.Command, args []string) error {
return fmt.Errorf("path must be a directory: %s", absPath)
}

// Set working directory for all agent subprocesses
agent.GlobalWorkDir = absPath

// Initialize state directory
st, err := state.New(absPath)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions internal/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ func runFull(cmd *cobra.Command, args []string) error {
return fmt.Errorf("path must be a directory: %s", absPath)
}

// Set working directory for all agent subprocesses
agent.GlobalWorkDir = absPath

// Initialize state
st, err := state.New(absPath)
if err != nil {
Expand Down