Repository navigation
build(cli): typecheck the CLI by following its imports, not a hand list - #30632
Conversation
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🔵 Low · up to
|
|
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 Verified:
Final sync: merged main 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. The three review points are the explicit path-loaded worker root, CLI Electron-import coverage, and packaged unpack rules. |
There was a problem hiding this comment.
🧹 Nitpick comments: 1
config/scripts/electron-builder-config.test.mjs: 1
377-377: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert that the obsolete unpack path is absent.
expect.arrayContainingdoes not reject extra entries. Add a negative assertion forout/main/claude-accounts/keychain.jsto 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
📒 Files selected for processing: 4
config/electron-builder.config.cjsconfig/scripts/electron-builder-config.test.mjsconfig/tsconfig.cli.jsondocs/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.












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.jsonlisted 284src/mainfiles by hand. It set"composite": true, and the parallel typecheck runner (CI andpnpm 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/mainfile 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.jsondropscompositeand 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.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.check-runtime-electron-ratchet.mjsaddssrc/cli/index.tsas an entry, so any Electron import reachable from the CLI fails CI. The CLI runs underELECTRON_RUN_AS_NODE, where Electron is unavailable.electron-builder.config.cjsdrops theout/main/claude-accounts/keychain.jsunpack 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:
tsconfig.cli.jsonas a project. The roottsconfig.jsonreferences only node and web, andbuild:cli,typecheck:tsc*and the benchmark scripts already pass--composite false.src/mainfile 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.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-argvandcli-command-names, which CLI tests import, sotc.clistill checks them.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.mjspins the new CLI entry and runs the full gate, which now bundles the CLI.config/scripts/electron-builder-config.test.mjsandconfig/scripts/typecheck-project-coverage.test.mjspass locally.CI's static-analysis job runs the
tc.cliproject through the parallel runner, now without composite.Review
Full path, not light: this changes what
build:cliemits (8 fewer dead files) and touches packaging config.Agent skill upstream boundary
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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)