Skip to content

perf(hook): avoid Pi package barrel import - #2938

Merged
KuSh merged 2 commits into
rtk-ai:developfrom
raj921:fix/pi-slow-startup
Aug 26, 2026
Merged

KuSh merged 2 commits into
rtk-ai:developfrom
raj921:fix/pi-slow-startup

Conversation

@raj921

@raj921 raj921 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace the runtime package import with a local type guard, so the Pi extension does not load the package barrel at startup.
  • Add a regression check that rejects value imports in the installed extension.

Fixes #2753

Test plan

  • Type-checked hooks/pi/rtk.ts against @earendil-works/pi-coding-agent 0.80.6
  • cargo test test_run_pi_mode_global_installs_plugin
  • cargo fmt --all --check && cargo clippy --all-targets && cargo test

Timing

With Bun 1.3.14 on macOS arm64, loading the package barrel took about 250 ms after warmup. Loading the small extensions module took about 10 ms.

@CLAassistant

CLAassistant commented Jul 10, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@kingpy-bot kingpy-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independently verified this on exact head 3e7d02d7b4bdcfaba8793433267c83721a34de44. The only runtime value import from the Pi package barrel is removed; the replacement imports are type-only and the local toolName === "bash" guard preserves the handler's runtime filtering before reading event.input.command.

In an isolated Rust 1.91 container, the focused Pi install regression passed, cargo fmt --all --check and cargo clippy --all-targets -- -D warnings passed, and the full cargo test --all gate passed (2,493 tests, 8 ignored). The installed-extension assertion also exercises the intended no-runtime-named-import invariant.

AI-assisted review.

@KuSh KuSh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except a few comments missing to document things

Comment thread hooks/pi/rtk.ts Resolved
Comment thread src/hooks/init.rs Resolved
@KuSh KuSh self-assigned this Jul 26, 2026
…#2753

Also fixes two docs left stale by the barrel-import removal: hooks/pi/README.md
and hooks/README.md still described bash-tool detection via the removed
isToolCallEventType value import.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@KuSh
KuSh merged commit 322db4d into rtk-ai:develop Aug 26, 2026
9 of 10 checks passed
@rtk-release-bot rtk-release-bot Bot mentioned this pull request Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pi slow startup

4 participants