fix(session-handoff): PowerShell hook body char count [v0.3.1]
`(& git log -1 --format='%b')` in PowerShell collapses multi-line subprocess
output into string[]. The threshold check used `$body.Length` which on a
string[] returns the line count, not char count — so the body>200 condition
was effectively comparing "more than 200 lines", which is much harder to
meet. Files-count saves it in practice for big commits, but small-file
big-message commits were under-detected.
Fix: join the array back into a single string with `-join "`n"` before
measuring length. Verified via stdin-pipe smoke against current HEAD:
body chars now report 1255 (vs 29 before — the line count).
POSIX `.sh` variant unaffected — `$()` collapses output and `${#var}` is
char count.
Bump 0.3.0 → 0.3.1 PATCH (bugfix, no behavior contract change).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: session-handoff
|
||||
version: 0.3.0
|
||||
version: 0.3.1
|
||||
description: "Sliding handoff between CC sessions via .tasks/NEXT_SESSION.md. Read on session start: orient agent, ask user before action. Write on session-end phrase or substantive commit. Session-end phrases: «завершаем сессию», «сворачиваемся», «закругляемся», «wrap up session», «end session», «we're done for now». Trigger-line in CLAUDE.md: `session handoff: read on start, write on end`. Skip task-zone phrases: «закрываем эту таску», «pause», «отбой», «разбегаемся»."
|
||||
---
|
||||
|
||||
|
||||
@@ -43,7 +43,9 @@ if ($inside -ne 'true') { exit 0 }
|
||||
|
||||
# Parse last commit
|
||||
$subject = (& git -C $cwd log -1 --format='%s').Trim()
|
||||
$body = (& git -C $cwd log -1 --format='%b')
|
||||
# PowerShell collapses multi-line subprocess output into string[] — join back so
|
||||
# .Length below is char count, not line count.
|
||||
$body = ((& git -C $cwd log -1 --format='%b') -join "`n")
|
||||
$files = ((& git -C $cwd diff-tree --no-commit-id --name-only -r HEAD) | Measure-Object).Count
|
||||
|
||||
# Trivial-prefix check (Conventional Commits prefix before optional scope + colon)
|
||||
@@ -52,10 +54,11 @@ $trivial = @('meta','docs','style','chore')
|
||||
if ($trivial -contains $prefix) { exit 0 }
|
||||
if ($subject -match 'fix\s+typo') { exit 0 }
|
||||
|
||||
# Threshold check
|
||||
# Threshold check (chars for body, count for files)
|
||||
$bodyLen = if ($body) { $body.Length } else { 0 }
|
||||
if ($bodyLen -le 200 -and $files -le 3) { exit 0 }
|
||||
|
||||
|
||||
# Substantive — emit JSON
|
||||
$msg = "Substantive commit detected on " + $cwd + ": ``" + $subject + "`` (" + $files + " files changed, body " + $bodyLen + " chars). Consider invoking session-handoff write-mode to update .tasks/NEXT_SESSION.md."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user