@mobius-os/mobius 0.3.73 → 0.3.75

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/install.ps1 CHANGED
@@ -10,7 +10,7 @@
10
10
  文件夹空白处注册两个 Explorer 右键入口:“在Mobius终端中打开”与
11
11
  “在Mobius终端中打开(管理员权限)”。
12
12
  .EXAMPLE
13
- irm https://serve.nutshellai.cn/publish/auto/mobiustui/install-v16.ps1 | iex
13
+ irm https://serve.nutshellai.cn/publish/auto/mobiustui/install-v18.ps1 | iex
14
14
  #>
15
15
  $ErrorActionPreference = 'Stop'
16
16
  $ProgressPreference = 'SilentlyContinue'
@@ -212,6 +212,9 @@ if ($userPath -notlike "*$binDir*") {
212
212
  # Directory\Background\shell\Mobius = 右键文件夹空白处,目标参数 %V
213
213
  # ...\MobiusAdmin = 同样的两处,UAC 提权后启动(管理员权限)
214
214
  # 使用 .cmd 辅助启动器,避免右键动作依赖 PowerShell ExecutionPolicy。
215
+ $logsDir = Join-Path $MHOME "logs"
216
+ New-Item -ItemType Directory -Force -Path $logsDir | Out-Null
217
+
215
218
  $openHereCmd = Join-Path $binDir "mobius-open-here.cmd"
216
219
  $openHereLines = @(
217
220
  '@echo off',
@@ -219,19 +222,49 @@ $openHereLines = @(
219
222
  'set "MOBIUS_TARGET=%~1"',
220
223
  'if not defined MOBIUS_TARGET set "MOBIUS_TARGET=%CD%"',
221
224
  'cd /d "%MOBIUS_TARGET%"',
225
+ '> "%USERPROFILE%\.mobius\logs\launcher.log" echo %DATE% %TIME% start target=%MOBIUS_TARGET%',
222
226
  'call "%~dp0mobius.cmd"',
227
+ '>> "%USERPROFILE%\.mobius\logs\launcher.log" echo %DATE% %TIME% exit=%ERRORLEVEL%',
223
228
  'endlocal'
224
229
  )
225
230
  Set-Content -Path $openHereCmd -Value $openHereLines -Encoding ASCII
226
231
 
227
232
  # 管理员入口: Explorer 直接跑这个脚本, 由它用 UAC 提权拉起同一个启动器.
228
233
  # -Encoding UTF8 在 Windows PowerShell 5.1 会写入 BOM, -File 才能正确读中文/引号.
234
+ # 优先显式拉起 Windows Terminal: 隐藏父窗口创建的控制台不会被默认终端接管,
235
+ # 落到 conhost 后中文/歧义宽度字符按 2 列渲染, TUI 右对齐的行会折行.
236
+ # Use Windows Terminal explicitly: the hidden parent's console is not handed to
237
+ # the default terminal, and conhost renders wide/ambiguous chars in 2 cells.
229
238
  $openHereAdminPs1 = Join-Path $binDir "mobius-open-here-admin.ps1"
230
239
  $openHereAdminLines = @(
231
240
  'param([string]$Target)',
241
+ '# 每次启动覆盖写诊断日志, 闪退时可以直接看原因.',
242
+ '# Overwrite a diagnostic log on every launch so a flash-and-close can be explained later.',
243
+ '$log = Join-Path $env:USERPROFILE ".mobius\logs\admin-launch.log"',
244
+ 'try {',
245
+ ' New-Item -ItemType Directory -Force -Path (Split-Path $log) | Out-Null',
232
246
  '# 右键文件夹时 Explorer 会传路径, 兜底用当前目录.',
233
- 'if (-not $Target) { $Target = (Get-Location).Path }',
234
- 'Start-Process -FilePath (Join-Path $PSScriptRoot ''mobius-open-here.cmd'') -ArgumentList (''"{0}"'' -f $Target) -Verb RunAs'
247
+ '# Explorer passes the folder path; fall back to the current directory.',
248
+ ' if (-not $Target) { $Target = (Get-Location).Path }',
249
+ ' $launcher = Join-Path $PSScriptRoot "mobius-open-here.cmd"',
250
+ ' $wt = Join-Path $env:LOCALAPPDATA "Microsoft\WindowsApps\wt.exe"',
251
+ ' if (Test-Path $wt) {',
252
+ '# wt 用 -d 指定起始目录, 再让 cmd 执行同一个启动器.',
253
+ '# wt takes the starting directory with -d and runs the same launcher via cmd.',
254
+ ' $wtArgs = ''-d "{0}" cmd.exe /d /s /c ""{1}" "{2}""'' -f $Target, $launcher, $Target',
255
+ ' Start-Process -FilePath $wt -ArgumentList $wtArgs',
256
+ ' "$(Get-Date -Format o) launched wt target=$Target launcher=$launcher" | Set-Content -Path $log',
257
+ ' } else {',
258
+ ' $commandLine = ''/d /s /c ""{0}" "{1}""'' -f $launcher, $Target',
259
+ '# 第五个参数 1 是 SW_SHOWNORMAL, 强制提权后的窗口可见.',
260
+ '# The fifth argument is SW_SHOWNORMAL, forcing the elevated window to be visible.',
261
+ ' $shell = New-Object -ComObject Shell.Application',
262
+ ' $shell.ShellExecute($env:ComSpec, $commandLine, $PSScriptRoot, "runas", 1)',
263
+ ' "$(Get-Date -Format o) launched conhost target=$Target launcher=$launcher" | Set-Content -Path $log',
264
+ ' }',
265
+ '} catch {',
266
+ ' "$(Get-Date -Format o) failed: $($_.Exception.Message)" | Set-Content -Path $log',
267
+ '}'
235
268
  )
236
269
  Set-Content -Path $openHereAdminPs1 -Value $openHereAdminLines -Encoding UTF8
237
270
 
@@ -282,7 +315,7 @@ Write-Host "右键文件夹或文件夹空白处,可选择: 在Mobius终端中
282
315
  try {
283
316
  Invoke-MobiusInstall
284
317
  } catch {
285
- $errorLog = Join-Path $env:TEMP "mobius-install-v16-error.log"
318
+ $errorLog = Join-Path $env:TEMP "mobius-install-v18-error.log"
286
319
  $errorText = $_ | Format-List * -Force | Out-String
287
320
  $errorText | Set-Content -Path $errorLog -Encoding UTF8
288
321
  Write-Host ""
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mobius-os/mobius",
3
- "version": "0.3.73",
3
+ "version": "0.3.75",
4
4
  "type": "module",
5
5
  "description": "Mobius terminal client. Reuses Mobius frontend TypeScript types and jsonl entry shapes.",
6
6
  "bin": {
@@ -1,6 +1,7 @@
1
1
  import React from 'react'
2
2
  import { Box, Text } from 'ink'
3
3
  import type { AimuxStatus } from '../aimux.js'
4
+ import { hostText } from '../lib/host-text.js'
4
5
 
5
6
  const STYLE: Record<AimuxStatus['state'], { icon: string; color: 'green' | 'yellow' | 'red' | 'gray' }> = {
6
7
  connected: { icon: '●', color: 'green' },
@@ -15,14 +16,16 @@ const STYLE: Record<AimuxStatus['state'], { icon: string; color: 'green' | 'yell
15
16
  export function aimuxStatusText(status: AimuxStatus, compact = false): string {
16
17
  const phase = status.phase && !['idle', 'connected'].includes(status.phase) ? ` · ${phaseLabel(status.phase)}` : ''
17
18
  const detail = status.detail || stateLabel(status.state)
18
- return `AIMUX${phase} · ${compact ? compactDetail(detail) : detail}`
19
+ // conhost 把 · 等歧义字符画成两列, Ink 只算一列 → 右侧内容溢出.
20
+ // conhost draws ambiguous glyphs two cells wide while Ink counts one.
21
+ return hostText(`AIMUX${phase} · ${compact ? compactDetail(detail) : detail}`)
19
22
  }
20
23
 
21
24
  export function AimuxStatusLine({ status, compact = false }: { status: AimuxStatus; compact?: boolean }) {
22
25
  const style = STYLE[status.state]
23
26
  return (
24
27
  <Box>
25
- <Text color={style.color}>{style.icon}</Text>
28
+ <Text color={style.color}>{hostText(style.icon)}</Text>
26
29
  <Text dimColor={status.state === 'disabled' || status.state === 'stopped'}>
27
30
  {' ' + aimuxStatusText(status, compact)}
28
31
  </Text>
@@ -22,6 +22,7 @@ import {
22
22
  type RowAnchor,
23
23
  } from '../lib/transcript-viewport.js'
24
24
  import type { ReadyState } from './PrepScreen.js'
25
+ import { IS_CONHOST, hostText } from '../lib/host-text.js'
25
26
  import type { AnyEntry } from '../types.js'
26
27
  import { ConfigFlow, ReconfigFlow, type ConfigResult } from './ConfigFlow.js'
27
28
  import { AIMUX_VERSION, type AimuxStatus } from '../aimux.js'
@@ -518,7 +519,7 @@ function MetaRow({ label, value, hint, labelWidth }: { label: string; value: str
518
519
  }
519
520
 
520
521
  function CompactHeader({ ready, sessionId, columns }: { ready: ReadyState; sessionId: string | null; columns: number }) {
521
- const context = `${ready.project.name} › ${ready.issue.title}${sessionId ? ` · ${sessionId.slice(0, 8)}` : ''}`
522
+ const context = hostText(`${ready.project.name} › ${ready.issue.title}${sessionId ? ` · ${sessionId.slice(0, 8)}` : ''}`)
522
523
  return (
523
524
  <Box justifyContent="space-between">
524
525
  <Text bold><Text dimColor>{'>_ '}</Text>Mobius</Text>
@@ -1012,8 +1013,8 @@ export function Composer({ onSubmit, onStop, onQuit, typing, commands, onHeightC
1012
1013
  {confirmQuit
1013
1014
  ? <Text color="yellowBright" bold>请再次按下Ctrl+C退出</Text>
1014
1015
  : <Text dimColor>
1015
- {hasPending ? <Text color="yellowBright">空回车插队 · </Text> : null}
1016
- {(stdout.columns ?? 80) >= 72 ? 'Enter 发送 · Shift+Enter / Alt+Enter / Ctrl+J 换行' : 'Enter 发送 · Alt+Enter / Ctrl+J 换行'}
1016
+ {hasPending ? <Text color="yellowBright">{hostText('空回车插队 · ')}</Text> : null}
1017
+ {hostText((stdout.columns ?? 80) >= 72 ? 'Enter 发送 · Shift+Enter / Alt+Enter / Ctrl+J 换行' : 'Enter 发送 · Alt+Enter / Ctrl+J 换行')}
1017
1018
  </Text>}
1018
1019
  <Text dimColor>{wrapped.length > maxRows ? `${visualCursor + 1}/${wrapped.length} 行` : `${wrapped.length} 行`}</Text>
1019
1020
  </Box>
@@ -1114,14 +1115,17 @@ function StatusArea({ ready, sessionId, columns, webUrl, aimuxStatus, modelDispl
1114
1115
  const model = modelDisplay
1115
1116
  const language = ready.prefs.language === 'en' ? 'English' : '中文'
1116
1117
  const cwd = compactPath(process.cwd())
1117
- const leftRaw = columns >= 100
1118
+ const leftRaw = hostText(columns >= 100
1118
1119
  ? `${model} · ${language} · ${cwd}`
1119
- : `${model} · ${ready.project.name}`
1120
- const rightRaw = columns >= 72
1120
+ : `${model} · ${ready.project.name}`)
1121
+ const rightRaw = hostText(columns >= 72
1121
1122
  ? `${ready.project.name} › ${ready.issue.title}${sessionId ? ` · ${sessionId.slice(0, 8)}` : ''}`
1122
- : ''
1123
+ : '')
1123
1124
  const left = truncateDisplay(leftRaw, rightRaw ? Math.floor(columns * 0.45) : columns - 2)
1124
- const right = rightRaw ? truncateDisplay(rightRaw, columns - left.length - 5) : ''
1125
+ // 宽度按显示列算, 不能用 .length: 中文/表情占两列, 按字符数会多给出预算.
1126
+ // Measure display columns, not UTF-16 units, or wide chars push the row over.
1127
+ const leftShown = copyNotice ?? left
1128
+ const right = rightRaw ? truncateDisplay(rightRaw, columns - displayWidth(leftShown) - 5) : ''
1125
1129
  return (
1126
1130
  <Box flexDirection="column" marginTop={1}>
1127
1131
  <Box justifyContent="space-between">
@@ -1146,12 +1150,15 @@ function ConnectivityRow({ aimuxStatus, webUrl, columns }: { aimuxStatus?: Aimux
1146
1150
  // No AIMUX status → web URL keeps the whole row (unchanged from before).
1147
1151
  // Otherwise leave room for the AIMUX block + 'web · ' prefix + a safety gap
1148
1152
  // (the gap also absorbs ambiguous-width chars like box-drawing in the detail).
1153
+ // conhost 下 '·' 按两列渲染, 改用 ASCII 前缀.
1154
+ // Under conhost '·' renders two cells wide, so use the ASCII prefix.
1155
+ const prefix = hostText(WEB_PREFIX)
1149
1156
  const urlBudget = aimuxWidth
1150
- ? Math.max(8, columns - 2 - aimuxWidth - WEB_PREFIX.length - 6)
1157
+ ? Math.max(8, columns - 2 - aimuxWidth - prefix.length - 6)
1151
1158
  : undefined
1152
1159
  const web = (
1153
1160
  <Text>
1154
- <Text dimColor>{WEB_PREFIX}</Text>
1161
+ <Text dimColor>{prefix}</Text>
1155
1162
  <Text color="cyan" underline>{clickableUrl(webUrl, urlBudget)}</Text>
1156
1163
  </Text>
1157
1164
  )
@@ -1173,10 +1180,24 @@ function compactPath(path: string): string {
1173
1180
  return path.startsWith(`${home}/`) ? `~/${path.slice(home.length + 1)}` : path
1174
1181
  }
1175
1182
 
1176
- function truncateDisplay(value: string, maxLength: number): string {
1177
- const limit = Math.max(1, Math.floor(maxLength))
1178
- if (value.length <= limit) return value
1179
- return limit <= 1 ? '…' : `${value.slice(0, limit - 1)}…`
1183
+ function truncateDisplay(value: string, maxWidth: number): string {
1184
+ // conhost 下用 ASCII 省略号, 避免 … 按两列渲染又溢出一列.
1185
+ // Use an ASCII ellipsis under conhost: … renders two cells there while Ink counts one.
1186
+ const ellipsis = IS_CONHOST ? '...' : '…'
1187
+ const limit = Math.max(1, Math.floor(maxWidth))
1188
+ if (displayWidth(value) <= limit) return value
1189
+ if (limit <= displayWidth(ellipsis)) return ellipsis
1190
+ // 按显示列切, 不把一个双列字符劈成两半.
1191
+ // Cut on display columns so a double-width char is never split in half.
1192
+ let out = ''
1193
+ let width = 0
1194
+ for (const ch of Array.from(value)) {
1195
+ const w = displayWidth(ch)
1196
+ if (width + w > limit - displayWidth(ellipsis)) break
1197
+ out += ch
1198
+ width += w
1199
+ }
1200
+ return `${out}${ellipsis}`
1180
1201
  }
1181
1202
 
1182
1203
  function buildWebUrl(server: string, webUserId: string, ready: ReadyState, sessionId: string | null): string {
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Terminal-host quirks for classic Windows consoles.
3
+ *
4
+ * conhost (the native cmd window) renders East Asian ambiguous characters
5
+ * (·, ›, …, ●, ○) as two cells when the console font is a CJK font, while Ink's
6
+ * layout (string-width) counts them as one. Right-aligned rows therefore spill
7
+ * their last cells onto the next line, and resizing the window does not help
8
+ * because the mismatch depends on the glyphs, not the width. Windows Terminal
9
+ * renders the same characters as one cell, so only classic conhost needs the
10
+ * ASCII fallbacks below.
11
+ */
12
+ export const IS_CONHOST = process.platform === 'win32'
13
+ && !process.env.WT_SESSION
14
+ && process.env.TERM_PROGRAM !== 'vscode'
15
+
16
+ const ASCII_FALLBACK: Record<string, string> = {
17
+ '·': '-', // middle dot used in status separators
18
+ '›': '>', // breadcrumb separator
19
+ '…': '...', // ellipsis
20
+ '●': '*', // filled status dot
21
+ '○': 'o', // hollow status dot
22
+ '◐': '~', // partial status dot
23
+ '◇': '<>', // reasoning marker
24
+ '✎': '*', // edit marker
25
+ '⚠': '!', // warning marker
26
+ '•': '*', // bullet
27
+ }
28
+
29
+ /** Replace wide-rendered ambiguous glyphs when running inside classic conhost. */
30
+ export function hostText(value: string): string {
31
+ if (!IS_CONHOST) return value
32
+ let out = ''
33
+ for (const ch of Array.from(value)) out += ASCII_FALLBACK[ch] ?? ch
34
+ return out
35
+ }
package/uninstall.ps1 CHANGED
@@ -119,14 +119,10 @@ function Invoke-MobiusUninstall {
119
119
  Step '删除临时安装器和旧错误日志...'
120
120
  Get-ChildItem $env:TEMP -Filter 'mobius-install-v*.ps1' -ErrorAction SilentlyContinue |
121
121
  Remove-Item -Force -ErrorAction SilentlyContinue
122
- Remove-Item (Join-Path $env:TEMP 'mobius-install-v10-error.log') -Force -ErrorAction SilentlyContinue
123
- Remove-Item (Join-Path $env:TEMP 'mobius-install-v11-error.log') -Force -ErrorAction SilentlyContinue
124
- Remove-Item (Join-Path $env:TEMP 'mobius-install-v12-error.log') -Force -ErrorAction SilentlyContinue
125
- Remove-Item (Join-Path $env:TEMP 'mobius-install-v13-error.log') -Force -ErrorAction SilentlyContinue
126
- Remove-Item (Join-Path $env:TEMP 'mobius-install-v14-error.log') -Force -ErrorAction SilentlyContinue
127
- Remove-Item (Join-Path $env:TEMP 'mobius-install-v15-error.log') -Force -ErrorAction SilentlyContinue
128
- Remove-Item (Join-Path $env:TEMP 'mobius-install-v16-error.log') -Force -ErrorAction SilentlyContinue
129
- Remove-Item (Join-Path $env:TEMP 'mobius-uninstall-v11-error.log') -Force -ErrorAction SilentlyContinue
122
+ Get-ChildItem $env:TEMP -Filter 'mobius-install-v*-error.log' -ErrorAction SilentlyContinue |
123
+ Remove-Item -Force -ErrorAction SilentlyContinue
124
+ Get-ChildItem $env:TEMP -Filter 'mobius-uninstall-v*-error.log' -ErrorAction SilentlyContinue |
125
+ Remove-Item -Force -ErrorAction SilentlyContinue
130
126
  Ok '临时安装文件已清理。'
131
127
 
132
128
  Write-Host ''