-
Notifications
You must be signed in to change notification settings - Fork 20
test: command hints + skill formatting coverage #430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { describe, test, expect } from "bun:test" | ||
| import { Command } from "../../src/command/index" | ||
|
|
||
| describe("Command.hints: template placeholder extraction", () => { | ||
| test("returns empty array for template with no placeholders", () => { | ||
| expect(Command.hints("Run the tests and report results")).toEqual([]) | ||
| expect(Command.hints("")).toEqual([]) | ||
| }) | ||
|
|
||
| test("extracts numbered placeholders in sorted order", () => { | ||
| expect(Command.hints("Review $2 and compare with $1")).toEqual(["$1", "$2"]) | ||
| }) | ||
|
|
||
| test("deduplicates repeated placeholder occurrences", () => { | ||
| expect(Command.hints("Use $1 then use $1 again and $2")).toEqual(["$1", "$2"]) | ||
| }) | ||
|
|
||
| test("appends $ARGUMENTS when present", () => { | ||
| expect(Command.hints("Do something with $ARGUMENTS")).toEqual(["$ARGUMENTS"]) | ||
| }) | ||
|
|
||
| test("multi-digit placeholders sort lexicographically", () => { | ||
| // $10 sorts before $2 in lexicographic order — this is the actual behavior | ||
| // since the code uses [...new Set(numbered)].sort() which is string sort | ||
| const result = Command.hints("Map $1 to $2 and also $10") | ||
| expect(result).toEqual(["$1", "$10", "$2"]) | ||
| }) | ||
| }) | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { describe, test, expect } from "bun:test" | ||
| import { Skill } from "../../src/skill/skill" | ||
|
|
||
| function skill(overrides: Partial<Skill.Info> = {}): Skill.Info { | ||
| return { | ||
| name: overrides.name ?? "test-skill", | ||
| description: overrides.description ?? "A test skill", | ||
| location: overrides.location ?? "/home/user/skills/test-skill/SKILL.md", | ||
| content: overrides.content ?? "# Test\nDo the thing.", | ||
| } | ||
| } | ||
|
|
||
| describe("Skill.fmt: skill list formatting", () => { | ||
| test("returns 'No skills' message for empty list", () => { | ||
| expect(Skill.fmt([], { verbose: false })).toBe("No skills are currently available.") | ||
| expect(Skill.fmt([], { verbose: true })).toBe("No skills are currently available.") | ||
| }) | ||
|
|
||
| test("verbose mode returns XML with skill tags", () => { | ||
| const skills = [ | ||
| skill({ name: "analyze", description: "Analyze code", location: "/path/to/analyze/SKILL.md" }), | ||
| skill({ name: "deploy", description: "Deploy app", location: "/path/to/deploy/SKILL.md" }), | ||
| ] | ||
| const output = Skill.fmt(skills, { verbose: true }) | ||
| expect(output).toContain("<available_skills>") | ||
| expect(output).toContain("</available_skills>") | ||
| expect(output).toContain("<name>analyze</name>") | ||
| expect(output).toContain("<description>Analyze code</description>") | ||
| expect(output).toContain("<name>deploy</name>") | ||
| expect(output).toContain("<description>Deploy app</description>") | ||
| // File paths get converted to file:// URLs | ||
| expect(output).toContain("file:///path/to/analyze/SKILL.md") | ||
| }) | ||
|
|
||
| test("non-verbose returns markdown with bullet points", () => { | ||
| const skills = [ | ||
| skill({ name: "lint", description: "Lint the code" }), | ||
| skill({ name: "format", description: "Format files" }), | ||
| ] | ||
| const output = Skill.fmt(skills, { verbose: false }) | ||
| expect(output).toContain("## Available Skills") | ||
| expect(output).toContain("- **lint**: Lint the code") | ||
| expect(output).toContain("- **format**: Format files") | ||
| }) | ||
|
|
||
| test("verbose mode preserves builtin: protocol without file:// conversion", () => { | ||
| const skills = [ | ||
| skill({ name: "builtin-skill", description: "Built in", location: "builtin:my-skill/SKILL.md" }), | ||
| ] | ||
| const output = Skill.fmt(skills, { verbose: true }) | ||
| expect(output).toContain("<location>builtin:my-skill/SKILL.md</location>") | ||
| // Should NOT contain file:// for builtin: paths | ||
| expect(output).not.toContain("file://") | ||
| }) | ||
| }) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a mixed-case assertion for numbered placeholders +
$ARGUMENTS.Line 18 currently verifies
$ARGUMENTSalone, but it does not assert combined behavior in the same template (e.g.,$1,$2, and$ARGUMENTStogether), which is the higher-value ordering/append contract.Suggested test addition
test("appends $ARGUMENTS when present", () => { expect(Command.hints("Do something with $ARGUMENTS")).toEqual(["$ARGUMENTS"]) + expect(Command.hints("Use $2 with $ARGUMENTS and $1")).toEqual(["$1", "$2", "$ARGUMENTS"]) })📝 Committable suggestion
🤖 Prompt for AI Agents