tlc-claude-code 2.5.0 → 2.6.1

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.
Files changed (76) hide show
  1. package/.claude/commands/tlc/autofix.md +34 -1
  2. package/.claude/commands/tlc/build.md +164 -6
  3. package/.claude/commands/tlc/ci.md +178 -414
  4. package/.claude/commands/tlc/coverage.md +34 -0
  5. package/.claude/commands/tlc/deploy.md +19 -6
  6. package/.claude/commands/tlc/discuss.md +34 -0
  7. package/.claude/commands/tlc/docs.md +35 -1
  8. package/.claude/commands/tlc/e2e.md +300 -0
  9. package/.claude/commands/tlc/edge-cases.md +35 -1
  10. package/.claude/commands/tlc/init.md +38 -8
  11. package/.claude/commands/tlc/new-project.md +46 -4
  12. package/.claude/commands/tlc/plan.md +33 -0
  13. package/.claude/commands/tlc/quick.md +33 -0
  14. package/.claude/commands/tlc/release.md +85 -135
  15. package/.claude/commands/tlc/restore.md +14 -0
  16. package/.claude/commands/tlc/review.md +76 -1
  17. package/.claude/commands/tlc/tlc.md +134 -0
  18. package/.claude/commands/tlc/verify.md +64 -65
  19. package/.claude/commands/tlc/watchci.md +10 -0
  20. package/.claude/hooks/tlc-block-tools.sh +13 -0
  21. package/.claude/hooks/tlc-session-init.sh +29 -0
  22. package/CODING-STANDARDS.md +35 -10
  23. package/package.json +1 -1
  24. package/server/lib/block-tools-hook.js +23 -0
  25. package/server/lib/e2e/acceptance-parser.js +132 -0
  26. package/server/lib/e2e/acceptance-parser.test.js +110 -0
  27. package/server/lib/e2e/framework-detector.js +47 -0
  28. package/server/lib/e2e/framework-detector.test.js +94 -0
  29. package/server/lib/e2e/log-assertions.js +107 -0
  30. package/server/lib/e2e/log-assertions.test.js +68 -0
  31. package/server/lib/e2e/test-generator.js +159 -0
  32. package/server/lib/e2e/test-generator.test.js +121 -0
  33. package/server/lib/e2e/verify-runner.js +191 -0
  34. package/server/lib/e2e/verify-runner.test.js +167 -0
  35. package/server/lib/hooks/block-tools-hook.test.js +54 -0
  36. package/server/lib/orchestration/cli-dispatch.js +16 -1
  37. package/server/lib/orchestration/cli-dispatch.test.js +94 -8
  38. package/server/lib/orchestration/completion-checker.js +101 -0
  39. package/server/lib/orchestration/completion-checker.test.js +177 -0
  40. package/server/lib/orchestration/result-verifier.js +143 -0
  41. package/server/lib/orchestration/result-verifier.test.js +291 -0
  42. package/server/lib/orchestration/session-dispatcher.js +99 -0
  43. package/server/lib/orchestration/session-dispatcher.test.js +215 -0
  44. package/server/lib/orchestration/session-status.js +147 -0
  45. package/server/lib/orchestration/session-status.test.js +130 -0
  46. package/server/lib/release/agent-runner-updates.js +24 -0
  47. package/server/lib/release/agent-runner-updates.test.js +22 -0
  48. package/server/lib/release/changelog-generator.js +142 -0
  49. package/server/lib/release/changelog-generator.test.js +113 -0
  50. package/server/lib/release/ci-watcher.js +83 -0
  51. package/server/lib/release/ci-watcher.test.js +81 -0
  52. package/server/lib/release/health-checker.js +111 -0
  53. package/server/lib/release/health-checker.test.js +121 -0
  54. package/server/lib/release/release-pipeline.js +187 -0
  55. package/server/lib/release/release-pipeline.test.js +262 -0
  56. package/server/lib/release/version-bumper.js +183 -0
  57. package/server/lib/release/version-bumper.test.js +142 -0
  58. package/server/lib/routing-preamble.integration.test.js +12 -0
  59. package/server/lib/routing-preamble.js +13 -2
  60. package/server/lib/routing-preamble.test.js +49 -0
  61. package/server/lib/scaffolding/ci-detector.js +139 -0
  62. package/server/lib/scaffolding/ci-detector.test.js +198 -0
  63. package/server/lib/scaffolding/ci-scaffolder.js +347 -0
  64. package/server/lib/scaffolding/ci-scaffolder.test.js +157 -0
  65. package/server/lib/scaffolding/deploy-detector.js +135 -0
  66. package/server/lib/scaffolding/deploy-detector.test.js +106 -0
  67. package/server/lib/scaffolding/health-scaffold.js +374 -0
  68. package/server/lib/scaffolding/health-scaffold.test.js +99 -0
  69. package/server/lib/scaffolding/logger-scaffold.js +196 -0
  70. package/server/lib/scaffolding/logger-scaffold.test.js +146 -0
  71. package/server/lib/scaffolding/migration-detector.js +78 -0
  72. package/server/lib/scaffolding/migration-detector.test.js +127 -0
  73. package/server/lib/scaffolding/snapshot-manager.js +142 -0
  74. package/server/lib/scaffolding/snapshot-manager.test.js +225 -0
  75. package/server/lib/task-router-config.js +50 -20
  76. package/server/lib/task-router-config.test.js +29 -15
