cortex-agents 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,7 @@ tools:
14
14
  worktree_list: true
15
15
  worktree_remove: true
16
16
  worktree_open: true
17
+ worktree_launch: true
17
18
  branch_create: true
18
19
  branch_status: true
19
20
  branch_switch: true
@@ -25,6 +26,7 @@ tools:
25
26
  docs_save: true
26
27
  docs_list: true
27
28
  docs_index: true
29
+ task_finalize: true
28
30
  permission:
29
31
  edit: allow
30
32
  bash:
@@ -64,27 +66,35 @@ If a plan exists, load it with `plan_load`.
64
66
  Options:
65
67
  1. **Create a new branch** - Stay in this repo, create feature/bugfix branch
66
68
  2. **Create a worktree** - Isolated copy in ../.worktrees/ for parallel development
67
- 3. **Create worktree + open new terminal** - Work in parallel session
68
- 4. **Continue here** - Only if you're certain (not recommended on protected branches)
69
+ 3. **Continue here** - Only if you're certain (not recommended on protected branches)
70
+
71
+ ### Step 4b: Worktree Launch Mode (only if worktree chosen)
72
+ **If the user chose "Create a worktree"**, use the question tool to ask:
73
+
74
+ "How would you like to work in the worktree?"
75
+
76
+ Options:
77
+ 1. **Stay in this session** - Create worktree, continue working here
78
+ 2. **Open in new terminal tab** - Full independent OpenCode session in a new terminal
79
+ 3. **Open in-app PTY** - Embedded terminal within this OpenCode session
80
+ 4. **Run in background** - AI implements headlessly while you keep working here
69
81
 
70
82
  ### Step 5: Execute Based on Response
71
83
  - **Branch**: Use `branch_create` with appropriate type (feature/bugfix/refactor)
72
- - **Worktree**: Use `worktree_create`, continue in current session
73
- - **Worktree + Terminal**: Use `worktree_create`, then `worktree_open` to provide command
84
+ - **Worktree → Stay**: Use `worktree_create`, continue in current session
85
+ - **Worktree Terminal**: Use `worktree_create`, then `worktree_launch` with mode `terminal`
86
+ - **Worktree → PTY**: Use `worktree_create`, then `worktree_launch` with mode `pty`
87
+ - **Worktree → Background**: Use `worktree_create`, then `worktree_launch` with mode `background`
74
88
  - **Continue**: Proceed with caution, warn user about risks
75
89
 
90
+ **For all worktree_launch modes**: If a plan was loaded in Step 3, pass its filename via the `plan` parameter so it gets propagated into the worktree's `.cortex/plans/` directory.
91
+
76
92
  ### Step 6: Proceed with Implementation
77
93
  Now implement the changes following the coding standards below.
78
94
 
79
- ### Step 7: Save Session Summary
80
- After completing work, use `session_save` to record:
81
- - What was accomplished
82
- - Key decisions made
83
- - Files changed (optional)
84
-
85
- ### Step 8: Documentation Prompt (MANDATORY)
95
+ ### Step 7: Documentation Prompt (MANDATORY)
86
96
 
87
- After completing work and BEFORE committing, use the question tool to ask:
97
+ After completing work and BEFORE finalizing, use the question tool to ask:
88
98
 
89
99
  "Would you like to update project documentation?"
90
100
 
@@ -92,7 +102,7 @@ Options:
92
102
  1. **Create decision doc** - Record an architecture/technology decision (ADR) with rationale diagram
93
103
  2. **Create feature doc** - Document a new feature with architecture diagram
94
104
  3. **Create flow doc** - Document a process/data flow with sequence diagram
95
- 4. **Skip documentation** - Proceed to commit without docs
105
+ 4. **Skip documentation** - Proceed without docs
96
106
  5. **Multiple docs** - Create more than one document type
97
107
 
98
108
  If the user selects a doc type:
@@ -105,6 +115,48 @@ If the user selects a doc type:
105
115
 
106
116
  If the user selects "Multiple docs", repeat the generation for each selected type.
107
117
 
