Skip to content

Commit eac49a0

Browse files
update default tools
Co-authored-by: Franz the Dog <franz@cutedogs.org>
1 parent 8fc8dec commit eac49a0

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

src/generator/workflow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function buildActionStep(
9494
prompt,
9595
};
9696

97-
const toolArgs = allowedTools.map((t) => `--allowedTools '${t}'`).join(" ");
97+
const toolArgs = `--allowedTools '${allowedTools.join(",")}'`;
9898
let claudeArgs = options.claude_args
9999
? `${options.claude_args} ${toolArgs}`
100100
: toolArgs;

test/generator/workflow.test.ts

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,22 @@ describe("generateWorkflow", () => {
5555
expect(actionStep.with.prompt).toBe("Review this code");
5656
expect(actionStep.with.github_token).toBe("${{ secrets.GITHUB_TOKEN }}");
5757
expect(actionStep.with.track_progress).toBe(true);
58-
// default allowed tools passed via claude_args
58+
// default allowed tools passed via a single --allowedTools flag (comma-separated)
5959
const args: string = actionStep.with.claude_args;
60+
const match = args.match(/--allowedTools '([^']+)'/);
61+
expect(match).toBeTruthy();
62+
const tools = match![1].split(",");
6063
for (const tool of [
6164
"Read", "Grep", "Glob", "Agent", "Skill",
6265
"TaskCreate", "TaskGet", "TaskList", "TaskOutput", "TaskStop", "TaskUpdate",
6366
"TodoWrite", "EnterWorktree", "ExitWorktree",
6467
"CronCreate", "CronDelete", "CronList",
6568
"ToolSearch", "LSP", "ListMcpResourcesTool", "ReadMcpResourceTool",
6669
"EnterPlanMode", "ExitPlanMode",
70+
"Bash(git diff*)", "Bash(git log*)", "Bash(git show*)", "Bash(gh pr *)",
6771
]) {
68-
expect(args).toContain(`--allowedTools '${tool}'`);
72+
expect(tools).toContain(tool);
6973
}
70-
expect(args).toContain("--allowedTools 'Bash(git diff*)'");
71-
expect(args).toContain("--allowedTools 'Bash(git log*)'");
72-
expect(args).toContain("--allowedTools 'Bash(git show*)'");
73-
expect(args).toContain("--allowedTools 'Bash(gh pr *)'");
7474
});
7575

7676
test("merges user-specified allowed_tools with defaults", () => {
@@ -91,13 +91,16 @@ describe("generateWorkflow", () => {
9191
(s: any) => s.uses === "anthropics/claude-code-action@v1"
9292
);
9393
const args: string = actionStep.with.claude_args;
94+
const match = args.match(/--allowedTools '([^']+)'/);
95+
expect(match).toBeTruthy();
96+
const tools = match![1].split(",");
9497
// defaults still present
95-
expect(args).toContain("--allowedTools 'Read'");
96-
expect(args).toContain("--allowedTools 'Agent'");
98+
expect(tools).toContain("Read");
99+
expect(tools).toContain("Agent");
97100
// user tools appended
98-
expect(args).toContain("--allowedTools 'Edit'");
99-
expect(args).toContain("--allowedTools 'Write'");
100-
expect(args).toContain("--allowedTools 'Bash(npm test*)'");
101+
expect(tools).toContain("Edit");
102+
expect(tools).toContain("Write");
103+
expect(tools).toContain("Bash(npm test*)");
101104
});
102105

103106
test("deduplicates user-specified tools that overlap with defaults", () => {
@@ -118,12 +121,17 @@ describe("generateWorkflow", () => {
118121
(s: any) => s.uses === "anthropics/claude-code-action@v1"
119122
);
120123
const args: string = actionStep.with.claude_args;
121-
const readMatches = args.match(/--allowedTools 'Read'/g);
122-
expect(readMatches).toHaveLength(1);
123-
const grepMatches = args.match(/--allowedTools 'Grep'/g);
124-
expect(grepMatches).toHaveLength(1);
124+
// should be a single --allowedTools flag
125+
const flagMatches = args.match(/--allowedTools/g);
126+
expect(flagMatches).toHaveLength(1);
127+
const match = args.match(/--allowedTools '([^']+)'/);
128+
expect(match).toBeTruthy();
129+
const tools = match![1].split(",");
130+
// duplicates removed
131+
expect(tools.filter((t: string) => t === "Read")).toHaveLength(1);
132+
expect(tools.filter((t: string) => t === "Grep")).toHaveLength(1);
125133
// non-default tool still added
126-
expect(args).toContain("--allowedTools 'Edit'");
134+
expect(tools).toContain("Edit");
127135
});
128136

129137
test("passes system prompt via --append-system-prompt", () => {

0 commit comments

Comments
 (0)