@@ -95,7 +95,40 @@ process.stdout.write(JSON.stringify(result));" 2>/dev/null
95
95
  - Execute inline (Claude) AND dispatch to CLI models simultaneously
96
96
  - Collect and merge results
97
97
 
98
- **Override:** Pass `--model <name>` to route this specific run to a different model.
98
+ **Override:** Pass `--model <name>` to route this specific run to a different model.
99
+
100
+ After `resolveRouting` returns, immediately write `.tlc/.autofix-routing-active` with the active provider name from `models[0]` before doing any other autofix work. Remove `.tlc/.autofix-routing-active` on completion, cancellation, or failure cleanup.
101
+
102
+ **Routing decision:**
103
+ - If routing says external provider (`models[0] !== 'claude'`), follow **ONLY ORCHESTRATOR MODE** below.
104
+ - If routing says Claude (`models[0] === 'claude'`), follow **INLINE MODE** below.
105
+
106
+ ## ORCHESTRATOR MODE
107
+
108
+ Use this mode only when `models[0]` is **NOT** `claude`.
109
+
110
+ Claude does not execute the autofix instructions inline in this path. Claude acts as the orchestrator for the routed provider run:
111
+
112
+ 1. Claude acts as the orchestrator for routed test-failure recovery rather than applying the autofix flow inline.
113
+ 2. Gather the failing test context, error output, project conventions, and relevant files before dispatching each fix attempt.
114
+ 3. Dispatch focused repair prompts through the provider CLI path, using `codex exec` for Codex-style providers or `gemini -p` for Gemini-style providers, preferably via the shared dispatch layer when available.
115
+ 4. Verify every routed fix before accepting it:
116
+ - Confirm the proposed change addresses the actual failure mode rather than masking symptoms.
117
+ - Confirm the relevant tests were re-run or that the provider clearly identified what still needs verification.
118
+ - Reject speculative or unverified fixes and dispatch a narrower retry using the latest failure data.
119
+ 5. Continue the dispatch, verify, and retry loop until the targeted failures are fixed or an explicit blocker is reported.
120
+ 6. Handle failures explicitly:
121
+ - If dispatch fails because of model mismatch, auth, or missing CLI, check `.tlc/.router-state.json` for the provider's actual available model and retry once with the corrected model.
122
+ - If retry still fails, stop and report the exact failure to the user. Do not silently fall back to Claude inline execution.
123
+ - If a routed fix worsens the state or returns partial edits, stop that branch and issue a corrective follow-up with the exact observed regression.
124
+ 7. When finished, display the routed autofix result, persist any captured memory, remove `.tlc/.autofix-routing-active`, and stop. Do **not** execute Inline Mode afterward.
125
+
126
+ ## INLINE MODE
127
+
128
+ Use this mode only when `models[0]` **IS** `claude`.
129
+
130
+ The existing autofix instructions below are the Inline Mode instructions and should be followed unchanged.
131
+
99
132
 
