Skip to content

Commit e97b1ee

Browse files
committed
docs(web-shared): document the @kilocode/web-shared specifier
Replace the @/ fallback and shadowing rule in packages/web-shared/AGENTS.md and apps/ai-gateway/AGENTS.md, and point comments that name web-shared modules at their new specifiers.
1 parent 3a4804a commit e97b1ee

12 files changed

Lines changed: 25 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 handlers as `@kilocode/web-shared/<path>`;
15+
`@/` resolves only to this app's `src`. See `packages/web-shared/AGENTS.md`.
1616
- Handlers that depend on the path accept both apps' paths: the LLM proxy's path
1717
validation and the blocked-client check in `src/proxy.ts` for
1818
`/api/v1/fim/completions`.

‎apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminServiceFeeExemption.dialog-state.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
// Mirrors ORGANIZATION_SERVICE_FEE_EXEMPTION_REASON_* in
8-
// @/lib/service-fees/organization-exemptions, which is server-only and cannot
8+
// @kilocode/web-shared/lib/service-fees/organization-exemptions, which is server-only and cannot
99
// be imported from a client component. The router remains the enforcement
1010
// boundary; these only drive client-side enablement and hints.
1111
export const SERVICE_FEE_EXEMPTION_REASON_MIN_LENGTH = 3;

‎apps/web/src/lib/auth/passkey.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { db } from '@kilocode/web-shared/lib/drizzle';
3737
* can satisfy the associated-domain/credential binding the browser or platform
3838
* authenticator created against `app.kilo.ai`.
3939
*
40-
* Resolved per ceremony rather than at module load: `@/lib/user/server` imports
40+
* Resolved per ceremony rather than at module load: `@kilocode/web-shared/lib/user/server` imports
4141
* this module for the sign-in provider, so importing it must not require a
4242
* WebAuthn configuration. A process without a relying party still loads the
4343
* route graph and only fails when a ceremony actually runs.

‎apps/web/src/lib/data-export/db.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { z } from 'zod';
99
* Client for the data export database: a separate, read-only Postgres instance
1010
* loaded out of band to back the user data export feature.
1111
*
12-
* Three things make this deliberately different from `@/lib/drizzle`:
12+
* Three things make this deliberately different from `@kilocode/web-shared/lib/drizzle`:
1313
*
1414
* 1. It is lazy. The primary pool is created at import time because the app
1515
* cannot serve a single request without it. This database is optional, so

