planning-with-files 3.10.2 → 3.12.0

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.
@@ -1,128 +1,128 @@
1
- #requires -Version 5.0
2
- <#
3
- .SYNOPSIS
4
- Emit a fixed-shape, cache-stable run-ledger summary (PowerShell mirror, v3).
5
-
6
- .DESCRIPTION
7
- Replaces raw progress.md tail injection in autonomous mode. Output is
8
- synthesized from the machine ledger and task_plan.md status counts only:
9
- NO free text from disk reaches model context, and NO timestamps, so the
10
- injected block is KV-cache stable by construction (architecture C3).
11
-
12
- Plan-dir resolution matches resolve-plan-dir.ps1:
13
- 1. $env:PLAN_ID -> .\.planning\$PLAN_ID\
14
- 2. .\.planning\.active_plan
15
- 3. Newest .\.planning\<dir>\ by LastWriteTime
16
- 4. Legacy: project root
17
-
18
- Output block (stable shape):
19
- === RUN LEDGER ===
20
- entries: <N>
21
- phases: <complete>/<total> complete
22
- in_progress: <phase heading or none>
23
- agent <name>: <last event type>
24
- ==================
25
- #>
26
- [CmdletBinding()]
27
- param()
28
-
29
- $ErrorActionPreference = "Stop"
30
-
31
- function Resolve-PlanDir {
32
- $planRoot = Join-Path (Get-Location) ".planning"
33
-
34
- if ($env:PLAN_ID) {
35
- $candidate = Join-Path $planRoot $env:PLAN_ID
36
- if (Test-Path -LiteralPath $candidate -PathType Container) { return $candidate }
37
- }
38
-
39
- $activePointer = Join-Path $planRoot ".active_plan"
40
- if (Test-Path -LiteralPath $activePointer) {
41
- $planId = (Get-Content -LiteralPath $activePointer -Raw).Trim()
42
- if ($planId) {
43
- $candidate = Join-Path $planRoot $planId
44
- if (Test-Path -LiteralPath $candidate -PathType Container) { return $candidate }
45
- }
46
- }
47
-
48
- if (Test-Path -LiteralPath $planRoot -PathType Container) {
49
- $newest = Get-ChildItem -LiteralPath $planRoot -Directory -ErrorAction SilentlyContinue |
50
- Where-Object { -not $_.Name.StartsWith(".") } |
51
- Where-Object { Test-Path -LiteralPath (Join-Path $_.FullName "task_plan.md") } |
52
- Sort-Object LastWriteTime -Descending |
53
- Select-Object -First 1
54
- if ($newest) { return $newest.FullName }
55
- }
56
-
57
- return (Get-Location).Path
58
- }
59
-
60
- $planDir = Resolve-PlanDir
61
- $planFile = Join-Path $planDir "task_plan.md"
62
-
63
- # --- Phase counts: same patterns as check-complete.ps1 ---
64
- $TOTAL = 0
65
- $COMPLETE = 0
66
- $IN_PROGRESS = 0
67
- $inProgressHeading = "none"
68
-
69
- if (Test-Path -LiteralPath $planFile) {
70
- $content = Get-Content -LiteralPath $planFile -Raw
71
- $TOTAL = ([regex]::Matches($content, "### Phase")).Count
72
- $COMPLETE = ([regex]::Matches($content, "\*\*Status:\*\* complete")).Count
73
- $IN_PROGRESS = ([regex]::Matches($content, "\*\*Status:\*\* in_progress")).Count
74
-
75
- if ($COMPLETE -eq 0 -and $IN_PROGRESS -eq 0) {
76
- $c2 = ([regex]::Matches($content, "\[complete\]")).Count
77
- $i2 = ([regex]::Matches($content, "\[in_progress\]")).Count
78
- if ($c2 -gt 0 -or $i2 -gt 0) {
79
- $COMPLETE = $c2
80
- $IN_PROGRESS = $i2
81
- }
82
- }
83
-
84
- # Heading of the first phase block whose status is in_progress.
85
- $heading = ""
86
- foreach ($line in (Get-Content -LiteralPath $planFile)) {
87
- if ($line -match "^### Phase") {
88
- $heading = $line
89
- } elseif ($line -match "\*\*Status:\*\* in_progress" -or $line -match "\[in_progress\]") {
90
- if ($heading) {
91
- $inProgressHeading = $heading
92
- break
93
- }
94
- }
95
- }
96
- }
97
-
98
- # --- Ledger stats ---
99
- $totalEntries = 0
100
- $ledgerFiles = Get-ChildItem -LiteralPath $planDir -Filter "ledger-*.jsonl" -File -ErrorAction SilentlyContinue
101
- foreach ($f in $ledgerFiles) {
102
- $lines = Get-Content -LiteralPath $f.FullName -ErrorAction SilentlyContinue
103
- foreach ($line in $lines) {
104
- if ($line -match '"tick"') { $totalEntries++ }
105
- }
106
- }
107
-
108
- Write-Output "=== RUN LEDGER ==="
109
- Write-Output ("entries: " + $totalEntries)
110
- Write-Output ("phases: " + $COMPLETE + "/" + $TOTAL + " complete")
111
- Write-Output ("in_progress: " + $inProgressHeading)
112
-
113
- foreach ($f in $ledgerFiles) {
114
- $agent = $f.Name -replace '^ledger-', '' -replace '\.jsonl$', ''
115
- # @(...) forces array semantics: a single-line file returns a string from
116
- # Get-Content and $lines[-1] would otherwise index the last character.
117
- $lines = @(Get-Content -LiteralPath $f.FullName -ErrorAction SilentlyContinue)
118
- $lastEvent = "none"
119
- if ($lines.Count -gt 0) {
120
- $lastLine = $lines[$lines.Count - 1]
121
- $m = [regex]::Match($lastLine, '"event"\s*:\s*"([A-Za-z_]+)"')
122
- if ($m.Success) { $lastEvent = $m.Groups[1].Value }
123
- }
124
- Write-Output ("agent " + $agent + ": " + $lastEvent)
125
- }
126
-
127
- Write-Output "=================="
128
- exit 0
1
+ #requires -Version 5.0
2
+ <#
3
+ .SYNOPSIS
4
+ Emit a fixed-shape, cache-stable run-ledger summary (PowerShell mirror, v3).
5
+
6
+ .DESCRIPTION
7
+ Replaces raw progress.md tail injection in autonomous mode. Output is
8
+ synthesized from the machine ledger and task_plan.md status counts only:
9
+ NO free text from disk reaches model context, and NO timestamps, so the
10
+ injected block is KV-cache stable by construction (architecture C3).
11
+
12
+ Plan-dir resolution matches resolve-plan-dir.ps1:
13
+ 1. $env:PLAN_ID -> .\.planning\$PLAN_ID\
14
+ 2. .\.planning\.active_plan
15
+ 3. Newest .\.planning\<dir>\ by LastWriteTime
16
+ 4. Legacy: project root
17
+
18
+ Output block (stable shape):
19
+ === RUN LEDGER ===
20
+ entries: <N>
21
+ phases: <complete>/<total> complete
22
+ in_progress: <phase heading or none>
23
+ agent <name>: <last event type>
24
+ ==================
25
+ #>
26
+ [CmdletBinding()]
27
+ param()
28
+
29
+ $ErrorActionPreference = "Stop"
30
+
31
+ function Resolve-PlanDir {
32
+ $planRoot = Join-Path (Get-Location) ".planning"
33
+
34
+ if ($env:PLAN_ID) {
35
+ $candidate = Join-Path $planRoot $env:PLAN_ID
36
+ if (Test-Path -LiteralPath $candidate -PathType Container) { return $candidate }
37
+ }
38
+
39
+ $activePointer = Join-Path $planRoot ".active_plan"
40
+ if (Test-Path -LiteralPath $activePointer) {
41
+ $planId = (Get-Content -LiteralPath $activePointer -Raw).Trim()
42
+ if ($planId) {
43
+ $candidate = Join-Path $planRoot $planId
44
+ if (Test-Path -LiteralPath $candidate -PathType Container) { return $candidate }
45
+ }
46
+ }
47
+
48
+ if (Test-Path -LiteralPath $planRoot -PathType Container) {
49
+ $newest = Get-ChildItem -LiteralPath $planRoot -Directory -ErrorAction SilentlyContinue |
50
+ Where-Object { -not $_.Name.StartsWith(".") } |
51
+ Where-Object { Test-Path -LiteralPath (Join-Path $_.FullName "task_plan.md") } |
52
+ Sort-Object LastWriteTime -Descending |
53
+ Select-Object -First 1
54
+ if ($newest) { return $newest.FullName }
55
+ }
56
+
57
+ return (Get-Location).Path
58
+ }
59
+
60
+ $planDir = Resolve-PlanDir
61
+ $planFile = Join-Path $planDir "task_plan.md"
62
+
63
+ # --- Phase counts: same patterns as check-complete.ps1 ---
64
+ $TOTAL = 0
65
+ $COMPLETE = 0
66
+ $IN_PROGRESS = 0
67
+ $inProgressHeading = "none"
68
+
69
+ if (Test-Path -LiteralPath $planFile) {
70
+ $content = Get-Content -LiteralPath $planFile -Raw
71
+ $TOTAL = ([regex]::Matches($content, "### Phase")).Count
72
+ $COMPLETE = ([regex]::Matches($content, "\*\*Status:\*\* complete")).Count
73
+ $IN_PROGRESS = ([regex]::Matches($content, "\*\*Status:\*\* in_progress")).Count
74
+
75
+ if ($COMPLETE -eq 0 -and $IN_PROGRESS -eq 0) {
76
+ $c2 = ([regex]::Matches($content, "\[complete\]")).Count
77
+ $i2 = ([regex]::Matches($content, "\[in_progress\]")).Count
78
+ if ($c2 -gt 0 -or $i2 -gt 0) {
79
+ $COMPLETE = $c2
80
+ $IN_PROGRESS = $i2
81
+ }
82
+ }
83
+
84
+ # Heading of the first phase block whose status is in_progress.
85
+ $heading = ""
86
+ foreach ($line in (Get-Content -LiteralPath $planFile)) {
87
+ if ($line -match "^### Phase") {
88
+ $heading = $line
89
+ } elseif ($line -match "\*\*Status:\*\* in_progress" -or $line -match "\[in_progress\]") {
90
+ if ($heading) {
91
+ $inProgressHeading = $heading
92
+ break
93
+ }
94
+ }
95
+ }
96
+ }
97
+
98
+ # --- Ledger stats ---
99
+ $totalEntries = 0
100
+ $ledgerFiles = Get-ChildItem -LiteralPath $planDir -Filter "ledger-*.jsonl" -File -ErrorAction SilentlyContinue
101
+ foreach ($f in $ledgerFiles) {
102
+ $lines = Get-Content -LiteralPath $f.FullName -ErrorAction SilentlyContinue
103
+ foreach ($line in $lines) {
104
+ if ($line -match '"tick"') { $totalEntries++ }
105
+ }
106
+ }
107
+
108
+ Write-Output "=== RUN LEDGER ==="
109
+ Write-Output ("entries: " + $totalEntries)
110
+ Write-Output ("phases: " + $COMPLETE + "/" + $TOTAL + " complete")
111
+ Write-Output ("in_progress: " + $inProgressHeading)
112
+
113
+ foreach ($f in $ledgerFiles) {
114
+ $agent = $f.Name -replace '^ledger-', '' -replace '\.jsonl$', ''
115
+ # @(...) forces array semantics: a single-line file returns a string from
116
+ # Get-Content and $lines[-1] would otherwise index the last character.
117
+ $lines = @(Get-Content -LiteralPath $f.FullName -ErrorAction SilentlyContinue)
118
+ $lastEvent = "none"
119
+ if ($lines.Count -gt 0) {
120
+ $lastLine = $lines[$lines.Count - 1]
121
+ $m = [regex]::Match($lastLine, '"event"\s*:\s*"([A-Za-z_]+)"')
122
+ if ($m.Success) { $lastEvent = $m.Groups[1].Value }
123
+ }
124
+ Write-Output ("agent " + $agent + ": " + $lastEvent)
125
+ }
126
+
127
+ Write-Output "=================="
128
+ exit 0