Cody ignore feature not working

When asking for a general overview of an Elixir codebase Cody seems fixated on looking in the assets/ and deps/ folders for context, when it would be better served looking at .ex files. I’ve tried to exclude the folders in the ignore file but Cody doesn’t seem to be detecting the file.

Contents of cody.json:

{
    "cody.unstableFeatures": true,
    "cody.internal.unstable": true,
    "latest-cody-release": {
        "description": "Summarize latest Cody release",
        "prompt": "What is the latest stable version of Cody? Briefly summarize the changes that were included in that release based on this CHANGELOG excerpt.",
        "context": {
            "selection": false,
            "command": "curl https://raw.githubusercontent.com/sourcegraph/cody/main/vscode/CHANGELOG.md | head -n 50"
        }
    }
}

Contents of .cody/ignore:

/deps/*
/assets/*
deps/*
assets/*
deps/
assets/
/deps
/assets
deps/swoosh
README.md

This is with enhanced context enabled, embeddings and search both indexed.

Cody 1.12.0

Hello @chris-wickens

Thank you for raising this issue. The Cody ignore feature is experimental. Take with caution.

For a guide on how to enable it, have a look at https://community.sourcegraph.com/t/how-to-enable-cody-ignore

Sorry for the inconvenient.

2 Likes

Thanks @chris-wickens for the detailed question did @PriNova’s solution work for you?

@chris-wickens it might not be working as expected because the "cody.internal.unstable": true setting should go into your VS Code User settings JSON and not cody.json, which is used for configuring custom commands.

Can you try moving the configuration from your cody.json file to your VS Code User Settings JSON file and see if that works?

1 Like

Thanks Beatrix, the cody.internal.unstable flag was in my user settings already but removing it from cody.json seems to have done the trick - either that or I restarted enough times for it to start working. Cody now ignores the folders I specify but unfortunately only adds a few files for context, so it’s not great at giving an overview. It is working much better for specific questions though. Thanks everybody for your help!

2 Likes

Actually, it’s still a big problem, very serious for me. With all these talks about Cody’s context understanding possibilities, I can’t use them because in game engines like Unity, I have to ignore almost everything except some scripts. And after that, Cody can’t find everything. For example, if I ask it, ‘What’s this project about?’ it can’t find any files. But there are some possible files in the Scripts folder. Cody can discuss them if I open them, so I think I set up .codyignore correctly. It seems like if it has to ignore some folders and use other folders, it’s too much for Cody.

If I understand this correctly, if you create a script for a GameObject you usually work in the bounds of this script, right?

And you place your script directly in a folder where other scripts of your project exists?

The easiest way is - if my assumptions are correct - to work in Cody with this single script only. That means to delete the repository chip at the beginning of a chat session and manually referencing only that script you are working on.

Let me try to explain in more detail.

A typical game engine contains thousands of files in various folders that are not related to the code I write. These include various graphics or even code from third-party libraries - it’s so large and already publicly known that I don’t see the point in having Cody study it. What I need is a certain number (10-300) of current code files in folders of various nesting levels within the Scripts folder in the project. Usually, all the code written by the developer is located inside such a folder - so in codyignore, I make sure everything is ignored except this folder.

This works at first glance - for example, I can’t discuss files outside of Scripts but can discuss those inside. However, this is similar to discussing individual parts of code with Claude or ChatGPT; it can’t be called understanding the project as a whole. At the same time, I often see Cody developers boasting about its understanding of the project context as a whole (including searching among files and selecting those relevant to the problem) - and I would be very interested to see how it would cope if it really understood the Scripts folder well (and all its nested folders and files) and ignored everything else. As far as I can see, it gets confused with this, as it starts to answer questions about the entire project somewhat strangely, missing files inside Scripts, sometimes distorting file names, etc.

Yes, I can discuss files one by one, as you suggested, but usually this is very limited because a specific problem usually involves 3-5 files - meaning that, except for the smallest problems, it’s pointless.

Removing the reference to the entire project each time you open a chat and then manually adding other scripts (each file) related to the problem is possible, but not very convenient.

The compromise I’ve come to (also not the most convenient, I’m writing in hopes that Cody developers will create something better for cases like mine?) - I created two commands that study comments. Both commands are set to study all open tabs and implement the highlighted comment. One is configured to edit code, the other to open a chat. And I keep open only those tabs that relate to the problem, understanding that Cody will study them.

Ignore everything

.
!.cody

Don’t ignore .gitignore and .codyignore

!.gitignore
!.cody/ignore

Don’t ignore Assets/Scripts directory

!/Assets/
/Assets/*
!/Assets/Scripts/

Don’t ignore .cs files in Assets/Scripts and its subdirectories

!/Assets/Scripts/**/*.cs

Ignore everything else in Assets/Scripts

/Assets/Scripts//*
!/Assets/Scripts/
/.cs
!/Assets/Scripts/**/
/

I fully grasp the concept as I work with Unreal Engine/Godot, and it appears to be similar.

When I write extensions or add features, I organize my folders around those features. This means I don’t place my scripts directly into the Engine Code but in a dedicated folder. Within this folder, I create my git repository, which only tracks my project folder, typically involving around those 3-5 files.
Only these files are indexed by Cody, while the rest, whether engine code or other features outside the project folder, are disregarded.

This approach is akin to a modular design within a component-based architecture.