Skip to content

Template file resolution failure in aid v1.3.1 - all prompt-* AI actions broken #8

@superresistant

Description

@superresistant

Summary

All prompt-* AI actions fail with "template file not found" errors in aid v1.3.1, despite template files being present and readable in the working directory. This affects all prompt-based AI actions, while flow-* actions work correctly.

Environment

  • OS: Windows 10/11 with Git Bash (MINGW64)
  • Terminal: Windows Terminal
  • aid Version: v1.3.1 (latest as of Aug 2025)
  • Shell: Git Bash / MINGW64
  • Binary Path: C:\Users\CurrentUser\.aid\bin\aid.exe

Bug Description

Expected Behavior

prompt-* AI actions should find and use template files (e.g., refactoring.md) when they are present in the current working directory.

Actual Behavior

All prompt-* AI actions fail with template resolution errors:

$ aid path/to/your/file.ext --ai-action prompt-for-refactoring-suggestion --stdout
Error: content generation failed: template file not found: refactoring.md (searched from /path/to/project)

Affected AI Actions

All 8 prompt-based actions are broken:

  • prompt-for-refactoring-suggestion
  • prompt-for-bug-hunting
  • prompt-for-security-analysis
  • prompt-for-performance-analysis
  • prompt-for-best-practices-analysis
  • prompt-for-single-file-docs
  • prompt-for-diagrams
  • prompt-for-complex-codebase-analysis

Working AI Actions

Flow-based actions work as expected:

  • flow-for-deep-file-to-file-analysis
  • flow-for-multi-file-docs

Reproduction Steps

  1. Download the necessary template files from the official GitHub repository.
    curl -O https://raw.githubusercontent.com/janreges/ai-distiller/main/internal/aiactions/templates/refactoring.md
    # (repeat for all 8 template files)
  2. Place refactoring.md in the project's working directory.
  3. Verify that the file exists and is readable:
    $ ls -la refactoring.md
    -rw-r--r-- 1 CurrentUser 197121 4403 Aug 18 10:50 refactoring.md
    
    $ file refactoring.md
    refactoring.md: Unicode text, UTF-8 text, with very long lines (323)
  4. Run a prompt-based action:
    $ aid path/to/your/file.ext --ai-action prompt-for-refactoring-suggestion --stdout
    ```5.  Observe the error, despite the file's presence.
    

Debugging Information

Verbose Output Analysis

With the -vvv flag, aid successfully processes the source file but fails later:

[11:11:10.849] [distill-for-action] INFO: Distilled 1087 bytes of content
Error: content generation failed: template file not found: refactoring.md (searched from /path/to/project)

Key Finding: The issue occurs during the content generation phase, after the file distillation has completed successfully.

Template Locations Tested

Templates were placed in various locations, but the error persisted:

  • Project root: /path/to/project/refactoring.md
  • Templates subdirectory: /path/to/project/templates/refactoring.md
  • Aid binary directory: C:\Users\CurrentUser\.aid\bin\refactoring.md
  • Aid installation templates: C:\Users\CurrentUser\.aid\templates\refactoring.md
  • MCP server directory: C:\Users\CurrentUser\AppData\Roaming\npm\node_modules\@janreges\ai-distiller-mcp\refactoring.md

Path Resolution Troubleshooting

Several attempts were made to rule out common Windows/Git Bash path conversion issues, none of which were successful:

  • Disable MSYS path conversion:
    MSYS_NO_PATHCONV=1 MSYS2_ARG_CONV_EXCL="*" aid path/to/your/file.ext --ai-action prompt-for-refactoring-suggestion --stdout
  • PowerShell wrapper with Windows paths:
    powershell.exe -Command "Set-Location '/path/to/project'; & 'C:\Users\CurrentUser\.aid\bin\aid.exe' 'path/to/your/file.ext' '--ai-action' 'prompt-for-refactoring-suggestion' '--stdout'"
  • cmd.exe wrapper:
    cmd.exe /c "pushd /path/to/project && C:\Users\CurrentUser\.aid\bin\aid.exe path/to/your/file.ext --ai-action prompt-for-refactoring-suggestion --stdout"

These tests indicate that the problem is likely not a path conversion issue.

File Accessibility Verification

The template files are accessible using native Windows commands:

PS /path/to/project> Get-ChildItem -Name "*.md"
# Lists all template files including refactoring.md

PS /path/to/project> Get-ItemProperty 'refactoring.md'
Name           Length LastWriteTime
----           ------ -------------
refactoring.md   4403 18/08/2025 10:50:20

Additional Context

Template File Source

The templates were acquired from the official repository:

  • Source: https://github.com/janreges/ai-distiller/tree/main/internal/aiactions/templates
  • All 8 template files were downloaded and verified.
  • The file format and content appear to be correct (UTF-8 encoded text with template variables like {{.ProjectName}}).

MCP Integration Status

  • MCP server integration is functioning correctly.
  • The AI can invoke aid through MCP.
  • Only prompt-* actions are affected; standard distillation and flow-* actions work as intended.

Cross-Platform Implications

While this report originates from a Windows Git Bash environment, the bug is likely to affect all platforms. This is because it appears to be in the aid binary's template resolution logic, rather than in OS-specific path handling.

Workaround

Users can utilize flow-* AI actions as an alternative to the non-functional prompt-* actions:```bash

Instead of the broken prompt actions, use:

aid ./src --ai-action flow-for-deep-file-to-file-analysis
aid ./src --ai-action flow-for-multi-file-docs

Flow actions provide similar analytical capabilities by generating structured task lists and analysis workflows without the need for templates.

Expected Fix

The template resolution logic should be updated to:

  1. Correctly search for template files in the current working directory.
  2. Provide more informative error messages that specify where templates are being sought.
  3. Consider adding a --template-dir flag or an AID_TEMPLATE_DIR environment variable for custom template locations.
  4. Include debugging output that shows the actual search paths being attempted.

Impact

This bug prevents users from utilizing 8 of the 10 AI-powered analysis features, which significantly curtails the tool's analytical capabilities. While the flow-* actions offer a partial workaround, they do not provide the same structured analysis prompts as the prompt-* actions.

This issue report contains a comprehensive breakdown of the bug, including all troubleshooting steps and evidence to suggest that this is a genuine bug rather than a configuration error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions