@@ -1233,66 +1233,66 @@ This rule is from a remote directory.
12331233
12341234// TestSingleExpansion verifies that content is expanded only once in the full flow
12351235func TestSingleExpansion (t * testing.T ) {
1236- dirs := setupTestDirs (t )
1236+ dirs := setupTestDirs (t )
12371237
1238- // Create a task that uses a parameter with expansion syntax
1239- taskFile := filepath .Join (dirs .tasksDir , "test-expand.md" )
1240- taskContent := `Task with parameter: ${param1}
1238+ // Create a task that uses a parameter with expansion syntax
1239+ taskFile := filepath .Join (dirs .tasksDir , "test-expand.md" )
1240+ taskContent := `Task with parameter: ${param1}
12411241
12421242And a value that looks like expansion syntax but should not be expanded: ${"nested"}`
1243- if err := os .WriteFile (taskFile , []byte (taskContent ), 0644 ); err != nil {
1244- t .Fatalf ("failed to create task file: %v" , err )
1245- }
1243+ if err := os .WriteFile (taskFile , []byte (taskContent ), 0644 ); err != nil {
1244+ t .Fatalf ("failed to create task file: %v" , err )
1245+ }
12461246
1247- // Run with param1 set to a value that contains expansion syntax
1248- output := runTool (t , "-C" , dirs .tmpDir , "-p" , "param1=!`echo hello`" , "test-expand" )
1247+ // Run with param1 set to a value that contains expansion syntax
1248+ output := runTool (t , "-C" , dirs .tmpDir , "-p" , "param1=!`echo hello`" , "test-expand" )
12491249
1250- // The param1 should be replaced with the literal string "!`echo hello`"
1251- // It should NOT be expanded again (that would execute the command)
1252- if ! strings .Contains (output , "!`echo hello`" ) {
1253- t .Errorf ("Expected param1 to be replaced with literal value, got: %s" , output )
1254- }
1250+ // The param1 should be replaced with the literal string "!`echo hello`"
1251+ // It should NOT be expanded again (that would execute the command)
1252+ if ! strings .Contains (output , "!`echo hello`" ) {
1253+ t .Errorf ("Expected param1 to be replaced with literal value, got: %s" , output )
1254+ }
12551255
1256- // Verify "hello" is not in output (which would indicate the command was executed)
1257- // Note: there may be other "hello" strings, so check for the specific context
1258- if strings .Contains (output , "Task with parameter: hello" ) {
1259- t .Errorf ("Parameter value was re-expanded (command was executed), got: %s" , output )
1260- }
1256+ // Verify "hello" is not in output (which would indicate the command was executed)
1257+ // Note: there may be other "hello" strings, so check for the specific context
1258+ if strings .Contains (output , "Task with parameter: hello" ) {
1259+ t .Errorf ("Parameter value was re-expanded (command was executed), got: %s" , output )
1260+ }
12611261}
12621262
12631263// TestCommandExpansionOnce verifies that command files are expanded only once
12641264func TestCommandExpansionOnce (t * testing.T ) {
1265- dirs := setupTestDirs (t )
1266- commandsDir := filepath .Join (dirs .tmpDir , ".agents" , "commands" )
1267- if err := os .MkdirAll (commandsDir , 0o755 ); err != nil {
1268- t .Fatalf ("failed to create commands dir: %v" , err )
1269- }
1265+ dirs := setupTestDirs (t )
1266+ commandsDir := filepath .Join (dirs .tmpDir , ".agents" , "commands" )
1267+ if err := os .MkdirAll (commandsDir , 0o755 ); err != nil {
1268+ t .Fatalf ("failed to create commands dir: %v" , err )
1269+ }
12701270
1271- // Create a command file with a parameter
1272- commandFile := filepath .Join (commandsDir , "test-cmd.md" )
1273- commandContent := `Command param: ${cmd_param}`
1274- if err := os .WriteFile (commandFile , []byte (commandContent ), 0644 ); err != nil {
1275- t .Fatalf ("failed to create command file: %v" , err )
1276- }
1271+ // Create a command file with a parameter
1272+ commandFile := filepath .Join (commandsDir , "test-cmd.md" )
1273+ commandContent := `Command param: ${cmd_param}`
1274+ if err := os .WriteFile (commandFile , []byte (commandContent ), 0644 ); err != nil {
1275+ t .Fatalf ("failed to create command file: %v" , err )
1276+ }
12771277
1278- // Create a task that calls the command with a param containing expansion syntax
1279- taskFile := filepath .Join (dirs .tasksDir , "test-cmd-task.md" )
1280- taskContent := `/test-cmd cmd_param="!` + "`echo injected`" + `"`
1281- if err := os .WriteFile (taskFile , []byte (taskContent ), 0644 ); err != nil {
1282- t .Fatalf ("failed to create task file: %v" , err )
1283- }
1278+ // Create a task that calls the command with a param containing expansion syntax
1279+ taskFile := filepath .Join (dirs .tasksDir , "test-cmd-task.md" )
1280+ taskContent := `/test-cmd cmd_param="!` + "`echo injected`" + `"`
1281+ if err := os .WriteFile (taskFile , []byte (taskContent ), 0644 ); err != nil {
1282+ t .Fatalf ("failed to create task file: %v" , err )
1283+ }
12841284
1285- // Run the task
1286- output := runTool (t , "-C" , dirs .tmpDir , "test-cmd-task" )
1285+ // Run the task
1286+ output := runTool (t , "-C" , dirs .tmpDir , "test-cmd-task" )
12871287
1288- // The command parameter should be replaced with the literal string "!`echo injected`"
1289- // It should NOT be expanded again (that would execute the command)
1290- if ! strings .Contains (output , "!`echo injected`" ) {
1291- t .Errorf ("Expected command param to be replaced with literal value, got: %s" , output )
1292- }
1288+ // The command parameter should be replaced with the literal string "!`echo injected`"
1289+ // It should NOT be expanded again (that would execute the command)
1290+ if ! strings .Contains (output , "!`echo injected`" ) {
1291+ t .Errorf ("Expected command param to be replaced with literal value, got: %s" , output )
1292+ }
12931293
1294- // Verify "injected" is not in output (which would indicate the command was executed)
1295- if strings .Contains (output , "Command param: injected" ) {
1296- t .Errorf ("Command parameter value was re-expanded (command was executed), got: %s" , output )
1297- }
1294+ // Verify "injected" is not in output (which would indicate the command was executed)
1295+ if strings .Contains (output , "Command param: injected" ) {
1296+ t .Errorf ("Command parameter value was re-expanded (command was executed), got: %s" , output )
1297+ }
12981298}
0 commit comments