100
133
  ## What This Does
101
134
 
@@ -103,6 +103,116 @@ process.stdout.write(JSON.stringify(result));" 2>/dev/null
103
103
 
104
104
  **Override:** Pass `--model <name>` to route this specific run to a different model.
105
105
 
106
+ After `resolveRouting` returns, immediately write `.tlc/.build-routing-active` with the active provider name from `models[0]` before doing any other build work. Remove `.tlc/.build-routing-active` on completion, cancellation, or failure cleanup.
107
+
108
+ **Routing decision:**
109
+ - If routing says external provider (`models[0] !== 'claude'`), follow **ONLY Orchestrator Mode** below.
110
+ - If routing says Claude (`models[0] === 'claude'`), follow **Inline Mode** below.
111
+
112
+ ## ORCHESTRATOR MODE
113
+
114
+ Use this mode only when `models[0]` is **NOT** `claude`.
115
+
116
+ Claude is the **project manager**. Claude reads the plan, breaks tasks into small prompts, and dispatches each to the tlc-core orchestrator. Claude does NOT write code.
117
+
118
+ ### Step O1: Read the Plan
119
+
120
+ Read `.planning/phases/{N}-PLAN.md`. Extract each task's goal, files, acceptance criteria, and test cases.
121
+
122
+ ### Step O2: Check Orchestrator Health
123
+
124
+ ```bash
125
+ curl -sf http://localhost:3100/health
126
+ ```
127
+
128
+ If healthy, dispatch via orchestrator (Step O3). If unreachable, fall back to direct Codex dispatch via Bash (Step O3-fallback).
129
+
130
+ ### Step O3: Dispatch Tasks to Orchestrator
131
+
132
+ For each independent task, dispatch via the orchestrator API:
133
+
134
+ ```bash
135
+ curl -s -X POST http://localhost:3100/sessions \
136
+ -H 'Content-Type: application/json' \
137
+ -d '{
138
+ "project": "<project-name>",
139
+ "pool": "local-tmux",
140
+ "command": "<provider>",
141
+ "prompt": "<task prompt — one clear action, explicit file paths, under 500 words>"
142
+ }'
143
+ ```
144
+
145
+ - `project`: the repo directory name under `/workspace/` (e.g., `Tools/TLC`)
146
+ - `command`: the provider from routing result (e.g., `codex`)
147
+ - `prompt`: small focused prompt for one task — include file paths, acceptance criteria, test command
148
+
149
+ **Save each returned session ID** to `.tlc/.active-sessions.json`:
150
+
151
+ ```bash
152
+ node -e "
153
+ const fs = require('fs');
154
+ const path = '.tlc/.active-sessions.json';
155
+ const existing = fs.existsSync(path) ? JSON.parse(fs.readFileSync(path, 'utf8')) : [];
156
+ existing.push({ sessionId: '<id>', taskName: '<task>', startedAt: new Date().toISOString() });
157
+ fs.writeFileSync(path, JSON.stringify(existing, null, 2));
158
+ "
159
+ ```
160
+
161
+ ### Step O3-fallback: Direct Dispatch (No Orchestrator)
162
+
163
+ If orchestrator is down, dispatch directly via tmux on the host:
164
+
165
+ ```bash
166
+ tmux new-session -d -s <task-id> -c $(pwd)
167
+ tmux send-keys -t <task-id> "/opt/homebrew/bin/codex --full-auto '<prompt>'" Enter
168
+ ```
169
+
170
+ ### Step O4: Report and Free
171
+
172
+ After dispatching all tasks, report:
173
+
174
+ ```
175
+ Dispatched N tasks to orchestrator:
176
+ ses_abc123 Task 1: Create schema codex running
177
+ ses_def456 Task 2: Add validation codex running
178
+
179
+ Run /tlc:status to check progress.
180
+ I'm free — what would you like to work on?
181
+ ```
182
+
183
+ **STOP HERE.** Do not write code. Do not execute inline mode. Claude is the PM, not the coder.
184
+
185
+ ### Step O5: Monitor (When User Asks)
186
+
187
+ When the user asks for status or agents complete, check:
188
+
189
+ ```bash
190
+ # Check all sessions
191
+ curl -s http://localhost:3100/sessions | node -e "
192
+ const d=require('fs').readFileSync('/dev/stdin','utf8');
193
+ JSON.parse(d).forEach(s=>console.log(s.id, s.status, s.project));
194
+ "
195
+
196
+ # Check specific session output (inside container)
197
+ docker exec tlc-agent-runner tmux capture-pane -t <session_id> -p -S -20
198
+ ```
199
+
200
+ Auto-approve any prompts found in tmux sessions:
201
+
202
+ ```bash
203
+ docker exec tlc-agent-runner tmux send-keys -t <session_id> Enter
204
+ ```
205
+
206
+ ### Step O6: Cleanup
207
+
208
+ When all tasks complete, remove `.tlc/.build-routing-active` and report results.
209
+
210
+ ## INLINE MODE
211
+
212
+ Use this mode only when `models[0]` **IS** `claude`.
213
+
214
+ The existing build instructions below are the Inline Mode instructions and should be followed unchanged.
215
+
106
216
  ## Engineering Standards
