Support shebang execution of markdown files

t-334·WorkTask·
·
·
·Omni/Agent.hs
Created1 month ago·Updated1 month ago

Dependencies

Description

Edit

Summary

When a markdown file has #!/usr/bin/env agent and is executed directly, the agent CLI should detect this and read the file content as the prompt.

Current Behavior

./Biz/PodcastItLater/Growth.md
# Error: agent tries to parse 'Biz/PodcastItLater/Growth.md' as prompt text

Expected Behavior

./Biz/PodcastItLater/Growth.md
# agent detects it's a file path, reads content, strips shebang, uses as prompt

Implementation

In parseOptions, before using the prompt argument:

1. Check if argPrompt is a file path that exists 2. If so, read the file content 3. Strip the shebang line (#!/usr/bin/env agent) if present 4. Use remaining content as the prompt

-- Pseudocode
argPrompt <- case Docopt.getArg args (Docopt.argument "prompt") of
  Nothing -> pure ""
  Just path -> do
    exists <- Dir.doesFileExist path
    if exists && ".md" `List.isSuffixOf` path
      then do
        content <- TextIO.readFile path
        -- Strip shebang line if present
        let lines = Text.lines content
        pure <| case lines of
          (first:rest) | "#!" `Text.isPrefixOf` first -> Text.unlines rest
          _ -> content
      else pure (Text.pack path)

Acceptance Criteria

  • [ ] ./Skill.md executes the skill as a prompt (file has shebang, is executable)
  • [ ] agent "hello" still works (string prompt)
  • [ ] agent Omni/Ide/Coder.md reads file content (explicit file path)
  • [ ] Shebang line is stripped from content
  • [ ] Non-.md files are treated as literal prompts

Timeline (2)

🔄[human]Open → InProgress1 month ago
🔄[human]InProgress → Done1 month ago