|
| 1 | +import { getAttemptCompletionDescription } from "../attempt-completion" |
| 2 | +import { EXPERIMENT_IDS } from "../../../../shared/experiments" |
| 3 | + |
| 4 | +describe("getAttemptCompletionDescription - DISABLE_COMPLETION_COMMAND experiment", () => { |
| 5 | + describe("when experiment is disabled (default)", () => { |
| 6 | + it("should include command parameter in the description", () => { |
| 7 | + const args = { |
| 8 | + cwd: "/test/path", |
| 9 | + supportsComputerUse: false, |
| 10 | + experiments: { |
| 11 | + [EXPERIMENT_IDS.DISABLE_COMPLETION_COMMAND]: false, |
| 12 | + }, |
| 13 | + } |
| 14 | + |
| 15 | + const description = getAttemptCompletionDescription(args) |
| 16 | + |
| 17 | + // Check that command parameter is included |
| 18 | + expect(description).toContain("- command: (optional)") |
| 19 | + expect(description).toContain("A CLI command to execute to show a live demo") |
| 20 | + expect(description).toContain("<command>Command to demonstrate result (optional)</command>") |
| 21 | + expect(description).toContain("<command>open index.html</command>") |
| 22 | + }) |
| 23 | + |
| 24 | + it("should include command parameter when experiments is undefined", () => { |
| 25 | + const args = { |
| 26 | + cwd: "/test/path", |
| 27 | + supportsComputerUse: false, |
| 28 | + } |
| 29 | + |
| 30 | + const description = getAttemptCompletionDescription(args) |
| 31 | + |
| 32 | + // Check that command parameter is included |
| 33 | + expect(description).toContain("- command: (optional)") |
| 34 | + expect(description).toContain("A CLI command to execute to show a live demo") |
| 35 | + expect(description).toContain("<command>Command to demonstrate result (optional)</command>") |
| 36 | + expect(description).toContain("<command>open index.html</command>") |
| 37 | + }) |
| 38 | + |
| 39 | + it("should include command parameter when no args provided", () => { |
| 40 | + const description = getAttemptCompletionDescription() |
| 41 | + |
| 42 | + // Check that command parameter is included |
| 43 | + expect(description).toContain("- command: (optional)") |
| 44 | + expect(description).toContain("A CLI command to execute to show a live demo") |
| 45 | + expect(description).toContain("<command>Command to demonstrate result (optional)</command>") |
| 46 | + expect(description).toContain("<command>open index.html</command>") |
| 47 | + }) |
| 48 | + }) |
| 49 | + |
| 50 | + describe("when experiment is enabled", () => { |
| 51 | + it("should NOT include command parameter in the description", () => { |
| 52 | + const args = { |
| 53 | + cwd: "/test/path", |
| 54 | + supportsComputerUse: false, |
| 55 | + experiments: { |
| 56 | + [EXPERIMENT_IDS.DISABLE_COMPLETION_COMMAND]: true, |
| 57 | + }, |
| 58 | + } |
| 59 | + |
| 60 | + const description = getAttemptCompletionDescription(args) |
| 61 | + |
| 62 | + // Check that command parameter is NOT included |
| 63 | + expect(description).not.toContain("- command: (optional)") |
| 64 | + expect(description).not.toContain("A CLI command to execute to show a live demo") |
| 65 | + expect(description).not.toContain("<command>Command to demonstrate result (optional)</command>") |
| 66 | + expect(description).not.toContain("<command>open index.html</command>") |
| 67 | + |
| 68 | + // But should still have the basic structure |
| 69 | + expect(description).toContain("## attempt_completion") |
| 70 | + expect(description).toContain("- result: (required)") |
| 71 | + expect(description).toContain("<attempt_completion>") |
| 72 | + expect(description).toContain("</attempt_completion>") |
| 73 | + }) |
| 74 | + |
| 75 | + it("should show example without command", () => { |
| 76 | + const args = { |
| 77 | + cwd: "/test/path", |
| 78 | + supportsComputerUse: false, |
| 79 | + experiments: { |
| 80 | + [EXPERIMENT_IDS.DISABLE_COMPLETION_COMMAND]: true, |
| 81 | + }, |
| 82 | + } |
| 83 | + |
| 84 | + const description = getAttemptCompletionDescription(args) |
| 85 | + |
| 86 | + // Check example format |
| 87 | + expect(description).toContain("Example: Requesting to attempt completion with a result") |
| 88 | + expect(description).toContain("I've updated the CSS") |
| 89 | + expect(description).not.toContain("Example: Requesting to attempt completion with a result and command") |
| 90 | + }) |
| 91 | + }) |
| 92 | + |
| 93 | + describe("description content", () => { |
| 94 | + it("should maintain core functionality description regardless of experiment", () => { |
| 95 | + const argsWithExperimentDisabled = { |
| 96 | + cwd: "/test/path", |
| 97 | + supportsComputerUse: false, |
| 98 | + experiments: { |
| 99 | + [EXPERIMENT_IDS.DISABLE_COMPLETION_COMMAND]: false, |
| 100 | + }, |
| 101 | + } |
| 102 | + |
| 103 | + const argsWithExperimentEnabled = { |
| 104 | + cwd: "/test/path", |
| 105 | + supportsComputerUse: false, |
| 106 | + experiments: { |
| 107 | + [EXPERIMENT_IDS.DISABLE_COMPLETION_COMMAND]: true, |
| 108 | + }, |
| 109 | + } |
| 110 | + |
| 111 | + const descriptionDisabled = getAttemptCompletionDescription(argsWithExperimentDisabled) |
| 112 | + const descriptionEnabled = getAttemptCompletionDescription(argsWithExperimentEnabled) |
| 113 | + |
| 114 | + // Both should contain core functionality |
| 115 | + const coreText = "After each tool use, the user will respond with the result of that tool use" |
| 116 | + expect(descriptionDisabled).toContain(coreText) |
| 117 | + expect(descriptionEnabled).toContain(coreText) |
| 118 | + |
| 119 | + // Both should contain the important note |
| 120 | + const importantNote = "IMPORTANT NOTE: This tool CANNOT be used until you've confirmed" |
| 121 | + expect(descriptionDisabled).toContain(importantNote) |
| 122 | + expect(descriptionEnabled).toContain(importantNote) |
| 123 | + |
| 124 | + // Both should contain result parameter |
| 125 | + expect(descriptionDisabled).toContain("- result: (required)") |
| 126 | + expect(descriptionEnabled).toContain("- result: (required)") |
| 127 | + }) |
| 128 | + }) |
| 129 | +}) |
0 commit comments