Task #18: Automatically test that uploaded skill files are read correctly.
The skill parser (artifacts/api-server/src/lib/skillParser.ts) had no automated
tests. A regression there could silently mis-read uploads. Added a new Vitest
suite covering the parsing/classification logic (NOT the ZIP size/safety limits,
which are tracked by a separate task).
New file: artifacts/api-server/src/lib/skillParser.test.ts
Coverage:
- parseSingleFile: kind/language/hash/size/isBinary for .md, .sh, .py, .json,
.txt, unknown ext, and a binary blob; path normalisation (dir strip,
backslashes); case-insensitive SKILL.md.
- parseText: wraps pasted text as markdown SKILL.md; byte-length sizing for
multi-byte content.
- parseZip (in-memory ZIP via fflate.zipSync): correct classification, nested
path preservation, __MACOSX/.git/node_modules skipping, dir/empty entry
skipping, binary-vs-text handling, stable hashing.
- deriveScanName: H1 from SKILL.md, name: front-matter fallback, quote
stripping, H1 preferred over front-matter, top-dir fallback, provided
fallback, 120-char truncation.
Verification: `pnpm --filter @workspace/api-server run test` → 59 passed
(24 new). Typecheck of the new test file is clean; pre-existing typecheck
errors in src/routes/scans.ts are unrelated and out of scope.
Replit-Task-Id: 06f18e6a-2d8d-4bf2-b2ae-29675f04c059