2026-01-09 02:24:43 +09:00
|
|
|
import { describe, it, expect } from "bun:test"
|
2026-01-16 01:57:57 +09:00
|
|
|
import { resolveSkillContent, resolveMultipleSkills, resolveSkillContentAsync, resolveMultipleSkillsAsync } from "./skill-content"
|
2026-01-09 02:24:43 +09:00
|
|
|
|
|
|
|
|
describe("resolveSkillContent", () => {
|
|
|
|
|
it("should return template for existing skill", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: builtin skills with 'frontend-ui-ux' skill
|
|
|
|
|
// when: resolving content for 'frontend-ui-ux'
|
2026-01-09 02:24:43 +09:00
|
|
|
const result = resolveSkillContent("frontend-ui-ux")
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: returns template string
|
2026-01-09 02:24:43 +09:00
|
|
|
expect(result).not.toBeNull()
|
|
|
|
|
expect(typeof result).toBe("string")
|
|
|
|
|
expect(result).toContain("Role: Designer-Turned-Developer")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("should return template for 'playwright' skill", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: builtin skills with 'playwright' skill
|
|
|
|
|
// when: resolving content for 'playwright'
|
2026-01-09 02:24:43 +09:00
|
|
|
const result = resolveSkillContent("playwright")
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: returns template string
|
2026-01-09 02:24:43 +09:00
|
|
|
expect(result).not.toBeNull()
|
|
|
|
|
expect(typeof result).toBe("string")
|
|
|
|
|
expect(result).toContain("Playwright Browser Automation")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("should return null for non-existent skill", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: builtin skills without 'nonexistent' skill
|
|
|
|
|
// when: resolving content for 'nonexistent'
|
2026-01-09 02:24:43 +09:00
|
|
|
const result = resolveSkillContent("nonexistent")
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: returns null
|
2026-01-09 02:24:43 +09:00
|
|
|
expect(result).toBeNull()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("should return null for empty string", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: builtin skills
|
|
|
|
|
// when: resolving content for empty string
|
2026-01-09 02:24:43 +09:00
|
|
|
const result = resolveSkillContent("")
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: returns null
|
2026-01-09 02:24:43 +09:00
|
|
|
expect(result).toBeNull()
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe("resolveMultipleSkills", () => {
|
|
|
|
|
it("should resolve all existing skills", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: list of existing skill names
|
2026-01-09 02:24:43 +09:00
|
|
|
const skillNames = ["frontend-ui-ux", "playwright"]
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when: resolving multiple skills
|
2026-01-09 02:24:43 +09:00
|
|
|
const result = resolveMultipleSkills(skillNames)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: all skills resolved, none not found
|
2026-01-09 02:24:43 +09:00
|
|
|
expect(result.resolved.size).toBe(2)
|
|
|
|
|
expect(result.notFound).toEqual([])
|
|
|
|
|
expect(result.resolved.get("frontend-ui-ux")).toContain("Designer-Turned-Developer")
|
|
|
|
|
expect(result.resolved.get("playwright")).toContain("Playwright Browser Automation")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("should handle partial success - some skills not found", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: list with existing and non-existing skills
|
2026-01-09 02:24:43 +09:00
|
|
|
const skillNames = ["frontend-ui-ux", "nonexistent", "playwright", "another-missing"]
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when: resolving multiple skills
|
2026-01-09 02:24:43 +09:00
|
|
|
const result = resolveMultipleSkills(skillNames)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: resolves existing skills, lists not found skills
|
2026-01-09 02:24:43 +09:00
|
|
|
expect(result.resolved.size).toBe(2)
|
|
|
|
|
expect(result.notFound).toEqual(["nonexistent", "another-missing"])
|
|
|
|
|
expect(result.resolved.get("frontend-ui-ux")).toContain("Designer-Turned-Developer")
|
|
|
|
|
expect(result.resolved.get("playwright")).toContain("Playwright Browser Automation")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("should handle empty array", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: empty skill names list
|
2026-01-09 02:24:43 +09:00
|
|
|
const skillNames: string[] = []
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when: resolving multiple skills
|
2026-01-09 02:24:43 +09:00
|
|
|
const result = resolveMultipleSkills(skillNames)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: returns empty resolved and notFound
|
2026-01-09 02:24:43 +09:00
|
|
|
expect(result.resolved.size).toBe(0)
|
|
|
|
|
expect(result.notFound).toEqual([])
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("should handle all skills not found", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: list of non-existing skills
|
2026-01-09 02:24:43 +09:00
|
|
|
const skillNames = ["skill-one", "skill-two", "skill-three"]
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when: resolving multiple skills
|
2026-01-09 02:24:43 +09:00
|
|
|
const result = resolveMultipleSkills(skillNames)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: no skills resolved, all in notFound
|
2026-01-09 02:24:43 +09:00
|
|
|
expect(result.resolved.size).toBe(0)
|
|
|
|
|
expect(result.notFound).toEqual(["skill-one", "skill-two", "skill-three"])
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("should preserve skill order in resolved map", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: list of skill names in specific order
|
2026-01-09 02:24:43 +09:00
|
|
|
const skillNames = ["playwright", "frontend-ui-ux"]
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when: resolving multiple skills
|
2026-01-09 02:24:43 +09:00
|
|
|
const result = resolveMultipleSkills(skillNames)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: map contains skills with expected keys
|
2026-01-09 02:24:43 +09:00
|
|
|
expect(result.resolved.has("playwright")).toBe(true)
|
|
|
|
|
expect(result.resolved.has("frontend-ui-ux")).toBe(true)
|
|
|
|
|
expect(result.resolved.size).toBe(2)
|
|
|
|
|
})
|
|
|
|
|
})
|
2026-01-16 01:57:57 +09:00
|
|
|
|
|
|
|
|
describe("resolveSkillContentAsync", () => {
|
|
|
|
|
it("should return template for builtin skill", async () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: builtin skill 'frontend-ui-ux'
|
|
|
|
|
// when: resolving content async
|
2026-01-16 01:57:57 +09:00
|
|
|
const result = await resolveSkillContentAsync("frontend-ui-ux")
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: returns template string
|
2026-01-16 01:57:57 +09:00
|
|
|
expect(result).not.toBeNull()
|
|
|
|
|
expect(typeof result).toBe("string")
|
|
|
|
|
expect(result).toContain("Role: Designer-Turned-Developer")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("should return null for non-existent skill", async () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: non-existent skill name
|
|
|
|
|
// when: resolving content async
|
2026-01-16 01:57:57 +09:00
|
|
|
const result = await resolveSkillContentAsync("definitely-not-a-skill-12345")
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: returns null
|
2026-01-16 01:57:57 +09:00
|
|
|
expect(result).toBeNull()
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe("resolveMultipleSkillsAsync", () => {
|
|
|
|
|
it("should resolve builtin skills", async () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: builtin skill names
|
2026-01-16 01:57:57 +09:00
|
|
|
const skillNames = ["playwright", "frontend-ui-ux"]
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when: resolving multiple skills async
|
2026-01-16 01:57:57 +09:00
|
|
|
const result = await resolveMultipleSkillsAsync(skillNames)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: all builtin skills resolved
|
2026-01-16 01:57:57 +09:00
|
|
|
expect(result.resolved.size).toBe(2)
|
|
|
|
|
expect(result.notFound).toEqual([])
|
|
|
|
|
expect(result.resolved.get("playwright")).toContain("Playwright Browser Automation")
|
|
|
|
|
expect(result.resolved.get("frontend-ui-ux")).toContain("Designer-Turned-Developer")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("should handle partial success with non-existent skills", async () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: mix of existing and non-existing skills
|
2026-01-16 01:57:57 +09:00
|
|
|
const skillNames = ["playwright", "nonexistent-skill-12345"]
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when: resolving multiple skills async
|
2026-01-16 01:57:57 +09:00
|
|
|
const result = await resolveMultipleSkillsAsync(skillNames)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: existing skills resolved, non-existing in notFound
|
2026-01-16 01:57:57 +09:00
|
|
|
expect(result.resolved.size).toBe(1)
|
|
|
|
|
expect(result.notFound).toEqual(["nonexistent-skill-12345"])
|
|
|
|
|
expect(result.resolved.get("playwright")).toContain("Playwright Browser Automation")
|
|
|
|
|
})
|
|
|
|
|
|
2026-01-16 08:01:04 +07:00
|
|
|
it("should NOT inject watermark when both options are disabled", async () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: git-master skill with watermark disabled
|
2026-01-16 01:57:57 +09:00
|
|
|
const skillNames = ["git-master"]
|
|
|
|
|
const options = {
|
|
|
|
|
gitMasterConfig: {
|
|
|
|
|
commit_footer: false,
|
|
|
|
|
include_co_authored_by: false,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when: resolving with git-master config
|
2026-01-16 01:57:57 +09:00
|
|
|
const result = await resolveMultipleSkillsAsync(skillNames, options)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: no watermark section injected
|
2026-01-16 01:57:57 +09:00
|
|
|
expect(result.resolved.size).toBe(1)
|
|
|
|
|
expect(result.notFound).toEqual([])
|
|
|
|
|
const gitMasterContent = result.resolved.get("git-master")
|
2026-01-16 08:01:04 +07:00
|
|
|
expect(gitMasterContent).not.toContain("Ultraworked with")
|
|
|
|
|
expect(gitMasterContent).not.toContain("Co-authored-by: Sisyphus")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("should inject watermark when enabled (default)", async () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: git-master skill with default config (watermark enabled)
|
2026-01-16 08:01:04 +07:00
|
|
|
const skillNames = ["git-master"]
|
|
|
|
|
const options = {
|
|
|
|
|
gitMasterConfig: {
|
|
|
|
|
commit_footer: true,
|
|
|
|
|
include_co_authored_by: true,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when: resolving with git-master config
|
2026-01-16 08:01:04 +07:00
|
|
|
const result = await resolveMultipleSkillsAsync(skillNames, options)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: watermark section is injected
|
2026-01-16 08:01:04 +07:00
|
|
|
expect(result.resolved.size).toBe(1)
|
|
|
|
|
const gitMasterContent = result.resolved.get("git-master")
|
|
|
|
|
expect(gitMasterContent).toContain("Ultraworked with [Sisyphus]")
|
|
|
|
|
expect(gitMasterContent).toContain("Co-authored-by: Sisyphus")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("should inject only footer when co-author is disabled", async () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: git-master skill with only footer enabled
|
2026-01-16 08:01:04 +07:00
|
|
|
const skillNames = ["git-master"]
|
|
|
|
|
const options = {
|
|
|
|
|
gitMasterConfig: {
|
|
|
|
|
commit_footer: true,
|
|
|
|
|
include_co_authored_by: false,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when: resolving with git-master config
|
2026-01-16 08:01:04 +07:00
|
|
|
const result = await resolveMultipleSkillsAsync(skillNames, options)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: only footer is injected
|
2026-01-16 08:01:04 +07:00
|
|
|
const gitMasterContent = result.resolved.get("git-master")
|
|
|
|
|
expect(gitMasterContent).toContain("Ultraworked with [Sisyphus]")
|
|
|
|
|
expect(gitMasterContent).not.toContain("Co-authored-by: Sisyphus")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("should inject watermark by default when no config provided", async () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: git-master skill with NO config (default behavior)
|
2026-01-16 08:01:04 +07:00
|
|
|
const skillNames = ["git-master"]
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when: resolving without any gitMasterConfig
|
2026-01-16 08:01:04 +07:00
|
|
|
const result = await resolveMultipleSkillsAsync(skillNames)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: watermark is injected (default is ON)
|
2026-01-16 08:01:04 +07:00
|
|
|
expect(result.resolved.size).toBe(1)
|
|
|
|
|
const gitMasterContent = result.resolved.get("git-master")
|
|
|
|
|
expect(gitMasterContent).toContain("Ultraworked with [Sisyphus]")
|
|
|
|
|
expect(gitMasterContent).toContain("Co-authored-by: Sisyphus")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("should inject only co-author when footer is disabled", async () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: git-master skill with only co-author enabled
|
2026-01-16 08:01:04 +07:00
|
|
|
const skillNames = ["git-master"]
|
|
|
|
|
const options = {
|
|
|
|
|
gitMasterConfig: {
|
|
|
|
|
commit_footer: false,
|
|
|
|
|
include_co_authored_by: true,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when: resolving with git-master config
|
2026-01-16 08:01:04 +07:00
|
|
|
const result = await resolveMultipleSkillsAsync(skillNames, options)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: only co-author is injected
|
2026-01-16 08:01:04 +07:00
|
|
|
const gitMasterContent = result.resolved.get("git-master")
|
|
|
|
|
expect(gitMasterContent).not.toContain("Ultraworked with [Sisyphus]")
|
|
|
|
|
expect(gitMasterContent).toContain("Co-authored-by: Sisyphus")
|
2026-01-16 01:57:57 +09:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("should handle empty array", async () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: empty skill names
|
2026-01-16 01:57:57 +09:00
|
|
|
const skillNames: string[] = []
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when: resolving multiple skills async
|
2026-01-16 01:57:57 +09:00
|
|
|
const result = await resolveMultipleSkillsAsync(skillNames)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: empty results
|
2026-01-16 01:57:57 +09:00
|
|
|
expect(result.resolved.size).toBe(0)
|
|
|
|
|
expect(result.notFound).toEqual([])
|
|
|
|
|
})
|
|
|
|
|
})
|
2026-01-25 15:02:41 +09:00
|
|
|
|
|
|
|
|
describe("resolveSkillContent with browserProvider", () => {
|
|
|
|
|
it("should resolve agent-browser skill when browserProvider is 'agent-browser'", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: browserProvider set to agent-browser
|
2026-01-25 15:02:41 +09:00
|
|
|
const options = { browserProvider: "agent-browser" as const }
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when: resolving content for 'agent-browser'
|
2026-01-25 15:02:41 +09:00
|
|
|
const result = resolveSkillContent("agent-browser", options)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: returns agent-browser template
|
2026-01-25 15:02:41 +09:00
|
|
|
expect(result).not.toBeNull()
|
|
|
|
|
expect(result).toContain("agent-browser")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("should return null for agent-browser when browserProvider is default", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: no browserProvider (defaults to playwright)
|
2026-01-25 15:02:41 +09:00
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when: resolving content for 'agent-browser'
|
2026-01-25 15:02:41 +09:00
|
|
|
const result = resolveSkillContent("agent-browser")
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: returns null because agent-browser is not in default builtin skills
|
2026-01-25 15:02:41 +09:00
|
|
|
expect(result).toBeNull()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("should return null for playwright when browserProvider is agent-browser", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: browserProvider set to agent-browser
|
2026-01-25 15:02:41 +09:00
|
|
|
const options = { browserProvider: "agent-browser" as const }
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when: resolving content for 'playwright'
|
2026-01-25 15:02:41 +09:00
|
|
|
const result = resolveSkillContent("playwright", options)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: returns null because playwright is replaced by agent-browser
|
2026-01-25 15:02:41 +09:00
|
|
|
expect(result).toBeNull()
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe("resolveMultipleSkills with browserProvider", () => {
|
|
|
|
|
it("should resolve agent-browser when browserProvider is set", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: agent-browser and git-master requested with browserProvider
|
2026-01-25 15:02:41 +09:00
|
|
|
const skillNames = ["agent-browser", "git-master"]
|
|
|
|
|
const options = { browserProvider: "agent-browser" as const }
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when: resolving multiple skills
|
2026-01-25 15:02:41 +09:00
|
|
|
const result = resolveMultipleSkills(skillNames, options)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: both resolved
|
2026-01-25 15:02:41 +09:00
|
|
|
expect(result.resolved.has("agent-browser")).toBe(true)
|
|
|
|
|
expect(result.resolved.has("git-master")).toBe(true)
|
|
|
|
|
expect(result.notFound).toHaveLength(0)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("should not resolve agent-browser without browserProvider option", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given: agent-browser requested without browserProvider
|
2026-01-25 15:02:41 +09:00
|
|
|
const skillNames = ["agent-browser"]
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when: resolving multiple skills
|
2026-01-25 15:02:41 +09:00
|
|
|
const result = resolveMultipleSkills(skillNames)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then: agent-browser not found
|
2026-01-25 15:02:41 +09:00
|
|
|
expect(result.resolved.has("agent-browser")).toBe(false)
|
|
|
|
|
expect(result.notFound).toContain("agent-browser")
|
|
|
|
|
})
|
|
|
|
|
})
|