Skip to content

Populate the suggested command onto the shell prompt (#2) - #5

Merged
emarref merged 1 commit into
mainfrom
2-populate-command-at-prompt
Jul 27, 2026
Merged

Populate the suggested command onto the shell prompt (#2)#5
emarref merged 1 commit into
mainfrom
2-populate-command-at-prompt

Conversation

@emarref

@emarref emarref commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Closes #2.

Replaces the -r confirm-then-run flow with the design agreed during triage: maic never runs anything itself — it hands you the command, on your prompt, to run/edit/discard.

What changed

  • maic <task> now prints exactly one command. A small zsh function — emitted by maic --init zsh and installed into ~/.zshrc — captures it and uses print -z to place it on your next prompt, editable and cursor-ready. Enter runs it in your interactive shell (so it lands in history and cd/export stick), edits are free, Ctrl-C discards.
  • Removed the -r/--run confirm-then-run flow and RunConfirmation. -r/--run is now a deprecated no-op that warns on stderr rather than changing behaviour silently.
  • Moved clean()MaicCore.cleanCommand; added MaicCore.zshShellInit (both unit-tested).
  • install.sh wires the integration into ~/.zshrc idempotently, with a trailing-newline guard and a MAIC_NO_SHELL_INIT=1 opt-out. Non-interactive / piped / $(…) use falls back to plain print, so x=$(maic …) keeps working.
  • Updated README + build.sh; retargeted the test harness onto cleanCommand and the emitted shell function.

Why a shell function (not all in the binary)

A child process can't type into its parent shell's line editor — so the command is handed back to zsh via print -z, which is also what makes it land in history and lets cd/export persist.

Testing

  • Release build (matches CI) + full maicTests suite (15 assertions) green.
  • Verified non-interactively: --init output parses (zsh -n), command maic routing, non-TTY fallback prints to stdout, installer idempotency (repeated runs → one block), the newline guard, and the -r deprecation notice.
  • The interactive print -z push was smoke-tested by hand in a real shell (isolated zsh -f -i with this build first on PATH) — command lands on the prompt, edits/Enter/Ctrl-C behave, and it shows up under up-arrow / Ctrl-R.

Out of scope (per the agreed brief)

Any auto-run/unattended mode; the old single-key/ESC/Tab/termios/custom-channel machinery; non-zsh shells (fall back to plain print).

maic no longer runs commands itself. `maic <task>` now prints exactly one
command; a small zsh function (emitted by `maic --init zsh`, installed into
~/.zshrc) captures it and uses `print -z` to place it on the next prompt —
editable and cursor-ready. Enter runs it in the interactive shell (so it
lands in history and cd/export stick), edits are free, Ctrl-C discards.
Nothing runs on its own.

- Remove the -r/--run confirm-then-run flow and RunConfirmation; -r is now a
  deprecated no-op that warns on stderr rather than changing behaviour silently.
- Move clean() -> MaicCore.cleanCommand; add MaicCore.zshShellInit.
- install.sh wires the integration into ~/.zshrc idempotently (skip with
  MAIC_NO_SHELL_INIT=1); non-interactive / piped / $(...) use falls back to
  plain print so capture keeps working.
- Update README + build.sh; retarget the test harness onto cleanCommand and
  the emitted shell function.

Closes #2.
@emarref
emarref merged commit 2a9eb22 into main Jul 27, 2026
1 check 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.

Populate the suggested command onto the shell prompt (editable, no auto-run) via a zsh function

1 participant