refactor(install): prefer native plugin install across targets (#609)
Some checks failed
CI / pr-title (push) Has been cancelled
CI / test (push) Has been cancelled
Release PR / release-pr (push) Has been cancelled
Release PR / publish-cli (push) Has been cancelled

Co-authored-by: John Cavanaugh <cavanaug@users.noreply.github.com>
This commit is contained in:
Trevin Chow
2026-04-20 18:47:07 -07:00
committed by GitHub
parent 9497a00d90
commit c2d60b47be
104 changed files with 7073 additions and 7068 deletions

View File

@@ -3,9 +3,12 @@ import { backupFile, copySkillDir, ensureDir, pathExists, readJson, sanitizePath
import { transformContentForKiro } from "../converters/claude-to-kiro"
import type { KiroBundle } from "../types/kiro"
import { cleanupStaleSkillDirs, cleanupStaleAgents } from "../utils/legacy-cleanup"
import { getLegacyKiroArtifacts } from "../data/plugin-legacy-artifacts"
import { moveLegacyArtifactToBackup, sanitizeManagedPluginName } from "./managed-artifacts"
export async function writeKiroBundle(outputRoot: string, bundle: KiroBundle): Promise<void> {
const paths = resolveKiroPaths(outputRoot)
const pluginName = bundle.pluginName ? sanitizeManagedPluginName(bundle.pluginName) : undefined
await ensureDir(paths.kiroDir)
// TODO(cleanup): Remove after v3 transition (circa Q3 2026)
@@ -100,6 +103,10 @@ export async function writeKiroBundle(outputRoot: string, bundle: KiroBundle): P
const merged = { ...existingConfig, mcpServers: { ...existingServers, ...bundle.mcpServers } }
await writeJson(mcpPath, merged)
}
if (pluginName) {
await cleanupKnownLegacyKiroArtifacts(paths, bundle)
}
}
function resolveKiroPaths(outputRoot: string) {
@@ -108,6 +115,7 @@ function resolveKiroPaths(outputRoot: string) {
if (base === ".kiro") {
return {
kiroDir: outputRoot,
managedDir: path.join(outputRoot, "compound-engineering"),
agentsDir: path.join(outputRoot, "agents"),
skillsDir: path.join(outputRoot, "skills"),
steeringDir: path.join(outputRoot, "steering"),
@@ -118,6 +126,7 @@ function resolveKiroPaths(outputRoot: string) {
const kiroDir = path.join(outputRoot, ".kiro")
return {
kiroDir,
managedDir: path.join(kiroDir, "compound-engineering"),
agentsDir: path.join(kiroDir, "agents"),
skillsDir: path.join(kiroDir, "skills"),
steeringDir: path.join(kiroDir, "steering"),
@@ -125,6 +134,26 @@ function resolveKiroPaths(outputRoot: string) {
}
}
async function cleanupKnownLegacyKiroArtifacts(
paths: ReturnType<typeof resolveKiroPaths>,
bundle: KiroBundle,
): Promise<void> {
const legacyArtifacts = getLegacyKiroArtifacts(bundle)
for (const skillName of legacyArtifacts.skills) {
await moveLegacyArtifactToBackup(paths.managedDir, "skills", paths.skillsDir, skillName, "Kiro skill")
}
for (const agentName of legacyArtifacts.agents) {
await moveLegacyArtifactToBackup(paths.managedDir, "agents", paths.agentsDir, `${agentName}.json`, "Kiro agent")
await moveLegacyArtifactToBackup(
paths.managedDir,
"agents",
path.join(paths.agentsDir, "prompts"),
`${agentName}.md`,
"Kiro agent prompt",
)
}
}
function validatePathSafe(name: string, label: string): void {
if (name.includes("..") || name.includes("/") || name.includes("\\")) {
throw new Error(`${label} name contains unsafe path characters: ${name}`)