fix(#1615): normalize Windows backslash paths in workflow content
computePathPrefix returned a Windows-style path (with backslashes from path.join) into markdown @-references. Workflow file content on Windows ended up with mixed separators, breaking substring checks in install/install-runtime-artifacts tests on windows-latest CI only. Normalize resolvedTarget and homeDir to forward slashes inside computePathPrefix. The prefix is always substituted into markdown body text, which uses POSIX paths universally. Idempotent on POSIX. Also normalizes the two test assertions to forward-slash form so they pass on Windows. Adds a regression test for backslash-style input. Documents DEFECT.WINDOWS-PATH-LEAK-IN-MARKDOWN-CONTENT + RULESET.CONTENT-PATH-NORMALIZATION in CONTEXT.md so this anti-pattern stops recurring.
This commit is contained in:
@@ -2169,10 +2169,18 @@ function convertClaudeCommandToKiloSkill(content, skillName) {
|
||||
* @private — exported as `_computePathPrefix` for tests.
|
||||
*/
|
||||
function computePathPrefix({ isGlobal, isOpencode, isWindowsHost: _isWindowsHost, resolvedTarget, homeDir }) {
|
||||
if (isGlobal && resolvedTarget.startsWith(homeDir) && !isOpencode) {
|
||||
return '$HOME' + resolvedTarget.slice(homeDir.length) + '/';
|
||||
// #1615: normalize Windows backslashes to forward slashes. This prefix is
|
||||
// substituted into markdown @-references (e.g. Windsurf workflow files),
|
||||
// which use POSIX paths universally. Idempotent on POSIX (no backslashes).
|
||||
// Without this, path.join on Windows produces a backslash prefix that
|
||||
// leaks into markdown content and breaks cross-platform substring checks.
|
||||
// See DEFECT.WINDOWS-PATH-LEAK-IN-MARKDOWN-CONTENT in CONTEXT.md.
|
||||
const posixTarget = String(resolvedTarget).replace(/\\/g, '/');
|
||||
const posixHome = homeDir ? String(homeDir).replace(/\\/g, '/') : homeDir;
|
||||
if (isGlobal && posixTarget.startsWith(posixHome) && !isOpencode) {
|
||||
return '$HOME' + posixTarget.slice(posixHome.length) + '/';
|
||||
}
|
||||
return `${resolvedTarget}/`;
|
||||
return `${posixTarget}/`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user