cwd-safe-astro-aliases: CWD-safe Astro aliases #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "task/cwd-safe-astro-aliases"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.