Skip to content

Commit 07a8969

Browse files
committed
build(web-shared): stop resolving @/ from packages/web-shared
Every import of web-shared code now uses @kilocode/web-shared/…, so '@/' maps to the importing app's own src only. Drop the second '@/' target from the web, ai-gateway, scripts and trpc tsconfigs, the web Jest config, the @kilocode/trpc rollup resolver and the Storybook webpack alias, and drop '@/' from the web-shared tsconfig so a stray '@/' import there fails its typecheck. A file under apps/web/src can no longer shadow a web-shared file with the same path, so the rule that a path exists in only one tree goes away.
1 parent 48f4f20 commit 07a8969

11 files changed

Lines changed: 21 additions & 25 deletions

File tree

‎apps/ai-gateway/AGENTS.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Next.js app that serves the AI gateway API on its own. It is not deployed yet;
1111
move under `/api/v1` too; the latter becomes `/api/v1/systemone`.
1212
- Route files are thin facades over handlers in `packages/web-shared`. Keep the
1313
`apps/web` `maxDuration` and `withRestTiming` usage, with route patterns that
14-
match this app's paths. See `packages/web-shared/AGENTS.md` for how `@/`
15-
imports resolve.
14+
match this app's paths. Import them as `@kilocode/web-shared/…`; see
15+
`packages/web-shared/AGENTS.md`.
1616
- Handlers that depend on the path accept both apps' paths, such as the LLM
1717
proxy's path validation.
1818
- `pnpm dev` runs with the web app's environment files. Start it with

‎apps/ai-gateway/tsconfig.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"skipLibCheck": true,
1010
"forceConsistentCasingInFileNames": true,
1111
"paths": {
12-
"@/*": ["./src/*", "../../packages/web-shared/src/*"],
12+
"@/*": ["./src/*"],
1313
"@kilocode/web-shared/*": ["../../packages/web-shared/src/*"],
1414
"@kilocode/db": ["../../packages/db/src/index.ts"],
1515
"@kilocode/db/*": ["../../packages/db/src/*"],

‎apps/storybook/.storybook/main.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const config: StorybookConfig = {
4242
if (config.resolve) {
4343
config.resolve.alias = {
4444
...config.resolve.alias,
45-
'@': [srcDir, webSharedSrcDir],
45+
'@': srcDir,
4646
'@kilocode/web-shared': webSharedSrcDir,
4747
'@/lib/utils': resolve(mocksDir, 'utils.ts'),
4848
};

‎apps/web/jest.config.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const config: Config = {
3333
'^@kilocode/app-shared/(.*)$': '<rootDir>/../../packages/app-shared/src/$1',
3434
'^@kilocode/web-shared/(.*)$': '<rootDir>/../../packages/web-shared/src/$1',
3535
'^(\\.{1,2}/.+)\\.js$': '$1',
36-
'^@/(.*)$': ['<rootDir>/src/$1', '<rootDir>/../../packages/web-shared/src/$1'],
36+
'^@/(.*)$': '<rootDir>/src/$1',
3737
'^server-only$': '<rootDir>/src/tests/setup/__mocks__/server-only.js',
3838
},
3939
roots: ['<rootDir>', '<rootDir>/../../packages/web-shared'],

‎apps/web/tsconfig.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"skipLibCheck": true,
1010
"forceConsistentCasingInFileNames": true,
1111
"paths": {
12-
"@/*": ["./src/*", "../../packages/web-shared/src/*"],
12+
"@/*": ["./src/*"],
1313
"@kilocode/web-shared/*": ["../../packages/web-shared/src/*"],
1414
"@kilocode/db": ["../../packages/db/src/index.ts"],
1515
"@kilocode/db/*": ["../../packages/db/src/*"],

‎apps/web/tsconfig.scripts.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"compilerOptions": {
44
"baseUrl": ".",
55
"paths": {
6-
"@/*": ["./src/*", "../../packages/web-shared/src/*"],
6+
"@/*": ["./src/*"],
77
"@kilocode/web-shared/*": ["../../packages/web-shared/src/*"],
88
"@kilocode/db": ["../../packages/db/src/index.ts"],
99
"@kilocode/db/*": ["../../packages/db/src/*"],

‎packages/trpc/rollup.config.mjs‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,9 @@ const plugins = [
3434
{
3535
name: 'resolve-aliases',
3636
resolveId(source) {
37-
// Resolve @/* path aliases to the tsc output, mirroring the tsconfig
38-
// fallback from apps/web/src to packages/web-shared/src.
37+
// Resolve the tsconfig path aliases to the tsc output.
3938
if (source.startsWith('@/')) {
40-
const webDts = resolveDts(path.resolve(tscOut, 'apps/web/src', source.slice(2)));
41-
if (existsSync(webDts)) return webDts;
42-
return resolveDts(path.resolve(tscOut, 'packages/web-shared/src', source.slice(2)));
39+
return resolveDts(path.resolve(tscOut, 'apps/web/src', source.slice(2)));
4340
}
4441
if (source.startsWith('@kilocode/web-shared/')) {
4542
const subpath = source.slice('@kilocode/web-shared/'.length);

‎packages/trpc/tsconfig.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"jsx": "react-jsx",
1717
"resolveJsonModule": true,
1818
"paths": {
19-
"@/*": ["../../apps/web/src/*", "../web-shared/src/*"],
19+
"@/*": ["../../apps/web/src/*"],
2020
"@kilocode/web-shared/*": ["../web-shared/src/*"],
2121
"@kilocode/db": ["../db/src/index.ts"],
2222
"@kilocode/db/*": ["../db/src/*"],

‎packages/web-shared/AGENTS.md‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# web-shared
22

3-
Server code shared by `apps/web` and `apps/ai-gateway`. The code was moved out of
4-
`apps/web/src` without changing its `@/` import specifiers.
3+
Server code shared by `apps/web` and `apps/ai-gateway`, moved out of `apps/web/src`.
54

65
## Module resolution
76

8-
- Consumers map `@/*` to their own `src/*` first and to `packages/web-shared/src/*`
9-
second. Keep both entries in sync in every tsconfig, the web Jest config, the
10-
`@kilocode/trpc` rollup resolver, and the Storybook webpack alias.
11-
- A path must exist in only one of `apps/web/src` and `packages/web-shared/src`.
12-
A duplicate silently shadows the web-shared file inside `apps/web`.
7+
- Import this package as `@kilocode/web-shared/<path under src>`, both from
8+
consumers and from inside this package. `@/` always means the importing app's
9+
own `src` and never resolves here.
10+
- `@kilocode/web-shared/*` maps to `packages/web-shared/src/*` in every consumer
11+
tsconfig, the web Jest config, the `@kilocode/trpc` rollup resolver, and the
12+
Storybook webpack alias. Keep those entries in sync.
1313
- Code here, including tests and `src/tests/helpers`, must only import from this
14-
package; `@/*` resolves to this package only. `pnpm --filter
15-
@kilocode/web-shared typecheck` enforces that with `tsconfig.lib.json` for
16-
runtime code (tests and helpers excluded) and `tsconfig.json` for everything.
14+
package. `pnpm --filter @kilocode/web-shared typecheck` enforces that with
15+
`tsconfig.lib.json` for runtime code (tests and helpers excluded) and
16+
`tsconfig.json` for everything; neither maps `@/`.
1717
- Tests run under the `apps/web` Jest config. A test that needs `apps/web` code
1818
belongs in `apps/web/src`, which can import from both.
1919
- Declare every npm import in `package.json` with the same version as

‎packages/web-shared/src/lib/config.server.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export const SLACK_ENCRYPTION_KEY = getEnvVariable('SLACK_ENCRYPTION_KEY');
234234
*
235235
* Unlike the GitLab/Bitbucket platform-credential keys, web holds the private half
236236
* because the Slack webhook path decrypts in-process. See
237-
* `@/lib/integrations/platforms/slack/credential-keyset`.
237+
* `apps/web/src/lib/integrations/platforms/slack/credential-keyset.ts`.
238238
*/
239239
export const SLACK_CREDENTIAL_KEYSET_JSON = getEnvVariable('SLACK_CREDENTIAL_KEYSET_JSON');
240240
// Posts notifications from server-side Admin UI code to a fixed Slack channel.

0 commit comments

Comments
 (0)