@@ -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 ( / - - a l l o w e d T o o l s ' ( [ ^ ' ] + ) ' / ) ;
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 ( / - - a l l o w e d T o o l s ' ( [ ^ ' ] + ) ' / ) ;
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 ( / - - a l l o w e d T o o l s ' R e a d ' / g) ;
122- expect ( readMatches ) . toHaveLength ( 1 ) ;
123- const grepMatches = args . match ( / - - a l l o w e d T o o l s ' G r e p ' / g) ;
124- expect ( grepMatches ) . toHaveLength ( 1 ) ;
124+ // should be a single --allowedTools flag
125+ const flagMatches = args . match ( / - - a l l o w e d T o o l s / g) ;
126+ expect ( flagMatches ) . toHaveLength ( 1 ) ;
127+ const match = args . match ( / - - a l l o w e d T o o l s ' ( [ ^ ' ] + ) ' / ) ;
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