mpfaffenberger / mpfaffenberger/code_puppy

Six core runtime files exceed the 600-line hard cap (config.py is 2151 lines)

Open
#397 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
814
Forks
278
Avg merge
2d 5h
Merged PRs (30d)
76

Description

Problem

CONTRIBUTING.md rule 3 states a 600-line hard cap — split into submodules. The core runtime/model layer violates it six times over:

File Lines
code_puppy/config.py 2151
code_puppy/callbacks.py 1147
code_puppy/cli_runner.py 1134
code_puppy/model_factory.py 986
code_puppy/claude_cache_client.py 843
code_puppy/gemini_model.py 840

Why it matters

  • config.py is a grab-bag of ~80 getters/setters spanning XDG paths, model settings, banner colors, autosave/TTY session tracking, API keys, and command history — at least six unrelated concerns in one module.
  • callbacks.py duplicates its PhaseType Literal (~55 entries) in the hand-maintained _callbacks dict (lines 6–111); these can drift. It could be _callbacks = {p: [] for p in typing.get_args(PhaseType)}.
  • cli_runner.py:interactive_mode is a ~700-line god function (see separate issue).
  • model_factory.py:ModelFactory.get_model is a ~450-line if/elif chain over model types; a dispatch table ({"openai": _build_openai, "anthropic": _build_anthropic, ...}) would make each builder independently testable and let the plugin handler path share the same mechanism it already uses for custom types.

Suggested fix

Split along existing seams, e.g.:

  • config/ package: paths.py, core.py (get_value/set_value), model_settings.py, sessions.py, colors.py, toggles.py — re-export from config/__init__.py to preserve the public API.
  • model_factory.py: extract one _build_<type>() function per model type into model_builders.py and dispatch via a dict.
  • callbacks.py: derive _callbacks from get_args(PhaseType) and consider grouping the thin on_* wrappers.

Filed by Zen Reviewer A (code-puppy-60635a)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with rule 3 in CONTRIBUTING.md, then map imports and public APIs for config.py, callbacks.py, cli_runner.py, model_factory.py, claude_cache_client.py, and gemini_model.py. Review the proposed config/ package and model builder seams before changing structure. Done means the six runtime files are split below 600 lines without breaking their public APIs or behavior; run the repository’s existing checks afterward.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.