content: name = "Obsidian Query Agent"
  description = "An agent to answer questions using data from markdown files in an Obsidian vault."
  system_prompt = """
  You are an assistant designed to answer questions by searching through markdown files in a user's Obsidian vault.
  
  ---
  
  {{cat AGENTS.md}}
  
  ---
  
  Today's date is {{$date}}. Use this to look up journals or meetings.
  
  Here is calendar of the previous month, this month and next. Use this to lookup day based on dates or the other way round.
  {{$cal -3}}
  
  Here is the directories available in my second brain:
  {{$tree -d ~/.local/share/sbdb}}
  """
  
  [[functions]]
  name = "search_notes"
  description = """
  Search for patterns with the text of notes from the vault.
  It returns the files that the pattern has been found in.
  
  NOTE: If a search returns nothing, use a shorter search pattern."""
  command = "rg -il -C 4 '{{pattern}}' | head -n 100 ; find . -name '{{pattern}}' | head -n 100"
  pwd="~/.local/share/sbdb/"
  safe = true
  
  [[functions.parameters]]
  name = "pattern"
  type = "string"
  description = "The regex pattern to search for"
  required = true
  
  [[functions.parameters]]
  name = "path"
  type = "string"
  description = "Path to search in the vault"
  required = true
  
  [[functions]]
  name = "find_note"
  description = "Find notes with a given name"
  command = "find . -name '*{{pattern}}*' -exec file {} \\;"
  pwd="~/.local/share/sbdb/"
  safe = true
  
  [[functions.parameters]]
  name = "pattern"
  type = "string"
  description = "Pattern to search notes with"
  required = false
  
  [[functions]]
  name = "list_directory"
  description = """
  List the file and folders in one of the directory in the vault
  In the response if something ends with a `/`, it is a directory, otherwise it is a file.
  """
  command = "find './{{directory}}' -exec file {} \\;"
  pwd="~/.local/share/sbdb/"
  safe = true
  
  [[functions.parameters]]
  name = "directory"
  type = "string"
  description = "Directory to list. All paths should be relative paths."
  required = true
  
  [[functions]]
  name = "read_file"
  description = "Read the contents of a note"
  command = "cat './{{note_path}}' 2>/dev/null || cat '{{note_path}}.md'"
  pwd="~/.local/share/sbdb/"
  safe = true
  
  [[functions.parameters]]
  name = "note_path"
  type = "string"
  description = "Name of the note to read. Provide the full path"
  required = true
  
  
  [[functions]]
  name = "edit_note"
  description = """Edit a note using special diff format.
  
  Reads a diff and applies it to the specified file.
  The diff uses a special format with SEARCH and REPLACE blocks.
  
  NOTES:
    - The search text must match exactly (including whitespace)
    - If multiple matches exist, the operation will fail to avoid ambiguity
    - Empty replace blocks will delete the search text
    - The original file is overwritten with the changes
    - The blocks should be named SEARCH and REPLACE as shown in the example
  """
  command = "apply-edit '{{note_name}}.md'"
  stdin = "{{diff}}"
  pwd="~/.local/share/sbdb/"
  safe = false
  
  [[functions.parameters]]
  name = "note_name"
  type = "string"
  description = "Name of the note to edit without the .md extension"
  required = true
  
  [[functions.parameters]]
  name = "diff"
  type = "string"
  description = """
  The diff to apply to the note in the format specified above
  
  FORMAT:
    <<<<<<< SEARCH
    [text to find]
    =======
    [text to replace with]
    >>>>>>> REPLACE
  
  NOTES:
    - The search text must match exactly (including whitespace)
    - If multiple matches exist, the operation will fail to avoid ambiguity
    - Empty replace blocks will delete the search text
    - The original file is overwritten with the changes
    - The blocks should be named SEARCH and REPLACE as shown in the example
  """
  required = true
  
  [[functions]]
  name = "create_note"
  description = "Create a new note with the given name and content"
  command = "tee '{{note_name}}.md' >/dev/null && echo 'Note created: {{note_name}}.md'"
  stdin = "{{content}}"
  pwd="~/.local/share/sbdb/"
  safe = false
  
  [[functions.parameters]]
  name = "note_name"
  type = "string"
  description = "Name of the note to create without the .md extension"
  required = true
  
  [[functions.parameters]]
  name = "content"
  type = "string"
  description = "Content of the note to create"
  required = true
  
  [[functions]]
  name = "delete_note"
  description = "Delete a note with the given name"
  command = "rm -f '{{note_name}}.md'"
  pwd="~/.local/share/sbdb/"
  safe = false
  
  [[functions.parameters]]
  name = "note_name"
  type = "string"
  description = "Name of the note to delete without the .md extension"
  required = true