u1s1-cli-cn 0.0.0-stage → 1.15.2

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.
Files changed (132) hide show
  1. package/README.md +71 -2
  2. package/bench/suite.json +193 -0
  3. package/dist/agent-setup.d.ts +169 -0
  4. package/dist/agent-setup.js +724 -0
  5. package/dist/agents/agent-config.d.ts +83 -0
  6. package/dist/agents/agent-config.js +154 -0
  7. package/dist/agents/claude.d.ts +113 -0
  8. package/dist/agents/claude.js +411 -0
  9. package/dist/agents/codex.d.ts +111 -0
  10. package/dist/agents/codex.js +392 -0
  11. package/dist/agents/launch.d.ts +109 -0
  12. package/dist/agents/launch.js +444 -0
  13. package/dist/agents/pi.d.ts +9 -0
  14. package/dist/agents/pi.js +560 -0
  15. package/dist/agents/prefs.d.ts +35 -0
  16. package/dist/agents/prefs.js +96 -0
  17. package/dist/agents/runtime.d.ts +354 -0
  18. package/dist/agents/runtime.js +884 -0
  19. package/dist/agents/status.d.ts +20 -0
  20. package/dist/agents/status.js +241 -0
  21. package/dist/announcements-poll.d.ts +22 -0
  22. package/dist/announcements-poll.js +59 -0
  23. package/dist/api.d.ts +147 -0
  24. package/dist/api.js +366 -0
  25. package/dist/bench-report.d.ts +22 -0
  26. package/dist/bench-report.js +161 -0
  27. package/dist/bench-scoring.d.ts +8 -0
  28. package/dist/bench-scoring.js +101 -0
  29. package/dist/bench-types.d.ts +50 -0
  30. package/dist/bench-types.js +1 -0
  31. package/dist/bench.d.ts +1 -0
  32. package/dist/bench.js +470 -0
  33. package/dist/brand.d.ts +42 -0
  34. package/dist/brand.js +165 -0
  35. package/dist/config-command.d.ts +18 -0
  36. package/dist/config-command.js +335 -0
  37. package/dist/config.d.ts +284 -0
  38. package/dist/config.js +526 -0
  39. package/dist/context-usage.d.ts +18 -0
  40. package/dist/context-usage.js +50 -0
  41. package/dist/deploy.d.ts +22 -0
  42. package/dist/deploy.js +447 -0
  43. package/dist/device-auth.d.ts +101 -0
  44. package/dist/device-auth.js +363 -0
  45. package/dist/embed.d.ts +26 -0
  46. package/dist/embed.js +28 -0
  47. package/dist/error-humanize.d.ts +24 -0
  48. package/dist/error-humanize.js +115 -0
  49. package/dist/feedback.d.ts +68 -0
  50. package/dist/feedback.js +229 -0
  51. package/dist/gateway-route.d.ts +57 -0
  52. package/dist/gateway-route.js +157 -0
  53. package/dist/i18n.d.ts +21 -0
  54. package/dist/i18n.js +46 -0
  55. package/dist/import/claude.d.ts +4 -0
  56. package/dist/import/claude.js +405 -0
  57. package/dist/import/codex.d.ts +4 -0
  58. package/dist/import/codex.js +389 -0
  59. package/dist/import/index.d.ts +1 -0
  60. package/dist/import/index.js +397 -0
  61. package/dist/import/skills.d.ts +89 -0
  62. package/dist/import/skills.js +509 -0
  63. package/dist/import/types.d.ts +104 -0
  64. package/dist/import/types.js +1 -0
  65. package/dist/import/util.d.ts +27 -0
  66. package/dist/import/util.js +241 -0
  67. package/dist/import/write.d.ts +4 -0
  68. package/dist/import/write.js +98 -0
  69. package/dist/index.d.ts +2 -0
  70. package/dist/index.js +342 -0
  71. package/dist/launcher.d.ts +48 -0
  72. package/dist/launcher.js +235 -0
  73. package/dist/login.d.ts +46 -0
  74. package/dist/login.js +300 -0
  75. package/dist/loop.d.ts +2 -0
  76. package/dist/loop.js +147 -0
  77. package/dist/mcp/client.d.ts +53 -0
  78. package/dist/mcp/client.js +450 -0
  79. package/dist/mcp/command.d.ts +25 -0
  80. package/dist/mcp/command.js +397 -0
  81. package/dist/mcp/config.d.ts +78 -0
  82. package/dist/mcp/config.js +224 -0
  83. package/dist/mcp/extension.d.ts +14 -0
  84. package/dist/mcp/extension.js +130 -0
  85. package/dist/mcp/tools.d.ts +24 -0
  86. package/dist/mcp/tools.js +101 -0
  87. package/dist/mcp-server.d.ts +105 -0
  88. package/dist/mcp-server.js +449 -0
  89. package/dist/model.d.ts +7 -0
  90. package/dist/model.js +76 -0
  91. package/dist/nudges.d.ts +27 -0
  92. package/dist/nudges.js +59 -0
  93. package/dist/pi-ui-text.d.ts +57 -0
  94. package/dist/pi-ui-text.js +148 -0
  95. package/dist/prompt.d.ts +5 -0
  96. package/dist/prompt.js +17 -0
  97. package/dist/request-trace.d.ts +12 -0
  98. package/dist/request-trace.js +45 -0
  99. package/dist/search-tools.d.ts +3 -0
  100. package/dist/search-tools.js +165 -0
  101. package/dist/secret-env.d.ts +14 -0
  102. package/dist/secret-env.js +90 -0
  103. package/dist/shell-doctor.d.ts +29 -0
  104. package/dist/shell-doctor.js +209 -0
  105. package/dist/site.d.ts +78 -0
  106. package/dist/site.js +142 -0
  107. package/dist/style.d.ts +11 -0
  108. package/dist/style.js +75 -0
  109. package/dist/subagent.d.ts +79 -0
  110. package/dist/subagent.js +189 -0
  111. package/dist/telemetry.d.ts +56 -0
  112. package/dist/telemetry.js +146 -0
  113. package/dist/tools.d.ts +90 -0
  114. package/dist/tools.js +679 -0
  115. package/dist/update.d.ts +40 -0
  116. package/dist/update.js +299 -0
  117. package/dist/usage.d.ts +21 -0
  118. package/dist/usage.js +238 -0
  119. package/dist/web.d.ts +13 -0
  120. package/dist/web.js +123 -0
  121. package/dist/webui-brand.d.ts +2 -0
  122. package/dist/webui-brand.js +169 -0
  123. package/package.json +60 -4
  124. package/scripts/p0-claude-code/README.md +39 -0
  125. package/scripts/p0-claude-code/launch-claude.ts +94 -0
  126. package/scripts/p0-claude-code/replay.ts +74 -0
  127. package/scripts/p0-claude-code/seed-local.mjs +145 -0
  128. package/scripts/p0-claude-code/tap.mjs +105 -0
  129. package/scripts/patch-pi.js +556 -0
  130. package/scripts/pi-patch-report.mjs +224 -0
  131. package/scripts/pi-upgrade.mjs +829 -0
  132. package/scripts/render-regression.mjs +244 -0
