|
| 1 | +# Cross-Platform Paths Pack |
| 2 | + |
| 3 | +Use this when a task touches filesystem paths, file URLs, public URLs, virtual module ids, generated import specifiers, scanner or project roots, build integrations, CLI behavior, language server paths, VS Code packaging, or tests and fixtures that assert paths. |
| 4 | + |
| 5 | +## Read |
| 6 | + |
| 7 | +- `AGENTS.md` |
| 8 | +- `.ai/context/index.md` |
| 9 | +- `.ai/code-style.md` |
| 10 | +- `.ai/context/testing.md` |
| 11 | +- The affected package `package.json` |
| 12 | +- The affected package-local `AI.md`, if present |
| 13 | +- Existing source and tests near the path-sensitive behavior |
| 14 | + |
| 15 | +## Workflow |
| 16 | + |
| 17 | +- Classify every changed string domain before editing: filesystem path, file URL, public URL, virtual module id, or generated import specifier. |
| 18 | +- Use `node:path` helpers for filesystem paths, with path segments passed separately. |
| 19 | +- Convert file URLs only at boundaries with `fileURLToPath()` / `pathToFileURL()` or the local package helper. |
| 20 | +- Use `path.relative(parent, child)` for filesystem containment checks; reject `..`, `../...`, and absolute relative results. |
| 21 | +- Keep URL-like strings slash-based and do not pass public URLs, virtual ids, or import specifiers through `node:path`. |
| 22 | +- For path-sensitive pure helpers, add focused tests with `path.win32` and `path.posix` where practical. Otherwise rely on package tests that already run in Windows CI and document that choice. |
| 23 | + |
| 24 | +## Validation |
| 25 | + |
| 26 | +- Run the affected package test command. |
| 27 | +- Run affected package lint if it defines `lint`. |
| 28 | +- Run `pnpm test:cross-platform-paths` when code or tests touch paths, file URLs, public URLs, virtual ids, generated import specifiers, scanner roots, project roots, build integrations, CLI, language server, or VS Code packaging. |
| 29 | +- If a flagged path pattern is intentional, either rewrite it into an explicit helper domain or update `.ai/cross-platform-path-baseline.json` with a clear review reason. |
| 30 | + |
| 31 | +## Escalate When |
| 32 | + |
| 33 | +- Path-sensitive behavior crosses package boundaries: read `.ai/context/package-boundaries.md`. |
| 34 | +- CSS output, runtime, extraction, language tooling, ESLint, compiler, parser, virtual module ids, or generated import specifiers change: read `.ai/context/accuracy-guardrails.md`. |
| 35 | +- CI, release, lockfiles, or package manager behavior changes: read `.ai/context/accuracy-guardrails.md`. |
0 commit comments