Before making changes, agents should always review:
REVIEW.md(current priorities and critical follow‑ups)README.md(user‑facing behavior and commands)package.json(activation, commands, settings)
src/extension.ts: Main VS Code extension (custom editorcsv.editor, commands undercsv.*).src/test/*.test.ts: Unit tests (compiled toout/test).src/types/: Type shims (e.g.,font-list.d.ts).out/: Transpiled JavaScript output.images/: Marketplace icon and screenshots.package.json: Activation events, commands, settings, and scripts.
npm install: Install dependencies.npm ci: Clean, reproducible install (preferred in CI/local verification).npm run compile: TypeScript →out/viatsc.npm run lint: ESLint over**/*.tsusingeslint.config.mjs.npm test: Compile, then run Node’s test runner onout/test.npm run package: Create a.vsixusingvsce(publish/build).
Example local loop:
npm install
npm run lint && npm run compile
npm test
- Use a modern Node runtime (recommended: Node 20 LTS).
- If using
nvm, runnvm use 20before install/build/test commands. - Prefer
npm ciovernpm installfor deterministic dependency resolution when validating changes.
- After any code change, run
npm run compilebefore sending the final response. - If compile fails, report the error and do not mark the task complete.
- Skip this only for docs-only changes or when the user explicitly asks to skip compile.
- Run
npm testwhen behavior changes (commands, settings, parsing, rendering, webview interactions, or data mutations). - If tests are skipped, state why and call out residual risk.
- Keep
package-lock.jsontracked in git; do not gitignore it. - Commit lockfile updates when dependencies or dependency metadata change.
- Avoid unrelated lockfile churn; if lockfile changes are incidental, regenerate with the project’s standard Node/npm toolchain.
- When adding/changing commands or settings, update both
package.jsoncontributions andREADME.mdin the same change. - For any user-visible behavior update, include a concise note in PR/test plan describing how it was validated.
- Changes to
media/main.js, webview message contracts, or rendered table HTML should include/update tests insrc/test. - Prefer tests that verify invariants and edge cases (selection/edit interactions, chunking behavior, escaping/linkification safety).
- Language: TypeScript with
strictmode (seetsconfig.json). - Indentation: 2 spaces; include semicolons.
- ESLint: prefer
===, require curly braces, no throwing literals; import names camelCase/PascalCase. - Structure: keep functions small and pure where feasible; utilities that don’t touch VS Code APIs are easier to test.
- Filenames:
kebab-casefor new files; tests end with.test.ts.
- Framework:
node:testwithassert. - Location/pattern:
src/test/**/*.test.ts→ compiled toout/test. - Run:
npm test(ensures a fresh compile). - Conventions: target pure utilities (parsing, type inference, color mapping, HTML escaping). Add tests when changing command behavior or settings logic. No formal coverage threshold; aim for meaningful cases.
- Commits: imperative mood, concise. Optional prefixes like
fix:/chore:to match history (e.g., “Add TSV support”, “chore: widen vscode engine compatibility”). Reference issues/PRs:(#42). - PRs: clear description, linked issues, test plan, and screenshots/GIFs for UI changes. Note any new settings/commands and update
README.mdwhen user-facing.
- Webview: escape all user data before injecting HTML; avoid
eval/inline scripts. Be mindful of content security. - Settings: use
csv.*keys declared inpackage.jsonand respectcsv.enabled. - Compatibility: keep within engines in
package.json(vscodeand Node). Validate both.csvand.tsvflows.