‎apps/web/src/lib/kiloclaw/kilo-chat-internal-client.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function getKiloChatBaseUrl(): string {
5252
// environment that has not provisioned the new var yet keeps working rather
5353
// than repeating a wrong-config outage; a follow-up removes the fallback once
5454
// KILO_CHAT_INTERNAL_URL is confirmed on every project. Read process.env
55-
// directly rather than importing from `@/lib/constants`: those constants are
55+
// directly rather than importing from `@kilocode/web-shared/lib/constants`: those constants are
5656
// marked required at import time, which crashes test setups if a var is
5757
// unset. This server-only client should fail loudly only when actually called.
5858
let raw = process.env.KILO_CHAT_INTERNAL_URL;

‎apps/web/src/routers/active-sessions-router.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ import type { createCallerForUser as CreateCallerForUser } from '@/routers/test-
2323
// `.env.test` sets SESSION_INGEST_WORKER_URL to '' (shared fixture used by
2424
// other test files too — do not change it here). `createCallerForUser`'s
2525
// import chain (test-utils -> trpc/init -> ...) transitively loads
26-
// `@/lib/config.server`, whose `SESSION_INGEST_WORKER_URL` export is a plain
26+
// `@kilocode/web-shared/lib/config.server`, whose `SESSION_INGEST_WORKER_URL` export is a plain
2727
// `const` computed once, the first time that module is evaluated. Static
2828
// ES `import` statements are always hoisted above every other statement by
2929
// the transform, so a statically-imported `createCallerForUser` would pull
3030
// in the real ('') value before any `process.env` assignment written below
31-
// it could run — and a `jest.mock('@/lib/config.server', ...)` registered
31+
// it could run — and a `jest.mock('@kilocode/web-shared/lib/config.server', ...)` registered
3232
// after that first (real) load cannot retroactively change the value
3333
// active-sessions-router.ts already captured. A dynamic `import()` executes
3434
// exactly where it is awaited (not hoisted), so resolving it in `beforeAll`

‎apps/web/src/routers/github-pr-review-router.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jest.mock('@/lib/integrations/platforms/github/user-token-client', () => ({
1414

1515
// P1-A-08c: the PR operation ledger. The router admits / settles /
1616
// marks-reconcile-pending through `@kilocode/db/operation-ledger`. Both it and
17-
// `@/lib/drizzle` are mocked so the ledger tests can assert admission, settle,
17+
// `@kilocode/web-shared/lib/drizzle` are mocked so the ledger tests can assert admission, settle,
1818
// replay, and reconcile orchestration without a database. The analytics
1919
// identity comes from `ctx.user`, which carries no email here, so it falls
2020
// back to the user id.

‎apps/web/src/routers/user-exports-router.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { __test__, userExportsRouter } from '@/routers/user-exports-router';
1919
import { createTestOrganization } from '@/tests/helpers/organization.helper';
2020
import { insertTestUser } from '@/tests/helpers/user.helper';
2121

22-
// Partial mocks: `@/lib/email` also exports the template registry that sibling
22+
// Partial mocks: `@kilocode/web-shared/lib/email` also exports the template registry that sibling
2323
// routers read at import time, so the real module must stay intact.
2424
jest.mock('@kilocode/web-shared/lib/email', () => {
2525
const actual: Record<string, unknown> = jest.requireActual('@kilocode/web-shared/lib/email');

‎apps/web/src/tests/helpers/fake-r2.helper.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ export function createFakeR2Client() {
3232
export type FakeR2Client = ReturnType<typeof createFakeR2Client>;
3333

3434
/**
35-
* Replacement for `@/lib/r2/client` whose `createR2Client` always returns the
35+
* Replacement for `@kilocode/web-shared/lib/r2/client` whose `createR2Client` always returns the
3636
* same fake and records the credentials it was created with. Retrieve the fake
37-
* with `jest.requireMock<FakeR2ClientModule>('@/lib/r2/client').fakeR2`.
37+
* with `jest.requireMock<FakeR2ClientModule>('@kilocode/web-shared/lib/r2/client').fakeR2`.
3838
*/
3939
export function createFakeR2ClientModule() {
4040
const fakeR2 = createFakeR2Client();

‎packages/web-shared/AGENTS.md‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
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`, consumed from source.
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 modules from this package as `@kilocode/web-shared/<path>`, which maps
8+
to `src/<path>`, both from consumers and inside this package. Every consumer
9+
tsconfig, the web Jest config, the `@kilocode/trpc` rollup resolver, and the
10+
Storybook webpack alias map that specifier. There is no `exports` map:
11+
specifiers are extensionless, so resolution relies on those mappings.
12+
- `@/` in a consumer means that consumer's own `src`; it never resolves here.
1313
- Runtime code here must only import from this package. `pnpm --filter
1414
@kilocode/web-shared typecheck` enforces that with `tsconfig.lib.json`, which
15-
resolves `@/*` to this package only and excludes tests.
16-
- Tests run under the `apps/web` Jest config and may import `apps/web` test
17-
helpers; `tsconfig.json` falls back to `apps/web/src` for editors and linting.
15+
excludes tests and does not map `@/` at all.
16+
- Tests run under the `apps/web` Jest config and may import `apps/web` modules
17+
and test helpers through `@/`, which `tsconfig.json` maps to `apps/web/src`.
1818
- Declare every npm import in `package.json` with the same version as
1919
`apps/web`, including the optional peers that make pnpm resolve the same
2020
`next` and `@sentry/nextjs` instances as `apps/web`. Two instances of `next`

0 commit comments

Comments
 (0)