Skip to content

feat(cli): allow send --if done - #401

Open
rimumomuri wants to merge 2 commits into
herdrdev:masterfrom
rimumomuri:send-if-done
Open

rimumomuri wants to merge 2 commits into
herdrdev:masterfrom
rimumomuri:send-if-done

Conversation

@rimumomuri

Copy link
Copy Markdown

Closes #154. A fresh take on #164 (by @dlucik), rebased on current master as suggested when it was closed. The change is the same; credit for the approach goes there.

Programs that report done at the end of a turn and stay there (Claude Code does) cannot get a guarded follow-up today: --if done fails argument parsing, and --if idle gives status_mismatch. The only option left is a send with no condition, which also types into the shell once the program has exited.

Still reproducible on hc 0.1.22 (macOS arm64):

$ hc send --if done t7 "next"
{"error":{"kind":"usage","message":"invalid value 'done' for '--if <STATUS>' [possible values: idle, working]"}}

The input path already compares the status word under the same lock, so only the type changes:

  • IdleOrWorking becomes SendIf with idle | working | done (CLI --if and terminal.send if).
  • blocked is unchanged: it is refused without --force and is not a value of if.
  • schema/hc.openrpc.json is regenerated (additive for clients of the released API), docs/commands.md is refreshed, and the manual gets one line.
  • One end-to-end test: a program that stays done refuses --if idle without typing, and accepts --if done both through the CLI and through terminal.send. It fails on master and passes with the change.

Checks on macOS arm64 (Rust 1.95.0, Zig 0.16.0): cargo fmt --check, cargo clippy -D warnings (native and the Windows type-check from just lint), just docs-check, and cargo test --locked (561 passed) all pass. cargo deny was not run because there are no dependency changes.

@NetDevAutomate

Copy link
Copy Markdown

A second use case for this, from a coordinator rather than a person: Answerback assigns work to agents running in hc terminals and wants to send a follow-up task to an interactive agent after it finished the first. hc get shows done (the agent's own OSC 7501 word), which stays done until the agent reports again, so --if idle refuses and the only alternative is an unconditional send that is typed even if the agent began a turn on its own in between.

I built the same change independently on 329cb66 before finding this PR, and the type, schema and docs/commands.md diffs came out byte-identical. On macOS arm64 (Zig 0.16.0) the full cargo test --locked passes with it, and these extra checks also pass against this branch: --if done refuses a working program and an idle one with status_mismatch and types nothing. The old-core behaviour is fail-closed: a 0.1.22 core rejects "done" with invalid_params, so a client can probe hc schema and fall back.

# Conflicts:
#	crates/herdr-core/src/SKILL.md
#	schema/hc.openrpc.json

This branch has not been deployed

No deployments
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.

terminal.send: allow if: "done" so a client can send a guarded follow-up after a finished turn

2 participants