Improve CLI startup with compile cache#48
Conversation
Enable Node's compile cache from the lightweight CLI entrypoint for normal commands while keeping the existing package-json --version fast path ahead of the main CLI import. Also keep --no-extensions --version on that fast path, add release-readiness coverage, record startup profiling/manual dogfood/observability evidence in pm, and backfill one missing closed-item resolution record so pm validate is clean. Verification: manual isolated temp-project smoke; PM_RUN_TESTS_SKIP_BUILD=1 release-readiness regression; node scripts/smoke-npx-from-pack.mjs; node scripts/release/run-gates.mjs --telemetry-mode required --max-sentry-critical 10 --max-sentry-high 20 --max-telemetry-error-rate 10 --json; pm validate --check-resolution --check-history-drift; pm health --check-only --summary.
Reviewer's GuideEnable Node’s compile cache for the main CLI entrypoint, keep specific version flags on the fast package-json path, add release-readiness coverage around startup behavior, and backfill resolution metadata in agent history files for clean validation. Sequence diagram for updated CLI startup with compile cachesequenceDiagram
actor User
participant Process
participant cli_ts as cli_ts
participant NodeModule as nodeModule
participant CliMain as cli_main_js
User ->> Process: pm [args]
Process ->> cli_ts: start CLI entrypoint
Process ->> cli_ts: printFastVersionIfRequested()
alt [only --version or -V (ignoring --no-extensions)]
cli_ts ->> Process: console.log(version)
Process -->> User: exit
else [other args]
cli_ts ->> cli_ts: enableNodeCompileCache()
alt [PM_CLI_DISABLE_COMPILE_CACHE != "1" and enableCompileCache available]
cli_ts ->> NodeModule: enableCompileCache(cacheDir)
else [compile cache disabled or unavailable]
cli_ts ->> cli_ts: skip compile cache
end
cli_ts ->> CliMain: import("./cli/main.js")
CliMain ->> User: execute full CLI
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Review limit reached
Your plan currently allows 1 review/hour. Refill in 43 minutes and 59 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR implements Node compile-cache bootstrap for CLI startup performance, conditionally enabled at runtime via environment variables while preserving the fast ChangesNode Compile Cache Implementation and Tests
Feature and Project Management Tracking
🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request implements a startup optimization for the CLI by enabling the Node.js compile cache and refining the fast-path version check to correctly handle the --no-extensions flag. It also includes extensive updates to internal project tracking and history files, documenting profiling evidence and implementation progress. Feedback was provided regarding the potential for permission conflicts when using a shared temporary directory for the compile cache, suggesting a user-specific naming convention to ensure the cache remains writable across different users.
| if (typeof enableCompileCache !== "function" || process.env.PM_CLI_DISABLE_COMPILE_CACHE === "1") { | ||
| return; | ||
| } | ||
| const cacheDir = process.env.PM_CLI_COMPILE_CACHE_DIR ?? path.join(os.tmpdir(), "pm-cli-node-compile-cache"); |
There was a problem hiding this comment.
Using a fixed directory name in a shared temporary location (like /tmp on Linux) can lead to permission conflicts on multi-user systems. If one user runs the CLI, the directory is created with their ownership, which may prevent other users from writing to the cache, effectively disabling the optimization for them. Consider making the cache directory user-specific by appending the username from environment variables to ensure the cache is writable for all users.
const cacheDir = process.env.PM_CLI_COMPILE_CACHE_DIR ?? path.join(os.tmpdir(), `pm-cli-node-compile-cache-${process.env.USER || process.env.USERNAME || "shared"}`);There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
tests/integration/release-readiness-runtime.spec.ts (1)
468-471: ⚡ Quick winAdd the reverse flag order case for
--versionparity.This test only validates
--no-extensions --version. Add--version --no-extensionstoo, so the stated contract is explicitly covered.Suggested test addition
const noExtensionsVersionResult = context.runCli(["--no-extensions", "--version"]); expect(noExtensionsVersionResult.code).toBe(0); expect(noExtensionsVersionResult.stdout.trim()).toBe(expectedVersion); expect(noExtensionsVersionResult.stderr.trim()).toBe(""); + + const versionThenNoExtensionsResult = context.runCli(["--version", "--no-extensions"]); + expect(versionThenNoExtensionsResult.code).toBe(0); + expect(versionThenNoExtensionsResult.stdout.trim()).toBe(expectedVersion); + expect(versionThenNoExtensionsResult.stderr.trim()).toBe("");🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/integration/release-readiness-runtime.spec.ts` around lines 468 - 471, Add a mirrored assertion that verifies flag-order parity by calling context.runCli with ["--version", "--no-extensions"] (similar to the existing noExtensionsVersionResult) and assert the returned process code, stdout.trim() equals expectedVersion, and stderr.trim() is empty; use a distinct variable name (e.g., versionNoExtensionsResult) and mirror the three expects from the existing block that uses context.runCli, expectedVersion, and noExtensionsVersionResult to keep behavior consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.agents/pm/history/pm-rnpb.jsonl:
- Line 507: Revert the direct edit that added metadata.comments[213] and the
metadata.updated_at replacement and instead record the continuation via the
official PM workflow/tooling; specifically remove the added JSON entry at
metadata.comments[213] and undo the metadata.updated_at change, then re-create
the note using the PM system-of-record process (referencing the child feature
pm-gt82 and the continuity text) rather than hand-editing the PM history file.
In @.agents/pm/issues/pm-ot8r.toon:
- Line 9: Revert the direct edit to the .agents/pm record (the updated_at change
in the .agents/pm/issues/pm-ot8r.toon file) and instead apply the metadata
update through the PM system workflow/commands that produce record mutations;
locate the PM record identified by "pm-ot8r" in the .agents/pm/* set, use the PM
CLI/API or UI to set the updated_at value (or trigger the intended record
update) so the system-of-record is the source of truth, and remove any manual
file changes to .agents/pm/** to comply with the repository rule.
---
Nitpick comments:
In `@tests/integration/release-readiness-runtime.spec.ts`:
- Around line 468-471: Add a mirrored assertion that verifies flag-order parity
by calling context.runCli with ["--version", "--no-extensions"] (similar to the
existing noExtensionsVersionResult) and assert the returned process code,
stdout.trim() equals expectedVersion, and stderr.trim() is empty; use a distinct
variable name (e.g., versionNoExtensionsResult) and mirror the three expects
from the existing block that uses context.runCli, expectedVersion, and
noExtensionsVersionResult to keep behavior consistent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 17cba56a-d82f-4283-a0a9-6c52aea083ff
📒 Files selected for processing (8)
.agents/pm/features/pm-gt82.toon.agents/pm/features/pm-rnpb.toon.agents/pm/history/pm-gt82.jsonl.agents/pm/history/pm-ot8r.jsonl.agents/pm/history/pm-rnpb.jsonl.agents/pm/issues/pm-ot8r.toonsrc/cli.tstests/integration/release-readiness-runtime.spec.ts
| {"ts":"2026-05-23T10:06:56.111Z","author":"codex-extensive-audit","op":"comment_add","patch":[{"op":"add","path":"/metadata/comments/211","value":{"created_at":"2026-05-23T10:06:56.111Z","author":"codex-extensive-audit","text":"Post-review final gate 2026-05-23: after applying Gemini's regex precompile feedback, reran node scripts/release/run-gates.mjs --telemetry-mode required --max-sentry-critical 10 --max-sentry-high 20 --max-telemetry-error-rate 10 --json. Passed: build, typecheck, docs-skills, static quality, coverage 100 files / 1484 tests / 100%, version policy 2026.5.23, secret scan, npx packed-package smoke, package-first dogfood 84 workflows, npm pack dry-run, compatibility check from base 2026.5.18, and required Sentry/telemetry gate with Sentry critical=0 high=0 total=0 and telemetry finish_error_rate_pct=3.08, failures_without_error_code_rows=0."}},{"op":"replace","path":"/metadata/updated_at","value":"2026-05-23T10:06:56.111Z"}],"before_hash":"5612d6031d3316d8a28bf31889a5f66144d8ef90838b74f63da473858979bc08","after_hash":"b316399d26f726dcc489d302faea8ea20b17d10ef1c5a6da9ca39c7c328274a1"} | ||
| {"ts":"2026-05-23T10:14:18.812Z","author":"codex-extensive-audit","op":"comment_add","patch":[{"op":"add","path":"/metadata/comments/212","value":{"created_at":"2026-05-23T10:14:18.812Z","author":"codex-extensive-audit","text":"Merge evidence 2026-05-23: PR #46 merged into main at 2026-05-23T10:13:45Z as merge commit df5b2c2274ca24b0d7913d54798d94699da49b10. Final PR head fb62eac4 had all GitHub checks green: CI build foundation, ubuntu Node 20 tests, macOS Node 20 tests, coverage gate, typecheck, static, compat, smokes, CodeRabbit status, and Sourcery status. Codex review found no major issues; Gemini actionable regex-precompile feedback was applied before merge; CodeRabbit and Sourcery review text remained rate-limited/no actionable feedback. Local post-merge pm validate --check-resolution --check-history-drift returned ok with no warnings."}},{"op":"replace","path":"/metadata/updated_at","value":"2026-05-23T10:14:18.812Z"}],"before_hash":"b316399d26f726dcc489d302faea8ea20b17d10ef1c5a6da9ca39c7c328274a1","after_hash":"f5d7e7b463ff0141e950d723438cdac6e6f7b584f8cf6b63b2af1375ff6ca311"} | ||
| {"ts":"2026-05-23T10:14:37.483Z","author":"codex-extensive-audit","op":"release","patch":[{"op":"remove","path":"/metadata/assignee"},{"op":"replace","path":"/metadata/updated_at","value":"2026-05-23T10:14:37.483Z"}],"before_hash":"f5d7e7b463ff0141e950d723438cdac6e6f7b584f8cf6b63b2af1375ff6ca311","after_hash":"6dd5df5ce5612dbbe13fb3bc3f46344b501567473c23695a7af52aeb4d0109b1","message":"Released claim after PR #46 merge and post-merge validation; parent remains in progress for future active work."} | ||
| {"ts":"2026-05-23T10:43:54.715Z","author":"codex-extensive-agent","op":"comment_add","patch":[{"op":"add","path":"/metadata/comments/213","value":{"created_at":"2026-05-23T10:43:54.715Z","author":"codex-extensive-agent","text":"Continuation 2026-05-23: active work resumed under existing child feature pm-gt82 for sub-200ms startup and agent token-efficiency improvements. No duplicate item created after pm context/search/list-open/list-in-progress orientation."}},{"op":"replace","path":"/metadata/updated_at","value":"2026-05-23T10:43:54.715Z"}],"before_hash":"6dd5df5ce5612dbbe13fb3bc3f46344b501567473c23695a7af52aeb4d0109b1","after_hash":"594d3f4a8648ac33f174521c3f445b5cc8e11133c219225145ad2ff10ce00869"} |
There was a problem hiding this comment.
Direct edit to PM system-of-record file should be avoided.
This change writes directly to .agents/pm/history/pm-rnpb.jsonl; update this record via the designated PM workflow/tooling instead of hand-editing tracked .agents/pm files.
As per coding guidelines, .agents/pm/**: pm is the system of record. Do not edit .agents/pm files directly.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.agents/pm/history/pm-rnpb.jsonl at line 507, Revert the direct edit that
added metadata.comments[213] and the metadata.updated_at replacement and instead
record the continuation via the official PM workflow/tooling; specifically
remove the added JSON entry at metadata.comments[213] and undo the
metadata.updated_at change, then re-create the note using the PM
system-of-record process (referencing the child feature pm-gt82 and the
continuity text) rather than hand-editing the PM history file.
| tags[0]: | ||
| created_at: "2026-05-22T15:44:28.669Z" | ||
| updated_at: "2026-05-23T10:23:23.319Z" | ||
| updated_at: "2026-05-23T11:01:01.607Z" |
There was a problem hiding this comment.
Use the PM system interface instead of direct file edits
These metadata changes are applied by directly editing a .agents/pm record file, which violates the repository rule for PM system-of-record files. Please perform this update through the PM workflow/commands that generate the record mutation.
As per coding guidelines: .agents/pm/**: pm is the system of record. Do not edit .agents/pm files directly.
Also applies to: 12-14
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.agents/pm/issues/pm-ot8r.toon at line 9, Revert the direct edit to the
.agents/pm record (the updated_at change in the .agents/pm/issues/pm-ot8r.toon
file) and instead apply the metadata update through the PM system
workflow/commands that produce record mutations; locate the PM record identified
by "pm-ot8r" in the .agents/pm/* set, use the PM CLI/API or UI to set the
updated_at value (or trigger the intended record update) so the system-of-record
is the source of truth, and remove any manual file changes to .agents/pm/** to
comply with the repository rule.
Add reverse-order --version coverage and use a per-user default Node compile-cache directory to avoid shared temp permission conflicts while preserving the explicit cache-dir override. Verification: pnpm build; PM_RUN_TESTS_SKIP_BUILD=1 release-readiness regression; node scripts/check-secrets.mjs; pm validate --check-resolution --check-history-drift --json; full release gate with required Sentry/telemetry.
|
Addressed review feedback in 3d61a23: added reverse-order |
Record PR #48 merge evidence, release the active pm-gt82 claim, and leave the broader startup/runtime-index work open for future slices. Verification: pm validate --check-resolution --check-history-drift --json; pm health --check-only --summary --json.
Summary
PM_CLI_DISABLE_COMPILE_CACHE=1andPM_CLI_COMPILE_CACHE_DIRescape hatches.pm --no-extensions --versionandpm --version --no-extensionson the fast package-json version path instead of importing the full CLI.pm-ot8rsopm validate --check-resolution --check-history-driftis clean.Validation
dist/cli.jswith separatePM_PATHandPM_GLOBAL_PATH.PM_RUN_TESTS_SKIP_BUILD=1 node scripts/run-tests.mjs test -- tests/integration/release-readiness-runtime.spec.ts --reporter=dotnode scripts/smoke-npx-from-pack.mjsnode scripts/release/run-gates.mjs --telemetry-mode required --max-sentry-critical 10 --max-sentry-high 20 --max-telemetry-error-rate 10 --jsonpm validate --check-resolution --check-history-drift --jsonpm health --check-only --summary --jsonObservability
Sentry/telemetry required gate passed with Sentry critical/high/total
0/0/0, telemetry finish error rate3%, and missing error-code rows0.Summary by Sourcery
Optimize CLI startup behavior while extending release-readiness coverage and backfilling package manager history metadata.
New Features:
Bug Fixes:
Enhancements: