Populate the suggested command onto the shell prompt (#2) - #5
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2.
Replaces the
-rconfirm-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 bymaic --init zshand installed into~/.zshrc— captures it and usesprint -zto place it on your next prompt, editable and cursor-ready. Enter runs it in your interactive shell (so it lands in history andcd/exportstick), edits are free, Ctrl-C discards.-r/--runconfirm-then-run flow andRunConfirmation.-r/--runis now a deprecated no-op that warns on stderr rather than changing behaviour silently.clean()→MaicCore.cleanCommand; addedMaicCore.zshShellInit(both unit-tested).install.shwires the integration into~/.zshrcidempotently, with a trailing-newline guard and aMAIC_NO_SHELL_INIT=1opt-out. Non-interactive / piped /$(…)use falls back to plainprint, sox=$(maic …)keeps working.cleanCommandand 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 letscd/exportpersist.Testing
maicTestssuite (15 assertions) green.--initoutput parses (zsh -n),command maicrouting, non-TTY fallback prints to stdout, installer idempotency (repeated runs → one block), the newline guard, and the-rdeprecation notice.print -zpush was smoke-tested by hand in a real shell (isolatedzsh -f -iwith 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).