tyc-cli 0.2.5 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,34 @@
2
2
 
3
3
  本项目遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/) 规范,版本号遵循 [Semantic Versioning](https://semver.org/lang/zh-CN/)。
4
4
 
5
+ ## [0.4.0] - 2026-05-03
6
+
7
+ ### 新增
8
+
9
+ - **输出格式三选一**(互斥优先级 `--md` > `--compact` > `--pretty` / 默认):
10
+ - `--compact`:紧凑单行 JSON(旧默认行为;管道 / `jq` 场景)
11
+ - 默认改为缩进 2 空格 JSON(pretty),人/Agent 通用
12
+ - `--pretty`:同默认;保留 flag 以保持向后兼容 / 显式声明意图
13
+ - `--md`:Markdown 表格(人类阅读 / Agent 上屏;自动渲染 `_summary` / 元数据 / `items` 表格)
14
+ - **截断与落盘**(与输出格式正交,可叠加任意子命令):
15
+ - `--head [N]`(默认 50):仅打印前 N 行;与 `--tail` 同时给则同时输出两端
16
+ - `--tail [M]`(默认 20):仅打印后 M 行
17
+ - `--full`:强制完整输出(最高优先级,覆盖 `--head/--tail/--threshold`)
18
+ - `--threshold <BYTES>`(默认 5000):**字节截断主开关**——超过该字节数从头按字节截断;**不传则永不截断**;与 `--head/--tail` 同时给则按字节截,行参数被忽略
19
+ - `--output-file <PATH>`:把完整结果写入指定路径;**必须显式指定才落盘**(不传则永不落盘)
20
+ - 截断/落盘提示打到 stderr,stdout 保持纯净数据流,便于管道与 `jq` 处理
21
+
22
+ ### 变更
23
+
24
+ - 默认 stdout 由紧凑单行 JSON 改为缩进 2 空格 JSON。需要旧默认行为的脚本请显式加 `--compact`
25
+
26
+ ## [0.3.0] - 2026-04-29
27
+
28
+ ### 新增
29
+
30
+ - **分层发现入口**:`tyc layers` / `tyc L0 list` / `tyc L1 list` / `tyc L2 list`,支持 `--md` / `--json`
31
+ - 每个 tool 的 `tyc ... --help` 标题带 `[L0]/[L1]/[L2]` 徽章,让 Agent 先看结构、后发一次 `tools/call`
32
+
5
33
  ## [0.2.0] - 2026-04-27
6
34
 
7
35
  ### 架构重构
package/README.md CHANGED
@@ -100,13 +100,58 @@ tyc executive personnel-dishonest "..." --humanName "张三"
100
100
 
101
101
  ### 全局选项
102
102
 
103
+ #### 输出格式(互斥优先级 `--md` > `--compact` > `--pretty` / 默认)
104
+
103
105
  | 选项 | 说明 |
104
106
  |------|------|
105
- | `--pretty` | 缩进 2 空格 JSON 输出(调试友好) |
107
+ | _(默认)_ | 缩进 2 空格 JSON(pretty)—— 人/Agent 都好读,已成默认 |
108
+ | `--pretty` | 同默认;保留 flag 以保持向后兼容 / 显式声明意图 |
109
+ | `--compact` | 紧凑单行 JSON(旧默认行为;管道 / `jq` 场景) |
106
110
  | `--md` | Markdown 表格化输出(人类阅读 / Agent 上屏) |
107
- | `--verbose` | 打印 MCP 请求详情到 stderr(URL / Mcp-Session-Id / 掩码 Authorization / 响应原文) |
111
+ | `--verbose` | 打印 MCP 请求详情到 stderr(与上述输出格式正交) |
112
+
113
+ #### 输出截断 / 落盘(与上述输出格式正交,可叠加任意子命令)
114
+
115
+ | 选项 | 默认值 | 说明 |
116
+ |------|-------:|------|
117
+ | `--head [N]` | 50 | 仅打印前 N 行;与 `--tail` 同时给则同时输出两端,否则只输出 head |
118
+ | `--tail [M]` | 20 | 仅打印后 M 行;与 `--head` 同时给则同时输出两端 |
119
+ | `--full` | false | 强制完整输出(最高优先级,覆盖 `--head/--tail/--threshold`) |
120
+ | `--threshold <BYTES>` | 5000 | **字节截断主开关**:超过该字节数则从头按字节截断;**不传则永不截断** |
121
+ | `--output-file <PATH>` | — | 把完整结果写入指定路径;**不传则永不落盘**(无自动落盘) |
122
+
123
+ > ⚠️ **截断决策树(与 stdout / 落盘行为)**
124
+ >
125
+ > 1. `--output-file` 给了 → 落盘永远写**完整**结果(与 stdout 是否截断无关)
126
+ > 2. `--full` 最高优先级 → stdout 也输出完整
127
+ > 3. 否则若 `--threshold N` 给了:超过 N 字节从头按字节截;**此模式下 `--head/--tail` 被忽略**
128
+ > 4. 否则若 `--head/--tail` 任一给了 → 行级截断
129
+ > 5. 否则 → 无截断、无落盘
130
+ >
131
+ > 截断与落盘的提示信息("已写入 …"、"输出被 head=5 截断 …")打到 stderr,stdout 仍为可程序化解析的纯净数据流。
132
+
133
+ #### 用法示例
134
+
135
+ ```bash
136
+ # 调试时只看头部
137
+ tyc company registration-info "百度" --head # 默认 50 行
138
+ tyc company registration-info "百度" --head 10 # 自定义 10 行
139
+
140
+ # 看头看尾,确认数据起止
141
+ tyc company key-personnel "百度" --head 5 --tail 5
108
142
 
109
- 三种输出互斥优先级:`--md > --pretty > 默认`。
143
+ # 字节预算控制(适合塞进 LLM context)
144
+ tyc risk overview "百度" --threshold 4000
145
+
146
+ # stdout 简洁 + 完整结果落盘
147
+ tyc company equity-tree "百度" --head 30 --output-file ./equity-tree.json
148
+
149
+ # 强制全量(覆盖以上一切截断)
150
+ tyc operation bidding-info "百度" --full
151
+
152
+ # 管道场景沿用旧紧凑 JSON
153
+ tyc company registration-info "百度" --compact | jq .name
154
+ ```
110
155
 
111
156
  ### 环境变量覆盖
112
157
 
@@ -201,7 +246,7 @@ tyc executive person-risk-overview "..." --humanName "张三"
201
246
  │ │
202
247
  │ └─ 多源并发聚合 · 时间戳格式化 · _summary 注入 · 空结果归一化
203
248
  │
204
- └─ 仅命令树 · 参数透传 · Session 管理 · --md/--pretty 呈现
249
+ └─ 仅命令树 · 参数透传 · Session 管理 · pretty/--md/--compact 呈现 · --head/--tail/--full/--threshold/--output-file 截断与落盘
205
250
  ```
206
251
 
207
252
  **CLI 的职责**:
@@ -210,7 +255,7 @@ tyc executive person-risk-overview "..." --humanName "张三"
210
255
  2. 组装 `tools/call` JSON-RPC 请求,透传 `Authorization` header
211
256
  3. Session 管理(`initialize` + 24h 缓存 + 失效重建)
212
257
  4. 解析 MCP Streamable HTTP 响应(纯 JSON 或 SSE)
213
- 5. 格式化输出(紧凑 JSON / `--pretty` / `--md`)
258
+ 5. 格式化输出(默认 pretty / `--compact` / `--md`),并可叠加 `--head/--tail/--full/--threshold/--output-file` 做截断与落盘
214
259
 
215
260
  **CLI 不做**:
216
261
 
@@ -243,7 +288,8 @@ tyc-cli/
243
288
  │ ├── init.ts # tyc init
244
289
  │ └── category.ts # 动态注册 6 分类 × N 方法
245
290
  └── utils/
246
- └── jsonToMarkdown.ts # --md 选项的 Markdown 渲染
291
+ ├── jsonToMarkdown.ts # --md 选项的 Markdown 渲染
292
+ └── truncate.ts # --head/--tail/--full/--threshold/--output-file 截断与落盘
247
293
  ```
248
294
 
249
295
  ---