feat: Stop-hook haiku AI context summarization (v1.5.0)#39
Merged
Conversation
Summarize Claude's last_assistant_message via claude-haiku on the Stop hook. Detached subprocess writes to context file; first-5-words remains as the immediate placeholder. Delivers ~100% AI summaries (up from 0.5% with inline strategy).
Strip (venv), user@host, and shell prompt characters ($ % # >) from first-5-words context. Simplify user-prompt handler by removing the haiku subprocess and inline strategy check (now handled by Stop hook).
Write the commit subject line to the context file when a git commit is detected in post-tool. Remove the inline AI context marker scanning block and all associated tests — inline strategy is now dead code.
Remove --ai-context-strategy flag, inline --append-system-prompt injection, display filtering, strategy validation, and debug event field. AI context is now a simple boolean: --ai-context enables Stop-hook haiku.
Remove inline_captured.* from stale file cleanup and inline_marker_miss event handler from Pulse Monitor.
Rewrite AI context docs, remove inline-context-spec, update README with new features (commit message capture, context sanitization), simplify CLI flag documentation.
zsh prompts include a directory name between user@host and the prompt character: (venv) user@host dir % command. The previous sed chain stripped (venv) and user@host but left dir % because % wasn't at position 0. Add a sed to strip an optional word before the prompt char.
There was a problem hiding this comment.
Pull request overview
This PR upgrades ccp’s AI context summarization by removing the unreliable inline-marker strategy and switching to Stop-hook-based haiku summarization derived from Claude’s actual response text (last_assistant_message), with additional context improvements (commit subject capture + prompt sanitization).
Changes:
- Replace inline AI context strategy with Stop-hook haiku summarization (two-phase: immediate first-5-words placeholder, then refined haiku after turn completes).
- Add automatic context enrichment: git commit subject capture and prompt prefix sanitization for pasted terminal content.
- Remove inline-strategy CLI/docs/tests and simplify debug monitoring around summary delivery.
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
lib/hook_runner.sh |
Adds prompt sanitization, implements Stop-hook haiku summarization using last_assistant_message, and captures git commit subjects into context. |
bin/ccp |
Removes --ai-context-strategy support and simplifies AI context startup messaging. |
tests/test-suite.sh |
Adds coverage for sanitization, stop-hook haiku behavior, truncation, CLAUDECODE clearing, and commit subject capture; removes inline-strategy tests. |
README.md |
Updates feature description and usage examples to reflect Stop-hook haiku summarization and removal of inline strategy. |
docs/ai-context.md |
Documents two-phase context and new Stop-hook summarization inputs/privacy implications. |
docs/dynamic-titles.md |
Updates hook behavior documentation (Stop now triggers summarization; commit writes context). |
docs/usage.md |
Removes --ai-context-strategy flag documentation. |
docs/inline-context-spec.md |
Deletes the inline strategy spec doc. |
lib/session.sh |
Stops pruning inline sentinel files (inline strategy removed). |
bin/ccp-watch |
Simplifies summary delivery tracking (no pending/inline-miss tracking). |
CHANGELOG.md |
Adds v1.5.0 entry describing Stop-hook haiku, commit capture, sanitization, and inline removal. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- hook_runner.sh: add race guard to haiku subprocess — only writes context if no newer prompt has arrived since the subprocess launched - hook_runner.sh: sync _status_priority() with monitor.sh — add missing Rebasing and Cherry-picking to priority 75 - tests: replace flaky sleep 2 with polling loops in haiku tests - tests: use printf '%s' for sanitization test payloads to avoid format string fragility with % characters - README: add missing -p/--print to no-value flags list - CHANGELOG: add v1.5.0 comparison link - docs/dynamic-titles.md: fix SubagentStop status text to match code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Major usability upgrade to AI context summarization — switches from the inline marker strategy (0.5% delivery rate) to Stop-hook-based haiku summarization (~100% delivery rate).
last_assistant_message— Claude's actual response — truncates to first 500 + last 500 chars, and sends it toclaude-haikufor a 3-5 word title summary. Summarizes what Claude did, not just what was asked.💾 Committed— free, human-written task summary.(venv) user@host %) stripped from first-5-words when users paste terminal output.--ai-context-strategyflag,--append-system-promptinjection,CCP_TASK_SUMMARYmarkers, and sentinel files all cleaned out.--ai-contextis now a simple boolean toggle._status_priority()in hook_runner.sh now includes Rebasing and Cherry-picking at priority 75, matching monitor.sh.Net result: -261 lines, simpler codebase, dramatically better title context quality.
Test plan
${msg:0:500}and${msg: -500})ccp --ai-context "test task"and confirm title updates with haiku summary after Claude respondsgit commitReview fixes addressed
sleep 2with polling loops (0.25s intervals, 5s timeout) for positive cases;sleep 1for negative casesprintf '%s'instead of raw format strings