prizmkit 1.1.98 → 1.1.100
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/README.md +5 -5
- package/bundled/dev-pipeline/launch-bugfix-daemon.sh +1 -1
- package/bundled/dev-pipeline/launch-feature-daemon.sh +1 -1
- package/bundled/dev-pipeline/launch-refactor-daemon.sh +1 -1
- package/bundled/dev-pipeline/lib/common.sh +244 -25
- package/bundled/dev-pipeline/reset-bug.sh +32 -2
- package/bundled/dev-pipeline/reset-feature.sh +32 -2
- package/bundled/dev-pipeline/reset-refactor.sh +32 -2
- package/bundled/dev-pipeline/run-bugfix.sh +133 -18
- package/bundled/dev-pipeline/run-feature.sh +134 -18
- package/bundled/dev-pipeline/run-refactor.sh +133 -18
- package/bundled/dev-pipeline/scripts/check-session-status.py +74 -1
- package/bundled/dev-pipeline/scripts/continuation.py +374 -0
- package/bundled/dev-pipeline/scripts/detect-stuck.py +5 -5
- package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +29 -35
- package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +19 -25
- package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +19 -25
- package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +1 -1
- package/bundled/dev-pipeline/scripts/init-pipeline.py +1 -1
- package/bundled/dev-pipeline/scripts/init-refactor-pipeline.py +1 -1
- package/bundled/dev-pipeline/scripts/parse-stream-progress.py +146 -16
- package/bundled/dev-pipeline/scripts/update-bug-status.py +220 -13
- package/bundled/dev-pipeline/scripts/update-feature-status.py +244 -18
- package/bundled/dev-pipeline/scripts/update-refactor-status.py +220 -13
- package/bundled/dev-pipeline/templates/agent-prompts/dev-implement.md +1 -1
- package/bundled/dev-pipeline/templates/bootstrap-tier1.md +2 -2
- package/bundled/dev-pipeline/templates/bootstrap-tier2.md +3 -3
- package/bundled/dev-pipeline/templates/bootstrap-tier3.md +3 -3
- package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +1 -1
- package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +3 -3
- package/bundled/dev-pipeline/templates/sections/log-size-awareness.md +31 -66
- package/bundled/dev-pipeline/templates/session-status-schema.json +1 -1
- package/bundled/dev-pipeline/tests/conftest.py +1 -0
- package/bundled/dev-pipeline/tests/test_auto_skip.py +518 -8
- package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +103 -0
- package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +60 -0
- package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +43 -0
- package/bundled/dev-pipeline-windows/lib/common.ps1 +172 -10
- package/bundled/dev-pipeline-windows/lib/pipeline.ps1 +95 -11
- package/bundled/dev-pipeline-windows/lib/reset.ps1 +34 -0
- package/bundled/dev-pipeline-windows/reset-bug.ps1 +1 -0
- package/bundled/dev-pipeline-windows/reset-feature.ps1 +1 -0
- package/bundled/dev-pipeline-windows/reset-refactor.ps1 +1 -0
- package/bundled/dev-pipeline-windows/scripts/check-session-status.py +74 -1
- package/bundled/dev-pipeline-windows/scripts/continuation.py +374 -0
- package/bundled/dev-pipeline-windows/scripts/detect-stuck.py +5 -5
- package/bundled/dev-pipeline-windows/scripts/generate-bootstrap-prompt.py +29 -35
- package/bundled/dev-pipeline-windows/scripts/generate-bugfix-prompt.py +20 -25
- package/bundled/dev-pipeline-windows/scripts/generate-refactor-prompt.py +20 -25
- package/bundled/dev-pipeline-windows/scripts/init-bugfix-pipeline.py +1 -1
- package/bundled/dev-pipeline-windows/scripts/init-pipeline.py +1 -1
- package/bundled/dev-pipeline-windows/scripts/init-refactor-pipeline.py +1 -1
- package/bundled/dev-pipeline-windows/scripts/parse-stream-progress.py +146 -16
- package/bundled/dev-pipeline-windows/scripts/update-bug-status.py +220 -13
- package/bundled/dev-pipeline-windows/scripts/update-feature-status.py +244 -18
- package/bundled/dev-pipeline-windows/scripts/update-refactor-status.py +220 -13
- package/bundled/dev-pipeline-windows/templates/agent-prompts/dev-implement.md +1 -1
- package/bundled/dev-pipeline-windows/templates/bootstrap-tier1.md +2 -2
- package/bundled/dev-pipeline-windows/templates/bootstrap-tier2.md +3 -3
- package/bundled/dev-pipeline-windows/templates/bootstrap-tier3.md +3 -3
- package/bundled/dev-pipeline-windows/templates/bugfix-bootstrap-prompt.md +1 -1
- package/bundled/dev-pipeline-windows/templates/refactor-bootstrap-prompt.md +3 -3
- package/bundled/dev-pipeline-windows/templates/sections/log-size-awareness.md +31 -68
- package/bundled/dev-pipeline-windows/templates/session-status-schema.json +1 -1
- package/bundled/skills/_metadata.json +1 -1
- package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +2 -2
- package/bundled/skills/feature-pipeline-launcher/SKILL.md +2 -2
- package/bundled/skills/recovery-workflow/SKILL.md +2 -2
- package/bundled/skills/recovery-workflow/evals/evals.json +2 -2
- package/bundled/skills/refactor-pipeline-launcher/SKILL.md +2 -2
- package/bundled/skills-windows/bugfix-pipeline-launcher/SKILL.md +2 -2
- package/bundled/skills-windows/feature-pipeline-launcher/SKILL.md +2 -2
- package/bundled/skills-windows/recovery-workflow/SKILL.md +2 -2
- package/bundled/skills-windows/recovery-workflow/evals/evals.json +2 -2
- package/bundled/skills-windows/refactor-pipeline-launcher/SKILL.md +2 -2
- package/package.json +1 -1
- package/bundled/dev-pipeline/scripts/monitor-log.sh +0 -104
- package/bundled/dev-pipeline-windows/scripts/monitor-log.ps1 +0 -102
|
@@ -48,8 +48,8 @@ Pipeline commands (for reference — Phase 1.3 will present these as a selectabl
|
|
|
48
48
|
| Workflow | Branch Pattern | Key Artifacts |
|
|
49
49
|
|----------|---------------|---------------|
|
|
50
50
|
| bug-fix-workflow | `fix/<BUG_ID>-*` | `.prizmkit/bugfix/<BUG_ID>/fix-plan.md`, `fix-report.md` |
|
|
51
|
-
| feature-workflow | `feat/*` | `.prizmkit/plans/feature-list.json`, `.prizmkit/state/features
|
|
52
|
-
| refactor-workflow | `refactor/*` | `.prizmkit/plans/refactor-list.json`, `.prizmkit/state/refactor
|
|
51
|
+
| feature-workflow | `feat/*` | `.prizmkit/plans/feature-list.json`, `.prizmkit/state/features/` |
|
|
52
|
+
| refactor-workflow | `refactor/*` | `.prizmkit/plans/refactor-list.json`, `.prizmkit/state/refactor/` |
|
|
53
53
|
|
|
54
54
|
---
|
|
55
55
|
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"name": "feature-list-exists",
|
|
24
24
|
"prompt": "resume",
|
|
25
25
|
"expected_output": "Should auto-detect feature-workflow from .prizmkit/plans/feature-list.json. Should detect .prizmkit/plans/feature-list.json exists but no pipeline state → infer Phase 3 (Launch). Should invoke feature-pipeline-launcher to start the pipeline.",
|
|
26
|
-
"setup_description": "On main branch, create .prizmkit/plans/feature-list.json with 3 features. No .prizmkit/state/features/
|
|
26
|
+
"setup_description": "On main branch, create .prizmkit/plans/feature-list.json with 3 features. No .prizmkit/state/features/ directory.",
|
|
27
27
|
"files": []
|
|
28
28
|
},
|
|
29
29
|
{
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"name": "refactor-monitoring",
|
|
32
32
|
"prompt": "pick up where it left off",
|
|
33
33
|
"expected_output": "Should auto-detect refactor-workflow from .prizmkit/plans/refactor-list.json + pipeline state. Should infer Phase 4 (Monitor). Should check pipeline status and report results.",
|
|
34
|
-
"setup_description": "On main branch, create .prizmkit/plans/refactor-list.json with 2 items. Create .prizmkit/state/refactor/
|
|
34
|
+
"setup_description": "On main branch, create .prizmkit/plans/refactor-list.json with 2 items. Create .prizmkit/state/refactor/ with status files showing 1 completed, 1 in-progress.",
|
|
35
35
|
"files": []
|
|
36
36
|
},
|
|
37
37
|
{
|
|
@@ -288,9 +288,9 @@ Detect user intent from their message, then follow the corresponding workflow:
|
|
|
288
288
|
4. **For per-refactor session logs** (when user asks about a specific refactor):
|
|
289
289
|
```bash
|
|
290
290
|
# Check refactor status for last session ID
|
|
291
|
-
cat .prizmkit/state/refactor
|
|
291
|
+
cat .prizmkit/state/refactor/<REFACTOR_ID>/status.json 2>/dev/null
|
|
292
292
|
# Then tail that refactor's session log
|
|
293
|
-
tail -100 .prizmkit/state/refactor
|
|
293
|
+
tail -100 .prizmkit/state/refactor/<REFACTOR_ID>/sessions/<SESSION_ID>/logs/session.log
|
|
294
294
|
```
|
|
295
295
|
|
|
296
296
|
---
|
|
@@ -271,9 +271,9 @@ Detect user intent from their message, then follow the corresponding workflow:
|
|
|
271
271
|
4. **For per-bug session logs** (when user asks about a specific bug):
|
|
272
272
|
```powershell
|
|
273
273
|
# Check bug status for last session ID
|
|
274
|
-
Get-Content .prizmkit/state/bugfix
|
|
274
|
+
Get-Content .prizmkit/state/bugfix/<BUG_ID>/status.json -ErrorAction SilentlyContinue
|
|
275
275
|
# Then tail that bug's session log
|
|
276
|
-
Get-Content -Tail 100 .prizmkit/state/bugfix
|
|
276
|
+
Get-Content -Tail 100 .prizmkit/state/bugfix/<BUG_ID>/sessions/<SESSION_ID>/logs/session.log
|
|
277
277
|
```
|
|
278
278
|
|
|
279
279
|
---
|
|
@@ -312,9 +312,9 @@ Detect user intent from their message, then follow the corresponding workflow:
|
|
|
312
312
|
4. **For per-feature session logs** (when user asks about a specific feature):
|
|
313
313
|
```powershell
|
|
314
314
|
# Check feature status for last session ID
|
|
315
|
-
Get-Content .prizmkit/state/features
|
|
315
|
+
Get-Content .prizmkit/state/features/<FEATURE_ID>/status.json -ErrorAction SilentlyContinue
|
|
316
316
|
# Then tail that feature's session log
|
|
317
|
-
Get-Content -Tail 100 .prizmkit/state/features
|
|
317
|
+
Get-Content -Tail 100 .prizmkit/state/features/<FEATURE_ID>/sessions/<SESSION_ID>/logs/session.log
|
|
318
318
|
```
|
|
319
319
|
|
|
320
320
|
---
|
|
@@ -48,8 +48,8 @@ Pipeline commands (for reference — Phase 1.3 will present these as a selectabl
|
|
|
48
48
|
| Workflow | Branch Pattern | Key Artifacts |
|
|
49
49
|
|----------|---------------|---------------|
|
|
50
50
|
| bug-fix-workflow | `fix/<BUG_ID>-*` | `.prizmkit/bugfix/<BUG_ID>/fix-plan.md`, `fix-report.md` |
|
|
51
|
-
| feature-workflow | `feat/*` | `.prizmkit/plans/feature-list.json`, `.prizmkit/state/features
|
|
52
|
-
| refactor-workflow | `refactor/*` | `.prizmkit/plans/refactor-list.json`, `.prizmkit/state/refactor
|
|
51
|
+
| feature-workflow | `feat/*` | `.prizmkit/plans/feature-list.json`, `.prizmkit/state/features/` |
|
|
52
|
+
| refactor-workflow | `refactor/*` | `.prizmkit/plans/refactor-list.json`, `.prizmkit/state/refactor/` |
|
|
53
53
|
|
|
54
54
|
---
|
|
55
55
|
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"name": "feature-list-exists",
|
|
24
24
|
"prompt": "resume",
|
|
25
25
|
"expected_output": "Should auto-detect feature-workflow from .prizmkit/plans/feature-list.json. Should detect .prizmkit/plans/feature-list.json exists but no pipeline state → infer Phase 3 (Launch). Should invoke feature-pipeline-launcher to start the pipeline.",
|
|
26
|
-
"setup_description": "On main branch, create .prizmkit/plans/feature-list.json with 3 features. No .prizmkit/state/features/
|
|
26
|
+
"setup_description": "On main branch, create .prizmkit/plans/feature-list.json with 3 features. No .prizmkit/state/features/ directory.",
|
|
27
27
|
"files": []
|
|
28
28
|
},
|
|
29
29
|
{
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"name": "refactor-monitoring",
|
|
32
32
|
"prompt": "pick up where it left off",
|
|
33
33
|
"expected_output": "Should auto-detect refactor-workflow from .prizmkit/plans/refactor-list.json + pipeline state. Should infer Phase 4 (Monitor). Should check pipeline status and report results.",
|
|
34
|
-
"setup_description": "On main branch, create .prizmkit/plans/refactor-list.json with 2 items. Create .prizmkit/state/refactor/
|
|
34
|
+
"setup_description": "On main branch, create .prizmkit/plans/refactor-list.json with 2 items. Create .prizmkit/state/refactor/ with status files showing 1 completed, 1 in-progress.",
|
|
35
35
|
"files": []
|
|
36
36
|
},
|
|
37
37
|
{
|
|
@@ -311,9 +311,9 @@ Detect user intent from their message, then follow the corresponding workflow:
|
|
|
311
311
|
4. **For per-refactor session logs** (when user asks about a specific refactor):
|
|
312
312
|
```powershell
|
|
313
313
|
# Check refactor status for last session ID
|
|
314
|
-
Get-Content .prizmkit/state/refactor
|
|
314
|
+
Get-Content .prizmkit/state/refactor/<REFACTOR_ID>/status.json -ErrorAction SilentlyContinue
|
|
315
315
|
# Then tail that refactor's session log
|
|
316
|
-
Get-Content -Tail 100 .prizmkit/state/refactor
|
|
316
|
+
Get-Content -Tail 100 .prizmkit/state/refactor/<REFACTOR_ID>/sessions/<SESSION_ID>/logs/session.log
|
|
317
317
|
```
|
|
318
318
|
|
|
319
319
|
---
|
package/package.json
CHANGED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# monitor-log.sh — Background log size monitor for AI session subagent
|
|
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
|
-
# bash monitor-log.sh <session_log> <max_size> <poll_interval> <status_file> <baseline_file>
|
|
10
|
-
#
|
|
11
|
-
# Status file format (JSON, rewritten each poll cycle):
|
|
12
|
-
# {
|
|
13
|
-
# "status": "OK" | "COMPACT_NEEDED",
|
|
14
|
-
# "total_bytes": <current session.log size in bytes>,
|
|
15
|
-
# "baseline_bytes": <baseline size from last compact>,
|
|
16
|
-
# "effective_bytes": <total - baseline>,
|
|
17
|
-
# "threshold_bytes": <compact threshold>,
|
|
18
|
-
# "overage_bytes": <effective - threshold, 0 if not exceeded>,
|
|
19
|
-
# "usage_pct": <effective / threshold * 100, integer>
|
|
20
|
-
# }
|
|
21
|
-
|
|
22
|
-
SESSION_LOG="${1}"
|
|
23
|
-
MAX_SIZE="${2}"
|
|
24
|
-
POLL_INTERVAL="${3}"
|
|
25
|
-
STATUS_FILE="${4}"
|
|
26
|
-
BASELINE_FILE="${5}"
|
|
27
|
-
|
|
28
|
-
# Validate required args
|
|
29
|
-
if [[ -z "$SESSION_LOG" || -z "$MAX_SIZE" || -z "$POLL_INTERVAL" || -z "$STATUS_FILE" || -z "$BASELINE_FILE" ]]; then
|
|
30
|
-
echo "Usage: $0 <session_log> <max_size> <poll_interval> <status_file> <baseline_file>" >&2
|
|
31
|
-
exit 1
|
|
32
|
-
fi
|
|
33
|
-
|
|
34
|
-
# Ensure status dir exists
|
|
35
|
-
mkdir -p "$(dirname "$STATUS_FILE")"
|
|
36
|
-
|
|
37
|
-
# Validate numeric args
|
|
38
|
-
if ! [[ "$MAX_SIZE" =~ ^[0-9]+$ ]]; then
|
|
39
|
-
echo "ERROR: max_size must be a non-negative integer" >&2
|
|
40
|
-
exit 1
|
|
41
|
-
fi
|
|
42
|
-
if ! [[ "$POLL_INTERVAL" =~ ^[0-9]+$ ]] || [[ "$POLL_INTERVAL" -le 0 ]]; then
|
|
43
|
-
echo "ERROR: poll_interval must be a positive integer" >&2
|
|
44
|
-
exit 1
|
|
45
|
-
fi
|
|
46
|
-
|
|
47
|
-
echo "[monitor-log] Starting log monitor: max=${MAX_SIZE} interval=${POLL_INTERVAL}s" >&2
|
|
48
|
-
echo "[monitor-log] Watching: $SESSION_LOG" >&2
|
|
49
|
-
|
|
50
|
-
while true; do
|
|
51
|
-
# Read current log size
|
|
52
|
-
if [[ -f "$SESSION_LOG" ]]; then
|
|
53
|
-
size=$(wc -c < "$SESSION_LOG" 2>/dev/null | tr -d ' ')
|
|
54
|
-
else
|
|
55
|
-
size=0
|
|
56
|
-
fi
|
|
57
|
-
|
|
58
|
-
# Read baseline (resets after each /compact)
|
|
59
|
-
baseline=0
|
|
60
|
-
if [[ -f "$BASELINE_FILE" ]]; then
|
|
61
|
-
baseline=$(cat "$BASELINE_FILE" 2>/dev/null | tr -d ' ')
|
|
62
|
-
if ! [[ "$baseline" =~ ^[0-9]+$ ]]; then
|
|
63
|
-
baseline=0
|
|
64
|
-
fi
|
|
65
|
-
fi
|
|
66
|
-
|
|
67
|
-
# Effective size = growth since last compact
|
|
68
|
-
effective=$((size - baseline))
|
|
69
|
-
if [[ $effective -lt 0 ]]; then
|
|
70
|
-
effective=0
|
|
71
|
-
fi
|
|
72
|
-
|
|
73
|
-
# Determine status (MAX_SIZE=0 disables monitoring)
|
|
74
|
-
if [[ $MAX_SIZE -gt 0 && $effective -gt $MAX_SIZE ]]; then
|
|
75
|
-
status="COMPACT_NEEDED"
|
|
76
|
-
overage=$((effective - MAX_SIZE))
|
|
77
|
-
echo "[monitor-log] COMPACT_NEEDED: effective=${effective} overage=${overage} (threshold=${MAX_SIZE})" >&2
|
|
78
|
-
else
|
|
79
|
-
status="OK"
|
|
80
|
-
overage=0
|
|
81
|
-
fi
|
|
82
|
-
|
|
83
|
-
# Usage percentage (effective / threshold * 100)
|
|
84
|
-
if [[ $MAX_SIZE -gt 0 ]]; then
|
|
85
|
-
usage_pct=$((effective * 100 / MAX_SIZE))
|
|
86
|
-
else
|
|
87
|
-
usage_pct=0
|
|
88
|
-
fi
|
|
89
|
-
|
|
90
|
-
# Write structured JSON status
|
|
91
|
-
cat > "$STATUS_FILE" << EOF
|
|
92
|
-
{
|
|
93
|
-
"status": "${status}",
|
|
94
|
-
"total_bytes": ${size},
|
|
95
|
-
"baseline_bytes": ${baseline},
|
|
96
|
-
"effective_bytes": ${effective},
|
|
97
|
-
"threshold_bytes": ${MAX_SIZE},
|
|
98
|
-
"overage_bytes": ${overage},
|
|
99
|
-
"usage_pct": ${usage_pct}
|
|
100
|
-
}
|
|
101
|
-
EOF
|
|
102
|
-
|
|
103
|
-
sleep "$POLL_INTERVAL"
|
|
104
|
-
done
|
|
@@ -1,102 +0,0 @@
|
|
|
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
|
-
}
|