u1s1-cli 1.13.2 → 1.14.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/dist/agent-setup.d.ts +14 -10
- package/dist/agent-setup.js +37 -165
- package/dist/index.js +4 -4
- package/dist/subagent.js +3 -3
- package/dist/tools.js +1 -1
- package/dist/web.js +3 -3
- package/package.json +3 -3
- package/scripts/patch-pi.js +77 -123
- package/scripts/render-regression.mjs +36 -90
- package/dist/workflow/runner.d.ts +0 -67
- package/dist/workflow/runner.js +0 -349
- package/dist/workflow/templates.d.ts +0 -11
- package/dist/workflow/templates.js +0 -200
- package/dist/workflow/tool.d.ts +0 -16
- package/dist/workflow/tool.js +0 -179
package/dist/agent-setup.d.ts
CHANGED
|
@@ -35,6 +35,14 @@ export declare function normalizeDefaultTools(settings: Record<string, unknown>)
|
|
|
35
35
|
* 用户在 extensions 里自己写过 builtin:llama.cpp 的任何开关就不动;标记写下后同样不再碰。
|
|
36
36
|
*/
|
|
37
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;
|
|
38
46
|
/** Defaults that don't overwrite values the user already set. */
|
|
39
47
|
export declare function ensureDefaultSettings(models?: ModelDef[]): void;
|
|
40
48
|
/** ≤0.4.0 wrote u1s1-dark/u1s1-light into the pi themes dir; remove them. */
|
|
@@ -93,12 +101,11 @@ export declare function writeMcpExtension(): void;
|
|
|
93
101
|
*/
|
|
94
102
|
export declare function writeAttributionExtension(site?: Site): void;
|
|
95
103
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* - 思考块折叠标签设为空,配合 pi 补丁(见 patches/)消除多余空行
|
|
104
|
+
* 「精简 UI」扩展(u1s1-compact-ui.js)已下线:界面回到 Pi 默认——内置工具调用、思考块都按原样显示。
|
|
105
|
+
* 旧版本每次启动都把它写进 <agentDir>/extensions,Pi 会照单加载并继续隐藏工具行,
|
|
106
|
+
* 所以启动时要把残留文件删掉(Desktop App 共用同一个 agentDir,同样受益)。
|
|
100
107
|
*/
|
|
101
|
-
export declare function
|
|
108
|
+
export declare function removeLegacyCompactUiExtension(outputDir?: string): void;
|
|
102
109
|
/**
|
|
103
110
|
* pi-web-ui 的就绪检测只认 <agentDir>/auth.json 里有没有凭据条目(models.json
|
|
104
111
|
* 的 apiKey 它不看),空 {} 会在网页里弹「未检测到 pi agent 配置」引导装 pi。
|
|
@@ -141,11 +148,8 @@ export declare function toProviderModels(models: ModelDef[], options?: {
|
|
|
141
148
|
export declare function endpointProviderEntry(ep: CustomEndpoint, options?: {
|
|
142
149
|
literalKey?: boolean;
|
|
143
150
|
}): Record<string, unknown>;
|
|
144
|
-
/**
|
|
145
|
-
|
|
146
|
-
* 拆解任务 → 生成沙箱脚本 → 调 run_workflow 执行。每次启动重写,便于随版迭代文案。
|
|
147
|
-
*/
|
|
148
|
-
export declare function ensureWorkflowPromptTemplate(): void;
|
|
151
|
+
/** run_workflow 已下线:清掉旧版本每次启动写入的 /workflow 提示词模板,免得它引导模型调用不存在的工具。 */
|
|
152
|
+
export declare function removeLegacyWorkflowPromptTemplate(): void;
|
|
149
153
|
export declare function scrubForeignProviderEnv(): void;
|
|
150
154
|
/** 把各端点密钥放进环境(TUI 直接 process.env;web 传给子进程)。 */
|
|
151
155
|
export declare function endpointKeyEnv(): Record<string, string>;
|
package/dist/agent-setup.js
CHANGED
|
@@ -88,6 +88,7 @@ function bundledPiVersion() {
|
|
|
88
88
|
const THINKING_DEFAULTS_MARKER = "u1s1ModelThinkingDefaults";
|
|
89
89
|
const CODEMODE_DEFAULT_MARKER = "u1s1CodemodeDefault";
|
|
90
90
|
const LLAMA_DISABLED_MARKER = "u1s1LlamaDisabledDefault";
|
|
91
|
+
const NATIVE_UI_MARKER = "u1s1NativeUiRestored";
|
|
91
92
|
function recordValue(value) {
|
|
92
93
|
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
93
94
|
? value
|
|
@@ -202,6 +203,27 @@ export function applyLlamaDisabledDefault(settings) {
|
|
|
202
203
|
settings[LLAMA_DISABLED_MARKER] = true;
|
|
203
204
|
return true;
|
|
204
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* 恢复 Pi 默认界面:早先版本替用户写下 hideThinkingBlock=true(隐藏思考块)和
|
|
208
|
+
* clearOnShrink=true(精简 UI 配套),并用扩展把内置工具行渲染成 0 行。现在不再覆盖,
|
|
209
|
+
* 老用户 settings.json 里残留的这两个值要清一次,否则升级后仍看不到思考块。
|
|
210
|
+
* 无法区分「u1s1 写的」和「用户后来自己选的」,所以全员只重置这一次;标记写下后
|
|
211
|
+
* 用户再在 /settings 里选的值就不会被动了。
|
|
212
|
+
*/
|
|
213
|
+
export function applyNativeUiRestore(settings) {
|
|
214
|
+
if (settings[NATIVE_UI_MARKER] === true)
|
|
215
|
+
return false;
|
|
216
|
+
delete settings["hideThinkingBlock"];
|
|
217
|
+
delete settings["clearOnShrink"];
|
|
218
|
+
const terminal = recordValue(settings["terminal"]);
|
|
219
|
+
if (terminal && "clearOnShrink" in terminal) {
|
|
220
|
+
delete terminal["clearOnShrink"];
|
|
221
|
+
if (Object.keys(terminal).length === 0)
|
|
222
|
+
delete settings["terminal"];
|
|
223
|
+
}
|
|
224
|
+
settings[NATIVE_UI_MARKER] = true;
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
205
227
|
/** Defaults that don't overwrite values the user already set. */
|
|
206
228
|
export function ensureDefaultSettings(models = []) {
|
|
207
229
|
mkdirSync(agentDir, { recursive: true });
|
|
@@ -225,16 +247,6 @@ export function ensureDefaultSettings(models = []) {
|
|
|
225
247
|
changed = true;
|
|
226
248
|
}
|
|
227
249
|
}
|
|
228
|
-
if (!("hideThinkingBlock" in settings)) {
|
|
229
|
-
settings["hideThinkingBlock"] = true;
|
|
230
|
-
changed = true;
|
|
231
|
-
}
|
|
232
|
-
// 精简 UI 配套:组件变矮(状态栏消失、思考区伸缩)时清掉残留空行,
|
|
233
|
-
// 否则增量打印会在聊天流里越攒越多幽灵空行
|
|
234
|
-
if (!("clearOnShrink" in settings)) {
|
|
235
|
-
settings["clearOnShrink"] = true;
|
|
236
|
-
changed = true;
|
|
237
|
-
}
|
|
238
250
|
// 启动时是否显示品牌横幅(logo + 版本号/目录/提示)
|
|
239
251
|
if (!("showStartupBanner" in settings)) {
|
|
240
252
|
settings["showStartupBanner"] = true;
|
|
@@ -255,6 +267,8 @@ export function ensureDefaultSettings(models = []) {
|
|
|
255
267
|
settings["tuiMode"] = "regular";
|
|
256
268
|
changed = true;
|
|
257
269
|
}
|
|
270
|
+
if (applyNativeUiRestore(settings))
|
|
271
|
+
changed = true;
|
|
258
272
|
if (applyCodemodeDefault(settings))
|
|
259
273
|
changed = true;
|
|
260
274
|
if (normalizeDefaultTools(settings))
|
|
@@ -314,7 +328,7 @@ export function writeWebToolsExtension(cfg, features) {
|
|
|
314
328
|
const imageLine = features.imageGen
|
|
315
329
|
? ` pi.registerTool(tools.createImageTool({ baseUrl, apiKey: process.env.U1S1_API_KEY }));\n`
|
|
316
330
|
: "";
|
|
317
|
-
// spawn_subagent
|
|
331
|
+
// spawn_subagent 只给主会话注册;子 agent 环境里跳过,杜绝孙 agent 递归 spawn
|
|
318
332
|
const subagentBlock = ` if (process.env.U1S1_IN_SUBAGENT !== "1") {\n` +
|
|
319
333
|
` let getParentModel = () => undefined;\n` +
|
|
320
334
|
` pi.on("session_start", (_event, ctx) => {\n` +
|
|
@@ -324,10 +338,6 @@ export function writeWebToolsExtension(cfg, features) {
|
|
|
324
338
|
` }\n` +
|
|
325
339
|
` });\n` +
|
|
326
340
|
` pi.registerTool(tools.createSubagentTool(getParentModel));\n` +
|
|
327
|
-
` try {\n` +
|
|
328
|
-
` const workflow = await import(${JSON.stringify(new URL("./workflow/tool.js", import.meta.url).href)});\n` +
|
|
329
|
-
` pi.registerTool(workflow.createRunWorkflowTool(getParentModel));\n` +
|
|
330
|
-
` } catch {}\n` +
|
|
331
341
|
` }\n`;
|
|
332
342
|
// 密钥剥离守卫也从这里装:Desktop App 的 pi 跑在 pi-web-ui 子进程里,没有
|
|
333
343
|
// 启动器代码,只有扩展能替它把 U1S1_API_KEY / U1S1_EP_KEY_* 挡在子进程之外
|
|
@@ -497,121 +507,16 @@ export function writeAttributionExtension(site = activeSite()) {
|
|
|
497
507
|
`}\n`);
|
|
498
508
|
}
|
|
499
509
|
/**
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
*
|
|
503
|
-
* - 思考块折叠标签设为空,配合 pi 补丁(见 patches/)消除多余空行
|
|
510
|
+
* 「精简 UI」扩展(u1s1-compact-ui.js)已下线:界面回到 Pi 默认——内置工具调用、思考块都按原样显示。
|
|
511
|
+
* 旧版本每次启动都把它写进 <agentDir>/extensions,Pi 会照单加载并继续隐藏工具行,
|
|
512
|
+
* 所以启动时要把残留文件删掉(Desktop App 共用同一个 agentDir,同样受益)。
|
|
504
513
|
*/
|
|
505
|
-
export function
|
|
514
|
+
export function removeLegacyCompactUiExtension(outputDir) {
|
|
506
515
|
const dir = outputDir ?? join(agentDir, "extensions");
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
const toolSummaryLabels = tr(`read: "读文件", write: "写文件", edit: "改文件", bash: "跑命令", grep: "搜内容", find: "找文件", ls: "列目录",`, `read: "read", write: "write", edit: "edit", bash: "bash", grep: "grep", find: "find", ls: "ls",`);
|
|
510
|
-
const toolCallsLabel = tr(`d.total + " 次工具调用"`, `d.total + (d.total === 1 ? " tool call" : " tool calls")`);
|
|
511
|
-
writeFileSync(join(dir, "u1s1-compact-ui.js"), `// 由 u1s1 每次启动自动生成,请勿手改
|
|
512
|
-
function oneLine(text, max = 160) {
|
|
513
|
-
const flat = String(text).replace(/\\s*\\n\\s*/g, " ; ").trim();
|
|
514
|
-
return flat.length > max ? flat.slice(0, max - 1) + "…" : flat;
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
export default async function (pi) {
|
|
518
|
-
// ---- 隐藏思考块折叠标签 ----
|
|
519
|
-
pi.on("session_start", async (_event, ctx) => {
|
|
520
|
-
if (ctx.hasUI) ctx.ui.setHiddenThinkingLabel("");
|
|
521
|
-
});
|
|
522
|
-
|
|
523
|
-
// ---- 汇总统计 ----
|
|
524
|
-
let counts = {};
|
|
525
|
-
let errors = 0;
|
|
526
|
-
// 工具调用被折叠后,这一行摘要是新手了解「AI 刚才做了什么」的唯一入口,内置工具名给人话
|
|
527
|
-
const TOOL_SUMMARY_LABELS = {
|
|
528
|
-
${toolSummaryLabels}
|
|
529
|
-
};
|
|
530
|
-
pi.on("agent_start", async () => {
|
|
531
|
-
counts = {};
|
|
532
|
-
errors = 0;
|
|
533
|
-
});
|
|
534
|
-
pi.on("tool_call", async (event) => {
|
|
535
|
-
counts[event.toolName] = (counts[event.toolName] ?? 0) + 1;
|
|
536
|
-
});
|
|
537
|
-
pi.on("tool_result", async (event) => {
|
|
538
|
-
if (event.isError) errors++;
|
|
539
|
-
});
|
|
540
|
-
pi.on("agent_end", async () => {
|
|
541
|
-
const total = Object.values(counts).reduce((a, b) => a + b, 0);
|
|
542
|
-
if (total === 0) return;
|
|
543
|
-
const parts = Object.entries(counts)
|
|
544
|
-
.sort((a, b) => b[1] - a[1])
|
|
545
|
-
.map(([name, n]) => (TOOL_SUMMARY_LABELS[name] ?? name) + "×" + n);
|
|
546
|
-
if (errors > 0) parts.push("✗ " + errors);
|
|
547
|
-
pi.appendEntry("tool-summary", { total, summary: parts.join(" · ") });
|
|
548
|
-
});
|
|
549
|
-
pi.registerEntryRenderer("tool-summary", (entry, _opts, theme) => {
|
|
550
|
-
const d = entry.data;
|
|
551
|
-
let text = theme.fg("muted", "⚙ ");
|
|
552
|
-
text += theme.fg("toolTitle", theme.bold(${toolCallsLabel}));
|
|
553
|
-
text += theme.fg("dim", " · " + d.summary);
|
|
554
|
-
return new Text(text, 0, 0);
|
|
555
|
-
});
|
|
556
|
-
|
|
557
|
-
// ---- 隐藏各内置工具 ----
|
|
558
|
-
const { createReadTool, createBashTool, createEditTool, createWriteTool, createGrepTool, createFindTool, createLsTool, SettingsManager } = await import("@earendil-works/pi-coding-agent");
|
|
559
|
-
const { Text } = await import("@earendil-works/pi-tui");
|
|
560
|
-
|
|
561
|
-
// pick(ctx) 可按会话上下文换一个同 schema 的实际执行工具(bash 按 shellPath 选)
|
|
562
|
-
function hideTool(name, orig, pick = () => orig) {
|
|
563
|
-
pi.registerTool({
|
|
564
|
-
name,
|
|
565
|
-
label: name,
|
|
566
|
-
description: orig.description,
|
|
567
|
-
parameters: orig.parameters,
|
|
568
|
-
// 自己管外壳:不用默认的 Box 包装,空内容才不会产生空行
|
|
569
|
-
renderShell: "self",
|
|
570
|
-
async execute(toolCallId, params, signal, onUpdate, ctx) {
|
|
571
|
-
return pick(ctx).execute(toolCallId, params, signal, onUpdate);
|
|
572
|
-
},
|
|
573
|
-
renderCall() {
|
|
574
|
-
return new Text("", 0, 0);
|
|
575
|
-
},
|
|
576
|
-
renderResult(result, { expanded }, theme, context) {
|
|
577
|
-
if (context.isError) {
|
|
578
|
-
const c = result.content.find((x) => x.type === "text");
|
|
579
|
-
const msg = oneLine(c && c.type === "text" ? c.text : "error");
|
|
580
|
-
// 低调处理:✗ 用警示色,内容用灰色弱化,避免满屏安静时红字过于扎眼
|
|
581
|
-
return new Text(theme.fg("warning", "✗ ") + theme.fg("muted", msg), 0, 0);
|
|
582
|
-
}
|
|
583
|
-
if (!expanded) return new Text("", 0, 0);
|
|
584
|
-
const c = result.content.find((x) => x.type === "text");
|
|
585
|
-
if (!c || c.type !== "text") return new Text("", 0, 0);
|
|
586
|
-
return new Text(c.text, 0, 0);
|
|
587
|
-
},
|
|
588
|
-
});
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
const cwd = process.cwd();
|
|
592
|
-
// 模型跑的 shell 命令拿不到 U1S1_API_KEY / U1S1_EP_KEY_* 等密钥(进程级守卫之外的显式一层)
|
|
593
|
-
const { stripSecretEnv } = await import(${JSON.stringify(new URL("./secret-env.js", import.meta.url).href)});
|
|
594
|
-
hideTool("read", createReadTool(cwd));
|
|
595
|
-
// 覆盖内置 bash 后 pi 不再替我们传 shellPath:不传就走 pi 的兜底,Git 不在 Program Files 时
|
|
596
|
-
// 会命中 System32 的 WSL 转发器,全部命令失败。与内置同源读 settings.json 的 shellPath
|
|
597
|
-
// (Windows 上由 shell-doctor 验活写入);项目级设置要看信任,故首次执行时按 ctx 解析一次
|
|
598
|
-
const bashOptions = { spawnHook: (spawnContext) => ({ ...spawnContext, env: stripSecretEnv(spawnContext.env) }) };
|
|
599
|
-
let bash;
|
|
600
|
-
const bashFor = (ctx) => {
|
|
601
|
-
if (!bash) {
|
|
602
|
-
const shellPath = SettingsManager.create(ctx?.cwd ?? cwd, undefined, { projectTrusted: ctx?.isProjectTrusted() ?? false }).getShellPath();
|
|
603
|
-
bash = createBashTool(cwd, { ...bashOptions, shellPath });
|
|
516
|
+
try {
|
|
517
|
+
rmSync(join(dir, "u1s1-compact-ui.js"), { force: true });
|
|
604
518
|
}
|
|
605
|
-
|
|
606
|
-
};
|
|
607
|
-
hideTool("bash", createBashTool(cwd, bashOptions), bashFor);
|
|
608
|
-
hideTool("edit", createEditTool(cwd));
|
|
609
|
-
hideTool("write", createWriteTool(cwd));
|
|
610
|
-
hideTool("grep", createGrepTool(cwd));
|
|
611
|
-
hideTool("find", createFindTool(cwd));
|
|
612
|
-
hideTool("ls", createLsTool(cwd));
|
|
613
|
-
}
|
|
614
|
-
`);
|
|
519
|
+
catch { }
|
|
615
520
|
}
|
|
616
521
|
/**
|
|
617
522
|
* pi-web-ui 的就绪检测只认 <agentDir>/auth.json 里有没有凭据条目(models.json
|
|
@@ -699,45 +604,12 @@ export function endpointProviderEntry(ep, options = {}) {
|
|
|
699
604
|
models: toProviderModels(ep.models),
|
|
700
605
|
};
|
|
701
606
|
}
|
|
702
|
-
/**
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
export function ensureWorkflowPromptTemplate() {
|
|
707
|
-
const dir = join(agentDir, "prompts");
|
|
708
|
-
mkdirSync(dir, { recursive: true });
|
|
709
|
-
const content = `---
|
|
710
|
-
description: Orchestrate many sub-agents for a large parallelizable task via run_workflow
|
|
711
|
-
argument-hint: "<task description>"
|
|
712
|
-
---
|
|
713
|
-
# Workflow: $ARGUMENTS
|
|
714
|
-
|
|
715
|
-
First decide whether this task really needs a workflow. Good fit: many independent pieces (e.g. translating each locale file, renaming across hundreds of files, reviewing many modules). Bad fit: a few small edits — just do them directly with your own tools.
|
|
716
|
-
|
|
717
|
-
If it is a fit:
|
|
718
|
-
|
|
719
|
-
0. **Prefer a built-in template** when one matches — call \`run_workflow\` with \`template\` + \`input\` instead of writing a script:
|
|
720
|
-
- \`i18n\` — translate locale file(s) to N languages: { "langs": ["en", "ja"], "source": "src/locales/zh.json" }
|
|
721
|
-
- \`review\` — per-file review + adversarial verification: { "files": [...] } or omit for git-diff files
|
|
722
|
-
- \`research\` — parallel investigation + synthesis: { "questions": ["..."], "context": "..." }
|
|
723
|
-
- \`refactor\` — rule-first batch refactor in isolated worktrees: { "instruction": "...", "files": [...] }
|
|
724
|
-
1. Otherwise decompose the task and write a JavaScript orchestration script. Top-level await and return are allowed. The script runs in a sandbox where ONLY these are available:
|
|
725
|
-
- \`subagent(task)\` or \`subagent({ task, model })\` — runs one sub-agent, resolves to its final output text
|
|
726
|
-
- \`parallel([() => ..., ...])\` — concurrent fan-out; each thunk's error becomes \`null\`; barrier semantics
|
|
727
|
-
- \`pipeline(items, [stage1, stage2, ...])\` — each item flows through all stages independently (prefer over parallel)
|
|
728
|
-
- \`judge(question)\` — cheap tool-free model call returning true/false; use for loop-until-done checks
|
|
729
|
-
- \`subagent({ task, worktree: true })\` — run in an isolated temp git worktree (auto-cleaned) when tasks would write conflicting files
|
|
730
|
-
- \`log(...)\`, \`setTimeout/clearTimeout\`, standard JS builtins (Promise/JSON/Math/...)
|
|
731
|
-
- NO require/import/process/fetch/fs access — the static validator rejects scripts that try
|
|
732
|
-
2. Every task string must be fully self-contained: which files to read/write, what "done" means, how to self-verify.
|
|
733
|
-
3. Call the \`run_workflow\` tool with the full source as \`script\`. Read its report carefully; on failures fix the script, or rerun with \`script_path\` + \`resume: true\` to continue from saved progress. For workflows worth rerunning (e.g. recurring i18n syncs), pass a memorable \`save_as\` name — rerun later with just \`script_path\`.
|
|
734
|
-
|
|
735
|
-
Keep scripts deterministic (same order of subagent calls every run) so resume works. Summarize the outcome to the user afterwards in their language.
|
|
736
|
-
`;
|
|
737
|
-
const p = join(dir, "workflow.md");
|
|
738
|
-
if (!existsSync(p) || readFileSync(p, "utf8") !== content) {
|
|
739
|
-
writeFileSync(p, content);
|
|
607
|
+
/** run_workflow 已下线:清掉旧版本每次启动写入的 /workflow 提示词模板,免得它引导模型调用不存在的工具。 */
|
|
608
|
+
export function removeLegacyWorkflowPromptTemplate() {
|
|
609
|
+
try {
|
|
610
|
+
rmSync(join(agentDir, "prompts", "workflow.md"), { force: true });
|
|
740
611
|
}
|
|
612
|
+
catch { }
|
|
741
613
|
}
|
|
742
614
|
/**
|
|
743
615
|
* pi 会把环境里的厂商密钥(ANTHROPIC_API_KEY 等)当作「已配置的 provider」,
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { execSync, spawnSync } from "node:child_process";
|
|
3
3
|
import { writeFileSync } from "node:fs";
|
|
4
|
-
import { cleanupBrandThemes, endpointKeyEnv, endpointProviderEntry, ensureBrandPrompt, ensureDefaultSettings, ensureProviderModels,
|
|
4
|
+
import { cleanupBrandThemes, endpointKeyEnv, endpointProviderEntry, ensureBrandPrompt, ensureDefaultSettings, ensureProviderModels, removeLegacyWorkflowPromptTemplate, scrubForeignProviderEnv, toProviderModels, writeAnnouncementsExtension, writeAttributionExtension, writeMcpExtension, removeLegacyCompactUiExtension, writeErrorHumanizeExtension, writeWebToolsExtension, } from "./agent-setup.js";
|
|
5
5
|
import { Text } from "@earendil-works/pi-tui";
|
|
6
6
|
import { printConsoleBanner } from "./brand.js";
|
|
7
7
|
import { activeSite, agentDir, apiModelToDef, CUSTOM_ENDPOINTS, isPortableInstall, loadConfig, MODELS, persistPreferredModel, PROVIDER_ID, readCompactionBudgetSetting, readCompactionReserveTokens, readSettings, refValid, resolvePreferredModel, setModelsFromApi, VERSION, } from "./config.js";
|
|
@@ -245,15 +245,15 @@ async function runAgent(cfg, args) {
|
|
|
245
245
|
const officialCfg = { ...cfg, baseUrl: signing.baseUrl, apiKey: signing.localKey };
|
|
246
246
|
ensureBrandPrompt(await shellReady);
|
|
247
247
|
ensureProviderModels(officialCfg);
|
|
248
|
-
|
|
248
|
+
removeLegacyWorkflowPromptTemplate();
|
|
249
249
|
// 联网工具经 agentDir/extensions 投影,TUI 和 Desktop App 共用一份注册
|
|
250
250
|
writeWebToolsExtension(officialCfg, {
|
|
251
251
|
webSearch: webSearchEnabled,
|
|
252
252
|
webFetchRender: webFetchRenderEnabled,
|
|
253
253
|
imageGen: imageGenEnabled,
|
|
254
254
|
});
|
|
255
|
-
// 精简 UI
|
|
256
|
-
|
|
255
|
+
// 精简 UI 已下线,界面回到 Pi 默认;清掉旧版写进 agentDir/extensions 的扩展,否则 Pi 仍会加载它
|
|
256
|
+
removeLegacyCompactUiExtension();
|
|
257
257
|
// 模型调用错误人话化(同样投影,Desktop App 共享)
|
|
258
258
|
writeErrorHumanizeExtension();
|
|
259
259
|
// 会话内公告触达:5 分钟轮询,公告变化时推进会话(同样投影,Desktop 共享)
|
package/dist/subagent.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createAgentSession, DefaultResourceLoader, getAgentDir, hasTrustRequiringProjectResources, ModelRuntime, ProjectTrustStore, SessionManager, SettingsManager, } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { tr } from "./i18n.js";
|
|
3
|
-
// ---- 子 agent spawn 基础设施:spawn_subagent
|
|
3
|
+
// ---- 子 agent spawn 基础设施:spawn_subagent 工具使用 ----
|
|
4
4
|
/** 同时在跑的子 agent 上限;超额排队,防止打爆网关。 */
|
|
5
5
|
export const SUBAGENT_CONCURRENCY = 4;
|
|
6
6
|
/** 单个子任务默认超时;到点 abort,不让一个卡死的任务拖住整批。 */
|
|
@@ -133,8 +133,8 @@ export async function runSubagent(opts) {
|
|
|
133
133
|
else {
|
|
134
134
|
model = undefined;
|
|
135
135
|
}
|
|
136
|
-
//
|
|
137
|
-
// cwd(worktree 隔离)
|
|
136
|
+
// 精简 UI 扩展已下线,但旧版 Desktop/并行会话可能还往共用的 agentDir 写它;它用
|
|
137
|
+
// process.cwd() 重建内置工具,会破坏自定义 cwd(worktree 隔离)下的路径解析,子会话一律不加载
|
|
138
138
|
const cwd = opts.cwd ?? process.cwd();
|
|
139
139
|
const agentDir = getAgentDir();
|
|
140
140
|
// 项目信任跟随主会话:SettingsManager 缺省 projectTrusted=true,会把主会话
|
package/dist/tools.js
CHANGED
|
@@ -209,7 +209,7 @@ export function createSearchTool(cfg) {
|
|
|
209
209
|
},
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
|
-
// ---- spawn_subagent 工具:spawn 设施在 ./subagent.ts
|
|
212
|
+
// ---- spawn_subagent 工具:spawn 设施在 ./subagent.ts ----
|
|
213
213
|
/** 单次调用最多并行任务数;再多模型也看不过来,让主 agent 分批调。 */
|
|
214
214
|
const SUBAGENT_MAX_TASKS = 10;
|
|
215
215
|
/** 子 agent 工具:独立上下文窗口干活,只把结果摘要带回主对话,不污染主 token 预算。 */
|
package/dist/web.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import { cleanupBrandThemes, endpointKeyEnv, ensureAuthCredential, ensureBrandPrompt,
|
|
4
|
+
import { cleanupBrandThemes, endpointKeyEnv, ensureAuthCredential, ensureBrandPrompt, removeLegacyWorkflowPromptTemplate, ensureDefaultSettings, ensureProviderModels, scrubForeignProviderEnv, writeAttributionExtension, writeMcpExtension, writeWebToolsExtension, } from "./agent-setup.js";
|
|
5
5
|
import { agentDir, apiModelToDef, MODELS, resolvePreferredModel, setModelsFromApi, u1s1Dir, writeAgentDefaultModel, } from "./config.js";
|
|
6
6
|
import { ensureSearchTools } from "./search-tools.js";
|
|
7
7
|
import { ensureUsableShell } from "./shell-doctor.js";
|
|
@@ -87,8 +87,8 @@ export async function prepareWebEnv(cfg) {
|
|
|
87
87
|
webOfficialCfg = officialCfg;
|
|
88
88
|
const modelsPath = refreshWebModels();
|
|
89
89
|
ensureBrandPrompt(await shellReady);
|
|
90
|
-
// /workflow
|
|
91
|
-
|
|
90
|
+
// 清理旧版 /workflow 提示词模板
|
|
91
|
+
removeLegacyWorkflowPromptTemplate();
|
|
92
92
|
// pi-web-ui 靠 auth.json 判断「已配置」,否则网页会弹 pi 安装引导
|
|
93
93
|
ensureAuthCredential();
|
|
94
94
|
// 联网工具经 agentDir/extensions 投影,和 TUI 共用一份注册
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "u1s1-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.1",
|
|
4
4
|
"description": "u1s1 — 有一说一,最省心的 AI 编程搭子。终端里用中文说需求,AI 帮你读文件、改代码、跑命令。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"homepage": "https://u1s1app.com",
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@earendil-works/pi-coding-agent": "1.
|
|
46
|
-
"@earendil-works/pi-tui": "1.
|
|
45
|
+
"@earendil-works/pi-coding-agent": "1.2.0",
|
|
46
|
+
"@earendil-works/pi-tui": "1.2.0",
|
|
47
47
|
"typebox": "1.3.7"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|