107
217
 
108
218
  **Code like a senior engineer with 15+ years experience.** Every line should reflect:
@@ -391,7 +501,7 @@ All agents use **opus**. No opus, no opus. Cost is not a concern — quality is.
391
501
  **Provider round-robin (worktree mode):**
392
502
  Tasks alternate between available providers. If Claude + Codex are both available, odd tasks go to Claude, even to Codex. Respects router state — never dispatches to unavailable providers.
393
503
 
394
- ### Step 1b: Execute Parallel Build
504
+ ### Step 1c: Execute Parallel Build
395
505
 
396
506
  **Worktree + Tmux mode** (multi-provider):
397
507
 
@@ -519,7 +629,7 @@ After merge-back:
519
629
  4. If clean, the integration branch is ready for a single PR to main
520
630
  5. Continue to Step 8 (verification)
521
631
 
522
- ### Step 1c: Sync and Claim (Multi-User, Sequential Only)
632
+ ### Step 1d: Sync and Claim (Multi-User, Sequential Only)
523
633
 
524
634
  **Note:** Skip this step if using Overdrive mode - agents handle claiming automatically.
525
635
 
@@ -551,6 +661,19 @@ Before starting work, coordinate with teammates:
551
661
 
552
662
  If no markers exist in PLAN.md, skip this step (single-user mode).
553
663
 
664
+ ### Step 1b: Migration Snapshot
665
+
666
+ Check for migration files in the current diff:
667
+ ```bash
668
+ MIGRATION_FILES=$(git diff --name-only main...HEAD | grep -E "prisma/migrations|drizzle/|migrations/.*\.(ts|js|sql)|alembic/versions" | grep -v "\.test\.")
669
+ ```
670
+
671
+ If `MIGRATION_FILES` is not empty:
672
+ 1. Detect DB connection from `.env` or config
673
+ 2. Take snapshot: run `server/lib/scaffolding/snapshot-manager.js takeSnapshot()`
674
+ 3. Report: `DB snapshot taken: .tlc/snapshots/{filename}. Run /tlc:restore to rollback if needed.`
675
+ 4. If snapshot fails (DB not running): warn but continue build
676
+
554
677
  ### Step 2: Detect Test Framework
