Skip to content

feat: add optional .gcoderc configuration file support - #48

Merged
shauryagangrade merged 2 commits into
shauryagangrade:mainfrom
aryansk:feat/gcoderc-config
Aug 14, 2026
Merged

feat: add optional .gcoderc configuration file support#48
shauryagangrade merged 2 commits into
shauryagangrade:mainfrom
aryansk:feat/gcoderc-config

Conversation

@aryansk

@aryansk aryansk commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Problem

Closes #15. GCode settings (default model, auto-approve, tool behavior) were
only configurable via command-line flags or environment variables — there was
no persistent file a user could edit across sessions.

Changes

  • New gcode/config.py: dependency-free loader for a .gcoderc file in the
    project root (or ~/.gcode/.gcoderc for user-wide defaults). Simple
    key = value format with # comments; bool/int/string values are parsed.
  • Supported keys: model, auto_approve, bash_timeout, system_prompt.
  • Precedence is documented and enforced: CLI flag / env var > config file >
    built-in default (--model/GCODE_MODEL beat model, --yes beats
    auto_approve).
  • gcode/tools.py: set_bash_timeout() lets the config override the bash
    tool's 300s default.
  • gcode/cli.py: startup loads the config, resolves the model, auto-approve,
    timeout, and system prompt (used for new and cleared sessions).
  • README: new "Configuration file" section with a table of supported keys.

Validation

  • pytest: 53 passed (7 new tests covering parsing, precedence, and
    fallbacks)
  • ruff check / ruff format --check / mypy gcode / compileall: all clean
  • Live: a sample .gcoderc is parsed and its model resolved correctly

@aryansk
aryansk force-pushed the feat/gcoderc-config branch from bdb1c38 to 0fc183d Compare August 14, 2026 15:04
@shauryagangrade

Copy link
Copy Markdown
Owner

Hi — reviewing this. Two things before it can merge:

  1. Stale branch + merge conflict. The branch is based on e4e062e, before fix: make common errors actionable with next-step hints #47 landed. Please rebase (or merge main) in. The only conflict is a trivial import-block collision in gcode/cli.py — both #47s merge and this branch add imports at the top of the same block. Fix: keep both import blocks (the gcode.config one from this branch and the gcode.errors one from fix: make common errors actionable with next-step hints #47). Everything else merges cleanly.

  2. Docstring nit (not blocking): gcode/config.py module docstring says it reads ~/.gcode/config, but the code and PR body use ~/.gcode/.gcoderc (USER_CONFIG_PATH). Minor inconsistency — worth aligning.

Nice, focused feature otherwise — clean precedence rules, good test coverage. cc @aryansk

Closes shauryagangrade#15. A .gcoderc in the project root (or ~/.gcode/.gcoderc)
can set model, auto_approve, bash_timeout, and system_prompt. CLI
flags and env vars still take precedence; format is simple key = value
with # comments. 7 new tests.
@aryansk
aryansk force-pushed the feat/gcoderc-config branch from 0fc183d to 4879df6 Compare August 14, 2026 15:33
The loader reads ~/.gcode/.gcoderc, not ~/.gcode/config.
@shauryagangrade
shauryagangrade marked this pull request as ready for review August 14, 2026 15:37
@shauryagangrade
shauryagangrade merged commit 37a5c3b into shauryagangrade:main Aug 14, 2026
6 checks passed
@aryansk

aryansk commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Both points are addressed in the merged head 54faa77: the branch was rebased onto current main (keeping both import blocks — gcode.config from this change and gcode.errors from #47), and the module docstring now reads ~/.gcode/.gcoderc to match USER_CONFIG_PATH. Thanks for the review and for merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add configuration file support (.gcoderc)

2 participants