package/README.md CHANGED
@@ -1,3 +1,72 @@
1
- # Temporary Holding Version
1
+ # u1s1 — 有一说一,最省心的 AI 编程搭子
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 在终端里用中文说需求,AI 帮你读文件、改代码、跑命令。不用买模型、不用配 API、不用懂那些名词,默认 DeepSeek Flash **每天免费 $2**(北京时间 0 点恢复),新用户另送一次性 $10 加量。
4
+
5
+ ## 三步开始
6
+
7
+ ### 🚀 一键安装(推荐)
8
+ 不需要提前装任何东西,复制下面一行到终端粘贴运行:
9
+
10
+ **Linux / macOS**
11
+ ```bash
12
+ curl -fsSL https://u1s1app.com/releases/install.sh | bash
13
+ ```
14
+
15
+ **Windows**
16
+ ```powershell
17
+ powershell -c "irm https://u1s1app.com/releases/install.ps1 | iex"
18
+ ```
19
+
20
+ 脚本会自动帮你安装 Node.js 和 u1s1,一行搞定。
21
+
22
+ ### 或者,手动安装(需要 Node.js 20+)
23
+ ```bash
24
+ npm i -g u1s1-cli-cn
25
+ ```
26
+
27
+ ### 安装好后
28
+ ```bash
29
+ # 第一次运行会引导你去 u1s1app.com 注册领 Key(30 秒,不用绑卡)
30
+ u1s1
31
+
32
+ # 进到你的项目文件夹,像发微信一样说需求
33
+ cd 我的项目
34
+ u1s1
35
+ ```
36
+
37
+ ## 常用命令
38
+
39
+ | 命令 | 作用 |
40
+ |---|---|
41
+ | `u1s1` | 进入交互模式,直接开聊 |
42
+ | `u1s1 -p "把 README 里的错别字修一下"` | 一句话模式,干完就退出 |
43
+ | `u1s1 usage` | 看额度用了多少 |
44
+ | `u1s1 model` | 看/切默认模型:`u1s1 model grok` 切 Grok 4.6,`u1s1 model deepseek` 切回(对话里 `/model` 同样会记住) |
45
+ | `u1s1 update` | 升级 u1s1 到最新版 |
46
+ | `u1s1 import` | 从 Claude Code / Codex 导入历史对话,之后 `/resume` 就能接着聊 |
47
+ | `u1s1 login` / `u1s1 logout` | 登录 / 退出 |
48
+
49
+ ## 长会话自动压缩
50
+
51
+ 对话越长,每一轮上传的历史越多,回复会变慢、也更容易出错。u1s1 会在上下文接近 **200K token** 时自动压缩(把早期对话浓缩成摘要,最近 2 万 token 原文保留),压缩时界面有提示;`/context` 可以随时看当前占用、预算和触发点,`/compact` 可以手动压缩。
52
+
53
+ 这只改变压缩时机,不改变模型能力。想调整或关闭,编辑 `~/.u1s1/agent/settings.json`:
54
+
55
+ ```json
56
+ { "compaction": { "maxContextTokens": 200000 } }
57
+ ```
58
+
59
+ `0` 表示不限(按模型自身窗口,如 DeepSeek Flash 的 1M)。改完重启 u1s1 生效。
60
+
61
+ ## 在终端粘贴图片
62
+
63
+ 默认模型 DeepSeek Flash 支持视觉输入,复制截图或图片后,在 u1s1 输入框按 `Ctrl+V` 即可附加图片。macOS 这里也使用 `Ctrl+V`;`Cmd+V` 由 Terminal/iTerm 接管,只适合粘贴文本,无法把剪贴板图片交给 CLI。
64
+
65
+ ## 有一说一
66
+
67
+ - **背后模型**:默认 DeepSeek Flash(1M 上下文,每天免费 $2);难题可随时 `u1s1 model grok` 切 Grok 4.6。对话里 `/model` 也会记住,下次启动还是这个。
68
+ - **怎么收费**:DeepSeek Flash 每天有 $2 免费用量,北京时间 0 点恢复且不累计。免费用完或切换其他模型后,按 API 实际成本从永久余额扣,不加价;新用户另送一次性 $10 加量。
69
+ - **额度不够**:邀请朋友,你俩各得 $1 永久加量 → [u1s1app.com/dashboard](https://u1s1app.com/dashboard)
70
+ - **内核**:基于开源的 [pi](https://pi.dev) coding agent,会话管理、斜杠命令、皮肤等能力全都有。
71
+
72
+ 官网:[u1s1app.com](https://u1s1app.com)
@@ -0,0 +1,193 @@
1
+ [
2
+ {
3
+ "name": "quick",
4
+ "description": "快速烟雾测试 — 几秒钟测完,日常切模型后随手验证",
5
+ "questions": [
6
+ {
7
+ "id": "hello",
8
+ "category": "基础",
9
+ "prompt": "只说一句「你好,我是 u1s1」就行,不要多余的话。",
10
+ "maxScore": 5,
11
+ "checks": [
12
+ { "type": "contains", "value": "你好", "ignoreCase": false, "points": 2, "description": "包含「你好」" },
13
+ { "type": "contains", "value": "u1s1", "ignoreCase": true, "points": 2, "description": "包含「u1s1」" },
14
+ { "type": "max_length", "value": 50, "points": 1, "description": "不超过 50 字(啰嗦扣分)" }
15
+ ]
16
+ },
17
+ {
18
+ "id": "reverse",
19
+ "category": "编码",
20
+ "prompt": "写一个 TypeScript 函数,把字符串里的单词顺序反转(不是字符反转)。示例: 'hello world' → 'world hello'。只给代码,不要解释。",
21
+ "maxScore": 10,
22
+ "checks": [
23
+ { "type": "contains_code_block", "value": true, "points": 2, "description": "包含代码块" },
24
+ { "type": "contains", "value": "reverse", "ignoreCase": false, "points": 2, "description": "函数名包含 reverse" },
25
+ { "type": "contains", "value": "split", "ignoreCase": false, "points": 2, "description": "用了 split" },
26
+ { "type": "contains", "value": "reverse(", "ignoreCase": false, "points": 2, "description": "调用了数组 reverse" },
27
+ { "type": "contains", "value": "join", "ignoreCase": false, "points": 2, "description": "用了 join" }
28
+ ]
29
+ }
30
+ ]
31
+ },
32
+ {
33
+ "name": "full",
34
+ "description": "全面评测 — 覆盖编程、推理、中文理解、指令遵循",
35
+ "questions": [
36
+ {
37
+ "id": "fizzbuzz",
38
+ "category": "编码",
39
+ "prompt": "用 TypeScript 写 fizzbuzz,从 1 到 100,3 的倍数打印 fizz,5 的倍数打印 buzz,同时是 3 和 5 的倍数打印 fizzbuzz。只给代码,不要解释。",
40
+ "maxScore": 10,
41
+ "checks": [
42
+ { "type": "contains_code_block", "value": true, "points": 1, "description": "包含代码" },
43
+ { "type": "contains", "value": "% 3", "ignoreCase": false, "points": 2, "description": "判断 3 的倍数" },
44
+ { "type": "contains", "value": "% 5", "ignoreCase": false, "points": 2, "description": "判断 5 的倍数" },
45
+ { "type": "contains", "value": "fizzbuzz", "ignoreCase": false, "points": 2, "description": "输出了 fizzbuzz" },
46
+ { "type": "contains", "value": "100", "ignoreCase": false, "points": 1.5, "description": "循环到 100" },
47
+ { "type": "not_contains", "value": "解释", "ignoreCase": true, "points": 1.5, "description": "没有多余解释" }
48
+ ]
49
+ },
50
+ {
51
+ "id": "sort-algo",
52
+ "category": "编码",
53
+ "prompt": "用 TypeScript 实现一个快速排序(原地排序,不创建新数组)。只给代码,不要解释。",
54
+ "maxScore": 10,
55
+ "checks": [
56
+ { "type": "contains_code_block", "value": true, "points": 1, "description": "包含代码" },
57
+ { "type": "contains", "value": "partition", "ignoreCase": false, "points": 2, "description": "实现了 partition 函数" },
58
+ { "type": "contains", "value": "pivot", "ignoreCase": false, "points": 2, "description": "选定了 pivot" },
59
+ { "type": "contains", "value": "quickSort", "ignoreCase": false, "points": 2, "description": "递归调用 quickSort" },
60
+ { "type": "not_contains", "value": "concat", "ignoreCase": false, "points": 2, "description": "不是非原地排序(没用 concat)" },
61
+ { "type": "not_contains", "value": "解释", "ignoreCase": true, "points": 1, "description": "没有多余解释" }
62
+ ]
63
+ },
64
+ {
65
+ "id": "react-component",
66
+ "category": "编码",
67
+ "prompt": "写一个 React 计数器组件(TypeScript),包含:+ 按钮、- 按钮、重置按钮,显示当前数值。用 useState。只给代码,不要解释。",
68
+ "maxScore": 10,
69
+ "checks": [
70
+ { "type": "contains_code_block", "value": true, "points": 1, "description": "包含代码" },
71
+ { "type": "contains", "value": "useState", "ignoreCase": false, "points": 2, "description": "用了 useState" },
72
+ { "type": "contains", "value": "button", "ignoreCase": true, "points": 1.5, "description": "包含按钮元素" },
73
+ { "type": "contains", "value": "+", "ignoreCase": false, "points": 1, "description": "有加号按钮" },
74
+ { "type": "contains", "value": "-", "ignoreCase": false, "points": 1, "description": "有减号按钮" },
75
+ { "type": "contains", "value": "重置", "ignoreCase": false, "points": 1.5, "description": "有重置按钮" },
76
+ { "type": "contains", "value": "React", "ignoreCase": true, "points": 1, "description": "导入 React" },
77
+ { "type": "contains", "value": "FC", "ignoreCase": false, "points": 1, "description": "用了 React.FC 类型" }
78
+ ]
79
+ },
80
+ {
81
+ "id": "regex",
82
+ "category": "编码",
83
+ "prompt": "写一个 JavaScript 正则表达式,匹配中国大陆手机号(11 位,1 开头,第二位 3-9)。只给正则,不要解释。",
84
+ "maxScore": 10,
85
+ "checks": [
86
+ { "type": "valid_regex", "value": true, "points": 3, "description": "正则语法有效" },
87
+ { "type": "contains", "value": "1[3-9]", "ignoreCase": false, "points": 3, "description": "匹配 1 开头+第二位 3-9" },
88
+ { "type": "contains", "value": "\\d{9}", "ignoreCase": false, "points": 2, "description": "匹配后 9 位数字" },
89
+ { "type": "contains", "value": "^", "ignoreCase": false, "points": 1, "description": "有开头锚点" },
90
+ { "type": "contains", "value": "$", "ignoreCase": false, "points": 1, "description": "有结尾锚点" }
91
+ ]
92
+ },
93
+ {
94
+ "id": "reasoning-1",
95
+ "category": "推理",
96
+ "prompt": "有三个箱子:一个只装苹果,一个只装橘子,一个混装。所有标签都贴错了。你只能从一个箱子里拿一个水果看,就能推断出所有箱子的正确内容。请问该从哪个箱子拿?为什么?",
97
+ "maxScore": 10,
98
+ "checks": [
99
+ { "type": "contains", "value": "混装", "ignoreCase": false, "points": 3, "description": "回答从混装箱拿" },
100
+ { "type": "contains", "value": "标签", "ignoreCase": false, "points": 2, "description": "提到标签贴错" },
101
+ { "type": "contains", "value": "推理", "ignoreCase": true, "points": 2, "description": "有推理过程" },
102
+ { "type": "min_length", "value": 100, "points": 3, "description": "解释够详细(>=100 字)" }
103
+ ]
104
+ },
105
+ {
106
+ "id": "reasoning-2",
107
+ "category": "推理",
108
+ "prompt": "一个人花 8 元买了一只鸡,9 元卖出,10 元买回,11 元卖出。他赚了多少钱?一步步算。",
109
+ "maxScore": 10,
110
+ "checks": [
111
+ { "type": "contains", "value": "2", "ignoreCase": false, "points": 4, "description": "答案正确(赚 2 元)" },
112
+ { "type": "contains", "value": "8", "ignoreCase": false, "points": 1.5, "description": "提到了 8 元买入" },
113
+ { "type": "contains", "value": "11", "ignoreCase": false, "points": 1.5, "description": "提到了 11 元卖出" },
114
+ { "type": "contains", "value": "利润", "ignoreCase": true, "points": 1.5, "description": "有利润计算过程" },
115
+ { "type": "min_length", "value": 80, "points": 1.5, "description": "有分步计算过程" }
116
+ ]
117
+ },
118
+ {
119
+ "id": "zh-explain",
120
+ "category": "中文",
121
+ "prompt": "用一句话给完全不懂编程的人解释什么是「递归」。说得通俗一点。",
122
+ "maxScore": 10,
123
+ "checks": [
124
+ { "type": "contains", "value": "套娃", "ignoreCase": false, "points": 3, "description": "用了套娃类比(通俗)" },
125
+ { "type": "min_length", "value": 20, "points": 2, "description": "不是敷衍(>=20 字)" },
126
+ { "type": "max_length", "value": 200, "points": 2, "description": "真的是一句话(<=200 字)" },
127
+ { "type": "not_contains", "value": "函数调用", "ignoreCase": true, "points": 1.5, "description": "没用编程术语" },
128
+ { "type": "not_contains", "value": "递归调用", "ignoreCase": true, "points": 1.5, "description": "没递归解释递归(循环定义)" }
129
+ ]
130
+ },
131
+ {
132
+ "id": "zh-poem",
133
+ "category": "中文",
134
+ "prompt": "以「AI」为主题写一首五言绝句(每句五个字,共四句)。只给诗句,不要解释。",
135
+ "maxScore": 10,
136
+ "checks": [
137
+ { "type": "has_chinese", "value": true, "points": 2, "description": "包含中文" },
138
+ { "type": "line_count_5chars", "value": 4, "points": 4, "description": "四句每句五字" },
139
+ { "type": "contains", "value": "AI", "ignoreCase": true, "points": 2, "description": "主题相关" },
140
+ { "type": "max_length", "value": 100, "points": 2, "description": "没有多余解释" }
141
+ ]
142
+ },
143
+ {
144
+ "id": "instruction-follow",
145
+ "category": "指令遵循",
146
+ "prompt": "你的回答里只能包含以下三个词(可以重复):好、的、行。其他任何词都不许出现。开始:今天天气怎么样?",
147
+ "maxScore": 10,
148
+ "checks": [
149
+ { "type": "allowed_words_only", "value": ["好", "的", "行"], "points": 8, "description": "只用了允许的词" },
150
+ { "type": "min_length", "value": 1, "points": 2, "description": "有实际回答(没沉默)" }
151
+ ]
152
+ },
153
+ {
154
+ "id": "format-json",
155
+ "category": "指令遵循",
156
+ "prompt": "输出一个 JSON 对象,包含 name(你的名字)、version(当前日期)、models(数组,随便列三个模型名)。只输出 JSON,不要 markdown 代码块标记。",
157
+ "maxScore": 10,
158
+ "checks": [
159
+ { "type": "parse_json", "value": true, "points": 4, "description": "能解析为合法 JSON" },
160
+ { "type": "has_json_key", "value": "name", "points": 1.5, "description": "包含 name 字段" },
161
+ { "type": "has_json_key", "value": "version", "points": 1.5, "description": "包含 version 字段" },
162
+ { "type": "has_json_key", "value": "models", "points": 1.5, "description": "包含 models 字段" },
163
+ { "type": "not_contains", "value": "```", "ignoreCase": false, "points": 1.5, "description": "没包在 markdown 代码块里" }
164
+ ]
165
+ },
166
+ {
167
+ "id": "context-length",
168
+ "category": "长上下文",
169
+ "prompt": "请重复以下句子 50 遍:「u1s1 有一说一。」然后告诉我你一共输出了多少遍。",
170
+ "maxScore": 10,
171
+ "checks": [
172
+ { "type": "contains", "value": "50", "ignoreCase": false, "points": 4, "description": "输出了 50 遍(或声明了 50)" },
173
+ { "type": "contains", "value": "u1s1 有一说一", "ignoreCase": true, "points": 3, "description": "内容包含 u1s1 有一说一" },
174
+ { "type": "min_length", "value": 200, "points": 3, "description": "长度足够(>=200 字符)" }
175
+ ]
176
+ },
177
+ {
178
+ "id": "translation",
179
+ "category": "翻译",
180
+ "prompt": "把这句话翻译成地道的中文: 'One should always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live.'",
181
+ "maxScore": 10,
182
+ "checks": [
183
+ { "type": "has_chinese", "value": true, "points": 2, "description": "输出是中文" },
184
+ { "type": "contains", "value": "暴力", "ignoreCase": false, "points": 2, "description": "翻出了 violent" },
185
+ { "type": "contains", "value": "代码", "ignoreCase": false, "points": 2, "description": "翻出了 code" },
186
+ { "type": "contains", "value": "维护", "ignoreCase": false, "points": 2, "description": "翻出了 maintaining" },
187
+ { "type": "contains", "value": "你", "ignoreCase": false, "points": 1, "description": "翻出了 you" },
188
+ { "type": "contains", "value": "住", "ignoreCase": false, "points": 1, "description": "翻出了 where you live" }
189
+ ]
190
+ }
191
+ ]
192
+ }
193
+ ]
@@ -0,0 +1,169 @@
1
+ import { type CliConfig, type CustomEndpoint, type ModelDef, type ThinkingLevel } from "./config.js";
2
+ import type { ShellDoctorResult } from "./shell-doctor.js";
3
+ import type { Site } from "./site.js";
4
+ /**
5
+ * 系统提示里的品牌人设。中国站面向编程新手、兜底语言中文(保持原文一字不差);
6
+ * 国际站面向开发者、兜底语言英文。按站点而不是界面语言判定,用时求值(配置可能晚于 import 才读)。
7
+ */
8
+ export declare function brandAppend(site?: Site): string;
9
+ /** pi auto-appends <agentDir>/APPEND_SYSTEM.md to its system prompt — our branding hook. */
10
+ export declare function ensureBrandPrompt(shell: ShellDoctorResult): void;
11
+ /**
12
+ * Seed per-model defaults without overwriting a user's Ctrl+S choice. The
13
+ * marker records values managed by u1s1, so a later Gateway default can update
14
+ * them while a diverged user value becomes user-owned.
15
+ */
16
+ export declare function applyModelThinkingDefaults(settings: Record<string, unknown>, models: ModelDef[]): boolean;
17
+ /** pi 1.0 的 DEFAULT_TOOL_NAMES(未导出,测试里对过 pi 源码)。 */
18
+ export declare const PI_DEFAULT_TOOL_NAMES: string[];
19
+ /**
20
+ * pi 内置 codemode 默认不开,u1s1 给每个用户开一次。标记写下后不再碰:用户删掉
21
+ * codemode 都算用户的选择。写成完整工具名列表而不是 `+codemode`,原因见
22
+ * normalizeDefaultTools。
23
+ */
24
+ export declare function applyCodemodeDefault(settings: Record<string, unknown>): boolean;
25
+ /**
26
+ * 每次启动把 defaultTools 里的 `+name` / `-name` 按 pi 1.0 的规则展开成完整工具名列表。
27
+ * Desktop App ≤0.1.23 内置的 pi 0.87.1 和 CLI 共用这份 settings.json,它不认增减写法,
28
+ * 会把 `["+codemode"]` 当成「只开一个叫 +codemode 的工具」,结果旧对话一个工具都没有。
29
+ * 展开后 pi 1.0 解析结果不变(项目级的 +/- 照样叠在上面),旧版也能读懂;
30
+ * 1.13.0 写下的 `["+codemode"]` 由此修复。
31
+ */
32
+ export declare function normalizeDefaultTools(settings: Record<string, unknown>): boolean;
33
+ /**
34
+ * pi 1.0 内置 llama.cpp 扩展(本地模型 provider + /llama),u1s1 走网关用不上,默认关一次。
35
+ * 用户在 extensions 里自己写过 builtin:llama.cpp 的任何开关就不动;标记写下后同样不再碰。
36
+ */
37
+ export declare function applyLlamaDisabledDefault(settings: Record<string, unknown>): boolean;
38
+ /**
39
+ * 恢复 Pi 默认界面:早先版本替用户写下 hideThinkingBlock=true(隐藏思考块)和
40
+ * clearOnShrink=true(精简 UI 配套),并用扩展把内置工具行渲染成 0 行。现在不再覆盖,
41
+ * 老用户 settings.json 里残留的这两个值要清一次,否则升级后仍看不到思考块。
42
+ * 无法区分「u1s1 写的」和「用户后来自己选的」,所以全员只重置这一次;标记写下后
43
+ * 用户再在 /settings 里选的值就不会被动了。
44
+ */
45
+ export declare function applyNativeUiRestore(settings: Record<string, unknown>): boolean;
46
+ /** Defaults that don't overwrite values the user already set. */
47
+ export declare function ensureDefaultSettings(models?: ModelDef[]): void;
48
+ /** ≤0.4.0 wrote u1s1-dark/u1s1-light into the pi themes dir; remove them. */
49
+ export declare function cleanupBrandThemes(): void;
50
+ /**
51
+ * u1s1 provider for SDK-based frontends (Desktop App): pi composes
52
+ * <agentDir>/models.json above registered providers, so this exposes the same
53
+ * models as the TUI's in-process extension without patching the frontend.
54
+ * apiKey stays an env reference — the launcher sets U1S1_API_KEY, the file
55
+ * itself holds no secret. Rewritten on every launch so baseUrl/model changes
56
+ * propagate; other providers a user may have added are preserved.
57
+ */
58
+ /**
59
+ * 联网工具经 <agentDir>/extensions 投影:pi 的资源加载器对 TUI 和 Desktop App
60
+ * 都会扫描这个目录,两个前端从此共用同一份工具注册,不用各接一遍。
61
+ * 文件每次启动重写(baseUrl/服务端开关变化随之生效);apiKey 走 U1S1_API_KEY
62
+ * 环境变量,文件里不落密钥。U1S1_TOOLS_VIA_EXTENSION 守卫:旧版 CLI 仍在
63
+ * 进程内注册工具且不设该变量,残留的本文件在旧版下自动空转,避免双重注册。
64
+ */
65
+ export declare function writeWebToolsExtension(cfg: CliConfig, features: {
66
+ webSearch: boolean;
67
+ webFetchRender: boolean;
68
+ imageGen: boolean;
69
+ }): void;
70
+ /**
71
+ * 生成「错误信息人话化」扩展到 <agentDir>/extensions/u1s1-error-humanize.js:
72
+ * 把「429: {json}」形态的模型调用错误翻成中文正文 + 状态码尾巴,TUI 和
73
+ * Desktop App 共用(同 compact-ui 的投影机制)。实现见 error-humanize.ts,
74
+ * 分类兼容性(重试/配额/上下文超长)的约束也写在那里。
75
+ * import 失败时静默跳过——Desktop 独立运行时若指向的 CLI dist 已不存在,
76
+ * 宁可回到原始错误文本,也不能让扩展报错刷英文堆栈。
77
+ */
78
+ export declare function writeErrorHumanizeExtension(): void;
79
+ /**
80
+ * 生成「会话内公告触达」扩展到 <agentDir>/extensions/u1s1-announcements.js:
81
+ * 启动横幅只渲染一次公告,维护窗口里挂着会话的用户只会撞裸错误(审计 F14)。
82
+ * 轮询逻辑在 announcements-poll.ts(5 分钟一次、首拉只建基线不打扰);
83
+ * 公告变化时 appendEntry 进会话 + 尽力弹 notify。TUI 和 Desktop App 共用。
84
+ * print/json 一次性模式不起轮询;import 失败静默跳过(同 error-humanize)。
85
+ */
86
+ export declare function writeAnnouncementsExtension(): void;
87
+ /**
88
+ * 生成「自定义 MCP 服务」扩展到 <agentDir>/extensions/u1s1-mcp.js,只给没有内置 MCP 的
89
+ * 旧引擎用(Desktop App 的 pi-web-ui 还是 0.83):读 agent/mcp.json,把工具注册成
90
+ * mcp_<服务>_<工具>,逻辑在 mcp/extension.ts。pi ≥0.99 有 pi.registerMcpServer,说明内置
91
+ * MCP 会读同一份配置,扩展直接让位。投影前先把 ≤1.12 的 ~/.u1s1/mcp.json 迁过去。
92
+ * 子会话(spawn_subagent)里不挂 MCP 工具:避免每个子进程都拉起一份服务。
93
+ */
94
+ export declare function writeMcpExtension(): void;
95
+ /**
96
+ * 生成「OpenRouter 应用归因」扩展到 <agentDir>/extensions/u1s1-attribution.js。
97
+ * 用户自己配 OPENROUTER_API_KEY 直连时,pi 内置的归因头归到 pi.dev 名下(且受遥测
98
+ * 开关控制);这里用 before_provider_headers 钩子覆盖为 u1s1,让这部分流量也计入
99
+ * u1s1 的 OpenRouter 公开排行与数据分析(openrouter.ai/docs/app-attribution)。
100
+ * 只在请求目标确认为 OpenRouter 时才改头,其它供应商不加多余头。
101
+ */
102
+ export declare function writeAttributionExtension(site?: Site): void;
103
+ /**
104
+ * 「精简 UI」扩展(u1s1-compact-ui.js)已下线:界面回到 Pi 默认——内置工具调用、思考块都按原样显示。
105
+ * 旧版本每次启动都把它写进 <agentDir>/extensions,Pi 会照单加载并继续隐藏工具行,
106
+ * 所以启动时要把残留文件删掉(Desktop App 共用同一个 agentDir,同样受益)。
107
+ */
108
+ export declare function removeLegacyCompactUiExtension(outputDir?: string): void;
109
+ /**
110
+ * 「界面文案」(斜杠命令补全描述、思考中提示)上一版投影成 <agentDir>/extensions/u1s1-ui-text.js,
111
+ * 用户带 --no-extensions 或在设置里禁用它时就失效;现在改由 pi.ts 的进程内扩展调用
112
+ * pi-ui-text.ts 的 registerUiText。启动时删掉残留文件,免得和进程内扩展各包一层
113
+ * (两层同时生效结果也正确,只是多余);Desktop App 共用 agentDir,它那里本来就是空转。
114
+ */
115
+ export declare function removeLegacyUiTextExtension(outputDir?: string): void;
116
+ /**
117
+ * pi-web-ui 的就绪检测只认 <agentDir>/auth.json 里有没有凭据条目(models.json
118
+ * 的 apiKey 它不看),空 {} 会在网页里弹「未检测到 pi agent 配置」引导装 pi。
119
+ * 这里补一条 u1s1 的 api_key 记录 —— key 用 $U1S1_API_KEY 环境变量引用,
120
+ * pi 的 resolveConfigValue 读取时才解析,文件本身不落密钥,和 models.json 同款。
121
+ * 其他 provider 的凭据原样保留;文件损坏时不动它,交给 SDK 自己报错。
122
+ */
123
+ export declare function ensureAuthCredential(): void;
124
+ /**
125
+ * pi provider 条目里的模型形状(models.json 与 registerProvider 共用)。
126
+ * contextWindow 不是模型真实窗口而是自动压缩预算(见 effectiveContextWindow):
127
+ * options.maxContextTokens 显式传 undefined 表示「用户没设」(测试用),不传则读 settings.json。
128
+ */
129
+ export declare function toProviderModels(models: ModelDef[], options?: {
130
+ maxContextTokens?: number;
131
+ }): {
132
+ id: string;
133
+ name: string;
134
+ reasoning: boolean;
135
+ thinkingLevelMap?: Partial<Record<ThinkingLevel, string | null>>;
136
+ input: ("text" | "image")[];
137
+ cost: NonNullable<ModelDef["cost"]>;
138
+ contextWindow: number;
139
+ maxTokens: number;
140
+ compat?: {
141
+ supportsStore?: boolean;
142
+ supportsDeveloperRole?: boolean;
143
+ supportsReasoningEffort: boolean;
144
+ maxTokensField?: "max_tokens";
145
+ requiresReasoningContentOnAssistantMessages?: boolean;
146
+ thinkingFormat: "openai" | "deepseek" | "qwen";
147
+ };
148
+ }[];
149
+ /**
150
+ * 自定义端点 → pi provider 条目。密钥走环境变量引用(启动器已 set,见
151
+ * endpointKeyEnv),文件里不落明文;没配密钥的端点(本机 Ollama 等)写
152
+ * 字面量 "local" —— pi 没有凭据会直接拒启("No API key found"),
153
+ * 这是 pi 自带 llama provider 的同款兜底,本地服务会忽略 Authorization 头。
154
+ */
155
+ export declare function endpointProviderEntry(ep: CustomEndpoint, options?: {
156
+ literalKey?: boolean;
157
+ }): Record<string, unknown>;
158
+ /** run_workflow 已下线:清掉旧版本每次启动写入的 /workflow 提示词模板,免得它引导模型调用不存在的工具。 */
159
+ export declare function removeLegacyWorkflowPromptTemplate(): void;
160
+ export declare function scrubForeignProviderEnv(): void;
161
+ /** 把各端点密钥放进环境(TUI 直接 process.env;web 传给子进程)。 */
162
+ export declare function endpointKeyEnv(): Record<string, string>;
163
+ export interface ProviderModelsFileOptions {
164
+ /** Destination for the composed provider config. Defaults to the shared agent models file. */
165
+ outputPath?: string;
166
+ /** Existing config to preserve. Defaults to outputPath. */
167
+ sourcePath?: string;
168
+ }
169
+ export declare function ensureProviderModels(cfg: CliConfig, options?: ProviderModelsFileOptions): void;