typed-vite-env-config: Typed Vite env config #4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "task/typed-vite-env-config"
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: Add a strict, typed Vite public environment configuration layer for NeoTavern frontend API and WebSocket URLs, grounded in the repo’s existing Vite client TypeScript setup.
Task intent: Ordinary upstream-facing work: define the public Vite env contract for NeoTavern backend endpoints and centralize URL normalization so frontend code has a typed helper instead of raw import.meta.env reads.
Benchmark plan: Construct a regular task package around adding two focused files: an ambient Vite env declaration and a small config resolver. The solver-facing prompt should ask for typed support for VITE_NEOTAVERN_API_URL and optional VITE_NEOTAVERN_WS_URL, with getPublicEnv-style resolution that strips trailing slashes, rejects missing or invalid URLs, and derives ws/wss from http/https API URLs when the WebSocket URL is absent.
Environment plan: Task environment: Python 3 plus Node 20/npm for running the verifier and TypeScript checks. Repository environment: materialize NeoTavern/NeoTavern-Frontend at 017bb4c2fa25900197556c3f7ee45c0d06616e32 and use its existing tsconfig.json, especially the Vite client typings and strict noEmit configuration; no backend service or network API is required.
Verifier plan: test_outputs.py should expect src/vite-env.d.ts and src/config/env.ts. It should assert that ImportMetaEnv includes readonly VITE_NEOTAVERN_API_URL and optional readonly VITE_NEOTAVERN_WS_URL, that env.ts exports normalizePublicBaseUrl, deriveWebSocketBaseUrl, and getPublicEnv, then create a temporary TypeScript contract file importing those exports and referencing import.meta.env.VITE_NEOTAVERN_API_URL. It should run npx tsc -p tsconfig.json --noEmit --pretty false and also check deterministic behavior for trailing-slash removal, http-to-ws and https-to-wss derivation, and invalid protocol rejection via the exported pure helpers.
Oracle plan: The oracle patch should create src/vite-env.d.ts with Vite ImportMetaEnv augmentation and src/config/env.ts with typed PublicRuntimeEnv/ResolvedPublicEnv exports, pure URL normalization helpers, WebSocket derivation, and getPublicEnv(env = import.meta.env). The implementation should avoid top-level env reads so verifier stubs can call the resolver deterministically.
Difficulty plan: Current coding agents may miss that tsconfig already supplies vite/client types, may incorrectly edit tsconfig.json, may add Node-only process.env usage, or may place env declarations outside the included src/**/*.d.ts glob. Strict noUnusedLocals and isolatedModules can also expose sloppy TypeScript fixes.
Repo patch scope: Expected upstream edits are limited to src/vite-env.d.ts and src/config/env.ts. Do not change tsconfig.json, package metadata, Vite config, or unrelated UI files.
Anti-leakage notes: Forbid solver-facing mentions of benchmark, harness, Snorkel, Harbor, std-ts, agent, stage, attempt, retry, generated task, and evaluation context. Present it only as normal frontend configuration work.
Approach: Use the existing Vite client typing hook from tsconfig.json, add an ambient env declaration under src, and implement a small typed resolver module with pure functions that can be type-checked and behavior-checked without launching the app.
Verification: Run python test_outputs.py /path/to/NeoTavern-Frontend; inside it, verify src/vite-env.d.ts and src/config/env.ts, create a temporary TypeScript contract check, and run npx tsc -p tsconfig.json --noEmit --pretty false.
Risk: The main risk is making the verifier too dependent on exact formatting. Author the checks around exported names, TypeScript compatibility, and observable URL behavior rather than line-by-line source matching.
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: typed-vite-env-config
Branch: task/typed-vite-env-config
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.