refactor(annotation): use #src/* subpath imports for cross-directory refs - #246
Open
contextbotai[bot] wants to merge 1 commit into
Open
refactor(annotation): use #src/* subpath imports for cross-directory refs#246contextbotai[bot] wants to merge 1 commit into
contextbotai[bot] wants to merge 1 commit into
Conversation
…refs
The annotation package used relative parent imports ('../...') for
cross-directory references, violating the repo convention that every
package declares "imports": { "#src/*": "./src/*" } and uses #src/*
for intra-package cross-directory imports (AGENTS.md > Conventions >
Imports).
- Add the missing #src/* subpath import declaration to the package's
package.json (it was the only src-bearing package missing it besides
the review scaffold).
- Rewrite all 26 '../' cross-directory imports to '#src/*'. Same-dir
siblings ('./x') are left relative per the convention.
Verified: bun run typecheck, lint, format:check, the Vite production
build (4730 modules), and the full vitest browser suite (159 tests)
all pass.
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 import convention (AGENTS.md → Conventions → Imports) is unambiguous:
This is the dominant, established pattern — 148
#src/*imports across the packages that declare the field. The@contextbridge/annotationpackage was the sole holdout: it never declared the#src/*alias in itspackage.jsonand used relative parent imports (from '../...') for every cross-directory reference. That made it the single most egregious, self-contained violation class in the codebase.Changes
packages/annotation/package.json— added the missing"imports": { "#src/*": "./src/*" }declaration (it was the only src-bearing package missing it, aside from thereviewscaffold which has no cross-directory imports).../cross-directory imports to#src/*across 11 source/test files (demo/,element/,element/mermaid/,testHelpers/). Same-directory sibling imports (./x) were intentionally left relative, per the convention. Import identifiers,typemodifiers, and ordering were preserved exactly — this is a pure path rewrite with no runtime/behavior change.Scope notes
from '../...'imports in the repo arewith { type: 'text' }build-time asset embeds that reference files outside their package (../../../annotation/dist/index.html,../../../harnessIntegrations/.../SKILL.md). These are notsrc/-relative and cannot be expressed as#src/*, so they are correctly out of scope.Verification
bun run typecheck(annotation) — passesbun run lint(repo,--max-warnings 0) — passesbun run format:check— passes#src/*subpath alias, not justtsc)chromium-headless-shelllocally to run browser-mode tests)Other violation classes noted for future runs (intentionally not touched here — one class per run)
node:fsreadFileSync/readdirSyncinstead ofBun.file/Bun.Glob(e.g.skills/src/skills.ts,skills/src/handlebars.ts:27— ironically the rule's own in-repo example file,instrumentation/src/node/*.ts). Deferred because migrating sync reads toBun.file().text()forces functions async and cascades to callers — a behavior-sensitive change that doesn't fit the "conservative, no behavior change" bar.??— a handful of per-fieldoptions.x ?? defaulton options bags (e.g.buildKeyEventinuseSubmitOnCmdEnter.test.ts,options.submissionintestHelpers/annotationFakes.ts). Low frequency; most??in the codebase are legitimate null-coalescing on lookups, not options-bag defaults.