Repository navigation
refactor(web-shared): add the @kilocode/web-shared import specifier - #7056
Closed
chrarnoldus wants to merge 3 commits into
Closed
chrarnoldus wants to merge 3 commits into
chrarnoldus wants to merge 3 commits into
Conversation
Add the explicit specifier next to the existing @/ fallback in every consumer tsconfig, the web Jest config, the trpc rollup resolver, the Storybook webpack alias and the MCP catalog import resolver, and declare the workspace devDependency in packages/trpc like @kilocode/db.
…web-shared Mechanical codemod output only, followed by oxfmt. Every `@/` module specifier in packages/web-shared that resolved into packages/web-shared/src now uses `@kilocode/web-shared/`. Specifiers that resolve into apps/web (test helpers) are unchanged. 323 files, 1,465 specifiers on 1,465 lines.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Reviewed the additive All 230 distinct rewritten specifiers resolve to existing files under Files Reviewed (336 files)Non-mechanical changes:
Mechanical (import-specifier rewrite only, verified no semantic body changes):
Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0 Review guidance: REVIEW.md from base branch |
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First preparation PR for #7051, which removes the
@/fallback betweenapps/webandpackages/web-shared. The stack is this PR, then #7058 (web-shared stops importingapps/web), then #7051. This PR introduces the explicit specifier and adopts it inside web-shared. It does not change how any existing@/import resolves.Specifier.
@kilocode/web-shared/<path>maps topackages/web-shared/src/<path>, wired like@kilocode/db/*. The mapping is added in:pathsinapps/web(tsconfig.json,tsconfig.scripts.json, inherited by Storybook),apps/ai-gateway,packages/trpcandpackages/web-shared(tsconfig.jsonandtsconfig.lib.json)moduleNameMapper, the@kilocode/trpcrollup resolver and the Storybook webpack aliasapps/web/src/scripts/mcp-catalog/catalog.ts)workspace:*devDependency inpackages/trpc, as for@kilocode/dband@kilocode/encryptionThere is no
exportsmap: the specifiers are extensionless and point at.ts/.tsxfiles andindex.tsdirectories, which anexportswildcard cannot probe.Adoption inside web-shared. Every
@/specifier inpackages/web-sharedthat resolved into the package itself now uses the package specifier. This exercises the mapping in theapps/webandapps/ai-gatewayNext.js builds, Jest, Storybook and the trpc build before refactor(web-shared): import web-shared via @kilocode/web-shared #7051 depends on it. Specifiers that resolve intoapps/web(test helpers) are unchanged.Docs.
packages/web-shared/AGENTS.mddocuments the specifier. The fallback description stays until refactor(web-shared): import web-shared via @kilocode/web-shared #7051 removes it.Codemod
The rewrite is the TypeScript compiler API codemod from #7051 (source below), run with
--only packages/web-shared. It collects string literals only in module-specifier positions:import/export … from,import x = require()import(),require(),require.resolve()jest.*('…')call:mock,doMock,dontMock,requireActual,requireMock, …typeof import('…')types anddeclare module '…'It resolves each
@/specifier withts.resolveModuleNameagainst both the apps/web tsconfig (the order Next.js and Jest use) and web-shared's own tsconfig. If the target is inpackages/web-shared/src, it swaps the prefix. The two resolutions never disagreed, and no specifier was unresolved.323 files, 1,465 specifiers on 1,465 lines. After
oxfmt, the commit is323 files changed, 1725 insertions(+), 1475 deletions(-). The extra lines are imports that the longer specifier pushed past the line limit and the formatter rewrapped. The files wereoxfmt-clean before the rewrite.Verification
cd apps/web && pnpm exec tsgo --noEmit,apps/ai-gatewaytypecheck,@kilocode/web-sharedtypecheck (tsconfig.lib.json) andtsgo -p packages/web-shared/tsconfig.json: all passapps/storybooktypecheck andpnpm build-storybook: both succeedpnpm --filter @kilocode/trpc build: succeeds, and the bundles contain no unresolved@kilocode/web-sharedor@/references.apps/mobiletypecheck passes against itnext buildofapps/ai-gatewaywithapps/web/.env.testas.env.production.localandapps/web/.envas.env, deleted afterwards: succeeds, all 15/api/v1routes builtcd apps/web && pnpm script src/scripts/mcp-catalog/dump.ts:services/kilo-mcp/catalog.jsonis unchangedcd apps/web && NODE_ENV=test pnpm exec jest --listTests: lists all 168 web-shared tests. Smoke-ran 4 web-shared suites that usejest.requireActual,jest.requireMockandjest.isolateModuleswith the new specifier, includingllm-proxy.test.ts: 87 tests pass. CI runs the full suitesoxlintonpackages/web-shared/src,packages/trpcand the mcp-catalog dir,oxfmt --list-differenton changed files andgit diff --check: all cleanVisual Changes
N/A
Reviewer Notes
oxfmtonly.git show <sha> -U0 | rg '^[+-][^+-]' | rg -v '@kilocode/web-shared/|@/'. It shows only rewrapped import andjest.*lines.Codemod source (
rewrite-web-shared-imports.mjs, run asnode rewrite-web-shared-imports.mjs . --only packages/web-shared && git diff --name-only -z | xargs -0 pnpm exec oxfmt)