From 79bd75b3dbf5f62d8b20ff8d85a9919cc6f9a7ac Mon Sep 17 00:00:00 2001 From: Kenny Date: Mon, 12 Jan 2026 22:46:28 -0500 Subject: [PATCH] refactor(skill-loader): eager loading with atomic file reads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Extract body during initial parseFrontmatter call - Rename lazyContent → eagerLoader with rationale comment - Eliminates redundant file read and race condition --- src/features/opencode-skill-loader/loader.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/features/opencode-skill-loader/loader.ts b/src/features/opencode-skill-loader/loader.ts index 5d6561da..4bff1ca1 100644 --- a/src/features/opencode-skill-loader/loader.ts +++ b/src/features/opencode-skill-loader/loader.ts @@ -84,7 +84,10 @@ ${body.trim()} $ARGUMENTS ` - const lazyContent: LazyContentLoader = { + // RATIONALE: We read the file eagerly to ensure atomic consistency between + // metadata and body. We maintain the LazyContentLoader interface for + // compatibility, but the state is effectively eager. + const eagerLoader: LazyContentLoader = { loaded: true, content: templateContent, load: async () => templateContent, @@ -111,7 +114,7 @@ $ARGUMENTS metadata: data.metadata, allowedTools: parseAllowedTools(data["allowed-tools"]), mcpConfig, - lazyContent, + lazyContent: eagerLoader, } } catch { return null