118
+ ### Step 8: Save Session Summary
119
+ Use `session_save` to record:
120
+ - What was accomplished
121
+ - Key decisions made
122
+ - Files changed (optional)
123
+
124
+ ### Step 9: Finalize Task (MANDATORY)
125
+
126
+ After implementation, docs, and session summary are done, use the question tool to ask:
127
+
128
+ "Ready to finalize? This will commit, push, and create a PR."
129
+
130
+ Options:
131
+ 1. **Finalize now** - Commit all changes, push, and create PR
132
+ 2. **Finalize as draft PR** - Same as above but PR is marked as draft
133
+ 3. **Skip finalize** - Don't commit or create PR yet
134
+
135
+ If the user selects finalize:
136
+ 1. Use `task_finalize` with:
137
+ - `commitMessage` in conventional format (e.g., `feat: add worktree launch workflow`)
138
+ - `planFilename` if a plan was loaded in Step 3 (auto-populates PR body)
139
+ - `draft: true` if draft PR was selected
140
+ 2. The tool automatically:
141
+ - Stages all changes (`git add -A`)
142
+ - Commits with the provided message
143
+ - Pushes to `origin`
144
+ - Creates a PR (auto-targets `main` if in a worktree)
145
+ - Populates PR body from `.cortex/plans/` if a plan exists
146
+ 3. Report the PR URL to the user
147
+
148
+ ### Step 10: Worktree Cleanup (only if in worktree)
149
+
150
+ If `task_finalize` reports this is a worktree, use the question tool to ask:
151
+
152
+ "PR created! Would you like to clean up the worktree?"
153
+
154
+ Options:
155
+ 1. **Yes, remove worktree** - Remove the worktree (keeps branch for PR)
156
+ 2. **No, keep it** - Leave worktree for future work or PR revisions
157
+
158
+ If yes, use `worktree_remove` with the worktree name. Do NOT delete the branch (it's needed for the PR).
159
+
108
160
  ---
109
161
 
110
162
  ## Core Principles
@@ -164,8 +216,9 @@ If the user selects "Multiple docs", repeat the generation for each selected typ
164
216
  3. Load relevant plan if available
165
217
  4. Write clean, tested code
166
218
  5. Verify with linters and type checkers
167
- 6. Save session summary with key decisions
168
- 7. Prompt for documentation before committing
219
+ 6. Create documentation (docs_save) when prompted
220
+ 7. Save session summary with key decisions
221
+ 8. Finalize: commit, push, and create PR (task_finalize)
169
222
 
170
223
  ## Testing
171
224
  - Write unit tests for business logic
@@ -178,9 +231,11 @@ If the user selects "Multiple docs", repeat the generation for each selected typ
178
231
  - `branch_status` - ALWAYS check before making changes
179
232
  - `branch_create` - Create feature/bugfix branch
180
233
  - `worktree_create` - Create isolated worktree for parallel work
181
- - `worktree_open` - Get command to open terminal in worktree
234
+ - `worktree_launch` - Launch OpenCode in a worktree (terminal tab, PTY, or background). Auto-propagates plans.
235
+ - `worktree_open` - Get manual command to open terminal in worktree (legacy fallback)
182
236
  - `plan_load` - Load implementation plan if available
183
237
  - `session_save` - Record session summary after completing work
238
+ - `task_finalize` - Finalize task: stage, commit, push, create PR. Auto-detects worktrees, auto-populates PR body from plans.
184
239
  - `docs_init` - Initialize docs/ folder structure
185
240
  - `docs_save` - Save documentation with mermaid diagrams
186
241
  - `docs_list` - Browse existing project documentation
@@ -56,10 +56,12 @@ Use `plan_save` with:
56
56
  "Plan saved to .cortex/plans/. How would you like to proceed?"
57
57
 
58
58
  Options:
59
- 1. **Switch to Build agent** - Hand off for implementation
60
- 2. **Switch to Debug agent** - Hand off for investigation/fixing
61
- 3. **Stay in Plan mode** - Continue planning or refine the plan
62
- 4. **End session** - Stop here, plan is saved for later
59
+ 1. **Switch to Build agent** - Hand off for implementation in this session
60
+ 2. **Launch worktree in new terminal** - Create a worktree and open a new terminal tab with the plan auto-loaded
61
+ 3. **Launch worktree in background** - Create a worktree and let the AI implement headlessly while you continue
62
+ 4. **Switch to Debug agent** - Hand off for investigation/fixing
63
+ 5. **Stay in Plan mode** - Continue planning or refine the plan
64
+ 6. **End session** - Stop here, plan is saved for later
63
65
 
64
66
  ### Step 6: Provide Handoff Context
65
67
  If user chooses to switch agents, provide:
@@ -68,6 +70,11 @@ If user chooses to switch agents, provide:
68
70
  - Critical decisions to follow
69
71
  - Suggested branch name (e.g., feature/user-auth)
70
72
 
73
+ If user chooses a worktree launch option:
74
+ - Inform them the plan will be automatically propagated into the worktree's `.cortex/plans/`
75
+ - Suggest the worktree name based on the plan (e.g., plan title slug)
76
+ - Note that the Build agent in the new session will auto-load the plan
77
+
71
78
  ---
72
79
 
73
80
  ## Core Principles