Commit 71f66ed
feat: structured agent monitoring with status persistence and graceful UX (#7)
* refactor: extract entrypoint functions with main()
Extract linear entrypoint.sh into discrete functions (parse_args,
copy_credentials, create_worktree, setup_agent_perms, run_agent,
run_interactive) called from a main() entry point. Prepares for
adding monitoring logic without growing an unmaintainable script.
Zero behavior change — all 49 shellspec tests pass unchanged.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat: add agent monitoring with status.json, log persistence, and lifecycle markers
Add structured monitoring to the entrypoint agent mode:
- Create .agent/ dir in worktree with status.json (phase, branch, task,
timestamps, exit code, commit count)
- Persist full agent output to .agent/agent.log via tee
- Emit [agent:status] tagged markers at lifecycle transitions
(starting → working → completed/errored)
- Capture post-run metrics (commit count, duration, last commit)
- Add .agent/ to worktree .gitignore automatically
The su-exec call no longer uses exec, allowing post-processing to run
after claude exits. Test mocks updated accordingly with 6 new test cases.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat: add Makefile monitoring targets with graceful fallback
Add new targets and enhance existing ones:
- status-agent: reads status.json from worktree (works post-exit)
- summary-agent: extracts [agent:status] markers from logs
- list-agents: now shows phase from each worktree's status.json
- logs-agent: falls back to .agent/agent.log when container is gone
- follow-agent: same fallback behavior
All fallback paths return exit 0 with contextual messages instead of
silent failures, fixing the UX issue where finished agents appeared
as errors.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat: add CLI status/summary commands and log fallback
Add new commands to the q CLI:
- q agents status --branch X: reads status.json directly from
filesystem (no container needed, works post-exit)
- q agents summary --branch X: shows structured lifecycle events
The logs and follow commands now delegate to Makefile targets that
include graceful fallback to persisted .agent/agent.log when the
container no longer exists.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* docs: update skill, docs, and evals for agent monitoring
Update spawn-agent skill with decision flow for monitoring:
status.json → agent.log → container logs. Add guidance for
post-exit scenarios where container is gone.
Update docs:
- spawn-agent-skill.md: new monitoring commands and post-exit status
- cli.md: document q agents status/summary and log fallback behavior
Update evals:
- list_and_monitor.md: add part 3 for status post-exit scenario
- evals.json: update eval 4 to prefer status.json, add evals 7
(status post-exit) and 8 (logs fallback)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: deimagjas <deimagjas@127.0.0.1>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 200ff59 commit 71f66ed
File tree
9 files changed
+454
-72
lines changed- .claude/skills/spawn-agent
- evals
- app/cli/src/container_cli/commands
- config
- spec
- docs/agents
9 files changed
+454
-72
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | | - | |
| 171 | + | |
172 | 172 | | |
173 | | - | |
174 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
175 | 187 | | |
176 | 188 | | |
177 | 189 | | |
178 | 190 | | |
179 | | - | |
180 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
181 | 199 | | |
182 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
183 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
184 | 207 | | |
185 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
186 | 215 | | |
187 | 216 | | |
188 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
189 | 221 | | |
190 | 222 | | |
191 | 223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
52 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
56 | 80 | | |
57 | 81 | | |
58 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
34 | 50 | | |
35 | 51 | | |
36 | 52 | | |
37 | 53 | | |
38 | 54 | | |
| 55 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
1 | 4 | | |
2 | 5 | | |
3 | 6 | | |
4 | 7 | | |
5 | | - | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
10 | 21 | | |
11 | 22 | | |
12 | 23 | | |
| |||
55 | 66 | | |
56 | 67 | | |
57 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
135 | 149 | | |
136 | 150 | | |
137 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
138 | 163 | | |
139 | 164 | | |
140 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
141 | 202 | | |
142 | 203 | | |
143 | 204 | | |
| |||
0 commit comments