-
Notifications
You must be signed in to change notification settings - Fork 50
feat: add session management and parallel work spawning #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -617,6 +617,82 @@ After fixing violations from SonarCloud, Codacy, ShellCheck, etc.: | |
|
|
||
| Example: Finding 15 SC2162 violations (read without -r) leads to adding clear examples in AGENTS.md's shell best practices section. | ||
|
|
||
| ## Spawning Parallel Sessions | ||
|
|
||
| OpenCode supports multiple session patterns for parallel work. | ||
|
|
||
| ### Non-Interactive Execution | ||
|
|
||
| ```bash | ||
| # Run a task without TUI | ||
| opencode run "Task description" --agent Build+ --title "Task Name" | ||
|
|
||
| # Background execution | ||
| opencode run "Long running task" --agent Build+ & | ||
| ``` | ||
|
|
||
| ### Persistent Server Mode | ||
|
|
||
| For multiple sessions sharing MCP connections: | ||
|
|
||
| ```bash | ||
| # Terminal 1: Start headless server | ||
| opencode serve --port 4097 | ||
|
|
||
| # Terminal 2+: Run against server (fast, reuses MCPs) | ||
| opencode run --attach http://localhost:4097 "Task 1" --agent Build+ | ||
| opencode run --attach http://localhost:4097 "Task 2" --agent SEO | ||
| ``` | ||
|
|
||
| ### Terminal Tab Spawning | ||
|
|
||
| ```bash | ||
| # macOS Terminal.app | ||
| osascript -e 'tell application "Terminal" to do script "cd ~/Git/project && opencode"' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The example commands use a hardcoded project path |
||
|
|
||
| # iTerm2 | ||
| osascript -e 'tell application "iTerm2" to tell current window to create tab with default profile command "cd ~/Git/project && opencode"' | ||
|
|
||
| # Linux GNOME Terminal | ||
| gnome-terminal --tab -- bash -c "cd ~/Git/project && opencode; exec bash" | ||
|
|
||
| # Kitty | ||
| kitty @ launch --type=tab --cwd=~/Git/project opencode | ||
| ``` | ||
|
|
||
| ### Worktree + New Session (Recommended) | ||
|
|
||
| Best pattern for parallel branch work: | ||
|
|
||
| ```bash | ||
| # Create worktree for parallel branch | ||
| ~/.aidevops/agents/scripts/worktree-helper.sh add feature/parallel-task | ||
| # Output: ~/Git/project-feature-parallel-task/ | ||
|
|
||
| # Spawn session in worktree (macOS) | ||
| osascript -e 'tell application "Terminal" to do script "cd ~/Git/project-feature-parallel-task && opencode"' | ||
| ``` | ||
|
|
||
| ### Session Handoff | ||
|
|
||
| When spawning a continuation session: | ||
|
|
||
| ```bash | ||
| # Export context for new session | ||
| cat > .session-handoff.md << EOF | ||
| # Session Handoff | ||
| **Branch**: $(git branch --show-current) | ||
| **Last commit**: $(git log -1 --oneline) | ||
| ## Continue With | ||
| - {next task description} | ||
| EOF | ||
|
|
||
| # Spawn with handoff | ||
| opencode run "Read .session-handoff.md and continue" --agent Build+ | ||
| ``` | ||
|
|
||
| See `workflows/session-manager.md` for full session lifecycle guidance. | ||
|
|
||
| ## References | ||
|
|
||
| - [OpenCode Agents Documentation](https://opencode.ai/docs/agents) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: marcusquinn/aidevops
Length of output: 3729
Session spawning examples should relocate to subagent; consolidate with ralph-loop.md "Session Completion & Spawning" section.
The section appropriately uses progressive disclosure with a pointer to
workflows/session-manager.md, aligning with prior learnings. However, two issues warrant refactoring:Duplication with
workflows/ralph-loop.md: Lines 347-403 of ralph-loop.md contain "Session Completion & Spawning" with overlapping spawning patterns and new session logic. This duplicates AGENTS.md lines 246-255.Inline spawning examples: The code examples at lines 246-255 (worktree + terminal spawning) should move to a dedicated subagent with a brief pointer in AGENTS.md, strengthening the progressive disclosure pattern already established by the pointer to workflows/session-manager.md.
The content itself is universally applicable (session management touches >80% of tasks), so root-level guidance is warranted—but delivery should follow the pointer-first pattern consistently.