feat(tools): add P2 typed CLI-text read tools (TP-3) - #135
Merged
Conversation
Add the benign-only cli_typed helper (TP-3) and four USB-only typed CLI-text read tools that parse device output into structure: core_status (free+uptime), fs_tree (storage tree), loader_list, and i2c_scan. Each returns raw output alongside the parsed fields; all raise the typed CLI-unavailable error over the WiFi bridge. Parsers are grounded in real device output captured over USB (Momentum): the i2c parser maps the scan grid's (row, column) position to the 7-bit address rather than matching literal 0x.. tokens. crypto_status from the plan is deferred: the device crypto command is a usage dump with no benign read-only status subcommand. Extends the GATE map and regenerates the tool-schema matrix (28 tools). Unit tests assert the parsers against captured output and the WiFi refusal; integration tests (usb-marked) exercise the live reads. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Constrain the i2c grid row regex to 0-7 and bound columns to 16 so malformed output cannot surface addresses outside the 7-bit space. Add tests for multi-device i2c, out-of-range rows, the fs_tree truncated path, and the gated-command refusal in cli_typed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
Review summary (/review-pr)Parallel agents: code-quality, silent-failure, test-coverage. Must-fix: none. The feared Fixed in 4a385aa:
Gates: ruff + ty clean, 281 passed / 13 deselected. Deferred to followup (not blocking): device-unreachable path test for the shared |
This was referenced Jun 23, 2026
millsmillsymills
added a commit
that referenced
this pull request
Jun 23, 2026
Add device-unreachable and catch-all error-path tests for the shared cli_typed helper, asserting it surfaces a ToolError rather than an implicit None on any failure. Add ANSI-bearing fixtures exercising the _strip_ansi path in the free/i2c/tree parsers and fix the inaccurate _FREE comment. Cover _parse_tree edges: a file row with no trailing size, and the leading-escape depth limitation. Closes #136 Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Implements the P2 band and its TP-3 prerequisite from
docs/superpowers/plans/2026-06-23-tool-coverage-to-90pct.md. P0/P1 landed in #130; this is the next phase.What's here
cli_typedhelper (tools/_common.py): benign-only wrapper overclient.cli_exec, reusing the existing_io_lock-held exchange. It refuses any gated command, so a transmit/destructive subcommand can never hide behind a typed tool.tools/cli_typed.py, gatenone, USB-only):flipperzero_core_status—free+uptime→ heap fields,heap_free_bytes, uptime.flipperzero_fs_tree—storage tree <path>→ depth-tagged file/dir entries,complete/truncated.flipperzero_loader_list—loader list→ app names.flipperzero_i2c_scan—i2c→ responding 7-bit addresses.outputalongside parsed fields (firmware CLI text is free-form/unversioned).CLI text mode unavailableerror over the WiFi bridge (TP-2).Grounded in real device output
Parsers were built and validated against output captured live over USB (Momentum firmware), and the four tools were exercised end-to-end through the MCP server against the device. Notably the
i2coutput is a positional grid, notFound: 0x..lines — the parser maps each non--cell's (row, column) to its 7-bit address.Deferred (intentional)
crypto_status(5th P2 tool in the plan): the devicecryptocommand is a usage dump (encrypt/decrypt/has_key/store_key) with no benign read-only status subcommand. Shipping it would return raw help text, which the plan's §1 says does not earn coverage. Left out pending a real read command.Coverage
P2 lands +4 (not +5) typed counting tools → matrix now 28 registered tools, new
cli_typedgroup.Tests
tests/unit/test_tool_cli_typed.py— parser tests against real captured output (incl. the i2c grid and the app-openuptimecase) + WiFi refusal.tests/integration/test_cli_typed_reads.py—usb-marked live reads.Note
While capturing reference output, a
storage tree /ext(whole volume) flooded USB and briefly wedged the CLI link mid-stream — it recovered on its own.fs_tree's docstring warns to pass a specific subdirectory; bounding large-tree captures cleanly is the TP-4a streaming-primitive work in a later phase.🤖 Generated with Claude Code