()
| 358 | // ─── Phase prompt injection ───────────────────────────────────────────────── |
| 359 | |
| 360 | phasePrompt() { |
| 361 | if (this.disabled) return ''; |
| 362 | |
| 363 | const reqProgress = this._loopActive && this._requirements.length > 0 |
| 364 | ? this._formatRequirementsChecklist() |
| 365 | : ''; |
| 366 | |
| 367 | if (this._phase === PHASES.IDLE) { |
| 368 | if (!this._loopActive || this._requirements.length === 0) return ''; |
| 369 | if (this.loopComplete()) { |
| 370 | return `\n\n[TDD LOOP: COMPLETE — all ${this._requirements.length} requirements fulfilled]\n${reqProgress}`; |
| 371 | } |
| 372 | if (this.allRequirementsDone()) { |
| 373 | return `\n\n[TDD LOOP: all tests green — run run_tests (full suite) to confirm no regressions]\n${reqProgress}`; |
| 374 | } |
| 375 | // There is an active requirement waiting for a cycle to begin |
| 376 | const active = this.activeRequirement(); |
| 377 | const current = active || this.pendingRequirements()[0]; |
| 378 | const nextText = current ? `"${current.text}"` : 'the next requirement'; |
| 379 | return `\n\n[TDD LOOP: ${this.doneRequirements().length}/${this._requirements.length} done — idle]\n${reqProgress}\nNext: write a failing test for ${nextText}, then call tdd_begin_cycle.`; |
| 380 | } |
| 381 | |
| 382 | const header = this._loopActive |
| 383 | ? `[TDD LOOP: ${this.doneRequirements().length}/${this._requirements.length} done — ${this._phase.toUpperCase()} phase]` |
| 384 | : `[TDD: ${this._phase.toUpperCase()} phase]`; |
| 385 | |
| 386 | let body = ''; |
| 387 | switch (this._phase) { |
| 388 | case PHASES.RED: |
| 389 | body = !this._redConfirmed |
| 390 | ? `Target test: "${this._targetTest}"\nYou MUST call run_tests (test_filter="${this._targetTest}") to confirm it FAILS before writing implementation.` |
| 391 | : `Target test: "${this._targetTest}" — RED confirmed.\nWrite the MINIMUM implementation to make it pass. Do NOT edit the test file.`; |
| 392 | break; |
| 393 | case PHASES.GREEN: |
| 394 | body = `Target test: "${this._targetTest}" is passing.\nDo NOT modify test files. Call tdd_advance to enter REFACTOR or skip to the next requirement.`; |
| 395 | break; |
| 396 | case PHASES.REFACTOR: |
| 397 | body = `Target test: "${this._targetTest}"\nStructural cleanup only. Call run_tests (full suite) then tdd_advance to complete this requirement.`; |
| 398 | break; |
| 399 | } |
| 400 | |
| 401 | return `\n\n${header}\n${reqProgress ? reqProgress + '\n' : ''}${body}`; |
| 402 | } |
| 403 | |
| 404 | // ─── Guards ──────────────────────────────────────────────────────────────── |
| 405 |
nothing calls this directly
no test coverage detected