cwd-safe-astro-aliases: CWD-safe Astro aliases #3

Open
std-bot wants to merge 1 commit from task/cwd-safe-astro-aliases into main
First-time contributor

Assigned idea

Benchmark authoring specification.

Summary: Make the Astro docs config resolve its Vite aliases relative to astro.config.ts instead of the process working directory, so loading the config from another cwd still points at this repo's www and src directories.

Task intent: Ordinary upstream-facing work for metonym/svelte-highlight: update the Astro/Vite config so the aliases @www, @layouts, @components, and svelte-highlight are anchored to the repository directory, while preserving the existing Svelte integration, preprocessors, package define values, prefetch settings, and optimizeDeps exclusion.

Benchmark plan: Construct the work package from commit d1bcb5707bbe76628753b386fa327cc26bde5471. The solver prompt should cite astro.config.ts as the affected file and specify the observable behavior: after process.chdir() to a temporary directory outside the repo, importing astro.config.ts must still produce vite.resolve.alias values pointing to the repo's www, www/layouts, www/components, and src paths. Do not ask for docs UI or library source changes.

Environment plan: Task environment: Node 20 or newer, npm dependencies installed at the repo root, and Python 3 for test_outputs.py. The verifier may create a temporary cwd outside the checkout. Environment/repo: the materialized upstream repo metonym/svelte-highlight at the fixed commit; the task should not require external services or publishing.

Verifier plan: test_outputs.py should exit 0 only when astro.config.ts computes cwd-independent alias paths. It should run from the repo root, create a temp directory, chdir there inside a Node helper such as node --import tsx, import the repo's astro.config.ts by absolute file URL, and assert config.vite.resolve.alias maps @www to /www, @layouts to /www/layouts, @components to /www/components, and svelte-highlight to /src. It should also reject solutions that call process.chdir in astro.config.ts and should run npm run build or an equivalent Astro config load check to catch regressions.

Oracle plan: The oracle solution is a one-file patch to astro.config.ts: derive the config directory with an ESM-safe mechanism such as fileURLToPath(import.meta.url) plus path.dirname, add a small helper that resolves paths from that directory, and use it for the four local Vite aliases. Keep the existing imports, integrations, optimizeCss/optimizeImports behavior, package-derived define constants, and __TS behavior otherwise unchanged.

Difficulty plan: Current coding systems may fail by continuing to use path.resolve with process.cwd(), trying to use __dirname in an ESM TypeScript config, fixing only one alias, hard-coding the checkout path, changing unrelated package metadata defines, or breaking the Astro config import syntax.

Repo patch scope: Expected upstream edits are limited to astro.config.ts. Do not change src/, www/, package.json, lockfiles, or dependency declarations.

Anti-leakage notes: Solver-facing materials must not mention benchmark, harness, Snorkel, Harbor, std-ts, agent, stage, attempt, retry, generated task, or evaluation context; present it as normal Astro config maintenance.

Approach: Use import.meta.url to compute the directory containing astro.config.ts, then replace the cwd-sensitive path.resolve("./...") alias targets with config-file-relative absolute paths. Preserve the alias keys and all unrelated config options.

Verification: Run python3 test_outputs.py from the repo root; it should inspect astro.config.ts, execute a Node helper from a temporary cwd to import astro.config.ts, verify the four vite.resolve.alias targets, and run npm run build or an equivalent Astro config load command.

Risk: The main risk is verifier fragility around TypeScript ESM loading and JSON import assertions in astro.config.ts. Mitigate by pinning Node 20+, installing repo dependencies before the check, normalizing paths before comparison, and keeping the behavioral import check focused on vite.resolve.alias.

Path rules: task package is tasks/; mutable upstream checkout is tasks//environment/repo; benchmark package files are under tasks//task; verifier/container environment belongs under tasks//task/environment; regular and UI verifier logic belongs in task/tests/test_outputs.py and test.sh only runs that file through pytest.

Agent context

Task slug: cwd-safe-astro-aliases
Branch: task/cwd-safe-astro-aliases

