tlc-claude-code 2.8.0 → 2.9.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.
- package/.claude/commands/tlc/audit.md +12 -0
- package/.claude/commands/tlc/autofix.md +12 -0
- package/.claude/commands/tlc/build.md +14 -2
- package/.claude/commands/tlc/cleanup.md +13 -1
- package/.claude/commands/tlc/coverage.md +12 -0
- package/.claude/commands/tlc/discuss.md +12 -0
- package/.claude/commands/tlc/docs.md +13 -1
- package/.claude/commands/tlc/edge-cases.md +13 -1
- package/.claude/commands/tlc/plan.md +12 -0
- package/.claude/commands/tlc/preflight.md +12 -0
- package/.claude/commands/tlc/refactor.md +12 -0
- package/.claude/commands/tlc/review-pr.md +13 -1
- package/.claude/commands/tlc/review.md +12 -0
- package/.claude/commands/tlc/security.md +13 -1
- package/.claude/commands/tlc/status.md +20 -1
- package/.claude/commands/tlc/verify.md +12 -0
- package/.claude/commands/tlc/watchci.md +12 -0
- package/package.json +1 -1
- package/server/lib/orchestration/completion-checker.js +52 -2
- package/server/lib/orchestration/completion-checker.test.js +64 -0
- package/server/lib/orchestration/session-status.js +28 -4
- package/server/lib/orchestration/session-status.test.js +44 -1
- package/server/lib/orchestration/skill-dispatcher.js +270 -0
- package/server/lib/orchestration/skill-dispatcher.test.js +449 -0
|
@@ -22,6 +22,18 @@ Run a comprehensive audit of the codebase against TLC coding standards.
|
|
|
22
22
|
/tlc:audit
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
## Background Dispatch
|
|
26
|
+
|
|
27
|
+
When the orchestrator is available (`curl -sf http://localhost:3100/health`), dispatch this command to a background agent session instead of running inline.
|
|
28
|
+
|
|
29
|
+
1. Check orchestrator health
|
|
30
|
+
2. If available: package the full skill prompt with project context (branch, changed files, current phase) and dispatch via `skill-dispatcher.dispatch({ skill: 'audit', prompt, project })`
|
|
31
|
+
3. Report to user: "Dispatched audit to background session ses_XXXX. Results will appear when complete."
|
|
32
|
+
4. When session completes, capture result via `skill-dispatcher.captureResult()` and display summary
|
|
33
|
+
5. If orchestrator unavailable, fall back to inline execution (existing behavior below)
|
|
34
|
+
|
|
35
|
+
Override: `--inline` flag forces inline execution even when orchestrator is available.
|
|
36
|
+
|
|
25
37
|
## CodeDB Acceleration
|
|
26
38
|
|
|
27
39
|
When CodeDB is available (`.mcp.json` has a `codedb` server), use these tools in the scan/search steps below. If CodeDB is unavailable, fall back to Grep/Glob/Read.
|
|
@@ -145,6 +145,18 @@ The existing autofix instructions below are the Inline Mode instructions and sho
|
|
|
145
145
|
/tlc:autofix
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
+
## Background Dispatch
|
|
149
|
+
|
|
150
|
+
When the orchestrator is available (`curl -sf http://localhost:3100/health`), dispatch this command to a background agent session instead of running inline.
|
|
151
|
+
|
|
152
|
+
1. Check orchestrator health
|
|
153
|
+
2. If available: package the full skill prompt with project context (branch, changed files, current phase) and dispatch via `skill-dispatcher.dispatch({ skill: 'autofix', prompt, project })`
|
|
154
|
+
3. Report to user: "Dispatched autofix to background session ses_XXXX. Results will appear when complete."
|
|
155
|
+
4. When session completes, capture result via `skill-dispatcher.captureResult()` and display summary
|
|
156
|
+
5. If orchestrator unavailable, fall back to inline execution (existing behavior below)
|
|
157
|
+
|
|
158
|
+
Override: `--inline` flag forces inline execution even when orchestrator is available.
|
|
159
|
+
|
|
148
160
|
## CodeDB Acceleration
|
|
149
161
|
|
|
150
162
|
When CodeDB is available (`.mcp.json` has a `codedb` server), use these tools in the scan/search steps below. If CodeDB is unavailable, fall back to Grep/Glob/Read.
|
|
@@ -158,6 +158,16 @@ fs.writeFileSync(path, JSON.stringify(existing, null, 2));
|
|
|
158
158
|
"
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
+
After dispatching, monitor each session to completion with `completion-checker` and react to the returned monitor state:
|
|
162
|
+
|
|
163
|
+
- When a session completes, call `skill-dispatcher.captureResult()` to collect its output before merge-back
|
|
164
|
+
- `stuck` -> ask the user: `Session stuck. Retry or cancel?`
|
|
165
|
+
- `budget_exhausted` -> ask the user: `Budget exhausted. Re-dispatch or skip?`
|
|
166
|
+
- `completed` -> proceed with merge-back
|
|
167
|
+
- `crashed` / `errored` -> report the error, skip that task, and continue with remaining tasks
|
|
168
|
+
|
|
169
|
+
Treat `completion-checker` as the source of truth for whether a session should merge, pause for user input, or be skipped.
|
|
170
|
+
|
|
161
171
|
### Step O3-fallback: Direct Dispatch (No Orchestrator)
|
|
162
172
|
|
|
163
173
|
If orchestrator is down, dispatch directly via tmux on the host:
|
|
@@ -173,13 +183,15 @@ After dispatching all tasks, report:
|
|
|
173
183
|
|
|
174
184
|
```
|
|
175
185
|
Dispatched N tasks to orchestrator:
|
|
176
|
-
ses_abc123 Task 1: Create schema codex running
|
|
177
|
-
ses_def456 Task 2: Add validation
|
|
186
|
+
ses_abc123 Task 1: Create schema codex running monitor=running
|
|
187
|
+
ses_def456 Task 2: Add validation codex running monitor=running
|
|
178
188
|
|
|
179
189
|
Run /tlc:status to check progress.
|
|
180
190
|
I'm free — what would you like to work on?
|
|
181
191
|
```
|
|
182
192
|
|
|
193
|
+
Include each session's current monitor state in the status display. When available, prefer the same session-status formatting used by orchestration status views so monitor values stay consistent across commands.
|
|
194
|
+
|
|
183
195
|
**STOP HERE.** Do not write code. Do not execute inline mode. Claude is the PM, not the coder.
|
|
184
196
|
|
|
185
197
|
### Step O5: Monitor (When User Asks)
|
|
@@ -25,7 +25,19 @@ Automatically fix all coding standards violations. No prompts - just fixes every
|
|
|
25
25
|
/tlc:cleanup
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
##
|
|
28
|
+
## Background Dispatch
|
|
29
|
+
|
|
30
|
+
When the orchestrator is available (`curl -sf http://localhost:3100/health`), dispatch this command to a background agent session instead of running inline.
|
|
31
|
+
|
|
32
|
+
1. Check orchestrator health
|
|
33
|
+
2. If available: package the full skill prompt with project context (branch, changed files, current phase) and dispatch via `skill-dispatcher.dispatch({ skill: 'cleanup', prompt, project })`
|
|
34
|
+
3. Report to user: "Dispatched cleanup to background session ses_XXXX. Results will appear when complete."
|
|
35
|
+
4. When session completes, capture result via `skill-dispatcher.captureResult()` and display summary
|
|
36
|
+
5. If orchestrator unavailable, fall back to inline execution (existing behavior below)
|
|
37
|
+
|
|
38
|
+
Override: `--inline` flag forces inline execution even when orchestrator is available.
|
|
39
|
+
|
|
40
|
+
## Process
|
|
29
41
|
|
|
30
42
|
### Step 1: Inject Standards
|
|
31
43
|
|
|
@@ -138,6 +138,18 @@ The existing coverage instructions below are the Inline Mode instructions and sh
|
|
|
138
138
|
- When joining a project to understand test gaps
|
|
139
139
|
- After "vibe coding" a feature without tests
|
|
140
140
|
|
|
141
|
+
## Background Dispatch
|
|
142
|
+
|
|
143
|
+
When the orchestrator is available (`curl -sf http://localhost:3100/health`), dispatch this command to a background agent session instead of running inline.
|
|
144
|
+
|
|
145
|
+
1. Check orchestrator health
|
|
146
|
+
2. If available: package the full skill prompt with project context (branch, changed files, current phase) and dispatch via `skill-dispatcher.dispatch({ skill: 'coverage', prompt, project })`
|
|
147
|
+
3. Report to user: "Dispatched coverage to background session ses_XXXX. Results will appear when complete."
|
|
148
|
+
4. When session completes, capture result via `skill-dispatcher.captureResult()` and display summary
|
|
149
|
+
5. If orchestrator unavailable, fall back to inline execution (existing behavior below)
|
|
150
|
+
|
|
151
|
+
Override: `--inline` flag forces inline execution even when orchestrator is available.
|
|
152
|
+
|
|
141
153
|
## CodeDB Acceleration
|
|
142
154
|
|
|
143
155
|
When CodeDB is available (`.mcp.json` has a `codedb` server), use these tools in the scan/search steps below. If CodeDB is unavailable, fall back to Grep/Glob/Read.
|
|
@@ -149,6 +149,18 @@ This command is not a blank-page brainstorming prompt. The agent should do the i
|
|
|
149
149
|
|
|
150
150
|
If no phase number, auto-detect current phase from `.planning/ROADMAP.md`.
|
|
151
151
|
|
|
152
|
+
## Background Dispatch (Research Only)
|
|
153
|
+
|
|
154
|
+
When the orchestrator is available, dispatch Step 1 (Scan Context) to a background agent for fast research, then continue the interview inline with the results.
|
|
155
|
+
|
|
156
|
+
1. Check orchestrator health
|
|
157
|
+
2. If available: dispatch a research agent via `skill-dispatcher.dispatch({ skill: 'discuss-research', prompt: 'Scan the codebase for phase context: read ROADMAP, PROJECT.md, relevant code, recent changes. Return structured context as JSON.' })`
|
|
158
|
+
3. When research agent completes, capture result and inject as context for Step 2 (Expand Before Asking)
|
|
159
|
+
4. Steps 2+ (the actual interview) always run inline - they need user interaction
|
|
160
|
+
5. If orchestrator unavailable, run Step 1 inline as before
|
|
161
|
+
|
|
162
|
+
Override: `--inline` flag forces all steps inline.
|
|
163
|
+
|
|
152
164
|
## CodeDB Acceleration
|
|
153
165
|
|
|
154
166
|
When CodeDB is available (`.mcp.json` has a `codedb` server), use these tools in the scan/search steps below. If CodeDB is unavailable, fall back to Grep/Glob/Read.
|
|
@@ -187,7 +187,19 @@ Once set up, GitHub Actions automatically:
|
|
|
187
187
|
|
|
188
188
|
2. **You don't need to manually maintain docs.** Just push code.
|
|
189
189
|
|
|
190
|
-
##
|
|
190
|
+
## Background Dispatch
|
|
191
|
+
|
|
192
|
+
When the orchestrator is available (`curl -sf http://localhost:3100/health`), dispatch this command to a background agent session instead of running inline.
|
|
193
|
+
|
|
194
|
+
1. Check orchestrator health
|
|
195
|
+
2. If available: package the full skill prompt with project context (branch, changed files, current phase) and dispatch via `skill-dispatcher.dispatch({ skill: 'docs', prompt, project })`
|
|
196
|
+
3. Report to user: "Dispatched docs to background session ses_XXXX. Results will appear when complete."
|
|
197
|
+
4. When session completes, capture result via `skill-dispatcher.captureResult()` and display summary
|
|
198
|
+
5. If orchestrator unavailable, fall back to inline execution (existing behavior below)
|
|
199
|
+
|
|
200
|
+
Override: `--inline` flag forces inline execution even when orchestrator is available.
|
|
201
|
+
|
|
202
|
+
## Process
|
|
191
203
|
|
|
192
204
|
### Step 1: Run Setup (Once)
|
|
193
205
|
|
|
@@ -147,7 +147,19 @@ The existing edge-case generation instructions below are the Inline Mode instruc
|
|
|
147
147
|
|
|
148
148
|
If no arguments, prompts for target.
|
|
149
149
|
|
|
150
|
-
##
|
|
150
|
+
## Background Dispatch
|
|
151
|
+
|
|
152
|
+
When the orchestrator is available (`curl -sf http://localhost:3100/health`), dispatch this command to a background agent session instead of running inline.
|
|
153
|
+
|
|
154
|
+
1. Check orchestrator health
|
|
155
|
+
2. If available: package the full skill prompt with project context (branch, changed files, current phase) and dispatch via `skill-dispatcher.dispatch({ skill: 'edge-cases', prompt, project })`
|
|
156
|
+
3. Report to user: "Dispatched edge-cases to background session ses_XXXX. Results will appear when complete."
|
|
157
|
+
4. When session completes, capture result via `skill-dispatcher.captureResult()` and display summary
|
|
158
|
+
5. If orchestrator unavailable, fall back to inline execution (existing behavior below)
|
|
159
|
+
|
|
160
|
+
Override: `--inline` flag forces inline execution even when orchestrator is available.
|
|
161
|
+
|
|
162
|
+
## Process
|
|
151
163
|
|
|
152
164
|
### Step 1: Identify Target
|
|
153
165
|
|
|
@@ -187,6 +187,18 @@ Before reading or writing phase artifacts, normalize the requested phase argumen
|
|
|
187
187
|
|
|
188
188
|
When a prefixed ID resolves to another repo, operate in that repo's directory (for example `CORE-3` resolves via the manifest and runs against `../tlc-core`).
|
|
189
189
|
|
|
190
|
+
## Background Dispatch (Research Only)
|
|
191
|
+
|
|
192
|
+
When the orchestrator is available, dispatch research (architecture scan, existing patterns, stack analysis) to a background agent before creating the plan inline.
|
|
193
|
+
|
|
194
|
+
1. Check orchestrator health
|
|
195
|
+
2. If available: dispatch research agent via `skill-dispatcher.dispatch({ skill: 'plan-research', prompt: 'Scan project structure, existing patterns, tech stack, and recent changes. Return structured context for planning.' })`
|
|
196
|
+
3. When research completes, inject results into Step 1 (Load Context)
|
|
197
|
+
4. Steps 2+ (task breakdown, plan creation) always run inline - they need user review
|
|
198
|
+
5. If orchestrator unavailable, run all steps inline as before
|
|
199
|
+
|
|
200
|
+
Override: `--inline` flag forces all steps inline.
|
|
201
|
+
|
|
190
202
|
## CodeDB Acceleration
|
|
191
203
|
|
|
192
204
|
When CodeDB is available (`.mcp.json` has a `codedb` server), use these tools in the scan/search steps below. If CodeDB is unavailable, fall back to Grep/Glob/Read.
|
|
@@ -15,6 +15,18 @@ It also runs:
|
|
|
15
15
|
- After any multi-file change
|
|
16
16
|
- Before recommending a commit or push
|
|
17
17
|
|
|
18
|
+
## Background Dispatch
|
|
19
|
+
|
|
20
|
+
When the orchestrator is available (`curl -sf http://localhost:3100/health`), dispatch this command to a background agent session instead of running inline.
|
|
21
|
+
|
|
22
|
+
1. Check orchestrator health
|
|
23
|
+
2. If available: package the full skill prompt with project context (branch, changed files, current phase) and dispatch via `skill-dispatcher.dispatch({ skill: 'preflight', prompt, project })`
|
|
24
|
+
3. Report to user: "Dispatched preflight to background session ses_XXXX. Results will appear when complete."
|
|
25
|
+
4. When session completes, capture result via `skill-dispatcher.captureResult()` and display summary
|
|
26
|
+
5. If orchestrator unavailable, fall back to inline execution (existing behavior below)
|
|
27
|
+
|
|
28
|
+
Override: `--inline` flag forces inline execution even when orchestrator is available.
|
|
29
|
+
|
|
18
30
|
## CodeDB Acceleration
|
|
19
31
|
|
|
20
32
|
When CodeDB is available (`.mcp.json` has a `codedb` server), use these tools in the scan/search steps below. If CodeDB is unavailable, fall back to Grep/Glob/Read.
|
|
@@ -17,6 +17,18 @@ Same fixes as `/tlc:cleanup` but:
|
|
|
17
17
|
/tlc:refactor
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
## Background Dispatch
|
|
21
|
+
|
|
22
|
+
When the orchestrator is available (`curl -sf http://localhost:3100/health`), dispatch this command to a background agent session instead of running inline.
|
|
23
|
+
|
|
24
|
+
1. Check orchestrator health
|
|
25
|
+
2. If available: package the full skill prompt with project context (branch, changed files, current phase) and dispatch via `skill-dispatcher.dispatch({ skill: 'refactor', prompt, project })`
|
|
26
|
+
3. Report to user: "Dispatched refactor to background session ses_XXXX. Results will appear when complete."
|
|
27
|
+
4. When session completes, capture result via `skill-dispatcher.captureResult()` and display summary
|
|
28
|
+
5. If orchestrator unavailable, fall back to inline execution (existing behavior below)
|
|
29
|
+
|
|
30
|
+
Override: `--inline` flag forces inline execution even when orchestrator is available.
|
|
31
|
+
|
|
20
32
|
## CodeDB Acceleration
|
|
21
33
|
|
|
22
34
|
When CodeDB is available (`.mcp.json` has a `codedb` server), use these tools in the scan/search steps below. If CodeDB is unavailable, fall back to Grep/Glob/Read.
|
|
@@ -18,7 +18,19 @@ Review a GitHub/GitLab pull request for TLC compliance.
|
|
|
18
18
|
/tlc:review-pr # Review current PR (if on PR branch)
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## Background Dispatch
|
|
22
|
+
|
|
23
|
+
When the orchestrator is available (`curl -sf http://localhost:3100/health`), dispatch this command to a background agent session instead of running inline.
|
|
24
|
+
|
|
25
|
+
1. Check orchestrator health
|
|
26
|
+
2. If available: package the full skill prompt with project context (branch, changed files, current phase) and dispatch via `skill-dispatcher.dispatch({ skill: 'review-pr', prompt, project })`
|
|
27
|
+
3. Report to user: "Dispatched review-pr to background session ses_XXXX. Results will appear when complete."
|
|
28
|
+
4. When session completes, capture result via `skill-dispatcher.captureResult()` and display summary
|
|
29
|
+
5. If orchestrator unavailable, fall back to inline execution (existing behavior below)
|
|
30
|
+
|
|
31
|
+
Override: `--inline` flag forces inline execution even when orchestrator is available.
|
|
32
|
+
|
|
33
|
+
## Process
|
|
22
34
|
|
|
23
35
|
### Step 1: Fetch PR Information
|
|
24
36
|
|
|
@@ -174,6 +174,18 @@ TLC automatically uses ALL providers configured for the `review` capability in `
|
|
|
174
174
|
/tlc:review --base dev # Review vs different base branch
|
|
175
175
|
```
|
|
176
176
|
|
|
177
|
+
## Background Dispatch
|
|
178
|
+
|
|
179
|
+
When the orchestrator is available (`curl -sf http://localhost:3100/health`), dispatch this command to a background agent session instead of running inline.
|
|
180
|
+
|
|
181
|
+
1. Check orchestrator health
|
|
182
|
+
2. If available: package the full skill prompt with project context (branch, changed files, current phase) and dispatch via `skill-dispatcher.dispatch({ skill: 'review', prompt, project })`
|
|
183
|
+
3. Report to user: "Dispatched review to background session ses_XXXX. Results will appear when complete."
|
|
184
|
+
4. When session completes, capture result via `skill-dispatcher.captureResult()` and display summary
|
|
185
|
+
5. If orchestrator unavailable, fall back to inline execution (existing behavior below)
|
|
186
|
+
|
|
187
|
+
Override: `--inline` flag forces inline execution even when orchestrator is available.
|
|
188
|
+
|
|
177
189
|
## CodeDB Acceleration
|
|
178
190
|
|
|
179
191
|
When CodeDB is available (`.mcp.json` has a `codedb` server), use these tools in the scan/search steps below. If CodeDB is unavailable, fall back to Grep/Glob/Read.
|
|
@@ -16,7 +16,19 @@ Run security audit on project dependencies and display vulnerabilities.
|
|
|
16
16
|
/tlc:security
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## Background Dispatch
|
|
20
|
+
|
|
21
|
+
When the orchestrator is available (`curl -sf http://localhost:3100/health`), dispatch this command to a background agent session instead of running inline.
|
|
22
|
+
|
|
23
|
+
1. Check orchestrator health
|
|
24
|
+
2. If available: package the full skill prompt with project context (branch, changed files, current phase) and dispatch via `skill-dispatcher.dispatch({ skill: 'security', prompt, project })`
|
|
25
|
+
3. Report to user: "Dispatched security to background session ses_XXXX. Results will appear when complete."
|
|
26
|
+
4. When session completes, capture result via `skill-dispatcher.captureResult()` and display summary
|
|
27
|
+
5. If orchestrator unavailable, fall back to inline execution (existing behavior below)
|
|
28
|
+
|
|
29
|
+
Override: `--inline` flag forces inline execution even when orchestrator is available.
|
|
30
|
+
|
|
31
|
+
## Process
|
|
20
32
|
|
|
21
33
|
### Step 1: Detect Package Manager
|
|
22
34
|
|
|
@@ -19,7 +19,13 @@ If no phase specified, shows overall test status.
|
|
|
19
19
|
- If no manifest exists, fall back to current-repo-only status
|
|
20
20
|
2. **Detect test framework** (Vitest, Jest, pytest, etc.)
|
|
21
21
|
3. **Run the test suite**
|
|
22
|
-
4. **
|
|
22
|
+
4. **Check active background agent sessions**
|
|
23
|
+
- Read `.tlc/.active-sessions.json` when present
|
|
24
|
+
- Query live session state for each active background session
|
|
25
|
+
- Use the shared `session-status` display functions for formatting session rows
|
|
26
|
+
- Show each running background agent with: skill name, elapsed time, session ID, and monitor state
|
|
27
|
+
- Mark stuck or errored sessions with `[!]`
|
|
28
|
+
5. **Report results** with next action
|
|
23
29
|
|
|
24
30
|
When workspace mode is active, include a one-line summary such as:
|
|
25
31
|
|
|
@@ -44,9 +50,22 @@ Test Status
|
|
|
44
50
|
───────────
|
|
45
51
|
[TLC] 142 tests | [CORE] 38 tests | [SA] 67 tests
|
|
46
52
|
|
|
53
|
+
Background Agents:
|
|
54
|
+
[TLC] review ses_abc123 2m30s running
|
|
55
|
+
[TLC] watchci ses_def456 15m running
|
|
56
|
+
[CORE] build ses_ghi789 5m stuck [!]
|
|
57
|
+
|
|
47
58
|
Ready for: /tlc:verify in the active repo
|
|
48
59
|
```
|
|
49
60
|
|
|
61
|
+
When active background sessions exist, always include a `Background Agents:` section after the test summary. Prefer session-status formatting helpers so the output stays aligned with other orchestration views.
|
|
62
|
+
|
|
63
|
+
Alerting rules:
|
|
64
|
+
|
|
65
|
+
- Show `[!]` for `stuck` sessions
|
|
66
|
+
- Show `[!]` for `errored` sessions
|
|
67
|
+
- Include the monitor state verbatim (`running`, `stuck`, `budget_exhausted`, `crashed`, etc.)
|
|
68
|
+
|
|
50
69
|
**Some failing:**
|
|
51
70
|
```
|
|
52
71
|
Test Status
|
|
@@ -17,6 +17,18 @@ Verify the phase automatically from its plan acceptance criteria, then leave onl
|
|
|
17
17
|
|
|
18
18
|
If no phase number, auto-detect current phase.
|
|
19
19
|
|
|
20
|
+
## Background Dispatch
|
|
21
|
+
|
|
22
|
+
When the orchestrator is available (`curl -sf http://localhost:3100/health`), dispatch this command to a background agent session instead of running inline.
|
|
23
|
+
|
|
24
|
+
1. Check orchestrator health
|
|
25
|
+
2. If available: package the full skill prompt with project context (branch, changed files, current phase) and dispatch via `skill-dispatcher.dispatch({ skill: 'verify', prompt, project })`
|
|
26
|
+
3. Report to user: "Dispatched verify to background session ses_XXXX. Results will appear when complete."
|
|
27
|
+
4. When session completes, capture result via `skill-dispatcher.captureResult()` and display summary
|
|
28
|
+
5. If orchestrator unavailable, fall back to inline execution (existing behavior below)
|
|
29
|
+
|
|
30
|
+
Override: `--inline` flag forces inline execution even when orchestrator is available.
|
|
31
|
+
|
|
20
32
|
## Process
|
|
21
33
|
|
|
22
34
|
### Step 1: Load the Phase Plan
|
|
@@ -19,6 +19,18 @@ This is the "I pushed, now babysit CI for me" command.
|
|
|
19
19
|
/tlc:watchci 3 # max 3 fix attempts (default: 5)
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
## Background Dispatch
|
|
23
|
+
|
|
24
|
+
When the orchestrator is available (`curl -sf http://localhost:3100/health`), dispatch this command to a background agent session instead of running inline.
|
|
25
|
+
|
|
26
|
+
1. Check orchestrator health
|
|
27
|
+
2. If available: package the full skill prompt with project context (branch, changed files, current phase) and dispatch via `skill-dispatcher.dispatch({ skill: 'watchci', prompt, project })`
|
|
28
|
+
3. Report to user: "Dispatched watchci to background session ses_XXXX. Results will appear when complete."
|
|
29
|
+
4. When session completes, capture result via `skill-dispatcher.captureResult()` and display summary
|
|
30
|
+
5. If orchestrator unavailable, fall back to inline execution (existing behavior below)
|
|
31
|
+
|
|
32
|
+
Override: `--inline` flag forces inline execution even when orchestrator is available.
|
|
33
|
+
|
|
22
34
|
## Process
|
|
23
35
|
|
|
24
36
|
### Step 1: Find the Active Run
|
package/package.json
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
const fs = require('fs/promises');
|
|
2
2
|
|
|
3
|
+
const ACTIONABLE_MONITOR_STATES = new Map([
|
|
4
|
+
['stuck', { suggestedAction: 'retry' }],
|
|
5
|
+
['budget_exhausted', { suggestedAction: 'retry' }],
|
|
6
|
+
]);
|
|
7
|
+
|
|
8
|
+
const FAILURE_MONITOR_STATES = new Map([
|
|
9
|
+
['crashed', 'session crashed and needs investigation'],
|
|
10
|
+
['errored', 'session errored and needs investigation'],
|
|
11
|
+
['loop_detected', 'session entered a loop and needs investigation'],
|
|
12
|
+
['timed_out', 'session timed out and needs investigation'],
|
|
13
|
+
]);
|
|
14
|
+
|
|
3
15
|
async function readActiveSessions(activeSessionsPath) {
|
|
4
16
|
try {
|
|
5
17
|
const raw = await fs.readFile(activeSessionsPath, 'utf8');
|
|
@@ -18,6 +30,19 @@ async function writeActiveSessions(activeSessionsPath, sessions) {
|
|
|
18
30
|
await fs.writeFile(activeSessionsPath, JSON.stringify(sessions, null, 2));
|
|
19
31
|
}
|
|
20
32
|
|
|
33
|
+
function getNormalizedStatus(payload) {
|
|
34
|
+
if (!payload || typeof payload !== 'object') {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const monitorState = payload.monitorState
|
|
39
|
+
|| payload.monitor?.state
|
|
40
|
+
|| payload.metadata?.monitorState
|
|
41
|
+
|| null;
|
|
42
|
+
|
|
43
|
+
return String(monitorState || payload.status || '').trim().toLowerCase() || null;
|
|
44
|
+
}
|
|
45
|
+
|
|
21
46
|
async function checkCompletions({
|
|
22
47
|
activeSessionsPath,
|
|
23
48
|
orchestratorUrl,
|
|
@@ -28,12 +53,14 @@ async function checkCompletions({
|
|
|
28
53
|
return {
|
|
29
54
|
completions: [],
|
|
30
55
|
failures: [],
|
|
56
|
+
actionable: [],
|
|
31
57
|
stillRunning: 0,
|
|
32
58
|
};
|
|
33
59
|
}
|
|
34
60
|
|
|
35
61
|
const completions = [];
|
|
36
62
|
const failures = [];
|
|
63
|
+
const actionable = [];
|
|
37
64
|
const remainingSessions = [];
|
|
38
65
|
|
|
39
66
|
let orchestratorReachable = true;
|
|
@@ -51,13 +78,14 @@ async function checkCompletions({
|
|
|
51
78
|
}
|
|
52
79
|
|
|
53
80
|
const payload = await response.json();
|
|
81
|
+
const status = getNormalizedStatus(payload);
|
|
54
82
|
|
|
55
|
-
if (
|
|
83
|
+
if (status === 'completed') {
|
|
56
84
|
completions.push(session);
|
|
57
85
|
continue;
|
|
58
86
|
}
|
|
59
87
|
|
|
60
|
-
if (
|
|
88
|
+
if (status === 'failed') {
|
|
61
89
|
failures.push({
|
|
62
90
|
...session,
|
|
63
91
|
...(payload.reason ? { reason: payload.reason } : {}),
|
|
@@ -65,6 +93,26 @@ async function checkCompletions({
|
|
|
65
93
|
continue;
|
|
66
94
|
}
|
|
67
95
|
|
|
96
|
+
if (ACTIONABLE_MONITOR_STATES.has(status)) {
|
|
97
|
+
actionable.push({
|
|
98
|
+
...session,
|
|
99
|
+
status,
|
|
100
|
+
actionable: true,
|
|
101
|
+
suggestedAction: ACTIONABLE_MONITOR_STATES.get(status).suggestedAction,
|
|
102
|
+
});
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (FAILURE_MONITOR_STATES.has(status)) {
|
|
107
|
+
failures.push({
|
|
108
|
+
...session,
|
|
109
|
+
status,
|
|
110
|
+
actionable: false,
|
|
111
|
+
failureReason: FAILURE_MONITOR_STATES.get(status),
|
|
112
|
+
});
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
|
|
68
116
|
remainingSessions.push(session);
|
|
69
117
|
} catch (error) {
|
|
70
118
|
if (!orchestratorReachable) {
|
|
@@ -82,6 +130,7 @@ async function checkCompletions({
|
|
|
82
130
|
return {
|
|
83
131
|
completions: [],
|
|
84
132
|
failures: [],
|
|
133
|
+
actionable: [],
|
|
85
134
|
stillRunning: -1,
|
|
86
135
|
error: 'orchestrator unreachable',
|
|
87
136
|
};
|
|
@@ -92,6 +141,7 @@ async function checkCompletions({
|
|
|
92
141
|
return {
|
|
93
142
|
completions,
|
|
94
143
|
failures,
|
|
144
|
+
actionable,
|
|
95
145
|
stillRunning: remainingSessions.length,
|
|
96
146
|
};
|
|
97
147
|
}
|
|
@@ -49,6 +49,7 @@ describe('completion-checker', () => {
|
|
|
49
49
|
expect(result).toEqual({
|
|
50
50
|
completions: [],
|
|
51
51
|
failures: [],
|
|
52
|
+
actionable: [],
|
|
52
53
|
stillRunning: 0,
|
|
53
54
|
});
|
|
54
55
|
expect(fetch).not.toHaveBeenCalled();
|
|
@@ -74,6 +75,7 @@ describe('completion-checker', () => {
|
|
|
74
75
|
expect(result).toEqual({
|
|
75
76
|
completions: [makeSession()],
|
|
76
77
|
failures: [],
|
|
78
|
+
actionable: [],
|
|
77
79
|
stillRunning: 0,
|
|
78
80
|
});
|
|
79
81
|
expect(JSON.parse(fs.readFileSync(activeSessionsPath, 'utf8'))).toEqual([]);
|
|
@@ -97,6 +99,7 @@ describe('completion-checker', () => {
|
|
|
97
99
|
expect(result).toEqual({
|
|
98
100
|
completions: [],
|
|
99
101
|
failures: [{ ...makeSession(), reason: 'Tests failed' }],
|
|
102
|
+
actionable: [],
|
|
100
103
|
stillRunning: 0,
|
|
101
104
|
});
|
|
102
105
|
expect(JSON.parse(fs.readFileSync(activeSessionsPath, 'utf8'))).toEqual([]);
|
|
@@ -131,11 +134,70 @@ describe('completion-checker', () => {
|
|
|
131
134
|
expect(result).toEqual({
|
|
132
135
|
completions: [completed],
|
|
133
136
|
failures: [{ ...failed, reason: 'Rejected' }],
|
|
137
|
+
actionable: [],
|
|
134
138
|
stillRunning: 1,
|
|
135
139
|
});
|
|
136
140
|
expect(JSON.parse(fs.readFileSync(activeSessionsPath, 'utf8'))).toEqual([running]);
|
|
137
141
|
});
|
|
138
142
|
|
|
143
|
+
it.each([
|
|
144
|
+
['stuck', { status: 'stuck', actionable: true, suggestedAction: 'retry' }],
|
|
145
|
+
['budget_exhausted', { status: 'budget_exhausted', actionable: true, suggestedAction: 'retry' }],
|
|
146
|
+
])('reports actionable monitor state %s', async (state, expected) => {
|
|
147
|
+
const activeSessionsPath = makeActiveSessionsPath();
|
|
148
|
+
const session = makeSession();
|
|
149
|
+
writeSessionsFile(activeSessionsPath, [session]);
|
|
150
|
+
|
|
151
|
+
const fetch = vi.fn().mockResolvedValue({
|
|
152
|
+
ok: true,
|
|
153
|
+
json: async () => ({ status: state }),
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const result = await checkCompletions({
|
|
157
|
+
activeSessionsPath,
|
|
158
|
+
orchestratorUrl: 'http://orchestrator.test',
|
|
159
|
+
fetch,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
expect(result).toEqual({
|
|
163
|
+
completions: [],
|
|
164
|
+
failures: [],
|
|
165
|
+
actionable: [{ ...session, ...expected }],
|
|
166
|
+
stillRunning: 0,
|
|
167
|
+
});
|
|
168
|
+
expect(JSON.parse(fs.readFileSync(activeSessionsPath, 'utf8'))).toEqual([]);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it.each([
|
|
172
|
+
['crashed', 'session crashed and needs investigation'],
|
|
173
|
+
['errored', 'session errored and needs investigation'],
|
|
174
|
+
['loop_detected', 'session entered a loop and needs investigation'],
|
|
175
|
+
['timed_out', 'session timed out and needs investigation'],
|
|
176
|
+
])('reports failure monitor state %s', async (state, failureReason) => {
|
|
177
|
+
const activeSessionsPath = makeActiveSessionsPath();
|
|
178
|
+
const session = makeSession();
|
|
179
|
+
writeSessionsFile(activeSessionsPath, [session]);
|
|
180
|
+
|
|
181
|
+
const fetch = vi.fn().mockResolvedValue({
|
|
182
|
+
ok: true,
|
|
183
|
+
json: async () => ({ status: state }),
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
const result = await checkCompletions({
|
|
187
|
+
activeSessionsPath,
|
|
188
|
+
orchestratorUrl: 'http://orchestrator.test',
|
|
189
|
+
fetch,
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
expect(result).toEqual({
|
|
193
|
+
completions: [],
|
|
194
|
+
failures: [{ ...session, status: state, actionable: false, failureReason }],
|
|
195
|
+
actionable: [],
|
|
196
|
+
stillRunning: 0,
|
|
197
|
+
});
|
|
198
|
+
expect(JSON.parse(fs.readFileSync(activeSessionsPath, 'utf8'))).toEqual([]);
|
|
199
|
+
});
|
|
200
|
+
|
|
139
201
|
it('returns an error result when the orchestrator is unreachable', async () => {
|
|
140
202
|
const activeSessionsPath = makeActiveSessionsPath();
|
|
141
203
|
const session = makeSession();
|
|
@@ -152,6 +214,7 @@ describe('completion-checker', () => {
|
|
|
152
214
|
expect(result).toEqual({
|
|
153
215
|
completions: [],
|
|
154
216
|
failures: [],
|
|
217
|
+
actionable: [],
|
|
155
218
|
stillRunning: -1,
|
|
156
219
|
error: 'orchestrator unreachable',
|
|
157
220
|
});
|
|
@@ -170,6 +233,7 @@ describe('completion-checker', () => {
|
|
|
170
233
|
expect(result).toEqual({
|
|
171
234
|
completions: [],
|
|
172
235
|
failures: [],
|
|
236
|
+
actionable: [],
|
|
173
237
|
stillRunning: 0,
|
|
174
238
|
});
|
|
175
239
|
expect(fs.existsSync(activeSessionsPath)).toBe(false);
|