Skip to content

Commit 69e23eb

Browse files
taroteneclaude
andcommitted
feat(shell): add --exec flag; fix broken firmware-ping just recipe
`just firmware-ping` was invoking `cargo run -- ping` which fails immediately because `ping` was removed as a CLI subcommand in #51 (the shell became a discovery-driven REPL). This PR fixes that by adding `--exec <COMMAND>` to telepath-shell for non-interactive single-command execution, and rewiring firmware-ping to use it with a sentinel grep so wire-format skew fails loudly. AGENTS.md is updated to prompt the developer to run `just firmware-ping` on PRs touching wire / macros / server / client / shell / nrf52840-ping. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 5db88e2 commit 69e23eb

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

AGENTS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ Changes to the macro MUST NOT break existing callers on stable toolchain.
140140
- Feature branches MUST be created before any code change.
141141
- PRs MUST reference the corresponding GitHub Issue.
142142
- `examples/nrf52840-ping/` changes SHOULD be a separate commit from workspace changes.
143+
- PRs that touch any of the following SHOULD be smoke-tested with `just firmware-ping`
144+
against a connected nRF52840-DK before requesting review, and the result recorded in
145+
the PR description's Test plan section:
146+
- `telepath-wire/`, `telepath-macros/`, `telepath-server/`, `telepath-client/`
147+
- `tools/telepath-shell/`
148+
- `examples/nrf52840-ping/`
149+
150+
This catches FW/host wire-format skew that `just ci` alone cannot detect without hardware.
143151

144152
## Toolchain
145153

@@ -158,3 +166,5 @@ git config --local core.hooksPath .githooks
158166
- `pre-commit``just fmt-check` (sub-second; runs on every commit)
159167
- `pre-push``just clippy` + `just test` (~30 s; runs before every push)
160168
- `just ci` (fmt-check + clippy + test + emulator) SHOULD be run before opening a PR.
169+
- `just firmware-ping` SHOULD additionally be run when the PR touches wire / macros /
170+
server / client / shell / nrf52840-ping (see "Commit and PR Rules" above).

Justfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ cli-build:
3838
cli *ARGS:
3939
cd tools/telepath-shell && cargo run -- {{ARGS}}
4040

41-
# End-to-end smoke test: flash then ping
41+
# Local end-to-end smoke: rebuild FW, flash, run `ping` once, assert sentinel.
42+
# Requires nRF52840-DK connected. Catches wire-format skew between FW and host.
4243
firmware-ping: firmware-flash
43-
cd tools/telepath-shell && cargo run -- ping
44+
cd tools/telepath-shell && cargo run -- --exec ping | tee /tmp/telepath-firmware-ping.out
45+
grep -qF "ping -> 0xDEADBEEF" /tmp/telepath-firmware-ping.out
4446

4547
# Build telepath-mcp-server
4648
mcp-build:

tools/telepath-shell/src/main.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ struct Cli {
6868
/// By default, telepath-shell issues a soft reset and retries the attach once.
6969
#[arg(long)]
7070
no_reset: bool,
71+
72+
/// Execute a single command non-interactively and exit.
73+
/// The argument uses the same syntax as the interactive REPL prompt:
74+
/// `ping`, `add 1 2`, `led_set 1 true`, etc.
75+
/// Exit code is non-zero if discovery or the command itself fails.
76+
#[arg(long, value_name = "COMMAND")]
77+
exec: Option<String>,
7178
}
7279

7380
fn parse_hex_u64(s: &str) -> Result<u64, String> {
@@ -122,6 +129,16 @@ fn main() -> anyhow::Result<()> {
122129
)
123130
})?;
124131
client.transport_mut().clear_read_deadline();
132+
133+
if let Some(line) = cli.exec.as_deref() {
134+
let line = line.trim();
135+
let mut parts = line.splitn(2, char::is_whitespace);
136+
let name = parts.next().unwrap_or("");
137+
let rest = parts.next().unwrap_or("").trim();
138+
dispatch_command(&mut client, name, rest)?;
139+
return Ok(());
140+
}
141+
125142
println!("{n} command(s) discovered (Ctrl-D / Ctrl-C to exit)");
126143

127144
let mut commands: Vec<String> = client

0 commit comments

Comments
 (0)