content: name = "Advanced Coder"
  description = "An intelligent coding assistant with context-aware code editing and reliable technical guidance"
  
  system_prompt = """
  You are a high-performance coding assistant optimized for fast, accurate codebase interaction and reliable development support.
  
  ## 🔍 Core Directives
  
  1. **Context-Aware Assistance**: Always check relevant files, symbols, and references before answering or modifying anything.
  2. **Minimal, Safe Edits**: Prefer localized, low-risk changes unless broader refactoring is explicitly requested.
  3. **Precision over Guessing**: Never assume code behavior—verify through context, usage, or related files.
  4. **Clarity in Responses**: Keep answers concise, actionable, and technically sound.
  
  ## 🧠 Functional Capabilities
  
  - **Code Understanding**: Navigate functions, types, and modules across files; recognize naming patterns, side effects, and architectural conventions.
  - **Targeted Editing**: Make surgical changes using diff-style edits; default to line-based edits unless structural refactoring is necessary.
  - **Dependency Awareness**: Handle `go.mod`, package imports, and init logic with insight into downstream implications.
  - **Testing Hooks**: Leverage existing tests to validate changes or generate relevant test cases on the fly.
  - **Cross-File Reasoning**: Trace references, call chains, and symbol definitions to answer complex questions with code-backed clarity.
  
  ## ⚙️ Execution Workflow
  
  1. **Discovery Phase**
     - Load directory structure (`tree`)
     - Check recent commits (`git log`)
     - Analyze key files: entry points, configs, and usage-heavy components
     - Identify relevant code symbols or patterns (via `ctags`, `rg`, or `symbol-search`)
  
  2. **Analysis Phase**
     - Understand context before any change: use `read_file`, `find_references`, or `search_for_text`
     - Answer questions using actual project code and conventions
  
  3. **Planning Phase**
     - For edits: Determine the smallest valid change that meets the requirement
     - For answers: Prioritize correctness, relevance, and project-fit over generic info
  
  4. **Implementation Phase**
     - Apply exact, reversible changes via `apply_edit` or `write_file`
     - Align with code style and naming conventions
  
  5. **Verification Phase**
     - Optionally validate through test hooks or reference checks
     - Clearly confirm change behavior and next steps if applicable
  
  ## 🌐 Environment Context
  
  - OS: {{$uname -o}}
  - Directory: {{$pwd}}
  - Date: {{$date}}
  - User: Abin Simon (meain), Senior Software Engineer (Go)
  - Scope: Current directory & subdirectories with project-aware boundaries
  
  ### Git Status
  {{$git log --oneline -10 2>/dev/null || echo "No git repository detected"}}
  
  ### Directory Tree
  {{$git ls-files --others --exclude-standard --cached | tree --fromfile -d || tree -d ./}}
  
  ## ✅ Response Protocol
  
  - **Answer Coding Questions**: Refer to real symbols, usage, or definitions when available. Use inline code snippets or edits.
  - **Modify Code**: Only change what’s needed. Follow project idioms. Use diff-style edits.
  - **Explain Only When Needed**: Avoid redundant elaboration unless asked.
  - **No Guesswork**: Validate with project data, not memory alone.
  - **Autonomous Execution**: Don’t wait for permission to fetch info, analyze context, or proceed with edits unless a risk is detected.
  
  ---
  
  User Instructions
  =================
  
  {{$cat $(git rev-parse --show-toplevel)/AGENTS.md 2>/dev/null || echo "No additional user instructions"}}
  
  Additional documentation
  ========================
  
  {{$if ls .llmdocs -1 >/dev/null 2>&1; then ls .llmdocs -1 | sed 's|^|- .llmdocs/|g'; else echo "No additional docs available"; fi}}
  
  IMPORTANT: Always look through the relevant files in the project before answering user's questions
  """
  
  ## Enhanced File Operations
  [[functions]]
  name = "read_file"
  description = "Read file contents with optional line numbers and range selection"
  command = "cat -T {{show_line_numbers}} {{file}} {{line_range}}"
  safe = true
  
  [[functions.parameters]]
  name = "file"
  type = "string"
  description = "Path to the file to read"
  required = true
  
  [[functions.parameters]]
  name = "show_line_numbers"
  type = "boolean"
  description = "Display line numbers"
  required = false
  format = "-n"
  
  [[functions.parameters]]
  name = "line_range"
  type = "string"
  description = "Line range to read (e.g., '10,20' for lines 10-20)"
  required = false
  format = "| sed -n '%sp'"
  
  [[functions]]
  name = "write_file"
  description = "Write content to file"
  command = "tee {{file}}"
  stdin = "{{content}}"
  
  [[functions.parameters]]
  name = "file"
  type = "string"
  description = "File to write"
  required = true
  
  [[functions.parameters]]
  name = "content"
  type = "string"
  description = "Content to write"
  required = true
  
  [[functions]]
  name = "apply_edit"
  description = "Apply precise search and replace edits to files using diff-style format. Uses SEARCH/REPLACE blocks: <<<<<<< SEARCH (text to find) ======= (replacement text) >>>>>>> REPLACE. Search text must match exactly including whitespace. Empty replace blocks delete the search text."
  command = "apply-edit {{file}}"
  stdin = "{{edit_content}}"
  
  [[functions.parameters]]
  name = "file"
  type = "string"
  description = "File to apply edits to"
  required = true
  
  [[functions.parameters]]
  name = "edit_content"
  type = "string"
  description = """Edit content in SEARCH/REPLACE format similar to aider.
  Ensure whitespace is not stripped in the search or replace blocks and exact search.
  
  - Provide search replace blocks only for consecutive blocks
  - Ensure the original text is as is including whitespace
  - Ensure new text includes the necessary whitespace
  - Do not include like line numbers in search or replace blocks
  - Include only a single search replace block in a single tool call (use separate tool calls for each search and replace operation)
  
  EXAMPLE:
  Given a file 'app.py' with contents:
  
  ```
  from flask import Flask
  app = Flask(__name__)
  ```
  
  The below block:
  
  ```
  <<<<<<< SEARCH
  from flask import Flask
  =======
  import math
  from flask import Flask
  >>>>>>> REPLACE
  ```
  
  Result: The file will be updated to:
  
  ```
  import math
  from flask import Flask
  app = Flask(__name__)
  ```"""
  required = true
  
  ## Enhanced Code Analysis
  
  [[functions]]
  name = "analyze_code_structure"
  description = "Analyze code structure and dependencies"
  command = "ctags -R --fields=+iaS --extra=+q . 2>/dev/null | head -n 500"
  safe = true
  
  [[functions.parameters]]
  name = "file_pattern"
  type = "string"
  description = "File pattern to analyze (e.g., '*.go', '*.py')"
  required = false
  
  [[functions]]
  name = "search_symbols"
  description = "Find symbols (functions/types/variables) with enhanced filtering"
  command = ",symbol-search | grep -i '{{pattern}}'"
  pwd = "{{directory}}"
  safe = true
  
  [[functions.parameters]]
  name = "directory"
  type = "string"
  description = "Directory to search in"
  required = false
  
  [[functions.parameters]]
  name = "pattern"
  type = "string"
  description = "Pattern to search for (case insensitive)"
  required = true
  
  [[functions]]
  name = "find_references"
  description = "Find all references to a symbol across the codebase"
  command = "rg -n '\\b{{symbol}}\\b' {{file_pattern}} | head -n 100"
  safe = true
  
  [[functions.parameters]]
  name = "symbol"
  type = "string"
  description = "Symbol to find references for"
  required = true
  
  [[functions.parameters]]
  name = "file_pattern"
  type = "string"
  description = "File pattern to search in (e.g., '*.go')"
  required = false
  
  ## Enhanced Search and Navigation
  
  [[functions]]
  name = "search_for_text"
  description = "Advanced text search with context and filtering"
  command = "rg {{case_sensitive}} {{whole_word}} {{context}} '{{pattern}}' {{file_pattern}} ./{{directory}} | head -n {{limit}}"
  safe = true
  
  [[functions.parameters]]
  name = "pattern"
  type = "string"
  description = "Pattern to search for (supports regex)"
  required = true
  
  [[functions.parameters]]
  name = "directory"
  type = "string"
  description = "Directory to search in"
  required = false
  
  [[functions.parameters]]
  name = "file_pattern"
  type = "string"
  description = "File pattern filter (e.g., 'go', 'py')"
  required = false
  format = "-t %s"
  
  [[functions.parameters]]
  name = "case_sensitive"
  type = "boolean"
  description = "Case sensitive search"
  required = false
  format = "-s"
  
  [[functions.parameters]]
  name = "whole_word"
  type = "boolean"
  description = "Match whole words only"
  required = false
  format = "-w"
  
  [[functions.parameters]]
  name = "context"
  type = "number"
  description = "Lines of context to show"
  required = false
  format = "-C %0.f"
  
  [[functions.parameters]]
  name = "limit"
  type = "number"
  description = "Maximum number of results"
  required = false
  default = "300"
  
  [[functions]]
  name = "find_files_by_name"
  description = "Find files with advanced filtering and sorting"
  command = "find . -name '{{pattern}}' {{file_type}} {{max_depth}} | sort"
  safe = true
  
  [[functions.parameters]]
  name = "pattern"
  type = "string"
  description = "Pattern to search for (supports wildcards)"
  required = true
  
  [[functions.parameters]]
  name = "file_type"
  type = "string"
  description = "File type filter"
  options = ["-type f", "-type d", "-type l"]
  required = false
  
  [[functions.parameters]]
  name = "max_depth"
  type = "number"
  description = "Maximum search depth"
  required = false
  format = "-maxdepth %0.f"
  
  ## Project Management
  
  [[functions]]
  name = "list_directory"
  description = "Enhanced directory listing with file information"
  command = "ls -la {{directory}} | head -n {{limit}}"
  safe = true
  
  [[functions.parameters]]
  name = "directory"
  type = "string"
  description = "Directory to list"
  required = true
  
  [[functions.parameters]]
  name = "limit"
  type = "number"
  description = "Maximum number of entries"
  required = false
  default = "100"
  
  [[functions]]
  name = "print_tree"
  description = "Print directory tree with enhanced filtering"
  command = "tree {{directory}} {{depth}} {{file_pattern}} {{ignore_pattern}}"
  safe = true
  
  [[functions.parameters]]
  name = "directory"
  type = "string"
  description = "Directory to print tree for"
  required = true
  
  [[functions.parameters]]
  name = "depth"
  type = "number"
  description = "Maximum depth to traverse"
  required = false
  format = "-L %0.f"
  
  [[functions.parameters]]
  name = "file_pattern"
  type = "string"
  description = "File pattern to include (e.g., '*.go')"
  required = false
  format = "-P '%s'"
  
  [[functions.parameters]]
  name = "ignore_pattern"
  type = "string"
  description = "Pattern to ignore (e.g., 'node_modules|.git')"
  required = false
  format = "-I '%s'"
  
  ## Advanced Operations
  
  [[functions]]
  name = "run_command"
  description = "Execute arbitrary commands with enhanced error handling"
  command = "{{command}} 2>&1 || echo 'Command failed with exit code $?'"
  safe = false
  
  [[functions.parameters]]
  name = "command"
  type = "string"
  description = "Command to execute"
  required = true
  
  [[functions]]
  name = "move_file"
  description = "Move or rename files"
  command = "mv {{source}} {{destination}} 2>&1 || echo 'Move operation failed'"
  safe = false
  
  [[functions.parameters]]
  name = "source"
  type = "string"
  description = "Source file or directory"
  required = true
  
  [[functions.parameters]]
  name = "destination"
  type = "string"
  description = "Destination path"
  required = true
  
  [[functions]]
  name = "get_search_results"
  description = """Get search results from DuckDuckGo.
  Use get_webpage function to get the full content of relevant webpages within the search results."""
  # https://github.com/jarun/ddgr/issues/159#issuecomment-1862655714
  command = "ddgr --noua --json '{{query}}'"
  safe = true
  
  [[functions.parameters]]
  name = "query"
  type = "string"
  description = "Query to search for"
  required = true
  
  [[functions]]
  name = "read_webpage"
  description = "Read and convert webpage content to markdown"
  command = "readable '{{url}}' | html2markdown"
  safe = true
  
  [[functions.parameters]]
  name = "url"
  type = "string"
  description = "URL of the webpage to read"
  required = true
  
  [[function]]
  name = "ask_question"
  description = "Ask questions about a popular tool or technology"
  command = "esa +qa '{{question}}'"
  
  [[function.parameters]]
  name = "question"
  type = "string"
  description = """Question to ask about the tool or technology.
  Example: How do I use chi router in Go?"""
  required = true