fix(parser): handle nested command tags in skill bodies (#1340)#1411
Open
averymkeller83-hub wants to merge 1 commit into
Open
fix(parser): handle nested command tags in skill bodies (#1340)#1411averymkeller83-hub wants to merge 1 commit into
averymkeller83-hub wants to merge 1 commit into
Conversation
When a slash-command's skill body contains literal `<command-message>` or `<command-name>` examples in its markdown, the SDK wrapper ends up with nested closing tags. The old lazy `<command-message>...</command-message>` match stopped at the inner closer, leaving the outer tail behind, so the parser fell through to `kind: 'text'` and rendered the entire skill body as plain text in the chat. Two changes: 1. Make `COMMAND_MESSAGE_RE` greedy so it consumes the whole outer block (including any nested example tags) in one pass. 2. Strip `<command-message>` blocks first, before extracting the command name and args. Previously, a nested `<command-name>/compact</command-name>` example inside the wrapper would be picked up by the extractor as the command name, instead of the outer wrapper's real `<command-name>/go</command-name>`. Adds a regression test covering the /go skill scenario from the issue. Fixes slopus#1340 Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
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
<command-message>/<command-name>examples in its markdown, the SDK wrapper ends up with nested closing tags, and the parser falls through tokind: 'text'— rendering the entire skill body as plain text in the chat.parseLocalCommandMessage.ts:COMMAND_MESSAGE_REbecomes greedy so the whole outer block (including any nested example tags) is consumed in one pass.<command-message>blocks are stripped before the name/args extractors run, so a nested<command-name>/compact</command-name>example inside the wrapper can't be mistaken for the real command name./goskill scenario from the issue.Why both changes are needed
Either fix alone is insufficient:
text.match(COMMAND_NAME_RE)still finds the first<command-name>tag in the original input, which is the nested example (/compact) rather than the outer wrapper's real command (/go).</command-message>behind.The community comment on #1340 caught the lazy/greedy half but missed the extraction-order half; this PR addresses both.
Test plan
pnpm vitest run sources/components/parseLocalCommandMessage.spec.ts— 15/15 tests pass (14 existing + 1 new regression test).pnpm typecheck— clean.🧙 Built with WOZCODE