djatadougbewilfried-star f23267105a
fix(design-system): make the skill work outside a vendored checkout and on Windows (#460)
* fix(design-system): resolve project root from cwd, not __file__

fetch-background.py and html-token-validator.py derived PROJECT_ROOT with five
.parent hops, which only reaches the project root when the skill is vendored at
<project>/.claude/skills/design-system/scripts/. Installed at user level
(~/.claude/skills/) or as a plugin, PROJECT_ROOT pointed outside the project, so
both scripts silently ran against no tokens at all.

Resolve from the working directory instead, matching generate-tokens.cjs and
validate-tokens.cjs which already use process.cwd(). DESIGN_SYSTEM_PROJECT_ROOT
overrides it when the project root cannot be inferred.

slide_search_core.py is left alone: it resolves skill-relative data, which is
the correct use of __file__.

Refs #459

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(design-system): stop findProjectRoot from hanging on Windows

embed-tokens.cjs walked up the tree with `while (dir !== '/')`. On Windows the
filesystem root is 'C:\', so that condition is never true, and path.dirname('C:\')
returns 'C:\' unchanged -- the loop spins forever at 100% CPU instead of erroring
out, whenever assets/design-tokens.css is not found above the cwd.

Stop when dirname stops changing, which terminates on every platform.

Refs #459

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(design-system): force UTF-8 stdout so emoji output works on cp1252 consoles

search-slides.py --context and html-token-validator.py print emoji. On a Windows
console the default encoding is cp1252, so the first emoji raises
UnicodeEncodeError and the command dies with a traceback instead of output --
this takes out --context, the entry point of the contextual slide system.

Reuse the guard already shipped in src/ui-ux-pro-max/scripts/search.py.

Refs #459

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* test(design-system): decode subprocess output as UTF-8 in validate-tokens tests

test_validate_tokens.py drives validate-tokens.cjs through subprocess.run with
text=True but no explicit encoding, so Python decodes the pipe with the locale
codec. On Windows (cp1252) the validator's emoji output raises UnicodeDecodeError
inside the reader thread, result.stdout comes back as None, and the assertion
fails with a confusing `TypeError: argument of type 'NoneType' is not a
container` -- this suite cannot pass on Windows at all today.

Pin the pipe and the fixture write to UTF-8. The validator itself was never at
fault: run by hand it flags the hardcoded hex correctly.

Note: brand/scripts/tests/test_sync_brand_to_tokens.py uses the same
text=True-without-encoding pattern and is one emoji away from failing the same
way. Left alone to keep this PR scoped to design-system.

Refs #459

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-01 01:42:36 +07:00
..