Fix Windows path separators and console encoding#83
Conversation
build_context emitted component/file-cache paths using the OS-native separator (e.g. scripts\helper.py on Windows), which broke SARIF output and tests that expect POSIX-style paths. Normalize relative paths with Path.as_posix() so analysis output is identical across platforms. Apply the same �s_posix() normalization to the five test helpers that build file caches from fixture directories. The CLI terminal report also crashed on Windows consoles (cp1252) with UnicodeEncodeError when rendering box-drawing characters and icons. Reconfigure stdout/stderr to UTF-8 (errors="replace") at startup so the report renders without crashing on any platform. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@keshprad — heads up: this PR has a content overlap with #87. Both PRs fix the same If this PR lands first, #87 becomes a full conflict on those 6 files and can be closed. Flagging so you don't have to resolve a merge conflict on review. |
rng1995
left a comment
There was a problem hiding this comment.
LGTM. Clean, well-scoped cross-platform fixes:
- Normalizing relative paths with
Path.as_posix()inbuild_context._walk_skill_files(and the matching test helpers) is the right fix — it guarantees POSIX-style component/file-cache keys regardless of OS, which keeps SARIF output and downstream pattern matching consistent on Windows. _ensure_utf8_streams()defensively reconfigures stdout/stderr to UTF-8 witherrors="replace", guards for streams without areconfiguremethod, and swallows onlyValueError/OSError— a reasonable way to avoidUnicodeEncodeErroron legacy Windows consoles.
Minor / optional (non-blocking):
_ensure_utf8_streams()runs unconditionally at import on every platform, switching the error handler toreplaceeven where the console is already UTF-8. That's harmless for a report-rendering CLI, but if you want strict behaviour preserved on POSIX you could gate it onsys.platform == "win32"or on a detected non-UTF-8 encoding.
Nice work verifying across input/output formats and confirming the previously-failing Windows tests now pass.
|
@dc995 - Please resolve the conflicts, minor issues and merge the PR. |
…console-encoding # Conflicts: # src/skillspector/nodes/build_context.py # tests/nodes/analyzers/test_semantic_developer_intent.py # tests/nodes/analyzers/test_semantic_security_discovery.py # tests/nodes/test_semantic_quality_policy.py # tests/test_mcp_least_privilege.py # tests/test_mcp_tool_poisoning.py
|
@rng1995 Done — this is ready to merge on your end:
PR shows |
|
@dc995 - You got another conflict to resolve. Please resolve it and I will merge the PR. Thanks! |
rng1995
left a comment
There was a problem hiding this comment.
[Automated SkillSpector Review]
Re-review after rebase — re-confirming approval.
Since my approval the path-normalization (Path.as_posix()) landed independently via #87, so this PR's unique remaining source change is the cli.py UTF-8 console fix — and it now addresses my prior non-blocking nit by skipping streams that are already UTF-8 (preserving strict behavior on POSIX, reconfiguring only legacy consoles). It still guards for a missing reconfigure and swallows only ValueError/OSError. The large -403 in the diff is just uv.lock regeneration. No concerns. Approving.
Summary
Fixes three Windows-specific portability bugs discovered while running the test suite and CLI on Windows.
1. Path separators in �uild_context (product bug)
�uild_context emitted component and file-cache paths using the OS-native separator (e.g.
scripts\helper.pyon Windows) instead of forward slashes. This broke SARIF output and any consumer/test expecting POSIX-style paths. Fixed by normalizing relative paths withPath.as_posix().2. Console encoding crash in the CLI (product bug)
The terminal report crashed on Windows consoles (cp1252) with
UnicodeEncodeErrorwhen rendering box-drawing characters/icons. Fixed by reconfiguringstdout/stderrto UTF-8 (errors="replace") at CLI startup.3. Test helpers (test-only)
Five test helpers built fixture file-caches with
str(path), producing backslash keys on Windows. Normalized them with.as_posix()to match the product behavior.Validation
ruff check), format (ruff format --check), build (python -m build): all passNotes
Changes are surgical: path-separator normalization and stdout encoding only. No behavior change to analysis logic.
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com