Skip to content

perf: lazy-load token burden command - #35

Open
infectiousstupidity wants to merge 1 commit into
Whamp:mainfrom
infectiousstupidity:perf/lazy-runtime-loading
Open

infectiousstupidity wants to merge 1 commit 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.

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

1 participant