Skip to content

deps(tko.io): bump astro 5→6, starlight 0.37→0.38, drop patch-package#360

Merged
brianmhunt merged 1 commit intomainfrom
deps/astro-6-starlight-0.38
Apr 22, 2026
Merged

deps(tko.io): bump astro 5→6, starlight 0.37→0.38, drop patch-package#360
brianmhunt merged 1 commit intomainfrom
deps/astro-6-starlight-0.38

Conversation

@brianmhunt
Copy link
Copy Markdown
Member

@brianmhunt brianmhunt commented Apr 22, 2026

Summary

Migrations

  • src/content.config.ts: add docsLoader(). Astro 6 requires Content Layer API loaders; file-based auto-discovery for src/content/docs/ is gone.
  • src/components/Header.astro and src/pages/tests.astro: resolve sibling/public/ paths from process.cwd() instead of new URL(..., import.meta.url). Astro 6's prerender bundles page modules into dist/.prerender/chunks/, so ../-relative URLs now resolve under dist/ and break.

Test plan

  • bun run build → 66 pages, clean
  • Verify deploy-docs CI passes
  • Smoke-test /3to4 (Header version readout) and /tests (manifest-driven iframes)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated Astro and Starlight development dependencies to latest versions for improved compatibility
    • Removed postinstall script to streamline dependency installation
    • Refactored internal file path resolution mechanisms

Fixes dependabot advisory: Astro XSS in define:vars via incomplete
</script> tag sanitization (supersedes #354).

Migrations:
- content.config.ts: add docsLoader() — Astro 6 requires Content Layer
  loaders; file-based auto-discovery removed.
- Header.astro + tests.astro: resolve sibling/public paths from
  process.cwd() instead of import.meta.url. Astro 6's prerender
  bundles into dist/.prerender/chunks/, breaking ../-relative URLs.
- Remove patch-package: upstream starlight already includes the
  head.ts fix the patch carried, and Bun has native patching.

Verified: bun run build → 66 pages, clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 22, 2026 17:09
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 22, 2026

📝 Walkthrough

Walkthrough

This pull request updates Astro dependencies to newer versions, removes the patch-package postinstall step, deletes the associated starlight patch file, and refactors path resolution across several components from import.meta.url-based approaches to process.cwd()-based approaches. Additionally, a content loader is introduced to the docs collection configuration.

Changes

Cohort / File(s) Summary
Dependency Updates & Script Changes
tko.io/package.json
Removed postinstall script; bumped @astrojs/starlight (0.37.7 → 0.38.3), @astrojs/check (0.9.6 → 0.9.8), and astro (5.18.1 → 6.1.8).
Patch File Removal
tko.io/patches/@astrojs+starlight+0.37.7.patch
Deleted patch file that previously handled head-construction logic validation and merging in starlight.
Path Resolution Refactoring
tko.io/src/components/Header.astro, tko.io/src/pages/tests.astro
Changed path resolution from import.meta.url-based (fileURLToPath, new URL) to process.cwd()-based (join) for accessing metadata and manifest files.
Content Configuration
tko.io/src/content.config.ts
Added docsLoader() to the docs collection definition alongside existing docsSchema().

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 Dependencies bump with graceful ease,
Patches fade like autumn leaves,
Path logic shifts from URLs to cwd,
A cleaner flow, the work is done! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and specifically summarizes the main changes: dependency version bumps for astro, starlight, and removal of patch-package, which are the core objectives of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch deps/astro-6-starlight-0.38

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
tko.io/src/pages/tests.astro (1)

12-14: Nit: process.cwd() is invocation-dependent.

Works as long as astro build/astro dev is invoked from tko.io/ (which the package scripts ensure), but silently resolves to the wrong path if someone runs the build from another cwd. Since bundle-tests.mjs already writes manifest.json to a known absolute location, consider making this resilient later — e.g. probe process.cwd() and its parent, or export the absolute path from a shared module. Not blocking given the PR’s successful 66-page build.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tko.io/src/pages/tests.astro` around lines 12 - 14, The current manifestPath
uses process.cwd() which is invocation-dependent; update the resolution so
manifestPath is robust by either importing an exported absolute path from the
bundling script (e.g., export the absolute manifest location from
bundle-tests.mjs and consume it where manifestPath is defined) or implement a
small probe that checks process.cwd() and its parent for
'public/tests/source/manifest.json' before falling back to process.cwd(); ensure
you reference the existing manifestPath, join, and the
'public/tests/source/manifest.json' string when implementing the fix.
tko.io/src/components/Header.astro (1)

4-16: LGTM — minor observation on cwd fragility.

The relative traversal '../builds/knockout/package.json' against process.cwd() correctly resolves to <repo>/builds/knockout/package.json when the build is run from tko.io/ (confirmed by the file’s presence and version field). Same caveat as tests.astro: this couples path resolution to the invocation directory rather than the module location. If you want a single source of truth for “repo root” across the Astro 6 migration, a small helper (e.g. resolveRepoFile(...)) would make both sites future-proof against invocation-dir changes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tko.io/src/components/Header.astro` around lines 4 - 16, The code in
Header.astro uses process.cwd() + '../builds/knockout/package.json' (see join,
readFileSync, const pkg, const version) which is fragile to invocation directory
changes; replace this with a repo-root resolver helper (e.g., resolveRepoFile)
that determines the repository root relative to the module (using
import.meta.url/fileURLToPath or a consistent project-root constant) and use
that helper to resolve and read the package.json so both Header.astro and
tests.astro share a single, stable source-of-truth for repo file paths.
tko.io/src/content.config.ts (1)

2-2: Drop the semicolon to match the Biome style.

This changed import should follow the repo’s no-semicolon TS formatting.

🧹 Proposed style fix
-import { docsLoader } from '@astrojs/starlight/loaders';
+import { docsLoader } from '@astrojs/starlight/loaders'

As per coding guidelines, **/*.{ts,tsx,js,jsx,json}: “Use Biome for linting and formatting: no semicolons, single quotes, no trailing commas, 120 char width, 2-space indent, LF line endings”.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tko.io/src/content.config.ts` at line 2, Remove the trailing semicolon from
the import statement that imports docsLoader from '@astrojs/starlight/loaders'
to conform to the Biome style (no semicolons); update the import line that
references docsLoader so it ends without a semicolon and ensure formatting
follows the repo's Biome rules (single quotes, 2-space indent, LF endings).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tko.io/src/components/Header.astro`:
- Around line 4-16: The code in Header.astro uses process.cwd() +
'../builds/knockout/package.json' (see join, readFileSync, const pkg, const
version) which is fragile to invocation directory changes; replace this with a
repo-root resolver helper (e.g., resolveRepoFile) that determines the repository
root relative to the module (using import.meta.url/fileURLToPath or a consistent
project-root constant) and use that helper to resolve and read the package.json
so both Header.astro and tests.astro share a single, stable source-of-truth for
repo file paths.

In `@tko.io/src/content.config.ts`:
- Line 2: Remove the trailing semicolon from the import statement that imports
docsLoader from '@astrojs/starlight/loaders' to conform to the Biome style (no
semicolons); update the import line that references docsLoader so it ends
without a semicolon and ensure formatting follows the repo's Biome rules (single
quotes, 2-space indent, LF endings).

In `@tko.io/src/pages/tests.astro`:
- Around line 12-14: The current manifestPath uses process.cwd() which is
invocation-dependent; update the resolution so manifestPath is robust by either
importing an exported absolute path from the bundling script (e.g., export the
absolute manifest location from bundle-tests.mjs and consume it where
manifestPath is defined) or implement a small probe that checks process.cwd()
and its parent for 'public/tests/source/manifest.json' before falling back to
process.cwd(); ensure you reference the existing manifestPath, join, and the
'public/tests/source/manifest.json' string when implementing the fix.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b28047a2-bf3e-42d3-bac7-0d7cd7f72468

📥 Commits

Reviewing files that changed from the base of the PR and between 4780dfe and 789ea8b.

⛔ Files ignored due to path filters (1)
  • tko.io/bun.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • tko.io/package.json
  • tko.io/patches/@astrojs+starlight+0.37.7.patch
  • tko.io/src/components/Header.astro
  • tko.io/src/content.config.ts
  • tko.io/src/pages/tests.astro
💤 Files with no reviewable changes (1)
  • tko.io/patches/@astrojs+starlight+0.37.7.patch

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the tko.io documentation site to Astro 6 / Starlight 0.38, including required Astro 6 migration adjustments and removal of patch-package now that the upstream Starlight fix is available.

Changes:

  • Bump astro 5→6, @astrojs/starlight 0.37→0.38, and @astrojs/check 0.9.6→0.9.8 (plus lockfile refresh).
  • Migrate src/content.config.ts to Astro 6’s Content Layer loader (docsLoader()).
  • Fix SSR-time filesystem path resolution in prerendered bundles (switch to process.cwd()-based paths) and remove the Starlight patch + patch-package hook.

Reviewed changes

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

Show a summary per file
File Description
tko.io/src/pages/tests.astro Adjust manifest path resolution for Astro 6 prerender bundling.
tko.io/src/content.config.ts Adds Starlight docsLoader() required by Astro 6 content layer.
tko.io/src/components/Header.astro Updates package.json path resolution to remain correct under prerender chunk bundling.
tko.io/patches/@astrojs+starlight+0.37.7.patch Removes obsolete patch file.
tko.io/package.json Bumps Astro/Starlight deps and removes patch-package postinstall.
tko.io/bun.lock Lockfile update reflecting new dependency tree.

Comment on lines +12 to +13
// Resolve from cwd (project root) — import.meta.url points into
// dist/.prerender/chunks/ under Astro 6's prerender bundler.
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

The comment says "Resolve from cwd (project root)", but in this repo process.cwd() will be the tko.io/ package directory (not the monorepo root) because the docs build runs from cd tko.io. Clarifying this (e.g., “site root” / “tko.io root”) would avoid confusion for contributors running scripts from other directories.

Suggested change
// Resolve from cwd (project root) — import.meta.url points into
// dist/.prerender/chunks/ under Astro 6's prerender bundler.
// Resolve from cwd (the tko.io site/package root during the docs
// build) — import.meta.url points into dist/.prerender/chunks/
// under Astro 6's prerender bundler.

Copilot uses AI. Check for mistakes.
Comment on lines 1 to 3
import { defineCollection } from 'astro:content';
import { docsLoader } from '@astrojs/starlight/loaders';
import { docsSchema } from '@astrojs/starlight/schema';
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

tko.io code generally follows the repo-wide Biome style (no semicolons). Since this file is being touched for the Astro 6 migration, consider removing the trailing semicolons here as well to keep formatting consistent.

Copilot uses AI. Check for mistakes.
@brianmhunt brianmhunt merged commit 733bbb1 into main Apr 22, 2026
13 checks passed
@brianmhunt brianmhunt deleted the deps/astro-6-starlight-0.38 branch April 22, 2026 18:40
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