Skip to content

Change base code refs to use prefixes and lint against URL form#5473

Open
backspace wants to merge 7 commits into
mainfrom
cs-12048-base-ref-constructions
Open

Change base code refs to use prefixes and lint against URL form#5473
backspace wants to merge 7 commits into
mainfrom
cs-12048-base-ref-constructions

Conversation

@backspace

@backspace backspace commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

This is a step toward changing realm server startup scripts to reference @cardstack/base instead of https://cardstack.com/base/.

backspace and others added 3 commits July 10, 2026 14:24
Code-ref builders and query on-refs that assembled base-module identifiers
from baseRealm.url now use the baseRRI helper, so the refs they produce are
canonical rather than URL-spelled: the FileDef query gate, module-syntax's
card-api ref, the file-def code-ref table, and the default spec type id.
Also converts loader.import call sites that reassembled URL-form specifiers
after the import sweep, matching the literal prefix-specifier convention.
Fetch-URL construction sites and the base alias registration itself are
unchanged — those are the URL boundary.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Guards against rename sweeps and copy-paste reintroducing
https://cardstack.com/base/ specifiers in import positions (static
imports, re-exports, dynamic import(), and loader.import() calls),
with an auto-fix to @cardstack/base/. The URL form in other positions
(fetch targets, alias registration, test assertions) is deliberately
not flagged.

Enabled via the plugin's recommended config (host, boxel-icons), and
fixes the one existing violation it caught.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…structions

# Conflicts:
#	packages/host/app/routes/module.ts
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Preview deployments

Host Test Results

    1 files      1 suites   2h 53m 52s ⏱️
3 470 tests 3 455 ✅ 15 💤 0 ❌
3 489 runs  3 474 ✅ 15 💤 0 ❌

Results for commit 94907cd.

Realm Server Test Results

    1 files  ±0      1 suites  ±0   12m 34s ⏱️ + 2m 56s
1 816 tests ±0  1 816 ✅ +30  0 💤 ±0  0 ❌  - 30 
1 895 runs  ±0  1 895 ✅ +30  0 💤 ±0  0 ❌  - 30 

Results for commit 94907cd. ± Comparison against earlier commit 7a6c518.

backspace and others added 3 commits July 13, 2026 08:19
The new no-url-form-base-imports rule caught these multi-line
loader.import() call sites after merging main; applied its auto-fix.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The repo pre-commit hook runs prettier over staged files, including the
plugin's generated README rules table, so the committed docs could never
byte-match raw eslint-doc-generator output and the generated-files CI
check failed. Add a postprocess that runs prettier during generation so
both produce identical output, and regenerate the existing docs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The prefix-form modules from the ref-construction cleanup skipped
resolveFileDefCodeRef's absolute-module early return and were resolved
against the indexed file's URL instead, so FileDef indexing stamped
broken refs (or garbage joined URLs where the base prefix mapping isn't
registered), erroring file rows across the realm-server suite. Restore
the URL-form construction and document why it must stay that way.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@backspace backspace changed the title Change server to use @cardstack/base on startup Change base code refs to use prefixes and lint against URL form Jul 13, 2026
@backspace backspace marked this pull request as ready for review July 13, 2026 22:33
@backspace backspace requested a review from a team July 14, 2026 12:25
@habdelra habdelra requested a review from Copilot July 14, 2026 13:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR is a step toward standardizing base-realm module references by switching call sites from the URL form (https://cardstack.com/base/...) to the canonical prefix form (@cardstack/base/...), and adding an ESLint rule to prevent reintroducing URL-form base imports.

Changes:

  • Migrates multiple host runtime/test loader imports from https://cardstack.com/base/... to @cardstack/base/....
  • Updates runtime-common/base code to prefer prefix-form RRIs for base modules in generated/module-syntax logic.
  • Adds @cardstack/boxel/no-url-form-base-imports (enabled in the plugin’s recommended config) with tests and documentation.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/runtime-common/module-syntax.ts Uses baseRRI('card-api') when canonicalizing/merging card-api imports during code generation.
packages/runtime-common/file-def-code-ref.ts Adds rationale for intentionally keeping URL-form base modules in file-def mappings.
packages/host/tests/unit/code-ref-test.ts Updates dynamic loader imports to @cardstack/base/... in unit tests.
packages/host/tests/integration/realm-test.gts Updates dynamic loader imports to @cardstack/base/... in integration tests.
packages/host/tests/integration/components/file-def-format-templates-test.gts Updates type-only base module import to @cardstack/base/....
packages/host/tests/integration/components/codemirror-embed-toolbar-test.gts Updates dynamic loader import to @cardstack/base/....
packages/host/app/utils/file-def-attributes-extractor.ts Updates dynamic loader import to @cardstack/base/card-api.
packages/host/app/tools/send-ai-assistant-message.ts Updates dynamic loader import to @cardstack/base/card-api.
packages/host/app/tools/patch-fields.ts Updates dynamic loader imports to @cardstack/base/card-api.
packages/host/app/tools/generate-thumbnail.ts Updates dynamic loader import to @cardstack/base/card-api.
packages/host/app/tools/copy-and-edit.ts Updates dynamic loader import to @cardstack/base/card-api.
packages/host/app/tools/ai-assistant.ts Updates dynamic loader import to @cardstack/base/card-api.
packages/host/app/services/card-service.ts Updates cached dynamic loader imports to @cardstack/base/... modules.
packages/host/app/routes/module.ts Import list reorder only (no behavior change).
packages/host/app/lib/file-def-manager.ts Import list reorder only (no behavior change).
packages/host/app/components/operator-mode/publish-realm-modal.gts Updates dynamic loader import to @cardstack/base/card-api.
packages/host/app/components/operator-mode/create-file-modal.gts Uses baseRRI(...) for base module IDs and reorders imports.
packages/eslint-plugin-boxel/tests/lib/rules/no-url-form-base-imports-test.js Adds tests for the new lint rule and autofix behavior.
packages/eslint-plugin-boxel/README.md Adds the new rule to the auto-generated rules list.
packages/eslint-plugin-boxel/lib/rules/no-url-form-base-imports.js Implements the new lint rule and fixer for URL-form base imports.
packages/eslint-plugin-boxel/lib/recommended-rules.js Enables the new rule in the plugin’s recommended config.
packages/eslint-plugin-boxel/docs/rules/template-missing-invokable.md Doc formatting update (quote style) in examples.
packages/eslint-plugin-boxel/docs/rules/no-url-form-base-imports.md Adds documentation for the new rule.
packages/eslint-plugin-boxel/docs/rules/no-duplicate-imports.md Doc formatting cleanup.
packages/eslint-plugin-boxel/docs/rules/missing-card-api-import.md Doc formatting update in examples (but still references URL-form base imports).
packages/eslint-plugin-boxel/.eslint-doc-generatorrc.js Ensures generated rule docs are Prettier-formatted to match repo checks.
packages/base/codemirror-editor.gts Uses baseRRI('card-api') in query filters instead of URL-form baseRealm usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/eslint-plugin-boxel/lib/rules/no-url-form-base-imports.js
Comment thread packages/eslint-plugin-boxel/docs/rules/missing-card-api-import.md Outdated
Derive the fixer's quote character from source text via
context.sourceCode.getText rather than literalNode.raw, which some
parsers/AST transforms leave unpopulated (a --fix-time throw). This
matches the sibling no-literal-realm-urls rule.

Also update the missing-card-api-import doc examples to the canonical
@cardstack/base/ prefix; the URL form they showed is now flagged by
no-url-form-base-imports, so copy-pasting them would trip the linter.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants