perf: faster session startup and statusline rendering#40
Conversation
Reduces session startup overhead from ~1.1s (3x Python/uv startup) to ~0.4s (1x) by combining inject_workflow_orchestrator, inject-output-style, and inject_token_efficiency into a single inject_all.py that reads stdin once and merges all additionalContext into one JSON response.
Review Summary by QodoConsolidate SessionStart hooks and optimize statusline rendering with stdin JSON
WalkthroughsDescription• Consolidate 3 SessionStart hooks into single inject_all.py script (~0.7s faster startup) • Read version/context from stdin JSON instead of subprocess calls (~1.9s faster statusline renders) • Implement 1-hour TTL cache for claude --version fallback when stdin unavailable • Update plugin version to v1.17.0 and plugin-hooks.json configuration Diagramflowchart LR
A["3 separate hooks<br/>inject_workflow_orchestrator.py<br/>inject-output-style.py<br/>inject_token_efficiency.py"] -->|consolidate| B["Single inject_all.py<br/>reads stdin once<br/>merges additionalContext"]
C["Subprocess calls<br/>claude --version<br/>JSONL file scans"] -->|optimize| D["stdin JSON fields<br/>version<br/>context_window"]
D -->|fallback| E["Cached version<br/>1-hour TTL<br/>tempfile"]
B -->|result| F["~1.7s faster<br/>session startup"]
D -->|result| G["~1.9s faster<br/>statusline render"]
File Changes1. hooks/SessionStart/inject_all.py
|
Code Review by Qodo
1. Tests call removed hook
|
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "uv run --no-project --script \"${CLAUDE_PLUGIN_ROOT}/hooks/SessionStart/inject_workflow_orchestrator.py\"", | ||
| "command": "uv run --no-project --script \"${CLAUDE_PLUGIN_ROOT}/hooks/SessionStart/inject_all.py\"", | ||
| "timeout": 20 | ||
| }, | ||
| { | ||
| "type": "command", | ||
| "command": "uv run --no-project --script \"${CLAUDE_PLUGIN_ROOT}/hooks/SessionStart/inject-output-style.py\"", | ||
| "timeout": 10 | ||
| }, | ||
| { | ||
| "type": "command", | ||
| "command": "uv run --no-project --script \"${CLAUDE_PLUGIN_ROOT}/hooks/SessionStart/inject_token_efficiency.py\"", | ||
| "timeout": 10 | ||
| } | ||
| ] |
There was a problem hiding this comment.
1. Tests call removed hook 🐞 Bug ≡ Correctness
The PR switches SessionStart to run only inject_all.py, but tests still import/execute hooks/SessionStart/inject_token_efficiency.py, which no longer exists, causing immediate CI failures (ImportError/FileNotFoundError).
Agent Prompt
## Issue description
SessionStart hooks are consolidated to `inject_all.py`, but the test suite still imports/runs `hooks/SessionStart/inject_token_efficiency.py` and asserts its old output semantics. This will break CI because the file is no longer present and the consolidated behavior differs.
## Issue Context
- SessionStart hook config now points to `inject_all.py`.
- Tests/fixtures still hardcode `inject_token_efficiency.py`.
## Fix Focus Areas
Choose one of:
1) **Update tests to target `inject_all.py`**
- Adjust fixtures and integration/unit tests to load/run `inject_all.py`.
- Update assertions: `CLAUDE_TOKEN_EFFICIENCY=0` should disable only the token-efficiency section, not necessarily produce empty stdout.
2) **Add backward-compatible wrapper scripts**
- Re-introduce `inject_token_efficiency.py` (and optionally the other two scripts) as thin wrappers that call into `inject_all.py` or preserve old behavior for tests/users.
### Files to edit
- hooks/plugin-hooks.json[81-90]
- tests/conftest.py[50-56]
- tests/test_integration.py[93-125]
- hooks/SessionStart/inject_all.py[1-15]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Summary
Changes
SessionStart hooks consolidated
inject_workflow_orchestrator.py,inject-output-style.py,inject_token_efficiency.pyinto singleinject_all.pyplugin-hooks.jsonto reference single scriptStatusline performance
versionfield instead of spawningclaude --version(920ms → 0ms)context_windowinstead of parsing JSONL filesclaude --versionwith 1-hour TTL if stdin unavailableImpact
Test plan
claudestart with plugin loads within reasonable time🤖 Generated with Claude Code