tyc-cli 0.3.9 → 0.3.11
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 +2 -0
- package/README.md +12 -4
- package/dist/catalog.json +175 -21
- package/dist/commands/category.js +4 -4
- package/dist/commands/output.js +4 -3
- package/dist/coreClient.js +3 -2
- package/dist/utils/history.js +3 -2
- package/dist/utils/identifierDetails.js +40 -0
- package/dist/utils/jsonToMarkdown.js +83 -9
- package/dist/utils/losslessJson.js +114 -0
- package/dist/utils/oa2.js +33 -0
- package/dist/utils/personnelChanges.js +3 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
### 修复
|
|
8
8
|
|
|
9
|
+
- 全部上游标识透传:CLI 无损解析 Core JSON,pretty/compact/Markdown 保留大整数数字、前导零字符串和显式空值;Markdown 增加与来源路径绑定的标识明细。服务端同步撤销 ID/UUID/记录/图边标识的隐藏规则;CLI 版本号已升至 0.3.10,尚未发布。
|
|
10
|
+
|
|
9
11
|
- E06 / E08:Markdown 完整呈现嵌套列表、对象和收到的变更原文,不再按字符数静默省略;用户显式指定的输出截断选项继续生效,上游原文已有的省略号不补造。
|
|
10
12
|
- 同步展示服务端的分页、日期与商标字段口径、风险状态和历史查询引导;人员变更使用服务端 `_parsed` 结果,股东来源及逐笔出资保留,历史列表 Markdown 按当前页日期排序且不改 JSON 顺序。
|
|
11
13
|
- E03:请求失败统一交由 CLI 入口输出并设置退出码,允许网络和标准流自然收尾;402 仍返回退出码 `1`,不触发额度重试。帮助、版本及参数错误也保留各自退出码,避免强制退出或重复输出。
|
package/README.md
CHANGED
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
## 📖 项目简介
|
|
13
13
|
|
|
14
14
|
`tyc-cli` 是天眼查 MCP Server 的官方命令行客户端。CLI 通过 shared core HTTP 入口
|
|
15
|
-
调用天眼查
|
|
15
|
+
调用天眼查 165 个业务语义聚合工具,覆盖企业工商、知产、司法风险、董监高等全维度
|
|
16
16
|
商业数据。
|
|
17
17
|
|
|
18
18
|
当前 MCP Server 的 `tools/list` 默认只公开少量 AI Agent 入口工具
|
|
19
|
-
(搜索、公司画像、能力目录、`call_tool` / `call_tools_batch` 等),但
|
|
19
|
+
(搜索、公司画像、能力目录、`call_tool` / `call_tools_batch` 等),但 165 个业务语义
|
|
20
20
|
工具仍注册在服务端并保持 `tools/call` 兼容。CLI 不依赖 `tools/list` 构建命令树,
|
|
21
21
|
而是使用打包内 `catalog.json` 直达这些业务工具。
|
|
22
22
|
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
- 🔌 **公网优先**:默认连接天眼查 MCP 端点 `https://mcp.tianyancha.com/mcp`;
|
|
28
28
|
支持 `--url` 指向本地或私有部署
|
|
29
29
|
- 🔄 **无本地 MCP Session**:CLI 调用 stateless shared core endpoint,不缓存 `Mcp-Session-Id`
|
|
30
|
-
- 🎯 **6 大业务分类 /
|
|
30
|
+
- 🎯 **6 大业务分类 / 165 个工具**:企业基础信息 · 风险合规 · 知识产权 · 经营与公示 · 历史信息 · 董监高
|
|
31
31
|
- 🤖 **AI Agent 友好**:tyc 英文 key 透传 / 时间戳格式化 / `_summary / _empty / _warnings` 元数据
|
|
32
32
|
|
|
33
33
|
---
|
|
@@ -149,6 +149,8 @@ tyc executive personnel-dishonest "..." --humanName "张三"
|
|
|
149
149
|
|
|
150
150
|
`--md` 从 Shared Core JSON 在本地渲染,布局可能与 MCP 的服务端 Markdown 不同。嵌套对象、数组完整保留,不再执行旧的 80 字符省略或 `key=…` 折叠;输出限制统一由下述显式选项控制。`_pagination`、日期/字段口径、历史查询指引和风险状态直接使用服务端元数据,不重新推导。变更记录只对 Markdown 的当前页按变更日期倒序展示,JSON 顺序不变;人员解析结果来自服务端 `_parsed`。
|
|
151
151
|
|
|
152
|
+
上游标识默认保留原键、值、类型。JSON 输出无损保留大整数数字字面量和前导零字符串;`--md` 附“上游标识明细”说明来源路径、所属记录及 JSON 原值,空串/null/零/空集合不混同。边 ID 和端点、业务记录主键、UUID 等也保留;同值标识不自动认定为同一主体。服务端具体契约与历史规则状态见 [API 通用约定](../../docs/t1_1/apis/README.md)。
|
|
153
|
+
|
|
152
154
|
#### 输出截断 / 落盘(与上述输出格式正交,可叠加任意子命令)
|
|
153
155
|
|
|
154
156
|
| 选项 | 默认值 | 说明 |
|
|
@@ -372,7 +374,7 @@ HTTP 402 同样返回退出码 1 并保留服务端错误说明,不自动重
|
|
|
372
374
|
| 职责 | 命令树 · 参数透传 · 格式化输出 | 多源聚合 · 时间戳格式化 · 元数据注入 · Authorization 透传至 OpenAPI |
|
|
373
375
|
| 运维 | 用户本地安装 | 默认连接官方托管 `mcp.tianyancha.com`,也可切到本机 apimcp 或用户自建 |
|
|
374
376
|
|
|
375
|
-
CLI 和 MCP Server 共享同一
|
|
377
|
+
CLI 和 MCP Server 共享同一 165 工具清单;工具元数据从打包内的 `catalog.json`
|
|
376
378
|
读取,保证命令树冷启动零网络开销。
|
|
377
379
|
|
|
378
380
|
---
|
|
@@ -412,3 +414,9 @@ MCP_URL=https://my-mcp.example.com/mcp AUTH_TOKEN=xxx bash test/t1_1/cli/run_t1_
|
|
|
412
414
|
本项目采用 [MIT License](LICENSE)。
|
|
413
415
|
|
|
414
416
|
数据来源:天眼查 OpenAPI(用户需自行获取并合规使用 token)。本工具不存储、不转发、不解析用户的查询数据,所有调用经天眼查 MCP Server 转发。
|
|
417
|
+
|
|
418
|
+
### 限制出境(L2)
|
|
419
|
+
|
|
420
|
+
`tyc risk exit-restriction "广东振戎能源有限公司" --pageNum 1 --pageSize 20 --md`
|
|
421
|
+
|
|
422
|
+
每页默认及最大 20 条。关键词匹配申请执行人和被执行人,命中不代表企业或其高管被限制出境。走 MCP 计费的用户每次有效查询扣 1 次,无结果或失败扣 0 次,翻页独立计次;企业独立凭据通道不进入 MCP 本地计费。完整字段及披露规则见[风险合规](../../docs/t1_1/apis/风险合规.md)。
|
package/dist/catalog.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
{
|
|
11
11
|
"group": "risk",
|
|
12
12
|
"name_zh": "风险合规",
|
|
13
|
-
"tool_count":
|
|
13
|
+
"tool_count": 38
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"group": "intellectual_property",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
{
|
|
26
26
|
"group": "history",
|
|
27
27
|
"name_zh": "历史信息",
|
|
28
|
-
"tool_count":
|
|
28
|
+
"tool_count": 18
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
"group": "executive",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
46
|
"layer": "L2",
|
|
47
|
-
"count":
|
|
47
|
+
"count": 58
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
"layer": "L3",
|
|
51
|
-
"count":
|
|
51
|
+
"count": 101
|
|
52
52
|
}
|
|
53
53
|
],
|
|
54
54
|
"tools": [
|
|
@@ -907,7 +907,7 @@
|
|
|
907
907
|
"requiredPlan": "vip",
|
|
908
908
|
"cliMethod": "stock-shareholders",
|
|
909
909
|
"categoryNameZh": "企业基础信息",
|
|
910
|
-
"description": "
|
|
910
|
+
"description": "查询上市公司股东榜单及参股控股信息。type=1查询十大股东(默认),type=2查询十大流通股东;一次仅查询一种股东榜单。time可指定股东榜单期次,格式YYYY-MM-DD,建议从返回的timeList选择;不传时采用下游默认期次,实际日期以返回记录为准。type和time仅影响股东榜单来源,pageNum/pageSize仅影响参股控股来源。需要比较两种榜单时,应使用相同time分别调用。股份类型shareType不能用于判断榜单类型。 数据权益:早鸟期可用;2026年9月1日起需VIP。",
|
|
911
911
|
"params": [
|
|
912
912
|
{
|
|
913
913
|
"name": "searchKey",
|
|
@@ -915,15 +915,30 @@
|
|
|
915
915
|
"required": true,
|
|
916
916
|
"description": "企业名称、统一社会信用代码或天眼查企业 ID"
|
|
917
917
|
},
|
|
918
|
+
{
|
|
919
|
+
"default": "1",
|
|
920
|
+
"enum": [
|
|
921
|
+
"1",
|
|
922
|
+
"2"
|
|
923
|
+
],
|
|
924
|
+
"name": "type",
|
|
925
|
+
"type": "string",
|
|
926
|
+
"description": "股东榜单类型:1=十大股东(默认),2=十大流通股东;仅作用于股东榜单来源"
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
"name": "time",
|
|
930
|
+
"type": "string",
|
|
931
|
+
"description": "股东榜单查询期次,格式YYYY-MM-DD;建议从timeList选择。不传采用下游默认期次;不影响参股控股来源"
|
|
932
|
+
},
|
|
918
933
|
{
|
|
919
934
|
"name": "pageNum",
|
|
920
935
|
"type": "number",
|
|
921
|
-
"description": "
|
|
936
|
+
"description": "参股控股页码(可选,默认 1);不对股东榜单分页"
|
|
922
937
|
},
|
|
923
938
|
{
|
|
924
939
|
"name": "pageSize",
|
|
925
940
|
"type": "number",
|
|
926
|
-
"description": "
|
|
941
|
+
"description": "参股控股每页大小(可选,默认 10);不对股东榜单分页"
|
|
927
942
|
}
|
|
928
943
|
]
|
|
929
944
|
},
|
|
@@ -1772,6 +1787,33 @@
|
|
|
1772
1787
|
}
|
|
1773
1788
|
]
|
|
1774
1789
|
},
|
|
1790
|
+
{
|
|
1791
|
+
"name": "get_historical_environmental_penalty",
|
|
1792
|
+
"group": "history",
|
|
1793
|
+
"layer": "L3",
|
|
1794
|
+
"requiredPlan": "vip",
|
|
1795
|
+
"cliMethod": "historical-environmental-penalty",
|
|
1796
|
+
"categoryNameZh": "历史信息",
|
|
1797
|
+
"description": "查询企业历史环保处罚记录,返回决定书文号、处罚日期、 处罚单位和处罚金额(元),用于历史环保合规排查。 违法类型为上游保留字段,可能为空。 支持企业名称或统一社会信用代码,历史记录不表示处罚已撤销或已整改。 数据权益:早鸟期可用;2026年9月1日起需VIP。",
|
|
1798
|
+
"params": [
|
|
1799
|
+
{
|
|
1800
|
+
"name": "searchKey",
|
|
1801
|
+
"type": "string",
|
|
1802
|
+
"required": true,
|
|
1803
|
+
"description": "精确企业名称或统一社会信用代码,不支持直接使用企业 ID"
|
|
1804
|
+
},
|
|
1805
|
+
{
|
|
1806
|
+
"name": "pageNum",
|
|
1807
|
+
"type": "number",
|
|
1808
|
+
"description": "页码,须为正整数,默认 1"
|
|
1809
|
+
},
|
|
1810
|
+
{
|
|
1811
|
+
"name": "pageSize",
|
|
1812
|
+
"type": "number",
|
|
1813
|
+
"description": "每页条数,须为 1–20 的整数,默认 10"
|
|
1814
|
+
}
|
|
1815
|
+
]
|
|
1816
|
+
},
|
|
1775
1817
|
{
|
|
1776
1818
|
"name": "get_historical_equity_freeze",
|
|
1777
1819
|
"group": "history",
|
|
@@ -2614,7 +2656,7 @@
|
|
|
2614
2656
|
"requiredPlan": "vip",
|
|
2615
2657
|
"cliMethod": "company-announcement",
|
|
2616
2658
|
"categoryNameZh": "经营与公示",
|
|
2617
|
-
"description": "
|
|
2659
|
+
"description": "查询上市公告及企业研报或相关公告。type=0查询企业研报,type=1查询相关公告(默认),仅作用于公告研报来源。相关公告可能由其他主体发布;返回标题、日期与原文链接,不代表已读取原文。适用于核验上市公司公告、破产重整/清算公告、管理人公告、资产处置公告、投资人招募公告。遇到“税务/规划/司法三重关卡”“资金来源”“交易对价”“股权比例”“担保责任”等问题时,应优先用公告原文核验,并按用户给定框架分别检查税务、规划/政策、司法/执行等维度。 数据权益:早鸟期可用;2026年9月1日起需VIP。",
|
|
2618
2660
|
"params": [
|
|
2619
2661
|
{
|
|
2620
2662
|
"name": "searchKey",
|
|
@@ -2622,6 +2664,16 @@
|
|
|
2622
2664
|
"required": true,
|
|
2623
2665
|
"description": "企业名称、统一社会信用代码或天眼查企业 ID"
|
|
2624
2666
|
},
|
|
2667
|
+
{
|
|
2668
|
+
"default": "1",
|
|
2669
|
+
"enum": [
|
|
2670
|
+
"0",
|
|
2671
|
+
"1"
|
|
2672
|
+
],
|
|
2673
|
+
"name": "type",
|
|
2674
|
+
"type": "number",
|
|
2675
|
+
"description": "公告研报查询类型:0=企业研报,1=相关公告(默认);不影响上市公告来源"
|
|
2676
|
+
},
|
|
2625
2677
|
{
|
|
2626
2678
|
"name": "pageNum",
|
|
2627
2679
|
"type": "number",
|
|
@@ -2630,7 +2682,7 @@
|
|
|
2630
2682
|
{
|
|
2631
2683
|
"name": "pageSize",
|
|
2632
2684
|
"type": "number",
|
|
2633
|
-
"description": "
|
|
2685
|
+
"description": "每个来源每页大小(可选,默认 10,最大 20;超出按 20 查询)"
|
|
2634
2686
|
}
|
|
2635
2687
|
]
|
|
2636
2688
|
},
|
|
@@ -2722,7 +2774,7 @@
|
|
|
2722
2774
|
"requiredPlan": "vip",
|
|
2723
2775
|
"cliMethod": "honor-info",
|
|
2724
2776
|
"categoryNameZh": "经营与公示",
|
|
2725
|
-
"description": "
|
|
2777
|
+
"description": "查询企业荣誉、奖项及认定,返回荣誉名称、状态、类型、级别、认证单位、有效期和来源。recordScope 支持 current(有效,默认)、historical(历史)、all(全部);上榜榜单请使用 get_ranking_list_info。 数据权益:早鸟期可用;2026年9月1日起需VIP。",
|
|
2726
2778
|
"params": [
|
|
2727
2779
|
{
|
|
2728
2780
|
"name": "searchKey",
|
|
@@ -2730,6 +2782,17 @@
|
|
|
2730
2782
|
"required": true,
|
|
2731
2783
|
"description": "企业名称、统一社会信用代码或天眼查企业 ID"
|
|
2732
2784
|
},
|
|
2785
|
+
{
|
|
2786
|
+
"default": "current",
|
|
2787
|
+
"enum": [
|
|
2788
|
+
"current",
|
|
2789
|
+
"historical",
|
|
2790
|
+
"all"
|
|
2791
|
+
],
|
|
2792
|
+
"name": "recordScope",
|
|
2793
|
+
"type": "string",
|
|
2794
|
+
"description": "查询范围:current=有效(默认)、historical=历史、all=全部;不是按过去日期查询快照"
|
|
2795
|
+
},
|
|
2733
2796
|
{
|
|
2734
2797
|
"name": "pageNum",
|
|
2735
2798
|
"type": "number",
|
|
@@ -2738,7 +2801,7 @@
|
|
|
2738
2801
|
{
|
|
2739
2802
|
"name": "pageSize",
|
|
2740
2803
|
"type": "number",
|
|
2741
|
-
"description": "每页大小(可选,默认 20
|
|
2804
|
+
"description": "每页大小(可选,默认 20,最大 20;超过时按 20 查询并返回请求值与生效值)"
|
|
2742
2805
|
}
|
|
2743
2806
|
]
|
|
2744
2807
|
},
|
|
@@ -2766,13 +2829,13 @@
|
|
|
2766
2829
|
"requiredPlan": "vip",
|
|
2767
2830
|
"cliMethod": "invest-agency-events",
|
|
2768
2831
|
"categoryNameZh": "经营与公示",
|
|
2769
|
-
"description": "
|
|
2832
|
+
"description": "查询投资机构最新投资动态。请传投资机构库收录的机构名称,例如“深创投”。使用工商全称可能返回空结果。 数据权益:早鸟期可用;2026年9月1日起需VIP。",
|
|
2770
2833
|
"params": [
|
|
2771
2834
|
{
|
|
2772
2835
|
"name": "searchKey",
|
|
2773
2836
|
"type": "string",
|
|
2774
2837
|
"required": true,
|
|
2775
|
-
"description": "
|
|
2838
|
+
"description": "请传投资机构库收录的机构名称,例如“深创投”。使用工商全称可能返回空结果。"
|
|
2776
2839
|
},
|
|
2777
2840
|
{
|
|
2778
2841
|
"name": "pageNum",
|
|
@@ -2793,13 +2856,13 @@
|
|
|
2793
2856
|
"requiredPlan": "vip",
|
|
2794
2857
|
"cliMethod": "invest-agency-funds",
|
|
2795
2858
|
"categoryNameZh": "经营与公示",
|
|
2796
|
-
"description": "
|
|
2859
|
+
"description": "查询投资机构基金信息,包含基金管理公司、对外投资基金和基金管理人。请传投资机构库收录的机构名称,例如“深创投”。使用工商全称可能返回空结果。 数据权益:早鸟期可用;2026年9月1日起需VIP。",
|
|
2797
2860
|
"params": [
|
|
2798
2861
|
{
|
|
2799
2862
|
"name": "searchKey",
|
|
2800
2863
|
"type": "string",
|
|
2801
2864
|
"required": true,
|
|
2802
|
-
"description": "
|
|
2865
|
+
"description": "请传投资机构库收录的机构名称,例如“深创投”。使用工商全称可能返回空结果。"
|
|
2803
2866
|
},
|
|
2804
2867
|
{
|
|
2805
2868
|
"name": "pageNum",
|
|
@@ -2820,13 +2883,13 @@
|
|
|
2820
2883
|
"requiredPlan": "vip",
|
|
2821
2884
|
"cliMethod": "invest-agency-news",
|
|
2822
2885
|
"categoryNameZh": "经营与公示",
|
|
2823
|
-
"description": "
|
|
2886
|
+
"description": "查询投资机构相关新闻舆情信息。请传投资机构库收录的机构名称,例如“深创投”。使用工商全称可能返回空结果。 数据权益:早鸟期可用;2026年9月1日起需VIP。",
|
|
2824
2887
|
"params": [
|
|
2825
2888
|
{
|
|
2826
2889
|
"name": "searchKey",
|
|
2827
2890
|
"type": "string",
|
|
2828
2891
|
"required": true,
|
|
2829
|
-
"description": "
|
|
2892
|
+
"description": "请传投资机构库收录的机构名称,例如“深创投”。使用工商全称可能返回空结果。"
|
|
2830
2893
|
},
|
|
2831
2894
|
{
|
|
2832
2895
|
"name": "pageNum",
|
|
@@ -2847,13 +2910,13 @@
|
|
|
2847
2910
|
"requiredPlan": "vip",
|
|
2848
2911
|
"cliMethod": "invest-agency-profile",
|
|
2849
2912
|
"categoryNameZh": "经营与公示",
|
|
2850
|
-
"description": "
|
|
2913
|
+
"description": "查询投资机构画像,包含工商追踪、机构成员和统计分析。请传投资机构库收录的机构名称,例如“深创投”。使用工商全称可能返回空结果。 数据权益:早鸟期可用;2026年9月1日起需VIP。",
|
|
2851
2914
|
"params": [
|
|
2852
2915
|
{
|
|
2853
2916
|
"name": "searchKey",
|
|
2854
2917
|
"type": "string",
|
|
2855
2918
|
"required": true,
|
|
2856
|
-
"description": "
|
|
2919
|
+
"description": "请传投资机构库收录的机构名称,例如“深创投”。使用工商全称可能返回空结果。"
|
|
2857
2920
|
},
|
|
2858
2921
|
{
|
|
2859
2922
|
"name": "pageNum",
|
|
@@ -2874,13 +2937,13 @@
|
|
|
2874
2937
|
"requiredPlan": "vip",
|
|
2875
2938
|
"cliMethod": "invest-agency-public-investments",
|
|
2876
2939
|
"categoryNameZh": "经营与公示",
|
|
2877
|
-
"description": "
|
|
2940
|
+
"description": "查询投资机构投资信息,包含公开投资事件和未公开投资。请传投资机构库收录的机构名称,例如“深创投”。使用工商全称可能返回空结果。 数据权益:早鸟期可用;2026年9月1日起需VIP。",
|
|
2878
2941
|
"params": [
|
|
2879
2942
|
{
|
|
2880
2943
|
"name": "searchKey",
|
|
2881
2944
|
"type": "string",
|
|
2882
2945
|
"required": true,
|
|
2883
|
-
"description": "
|
|
2946
|
+
"description": "请传投资机构库收录的机构名称,例如“深创投”。使用工商全称可能返回空结果。"
|
|
2884
2947
|
},
|
|
2885
2948
|
{
|
|
2886
2949
|
"name": "pageNum",
|
|
@@ -3709,6 +3772,33 @@
|
|
|
3709
3772
|
}
|
|
3710
3773
|
]
|
|
3711
3774
|
},
|
|
3775
|
+
{
|
|
3776
|
+
"name": "get_exit_restriction",
|
|
3777
|
+
"group": "risk",
|
|
3778
|
+
"layer": "L2",
|
|
3779
|
+
"requiredPlan": "vip",
|
|
3780
|
+
"cliMethod": "exit-restriction",
|
|
3781
|
+
"categoryNameZh": "风险合规",
|
|
3782
|
+
"description": "查询与企业相关的限制出境记录,包括案号、限制出境对象、被执行人、申请执行人、执行法院、执行标的及发布日期。关键词同时匹配申请执行人和被执行人,命中记录不代表该企业或其高管被限制出境,应结合记录中的角色字段判断。 数据权益:早鸟期可用;2026年9月1日起需VIP。",
|
|
3783
|
+
"params": [
|
|
3784
|
+
{
|
|
3785
|
+
"name": "searchKey",
|
|
3786
|
+
"type": "string",
|
|
3787
|
+
"required": true,
|
|
3788
|
+
"description": "企业名称、统一社会信用代码、天眼查企业 ID 或注册号;同时匹配申请执行人和被执行人"
|
|
3789
|
+
},
|
|
3790
|
+
{
|
|
3791
|
+
"name": "pageNum",
|
|
3792
|
+
"type": "number",
|
|
3793
|
+
"description": "页码,须为正整数,默认 1"
|
|
3794
|
+
},
|
|
3795
|
+
{
|
|
3796
|
+
"name": "pageSize",
|
|
3797
|
+
"type": "number",
|
|
3798
|
+
"description": "每页条数,须为 1–20 的整数,默认 20;超过 20 拒绝调用"
|
|
3799
|
+
}
|
|
3800
|
+
]
|
|
3801
|
+
},
|
|
3712
3802
|
{
|
|
3713
3803
|
"name": "get_guarantee_info",
|
|
3714
3804
|
"group": "risk",
|
|
@@ -3931,6 +4021,43 @@
|
|
|
3931
4021
|
}
|
|
3932
4022
|
]
|
|
3933
4023
|
},
|
|
4024
|
+
{
|
|
4025
|
+
"name": "get_labor_arbitration",
|
|
4026
|
+
"group": "risk",
|
|
4027
|
+
"layer": "L3",
|
|
4028
|
+
"requiredPlan": "vip",
|
|
4029
|
+
"cliMethod": "labor-arbitration",
|
|
4030
|
+
"categoryNameZh": "风险合规",
|
|
4031
|
+
"description": "查询企业劳动仲裁公告,必须选择 court 开庭公告或 delivery 送达公告。 返回案号、申请人、被申请人及对应日期;开庭公告另含案由和发布机构。 支持精确企业名称或统一社会信用代码;公告不代表已裁决或败诉。 数据权益:早鸟期可用;2026年9月1日起需VIP。",
|
|
4032
|
+
"params": [
|
|
4033
|
+
{
|
|
4034
|
+
"name": "searchKey",
|
|
4035
|
+
"type": "string",
|
|
4036
|
+
"required": true,
|
|
4037
|
+
"description": "精确企业名称或统一社会信用代码,不支持直接使用企业 ID"
|
|
4038
|
+
},
|
|
4039
|
+
{
|
|
4040
|
+
"enum": [
|
|
4041
|
+
"court",
|
|
4042
|
+
"delivery"
|
|
4043
|
+
],
|
|
4044
|
+
"name": "noticeType",
|
|
4045
|
+
"type": "string",
|
|
4046
|
+
"required": true,
|
|
4047
|
+
"description": "court 为开庭公告,delivery 为送达公告;每次只查询所选类型"
|
|
4048
|
+
},
|
|
4049
|
+
{
|
|
4050
|
+
"name": "pageNum",
|
|
4051
|
+
"type": "number",
|
|
4052
|
+
"description": "正整数页码,默认 1"
|
|
4053
|
+
},
|
|
4054
|
+
{
|
|
4055
|
+
"name": "pageSize",
|
|
4056
|
+
"type": "number",
|
|
4057
|
+
"description": "每页 1–20 条,默认 10"
|
|
4058
|
+
}
|
|
4059
|
+
]
|
|
4060
|
+
},
|
|
3934
4061
|
{
|
|
3935
4062
|
"name": "get_land_mortgage_info",
|
|
3936
4063
|
"group": "risk",
|
|
@@ -3992,6 +4119,33 @@
|
|
|
3992
4119
|
}
|
|
3993
4120
|
]
|
|
3994
4121
|
},
|
|
4122
|
+
{
|
|
4123
|
+
"name": "get_prelitigation_mediation",
|
|
4124
|
+
"group": "risk",
|
|
4125
|
+
"layer": "L3",
|
|
4126
|
+
"requiredPlan": "vip",
|
|
4127
|
+
"cliMethod": "prelitigation-mediation",
|
|
4128
|
+
"categoryNameZh": "风险合规",
|
|
4129
|
+
"description": "查询企业当前诉前调解记录,返回案号、法院、立案日期、案由及当事人分组。 支持精确企业名称或统一社会信用代码;PunishDate 表示立案日期,角色保留上游代码。 不含历史诉前调解,不代表已形成裁判或已达成调解。 数据权益:早鸟期可用;2026年9月1日起需VIP。",
|
|
4130
|
+
"params": [
|
|
4131
|
+
{
|
|
4132
|
+
"name": "searchKey",
|
|
4133
|
+
"type": "string",
|
|
4134
|
+
"required": true,
|
|
4135
|
+
"description": "精确企业名称或统一社会信用代码,不支持直接使用企业 ID"
|
|
4136
|
+
},
|
|
4137
|
+
{
|
|
4138
|
+
"name": "pageNum",
|
|
4139
|
+
"type": "number",
|
|
4140
|
+
"description": "正整数页码,默认 1"
|
|
4141
|
+
},
|
|
4142
|
+
{
|
|
4143
|
+
"name": "pageSize",
|
|
4144
|
+
"type": "number",
|
|
4145
|
+
"description": "每页 1–20 条,默认 10"
|
|
4146
|
+
}
|
|
4147
|
+
]
|
|
4148
|
+
},
|
|
3995
4149
|
{
|
|
3996
4150
|
"name": "get_public_exhortation",
|
|
3997
4151
|
"group": "risk",
|
|
@@ -5,6 +5,8 @@ import { emitToolResult } from "./output.js";
|
|
|
5
5
|
const GLOBAL_OUTPUT_HELP = `
|
|
6
6
|
全局输出选项:所有工具命令均支持 --md / --compact / --pretty / --head / --tail / --full / --threshold / --output-file / --verbose;完整说明见 tyc --help。
|
|
7
7
|
`;
|
|
8
|
+
// These tools have source- and row-specific ID semantics in the server view.
|
|
9
|
+
const personIdentifierViews = new Set(["get_person_profile", "get_personnel_legal_rep_roles", "get_person_partners", "get_actual_controller"]);
|
|
8
10
|
export function registerCategoryCommands(program) {
|
|
9
11
|
for (const cat of getCategories()) {
|
|
10
12
|
const tools = getToolsByGroup(cat.group);
|
|
@@ -58,7 +60,8 @@ function bindMethod(catCmd, tool, program) {
|
|
|
58
60
|
const opts = program.opts();
|
|
59
61
|
const verbose = !!opts.verbose;
|
|
60
62
|
try {
|
|
61
|
-
const
|
|
63
|
+
const format = opts.md && personIdentifierViews.has(tool.name) ? "markdown" : "json";
|
|
64
|
+
const result = await callCoreToolWithOAuthRefresh(tool.name, args, { verbose, format });
|
|
62
65
|
emitToolResult(result, opts, tool.name);
|
|
63
66
|
}
|
|
64
67
|
catch (err) {
|
|
@@ -67,6 +70,3 @@ function bindMethod(catCmd, tool, program) {
|
|
|
67
70
|
}
|
|
68
71
|
});
|
|
69
72
|
}
|
|
70
|
-
async function callToolWithOAuthRefresh(name, args, verbose) {
|
|
71
|
-
return callCoreToolWithOAuthRefresh(name, args, { verbose });
|
|
72
|
-
}
|
package/dist/commands/output.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseLosslessJSON, stringifyLosslessJSON } from "../utils/losslessJson.js";
|
|
1
2
|
import { jsonToMarkdown } from "../utils/jsonToMarkdown.js";
|
|
2
3
|
import { applyTruncation, resolveOptionalInt, TRUNCATE_DEFAULTS, } from "../utils/truncate.js";
|
|
3
4
|
export function emitToolResult(result, opts, toolName) {
|
|
@@ -11,7 +12,7 @@ export function emitToolResult(result, opts, toolName) {
|
|
|
11
12
|
}
|
|
12
13
|
let payload;
|
|
13
14
|
try {
|
|
14
|
-
payload =
|
|
15
|
+
payload = parseLosslessJSON(text);
|
|
15
16
|
}
|
|
16
17
|
catch {
|
|
17
18
|
emitWithTruncation(text.endsWith("\n") ? text.slice(0, -1) : text, opts);
|
|
@@ -22,10 +23,10 @@ export function emitToolResult(result, opts, toolName) {
|
|
|
22
23
|
rendered = jsonToMarkdown(payload, toolName);
|
|
23
24
|
}
|
|
24
25
|
else if (opts.compact) {
|
|
25
|
-
rendered =
|
|
26
|
+
rendered = stringifyLosslessJSON(payload);
|
|
26
27
|
}
|
|
27
28
|
else {
|
|
28
|
-
rendered =
|
|
29
|
+
rendered = stringifyLosslessJSON(payload, null, 2);
|
|
29
30
|
}
|
|
30
31
|
emitWithTruncation(rendered, opts);
|
|
31
32
|
}
|
package/dist/coreClient.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseLosslessJSON, stringifyLosslessJSON } from "./utils/losslessJson.js";
|
|
1
2
|
function maskToken(v) {
|
|
2
3
|
if (!v)
|
|
3
4
|
return "";
|
|
@@ -104,7 +105,7 @@ export async function callCoreTool(cfg, name, args, opts) {
|
|
|
104
105
|
}
|
|
105
106
|
let parsed;
|
|
106
107
|
try {
|
|
107
|
-
parsed =
|
|
108
|
+
parsed = parseLosslessJSON(text);
|
|
108
109
|
}
|
|
109
110
|
catch {
|
|
110
111
|
throw new Error(`core 响应不是 JSON:HTTP ${resp.status}\n${text.slice(0, 500)}`);
|
|
@@ -114,7 +115,7 @@ export async function callCoreTool(cfg, name, args, opts) {
|
|
|
114
115
|
throw new Error(`core/tools/call HTTP ${resp.status}\n${desc}`);
|
|
115
116
|
}
|
|
116
117
|
const content = parsed.content;
|
|
117
|
-
const contentText = typeof content === "string" ? content :
|
|
118
|
+
const contentText = typeof content === "string" ? content : stringifyLosslessJSON(content ?? {});
|
|
118
119
|
return {
|
|
119
120
|
content: [{ type: "text", text: contentText }],
|
|
120
121
|
};
|
package/dist/utils/history.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
1
|
+
import { stringifyLosslessJSON, LosslessNumber } from "./losslessJson.js";
|
|
2
|
+
const object = (v) => v !== null && typeof v === "object" && !Array.isArray(v) && !(v instanceof LosslessNumber);
|
|
3
|
+
const text = (v) => typeof v === "string" ? v : stringifyLosslessJSON(v) ?? "null";
|
|
3
4
|
const cell = (v) => text(v).replace(/\|/g, "\\|").replace(/\r?\n/g, " ");
|
|
4
5
|
export function renderHistoryGuide(value) {
|
|
5
6
|
if (!object(value))
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { LosslessNumber, stringifyLosslessJSON } from "./losslessJson.js";
|
|
2
|
+
const identifier = (key) => {
|
|
3
|
+
if (["paid", "unpaid", "valid", "invalid", "solid", "fluid", "rapid", "grid"].includes(key.toLowerCase()))
|
|
4
|
+
return false;
|
|
5
|
+
return /(?:id|ids|uuid|uuids|guid|guids)$/i.test(key) || /^(?:startNode|endNode|idsFrom|idsTo|idsNew)$/i.test(key);
|
|
6
|
+
};
|
|
7
|
+
const cell = (text) => text.replace(/\|/g, "\\|").replace(/\r?\n/g, " ");
|
|
8
|
+
/** Full identifiers, tied to their final source/record paths, including nulls.
|
|
9
|
+
* Rendering happens after Core's data-rights filtering and before truncation.
|
|
10
|
+
*/
|
|
11
|
+
export function identifierDetails(value) {
|
|
12
|
+
const rows = [];
|
|
13
|
+
const visit = (value, path, record) => {
|
|
14
|
+
if (value === null || typeof value !== "object" || value instanceof LosslessNumber)
|
|
15
|
+
return;
|
|
16
|
+
if (Array.isArray(value)) {
|
|
17
|
+
value.forEach((item, i) => visit(item, `${path}[${i}]`, record));
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const object = value;
|
|
21
|
+
for (const key of ["name", "companyName", "investorName", "title"]) {
|
|
22
|
+
if (typeof object[key] === "string" && object[key]) {
|
|
23
|
+
record = object[key];
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
for (const key of Object.keys(object).sort()) {
|
|
28
|
+
if (["_summary", "_empty", "_warnings", "_tip", "_truncated", "_pagination", "_riskOverview", "_dateSemantics", "_fieldSemantics", "_historyGuide", "_source", "_parsed", "_field_meanings"].includes(key))
|
|
29
|
+
continue;
|
|
30
|
+
const field = path ? path + "." + key : key;
|
|
31
|
+
if (identifier(key) || ((key === "source" || key === "target") && "source" in object && "target" in object)) {
|
|
32
|
+
rows.push(`| ${cell(field)} | ${cell(record)} | ${cell(stringifyLosslessJSON(object[key]))} |`);
|
|
33
|
+
}
|
|
34
|
+
else
|
|
35
|
+
visit(object[key], field, record);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
visit(value, "", "");
|
|
39
|
+
return rows.length ? "\n## 上游标识明细\n\n> 原字段和值按来源路径保留;记录主键、局部节点或同值 ID 不自动表示同一主体。空值不能作为关联键。\n\n| 来源路径(原键) | 所属记录 | 原值(JSON) |\n|---|---|---|\n" + rows.join("\n") + "\n" : "";
|
|
40
|
+
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { renderOA2Items } from "./oa2.js";
|
|
2
|
+
import { identifierDetails } from "./identifierDetails.js";
|
|
3
|
+
import { stringifyLosslessJSON, LosslessNumber } from "./losslessJson.js";
|
|
1
4
|
/**
|
|
2
5
|
* JSON → Markdown 输出格式化
|
|
3
6
|
*
|
|
@@ -9,9 +12,9 @@
|
|
|
9
12
|
*/
|
|
10
13
|
import { renderChangeRecords, splitChangeRecords } from "./personnelChanges.js";
|
|
11
14
|
import { renderHistoryGuide, splitHistoricalPersonnel } from "./history.js";
|
|
12
|
-
const META_KEYS = new Set(["_summary", "_empty", "_warnings", "_tip", "_truncated", "_pagination", "_riskOverview", "_dateSemantics", "_fieldSemantics", "_historyGuide", "_source"]);
|
|
15
|
+
const META_KEYS = new Set(["_summary", "_empty", "_warnings", "_tip", "_truncated", "_pagination", "_riskOverview", "_recordCounts", "_dateSemantics", "_fieldSemantics", "_historyGuide", "_source"]);
|
|
13
16
|
function isPlainObject(v) {
|
|
14
|
-
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
17
|
+
return v !== null && typeof v === "object" && !Array.isArray(v) && !(v instanceof LosslessNumber);
|
|
15
18
|
}
|
|
16
19
|
function formatPrimitive(v) {
|
|
17
20
|
if (v === null || v === undefined || v === "")
|
|
@@ -42,13 +45,13 @@ function formatArrayCell(arr) {
|
|
|
42
45
|
return arr.map(formatPrimitive).join(", ");
|
|
43
46
|
}
|
|
44
47
|
// 对象数组:紧凑 JSON
|
|
45
|
-
return
|
|
48
|
+
return stringifyLosslessJSON(arr);
|
|
46
49
|
}
|
|
47
50
|
function formatObjectInline(obj) {
|
|
48
|
-
return
|
|
51
|
+
return stringifyLosslessJSON(obj);
|
|
49
52
|
}
|
|
50
53
|
function renderJSONBlock(value) {
|
|
51
|
-
const text =
|
|
54
|
+
const text = stringifyLosslessJSON(value, null, 2);
|
|
52
55
|
const longestFence = Math.max(0, ...(text.match(/`+/g) || []).map((s) => s.length));
|
|
53
56
|
const fence = "`".repeat(Math.max(3, longestFence + 1));
|
|
54
57
|
return `${fence}json\n${text}\n${fence}\n`;
|
|
@@ -146,7 +149,7 @@ function renderMeta(obj) {
|
|
|
146
149
|
lines.push(`> 💡 **提示**:${formatPrimitive(obj._tip)}`);
|
|
147
150
|
}
|
|
148
151
|
if (obj._empty === true && !isPlainObject(obj._riskOverview)) {
|
|
149
|
-
lines.push(`> ⚪
|
|
152
|
+
lines.push(`> ⚪ **空结果**:本次未返回记录`);
|
|
150
153
|
}
|
|
151
154
|
if (isPlainObject(obj._pagination)) {
|
|
152
155
|
const p = obj._pagination;
|
|
@@ -266,7 +269,7 @@ function renderNestedObjects(obj) {
|
|
|
266
269
|
* @param value 工具返回的 JSON(已 parse 为对象)
|
|
267
270
|
* @param toolName 工具名(可选,用作标题)
|
|
268
271
|
*/
|
|
269
|
-
|
|
272
|
+
function renderMarkdownValue(value, toolName) {
|
|
270
273
|
if (value === null || value === undefined) {
|
|
271
274
|
return "_(空)_\n";
|
|
272
275
|
}
|
|
@@ -278,12 +281,12 @@ export function jsonToMarkdown(value, toolName) {
|
|
|
278
281
|
const obj = value;
|
|
279
282
|
const historical = splitHistoricalPersonnel(obj, toolName);
|
|
280
283
|
if (historical)
|
|
281
|
-
return
|
|
284
|
+
return renderMarkdownValue(historical.rest, toolName) + "\n" + historical.markdown;
|
|
282
285
|
const changes = splitChangeRecords(obj, toolName);
|
|
283
286
|
if (changes) {
|
|
284
287
|
// The recursive call receives a copy without the extracted list. Keep raw
|
|
285
288
|
// code blocks verbatim: the generic newline compaction must not touch them.
|
|
286
|
-
return
|
|
289
|
+
return renderMarkdownValue(changes.rest, toolName) + "\n" + renderChangeRecords(changes.records, changes.title);
|
|
287
290
|
}
|
|
288
291
|
const parts = [];
|
|
289
292
|
// 标题
|
|
@@ -297,10 +300,78 @@ export function jsonToMarkdown(value, toolName) {
|
|
|
297
300
|
const meta = renderMeta(obj);
|
|
298
301
|
if (meta)
|
|
299
302
|
parts.push(meta);
|
|
303
|
+
const oa2 = renderOA2Items(obj, toolName);
|
|
304
|
+
if (oa2 !== undefined)
|
|
305
|
+
return parts.concat(oa2).join("\n");
|
|
300
306
|
if (toolName === "get_risk_overview" || isPlainObject(obj._riskOverview)) {
|
|
301
307
|
parts.push(renderRiskOverview(obj));
|
|
302
308
|
return parts.join("\n").replace(/\n{3,}/g, "\n\n");
|
|
303
309
|
}
|
|
310
|
+
if (toolName === "get_stock_shareholders" && isPlainObject(obj.sources)) {
|
|
311
|
+
for (const scope of ["top", "holding"]) {
|
|
312
|
+
const source = obj.sources[scope];
|
|
313
|
+
if (!isPlainObject(source))
|
|
314
|
+
continue;
|
|
315
|
+
const title = scope === "holding" ? "参股控股" : String(source._queryType) === "2" ? "十大流通股东" : String(source._queryType) === "1" ? "十大股东" : "股东榜单";
|
|
316
|
+
parts.push(`## ${title}\n`);
|
|
317
|
+
if (scope === "top" && source._queryType !== undefined)
|
|
318
|
+
parts.push(`> 查询类型:type=${source._queryType};续查保持 --type ${source._queryType}。\n`);
|
|
319
|
+
if (source.status === "error") {
|
|
320
|
+
parts.push(`> 查询失败:${escapeCell(formatPrimitive(source.error))};不能据此判断无记录。\n`);
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
if (source.status === "unknown") {
|
|
324
|
+
parts.push("> 返回结构未知,无法确认记录数。\n");
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
if (scope === "top") {
|
|
328
|
+
parts.push(`> 本次返回${source.returnedCount}条。${escapeCell(formatPrimitive(source._periodNote))}\n`);
|
|
329
|
+
if (source.empty === true)
|
|
330
|
+
parts.push("> 空结果:本次股东榜单查询无记录。\n");
|
|
331
|
+
if (Array.isArray(source.holderList))
|
|
332
|
+
parts.push(renderItemsTable(source.holderList, title));
|
|
333
|
+
if (Array.isArray(source.timeList))
|
|
334
|
+
parts.push(renderItemsTable(source.timeList, "可选期次 timeList"));
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
parts.push(renderMeta(source));
|
|
338
|
+
if (source.empty === true)
|
|
339
|
+
parts.push("> 空结果:本次参股控股查询无记录。\n");
|
|
340
|
+
else if (Array.isArray(source.items) && source.items.length === 0)
|
|
341
|
+
parts.push("> 当前页无记录,不代表该来源没有记录。\n");
|
|
342
|
+
if (Array.isArray(source.items))
|
|
343
|
+
parts.push(renderItemsTable(source.items, title));
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return parts.join("\n").replace(/\n{3,}/g, "\n\n");
|
|
347
|
+
}
|
|
348
|
+
if (toolName === "get_company_announcement" && isPlainObject(obj.sources)) {
|
|
349
|
+
for (const scope of ["stock", "mr"]) {
|
|
350
|
+
const source = obj.sources[scope];
|
|
351
|
+
if (!isPlainObject(source))
|
|
352
|
+
continue;
|
|
353
|
+
const title = scope === "stock" ? "上市公告" : String(source._queryType) === "0" ? "企业研报" : String(source._queryType) === "1" ? "相关公告" : "公告研报";
|
|
354
|
+
parts.push(`## ${title}\n`);
|
|
355
|
+
if (scope === "mr" && source._queryType !== undefined)
|
|
356
|
+
parts.push(`> 查询类型:type=${source._queryType}(${title});续查保持 --type ${source._queryType}。\n`);
|
|
357
|
+
if (source.status === "error") {
|
|
358
|
+
parts.push(`> 查询失败:${escapeCell(formatPrimitive(source.error))};不能据此判断该来源无记录。\n`);
|
|
359
|
+
}
|
|
360
|
+
else if (source.status === "unknown") {
|
|
361
|
+
parts.push("> 返回结构未知,无法确认该来源记录数。\n");
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
parts.push(renderMeta(source));
|
|
365
|
+
if (source.empty === true)
|
|
366
|
+
parts.push(`> 空结果:未发现${title}记录。\n`);
|
|
367
|
+
else if (Array.isArray(source.items) && source.items.length === 0)
|
|
368
|
+
parts.push("> 当前页无记录,不代表该来源没有记录。\n");
|
|
369
|
+
else if (Array.isArray(source.items))
|
|
370
|
+
parts.push(renderItemsTable(source.items, title));
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return parts.join("\n").replace(/\n{3,}/g, "\n\n");
|
|
374
|
+
}
|
|
304
375
|
// 顶层字段
|
|
305
376
|
const topFields = renderTopFields(obj);
|
|
306
377
|
parts.push(topFields);
|
|
@@ -314,3 +385,6 @@ export function jsonToMarkdown(value, toolName) {
|
|
|
314
385
|
parts.push(nested);
|
|
315
386
|
return parts.join("\n").replace(/\n{3,}/g, "\n\n");
|
|
316
387
|
}
|
|
388
|
+
export function jsonToMarkdown(value, toolName) {
|
|
389
|
+
return renderMarkdownValue(value, toolName) + identifierDetails(value);
|
|
390
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/** JSON numbers whose original token cannot survive native Number serialisation.
|
|
2
|
+
* Keep the token numeric in JSON; String(value) is exact in Markdown. Node 18+.
|
|
3
|
+
*/
|
|
4
|
+
export class LosslessNumber {
|
|
5
|
+
token;
|
|
6
|
+
constructor(token) {
|
|
7
|
+
this.token = token;
|
|
8
|
+
}
|
|
9
|
+
toString() { return this.token; }
|
|
10
|
+
}
|
|
11
|
+
export function parseLosslessJSON(text) {
|
|
12
|
+
let offset = 0;
|
|
13
|
+
const fail = () => { throw new SyntaxError(`Invalid JSON at ${offset}`); };
|
|
14
|
+
const whitespace = () => { while (/[\t\n\r ]/.test(text[offset] ?? "x"))
|
|
15
|
+
offset++; };
|
|
16
|
+
const string = () => {
|
|
17
|
+
const start = offset++;
|
|
18
|
+
while (offset < text.length) {
|
|
19
|
+
const ch = text[offset++];
|
|
20
|
+
if (ch === "\\")
|
|
21
|
+
offset++;
|
|
22
|
+
else if (ch === '"')
|
|
23
|
+
return JSON.parse(text.slice(start, offset));
|
|
24
|
+
}
|
|
25
|
+
return fail();
|
|
26
|
+
};
|
|
27
|
+
const value = () => {
|
|
28
|
+
whitespace();
|
|
29
|
+
const ch = text[offset];
|
|
30
|
+
if (ch === '"')
|
|
31
|
+
return string();
|
|
32
|
+
if (ch === "{" || ch === "[") {
|
|
33
|
+
const object = ch === "{";
|
|
34
|
+
offset++;
|
|
35
|
+
const result = object ? {} : [];
|
|
36
|
+
const end = object ? "}" : "]";
|
|
37
|
+
whitespace();
|
|
38
|
+
if (text[offset] === end) {
|
|
39
|
+
offset++;
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
while (offset < text.length) {
|
|
43
|
+
whitespace();
|
|
44
|
+
let key = "";
|
|
45
|
+
if (object) {
|
|
46
|
+
if (text[offset] !== '"')
|
|
47
|
+
fail();
|
|
48
|
+
key = string();
|
|
49
|
+
whitespace();
|
|
50
|
+
if (text[offset++] !== ":")
|
|
51
|
+
fail();
|
|
52
|
+
}
|
|
53
|
+
const item = value();
|
|
54
|
+
if (object)
|
|
55
|
+
Object.defineProperty(result, key, { value: item, enumerable: true, writable: true, configurable: true });
|
|
56
|
+
else
|
|
57
|
+
result.push(item);
|
|
58
|
+
whitespace();
|
|
59
|
+
if (text[offset] === end) {
|
|
60
|
+
offset++;
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
if (text[offset++] !== ",")
|
|
64
|
+
fail();
|
|
65
|
+
}
|
|
66
|
+
return fail();
|
|
67
|
+
}
|
|
68
|
+
for (const [token, item] of [["true", true], ["false", false], ["null", null]]) {
|
|
69
|
+
if (text.startsWith(token, offset)) {
|
|
70
|
+
offset += token.length;
|
|
71
|
+
return item;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const match = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(text.slice(offset));
|
|
75
|
+
if (!match)
|
|
76
|
+
return fail();
|
|
77
|
+
const token = match[0];
|
|
78
|
+
offset += token.length;
|
|
79
|
+
const number = Number(token);
|
|
80
|
+
return JSON.stringify(number) === token && (Number.isSafeInteger(number) || !Number.isInteger(number))
|
|
81
|
+
? number : new LosslessNumber(token);
|
|
82
|
+
};
|
|
83
|
+
const result = value();
|
|
84
|
+
whitespace();
|
|
85
|
+
if (offset !== text.length)
|
|
86
|
+
fail();
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
export function stringifyLosslessJSON(value, _replacer = null, space = 0) {
|
|
90
|
+
const indent = " ".repeat(Math.min(10, Math.max(0, space)));
|
|
91
|
+
const ancestors = new Set();
|
|
92
|
+
const encode = (item, depth) => {
|
|
93
|
+
if (item instanceof LosslessNumber)
|
|
94
|
+
return item.token;
|
|
95
|
+
if (item === null || typeof item !== "object")
|
|
96
|
+
return JSON.stringify(item);
|
|
97
|
+
if (ancestors.has(item))
|
|
98
|
+
throw new TypeError("Circular JSON value");
|
|
99
|
+
ancestors.add(item);
|
|
100
|
+
const array = Array.isArray(item);
|
|
101
|
+
const entries = array ? item.map((v) => encode(v, depth + 1) ?? "null")
|
|
102
|
+
: Object.entries(item).flatMap(([key, v]) => {
|
|
103
|
+
const text = encode(v, depth + 1);
|
|
104
|
+
return text === undefined ? [] : [JSON.stringify(key) + (indent ? ": " : ":") + text];
|
|
105
|
+
});
|
|
106
|
+
ancestors.delete(item);
|
|
107
|
+
const [open, close] = array ? ["[", "]"] : ["{", "}"];
|
|
108
|
+
if (!entries.length)
|
|
109
|
+
return open + close;
|
|
110
|
+
return indent ? open + "\n" + entries.map((entry) => indent.repeat(depth + 1) + entry).join(",\n")
|
|
111
|
+
+ "\n" + indent.repeat(depth) + close : open + entries.join(",") + close;
|
|
112
|
+
};
|
|
113
|
+
return encode(value, 0);
|
|
114
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** OA2 list labels preserve the provider's date/unit/role semantics. */
|
|
2
|
+
export function renderOA2Items(obj, toolName) {
|
|
3
|
+
let columns;
|
|
4
|
+
switch (toolName) {
|
|
5
|
+
case 'get_historical_environmental_penalty':
|
|
6
|
+
columns = [['Id', '记录标识'], ['CaseNo', '决定书文号'], ['PunishDate', '处罚日期'], ['IllegalType', '违法类型'], ['PunishGov', '处罚单位'], ['PunishAmt', '处罚金额(元)']];
|
|
7
|
+
break;
|
|
8
|
+
case 'get_labor_arbitration':
|
|
9
|
+
columns = [['CaseNo', '案号'], ['Applicant', '申请人'], ['Respondent', '被申请人']];
|
|
10
|
+
if (obj._notice_type === 'court')
|
|
11
|
+
columns.push(['CaseReason', '案由'], ['PublishOrg', '发布机构'], ['PublishDate', '开庭日期']);
|
|
12
|
+
else
|
|
13
|
+
columns.push(['PublishDate', '发布日期']);
|
|
14
|
+
break;
|
|
15
|
+
case 'get_prelitigation_mediation':
|
|
16
|
+
columns = [['CaseNo', '案号'], ['Court', '法院'], ['PunishDate', '立案日期'], ['CaseReason', '案由'], ['RoleList', '当事人分组(上游代码)']];
|
|
17
|
+
break;
|
|
18
|
+
default: return undefined;
|
|
19
|
+
}
|
|
20
|
+
const items = Array.isArray(obj.items) ? obj.items : [];
|
|
21
|
+
if (!items.length)
|
|
22
|
+
return '';
|
|
23
|
+
const cell = (v) => String(v ?? '').replace(/\|/g, '\\|').replace(/\r?\n/g, ' ') || '—';
|
|
24
|
+
const lines = ['| ' + columns.map(([, title]) => title).join(' | ') + ' |', '| ' + columns.map(() => '---').join(' | ') + ' |'];
|
|
25
|
+
for (const row of items) {
|
|
26
|
+
lines.push('| ' + columns.map(([key]) => {
|
|
27
|
+
if (key !== 'RoleList')
|
|
28
|
+
return cell(row[key]);
|
|
29
|
+
return cell((row.RoleList ?? []).map((role) => `类型代码 ${role.RoleType}:${role.RoleItemList.join('、')}`).join(';'));
|
|
30
|
+
}).join(' | ') + ' |');
|
|
31
|
+
}
|
|
32
|
+
return lines.join('\n') + '\n';
|
|
33
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { stringifyLosslessJSON, LosslessNumber } from "./losslessJson.js";
|
|
1
2
|
// Presentation only: all personnel extraction and statuses come from Shared Core.
|
|
2
3
|
import { changeRecordsForDisplay } from "./history.js";
|
|
3
|
-
const object = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
4
|
-
const text = (v) => typeof v === "string" ? v :
|
|
4
|
+
const object = (v) => v !== null && typeof v === "object" && !Array.isArray(v) && !(v instanceof LosslessNumber);
|
|
5
|
+
const text = (v) => typeof v === "string" ? v : stringifyLosslessJSON(v) ?? "null";
|
|
5
6
|
const cell = (v) => (v === undefined || v === "" ? "-" : text(v)).replace(/\|/g, "\\|").replace(/\r?\n/g, " ");
|
|
6
7
|
function block(value) {
|
|
7
8
|
const raw = text(value);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tyc-cli",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "天眼查 AI CLI —
|
|
3
|
+
"version": "0.3.11",
|
|
4
|
+
"description": "天眼查 AI CLI — 165 个业务语义聚合工具 · 默认 Shared Core 调用 · 兼容 MCP transport",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"tyc": "dist/index.js"
|