-
Notifications
You must be signed in to change notification settings - Fork 9
feat(chat-workflow): port skill discovery + skillTool (PR 6, slim) #587
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b21d9e8
feat(chat-workflow): port skill discovery + skillTool (PR 6, slim)
sweetmantech 4db8cce
fix(skills): match open-agents 3-path scan (was scanning the wrong dir)
sweetmantech 930ffc2
refactor(skills): YAGNI project-dir scan + extract getSkills (per PR …
sweetmantech 84605bb
refactor(skills): SRP — extract findSkillFile + getGlobalSkillsDirectory
sweetmantech 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
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
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
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
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,169 @@ | ||
| import { describe, it, expect, vi, beforeEach } from "vitest"; | ||
| import { skillTool } from "@/lib/agent/tools/skillTool"; | ||
| import { connectVercel } from "@/lib/sandbox/vercel/connect/connectVercel"; | ||
|
|
||
| vi.mock("@/lib/sandbox/vercel/connect/connectVercel", () => ({ | ||
| connectVercel: vi.fn(), | ||
| })); | ||
|
|
||
| const baseCtx = { | ||
| sandbox: { state: { sandboxName: "x" }, workingDirectory: "/sandbox/mono" }, | ||
| }; | ||
|
|
||
| function makeSandbox(readFile: ReturnType<typeof vi.fn>) { | ||
| return { workingDirectory: "/sandbox/mono", readFile }; | ||
| } | ||
|
|
||
| function skillMd(body: string) { | ||
| return `---\nname: commit\ndescription: Make a commit\n---\n\n${body}`; | ||
| } | ||
|
|
||
| beforeEach(() => vi.clearAllMocks()); | ||
|
|
||
| describe("skillTool", () => { | ||
| it("returns success:false with available skills when the requested skill isn't in context", async () => { | ||
| vi.mocked(connectVercel).mockResolvedValue(makeSandbox(vi.fn()) as never); | ||
| const result = (await skillTool.execute!({ skill: "unknown" }, { | ||
| experimental_context: { | ||
| ...baseCtx, | ||
| skills: [ | ||
| { | ||
| name: "commit", | ||
| description: "Make a commit", | ||
| path: "/sandbox/mono/skills/commit", | ||
| filename: "SKILL.md", | ||
| options: {}, | ||
| }, | ||
| { | ||
| name: "deploy", | ||
| description: "Deploy", | ||
| path: "/sandbox/mono/skills/deploy", | ||
| filename: "SKILL.md", | ||
| options: {}, | ||
| }, | ||
| ], | ||
| }, | ||
| } as never)) as { success: boolean; error: string }; | ||
| expect(result.success).toBe(false); | ||
| expect(result.error).toMatch(/Available skills: commit, deploy/); | ||
| }); | ||
|
|
||
| it("returns success:false when no skills are loaded", async () => { | ||
| vi.mocked(connectVercel).mockResolvedValue(makeSandbox(vi.fn()) as never); | ||
| const result = (await skillTool.execute!({ skill: "commit" }, { | ||
| experimental_context: { ...baseCtx, skills: [] }, | ||
| } as never)) as { success: boolean; error: string }; | ||
| expect(result.success).toBe(false); | ||
| expect(result.error).toMatch(/Available skills: none/); | ||
| }); | ||
|
|
||
| it("matches the skill name case-insensitively (slash-command behavior)", async () => { | ||
| const sb = makeSandbox(vi.fn().mockResolvedValue(skillMd("body content"))); | ||
| vi.mocked(connectVercel).mockResolvedValue(sb as never); | ||
| const result = (await skillTool.execute!( | ||
| { skill: "COMMIT" }, // model typed it loud | ||
| { | ||
| experimental_context: { | ||
| ...baseCtx, | ||
| skills: [ | ||
| { | ||
| name: "commit", | ||
| description: "x", | ||
| path: "/sandbox/mono/skills/commit", | ||
| filename: "SKILL.md", | ||
| options: {}, | ||
| }, | ||
| ], | ||
| }, | ||
| } as never, | ||
| )) as { success: boolean; skillName: string }; | ||
| expect(result.success).toBe(true); | ||
| expect(result.skillName).toBe("COMMIT"); | ||
| }); | ||
|
|
||
| it("returns the SKILL.md body with skill directory injected", async () => { | ||
| const sb = makeSandbox(vi.fn().mockResolvedValue(skillMd("Run git commit -m ..."))); | ||
| vi.mocked(connectVercel).mockResolvedValue(sb as never); | ||
| const result = (await skillTool.execute!({ skill: "commit" }, { | ||
| experimental_context: { | ||
| ...baseCtx, | ||
| skills: [ | ||
| { | ||
| name: "commit", | ||
| description: "x", | ||
| path: "/sandbox/mono/skills/commit", | ||
| filename: "SKILL.md", | ||
| options: {}, | ||
| }, | ||
| ], | ||
| }, | ||
| } as never)) as { success: boolean; content: string; skillPath: string }; | ||
| expect(result.success).toBe(true); | ||
| expect(result.skillPath).toBe("/sandbox/mono/skills/commit"); | ||
| expect(result.content).toContain("Skill directory: /sandbox/mono/skills/commit"); | ||
| expect(result.content).toContain("Run git commit -m ..."); | ||
| expect(sb.readFile).toHaveBeenCalledWith("/sandbox/mono/skills/commit/SKILL.md", "utf-8"); | ||
| }); | ||
|
|
||
| it("substitutes $ARGUMENTS in the skill body when args are provided", async () => { | ||
| const sb = makeSandbox(vi.fn().mockResolvedValue(skillMd('git commit -m "$ARGUMENTS"'))); | ||
| vi.mocked(connectVercel).mockResolvedValue(sb as never); | ||
| const result = (await skillTool.execute!({ skill: "commit", args: "fix bug" }, { | ||
| experimental_context: { | ||
| ...baseCtx, | ||
| skills: [ | ||
| { | ||
| name: "commit", | ||
| description: "x", | ||
| path: "/sandbox/mono/skills/commit", | ||
| filename: "SKILL.md", | ||
| options: {}, | ||
| }, | ||
| ], | ||
| }, | ||
| } as never)) as { content: string }; | ||
| expect(result.content).toContain('git commit -m "fix bug"'); | ||
| expect(result.content).not.toContain("$ARGUMENTS"); | ||
| }); | ||
|
|
||
| it("rejects skills with disable-model-invocation set", async () => { | ||
| vi.mocked(connectVercel).mockResolvedValue(makeSandbox(vi.fn()) as never); | ||
| const result = (await skillTool.execute!({ skill: "internal" }, { | ||
| experimental_context: { | ||
| ...baseCtx, | ||
| skills: [ | ||
| { | ||
| name: "internal", | ||
| description: "x", | ||
| path: "/sandbox/mono/skills/internal", | ||
| filename: "SKILL.md", | ||
| options: { disableModelInvocation: true }, | ||
| }, | ||
| ], | ||
| }, | ||
| } as never)) as { success: boolean; error: string }; | ||
| expect(result.success).toBe(false); | ||
| expect(result.error).toMatch(/cannot be invoked/); | ||
| }); | ||
|
|
||
| it("returns success:false when the SKILL.md read fails", async () => { | ||
| const sb = makeSandbox(vi.fn().mockRejectedValue(new Error("ENOENT"))); | ||
| vi.mocked(connectVercel).mockResolvedValue(sb as never); | ||
| const result = (await skillTool.execute!({ skill: "commit" }, { | ||
| experimental_context: { | ||
| ...baseCtx, | ||
| skills: [ | ||
| { | ||
| name: "commit", | ||
| description: "x", | ||
| path: "/sandbox/mono/skills/commit", | ||
| filename: "SKILL.md", | ||
| options: {}, | ||
| }, | ||
| ], | ||
| }, | ||
| } as never)) as { success: boolean; error: string }; | ||
| expect(result.success).toBe(false); | ||
| expect(result.error).toMatch(/ENOENT/); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
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.
P3: Custom agent: Enforce Clear Code Style and Maintainability Practices
File exceeds the 100-line limit required by the style/maintainability rule.
Prompt for AI agents