Squash the current repository state back into one baseline commit while
preserving the README reframing and repository contents.

Constraint: User explicitly requested a single squashed commit with subject "asdf"
Confidence: high
Scope-risk: broad
Reversibility: clean
Directive: This commit intentionally rewrites published history; coordinate before future force-pushes
Tested: git status clean; local history rewritten to one commit; force-pushed main to origin and instructkr
Not-tested: Fresh clone verification after push
This commit is contained in:
did:key:z6MkqDnb7Siv3Cwj7pGJq4T5EsUisECqR8KpnDLwcaZq5TPr
2026-03-31 03:34:03 -07:00
commit d2542c9a62
1903 changed files with 513517 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
import type {
RenderableMessage,
SystemStopHookSummaryMessage,
} from '../types/message.js'
function isLabeledHookSummary(
msg: RenderableMessage,
): msg is SystemStopHookSummaryMessage {
return (
msg.type === 'system' &&
msg.subtype === 'stop_hook_summary' &&
msg.hookLabel !== undefined
)
}
/**
* Collapses consecutive hook summary messages with the same hookLabel
* (e.g. PostToolUse) into a single summary. This happens when parallel
* tool calls each emit their own hook summary.
*/
export function collapseHookSummaries(
messages: RenderableMessage[],
): RenderableMessage[] {
const result: RenderableMessage[] = []
let i = 0
while (i < messages.length) {
const msg = messages[i]!
if (isLabeledHookSummary(msg)) {
const label = msg.hookLabel
const group: SystemStopHookSummaryMessage[] = []
while (i < messages.length) {
const next = messages[i]!
if (!isLabeledHookSummary(next) || next.hookLabel !== label) break
group.push(next)
i++
}
if (group.length === 1) {
result.push(msg)
} else {
result.push({
...msg,
hookCount: group.reduce((sum, m) => sum + m.hookCount, 0),
hookInfos: group.flatMap(m => m.hookInfos),
hookErrors: group.flatMap(m => m.hookErrors),
preventedContinuation: group.some(m => m.preventedContinuation),
hasOutput: group.some(m => m.hasOutput),
// Parallel tool calls' hooks overlap; max is closest to wall-clock.
totalDurationMs: Math.max(...group.map(m => m.totalDurationMs ?? 0)),
})
}
} else {
result.push(msg)
i++
}
}
return result
}