refactor(skill-loader): eager loading with atomic file reads

- Extract body during initial parseFrontmatter call
- Rename lazyContent → eagerLoader with rationale comment
- Eliminates redundant file read and race condition
This commit is contained in:
Kenny
2026-01-12 22:46:28 -05:00
parent 6bbe69a72a
commit 79bd75b3db

View File

@@ -84,7 +84,10 @@ ${body.trim()}
$ARGUMENTS
</user-request>`
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