[PR #4083] perf(cli): skip command schemas for standalone version queries #6045

Open
opened 2026-10-31 01:11:25 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4083
Author: @Hahaa909
Created: 10/15/2026
Status: 🔄 Open

Base: main ← Head: jianghh/rea-3813-cli-startup-residual


📝 Commits (2)

  • 8be151e perf(cli): skip command schemas for standalone version queries
  • 53e6784 chore: merge main into standalone version fast path

📊 Changes

9 files changed (+178 additions, -54 deletions)

View changed files

📝 scripts/bundle-runtime.mjs (+1 -0)
📝 scripts/prepack.mjs (+1 -0)
📝 scripts/rea.mjs (+11 -2)
📝 scripts/verify-windows-package.mjs (+6 -0)
📝 src/cli.ts (+2 -44)
➕ src/cliBase.ts (+53 -0)
📝 tests/boundary/cli/cliStartupImports.test.ts (+64 -0)
📝 tests/boundary/cli/dispatcher.test.ts (+36 -3)
📝 tests/boundary/process/runtimeBundle.test.ts (+4 -5)

📄 Description

Summary

A standalone rea --version currently imports the complete command registry and constructs its command/tool schemas before Incur prints the version. Route that exact invocation through a shared CLI base, so version queries use the same identity, Incur builtins, configuration validation and output handling without registering analysis commands.

Refs #3813. This is a bounded follow-up: #4041 already records the default catalog digests, and 85788452 already batches redundant lifecycle dry runs. This change addresses neither of those paths and does not claim to resolve the lifecycle CI timeout or optimize root help.

Change and scope

  • Extract the existing CLI identity/builtins and configuration-error projection into cliBase.ts; the complete createCli() uses the same factory.
  • Select that base only for the exact standalone --version invocation. Combined flags, help and shell completion keep the complete registry.
  • Bundle and require the base entry in the compiled/package runtime; exercise installed version output in the Windows package verifier.

Semantic owner: the executable dispatcher and shared CLI construction. Routine performance fix within existing behavior; a new provider/authority decision is not applicable. No MCP schema, catalog digest, Evidence, target interaction, package-version or generated-metadata contract changes.

Evidence and regression coverage

The compiled CLI regression fails on the base behavior with Version lookup loaded the full command registry and passes with this change. Coverage includes unchanged plain-text version stdout, structured --version --json behavior, invalid REA_LOG_LEVEL rejection, combined-help/completion dispatch, missing-runtime diagnostics, runtime bundling, and the existing client lifecycle tests.

An earlier pre-main-sync Windows x64 / Node 24.18.0 exploratory sample (12 measured pairs after two warmups, alternating the original dispatcher and standalone route) measured median wall time of 810 ms versus 175 ms, CPU time of 1038 ms versus 171 ms, and peak RSS of 314.7 MiB versus 60.9 MiB. That sample demonstrated the intended import-boundary effect, but it predates the current main merge and is not presented as current acceptance evidence. The current branch was revalidated for correctness and packaging after resolving the CLI architecture conflicts; performance has not been remeasured after that sync.

Validation performed

Current branch after merging main (53e67844d), Windows x64 / Node 24.22.1:

  • npm ci — passed.
  • npm run build:cached — passed.
  • npm run test:focused -- tests/boundary/cli/cliStartupImports.test.ts tests/boundary/cli/dispatcher.test.ts tests/boundary/process/runtimeBundle.test.ts tests/boundary/cli/clientProfileLifecycle.test.ts — 29 tests passed across 4 files.
  • npm run check:fast — passed (typecheck and lint).
  • npm run verify:architecture-guards — passed.
  • npm run knip:production — passed.
  • npm run lint:typed — passed across 6008 files with 0 errors.
  • npm run verify:package:windows — passed: package install/version/help, 233 MCP tools, Ghidra bridge presence, OpenCode/VS Code/Copilot CLI agent setup, setup idempotency, uninstall and exact-release update.
  • git diff --check origin/main HEAD — passed.

npm run check reached and passed typecheck, lint, formatting and metadata checks, then stopped at the ordinary knip stage on seven unused exports/types already present on current main; this PR does not modify those owning files. The production-reachability (knip:production) and architecture checks relevant to the shipped path pass.

The source checkout's Windows native addon was restored from the matching published 6.8.0 tarball and passed the repository's artifact SHA/metadata verification. No native build outputs are committed.

Author readiness

Human owner: @Hahaa909

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/4083 **Author:** [@Hahaa909](https://github.com/Hahaa909) **Created:** 10/15/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `jianghh/rea-3813-cli-startup-residual` --- ### 📝 Commits (2) - [`8be151e`](https://github.com/morluto/rea/commit/8be151e225cb0c688871d34307092cbdad5a8b22) perf(cli): skip command schemas for standalone version queries - [`53e6784`](https://github.com/morluto/rea/commit/53e67844dc8e2693cbd08ab8e88ca52928107eee) chore: merge main into standalone version fast path ### 📊 Changes **9 files changed** (+178 additions, -54 deletions) <details> <summary>View changed files</summary> 📝 `scripts/bundle-runtime.mjs` (+1 -0) 📝 `scripts/prepack.mjs` (+1 -0) 📝 `scripts/rea.mjs` (+11 -2) 📝 `scripts/verify-windows-package.mjs` (+6 -0) 📝 `src/cli.ts` (+2 -44) ➕ `src/cliBase.ts` (+53 -0) 📝 `tests/boundary/cli/cliStartupImports.test.ts` (+64 -0) 📝 `tests/boundary/cli/dispatcher.test.ts` (+36 -3) 📝 `tests/boundary/process/runtimeBundle.test.ts` (+4 -5) </details> ### 📄 Description ## Summary A standalone `rea --version` currently imports the complete command registry and constructs its command/tool schemas before Incur prints the version. Route that exact invocation through a shared CLI base, so version queries use the same identity, Incur builtins, configuration validation and output handling without registering analysis commands. Refs #3813. This is a bounded follow-up: #4041 already records the default catalog digests, and `85788452` already batches redundant lifecycle dry runs. This change addresses neither of those paths and does not claim to resolve the lifecycle CI timeout or optimize root help. ## Change and scope - Extract the existing CLI identity/builtins and configuration-error projection into `cliBase.ts`; the complete `createCli()` uses the same factory. - Select that base only for the exact standalone `--version` invocation. Combined flags, help and shell completion keep the complete registry. - Bundle and require the base entry in the compiled/package runtime; exercise installed version output in the Windows package verifier. Semantic owner: the executable dispatcher and shared CLI construction. Routine performance fix within existing behavior; a new provider/authority decision is not applicable. No MCP schema, catalog digest, Evidence, target interaction, package-version or generated-metadata contract changes. ## Evidence and regression coverage The compiled CLI regression fails on the base behavior with `Version lookup loaded the full command registry` and passes with this change. Coverage includes unchanged plain-text version stdout, structured `--version --json` behavior, invalid `REA_LOG_LEVEL` rejection, combined-help/completion dispatch, missing-runtime diagnostics, runtime bundling, and the existing client lifecycle tests. An earlier pre-`main`-sync Windows x64 / Node 24.18.0 exploratory sample (12 measured pairs after two warmups, alternating the original dispatcher and standalone route) measured median wall time of 810 ms versus 175 ms, CPU time of 1038 ms versus 171 ms, and peak RSS of 314.7 MiB versus 60.9 MiB. That sample demonstrated the intended import-boundary effect, but it predates the current `main` merge and is not presented as current acceptance evidence. The current branch was revalidated for correctness and packaging after resolving the CLI architecture conflicts; performance has not been remeasured after that sync. ## Validation performed Current branch after merging `main` (`53e67844d`), Windows x64 / Node 24.22.1: - `npm ci` — passed. - `npm run build:cached` — passed. - `npm run test:focused -- tests/boundary/cli/cliStartupImports.test.ts tests/boundary/cli/dispatcher.test.ts tests/boundary/process/runtimeBundle.test.ts tests/boundary/cli/clientProfileLifecycle.test.ts` — 29 tests passed across 4 files. - `npm run check:fast` — passed (typecheck and lint). - `npm run verify:architecture-guards` — passed. - `npm run knip:production` — passed. - `npm run lint:typed` — passed across 6008 files with 0 errors. - `npm run verify:package:windows` — passed: package install/version/help, 233 MCP tools, Ghidra bridge presence, OpenCode/VS Code/Copilot CLI agent setup, setup idempotency, uninstall and exact-release update. - `git diff --check origin/main HEAD` — passed. `npm run check` reached and passed typecheck, lint, formatting and metadata checks, then stopped at the ordinary `knip` stage on seven unused exports/types already present on current `main`; this PR does not modify those owning files. The production-reachability (`knip:production`) and architecture checks relevant to the shipped path pass. The source checkout's Windows native addon was restored from the matching published 6.8.0 tarball and passed the repository's artifact SHA/metadata verification. No native build outputs are committed. ## Author readiness Human owner: @Hahaa909 - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6045
No description provided.