Skip to content

perf: lazy-load token burden command - #35

Closed
infectiousstupidity wants to merge 125 commits into
Whamp:mainfrom
infectiousstupidity:perf/lazy-runtime-loading
Closed

infectiousstupidity wants to merge 125 commits into
Whamp:mainfrom
infectiousstupidity:perf/lazy-runtime-loading

Conversation

@infectiousstupidity

@infectiousstupidity infectiousstupidity commented Aug 29, 2026 •

Copy link
Copy Markdown

Fixes #33.

Alternative implementation to #34.

Problem

pi-token-burden currently loads the full command dependency graph when the extension itself is loaded, even when /token-burden is never used.

This includes relatively expensive modules such as the tokenizer, report UI, skill handling, and extension-analysis code, adding unnecessary cost to normal Pi startup.

Change

Keep the extension entrypoint lightweight and move the /token-burden implementation into runTokenBurden.ts.

index.ts now only:

  1. registers /token-burden
  2. dynamically imports runTokenBurden when the command is invoked
  3. delegates execution to it

This creates one explicit lazy-loading boundary so future command-only dependencies naturally remain off the startup path.

Tests verify that the command module is not evaluated during extension registration, then loads and delegates correctly when /token-burden is invoked. The existing active-tool/envelope behavior test is retained with the extracted command implementation.

Validation

pnpm run check passes in a clean Linux checkout on Node 22, including all 213 unit tests.

Scope

This PR intentionally contains only the startup lazy-loading change. It does not include the other performance work from my fork.

Whamp added 30 commits February 26, 2026 14:25
Added a link to the token-burden tool in the README.
* style: fix import formatting

* chore: remove gpt-tokenizer from knip ignoreDependencies

* docs: update AGENTS.md for BPE tokenization

* fix(ci): install gitleaks binary in GitHub Actions

* chore: remove gitleaks from project

* docs: update README token estimation section for BPE
Removed the token burden screenshot and related table from the README.
…ackage discovery

Addresses code review findings:
- P1: Resolve relative disable paths from settings base dir (not CWD)
- P1: Normalize disabled paths consistently in discovery and persistence
- P2: Scan configured skill paths and package paths from settings
- P2: Fail fast with rollback on frontmatter write failures
- P3: Remove unused @fast-check/vitest dependency
- TmuxHarness class wraps tmux lifecycle (start, sendKeys, capture, waitFor, stop)
- Separate vitest.config.e2e.ts with 30s test timeout
- Main vitest config excludes src/e2e/ so pnpm run test stays fast
- knip entry updated to include e2e test files
- Smoke test: starts pi, opens /token-burden overlay, asserts title visible
- Verifies title, context bar, stacked bar, section table render
- Cursor indicator present on first row
- Down arrow navigation wraps at boundaries
- Drill-down into AGENTS.md children and esc back
- Esc from sections closes overlay
- Settings isolation via PI_CODING_AGENT_DIR pointing to temp directory
- Robust section navigation (searches for Skills row, not positional)
- Tests: skill list rendering, navigation past 8 rows (P1 regression),
  state cycling, pending changes counter, Ctrl+S save, discard
  confirmation (y/n), fuzzy search filtering
Ultracite's jest plugin overrides (no-hooks, max-expects, etc.) run in
an override block that takes precedence over local config — oxlint does
not merge overrides from extended configs with local overrides for the
same glob. Ignoring only src/e2e/ keeps lint coverage for unit tests
while exempting e2e tests that legitimately need hooks, multi-assert,
and conditional screen parsing.
Adds end-to-end tests that launch pi in tmux, interact with the
/token-burden overlay via keystrokes, and assert on captured screen output.

- TmuxHarness class (start, sendKeys, capture, waitFor, stop)
- Overlay tests: rendering, navigation, drill-down, close
- Skill-toggle tests: state cycling, save, discard, fuzzy search
- Separate vitest config (30s timeout), pnpm run test:e2e
- Settings isolation via PI_CODING_AGENT_DIR
- 67 unit tests + 15 e2e tests, all passing
Sandcastle AFK and others added 28 commits July 9, 2026 18:32
sandcastle: issue #28 — Sandcastle synthetic smoke: staged documentation marker
fix: harden Sandcastle AFK publication contracts
docs: preserve combined taxonomy decisions
@github-actions
github-actions Bot force-pushed the perf/lazy-runtime-loading branch from 7306605 to 26f0a5e Compare October 22, 2026 09:25
@infectiousstupidity infectiousstupidity closed this by deleting the head repository Oct 22, 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 token burden places burden on startup time

2 participants