prizmkit 1.1.96 → 1.1.97
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/bundled/VERSION.json +3 -3
- package/bundled/dev-pipeline/run-bugfix.sh +5 -1
- package/bundled/dev-pipeline/run-feature.sh +5 -1
- package/bundled/dev-pipeline/run-refactor.sh +5 -1
- package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +98 -7
- package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +86 -3
- package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +86 -3
- package/bundled/dev-pipeline/scripts/monitor-log.sh +104 -0
- package/bundled/dev-pipeline/templates/bootstrap-tier1.md +4 -1
- package/bundled/dev-pipeline/templates/bootstrap-tier2.md +5 -2
- package/bundled/dev-pipeline/templates/bootstrap-tier3.md +5 -2
- package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +3 -0
- package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +3 -2
- package/bundled/dev-pipeline/templates/sections/log-size-awareness.md +76 -0
- package/bundled/dev-pipeline-windows/lib/pipeline.ps1 +2 -0
- package/bundled/dev-pipeline-windows/scripts/generate-bootstrap-prompt.py +98 -7
- package/bundled/dev-pipeline-windows/scripts/generate-bugfix-prompt.py +86 -3
- package/bundled/dev-pipeline-windows/scripts/generate-refactor-prompt.py +86 -3
- package/bundled/dev-pipeline-windows/scripts/monitor-log.ps1 +102 -0
- package/bundled/dev-pipeline-windows/templates/bootstrap-tier1.md +4 -1
- package/bundled/dev-pipeline-windows/templates/bootstrap-tier2.md +5 -2
- package/bundled/dev-pipeline-windows/templates/bootstrap-tier3.md +5 -2
- package/bundled/dev-pipeline-windows/templates/bugfix-bootstrap-prompt.md +3 -0
- package/bundled/dev-pipeline-windows/templates/refactor-bootstrap-prompt.md +3 -2
- package/bundled/dev-pipeline-windows/templates/sections/log-size-awareness.md +78 -0
- package/bundled/skills/_metadata.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env pwsh
|
|
2
|
+
# monitor-log.ps1 — Background log size monitor for AI session subagent (PowerShell)
|
|
3
|
+
#
|
|
4
|
+
# Polls session.log size, computes effective size (current - baseline),
|
|
5
|
+
# and writes a structured JSON status file. Intended to be run by a
|
|
6
|
+
# background subagent inside the AI CLI session.
|
|
7
|
+
#
|
|
8
|
+
# Usage:
|
|
9
|
+
# pwsh -NoProfile -File monitor-log.ps1 <session_log> <max_size> <poll_interval> <status_file> <baseline_file>
|
|
10
|
+
# powershell.exe -NoProfile -File monitor-log.ps1 <session_log> <max_size> <poll_interval> <status_file> <baseline_file>
|
|
11
|
+
#
|
|
12
|
+
# Status file format (JSON, rewritten each poll cycle):
|
|
13
|
+
# {
|
|
14
|
+
# "status": "OK" | "COMPACT_NEEDED",
|
|
15
|
+
# "total_bytes": <current session.log size>,
|
|
16
|
+
# "baseline_bytes": <size after last /compact>,
|
|
17
|
+
# "effective_bytes": <total - baseline>,
|
|
18
|
+
# "threshold_bytes": <compact threshold>,
|
|
19
|
+
# "overage_bytes": <effective - threshold, 0 if not exceeded>,
|
|
20
|
+
# "usage_pct": <effective / threshold * 100>
|
|
21
|
+
# }
|
|
22
|
+
|
|
23
|
+
param(
|
|
24
|
+
[Parameter(Mandatory=$true)] [string]$SessionLog,
|
|
25
|
+
[Parameter(Mandatory=$true)] [long]$MaxSize,
|
|
26
|
+
[Parameter(Mandatory=$true)] [int]$PollInterval,
|
|
27
|
+
[Parameter(Mandatory=$true)] [string]$StatusFile,
|
|
28
|
+
[Parameter(Mandatory=$true)] [string]$BaselineFile
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
if ($MaxSize -lt 0) {
|
|
32
|
+
Write-Error "ERROR: MaxSize must be a non-negative integer"
|
|
33
|
+
exit 1
|
|
34
|
+
}
|
|
35
|
+
if ($PollInterval -le 0) {
|
|
36
|
+
Write-Error "ERROR: PollInterval must be a positive integer"
|
|
37
|
+
exit 1
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
# Ensure status directory exists
|
|
41
|
+
$statusDir = Split-Path -Parent $StatusFile
|
|
42
|
+
if (-not (Test-Path $statusDir)) {
|
|
43
|
+
New-Item -ItemType Directory -Path $statusDir -Force | Out-Null
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
Write-Error "[monitor-log] Starting log monitor: max=$MaxSize interval=${PollInterval}s"
|
|
47
|
+
Write-Error "[monitor-log] Watching: $SessionLog"
|
|
48
|
+
|
|
49
|
+
while ($true) {
|
|
50
|
+
# Read current log size
|
|
51
|
+
if (Test-Path $SessionLog) {
|
|
52
|
+
$size = (Get-Item $SessionLog).Length
|
|
53
|
+
} else {
|
|
54
|
+
$size = 0
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
# Read baseline (resets after each /compact)
|
|
58
|
+
$baseline = 0
|
|
59
|
+
if (Test-Path $BaselineFile) {
|
|
60
|
+
try {
|
|
61
|
+
$baseline = [long](Get-Content $BaselineFile -Raw).Trim()
|
|
62
|
+
} catch {
|
|
63
|
+
$baseline = 0
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
# Effective size = growth since last compact
|
|
68
|
+
$effective = $size - $baseline
|
|
69
|
+
if ($effective -lt 0) {
|
|
70
|
+
$effective = 0
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
# Determine status (MaxSize=0 disables monitoring)
|
|
74
|
+
if ($MaxSize -gt 0 -and $effective -gt $MaxSize) {
|
|
75
|
+
$status = "COMPACT_NEEDED"
|
|
76
|
+
$overage = $effective - $MaxSize
|
|
77
|
+
Write-Error "[monitor-log] COMPACT_NEEDED: effective=$effective overage=$overage (threshold=$MaxSize)"
|
|
78
|
+
} else {
|
|
79
|
+
$status = "OK"
|
|
80
|
+
$overage = 0
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
# Usage percentage
|
|
84
|
+
if ($MaxSize -gt 0) {
|
|
85
|
+
$usagePct = [Math]::Floor($effective * 100 / $MaxSize)
|
|
86
|
+
} else {
|
|
87
|
+
$usagePct = 0
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
# Write structured JSON status
|
|
91
|
+
@{
|
|
92
|
+
status = $status
|
|
93
|
+
total_bytes = $size
|
|
94
|
+
baseline_bytes = $baseline
|
|
95
|
+
effective_bytes = $effective
|
|
96
|
+
threshold_bytes = $MaxSize
|
|
97
|
+
overage_bytes = $overage
|
|
98
|
+
usage_pct = $usagePct
|
|
99
|
+
} | ConvertTo-Json -Compress | Out-File -FilePath $StatusFile -NoNewline
|
|
100
|
+
|
|
101
|
+
Start-Sleep -Seconds $PollInterval
|
|
102
|
+
}
|
|
@@ -12,7 +12,7 @@ You are the **session orchestrator**. Implement Feature {{FEATURE_ID}}: "{{FEATU
|
|
|
12
12
|
|
|
13
13
|
**CRITICAL**: You MUST NOT exit until ALL work is complete and committed.
|
|
14
14
|
|
|
15
|
-
**Tier 1 — Single Agent**: You handle everything directly. No subagents
|
|
15
|
+
**Tier 1 — Single Agent**: You handle everything directly. No normal work subagents; the log-size monitor is the only allowed persistent background subagent. No TeamCreate.
|
|
16
16
|
|
|
17
17
|
### Feature Description
|
|
18
18
|
|
|
@@ -54,6 +54,9 @@ You are running in **headless non-interactive mode** with a FINITE context windo
|
|
|
54
54
|
|
|
55
55
|
---
|
|
56
56
|
|
|
57
|
+
{{LOG_SIZE_AWARENESS}}
|
|
58
|
+
---
|
|
59
|
+
|
|
57
60
|
## PrizmKit Directory Convention
|
|
58
61
|
|
|
59
62
|
```
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
You are the **session orchestrator**. Implement Feature {{FEATURE_ID}}: "{{FEATURE_TITLE}}".
|
|
12
12
|
|
|
13
|
-
**CRITICAL**: You MUST NOT exit until ALL work is complete and committed. When you spawn subagents, wait for each to finish (run_in_background=false).
|
|
13
|
+
**CRITICAL**: You MUST NOT exit until ALL work is complete and committed. When you spawn normal work subagents, wait for each to finish (run_in_background=false). The log-size monitor is the only allowed persistent background subagent.
|
|
14
14
|
|
|
15
15
|
**Tier 2 — Dual Agent**: You handle context + planning directly. Then spawn Dev and Reviewer subagents. Spawn Dev and Reviewer agents via the Agent tool.
|
|
16
16
|
|
|
@@ -60,6 +60,9 @@ You are running in **headless non-interactive mode** with a FINITE context windo
|
|
|
60
60
|
|
|
61
61
|
---
|
|
62
62
|
|
|
63
|
+
{{LOG_SIZE_AWARENESS}}
|
|
64
|
+
---
|
|
65
|
+
|
|
63
66
|
## PrizmKit Directory Convention
|
|
64
67
|
|
|
65
68
|
```
|
|
@@ -699,7 +702,7 @@ Remove-Item -Force -ErrorAction SilentlyContinue .prizmkit/specs/{{FEATURE_SLUG}
|
|
|
699
702
|
- Build context-snapshot.md FIRST; all subagents read it instead of re-reading source files
|
|
700
703
|
- context-snapshot.md is append-only: orchestrator writes Sections 1-4, Dev appends Implementation Log, Reviewer appends Review Notes
|
|
701
704
|
- Gate checks enforce Implementation Log and Review Notes are written before proceeding
|
|
702
|
-
- Do NOT use `run_in_background=true` when spawning subagents
|
|
705
|
+
- Do NOT use `run_in_background=true` when spawning normal work subagents; the log-size monitor is the only allowed persistent background subagent
|
|
703
706
|
- `/prizmkit-committer` is mandatory, and must not be replaced with manual git commit commands
|
|
704
707
|
- Do NOT run `git add`/`git commit` during Phase 1-5 — all changes are committed once in Phase 6
|
|
705
708
|
- If any files remain after the commit, amend the existing commit — do NOT create a follow-up commit
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
You are the **session orchestrator**. Implement Feature {{FEATURE_ID}}: "{{FEATURE_TITLE}}".
|
|
12
12
|
|
|
13
|
-
**CRITICAL**: You MUST NOT exit until ALL work is complete and committed. When you spawn subagents, wait for each to finish (run_in_background=false). Do NOT spawn agents in background and exit — that kills the session.
|
|
13
|
+
**CRITICAL**: You MUST NOT exit until ALL work is complete and committed. When you spawn normal work subagents, wait for each to finish (run_in_background=false). The log-size monitor is the only allowed persistent background subagent. Do NOT spawn work agents in background and exit — that kills the session.
|
|
14
14
|
|
|
15
15
|
**Tier 3 — Full Team**: For complex features, use the full pipeline (Phase 0–6) with Dev + Reviewer agents spawned via the Agent tool.
|
|
16
16
|
|
|
@@ -60,6 +60,9 @@ You are running in **headless non-interactive mode** with a FINITE context windo
|
|
|
60
60
|
|
|
61
61
|
---
|
|
62
62
|
|
|
63
|
+
{{LOG_SIZE_AWARENESS}}
|
|
64
|
+
---
|
|
65
|
+
|
|
63
66
|
## PrizmKit Directory Convention
|
|
64
67
|
|
|
65
68
|
```
|
|
@@ -780,7 +783,7 @@ Remove-Item -Force -ErrorAction SilentlyContinue .prizmkit/specs/{{FEATURE_SLUG}
|
|
|
780
783
|
- Tier 3: full team — Dev (implementation) → Reviewer (review) — spawn agents directly via Agent tool
|
|
781
784
|
- context-snapshot.md is append-only: orchestrator writes Sections 1-4, Dev appends Implementation Log, Reviewer appends Review Notes
|
|
782
785
|
- Gate checks enforce Implementation Log and Review Notes are written before proceeding
|
|
783
|
-
- Do NOT use `run_in_background=true` when spawning agents
|
|
786
|
+
- Do NOT use `run_in_background=true` when spawning normal work agents; the log-size monitor is the only allowed persistent background subagent
|
|
784
787
|
- Commit phase must use `/prizmkit-committer`; do NOT replace with manual git commit commands
|
|
785
788
|
- Do NOT run `git add`/`git commit` during Phase 1-5 — all changes are committed once in Phase 6
|
|
786
789
|
- If any files remain after the commit, amend the existing commit — do NOT create a follow-up commit
|
|
@@ -13,6 +13,8 @@ You are the **bug fix session agent**. Fix Bug {{BUG_ID}}: "{{BUG_TITLE}}".
|
|
|
13
13
|
|
|
14
14
|
**CRITICAL**: You MUST NOT exit until ALL work is complete and committed.
|
|
15
15
|
|
|
16
|
+
**SUBAGENT LIFECYCLE**: The log-size monitor is the only allowed persistent background subagent. Any normal work subagent must be awaited with `run_in_background=false`.
|
|
17
|
+
|
|
16
18
|
**NON-INTERACTIVE MODE**: There is NO human on the other end. NEVER ask for user confirmation, NEVER wait for user input. Make decisions autonomously and move forward.
|
|
17
19
|
|
|
18
20
|
### Bug Description
|
|
@@ -51,6 +53,7 @@ You are the **bug fix session agent**. Fix Bug {{BUG_ID}}: "{{BUG_TITLE}}".
|
|
|
51
53
|
4. **Minimize tool output** — Capture to temp file, scan first/last lines, filter with Select-String, regex matching, or PowerShell object filtering. Never load full output.
|
|
52
54
|
5. **No intermediate commits** — All changes committed once at the end via `/prizmkit-committer`.
|
|
53
55
|
|
|
56
|
+
{{LOG_SIZE_AWARENESS}}
|
|
54
57
|
## Bug Fix Artifacts Directory
|
|
55
58
|
|
|
56
59
|
```
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
You are the **refactor session orchestrator**. Execute Refactor {{REFACTOR_ID}}: "{{REFACTOR_TITLE}}".
|
|
14
14
|
|
|
15
|
-
**CRITICAL SESSION LIFECYCLE RULE**: You MUST NOT exit until ALL work is complete and session-status.json is written. When you spawn subagents, you MUST **wait for each to finish** (run_in_background=false) before proceeding. Do NOT spawn
|
|
15
|
+
**CRITICAL SESSION LIFECYCLE RULE**: You MUST NOT exit until ALL work is complete and session-status.json is written. When you spawn normal work subagents, you MUST **wait for each to finish** (run_in_background=false) before proceeding. The log-size monitor is the only allowed persistent background subagent. Do NOT spawn a work agent in the background and exit — that kills the session.
|
|
16
16
|
|
|
17
17
|
**NON-INTERACTIVE MODE**: You are running in headless non-interactive mode. There is NO human on the other end. NEVER ask for user confirmation, NEVER wait for user input, NEVER use interactive prompts (e.g. "Would you like me to…"). If a skill has an interactive step (e.g. offer remediation, ask for approval), skip it and proceed autonomously. Make decisions based on the data available and move forward.
|
|
18
18
|
|
|
@@ -78,6 +78,7 @@ You are the **refactor session orchestrator**. Execute Refactor {{REFACTOR_ID}}:
|
|
|
78
78
|
|
|
79
79
|
## Execution Instructions
|
|
80
80
|
|
|
81
|
+
{{LOG_SIZE_AWARENESS}}
|
|
81
82
|
**YOU are the orchestrator. Execute each phase by spawning the appropriate team agent with run_in_background=false.**
|
|
82
83
|
|
|
83
84
|
**Agent spawn failure policy (all Agent tool calls)**:
|
|
@@ -336,4 +337,4 @@ Write to: `{{SESSION_STATUS_PATH}}`
|
|
|
336
337
|
- **Commit with** `refactor(<scope>):` prefix, NOT `feat:` or `fix:`
|
|
337
338
|
- **Run full retrospective** (Job 1 + Job 2) — refactoring changes code structure
|
|
338
339
|
- ALWAYS write session-status.json before exiting
|
|
339
|
-
- Do NOT use `run_in_background=true` when spawning agents
|
|
340
|
+
- Do NOT use `run_in_background=true` when spawning normal work agents; the log-size monitor is the only allowed persistent background subagent
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
## Session Log Budget Monitoring (PROACTIVE)
|
|
2
|
+
|
|
3
|
+
Your session log grows with every tool call and subagent spawn.
|
|
4
|
+
To prevent context exhaustion, **spawn a background monitoring subagent at session start**.
|
|
5
|
+
|
|
6
|
+
### How to Set Up the Monitor
|
|
7
|
+
|
|
8
|
+
1. **AS THE VERY FIRST ACTION** (before Phase 0), spawn a monitoring subagent
|
|
9
|
+
with `run_in_background: true` and this task:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
Run this command and keep it running:
|
|
13
|
+
$psHost = if (Get-Command pwsh -ErrorAction SilentlyContinue) { 'pwsh' } else { 'powershell.exe' }
|
|
14
|
+
& $psHost -NoProfile -File {{LOG_MONITOR_SCRIPT}} {{SESSION_LOG_PATH}} {{MAX_LOG_SIZE}} {{LOG_MONITOR_POLL_INTERVAL}} {{LOG_MONITOR_STATUS_FILE}} {{LOG_MONITOR_BASELINE_FILE}}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The subagent MUST use `run_in_background: true`. It writes a JSON status
|
|
18
|
+
file every {{LOG_MONITOR_POLL_INTERVAL}} seconds.
|
|
19
|
+
|
|
20
|
+
2. **BEFORE EACH MAJOR PHASE** (Phase 0, 1, 2, ...), read the status:
|
|
21
|
+
|
|
22
|
+
```powershell
|
|
23
|
+
if (Test-Path {{LOG_MONITOR_STATUS_FILE}}) { Get-Content {{LOG_MONITOR_STATUS_FILE}} } else { '{"status":"OK"}' }
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The status file contains structured diagnostics:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"status": "OK | COMPACT_NEEDED",
|
|
31
|
+
"total_bytes": <current session.log size>,
|
|
32
|
+
"baseline_bytes": <size after last /compact>,
|
|
33
|
+
"effective_bytes": <total - baseline, incremental growth>,
|
|
34
|
+
"threshold_bytes": <{{MAX_LOG_SIZE}}>,
|
|
35
|
+
"overage_bytes": <effective - threshold, 0 when OK>,
|
|
36
|
+
"usage_pct": <effective / threshold * 100>
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Extract fields for decision-making:
|
|
41
|
+
```powershell
|
|
42
|
+
$data = Get-Content {{LOG_MONITOR_STATUS_FILE}} | ConvertFrom-Json
|
|
43
|
+
$status = $data.status
|
|
44
|
+
$effective = $data.effective_bytes
|
|
45
|
+
$overage = $data.overage_bytes
|
|
46
|
+
$usage = $data.usage_pct
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
3. **On COMPACT_NEEDED** (effective_bytes > {{MAX_LOG_SIZE}} bytes, {{MAX_LOG_SIZE_HUMAN}}):
|
|
50
|
+
- Check `overage_bytes` to decide urgency:
|
|
51
|
+
- **Minor overage** (< 512KB): complete the current sub-step, update durable workflow checkpoint artifacts, write baseline, `/compact`
|
|
52
|
+
- **Major overage** (>= 512KB): update durable workflow checkpoint artifacts, write baseline, `/compact` — do NOT start new work
|
|
53
|
+
- Write baseline before `/compact`:
|
|
54
|
+
```powershell
|
|
55
|
+
(Get-Item {{SESSION_LOG_PATH}}).Length | Out-File -NoNewline {{LOG_MONITOR_BASELINE_FILE}}
|
|
56
|
+
```
|
|
57
|
+
- Execute `/compact`
|
|
58
|
+
- Continue the workflow after `/compact`; re-read this status file before the next major phase
|
|
59
|
+
|
|
60
|
+
### How the Baseline Prevents Infinite Compaction Loops
|
|
61
|
+
|
|
62
|
+
- Before the first `/compact`: baseline = 0, effective = full log size → triggers when log exceeds threshold
|
|
63
|
+
- After `/compact`: baseline = current log size, effective ≈ 0 → status resets to OK
|
|
64
|
+
- The monitor only triggers again when **new** log growth since the last compact exceeds the threshold
|
|
65
|
+
- Each `/compact` resets the baseline, breaking the infinite loop
|
|
66
|
+
|
|
67
|
+
### Log Growth Reduction Tips
|
|
68
|
+
|
|
69
|
+
- **Re-read context-snapshot.md instead of source files** — already in context
|
|
70
|
+
- **Filter command output** — pipe to `Select-Object -Last 20` or `Select-String`, never full output
|
|
71
|
+
- **Limit subagent prompts** — shorter, focused prompts = shorter transcripts
|
|
72
|
+
- **Checkpoint often** — update durable workflow checkpoint artifacts before `/compact`
|
|
73
|
+
|
|
74
|
+
### What Survives
|
|
75
|
+
|
|
76
|
+
- All git commits are permanent
|
|
77
|
+
- The workflow checkpoint is preserved and auto-resumed
|
|
78
|
+
- `/compact` compresses context without losing progress
|