fix: sanitize colons in skill/agent names for Windows path compatibility (#398)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import path from "path"
|
||||
import { backupFile, copySkillDir, ensureDir, pathExists, readJson, writeJson, writeText } from "../utils/files"
|
||||
import { backupFile, copySkillDir, ensureDir, pathExists, readJson, sanitizePathName, writeJson, writeText } from "../utils/files"
|
||||
import { transformContentForKiro } from "../converters/claude-to-kiro"
|
||||
import type { KiroBundle } from "../types/kiro"
|
||||
|
||||
@@ -15,13 +15,13 @@ export async function writeKiroBundle(outputRoot: string, bundle: KiroBundle): P
|
||||
|
||||
// Write agent JSON config
|
||||
await writeJson(
|
||||
path.join(paths.agentsDir, `${agent.name}.json`),
|
||||
path.join(paths.agentsDir, `${sanitizePathName(agent.name)}.json`),
|
||||
agent.config,
|
||||
)
|
||||
|
||||
// Write agent prompt file
|
||||
await writeText(
|
||||
path.join(paths.agentsDir, "prompts", `${agent.name}.md`),
|
||||
path.join(paths.agentsDir, "prompts", `${sanitizePathName(agent.name)}.md`),
|
||||
agent.promptContent + "\n",
|
||||
)
|
||||
}
|
||||
@@ -32,7 +32,7 @@ export async function writeKiroBundle(outputRoot: string, bundle: KiroBundle): P
|
||||
for (const skill of bundle.generatedSkills) {
|
||||
validatePathSafe(skill.name, "skill")
|
||||
await writeText(
|
||||
path.join(paths.skillsDir, skill.name, "SKILL.md"),
|
||||
path.join(paths.skillsDir, sanitizePathName(skill.name), "SKILL.md"),
|
||||
skill.content + "\n",
|
||||
)
|
||||
}
|
||||
@@ -42,7 +42,7 @@ export async function writeKiroBundle(outputRoot: string, bundle: KiroBundle): P
|
||||
if (bundle.skillDirs.length > 0) {
|
||||
for (const skill of bundle.skillDirs) {
|
||||
validatePathSafe(skill.name, "skill directory")
|
||||
const destDir = path.join(paths.skillsDir, skill.name)
|
||||
const destDir = path.join(paths.skillsDir, sanitizePathName(skill.name))
|
||||
|
||||
// Validate destination doesn't escape skills directory
|
||||
const resolvedDest = path.resolve(destDir)
|
||||
@@ -63,7 +63,7 @@ export async function writeKiroBundle(outputRoot: string, bundle: KiroBundle): P
|
||||
for (const file of bundle.steeringFiles) {
|
||||
validatePathSafe(file.name, "steering file")
|
||||
await writeText(
|
||||
path.join(paths.steeringDir, `${file.name}.md`),
|
||||
path.join(paths.steeringDir, `${sanitizePathName(file.name)}.md`),
|
||||
file.content + "\n",
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user