Repository navigation
refactor(launcher): scope SessionStart provision pre-warm to the startup matcher - #5
Merged
Merged
Conversation
…rtup` matcher
Provisioning the pinned bun into CLAUDE_PLUGIN_DATA is a first-session concern,
so the pre-warm hook does not need to re-fire on resume/clear/compact (the bun
already exists by then). Add `matcher: "startup"` to the SessionStart hook.
Why not the `Setup` event (the obvious "this is setup, not per-session" instinct):
`Setup` fires only on explicit `claude --init-only` / `-p --init|--maintenance`
("one-time preparation in CI or scripts") — never on plugin install or normal
startup. Moving the pre-warm there would skip it for ordinary users, so the first
scholar tool call would pay the full cold bun download + (on the source-sync path)
the ~67 MB import-graph auto-install — the cold-start latency already seen in the
field. The Claude Code plugins reference prescribes a guarded SessionStart hook
writing into CLAUDE_PLUGIN_DATA for exactly this "install a dependency once, reuse
across sessions and updates" case; this change keeps that mechanism and just
narrows when it fires.
Changes:
- .claude-plugin/plugin.json (committed source-sync manifest): matcher added.
- scripts/build-plugin.ts buildManifest(): matcher added to the generated per-OS
manifests + rationale comment. buildMcpbManifest emits no SessionStart hook
(Desktop schema), so it is unaffected.
- tests/manifests.test.ts + tests/build-plugin.test.ts: assert matcher:"startup"
(committed manifest + linux/win32 generated manifests).
- 2026-06-01-slim-plugin-pivot spec: forward-looking hook description updated.
Verified: both targets build (linux 2.9 MB / win32 3.0 MB, 19 files each) and the
generated manifests carry matcher:"startup"; suite 391 pass / 0 fail; tsc clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR scopes the SessionStart bun pre-warm hook to only run on the startup matcher, avoiding redundant provisioning work on other session triggers while preserving correctness (the launcher remains the synchronous provisioning gate).
Changes:
- Add
matcher: "startup"to the committed.claude-plugin/plugin.jsonSessionStart hook. - Update
scripts/build-plugin.tsto emitmatcher: "startup"in generated per-OS plugin manifests. - Strengthen tests and documentation to assert/describe the
startup-scoped pre-warm behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
tests/manifests.test.ts |
Updates the committed-manifest assertion to require matcher: "startup" on the SessionStart hook. |
tests/build-plugin.test.ts |
Adds checks that generated linux/win32 manifests include SessionStart[0].matcher === "startup". |
scripts/build-plugin.ts |
Emits matcher: "startup" for the generated SessionStart pre-warm hook and documents the rationale inline. |
docs/superpowers/specs/2026-06-01-slim-plugin-pivot.md |
Updates the spec to reflect that the SessionStart pre-warm is scoped to startup. |
.claude-plugin/plugin.json |
Adds "matcher": "startup" to the committed SessionStart hook group. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…as current in isolation Follow-up to the matcher-scoping change (this branch / PR #5), addressing the doc-hygiene item it surfaced. The bun-launcher unification (PR #4) retired the per-OS `launch.{sh,cmd}` shell pair, and every stale reference in the docs already carries an adjacent supersede banner (repo convention: keep the dated record, add a banner). The residual problem is the grep/scroll-lander: two lines state the retired shell-pair launcher as the *current* mechanism when read without the banner in view. Self-label them inline; the historical data stays put (the banners say to keep it). - docs/.../2026-06-01-slim-plugin-pivot.md: the "Both packages build" bullet-list intro now names the 2026-06-01 sizes + `launch.{sh,cmd}` in the bullets below as the retired shell-pair record and points at the current `bun launch.mjs`. - docs/audits/2026-06-02-maintenance-readiness.md: the "Launch chain" status row is tagged as a 2026-06-02 snapshot superseded by the note directly below it. Left as-is (already adequately framed): the supersede banners themselves; the RESOLVED+moot `launch.cmd` CRLF section; HUMAN.md's "(2026-06-03)" launcher-proof paragraph (bold dated header + adjacent banner). Docs-only; no code/test change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Scope the SessionStart provisioning pre-warm hook to the
startupmatcher(
matcher: "startup"), in both the committed source-sync manifest and thegenerated per-OS bundle manifests.
Provisioning the pinned bun into
CLAUDE_PLUGIN_DATAis a first-sessionconcern. There's no point re-firing the pre-warm on
resume/clear/compact—the bun already exists by then. Narrowing the matcher avoids that wasted work.
This is a follow-up to the launcher unification (PR #4, merged). It targets
main.Why
startup, and why notSetupThe instinct "this is setup, not per-session, so use the
Setupevent" iswrong here. Per the Claude Code hooks reference:
Setupfires only on explicitclaude --init-only/-p --init | --maintenance("one-time preparation in CI or scripts") — never on plugininstall or normal startup. Moving the pre-warm there would skip it for ordinary
users, so the first scholar tool call would pay the full cold bun download +
(on the source-sync path) the ~67 MB import-graph auto-install — the cold-start
latency already seen in the field.
SessionStart/startupfires on a new session — exactly thefirst-session case we want.
The plugins reference prescribes the SessionStart-into-
CLAUDE_PLUGIN_DATAmechanism (install a dependency once, reuse across sessions and updates), but
its example is unscoped, guarding idempotency with an in-hook
diff. Thestartupnarrowing is scholar's own decision, not a doc prescription, and issafe because:
ensure-bunis already idempotent + flock-guarded (scholar's guard-equivalentto the docs'
diff), andlaunch.mjs(no flag) is the real correctness gate — it provisionssynchronously before spawning the server, hook or not. The SessionStart hook is
a latency-only pre-warm (SessionStart does not block MCP spawn).
So even on a
CLAUDE_PLUGIN_DATAwipe or abundledBunVersionbump — where aresumesession would otherwise skip re-provisioning — correctness still holds:the launcher re-provisions on the next spawn regardless.
Changes
.claude-plugin/plugin.json(committed source-sync manifest):matcheradded.scripts/build-plugin.tsbuildManifest():matcheradded to the generatedper-OS manifests + rationale comment.
buildMcpbManifestemits no SessionStarthook (Claude Desktop schema), so it is unaffected.
tests/manifests.test.ts+tests/build-plugin.test.ts: assertmatcher: "startup"(committed manifest + linux/win32 generated manifests).docs/.../2026-06-01-slim-plugin-pivot.md: hook-scope description updated.Verification (and its boundary)
tsc --noEmitclean.
startupmatcher value is confirmed against the Claude Code hooksreference (
startup/resume/clear/compact) and corroborated by the exacttrigger descriptions in that table.
Boundary: the green checks prove the emitted JSON carries
matcher:"startup"and that both bundles build — they do not exercise a live plugin install, so
they don't prove Claude Code honors the matcher on a plugin SessionStart hook at
load time. Low risk (it's a documented field), but that leg is unproven here.
Doc-hygiene follow-up (resolved — second commit)
The first surfacing of this PR flagged retired
launch.{sh,cmd}references in thedocs. On full review, every such reference already carries an adjacent
supersede banner (repo convention: keep the dated record + add a banner) — so
nothing was unguarded. The one residual failure mode is the grep/scroll-lander:
two lines state the retired shell-pair launcher as the current mechanism when
read without the banner in view. The second commit (
docs(launcher): self-label …) self-labels those two lines inline, keeping the historical data per thebanners:
docs/.../2026-06-01-slim-plugin-pivot.md— the "Both packages build" bulletintro now names the 2026-06-01 bullets as the retired record + points at
bun launch.mjs.docs/audits/2026-06-02-maintenance-readiness.md— the "Launch chain" statusrow is tagged a 2026-06-02 snapshot, superseded by the note directly below.
Left as-is (already adequately framed): the supersede banners; the RESOLVED+moot
launch.cmdCRLF section; HUMAN.md's bold-dated "(2026-06-03)" launcher-proofparagraph. Docs-only commit; no code/test change.
🤖 Generated with Claude Code