Skip to content

feat(plugins): add prompt_newline plugin with /prompt_newline toggle#321

Merged
mpfaffenberger merged 1 commit intompfaffenberger:mainfrom
mmcguff:feat/prompt-newline-plugin
May 6, 2026
Merged

feat(plugins): add prompt_newline plugin with /prompt_newline toggle#321
mpfaffenberger merged 1 commit intompfaffenberger:mainfrom
mmcguff:feat/prompt-newline-plugin

Conversation

@mmcguff
Copy link
Copy Markdown
Contributor

@mmcguff mmcguff commented May 6, 2026

🐶 feat(plugins): add prompt_newline plugin with /prompt_newline toggle

What

Adds a tiny opt-in ergonomics plugin that drops user input onto a fresh line below the puppy/agent/model/cwd prompt chrome. Helpful when your cwd is a 90-character monstrosity and there's no horizontal room left to type.

Before (default, unchanged):

🐶 puppy [code-puppy 🐶] [gpt-5] (~/long/path/to/project) >>> my task here

After enabling /prompt_newline on:

🐶 puppy [code-puppy 🐶] [gpt-5] (~/long/path/to/project) >>>
my task here

Why

Long working-directory paths squeeze the input area to nothing on standard terminal widths. A trailing newline on the prompt is the cheapest possible fix without redesigning the chrome. Some folks love it, some hate it — so it's off by default and toggleable per user, persisted in puppy.cfg.

How (per CONTRIBUTING.md)

This is a plugin, not a core change. Lives entirely under code_puppy/plugins/prompt_newline/ and uses three documented hooks from code_puppy/callbacks.py:

Hook Purpose
startup Monkey-patches get_prompt_with_active_model to optionally append ("", "\n") to the returned FormattedText. The wrapper re-checks is_enabled() at call time, so the slash-command toggle takes effect immediately — no restart.
custom_command Handles /prompt_newline [on|off|toggle]. Bare /prompt_newline flips the current state.
custom_command_help Adds the command to /help.

State is persisted to puppy.cfg via the existing get_value / set_config_value helpers (mirrors the dbos_durable_exec plugin pattern). Default is OFF — opting in is a one-line PR-from-the-user's perspective.

The monkey-patch is idempotent (guarded by a sentinel attribute) and fail-soft (any exception in the wrapper falls back to the original FormattedText, never crashes the prompt).

Files

code_puppy/plugins/prompt_newline/__init__.py            # docstring only
code_puppy/plugins/prompt_newline/config.py              # is_enabled / set_enabled
code_puppy/plugins/prompt_newline/register_callbacks.py  # hook registration
tests/plugins/test_prompt_newline_plugin.py              # 12 test cases

Total: 378 LOC (well under the 600-line cap; no file approaches it).

Tests

12 new test cases in tests/plugins/test_prompt_newline_plugin.py covering:

  • /help entry registration
  • Custom-command name routing (ignores other commands)
  • All toggle-arg parsing variants (on/off/true/false/1/0/yes/no/enable/disable/toggle)
  • Garbage-arg rejection
  • _append_newline purity (doesn't mutate the original FormattedText)
  • _install_prompt_patch idempotency + original-function preservation
  • Patched prompt appends newline only when is_enabled() returns True
  • Explicit on persists to puppy.cfg
  • Bare /prompt_newline flips state correctly
  • Default state is OFF
  • Garbage arg surfaces an error and doesn't change config
50 passed, 1 xpassed in 11.94s

(Also re-ran tests/test_prompt_toolkit_completion.py to confirm zero regressions in the patched module.)

Lint

ruff check --fix and ruff format both clean.

Backwards compatibility

Zero behavior change for existing users. Default is OFF; users must opt in with /prompt_newline on.

Future work (not in this PR)

If demand materializes, the same plugin could grow:

  • Env-var override (CODE_PUPPY_PROMPT_NEWLINE=1)
  • /set prompt_newline true integration via the existing settings completer
  • Configurable separator (e.g. blank line vs glyph)

Intentionally YAGNI'd for now.

Tiny ergonomics hack: when enabled, drops user input onto a fresh line
below the puppy/agent/model/cwd prompt chrome so long cwd paths don't
squeeze the typing area.

* New plugin: code_puppy/plugins/prompt_newline/
* Hooks: startup (monkey-patches get_prompt_with_active_model),
  custom_command (/prompt_newline [on|off|toggle]), custom_command_help
* Persisted via puppy.cfg key 'prompt_newline'. Default: OFF.
* Toggle takes effect immediately (no restart) since the wrapper checks
  is_enabled() at call time.
* Tests: tests/plugins/test_prompt_newline_plugin.py (12 cases)
Copilot AI review requested due to automatic review settings May 6, 2026 18:09
@mpfaffenberger mpfaffenberger merged commit 36abe3f into mpfaffenberger:main May 6, 2026
5 of 6 checks passed
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.

2 participants