diff --git a/README.md b/README.md index 70447fce..7cb1174a 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,7 @@ Sipeed has given strong support to HSync's work on its SLogic analyzers. ### Command line & automation (`hsync-cli`) - **Standalone headless CLI (`hsync-cli`)** for scripts, hardware-in-the-loop tests and AI coding agents: `doctor`, `devices`, `catalog`, declarative `capture` (with `--trigger-timeout`, `--fallback-instant`, memory guardrails and `--exec` arm-then-act DUT stimulation), L0 signal `inspect`, L1/L2 `decode` (shorthand pipelines, summaries, structured `--where` filters, compact protocol transcripts and NDJSON), L3 `transitions`, Unicode `wave`, `measure` (pulses, edges, glitches, cross-channel deltas), `search` and `export`. +- **Built-in stateful MCP server (`hsync-cli mcp`)** over stdio JSON-RPC 2.0: keeps USB analyzers and captures open in memory across multi-turn agent sessions, exposes two-phase `capture_arm` / `capture_collect` and hot-loading custom `uiharu` DSL IR modules. - **Structured `--json` mode** across every command (including dual sample/time coordinates and actionable error hints) plus a ready-to-use Agent Skill in [skills/hsync-cli/SKILL.md](skills/hsync-cli/SKILL.md). See the [CLI guide](docs/cli.md). ## Download diff --git a/README.zh-CN.md b/README.zh-CN.md index b25066a4..4b0c14de 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -102,6 +102,7 @@ SLogic 系列逻辑分析仪的适配得到了矽速科技(Sipeed)的大力 ### 命令行与自动化(`hsync-cli`) - **独立无头命令行工具(`hsync-cli`)**,面向脚本、硬件在环测试与 AI Agent:涵盖 `doctor`、`devices`、`catalog`、声明式 `capture`(支持 `--trigger-timeout`、`--fallback-instant`、内存护栏与 `--exec` 先武装后激励协同)、L0 信号体检 `inspect`、L1/L2 `decode`(简写流水线、解码摘要、结构化 `--where` 过滤、紧凑协议视图与 NDJSON)、L3 `transitions` / Unicode `wave` / `measure`(脉宽、边沿、毛刺、跨通道延迟)、`search` 与 `export`。 +- **内置有状态 MCP 服务器(`hsync-cli mcp`)**(stdio JSON-RPC 2.0):在多轮 Agent 会话期间保持 USB 逻辑分析仪常驻与采集数据驻留内存,提供两阶段 `capture_arm` / `capture_collect` 与自定义 `uiharu` DSL IR 模块热加载。 - **全局 `--json` 结构化输出**(统一双坐标系与可恢复错误提示),并在 [skills/hsync-cli/SKILL.md](skills/hsync-cli/SKILL.md) 提供官方 Agent Skill。参见[命令行指南(英文)](docs/cli.md)。 ## 下载 diff --git a/crates/hsync-cli/src/commands/capture.rs b/crates/hsync-cli/src/commands/capture.rs index 676bb1be..d3886d56 100644 --- a/crates/hsync-cli/src/commands/capture.rs +++ b/crates/hsync-cli/src/commands/capture.rs @@ -37,16 +37,16 @@ use crate::units::{ }; /// Default memory guardrail (512 MiB) so an agent cannot accidentally allocate gigabytes. -const DEFAULT_MAX_MEMORY: u64 = 512 * 1024 * 1024; -const DEFAULT_TRIGGER_TIMEOUT: Duration = Duration::from_secs(10); +pub const DEFAULT_MAX_MEMORY: u64 = 512 * 1024 * 1024; +pub const DEFAULT_TRIGGER_TIMEOUT: Duration = Duration::from_secs(10); /// Floor of the default `--timeout`. -const DEFAULT_TOTAL_TIMEOUT: Duration = Duration::from_secs(60); +pub const DEFAULT_TOTAL_TIMEOUT: Duration = Duration::from_secs(60); /// Fixed allowance of the default `--timeout` for arming, upload and saving. const TOTAL_TIMEOUT_MARGIN: Duration = Duration::from_secs(10); /// How long a capture may take to end after it was told to stop before the CLI gives up on it. const STOP_GRACE: Duration = Duration::from_secs(10); /// How long `--exec` may keep running after a capture ends before it is killed. -const DEFAULT_EXEC_GRACE: Duration = Duration::from_secs(10); +pub const DEFAULT_EXEC_GRACE: Duration = Duration::from_secs(10); const EXEC_OUTPUT_CAP: usize = 4096; /// How long `--exec` output readers may keep draining after the command has exited. const EXEC_DRAIN: Duration = Duration::from_millis(500); @@ -89,6 +89,7 @@ hsync-cli capture [options] length x1.5 + trigger timeout + 10s, at least 60s) --fallback-instant On trigger timeout, take a short instant snapshot to inspect idle levels --exec Arm-then-act: run shell command once capture is armed/started + (its stdin is empty) --exec-grace