@@ -422,15 +422,11 @@ echo "Bootstrap executed successfully"
422422func TestOpenCodeRulesSupport (t * testing.T ) {
423423 tmpDir := t .TempDir ()
424424 openCodeAgentDir := filepath .Join (tmpDir , ".opencode" , "agent" )
425- openCodeCommandDir := filepath .Join (tmpDir , ".opencode" , "command" )
426425 tasksDir := filepath .Join (tmpDir , ".agents" , "tasks" )
427426
428427 if err := os .MkdirAll (openCodeAgentDir , 0o755 ); err != nil {
429428 t .Fatalf ("failed to create opencode agent dir: %v" , err )
430429 }
431- if err := os .MkdirAll (openCodeCommandDir , 0o755 ); err != nil {
432- t .Fatalf ("failed to create opencode command dir: %v" , err )
433- }
434430 if err := os .MkdirAll (tasksDir , 0o755 ); err != nil {
435431 t .Fatalf ("failed to create tasks dir: %v" , err )
436432 }
@@ -445,16 +441,6 @@ This agent helps with documentation.
445441 t .Fatalf ("failed to write agent file: %v" , err )
446442 }
447443
448- // Create a command rule file in .opencode/command
449- commandFile := filepath .Join (openCodeCommandDir , "commit.md" )
450- commandContent := `# Commit Command
451-
452- This command helps create commits.
453- `
454- if err := os .WriteFile (commandFile , []byte (commandContent ), 0o644 ); err != nil {
455- t .Fatalf ("failed to write command file: %v" , err )
456- }
457-
458444 // Create a task file
459445 taskFile := filepath .Join (tasksDir , "test-opencode.md" )
460446 taskContent := `---
@@ -476,17 +462,45 @@ This is a test task.
476462 t .Errorf ("OpenCode agent rule content not found in stdout" )
477463 }
478464
479- // Check that command rule content is present
480- if ! strings .Contains (output , "# Commit Command" ) {
481- t .Errorf ("OpenCode command rule content not found in stdout" )
482- }
483-
484465 // Check that task content is present
485466 if ! strings .Contains (output , "# Test OpenCode Task" ) {
486467 t .Errorf ("task content not found in stdout" )
487468 }
488469}
489470
471+ func TestOpenCodeCommandTaskSupport (t * testing.T ) {
472+ tmpDir := t .TempDir ()
473+ openCodeCommandDir := filepath .Join (tmpDir , ".opencode" , "command" )
474+
475+ if err := os .MkdirAll (openCodeCommandDir , 0o755 ); err != nil {
476+ t .Fatalf ("failed to create opencode command dir: %v" , err )
477+ }
478+
479+ // Create a task file in .opencode/command
480+ taskFile := filepath .Join (openCodeCommandDir , "fix-bug.md" )
481+ taskContent := `---
482+ task_name: fix-bug
483+ ---
484+ # Fix Bug Command
485+
486+ This is an OpenCode command task for fixing bugs.
487+ `
488+ if err := os .WriteFile (taskFile , []byte (taskContent ), 0o644 ); err != nil {
489+ t .Fatalf ("failed to write task file: %v" , err )
490+ }
491+
492+ // Run the program
493+ output := runTool (t , "-C" , tmpDir , "fix-bug" )
494+
495+ // Check that task content is present
496+ if ! strings .Contains (output , "# Fix Bug Command" ) {
497+ t .Errorf ("OpenCode command task content not found in stdout" )
498+ }
499+ if ! strings .Contains (output , "This is an OpenCode command task for fixing bugs." ) {
500+ t .Errorf ("OpenCode command task description not found in stdout" )
501+ }
502+ }
503+
490504func TestTaskSelectionByFrontmatter (t * testing.T ) {
491505 tmpDir := t .TempDir ()
492506 tasksDir := filepath .Join (tmpDir , ".agents" , "tasks" )
@@ -518,36 +532,36 @@ This task has a different filename than task_name.
518532 }
519533}
520534
521- func TestTaskMissingTaskNameError (t * testing.T ) {
535+ func TestTaskWithoutTaskNameUsesFilename (t * testing.T ) {
522536 tmpDir := t .TempDir ()
523537 tasksDir := filepath .Join (tmpDir , ".agents" , "tasks" )
524538
525539 if err := os .MkdirAll (tasksDir , 0o755 ); err != nil {
526540 t .Fatalf ("failed to create tasks dir: %v" , err )
527541 }
528542
529- // Create a task file WITHOUT task_name in frontmatter
530- taskFile := filepath .Join (tasksDir , "bad -task.md" )
543+ // Create a file WITHOUT task_name in frontmatter - should use filename
544+ taskFile := filepath .Join (tasksDir , "my -task.md" )
531545 taskContent := `---
532546description: A task without task_name
533547---
534- # Bad Task
548+ # My Task
535549
536- This task is missing task_name in frontmatter .
550+ This file uses the filename as task_name .
537551`
538552 if err := os .WriteFile (taskFile , []byte (taskContent ), 0o644 ); err != nil {
539- t .Fatalf ("failed to write task file: %v" , err )
553+ t .Fatalf ("failed to write file: %v" , err )
540554 }
541555
542- // Run the program - should fail with an error
543- output , err := runToolWithError ("-C" , tmpDir , "bad-task" )
544- if err == nil {
545- t .Fatalf ("expected program to fail, but it succeeded" )
546- }
556+ // Run the program - should succeed using filename as task name
557+ output := runTool (t , "-C" , tmpDir , "my-task" )
547558
548- // Check that error message mentions missing task_name
549- if ! strings .Contains (output , "missing required 'task_name' field in frontmatter" ) {
550- t .Errorf ("expected error about missing task_name, got: %s" , output )
559+ // Check that task content is present
560+ if ! strings .Contains (output , "# My Task" ) {
561+ t .Errorf ("task content not found in stdout" )
562+ }
563+ if ! strings .Contains (output , "This file uses the filename as task_name." ) {
564+ t .Errorf ("task description not found in stdout" )
551565 }
552566}
553567
0 commit comments