fix: 保留ktWorkflow清理模板目录

This commit is contained in:
sunlei 2026-07-03 18:22:52 +08:00
parent 1e39a431b7
commit a2f98b7c00
2 changed files with 7 additions and 4 deletions

View File

@ -2082,8 +2082,8 @@ export async function runSelfTest(): Promise<void> {
const workspaceHistoryRoot = cleanupRoots.find( const workspaceHistoryRoot = cleanupRoots.find(
(item) => item.root === ".kt-workspace", (item) => item.root === ".kt-workspace",
); );
if (testArtifactsRoot?.preservedNames.includes("_templates")) { if (!testArtifactsRoot?.preservedNames.includes("_templates")) {
throw new Error("cleanup template migration self-check failed"); throw new Error("cleanup template preservation self-check failed");
} }
if (!workspaceHistoryRoot?.preservedNames.includes("test-artifacts")) { if (!workspaceHistoryRoot?.preservedNames.includes("test-artifacts")) {
throw new Error("cleanup workspace root preservation self-check failed"); throw new Error("cleanup workspace root preservation self-check failed");

View File

@ -52,8 +52,8 @@ const workspaceRootPreservedNames = new Set([
/** /**
* Builds the directory names that represent generated artifact categories under * Builds the directory names that represent generated artifact categories under
* `.kt-workspace`; reusable templates and references are intentionally not * `.kt-workspace`; test artifact templates stay in place because KT page and
* preserved here because they belong in `workspace-assets`. * business test flows use them as local scaffolding inputs.
* *
* @param rootRelativePath - Cleanup root relative to the KT workspace. * @param rootRelativePath - Cleanup root relative to the KT workspace.
* @returns Category names that cleanup should skip when pruning `.kt-workspace`. * @returns Category names that cleanup should skip when pruning `.kt-workspace`.
@ -66,6 +66,9 @@ function buildPreservedNames(rootRelativePath: string): Set<string> {
preservedNames.add(name); preservedNames.add(name);
} }
} }
if (rootRelativePath === '.kt-workspace/test-artifacts') {
preservedNames.add('_templates');
}
return preservedNames; return preservedNames;
} }