diff --git a/src/selfTest.ts b/src/selfTest.ts index 6fa1eca..85d4e88 100644 --- a/src/selfTest.ts +++ b/src/selfTest.ts @@ -2082,8 +2082,8 @@ export async function runSelfTest(): Promise { const workspaceHistoryRoot = cleanupRoots.find( (item) => item.root === ".kt-workspace", ); - if (testArtifactsRoot?.preservedNames.includes("_templates")) { - throw new Error("cleanup template migration self-check failed"); + if (!testArtifactsRoot?.preservedNames.includes("_templates")) { + throw new Error("cleanup template preservation self-check failed"); } if (!workspaceHistoryRoot?.preservedNames.includes("test-artifacts")) { throw new Error("cleanup workspace root preservation self-check failed"); diff --git a/src/tools/cleanup.ts b/src/tools/cleanup.ts index 453868a..f452803 100644 --- a/src/tools/cleanup.ts +++ b/src/tools/cleanup.ts @@ -52,8 +52,8 @@ const workspaceRootPreservedNames = new Set([ /** * Builds the directory names that represent generated artifact categories under - * `.kt-workspace`; reusable templates and references are intentionally not - * preserved here because they belong in `workspace-assets`. + * `.kt-workspace`; test artifact templates stay in place because KT page and + * business test flows use them as local scaffolding inputs. * * @param rootRelativePath - Cleanup root relative to the KT workspace. * @returns Category names that cleanup should skip when pruning `.kt-workspace`. @@ -66,6 +66,9 @@ function buildPreservedNames(rootRelativePath: string): Set { preservedNames.add(name); } } + if (rootRelativePath === '.kt-workspace/test-artifacts') { + preservedNames.add('_templates'); + } return preservedNames; }