gitingest icon indicating copy to clipboard operation
gitingest copied to clipboard

feat: config parameters as environment variables

Open adityakavalur opened this issue 6 months ago • 4 comments

Great project! Its a great way for AI agents to ingest codebases!

Have you all considered surfacing the config.py variables such as MAX_FILES and others as environment variables? So that users can override default values.

I occasionally run into such issues when working with large scientific codes (especially with recurse submodules)

Thanks!

adityakavalur avatar Jun 20 '25 12:06 adityakavalur

Hi @adityakavalur, thanks for the kind words and the suggestion!

Current state

Only MAX_FILE_SIZE is configurable now:

How Example
Python ingest(repo_path, max_file_size=5_000_000)
CLI gitingest -s 5_000_000 /path/to/repo

Proposal: GITINGEST_* environment variables

Let every constant in config.py be override-able, e.g.:

export GITINGEST_MAX_FILES=5000
export GITINGEST_MAX_TOTAL_SIZE_BYTES=$((10 * 1024 * 1024))
gitingest /path/to/repo          # CLI

Python picks these up automatically:

from gitingest import ingest
summary, tree, content = ingest("path/to/repo")

Precedence: CLI/Python arg → GITINGEST_* env var → default in config.py. Implementation is just a quick os.getenv check—no new deps, no breaking changes.


Optional: repo-level config

If you’d rather commit defaults, we could also parse a .gitingest.toml (or [tool.gitingest] in pyproject.toml). Env vars / flags would still win.


Quick questions

  1. Do you mostly use the CLI, the Python API, or both?
  2. Are env vars enough, or would a dot-file help too?

(FYI: recursive submodules are disabled by default since PR https://github.com/cyclotruc/gitingest/pull/209 and an opt-in flag is in PR https://github.com/cyclotruc/gitingest/pull/221.)

Thanks again! Keen to hear what fits your workflow best!

filipchristiansen avatar Jun 21 '25 10:06 filipchristiansen

@filipchristiansen thanks for taking a look at the issue!

I see the max_file_size as an option in the ingest call, thanks for the pointer. I think surfacing the rest of them that way would be great! I generally use it through Python API calls so its actually easier this way actually.

Just for background, I use it as a function in shell-gpt

adityakavalur avatar Jun 21 '25 14:06 adityakavalur

Thanks for the extra context, @adityakavalur! 🙌

I’ve assigned the issue to myself and will tackle it soon. Here’s the plan:

  1. Python API – surface every config.py constant as a keyword argument in ingest(), mirroring the existing max_file_size.
  2. Environment variables – support matching GITINGEST_* env vars so both the Python API and the CLI can pick them up transparently.
  3. CLI flags – add equivalent --flag options for each constant, giving one-liner control without exporting env vars.
  4. Docs/examples – update both Python and CLI snippets to showcase the new knobs.

I should have a PR up shortly. Thanks again for the suggestion! 🎉

filipchristiansen avatar Jun 21 '25 15:06 filipchristiansen

See my other application

Cheelax avatar Jun 28 '25 13:06 Cheelax

@Cheelax Is going to be working on this, Thanks a lot! Looking forward to the pr

cyclotruc avatar Jul 04 '25 10:07 cyclotruc

Hi there! We haven’t seen activity here for 45 days, so I’m marking this issue as stale. If you’d like to keep it open, please leave a comment within 10 days. Thanks!

github-actions[bot] avatar Aug 19 '25 06:08 github-actions[bot]

Hi there! We haven’t heard anything for 10 days, so I’m closing this issue. Feel free to reopen if you’d like to continue the discussion. Thanks!

github-actions[bot] avatar Aug 31 '25 06:08 github-actions[bot]