fix(core): complete toPosixPath coverage for Windows output paths

Three files emit path.join or path.relative results directly into
JSON output without normalizing backslashes on Windows. Wrap these
with toPosixPath (already used in core.cjs and init.cjs) so agents
receive consistent forward-slash paths on all platforms.

Files changed:
- phase.cjs: wrap directory path in cmdPhasesFind
- commands.cjs: wrap todo path in cmdListTodos, relPath in cmdScaffold
- template.cjs: wrap relPath in cmdTemplateFill (both exists and
  created branches)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Tibsfox
2026-03-03 01:46:52 -08:00
committed by Lex Christopherson
parent 22fe139e7b
commit 15226feb18
3 changed files with 8 additions and 8 deletions

View File

@@ -4,7 +4,7 @@
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
const { safeReadFile, loadConfig, isGitIgnored, execGit, normalizePhaseName, comparePhaseNum, getArchivedPhaseDirs, generateSlugInternal, getMilestoneInfo, resolveModelInternal, MODEL_PROFILES, output, error, findPhaseInternal } = require('./core.cjs');
const { safeReadFile, loadConfig, isGitIgnored, execGit, normalizePhaseName, comparePhaseNum, getArchivedPhaseDirs, generateSlugInternal, getMilestoneInfo, resolveModelInternal, MODEL_PROFILES, toPosixPath, output, error, findPhaseInternal } = require('./core.cjs');
const { extractFrontmatter } = require('./frontmatter.cjs');
function cmdGenerateSlug(text, raw) {
@@ -68,7 +68,7 @@ function cmdListTodos(cwd, area, raw) {
created: createdMatch ? createdMatch[1].trim() : 'unknown',
title: titleMatch ? titleMatch[1].trim() : 'Untitled',
area: todoArea,
path: path.join('.planning', 'todos', 'pending', file),
path: toPosixPath(path.join('.planning', 'todos', 'pending', file)),
});
} catch {}
}
@@ -528,7 +528,7 @@ function cmdScaffold(cwd, type, options, raw) {
}
fs.writeFileSync(filePath, content, 'utf-8');
const relPath = path.relative(cwd, filePath);
const relPath = toPosixPath(path.relative(cwd, filePath));
output({ created: true, path: relPath }, raw, relPath);
}

View File

@@ -4,7 +4,7 @@
const fs = require('fs');
const path = require('path');
const { escapeRegex, normalizePhaseName, comparePhaseNum, findPhaseInternal, getArchivedPhaseDirs, generateSlugInternal, getMilestonePhaseFilter, output, error } = require('./core.cjs');
const { escapeRegex, normalizePhaseName, comparePhaseNum, findPhaseInternal, getArchivedPhaseDirs, generateSlugInternal, getMilestonePhaseFilter, toPosixPath, output, error } = require('./core.cjs');
const { extractFrontmatter } = require('./frontmatter.cjs');
const { writeStateMd } = require('./state.cjs');
@@ -180,7 +180,7 @@ function cmdFindPhase(cwd, phase, raw) {
const result = {
found: true,
directory: path.join('.planning', 'phases', match),
directory: toPosixPath(path.join('.planning', 'phases', match)),
phase_number: phaseNumber,
phase_name: phaseName,
plans,

View File

@@ -4,7 +4,7 @@
const fs = require('fs');
const path = require('path');
const { normalizePhaseName, findPhaseInternal, generateSlugInternal, output, error } = require('./core.cjs');
const { normalizePhaseName, findPhaseInternal, generateSlugInternal, toPosixPath, output, error } = require('./core.cjs');
const { reconstructFrontmatter } = require('./frontmatter.cjs');
function cmdTemplateSelect(cwd, planPath, raw) {
@@ -210,12 +210,12 @@ function cmdTemplateFill(cwd, templateType, options, raw) {
const outPath = path.join(cwd, phaseInfo.directory, fileName);
if (fs.existsSync(outPath)) {
output({ error: 'File already exists', path: path.relative(cwd, outPath) }, raw);
output({ error: 'File already exists', path: toPosixPath(path.relative(cwd, outPath)) }, raw);
return;
}
fs.writeFileSync(outPath, fullContent, 'utf-8');
const relPath = path.relative(cwd, outPath);
const relPath = toPosixPath(path.relative(cwd, outPath));
output({ created: true, path: relPath, template: templateType }, raw, relPath);
}