Skip to content

build(cli): typecheck the CLI by following its imports, not a hand list - #30632

Merged
brennanb2025 merged 5 commits into
mainfrom
brennanb2025/cli-tsconfig-derive
Oct 21, 2026
Merged

brennanb2025 merged 5 commits into
mainfrom
brennanb2025/cli-tsconfig-derive

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​16 $\color{#cf222e}{\Huge{\mathbf{−}}}$​303 $\color{#cf222e}{\Huge{\mathbf{−}}}$​287

ELI5

The command-line tool's type check used a hand-written list of every file it pulled in from the desktop app's code. Each time someone made the CLI import a new file, CI failed until they added that file to the list. Now the check follows the CLI's imports by itself, so the list is gone.

What Changed

Problem. config/tsconfig.cli.json listed 284 src/main files by hand. It set "composite": true, and the parallel typecheck runner (CI and pnpm tc:cli) defaults to Bun check; its native path checks without --composite false. In composite mode, a file that is imported but not listed fails with TS6307. So every PR that made the CLI reach a new main module needed a list edit, or CI failed (22 squash commits mention it; follow-ups like 0ed0caa), and every such list edit conflicted with other open PRs.

Developer-facing change. A CLI import of a new src/main file no longer needs a config edit. Packaged CLI and app behavior is intended to stay the same; this is being verified with packaged main-versus-branch QA.

Mechanism.

  • tsconfig.cli.json drops composite and the list. It includes only the CLI's roots (src/cli, src/shared, the process-host fixtures), and TypeScript pulls in imported files on its own.
  • One file stays listed: profile-state-backup-worker-entry.ts. Its launcher, which the CLI does import, loads it by file path from the folder next to itself, so no import reaches it and the build must still emit it.
  • The CLI must remain free of Electron imports. The existing Electron import check now covers that boundary directly: check-runtime-electron-ratchet.mjs adds src/cli/index.ts as an entry, so any Electron import reachable from the CLI fails CI. The CLI runs under ELECTRON_RUN_AS_NODE, where Electron is unavailable.
  • electron-builder.config.cjs drops the out/main/claude-accounts/keychain.js unpack entry, along with its test line. Nothing in the production CLI imports that file any more, so CLI TypeScript emission stops producing it. The desktop build still emits a standalone entry and bundled credential code; removing the unpack rule places that entry inside the app archive. The existing packaged CLI import-closure check rejects missing runtime imports.

What I checked first-hand on 5f2bb93:

  • Nothing references tsconfig.cli.json as a project. The root tsconfig.json references only node and web, and build:cli, typecheck:tsc* and the benchmark scripts already pass --composite false.
  • I built the TypeScript program from the roots alone. It contains no src/main file outside the old list, so its source set can only be the same or smaller. This is not a peak-memory measurement; the current Bun scheduler estimates 4 GiB per project, while the native CLI estimate stays 2 GiB.
  • 9 listed files are no longer imported by anything in the CLI:
    • the backup worker entry, kept as above;
    • 6 files that only Electron main code imports (keychain, generic-password, git-bash, runtime-metadata, startup-diagnostics, http1-compatibility-profile-state). electron-vite builds its own outputs; these CLI TypeScript outputs have no production CLI consumer. The HTTP/1 module remains in the typecheck through a CLI test;
    • serve-mode-argv and cli-command-names, which CLI tests import, so tc.cli still checks them.
  • No file in the CLI graph imports electron, and esbuild bundles the CLI entry cleanly.

Why

The common pattern is a project config that lists its root folders and lets imports bring in the rest, with composite only on projects other configs reference. The alternative, keeping composite and generating the list, would keep a second copy of the import graph that nobody needs. The Electron ratchet is the check that already guards the runtime and orcad graphs by reachability. Extending it to the CLI enforces the fence the list implied, with no new mechanism.

Linked Issue

Tracked in the tech-debt audit (derived registries, PR 4). No GitHub issue.

Visual Proof

Full-path packaged CLI/app comparison and backup-worker QA is required because build output and packaging change. Screenshots will be linked in the review status comment after that run.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • config/scripts/check-runtime-electron-ratchet.test.mjs pins the new CLI entry and runs the full gate, which now bundles the CLI.

  • config/scripts/electron-builder-config.test.mjs and config/scripts/typecheck-project-coverage.test.mjs pass locally.

  • CI's static-analysis job runs the tc.cli project through the parallel runner, now without composite.

Review

Full path, not light: this changes what build:cli emits (8 fewer dead files) and touches packaging config.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Cross-platform: config only, with no paths assumed. SSH/remote, mobile and backwards compatibility: unaffected, since nothing exchanged between client and host changes. Open feature PRs that add lines to the old list (for example #14621) will get one conflict each; the fix is to drop their hunk.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

tsconfig.cli.json listed 284 src/main files because composite made any
unlisted import fail the parallel typecheck with TS6307. Nothing references
it as a project, so drop composite and keep only the CLI's roots plus the
backup worker entry, which is loaded by path. The Electron import ratchet now
also walks the CLI entry, replacing the fence the list implied.
@brennanb2025
brennanb2025 marked this pull request as ready for review October 19, 2026 08:01
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4c2d1e16-5d5a-4220-8770-16a0723085d1
📥 Commits

Reviewing files that changed from the base of the PR and between 7418e6c and 39e0702.

📒 Files selected for processing: 1
  • config/tsconfig.cli.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

📝 Walkthrough

The CLI TypeScript include list now covers CLI and shared sources, fixtures, and the profile-state backup worker entry. The Electron-import ratchet now checks Orcad and CLI entry points, and its failure message names the CLI as a plain-Node environment. The archive configuration and its test no longer include the explicit Claude accounts keychain unpack path.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 39e07

The current packaging configuration is consistent with the intended change. Its test leaves a narrow regression gap, which can be addressed as a follow-up.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly describes the main change: CLI typechecking now follows imports instead of a manually maintained file list.
Description check Passed The description is detailed and covers the change, rationale, mechanism, testing, risks, and checklist. It notes that no GitHub issue is linked and that visual proof is planned rather than attached, b…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 9 files. (1 skipped: 1 …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is detailed and covers the change, rationale, mechanism, testing, risks, and checklist. It notes that no GitHub issue is linked and that visual proof is planned rather than attached, but the overall description is complete and relevant.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 9 files. (1 skipped: 1 unsupported.)

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@brennanb2025

brennanb2025 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

The CLI compiler configuration duplicated its imported desktop dependencies in a long manual list. That list could drift as imports changed. This PR derives those dependencies from imports, keeps the backup worker that is loaded by filename, and includes the CLI in the existing Electron-import check. CLI commands and normal app behavior matched in packaged main-versus-branch QA; the standalone build emits eight fewer unused files.

Full review completed, including independent final merge-resolution review on 39e070283aacb571adb8de1b490f6ddadba22a2a. Correctness, architecture, performance and final readiness review found no proven PR defects, so no code fixes were needed. The missing original plan checks were completed after implementation; they were not pre-code approval. A pre-existing stale entry-list comment remains deferred.

Verified:

  • Exact-head full PR workflow and auxiliary checks: 22 passed, 18 intended skips; no unresolved review threads, out of draft, CLEAN.
  • Admitted M4Air macOS arm64 QA on the pre-sync head f94341f5d6578c9c46f9a3a230a493486b1edf9d compared actual local packages with its merge parent 912cb06398cb769c10ccdd3ac9d8540e291acf3d. Both packaged CLIs passed help, version, account listing and profile-export listing from neutral directories without development dependency overrides; results matched.
  • Real standalone and packaged backup launchers completed on both commits. All four workers returned success and exited zero; backup integrity and saved document hashes matched.
  • Desktop keychain.js remains present, moving from unpacked storage into app.asar. Its real scoped credential lookup loaded on both packages without module errors. Setup, default tabs, editor, account settings, folder workspaces and real signed-in agent commands were exercised through the rendered app. Grok drove initial flows; Codex completed the paired final acceptance.

Final sync: merged main 07e6bb8a27b1fc87809d36487b4e66bfc855795a into the previously reviewed merge. Independent review verified the sole CLI configuration conflict preserves both sides: the new provider error-chain module is reached by literal imports, and the resolved configuration is byte-identical to the reviewed parent. All five PR files retain reviewed bytes; packaging/build compositions preserve incoming main, and mandatory hooks introduced no tree changes. This mechanical resolution adds no shipped behavior beyond composing main, so prior packaged QA is retained under the coordinator’s explicit policy; the new merged artifact was not rerun locally. Exact-head PR Checks run, including aggregate verification, passed.

Limits and deferred observations: these were unsigned local arm64 packages with ad-hoc-signed helpers, not distribution installers. Native stored-secret decryption was not exercised. A terminal ownership banner appeared after one forced branch restart but not after the base restart; process-stop sequences differed, so a bounded trace did not establish a PR regression. Normal fresh runs passed. Shared-machine configuration hashes changed: the launcher attributed the Grok/Codex changes to another lane; two Claude configuration changes remain unattributed, with no owned QA process running at those timestamps. No real configuration was restored. All owned QA processes stopped and the worktree was restored cleanly.

For Brennan’s review

Whole-window comparisons below use the same fixture and settings within each pair. CLI output and backup integrity were checked directly rather than inferred from screenshots.

Flow Main Branch
Setup result opened in editor Main setup Branch setup
Default terminal and selected agent Main default terminal Branch default terminal
Real Codex command completed Main Codex result Branch Codex result
Managed account view Main accounts Branch accounts
Folder workspace Main folder Branch folder
Deferred forced-restart observation, unequal stop sequences Main restart Branch restart

The three review points are the explicit path-loaded worker root, CLI Electron-import coverage, and packaged unpack rules.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments: 1
config/scripts/electron-builder-config.test.mjs: 1

377-377: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert that the obsolete unpack path is absent.

expect.arrayContaining does not reject extra entries. Add a negative assertion for out/main/claude-accounts/keychain.js to protect the removal of this obsolete entry.

Suggested fix
+      expect(electronBuilderConfig.asarUnpack).not.toContain(
+        'out/main/claude-accounts/keychain.js'
+      )

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6d353a38-47ee-476e-8cfe-f4371994510a
📥 Commits

Reviewing files that changed from the base of the PR and between f94341f and 7418e6c.

📒 Files selected for processing: 4
  • config/electron-builder.config.cjs
  • config/scripts/electron-builder-config.test.mjs
  • config/tsconfig.cli.json
  • docs/reference/agent-browser-focus-isolation.md
💤 Files with no reviewable changes: 1
  • config/electron-builder.config.cjs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

@brennanb2025
brennanb2025 merged commit 29e5504 into main Oct 21, 2026
40 checks passed
@zpyoung zpyoung mentioned this pull request Oct 21, 2026
1 of 2 tasks
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.

1 participant