From 1f9da9ed5fcfcd9d402abeab95fad6ed001b84e2 Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Tue, 17 Mar 2026 20:39:54 -0400 Subject: [PATCH] fix: always ensure tasks/ directory exists for slice units (#900) (#1050) ensurePreconditions() had two branches: create-slice (which included tasks/) and slice-exists (which conditionally created tasks/). The conditional path could miss cases where a slice dir was created manually or by a previous run without the tasks/ subdirectory. Simplified to: create slice dir if missing, then always check and create tasks/ unconditionally. Removes the branching that could leave tasks/ missing. --- src/resources/extensions/gsd/auto.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/resources/extensions/gsd/auto.ts b/src/resources/extensions/gsd/auto.ts index 790e04c3d..5dd5bd4b7 100644 --- a/src/resources/extensions/gsd/auto.ts +++ b/src/resources/extensions/gsd/auto.ts @@ -3318,15 +3318,16 @@ function ensurePreconditions( const slicesDir = join(mDirResolved, "slices"); const sDir = resolveDir(slicesDir, sid); if (!sDir) { - // Create slice dir with bare ID - const newSliceDir = join(slicesDir, sid); - mkdirSync(join(newSliceDir, "tasks"), { recursive: true }); - } else { - // Ensure tasks/ subdir exists - const tasksDir = join(slicesDir, sDir, "tasks"); - if (!existsSync(tasksDir)) { - mkdirSync(tasksDir, { recursive: true }); - } + // Create slice dir with bare ID (tasks/ included) + mkdirSync(join(slicesDir, sid, "tasks"), { recursive: true }); + } + // Always ensure tasks/ subdir exists — even when slice dir was already + // present. Handles the case where a slice was created manually or by a + // previous run that didn't create tasks/. (#900) + const resolvedSliceDir = resolveDir(slicesDir, sid) ?? sid; + const tasksDir = join(slicesDir, resolvedSliceDir, "tasks"); + if (!existsSync(tasksDir)) { + mkdirSync(tasksDir, { recursive: true }); } } }