Aider-AI / aider

aider is AI pair programming in your terminal
https://aider.chat/
Apache License 2.0
22.51k stars 2.09k forks source link

Having issues trying to `/lint` with `ansible-lint` #2461

Open rjlasko opened 6 hours ago

rjlasko commented 6 hours ago

Issue

Hello! I have been successfully using aider to do some minor development of an Ansible project. I am very interested in using its promoted linting capabilities, as I have a TON that aren't worth my time but would be perfect for AI to take care of. Sadly, this seems not to be working for me. 😞

Issue: Trying to use /lint with ansible-lint seems to do nothing, when asking to lint the files added to the chat. I am likely doing something wrong, or altogether don't know what I am doing, but it may also be a genuine problem. (#2270 makes me suspect the latter)

$ aider
> /add ansible/*.yml

Added ansible/host1.yml to the chat
Added ansible/inventory.yml to the chat

(omitting the above files indicated as added to the chat)
> /lint
(again, omitting the above files indicated as added to the chat)
>

Additionally....

There are no "unstaged" changes in the repository. Invoking /run ANSIBLE_ASK_VAULT_PASS=false ansible-lint -c ansible/.ansible-lint within an aider session gives an expected output:

> /run ANSIBLE_ASK_VAULT_PASS=false ansible-lint -c ansible/.ansible-lint
(many lines of output, like the following)

fqcn[action-core]: Use FQCN for builtin module actions (debug). (warning)
ansible/host2.yml:3 Use `ansible.builtin.debug` or `ansible.legacy.debug` instead.

Read documentation for instructions on how to ignore specific rule violations.

                           Rule Violation Summary                           
 count tag                        profile    rule associated tags           
     7 command-instead-of-module  basic      command-shell, idiom (warning) 
     7 command-instead-of-shell   basic      command-shell, idiom           
     2 deprecated-local-action    basic      deprecations (warning)         
     2 key-order[task]            basic      formatting                     
     1 jinja[invalid]             basic      formatting                     
    18 jinja[spacing]             basic      formatting                     
     1 no-free-form               basic      syntax, risk (warning)         
     2 schema[role-arg-spec]      basic      core                           
     1 schema[tasks]              basic      core                           
     7 var-naming[no-reserved]    basic      idiom                          
   415 var-naming[no-role-prefix] basic      idiom                          
     2 var-naming[pattern]        basic      idiom                          
    50 yaml[brackets]             basic      formatting, yaml               
     7 yaml[line-length]          basic      formatting, yaml               
     5 yaml[truthy]               basic      formatting, yaml               
    42 name[template]             moderate   idiom                          
     6 latest[git]                safety     idempotency (warning)          
     2 package-latest             safety     idempotency (warning)          
     5 risky-file-permissions     safety     unpredictability               
     5 risky-shell-pipe           safety     command-shell                  
     7 ignore-errors              shared     unpredictability (warning)     
    33 no-changed-when            shared     command-shell, idempotency     
     1 no-handler                 shared     idiom (warning)                
    75 fqcn[action-core]          production formatting (warning)           
     1 fqcn[action]               production formatting                     
     8 run-once[play]                        idiom                          

Failed: 611 failure(s), 101 warning(s) on 827 files. Last profile that met the validation criteria was 'min'.
Add command output to the chat? (Y)es/(N)o [Yes]: n          

Here is my aider.conf.yml

model: openai/gpt-4o

dark-mode: true
gitignore: false
auto-commits: false

lint-cmd: ANSIBLE_ASK_VAULT_PASS=false ansible-lint -c ansible/.ansible-lint

And here is some other information, if it is helpful.

$ ls -al ./myproject
drwxr-xr-x  16 xxx  9999      512 Nov 24 10:21 .
drwxr-xr-x   5 xxx  9999      160 Nov 19 00:24 ..
-rw-r-----@  1 xxx  9999  1159899 Nov 25 21:13 .aider.chat.history.md
-rw-r-----@  1 xxx  9999    25011 Nov 25 21:07 .aider.input.history
drwxr-x---   5 xxx  9999      160 Nov 25 21:13 .aider.tags.cache.v3
-rw-r-----@  1 xxx  9999      354 Nov 24 10:21 .editorconfig
drwxr-xr-x  16 xxx  9999      512 Nov 25 00:30 .git
-rw-r--r--   1 xxx  9999       81 Nov 16 00:54 .gitignore
drwxr-xr-x@  9 xxx  9999      288 Nov 25 21:13 .idea
drwxr-xr-x  31 xxx  9999      992 Nov 25 00:05 ansible
drwxr-xr-x  13 xxx  9999      416 Nov 16 00:53 app

And here is the ansible dir:

$ ls -al ./myproject/ansible
drwxr-xr-x  31 xxx  9999   992 Nov 25 00:05 .
drwxr-xr-x  16 xxx  9999   512 Nov 24 10:21 ..
-rw-r--r--@  1 xxx  9999   369 Nov 25 00:05 .ansible-lint
-rw-r--r--@  1 xxx  9999   585 Nov 24 11:11 .yamllint
-rw-r--r--   1 xxx  9999   996 Nov 16 00:54 ansible.cfg
-rw-r-----@  1 xxx  9999   375 Nov 24 10:23 host1.yml
-rw-r-----@  1 xxx  9999   153 Nov 24 10:23 host2.yml
-rw-r-----@  1 xxx  9999   226 Nov 24 23:12 host3.yml
-rw-r--r--@  1 xxx  9999  4712 Nov 24 23:11 host4.yml
drwxr-xr-x   6 xxx  9999   192 Nov 24 10:05 files
drwxr-xr-x   6 xxx  9999   192 Nov 16 00:54 filter_plugins
drwxr-xr-x  11 xxx  9999   352 Nov 24 10:23 group_vars
drwxr-x---  10 xxx  9999   320 Nov 16 00:53 host_vars
-rw-r-----   1 xxx  9999  4076 Nov 19 00:28 inventory.yml
drwxr-x---  13 xxx  9999   416 Nov 24 09:44 roles
drwxr-x---   6 xxx  9999   192 Nov 16 00:53 templates

Not sure what is issue, and would be very thankful for some help.

Be kind, and thanks again.

Version and model info

Aider v0.64.1 Main model: openai/gpt-4o with diff edit format Weak model: gpt-4o-mini Git repo: ../.git with 589 files Repo-map: using 1024 tokens, auto refresh

I am using MacOS Sonoma Running aider from within an IntelliJ terminal, but also get the same behavior from MacOS's vanilla Terminal application.

paul-gauthier commented 5 hours ago

Thanks for trying aider and filing this issue.

The /lint command will run the linter on all the "dirty" files which have been added to the chat. From your comments, it sounds like you tried to run it when there were no files with uncommitted changes (dirty files).

You can have aider help with linting in a few ways: