fix(git-master): inject watermark only when enabled instead of overriding defaults

The watermark (commit footer and co-author) was inconsistently applied because:
1. The skill tool didn't receive gitMasterConfig
2. The approach was 'default ON, inject DISABLED override' which LLMs sometimes ignored

This refactors to 'inject only when enabled' approach:
- Remove hardcoded watermark section from base templates
- Dynamically inject section 5.5 based on config values
- Default is still ON (both true when no config)
- When both disabled, no injection occurs (clean prompt)

Also fixes missing config propagation to skill tool and createBuiltinAgents.
This commit is contained in:
Nguyen Khac Trung Kien
2026-01-16 08:01:04 +07:00
parent 837176d947
commit e36385e671
9 changed files with 157 additions and 86 deletions

View File

@@ -160,8 +160,8 @@ describe("resolveMultipleSkillsAsync", () => {
expect(result.resolved.get("playwright")).toContain("Playwright Browser Automation")
})
it("should support git-master config injection", async () => {
// #given: git-master skill with config override
it("should NOT inject watermark when both options are disabled", async () => {
// #given: git-master skill with watermark disabled
const skillNames = ["git-master"]
const options = {
gitMasterConfig: {
@@ -173,12 +173,84 @@ describe("resolveMultipleSkillsAsync", () => {
// #when: resolving with git-master config
const result = await resolveMultipleSkillsAsync(skillNames, options)
// #then: config values injected into template
// #then: no watermark section injected
expect(result.resolved.size).toBe(1)
expect(result.notFound).toEqual([])
const gitMasterContent = result.resolved.get("git-master")
expect(gitMasterContent).toContain("commit_footer")
expect(gitMasterContent).toContain("DISABLED")
expect(gitMasterContent).not.toContain("Ultraworked with")
expect(gitMasterContent).not.toContain("Co-authored-by: Sisyphus")
})
it("should inject watermark when enabled (default)", async () => {
// #given: git-master skill with default config (watermark enabled)
const skillNames = ["git-master"]
const options = {
gitMasterConfig: {
commit_footer: true,
include_co_authored_by: true,
},
}
// #when: resolving with git-master config
const result = await resolveMultipleSkillsAsync(skillNames, options)
// #then: watermark section is injected
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 () => {
// #given: git-master skill with only footer enabled
const skillNames = ["git-master"]
const options = {
gitMasterConfig: {
commit_footer: true,
include_co_authored_by: false,
},
}
// #when: resolving with git-master config
const result = await resolveMultipleSkillsAsync(skillNames, options)
// #then: only footer is injected
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 () => {
// #given: git-master skill with NO config (default behavior)
const skillNames = ["git-master"]
// #when: resolving without any gitMasterConfig
const result = await resolveMultipleSkillsAsync(skillNames)
// #then: watermark is injected (default is ON)
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 () => {
// #given: git-master skill with only co-author enabled
const skillNames = ["git-master"]
const options = {
gitMasterConfig: {
commit_footer: false,
include_co_authored_by: true,
},
}
// #when: resolving with git-master config
const result = await resolveMultipleSkillsAsync(skillNames, options)
// #then: only co-author is injected
const gitMasterContent = result.resolved.get("git-master")
expect(gitMasterContent).not.toContain("Ultraworked with [Sisyphus]")
expect(gitMasterContent).toContain("Co-authored-by: Sisyphus")
})
it("should handle empty array", async () => {