refactor(annotation): use #src subpath imports instead of parent-relative paths - #237
Open
contextbotai[bot] wants to merge 2 commits into
Open
refactor(annotation): use #src subpath imports instead of parent-relative paths#237contextbotai[bot] wants to merge 2 commits into
contextbotai[bot] wants to merge 2 commits into
Conversation
…tive paths
The @contextbridge/annotation package used ../ parent-directory relative
imports for cross-directory intra-package references, violating the
subpath-import convention in AGENTS.md ('Subpath imports for intra-package
refs ... Code writes import { x } from #src/context.ts for cross-directory
imports'). Every other package that has cross-directory code already
declares and uses #src/*.
- Add "imports": { "#src/*": "./src/*" } to packages/annotation/package.json
- Rewrite all 23 parent-relative (../, ../../) imports across 8 files to
#src/* equivalents
- Same-directory sibling imports (./) left as-is, per the convention
jcarver989
enabled auto-merge (squash)
July 10, 2026 22:17
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.
What & why
The repo's
AGENTS.mdmandates subpath imports for intra-package references:Every workspace package that has cross-directory code already declares and uses
#src/*(9 of them: cli, context, harness, instrumentation, server, shared, skills, storage, ui). The@contextbridge/annotationpackage was the sole outlier — it never declared theimportsmap and reached across directories with parent-relative paths (../,../../) instead of#src/*.This was the single most egregious, clearly-defined, and safely-fixable violation class:
Changes
"imports": { "#src/*": "./src/*" }topackages/annotation/package.json(matching the other packages).#src/*equivalents across:src/demo/DemoStage.tsxsrc/element/ElementAdapter.tssrc/element/useElementTargets.tssrc/element/mermaid/mermaidAdapter.tssrc/element/mermaid/mermaidAdapter.test.tssrc/element/mermaid/MermaidBlock.tsxsrc/testHelpers/index.tsxsrc/testHelpers/appContextDecorator.tsxsrc/testHelpers/createFakeAppContext.tssrc/testHelpers/renderAnnotationHook.tsx./x) untouched, exactly as the convention permits.Verification
bun run format:check— cleanbun run lint— clean (--max-warnings 0)bun run --cwd packages/annotation typecheck— cleanpackages/annotationvitest browser suite (Playwright/Chromium) — 151 tests / 12 files passing, confirming#src/*resolves in vitest browser mode.vite build(the production single-file bundle) — succeeds, confirming#src/*resolves through the vite bundler with no extra alias config.Notes for reviewer / future runs
Other convention-violation classes I noticed but intentionally left for follow-up runs (one class per run):
??fallbacks vs. destructured defaults — many??uses exist but most are legitimate (non-options-bag) usages; needs case-by-case review to avoid behavior changes.createDeferredinpackages/instrumentation/src/node/harnessDiscovery.test.tsshould use the sharedcreateDeferredfrom@contextbridge/shared/testHelpersper the testing-patterns rule.packages/cli/src/environment.tsuses.min(1)on a numericPortSchema— the.nonempty()convention is specifically for string schemas, so this is likely NOT a violation.