graphify icon indicating copy to clipboard operation
graphify copied to clipboard

[BUG] `.graphifyignore` does not allow selecting single file type

Open raulparada opened this issue 6 months ago • 4 comments

Hi! I've a typical python project with of course many .py files and also a good few .md, .png, etc. files. I'd like to skip the semantic extraction part and just use the AST extraction due to multiple reasons, e.g. to just trial this utility, to (initially) index a huge codebase continually without worrying about costs at all, etc.

I tried the .graphifyignore with a naive:

*
!*.py

but then everything is excluded. Tried a further !**/**/*.py for good measure which also didn't work (though to be clear expectation would be that the above alone works).

What's the way to achieve AST-based-only extraction, i.e. no LLM usage at all for making the graph? any cli flag or a correct syntax for the ignore file (I know I could go ignoring file types but hard to maintain that)?

Thanks!

 ❯ graphify --version
graphify 0.8.20

raulparada avatar May 27 '26 12:05 raulparada

Good question. Two things to know:\n\n1. Code files are already AST-only (no LLM cost). graphify only invokes an LLM for document files (.md, .pdf, images, etc.). All code files (.py, .ts, .go, ...) go through the AST extractor — zero API calls, zero cost. So if your project is mostly Python with some docs, you can simply let graphify run and it will only charge for the doc files.\n\n2. To exclude docs entirely, add to .graphifyignore:\n\n*.md\n*.pdf\n*.png\n*.jpg\n\nThis is easier to maintain than a wildcard + negation approach.\n\nOn the *\n!*.py pattern: this hits a known gitignore edge case — a bare * at the root matches and prunes directories before the negation can un-ignore files inside them. The practical workaround is to ignore by extension rather than include by extension.

safishamsi avatar May 27 '26 21:05 safishamsi

Thanks.

Code files are already AST-only (no LLM cost)

Understood so from docs, thanks for confirming though cause LLMs were assuming there was also semantic parsing on code files (maybe on docstrings or so).

To exclude docs entirely, add to .graphifyignore:\n\n*.md\n*.pdf\n*.png\n*.jpg\n\nThis is easier to maintain than a wildcard + negation approach.

That's really not true though. Two lines in the ignore file fit my use-case much better than an indeterminate amount of lines—requiring maintenance—do. And for example now that I did it this way I had to go through trial and error to find that I also needed to add:

*.yaml
*.yml
*.txt

in a small project I'm trialling on to skip the 'docs' semantic parsing. BTW gitignore does not have this issue, and it's even documented on the main README of this repo as supported, where it says:

# only index src/, ignore everything else
*
!src/
!src/**

I really believe that:

  1. fixing the ignore syntax to match the working of e.g. .gitignore
  2. (and maybe) adding a CLI flag to skip doc/semantic parsing

would benefit adoption.

Thanks for the utility and your time, good luck!

raulparada avatar May 28 '26 07:05 raulparada

Came here because I have the same exact issue. I just wanted to try it out, but:

❯ graphify .
[graphify extract] scanning /Users/user-name/src/project-name
[graphify extract] found 287 code, 56 docs, 0 papers, 6 images
error: no LLM API key found (62 doc/paper/image file(s) need semantic extraction). Set GEMINI_API_KEY or GOOGLE_API_KEY (gemini), MOONSHOT_API_KEY (kimi), ANTHROPIC_API_KEY (claude), OPENAI_API_KEY (openai), DEEPSEEK_API_KEY (deepseek), or pass --backend. A code-only corpus needs no key.

What do you think of a graphify --code-only . or graphify --no-semantic-extraction .

chhh avatar Jun 15 '26 21:06 chhh

Already fixed on current v8.

Reproduced the exact repro from this issue: * + !*.py in .graphifyignore, with a top-level a.py, a top-level b.md, and a sub/c.py.

files: {'code': ['a.py'], ...}
ignored: ['.graphifyignore', 'b.md', 'sub/']

So the top-level a.py is correctly kept, b.md is correctly excluded, and sub/ (and everything inside it, including sub/c.py) is excluded — matching real git's own gitignore semantics for this exact pattern (git check-ignore on the same tree gives the identical result: a.py not ignored, b.md and sub/c.py ignored, because once a directory itself matches *, git never descends into it to apply the negation).

The originally reported behavior (everything excluded, including top-level a.py) no longer reproduces.

ayushcodes10 avatar Sep 16 '26 09:09 ayushcodes10