## Assigned idea Benchmark authoring specification. Summary: Make the Astro docs config resolve its Vite aliases relative to astro.config.ts instead of the process working directory, so loading the config from another cwd still points at this repo's www and src directories. Task intent: Ordinary upstream-facing work for metonym/svelte-highlight: update the Astro/Vite config so the aliases @www, @layouts, @components, and svelte-highlight are anchored to the repository directory, while preserving the existing Svelte integration, preprocessors, package define values, prefetch settings, and optimizeDeps exclusion. Benchmark plan: Construct the work package from commit d1bcb5707bbe76628753b386fa327cc26bde5471. The solver prompt should cite astro.config.ts as the affected file and specify the observable behavior: after process.chdir() to a temporary directory outside the repo, importing astro.config.ts must still produce vite.resolve.alias values pointing to the repo's www, www/layouts, www/components, and src paths. Do not ask for docs UI or library source changes. Environment plan: Task environment: Node 20 or newer, npm dependencies installed at the repo root, and Python 3 for test_outputs.py. The verifier may create a temporary cwd outside the checkout. Environment/repo: the materialized upstream repo metonym/svelte-highlight at the fixed commit; the task should not require external services or publishing. Verifier plan: test_outputs.py should exit 0 only when astro.config.ts computes cwd-independent alias paths. It should run from the repo root, create a temp directory, chdir there inside a Node helper such as node --import tsx, import the repo's astro.config.ts by absolute file URL, and assert config.vite.resolve.alias maps @www to <repo>/www, @layouts to <repo>/www/layouts, @components to <repo>/www/components, and svelte-highlight to <repo>/src. It should also reject solutions that call process.chdir in astro.config.ts and should run npm run build or an equivalent Astro config load check to catch regressions. Oracle plan: The oracle solution is a one-file patch to astro.config.ts: derive the config directory with an ESM-safe mechanism such as fileURLToPath(import.meta.url) plus path.dirname, add a small helper that resolves paths from that directory, and use it for the four local Vite aliases. Keep the existing imports, integrations, optimizeCss/optimizeImports behavior, package-derived define constants, and __TS behavior otherwise unchanged. Difficulty plan: Current coding systems may fail by continuing to use path.resolve with process.cwd(), trying to use __dirname in an ESM TypeScript config, fixing only one alias, hard-coding the checkout path, changing unrelated package metadata defines, or breaking the Astro config import syntax. Repo patch scope: Expected upstream edits are limited to astro.config.ts. Do not change src/, www/, package.json, lockfiles, or dependency declarations. Anti-leakage notes: Solver-facing materials must not mention benchmark, harness, Snorkel, Harbor, std-ts, agent, stage, attempt, retry, generated task, or evaluation context; present it as normal Astro config maintenance. Approach: Use import.meta.url to compute the directory containing astro.config.ts, then replace the cwd-sensitive path.resolve("./...") alias targets with config-file-relative absolute paths. Preserve the alias keys and all unrelated config options. Verification: Run python3 test_outputs.py from the repo root; it should inspect astro.config.ts, execute a Node helper from a temporary cwd to import astro.config.ts, verify the four vite.resolve.alias targets, and run npm run build or an equivalent Astro config load command. Risk: The main risk is verifier fragility around TypeScript ESM loading and JSON import assertions in astro.config.ts. Mitigate by pinning Node 20+, installing repo dependencies before the check, normalizing paths before comparison, and keeping the behavioral import check focused on vite.resolve.alias. Path rules: task package is tasks/<slug>; mutable upstream checkout is tasks/<slug>/environment/repo; benchmark package files are under tasks/<slug>/task; verifier/container environment belongs under tasks/<slug>/task/environment; regular and UI verifier logic belongs in task/tests/test_outputs.py and test.sh only runs that file through pytest. ## Agent context Task slug: cwd-safe-astro-aliases Branch: task/cwd-safe-astro-aliases <!-- std-ts:idea-pr-body -->
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin task/cwd-safe-astro-aliases:task/cwd-safe-astro-aliases
git switch task/cwd-safe-astro-aliases

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff task/cwd-safe-astro-aliases
git switch task/cwd-safe-astro-aliases
git rebase main
git switch main
git merge --ff-only task/cwd-safe-astro-aliases
git switch task/cwd-safe-astro-aliases
git rebase main
git switch main
git merge --no-ff task/cwd-safe-astro-aliases
git switch main
git merge --squash task/cwd-safe-astro-aliases
git switch main
git merge --ff-only task/cwd-safe-astro-aliases
git switch main
git merge task/cwd-safe-astro-aliases
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
snorkel/root-repository-maintenance-e12f3c587c0145!3
No description provided.