Skip to content

feat(em): add agy (Antigravity CLI) as em-ai backend - #491

Merged
Data-Wise merged 1 commit into
devfrom
feature/em-agy-backend
Jul 7, 2026
Merged

Data-Wise merged 1 commit into
devfrom
feature/em-agy-backend

Conversation

@Data-Wise

Copy link
Copy Markdown
Owner

Summary

  • Adds agy (Antigravity CLI) as the primary fallback AI backend in em's AI abstraction layer, ahead of gemini in the chain (claude → agy → gemini → none). Google's gemini CLI is deprecated upstream in favor of Antigravity; gemini is kept, not removed, for existing FLOW_EMAIL_AI=gemini configs.
  • agy needs a validation wrapper, not a drop-in swap: it has no clean-output flag (appends an unrequested markdown status block to every response) and has been observed to exit 0 with a canned "system operational" response on degenerate input rather than failing loudly. New _em_ai_agy_clean_output/_em_ai_agy_looks_valid helpers strip and sanity-check its output before use; a failed check falls through to the existing fallback chain.
  • Fixes a more serious bug found during live verification: capturing agy's output via $(...) command substitution hangs or dies silently, independent of timeout — agy leaves a descendant process attached to its stdout pipe, so $(...) blocks waiting for an EOF that never comes. Fixed by routing output through a temp file instead of $(...).
  • Updates doctor's health check and the full doc surface documenting the --backend/FLOW_EMAIL_AI option set: EMAIL-DISPATCHER-GUIDE.md, EMAIL-COOKBOOK.md, docs/commands/doctor.md, MASTER-DISPATCHER-GUIDE.md, MASTER-API-REFERENCE.md, MASTER-ARCHITECTURE.md, REFCARD-EMAIL-DISPATCHER.md, QUICK-REFERENCE.md, docs/tutorials/46-em-v2-features.md, man/man1/em.1, root + docs CHANGELOG.md. Left docs/specs/* (historical, point-in-time) and docs/tutorials/33-himalaya-email.md's himalaya.nvim :HimalayaAi setting (a separate editor plugin, not em) untouched.
  • Registered tests/test-em-ai-switch.zsh in run-all.sh, which had never been wired into the suite.

Test plan

  • tests/test-em-ai-switch.zsh — 24/24 pass (added agy switch/toggle/extra_args cases)
  • tests/test-em-ai-agy.zsh (new) — 8/8 pass (clean-output stripping + canned-response validation)
  • ./tests/run-all.sh — 77 passed, 0 failed, 0 timeout, 1 skipped (expected — e2e-em-dispatcher skips when the external tool is absent, matches documented baseline). Ran twice for consistency.
  • mkdocs build --strict — clean, run twice (before and after the second docs pass), 0 warnings both times.
  • Live e2e: _em_ai_execute agy "..." "..." 15 classify verified against the real agy binary post-fix — returns hello/EXIT:0 cleanly through the actual code path (pre-fix: hung/died silently, reproduced 3x).

🤖 Generated with Claude Code

…legacy

Adds agy ahead of gemini in the em-ai fallback chain (claude -> agy ->
gemini -> none), since Google's gemini CLI is deprecated upstream in
favor of Antigravity. gemini is retained, not removed, for existing
FLOW_EMAIL_AI=gemini configs.

agy requires a validation wrapper, not a drop-in swap: it has no
clean-output flag (appends an unrequested markdown status block to
every response) and has been observed to exit 0 with a canned
"system operational" response on degenerate input rather than failing
loudly. _em_ai_agy_clean_output/_em_ai_agy_looks_valid strip and
sanity-check its output before use.

Also fixes a more serious bug found during live verification: capturing
agy's output via $(...) command substitution hangs or dies silently,
independent of `timeout` -- agy leaves a descendant process attached to
its stdout pipe, so $(...) blocks waiting for EOF that never comes.
Fixed by routing output through a temp file instead.

Updates doctor's health check and the full doc surface for the
--backend/FLOW_EMAIL_AI option set (guide, cookbook, doctor reference,
master dispatcher/API/architecture docs, refcard, quick reference,
tutorial, man page, changelog) -- left docs/specs/* (historical) and
himalaya.nvim's separate :HimalayaAi gemini setting untouched.

Also registers tests/test-em-ai-switch.zsh in run-all.sh, which had
never been wired into the suite.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Data-Wise
Data-Wise merged commit f55fd36 into dev Jul 7, 2026
2 checks passed
@Data-Wise
Data-Wise deleted the feature/em-agy-backend branch July 7, 2026 17:15
Data-Wise pushed a commit that referenced this pull request Jul 7, 2026
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Data-Wise added a commit that referenced this pull request Jul 7, 2026
…492)

PR #491 added agy as an em-ai backend but only updated commands/doctor.zsh
(flow doctor). em() has its own separate, duplicate help text (_em_help)
and inline dependency check (_em_doctor) that still showed
--backend claude|gemini with no agy option. Fixes both, keeps gemini
labeled as legacy consistent with the rest of that PR.

Co-authored-by: Test User <test@example.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
@Data-Wise Data-Wise mentioned this pull request Jul 7, 2026
4 tasks done
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.

1 participant