agent-gauntlet 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +4 -2
- package/src/cli-adapters/claude.ts +139 -108
- package/src/cli-adapters/codex.ts +141 -117
- package/src/cli-adapters/cursor.ts +152 -0
- package/src/cli-adapters/gemini.ts +171 -139
- package/src/cli-adapters/github-copilot.ts +153 -0
- package/src/cli-adapters/index.ts +77 -48
- package/src/commands/check.test.ts +24 -20
- package/src/commands/check.ts +65 -59
- package/src/commands/detect.test.ts +38 -32
- package/src/commands/detect.ts +74 -61
- package/src/commands/health.test.ts +67 -53
- package/src/commands/health.ts +167 -145
- package/src/commands/help.test.ts +37 -37
- package/src/commands/help.ts +30 -22
- package/src/commands/index.ts +9 -9
- package/src/commands/init.test.ts +118 -107
- package/src/commands/init.ts +514 -417
- package/src/commands/list.test.ts +87 -70
- package/src/commands/list.ts +28 -24
- package/src/commands/rerun.ts +142 -119
- package/src/commands/review.test.ts +26 -20
- package/src/commands/review.ts +65 -59
- package/src/commands/run.test.ts +22 -20
- package/src/commands/run.ts +64 -58
- package/src/commands/shared.ts +44 -35
- package/src/config/loader.test.ts +112 -90
- package/src/config/loader.ts +132 -123
- package/src/config/schema.ts +49 -47
- package/src/config/types.ts +15 -13
- package/src/config/validator.ts +521 -454
- package/src/core/change-detector.ts +122 -104
- package/src/core/entry-point.test.ts +60 -62
- package/src/core/entry-point.ts +76 -67
- package/src/core/job.ts +69 -59
- package/src/core/runner.ts +261 -230
- package/src/gates/check.ts +78 -69
- package/src/gates/result.ts +7 -7
- package/src/gates/review.test.ts +174 -138
- package/src/gates/review.ts +716 -561
- package/src/index.ts +16 -15
- package/src/output/console.ts +253 -214
- package/src/output/logger.ts +64 -52
- package/src/templates/run_gauntlet.template.md +18 -0
- package/src/utils/diff-parser.ts +64 -62
- package/src/utils/log-parser.ts +227 -206
- package/src/utils/sanitizer.ts +1 -1
|
@@ -1,117 +1,128 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
afterAll,
|
|
3
|
+
afterEach,
|
|
4
|
+
beforeAll,
|
|
5
|
+
beforeEach,
|
|
6
|
+
describe,
|
|
7
|
+
expect,
|
|
8
|
+
it,
|
|
9
|
+
mock,
|
|
10
|
+
} from "bun:test";
|
|
11
|
+
import fs from "node:fs/promises";
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
import { Command } from "commander";
|
|
5
14
|
|
|
6
|
-
const TEST_DIR = path.join(process.cwd(),
|
|
15
|
+
const TEST_DIR = path.join(process.cwd(), `test-init-${Date.now()}`);
|
|
7
16
|
|
|
8
17
|
// Mock adapters
|
|
9
18
|
const mockAdapters = [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
{
|
|
20
|
+
name: "mock-cli-1",
|
|
21
|
+
isAvailable: async () => true,
|
|
22
|
+
getProjectCommandDir: () => ".mock1",
|
|
23
|
+
getUserCommandDir: () => null,
|
|
24
|
+
getCommandExtension: () => ".sh",
|
|
25
|
+
canUseSymlink: () => false,
|
|
26
|
+
transformCommand: (content: string) => content,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "mock-cli-2",
|
|
30
|
+
isAvailable: async () => false, // Not available
|
|
31
|
+
getProjectCommandDir: () => ".mock2",
|
|
32
|
+
getUserCommandDir: () => null,
|
|
33
|
+
getCommandExtension: () => ".sh",
|
|
34
|
+
canUseSymlink: () => false,
|
|
35
|
+
transformCommand: (content: string) => content,
|
|
36
|
+
},
|
|
28
37
|
];
|
|
29
38
|
|
|
30
|
-
mock.module(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
mock.module("../cli-adapters/index.js", () => ({
|
|
40
|
+
getAllAdapters: () => mockAdapters,
|
|
41
|
+
getProjectCommandAdapters: () => mockAdapters,
|
|
42
|
+
getUserCommandAdapters: () => [],
|
|
34
43
|
}));
|
|
35
44
|
|
|
36
45
|
// Import after mocking
|
|
37
|
-
const { registerInitCommand } = await import(
|
|
38
|
-
|
|
39
|
-
describe(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
46
|
+
const { registerInitCommand } = await import("./init.js");
|
|
47
|
+
|
|
48
|
+
describe("Init Command", () => {
|
|
49
|
+
let program: Command;
|
|
50
|
+
const originalConsoleLog = console.log;
|
|
51
|
+
const originalCwd = process.cwd();
|
|
52
|
+
let logs: string[];
|
|
53
|
+
|
|
54
|
+
beforeAll(async () => {
|
|
55
|
+
await fs.mkdir(TEST_DIR, { recursive: true });
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
afterAll(async () => {
|
|
59
|
+
await fs.rm(TEST_DIR, { recursive: true, force: true });
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
beforeEach(() => {
|
|
63
|
+
program = new Command();
|
|
64
|
+
registerInitCommand(program);
|
|
65
|
+
logs = [];
|
|
66
|
+
console.log = (...args: unknown[]) => {
|
|
67
|
+
logs.push(args.join(" "));
|
|
68
|
+
};
|
|
69
|
+
process.chdir(TEST_DIR);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
afterEach(() => {
|
|
73
|
+
console.log = originalConsoleLog;
|
|
74
|
+
process.chdir(originalCwd);
|
|
75
|
+
// Cleanup any created .gauntlet directory
|
|
76
|
+
return fs
|
|
77
|
+
.rm(path.join(TEST_DIR, ".gauntlet"), { recursive: true, force: true })
|
|
78
|
+
.catch(() => {});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("should register the init command", () => {
|
|
82
|
+
const initCmd = program.commands.find((cmd) => cmd.name() === "init");
|
|
83
|
+
expect(initCmd).toBeDefined();
|
|
84
|
+
expect(initCmd?.description()).toBe("Initialize .gauntlet configuration");
|
|
85
|
+
expect(initCmd?.options.some((opt) => opt.long === "--yes")).toBe(true);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("should create .gauntlet directory structure with --yes flag", async () => {
|
|
89
|
+
// We expect it to use the available mock-cli-1
|
|
90
|
+
await program.parseAsync(["node", "test", "init", "--yes"]);
|
|
91
|
+
|
|
92
|
+
// Check that files were created
|
|
93
|
+
const gauntletDir = path.join(TEST_DIR, ".gauntlet");
|
|
94
|
+
const configFile = path.join(gauntletDir, "config.yml");
|
|
95
|
+
const reviewsDir = path.join(gauntletDir, "reviews");
|
|
96
|
+
const checksDir = path.join(gauntletDir, "checks");
|
|
97
|
+
const runGauntletFile = path.join(gauntletDir, "run_gauntlet.md");
|
|
98
|
+
|
|
99
|
+
expect(await fs.stat(gauntletDir)).toBeDefined();
|
|
100
|
+
expect(await fs.stat(configFile)).toBeDefined();
|
|
101
|
+
expect(await fs.stat(reviewsDir)).toBeDefined();
|
|
102
|
+
expect(await fs.stat(checksDir)).toBeDefined();
|
|
103
|
+
expect(await fs.stat(runGauntletFile)).toBeDefined();
|
|
104
|
+
|
|
105
|
+
// Verify config content
|
|
106
|
+
const configContent = await fs.readFile(configFile, "utf-8");
|
|
107
|
+
expect(configContent).toContain("base_branch");
|
|
108
|
+
expect(configContent).toContain("log_dir");
|
|
109
|
+
expect(configContent).toContain("mock-cli-1"); // Should be present
|
|
110
|
+
expect(configContent).not.toContain("mock-cli-2"); // Should not be present (unavailable)
|
|
111
|
+
|
|
112
|
+
// Verify review file content
|
|
113
|
+
const reviewFile = path.join(reviewsDir, "code-quality.md");
|
|
114
|
+
const reviewContent = await fs.readFile(reviewFile, "utf-8");
|
|
115
|
+
expect(reviewContent).toContain("mock-cli-1");
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("should not create directory if .gauntlet already exists", async () => {
|
|
119
|
+
// Create .gauntlet directory first
|
|
120
|
+
const gauntletDir = path.join(TEST_DIR, ".gauntlet");
|
|
121
|
+
await fs.mkdir(gauntletDir, { recursive: true });
|
|
122
|
+
|
|
123
|
+
await program.parseAsync(["node", "test", "init", "--yes"]);
|
|
124
|
+
|
|
125
|
+
const output = logs.join("\n");
|
|
126
|
+
expect(output).toContain(".gauntlet directory already exists");
|
|
127
|
+
});
|
|
117
128
|
});
|