555
678
 
556
679
  #### Check TLC Config First
@@ -705,7 +828,24 @@ def test_login_raises_for_invalid_password():
705
828
  login("user@test.com", "wrong")
706
829
  ```
707
830
 
708
- #### 4b. Run this test file
831
+ #### 4b. Generate E2E Tests
832
+
833
+ After writing the unit test file for the task, generate matching end-to-end coverage from the task's acceptance criteria in `PLAN.md`.
834
+
835
+ Process:
836
+ - Parse acceptance criteria for the current task from `PLAN.md` using `server/lib/e2e/acceptance-parser.js`
837
+ - Detect the existing E2E framework, or scaffold one if missing, using `server/lib/e2e/framework-detector.js`
838
+ - Generate E2E test files for the current task using `server/lib/e2e/test-generator.js`
839
+ - Place generated E2E coverage alongside the task's unit tests in the same red/green workflow
840
+
841
+ Requirements:
842
+ - E2E tests must map directly to acceptance criteria for the current task
843
+ - Generated files must follow the detected or scaffolded framework conventions
844
+ - If no E2E framework exists, scaffold it before generating tests
845
+ - E2E tests should be committed alongside the unit tests for that task
846
+ - Do NOT write implementation code while generating tests
847
+
848
+ #### 4c. Run this test file
709
849
 
710
850
  ```bash
711
851
  npm test -- tests/auth/login.test.ts # vitest
@@ -717,16 +857,18 @@ Verify:
717
857
  - ✅ Tests FAIL (not pass, not skip)
718
858
  - ❌ If import errors, add mocks/stubs and retry
719
859
 
720
- #### 4c. Commit this test file
860
+ #### 4d. Commit this test file
721
861
 
722
862
  ```bash
723
863
  git add tests/auth/login.test.ts
724
864
  git commit -m "test: add login tests (red) - phase {N}"
725
865
  ```
726
866
 
727
- #### 4d. Move to next task
867
+ If E2E files were generated for the task, stage and commit them in the same commit as the unit tests.
868
+
869
+ #### 4e. Move to next task
728
870
 
729
- Repeat 4a-4c for each task in the test plan.
871
+ Repeat 4a-4d for each task in the test plan.
730
872
 
731
873
  **Critical Rules:**
732
874
  - Tests must be **syntactically valid** and **runnable**
@@ -1051,6 +1193,14 @@ After user approval:
1051
1193
  # Push branch
1052
1194
  git push -u origin "$branchName"
1053
1195
 
1196
+ # Warn if the PR will have no automated CI checks
1197
+ node -e "const fs = require('fs');
1198
+ const { detectCI } = require('./server/lib/scaffolding/ci-detector.js');
1199
+ const result = detectCI({ projectDir: process.cwd(), fs });
1200
+ if (result.platform === 'none') {
1201
+ console.warn('No CI configured. PR will not have automated checks. Run /tlc:ci to set up.');
1202
+ }" 2>/dev/null
1203
+
1054
1204
  # Create PR with phase summary
1055
1205
  gh pr create \
1056
1206
  --base "$mainBranch" \
@@ -1068,6 +1218,14 @@ gh pr create \
1068
1218
  {test runner summary}"
1069
1219
  ```
1070
1220
 
1221
+ **Merge strategy:** When merging PRs, ALWAYS use `--merge` (not `--squash`):
1222
+ ```bash
1223
+ gh pr merge <number> --merge
1224
+ ```
1225
+ - `--merge` preserves commit history and shows the correct PR title
1226
+ - `--squash` only when the user explicitly asks for it (messy WIP branches)
1227
+ - Sync PRs (dev → test, test → main) MUST use `--merge` — never squash a sync
1228
+
1071
1229
  #### Step 11-gh: GitHub: Link PR to Project
1072
1230
 
1073
1231
  If GitHub sync is enabled, after the PR is created: