prizmkit 1.1.69 → 1.1.72

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 (57) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/dev-pipeline/lib/common.sh +427 -0
  3. package/bundled/dev-pipeline/lib/heartbeat.sh +36 -0
  4. package/bundled/dev-pipeline/run-feature.sh +109 -29
  5. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +11 -12
  6. package/bundled/dev-pipeline/scripts/parse-stream-progress.py +160 -3
  7. package/bundled/dev-pipeline/scripts/update-feature-status.py +27 -3
  8. package/bundled/dev-pipeline/templates/agent-prompts/dev-implement.md +36 -22
  9. package/bundled/dev-pipeline/templates/agent-prompts/reviewer-review.md +1 -1
  10. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +24 -21
  11. package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +13 -26
  12. package/bundled/dev-pipeline/templates/sections/ac-verification-checklist.md +4 -10
  13. package/bundled/dev-pipeline/templates/sections/context-budget-rules.md +1 -0
  14. package/bundled/dev-pipeline/templates/sections/feature-context.md +16 -11
  15. package/bundled/dev-pipeline/templates/sections/phase-browser-verification-auto.md +17 -26
  16. package/bundled/dev-pipeline/templates/sections/phase-browser-verification-opencli.md +1 -1
  17. package/bundled/dev-pipeline/templates/sections/phase-browser-verification.md +1 -1
  18. package/bundled/dev-pipeline/templates/sections/phase-commit-full.md +11 -0
  19. package/bundled/dev-pipeline/templates/sections/phase-commit.md +11 -0
  20. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-base.md +1 -1
  21. package/bundled/dev-pipeline/templates/sections/phase-implement-agent.md +2 -9
  22. package/bundled/dev-pipeline/templates/sections/phase-implement-full.md +2 -9
  23. package/bundled/dev-pipeline/templates/sections/phase-implement-lite.md +8 -17
  24. package/bundled/dev-pipeline/templates/sections/phase-plan-lite.md +1 -1
  25. package/bundled/dev-pipeline/templates/sections/phase-review-full.md +1 -1
  26. package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +1 -1
  27. package/bundled/dev-pipeline/templates/sections/task-contract.md +34 -0
  28. package/bundled/dev-pipeline/templates/sections/test-failure-recovery-agent.md +27 -46
  29. package/bundled/dev-pipeline/templates/sections/test-failure-recovery-lite.md +27 -37
  30. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +13 -0
  31. package/bundled/dev-pipeline-windows/lib/common.ps1 +61 -1
  32. package/bundled/dev-pipeline-windows/lib/pipeline.ps1 +299 -14
  33. package/bundled/dev-pipeline-windows/scripts/generate-bootstrap-prompt.py +11 -12
  34. package/bundled/dev-pipeline-windows/scripts/parse-stream-progress.py +160 -3
  35. package/bundled/dev-pipeline-windows/scripts/update-feature-status.py +27 -3
  36. package/bundled/dev-pipeline-windows/templates/agent-prompts/dev-implement.md +36 -22
  37. package/bundled/dev-pipeline-windows/templates/agent-prompts/reviewer-review.md +1 -1
  38. package/bundled/dev-pipeline-windows/templates/bugfix-bootstrap-prompt.md +24 -21
  39. package/bundled/dev-pipeline-windows/templates/refactor-bootstrap-prompt.md +13 -26
  40. package/bundled/dev-pipeline-windows/templates/sections/ac-verification-checklist.md +4 -10
  41. package/bundled/dev-pipeline-windows/templates/sections/context-budget-rules.md +1 -0
  42. package/bundled/dev-pipeline-windows/templates/sections/feature-context.md +16 -11
  43. package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification-auto.md +22 -10
  44. package/bundled/dev-pipeline-windows/templates/sections/phase-commit-full.md +11 -0
  45. package/bundled/dev-pipeline-windows/templates/sections/phase-commit.md +11 -0
  46. package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-base.md +1 -1
  47. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-agent.md +2 -9
  48. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-full.md +2 -9
  49. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-lite.md +8 -19
  50. package/bundled/dev-pipeline-windows/templates/sections/phase-plan-lite.md +1 -1
  51. package/bundled/dev-pipeline-windows/templates/sections/phase-review-full.md +1 -1
  52. package/bundled/dev-pipeline-windows/templates/sections/phase-specify-plan-full.md +1 -1
  53. package/bundled/dev-pipeline-windows/templates/sections/task-contract.md +34 -0
  54. package/bundled/dev-pipeline-windows/templates/sections/test-failure-recovery-agent.md +27 -46
  55. package/bundled/dev-pipeline-windows/templates/sections/test-failure-recovery-lite.md +27 -37
  56. package/bundled/skills/_metadata.json +1 -1
  57. package/package.json +1 -1
@@ -0,0 +1,34 @@
1
+ ## Task Contract
2
+
3
+ This section defines the only work that belongs to this session.
4
+
5
+ ### Objective
6
+
7
+ Implement {{FEATURE_ID}}: "{{FEATURE_TITLE}}".
8
+
9
+ {{FEATURE_DESCRIPTION}}
10
+
11
+ ### Scope Rule
12
+
13
+ Current scope is limited to the intersection of:
14
+
15
+ 1. The Objective above
16
+ 2. The Verification Gates below
17
+ 3. Dependencies required to complete those gates
18
+
19
+ Raw user context, project brief, and completed dependency notes are authoritative context, but they do not expand scope by themselves.
20
+
21
+ ### Non-Scope Rule
22
+
23
+ Do NOT implement unrelated backlog items, already completed features, or adjacent modules unless they are required by the Objective or a Verification Gate.
24
+
25
+ ### Verification Gates
26
+
27
+ These gates are generated from `feature.acceptance_criteria` and are the only acceptance requirements for this session.
28
+
29
+ {{AC_CHECKLIST}}
30
+
31
+ Gate rule:
32
+ - `[x]` means verified with implementation or test evidence.
33
+ - Any remaining `[ ]` means the feature is incomplete.
34
+ - If a gate is blocked, document the reason in `failure-log.md`; blocked is not success.
@@ -1,67 +1,48 @@
1
1
  ## Test Failure Recovery Protocol
2
2
 
3
- When tests fail during implementation (Phase 3 / Phase 4), use **convergence-based recovery** keep fixing as long as progress is being made.
3
+ Use this protocol whenever implementation or review tests fail. Its purpose is to distinguish tolerated pre-existing failures from blockers introduced by this session.
4
4
 
5
- ### Recovery Loop
6
-
7
- 1. **Run tests and record results**:
8
- - Count total failures and note which tests failed
9
- - Compare against baseline (BASELINE_FAILURES) — exclude pre-existing failures
10
-
11
- 2. **Check termination conditions** (evaluate BEFORE each fix attempt):
12
- - **All tests pass** → Done. Exit recovery loop.
13
- - **Plateau detected** — same failure count AND same failing tests for 3 consecutive rounds → AI cannot resolve these failures. Document and exit.
14
- - **Still making progress** — failure count decreased compared to previous round → Continue fixing.
15
- - **First round** — no history yet → Proceed to fix.
16
-
17
- 3. **Fix and iterate**:
18
- - Analyze remaining failures: root cause (code bug vs. test brittleness vs. environment issue)
19
- - Categorize:
20
- - **Pre-existing baseline failure**: Expected, do NOT fix
21
- - **New regression**: Fix the code
22
- - **Brittle test**: Fix the test or environment setup
23
- - Apply fix, re-run `($TEST_CMD)`, go back to step 1
5
+ ### Failure Classes
24
6
 
25
- ### Convergence Tracking
7
+ | Class | Meaning | Required Action | May Continue? |
8
+ |-------|---------|-----------------|---------------|
9
+ | Baseline failure | Existed before this session | Document in Implementation Log or review notes | Yes |
10
+ | New regression | Introduced by this session | Fix before reporting success | No |
11
+ | Brittle test | Test expectation/setup is wrong for the intended behavior | Fix the test or environment setup, then rerun | Only after fixed or documented as blocked |
12
+ | Environment/tooling failure | External tool, network, install, or local environment prevents verification | Document in `failure-log.md` with impact on gates | Only if no Verification Gate is blocked |
26
13
 
27
- Track failures each round. Example: 5→3→3→3→3 = plateau at round 3, stop at round 5 (3/3).
14
+ ### Recovery Loop
28
15
 
29
- **Key rule**: If failures decrease (even by 1), the plateau counter resets to 0.
16
+ 1. Run tests and record: failing test names, failure count, and class for each failure.
17
+ 2. Compare with `BASELINE_FAILURES`; never blame baseline failures on this feature.
18
+ 3. Fix new regressions and brittle tests while progress is being made.
19
+ 4. Stop after a plateau: same failure count and same failing tests for 3 consecutive rounds.
20
+ 5. If failures decrease, reset the plateau counter.
30
21
 
31
- ### Escalation — Dev + Reviewer Workflow
22
+ ### Success Rule
32
23
 
33
- When the recovery loop exits with remaining failures:
34
- - Dev appends failure details to Implementation Log
35
- - Reviewer agent runs full test suite in Phase 5
36
- - If Reviewer confirms NEW regressions (not in baseline): mark verdict as `NEEDS_FIXES`
37
- - If Reviewer confirms only baseline failures remain: proceed with `PASS_WITH_WARNINGS`
24
+ Proceed to review only when:
38
25
 
39
- ### Context-Aware Test Re-run (Performance Optimization)
26
+ 1. all new regressions are fixed;
27
+ 2. baseline failures are documented;
28
+ 3. every Verification Gate is verified.
40
29
 
41
- **Skip redundant re-runs**:
42
- - If Implementation Log section in context-snapshot.md already confirms "all tests passing"
43
- - → Skip Phase 5 test suite re-run (Reviewer will verify baseline log instead)
44
- - This avoids rebuilding/re-running tests when already verified
30
+ Blocked gates are not success. If any gate cannot be verified, follow the Blocked Rule.
45
31
 
46
- **When to re-run**:
47
- - If Implementation Log is missing or incomplete
48
- - If any new code was added after the last test run
49
- - If Reviewer suspects brittleness or environment drift
32
+ ### Blocked Rule
50
33
 
51
- ### Failure Capture Rules
34
+ If a remaining failure prevents any Verification Gate from being verified, the feature is incomplete. Write `failure-log.md` and do not report success.
52
35
 
53
- If tests remain broken after recovery:
36
+ ### Failure Capture Format
54
37
 
55
- ```
38
+ ```markdown
56
39
  ## Test Failures Encountered
57
40
 
58
41
  - **Test**: [test name/path]
59
42
  - Root Cause: [explanation]
60
- - Category: [pre-existing baseline | new regression | brittle test | environment]
43
+ - Category: [baseline failure | new regression | brittle test | environment/tooling]
61
44
  - Rounds Attempted: [N rounds, plateau at round M]
62
- - Status: [still failing | requires next session | known limitation]
45
+ - Status: [fixed | still failing | blocked]
63
46
 
64
- - **Impact on Feature**: [can AC be verified despite failure | blocks AC verification]
47
+ - **Impact on Verification Gates**: [verified | not affected | blocked + reason]
65
48
  ```
66
-
67
- **Rule**: If any AC cannot be verified due to test failure, the feature is incomplete. Document in failure-log.md for next session.
@@ -1,58 +1,48 @@
1
1
  ## Test Failure Recovery Protocol
2
2
 
3
- When tests fail during implementation, use **convergence-based recovery** keep fixing as long as progress is being made.
3
+ Use this protocol whenever implementation tests fail. Its purpose is to distinguish tolerated pre-existing failures from blockers introduced by this session.
4
4
 
5
- ### Recovery Loop
6
-
7
- 1. **Run tests and record results**:
8
- - Count total failures and note which tests failed
9
- - Compare against baseline (BASELINE_FAILURES) — exclude pre-existing failures
10
-
11
- 2. **Check termination conditions** (evaluate BEFORE each fix attempt):
12
- - **All tests pass** → Done. Exit recovery loop.
13
- - **Plateau detected** — same failure count AND same failing tests for 3 consecutive rounds → AI cannot resolve these failures. Document and exit.
14
- - **Still making progress** — failure count decreased compared to previous round → Continue fixing.
15
- - **First round** — no history yet → Proceed to fix.
5
+ ### Failure Classes
16
6
 
17
- 3. **Fix and iterate**:
18
- - Analyze remaining failures: root cause (code bug vs. test brittleness vs. environment issue)
19
- - Categorize:
20
- - **Pre-existing baseline failure**: Expected, do NOT fix
21
- - **New regression**: Fix the code
22
- - **Brittle test**: Fix the test or environment setup
23
- - Apply fix, re-run `($TEST_CMD)`, go back to step 1
7
+ | Class | Meaning | Required Action | May Continue? |
8
+ |-------|---------|-----------------|---------------|
9
+ | Baseline failure | Existed before this session | Document in Implementation Log | Yes |
10
+ | New regression | Introduced by this session | Fix before reporting success | No |
11
+ | Brittle test | Test expectation/setup is wrong for the intended behavior | Fix the test or environment setup, then rerun | Only after fixed or documented as blocked |
12
+ | Environment/tooling failure | External tool, network, install, or local environment prevents verification | Document in `failure-log.md` with impact on gates | Only if no Verification Gate is blocked |
24
13
 
25
- ### Convergence Tracking
14
+ ### Recovery Loop
26
15
 
27
- Track failures each round. Example: 5→3→3→3→3 = plateau at round 3, stop at round 5 (3/3).
16
+ 1. Run tests and record: failing test names, failure count, and class for each failure.
17
+ 2. Compare with `BASELINE_FAILURES`; never blame baseline failures on this feature.
18
+ 3. Fix new regressions and brittle tests while progress is being made.
19
+ 4. Stop after a plateau: same failure count and same failing tests for 3 consecutive rounds.
20
+ 5. If failures decrease, reset the plateau counter.
28
21
 
29
- **Key rule**: If failures decrease (even by 1), the plateau counter resets to 0.
22
+ ### Success Rule
30
23
 
31
- ### Escalation — Single Agent
24
+ Proceed only when:
32
25
 
33
- When the recovery loop exits with remaining failures:
34
- - Document all remaining failures in Implementation Log with root cause analysis
35
- - Record PARTIAL status with known failure list
36
- - **Do NOT block commit** — unresolved test failures are deferred to next session
26
+ 1. all new regressions are fixed;
27
+ 2. baseline failures are documented;
28
+ 3. every Verification Gate is verified.
37
29
 
38
- ### Context-Aware Optimization
30
+ Blocked gates are not success. If any gate cannot be verified, follow the Blocked Rule.
39
31
 
40
- **Skip redundant re-runs**: If Implementation Log already confirms "all tests passing", skip full suite re-run.
32
+ ### Blocked Rule
41
33
 
42
- ### Failure Capture Rules
34
+ If a remaining failure prevents any Verification Gate from being verified, the feature is incomplete. Write `failure-log.md` and do not report success.
43
35
 
44
- If tests remain broken after recovery:
36
+ ### Failure Capture Format
45
37
 
46
- ```
38
+ ```markdown
47
39
  ## Test Failures Encountered
48
40
 
49
41
  - **Test**: [test name/path]
50
42
  - Root Cause: [explanation]
51
- - Category: [pre-existing baseline | new regression | brittle test | environment]
43
+ - Category: [baseline failure | new regression | brittle test | environment/tooling]
52
44
  - Rounds Attempted: [N rounds, plateau at round M]
53
- - Status: [still failing | requires next session | known limitation]
45
+ - Status: [fixed | still failing | blocked]
54
46
 
55
- - **Impact on Feature**: [can AC be verified despite failure | blocks AC verification]
47
+ - **Impact on Verification Gates**: [verified | not affected | blocked + reason]
56
48
  ```
57
-
58
- **Rule**: If any AC cannot be verified due to test failure, the feature is incomplete. Document in failure-log.md for next session.
@@ -6,6 +6,7 @@ from generate_bootstrap_prompt import (
6
6
  compute_feature_slug,
7
7
  find_feature,
8
8
  format_acceptance_criteria,
9
+ format_ac_checklist,
9
10
  format_global_context,
10
11
  get_completed_dependencies,
11
12
  determine_pipeline_mode,
@@ -73,6 +74,18 @@ class TestFormatAcceptanceCriteria:
73
74
  assert "- Password reset works" in result
74
75
 
75
76
 
77
+ class TestFormatAcChecklist:
78
+ def test_empty_does_not_create_unchecked_gate(self):
79
+ result = format_ac_checklist([])
80
+ assert result == "- (no Verification Gates specified)"
81
+ assert "[ ]" not in result
82
+
83
+ def test_items_are_unchecked_verification_gates(self):
84
+ result = format_ac_checklist(["Users can log in", "Password reset works"])
85
+ assert "- [ ] Users can log in" in result
86
+ assert "- [ ] Password reset works" in result
87
+
88
+
76
89
  # ---------------------------------------------------------------------------
77
90
  # format_global_context
78
91
  # ---------------------------------------------------------------------------
@@ -3,7 +3,9 @@ $ErrorActionPreference = 'Stop'
3
3
 
4
4
  $script:PrizmAiProcess = $null
5
5
 
6
- if (-not ('PrizmLineLogBridge' -as [type])) {
6
+ function Initialize-PrizmLineLogBridgeType {
7
+ if ('PrizmLineLogBridge' -as [type]) { return }
8
+
7
9
  Add-Type -TypeDefinition @'
8
10
  using System;
9
11
  using System.Diagnostics;
@@ -164,6 +166,63 @@ function Test-PrizmInfraError {
164
166
  return ($haystack -match '(?i)auth_unavailable|no auth available|502 Bad Gateway|503 Service Unavailable|504 Gateway Timeout|gateway timeout|upstream (connect )?error|connection reset|ECONNRESET|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|rate limit|rate_limit|temporarily unavailable|overloaded')
165
167
  }
166
168
 
169
+ function Test-PrizmAiRuntimeError {
170
+ param([string]$SessionLog, [string]$ProgressJson)
171
+
172
+ if ($ProgressJson -and (Test-Path $ProgressJson)) {
173
+ try {
174
+ $progress = Get-Content $ProgressJson -Raw -ErrorAction Stop | ConvertFrom-Json -ErrorAction Stop
175
+ if ($progress.PSObject.Properties['fatal_error_code'] -and $progress.fatal_error_code) {
176
+ return $true
177
+ }
178
+ } catch {}
179
+ }
180
+
181
+ $parts = @()
182
+ if ($SessionLog -and (Test-Path $SessionLog)) {
183
+ try {
184
+ $text = Get-Content $SessionLog -Raw -ErrorAction Stop
185
+ if ($text.Length -gt 65536) { $text = $text.Substring($text.Length - 65536) }
186
+ $parts += $text
187
+ } catch {}
188
+ }
189
+ if ($ProgressJson -and (Test-Path $ProgressJson)) {
190
+ try { $parts += (Get-Content $ProgressJson -Raw -ErrorAction Stop) } catch {}
191
+ }
192
+ if ($parts.Count -eq 0) { return $false }
193
+
194
+ $haystack = $parts -join "`n"
195
+ $contextPattern = '(?i)context_too_large|model_context_window_exceeded|input exceeds the context window|context window of this model|context window (was )?exceeded|exceeded (the )?context window|invalid_request_error.*context window|context window.*invalid_request_error'
196
+ $errorPattern = '(?i)api error|invalid_request_error|api_error_status|api_error_code|status\s*[:=]?\s*(400|413)|last_result_is_error\s*["'':=]?\s*true|is_error\s*["'':=]?\s*true'
197
+ if (($haystack -match $contextPattern) -and ($haystack -match $errorPattern)) { return $true }
198
+ return $false
199
+ }
200
+
201
+ function Get-PrizmProgressFatalErrorCode {
202
+ param([string]$ProgressFile)
203
+ if (-not (Test-Path $ProgressFile)) { return '' }
204
+ try {
205
+ $progress = Get-Content $ProgressFile -Raw -ErrorAction Stop | ConvertFrom-Json -ErrorAction Stop
206
+ if ($progress.PSObject.Properties['fatal_error_code'] -and $progress.fatal_error_code) {
207
+ return [string]$progress.fatal_error_code
208
+ }
209
+ } catch {}
210
+ return ''
211
+ }
212
+
213
+ function Write-PrizmFatalErrorMarker {
214
+ param([string]$MarkerPath, [string]$FatalErrorCode, [int]$StaleSeconds, [int]$Threshold)
215
+ $markerDir = Split-Path $MarkerPath -Parent
216
+ if ($markerDir) { New-Item -ItemType Directory -Force -Path $markerDir | Out-Null }
217
+ [ordered]@{
218
+ killed_at = (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
219
+ reason = $FatalErrorCode
220
+ fatal_error_code = $FatalErrorCode
221
+ stale_seconds = $StaleSeconds
222
+ threshold = $Threshold
223
+ } | ConvertTo-Json -Compress | Set-Content -Path $MarkerPath -Encoding UTF8
224
+ }
225
+
167
226
  function Get-PrizmConfigValue {
168
227
  param([string]$ConfigPath, [string]$Key)
169
228
  if (-not (Test-Path $ConfigPath)) { return $null }
@@ -638,6 +697,7 @@ function Invoke-PrizmAiSession {
638
697
  $psi.Arguments = $argumentString
639
698
  }
640
699
 
700
+ Initialize-PrizmLineLogBridgeType
641
701
  $process = [System.Diagnostics.Process]::Start($psi)
642
702
  $script:PrizmAiProcess = $process
643
703
  $logBridge = [PrizmLineLogBridge]::new($LogPath)