Repository navigation
fix(subagents): read frontmatter from files saved with a UTF-8 BOM - #2516
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary / 概要
A subagent definition or prompt template saved as "UTF-8 with BOM" loses its frontmatter. Windows editors can save files this way: older Notepad does by default, and VS Code or Notepad++ do when set to it.
Both loaders read the file with
readFile(path, "utf8"), which keeps a leading\uFEFF. The frontmatter checks then fail on the first character:parseSubagentDefinition(packages/shared/src/subagent-definition.ts,splitFrontmatter):startsWith("---\n")is false, so the whole file is treated as the body and the parse fails withmissing `description`. The subagent never reaches theTaskcatalog, and the diagnostic points at a field that is in the file.packages/agent-runtime/src/prompt-templates.ts,parsePrompt): the template loads with no description, and the---frontmatter block shows up in the template body.Fix: strip one leading
\uFEFFbefore looking for frontmatter. This is the same thingsplitModeDocumentinpackages/agent-runtime/src/mode-definitions.tsalready does for mode documents. Files without a BOM are handled exactly as before.Requirement link / 需求关联
fix. I didn't open an issue for it; happy to open one if you prefer.Validation
On a worktree from latest
origin/main(pnpm check:pr-basepasses):packages/shared/src/subagent-definition.test.ts: parses a BOM-prefixed definition.packages/agent-runtime/src/prompt-templates.test.ts: loads a BOM-prefixed template file throughloadComposerTemplates.mainand pass with the fix.packages/shared:vitest rungives 116 files and 1478 tests passed.tsc --noEmitis clean.packages/agent-runtime:vitest rungives 2122 of 2123 passed, andtsc --noEmitis clean. The one failure,system-ca.test.ts > applyAdditiveDefaultCaCertificates keeps pre-existing default roots, depends on this machine's system CA store and also fails onmainhere.pnpm lint: clean.pnpm test:e2e:subagents: 34/34 checks passed.pnpm test:e2e:composer-autocomplete: passes.