87254dd561
When parity/divergence work needs Ink's source, clone it once to a fixed path (/tmp/ink) and read locally instead of relying on node_modules (Ink isn't a dependency). Always check out and confirm the pinned baseline first — the exact version/commit lives in .agents/docs/ink-divergences.md — since a claim read against the wrong Ink version is worse than none. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5.7 KiB
5.7 KiB
Common Pitfalls & Best Practices
- AGENTS.md is the source of truth. CLAUDE.md is a symlink to it.
- Always use Vue's
shallowRefoverrefby default. Usingrefrequires a solid justification and a code comment explaining why deep reactivity is needed. - Always use
defineComponent()to define components. Never use bare{ setup() {} }objects — they lack component scope, soinject,watch, andonScopeDisposewon't work correctly. - Vue SFCs must use
<script setup>unless there's an explicit reason not to. - When code must deviate from normal/idiomatic style because the situation genuinely requires it (e.g. a control-character regex in a terminal parser, a deliberate string code-point spread, a lint rule suppressed for a justified reason), add a comment explaining why it has to be written that way. Don't silence a linter or write surprising code without a note — the next reader should not have to guess whether it's intentional.
- Bug fixes must follow test-first: write a failing test that reproduces the bug, then fix the code and verify the test passes.
- Tests must simulate real user conditions. Non-TTY environments disable chalk colors — use
FORCE_COLORenv var so ANSI output is always exercised. A bug invisible in tests but visible in a real terminal is a testing gap, not a minor issue. Each spawned subprocess is a fresh Node process with its own chalk, so PTY/child helpers must setFORCE_COLORin the child env too, not just the vitest config. - When debugging color/ANSI output in non-TTY environments (e.g. Claude Code shell), use
FORCE_COLOR=3env var to force chalk to output ANSI codes. - Test files run in parallel (
fileParallelism: true), but tests WITHIN a file run serially. We deliberately do NOT setsequence.concurrent: many render tests assert timing-sensitive counts driven by the renderer's ~32ms commit throttle, and in-file concurrency starves them of wall-clock on a 4-core CI runner (it passes on higher-core dev machines — the classic local-vs-CI trap). PTY tests needpool: "forks"(node-pty requireschild_process.fork, not worker threads). - Tests that depend on process-global state — fake timers (
vi.useFakeTimers, which mutates globalsetTimeout/performance) or assertions on shared globals (process.listenerCount, live yoga-node counts) — live in*.sequential.test.*files. Even file-level parallelism can perturb them, and grouping them by name documents the constraint. Add a header comment saying which global forces it. - Tests must not implicitly depend on the host environment. The CI runner sets
CI=true, which flipsinteractive = !isInCi && isTTYoff (disabling the resize listener, cursor, ANSI erases) — so both vitest configs forceenv: { CI: "false" }, and PTY child helpers setCI: "false"per-spawn. If a test needs a specific CI/TTY/color behavior, inject it explicitly (mount option, child env) rather than relying on the ambient value. Reproduce CI locally withCI=true vp run cion a fresh checkout (rm -rf packages/*/dist). - After completing any task, run
vp run ready(orvpr ready) to verify: lint, type-check, test all packages, and build. - Never commit anything under
docs/. That directory is for local working notes and specs — it must stay out of git. - To read Ink's source (parity / divergence work), clone it once to a fixed local path and read from there —
git clone https://github.com/vadimdemedes/ink /tmp/inkonly when/tmp/inkis missing, otherwise reuse the existing clone (Ink isn't an npm dependency, so it's not innode_modules). Before trusting anything you read, check out and confirm the pinned baseline —.agents/docs/ink-divergences.mdrecords the exact version/commit (currently v7.0.4); a claim read against the wrong Ink version is worse than none.
Context Engineering
Long-lived design context lives in .agents/docs/ (committed — distinct from the
uncommitted docs/ working-notes folder). Convention, borrowed from rolldown:
- One concept per file; files cross-link with
[[other-doc]]. - If a design doc covers the area you're about to work in, read it first.
- If your change affects a design doc, update it in the same change. Docs that drift from reality are worse than no docs.
- Capture the why — trade-offs considered, alternatives rejected, known pitfalls — not just what the code does.
- Be concise and direct: the essential what + why, led by the principle or intuition. Lose no information, but don't write essays or exhaustive mechanism dumps. When a behavior is the correct default (e.g. render = f(current props)), state the principle — don't dress it up as a framework limitation.
Using Vite+, the Unified Toolchain for the Web
This project is using Vite+, a unified toolchain built on top of Vite, Rolldown, Vitest, tsdown, Oxlint, Oxfmt, and Vite Task. Vite+ wraps runtime management, package management, and frontend tooling in a single global CLI called vp. Vite+ is distinct from Vite, and it invokes Vite through vp dev and vp build. Run vp help to print a list of commands and vp <command> --help for information about a specific command.
Docs are local at node_modules/vite-plus/docs or online at https://viteplus.dev/guide/.
Review Checklist
- Run
vp installafter pulling remote changes and before getting started. - Run
vp checkandvp testto format, lint, type check and test changes. - Check if there are
vite.config.tstasks orpackage.jsonscripts necessary for validation, run viavp run <script>. - If setup, runtime, or package-manager behavior looks wrong, run
vp env doctorand include its output when asking for help.