u1s1-cli 1.11.2 → 1.11.5

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/config.d.ts CHANGED
@@ -172,6 +172,8 @@ export declare const agentSettingsFile: string;
172
172
  export interface AgentSettings {
173
173
  showStartupBanner?: boolean;
174
174
  autoUpdate?: boolean;
175
+ /** HTTP proxy applied to all startup and kernel network requests. */
176
+ httpProxy?: string;
175
177
  /** false 时关闭客户端事件上报(见 telemetry.ts;环境变量 U1S1_TELEMETRY=0 同效) */
176
178
  telemetry?: boolean;
177
179
  /** pi 自己的 compaction 设置块;u1s1 额外认 maxContextTokens(自动压缩预算,0 = 关) */
package/dist/index.js CHANGED
@@ -17,6 +17,19 @@ import { createGatewayTelemetry } from "./telemetry.js";
17
17
  const PACKAGE_NAME = "u1s1-cli";
18
18
  /** 启动时检测到的可自动安装的新版;TUI 退出后才装(见 installPendingUpdate)。 */
19
19
  let pendingUpdate;
20
+ /**
21
+ * Configure the same undici dispatcher used by the embedded kernel before any
22
+ * CLI startup request runs. The kernel keeps this helper in an internal file,
23
+ * so resolve it relative to its public entry instead of relying on an
24
+ * unsupported package subpath export.
25
+ */
26
+ async function configureStartupHttp() {
27
+ const piEntry = import.meta.resolve("@earendil-works/pi-coding-agent");
28
+ const dispatcherUrl = new URL("./core/http-dispatcher.js", piEntry).href;
29
+ const dispatcher = await import(dispatcherUrl);
30
+ dispatcher.applyHttpProxySettings(readSettings().httpProxy);
31
+ dispatcher.configureHttpDispatcher();
32
+ }
20
33
  /**
21
34
  * 启动时自动检查 npm 最新版:autoUpdate 开着就记下退出后安装,关着也在启动横幅的
22
35
  * 版本号后面提示一句(u1s1 vX.Y.Z 后跟升级状态,见 setUpdateNotice)。
@@ -679,6 +692,10 @@ async function run() {
679
692
  const args = process.argv.slice(2);
680
693
  const cmd = args[0];
681
694
  const rest = args.slice(1);
695
+ // Must precede ensureAuth/login, fetchModels, and every command that can
696
+ // issue network requests. No proxy configured means direct connections via
697
+ // EnvHttpProxyAgent, preserving the existing fallback behavior.
698
+ await configureStartupHttp();
682
699
  if (cmd === "--version" || cmd === "-v") {
683
700
  console.log(`u1s1 v${VERSION}`);
684
701
  return;
package/dist/update.d.ts CHANGED
@@ -5,6 +5,8 @@ export declare function detectPackageManager(): string;
5
5
  /** Fetch the latest published version from npm registry. */
6
6
  export declare function getLatestVersion(): Promise<string | undefined>;
7
7
  export declare function compareVersions(a: string, b: string): number;
8
+ /** 生成 Windows 更新启动器:优先使用 PowerShell 7,没有时回退 Windows PowerShell。 */
9
+ export declare function buildWindowsUpdateLauncherScript(): string;
8
10
  /** 从固定发布源拉一个文本文件:强制 https、拒绝重定向、限长。 */
9
11
  export declare function fetchReleaseText(name: string, maxBytes: number, timeoutMs?: number): Promise<string>;
10
12
  /** 在 sha256sum 格式的清单里找某个文件的哈希("<hex> <name>" 或 "<hex> *<name>")。 */
package/dist/update.js CHANGED
@@ -69,6 +69,17 @@ export function compareVersions(a, b) {
69
69
  const RELEASE_ORIGIN = "https://u1s1.io";
70
70
  const INSTALL_SCRIPT_NAME = "install.sh";
71
71
  const MAX_SUMS_BYTES = 64 * 1024;
72
+ /** 生成 Windows 更新启动器:优先使用 PowerShell 7,没有时回退 Windows PowerShell。 */
73
+ export function buildWindowsUpdateLauncherScript() {
74
+ return [
75
+ "$inner = '-NoProfile -ExecutionPolicy Bypass -NoExit -File \"' + $PSScriptRoot + '\\update.ps1\"'",
76
+ "$ps = (Get-Command pwsh -ErrorAction SilentlyContinue).Source",
77
+ "if (-not $ps) { $ps = (Get-Command powershell -ErrorAction SilentlyContinue).Source }",
78
+ "if (-not $ps) { throw '找不到可用的 PowerShell' }",
79
+ "Start-Process -FilePath $ps -ArgumentList $inner",
80
+ "",
81
+ ].join("\n");
82
+ }
72
83
  /** 从固定发布源拉一个文本文件:强制 https、拒绝重定向、限长。 */
73
84
  export async function fetchReleaseText(name, maxBytes, timeoutMs = 30_000) {
74
85
  const url = new URL(`/releases/${name}`, RELEASE_ORIGIN);
@@ -135,8 +146,7 @@ async function portableSelfUpdate(latest) {
135
146
  // 拼字符串,没有引号二次解析问题。
136
147
  const dir = mkdtempSync(join(tmpdir(), "u1s1-update-"));
137
148
  writeFileSync(join(dir, "update.ps1"), "irm https://u1s1.io/releases/install.ps1 | iex\n");
138
- writeFileSync(join(dir, "launch.ps1"), "$inner = '-NoProfile -ExecutionPolicy Bypass -NoExit -File \"' + $PSScriptRoot + '\\update.ps1\"'\n" +
139
- "Start-Process powershell -ArgumentList $inner\n");
149
+ writeFileSync(join(dir, "launch.ps1"), buildWindowsUpdateLauncherScript());
140
150
  const res = spawnSync("powershell.exe", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-File", join(dir, "launch.ps1")], { stdio: "ignore", windowsHide: true, timeout: 30_000 });
141
151
  if (res.error || res.status !== 0) {
142
152
  console.error("无法拉起更新窗口。请手动在 PowerShell 里运行:");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "u1s1-cli",
3
- "version": "1.11.2",
3
+ "version": "1.11.5",
4
4
  "description": "u1s1 — 有一说一,最省心的 AI 编程搭子。终端里用中文说需求,AI 帮你读文件、改代码、跑命令。",
5
5
  "type": "module",
6
6
  "bin": {