@clipen/clipen-cli 1.0.7 → 1.0.8

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 (38) hide show
  1. package/README.md +3 -2
  2. package/apps/web/dist/assets/{index-CaxEZKLc.css → index-CJ80KHsQ.css} +1 -1
  3. package/apps/web/dist/assets/index-C_4u_hVf.js +16 -0
  4. package/apps/web/dist/index.html +2 -2
  5. package/bin/clipen.js +231 -61
  6. package/package.json +8 -2
  7. package/pyproject.toml +1 -1
  8. package/src/clipen/__init__.py +1 -1
  9. package/src/clipen/analysis/qwen_worker.py +13 -4
  10. package/src/clipen/analysis/setup.py +2 -1
  11. package/src/clipen/analysis/setup_cli.py +58 -12
  12. package/src/clipen/bootstrap.py +389 -164
  13. package/src/clipen/cli.py +40 -15
  14. package/src/clipen/controller/app.py +37 -17
  15. package/src/clipen/controller/server.py +65 -27
  16. package/src/clipen/editing/agent_repository.py +8 -0
  17. package/src/clipen/editing/change_report.py +17 -0
  18. package/src/clipen/editing/coordinator.py +6 -0
  19. package/src/clipen/editing/evidence_jobs.py +3 -1
  20. package/src/clipen/editing/history_changes.py +56 -27
  21. package/src/clipen/editing/production_progress.py +46 -3
  22. package/src/clipen/editing/versions.py +53 -10
  23. package/src/clipen/i18n.py +155 -0
  24. package/src/clipen/locale_en.py +528 -0
  25. package/src/clipen/mcp_editing/__main__.py +8 -0
  26. package/src/clipen/projects/models.py +16 -1
  27. package/src/clipen/projects/picker.py +3 -1
  28. package/src/clipen/projects/storage.py +17 -1
  29. package/src/clipen/providers/claude_editing.py +3 -1
  30. package/src/clipen/providers/codex_editing.py +3 -1
  31. package/src/clipen/providers/editing_agent.py +36 -1
  32. package/src/clipen/providers/liveness.py +39 -0
  33. package/src/clipen/skills/builtin/display.en.json +89 -0
  34. package/src/clipen/skills/builtin/references/graphics.md +0 -1
  35. package/src/clipen/skills/catalog.py +22 -0
  36. package/src/clipen/terminal.py +344 -0
  37. package/src/clipen/workspace.py +97 -28
  38. package/apps/web/dist/assets/index-C3Zw0WaM.js +0 -14
@@ -20,20 +20,18 @@ from pathlib import Path
20
20
  from types import ModuleType
21
21
  from typing import Iterator, Mapping, Sequence, TextIO
22
22
 
23
+ from clipen import __version__
23
24
  from clipen.asr_release import (
24
25
  ASR_SOFTWARE_LICENSE,
25
- ASR_SOFTWARE_LICENSE_URL,
26
26
  DOWNLOAD_BYTES,
27
- INSTALLED_BYTES,
28
- LICENSE_NOTICE,
29
27
  MODEL_NAME,
30
- MODEL_REPOSITORY,
31
- MODEL_REVISION,
32
28
  PROGRESS_RECORD_PREFIX,
33
29
  quick_release_is_ready,
34
30
  release_root,
35
31
  )
32
+ from clipen.i18n import current, normalize, save_language, saved_language, speaking, system_language, tr
36
33
  from clipen.own_python import sealed_environment
34
+ from clipen.terminal import FRAME_OPEN, Terminal
37
35
 
38
36
  try:
39
37
  import fcntl as _fcntl
@@ -42,6 +40,9 @@ except ImportError: # Windows does not provide POSIX advisory file locks.
42
40
 
43
41
 
44
42
  _RUNTIME_SCHEMA = 1
43
+ # Rough download sizes, so the person knows what setup costs before agreeing to it.
44
+ _RUNTIME_DOWNLOAD_BYTES = 80_000_000
45
+ _CHROMIUM_DOWNLOAD_BYTES = 150_000_000
45
46
  _PIP_VERSION = "26.2.1"
46
47
  _SETUPTOOLS_VERSION = "84.0.0"
47
48
  _WHEEL_VERSION = "0.48.0"
@@ -77,7 +78,12 @@ class BootstrapError(RuntimeError):
77
78
 
78
79
  def _require_posix_file_locking() -> ModuleType:
79
80
  if _fcntl is None:
80
- raise BootstrapError("這個開發版本尚不支援 Windows;第一次設定需要 POSIX 檔案鎖")
81
+ raise BootstrapError(
82
+ tr(
83
+ "這個開發版本尚不支援 Windows;第一次設定需要 POSIX 檔案鎖",
84
+ "This version does not support Windows yet; first-time setup needs POSIX file locks",
85
+ )
86
+ )
81
87
  return _fcntl
82
88
 
83
89
 
@@ -153,7 +159,9 @@ def _runtime_fingerprint(repo_root: Path, *, project_version: bytes | None) -> s
153
159
  ):
154
160
  path = repo_root / relative
155
161
  if not path.is_file() or path.is_symlink():
156
- raise BootstrapError(f"缺少必要的 runtime 定義:{relative}")
162
+ raise BootstrapError(
163
+ tr(f"缺少必要的 runtime 定義:{relative}", f"A required runtime definition is missing: {relative}")
164
+ )
157
165
  digest.update(relative.encode())
158
166
  contents = path.read_bytes()
159
167
  if relative == "pyproject.toml" and project_version is not None:
@@ -222,7 +230,6 @@ def _ready_runtime(root: Path, fingerprint: str, repo_root: Path) -> Path | None
222
230
 
223
231
 
224
232
  def _confirm_setup(
225
- runtime: Path,
226
233
  stdin: TextIO,
227
234
  stdout: TextIO,
228
235
  *,
@@ -231,47 +238,50 @@ def _confirm_setup(
231
238
  asr_root: Path | None = None,
232
239
  include_runtime: bool = True,
233
240
  ) -> bool:
234
- print("Clipen 第一次設定" if include_runtime else "Clipen 需要完成設定", file=stdout)
235
- print("將會建立:", file=stdout)
236
- if include_runtime:
237
- print(" • Clipen 專用 Python 虛擬環境", file=stdout)
238
- print(" • 鎖定版本的本機 Controller 與安全驗證套件", file=stdout)
239
- if asr_root is not None:
240
- print(" • 隔離的本機語音辨識執行環境", file=stdout)
241
- print(f" • 固定版本 {MODEL_NAME} 模型", file=stdout)
242
- if command_path is not None and profile_path is not None:
243
- print(f" • `clipen` 指令:{command_path}", file=stdout)
244
- print(f" • 將 Clipen 加入 PATH:{profile_path}", file=stdout)
241
+ """One short screen: how much is downloaded, how long it takes, and what changes on the Mac."""
242
+ terminal = Terminal(stdout)
243
+ download = (_RUNTIME_DOWNLOAD_BYTES if include_runtime else 0) + (DOWNLOAD_BYTES if asr_root is not None else 0)
245
244
  if not _chrome_ready(Path.home()):
246
- print(" • Chromium(這台 Mac 沒有 Google Chrome;Clipen 用它畫畫面元件,約 150 MB)", file=stdout)
247
- if include_runtime:
248
- print(f"Clipen runtime:{runtime}", file=stdout)
245
+ download += _CHROMIUM_DOWNLOAD_BYTES
246
+ lines = [tr(f"需要下載約 {terminal.bold(_size(download))}", f"Downloads about {terminal.bold(_size(download))}")]
249
247
  if asr_root is not None:
250
- print(f"語音辨識:{asr_root}", file=stdout)
251
- print(
252
- f"語音辨識部分需下載約 {DOWNLOAD_BYTES / 1_000_000_000:.1f} GB,"
253
- f"安裝後約 {INSTALLED_BYTES / 1_000_000_000:.1f} GB。",
254
- file=stdout,
255
- )
256
- print(
257
- f"模型來源:{MODEL_REPOSITORY} @ {MODEL_REVISION[:8]}",
258
- file=stdout,
248
+ lines[0] += tr("(大部分是語音辨識模型)", " (mostly the speech recognition model)")
249
+ lines.append(tr("依網路速度大約 5–15 分鐘", "About 5–15 minutes, depending on your connection"))
250
+ if command_path is not None and profile_path is not None:
251
+ lines.append(
252
+ tr(
253
+ f"會新增 {terminal.bold('clipen')} 指令,之後直接輸入 clipen codex 就能開始",
254
+ f"Adds the {terminal.bold('clipen')} command; afterwards just type clipen codex to start",
255
+ )
259
256
  )
260
- print("繁體中文轉換套件:PyPI 鎖定版本", file=stdout)
261
- print(
262
- f"MLX Speech 本機執行程式:{ASR_SOFTWARE_LICENSE}({ASR_SOFTWARE_LICENSE_URL})",
263
- file=stdout,
257
+ fine_print = [tr("不會動到你原本的 Python,也不需要 sudo", "Leaves your own Python alone and needs no sudo")]
258
+ if asr_root is not None:
259
+ fine_print.insert(
260
+ 0,
261
+ tr(
262
+ f"語音辨識模型 {MODEL_NAME} 採 Apache-2.0,執行程式 MLX Speech 採 {ASR_SOFTWARE_LICENSE}",
263
+ f"Speech model {MODEL_NAME} is Apache-2.0; the MLX Speech runtime is {ASR_SOFTWARE_LICENSE}",
264
+ ),
264
265
  )
265
- print(LICENSE_NOTICE, file=stdout)
266
- print("依網路速度可能需要數分鐘;安裝期間會持續顯示目前階段與經過時間。", file=stdout)
267
- print("不會使用或修改你電腦上原有的 Python,也不會使用 sudo。", file=stdout)
268
- print("AI(Codex/Claude)登入與模型呼叫不會在設定階段執行。", file=stdout)
266
+ terminal.note(
267
+ tr("安裝 Clipen", "Install Clipen")
268
+ if include_runtime
269
+ else tr("Clipen 需要完成設定", "Clipen needs to finish setting up"),
270
+ lines,
271
+ fine_print,
272
+ )
269
273
  if not stdin.isatty():
270
- raise BootstrapError("第一次設定需要在互動式 Terminal 中確認。")
271
- stdout.write("開始完整設定?[Y/n] ")
272
- stdout.flush()
273
- answer = stdin.readline().strip().lower()
274
- return answer in {"", "y", "yes"}
274
+ raise BootstrapError(
275
+ tr(
276
+ "第一次設定需要在互動式 Terminal 中確認。",
277
+ "First-time setup needs confirming in an interactive Terminal.",
278
+ )
279
+ )
280
+ return terminal.confirm(tr("開始安裝?", "Start the install?"), stdin)
281
+
282
+
283
+ def _size(count: int) -> str:
284
+ return f"{count / 1_000_000_000:.1f} GB" if count >= 1_000_000_000 else f"{round(count / 1_000_000)} MB"
275
285
 
276
286
 
277
287
  # What the web UI is built from, inside apps/web.
@@ -300,13 +310,18 @@ def ensure_web_build(repo_root: Path, stream: TextIO = sys.stdout) -> None:
300
310
  return
301
311
  npm = shutil.which("npm")
302
312
  if npm is None:
303
- raise BootstrapError("從原始碼執行 Clipen 需要 Node.js 18 以上來建立操作介面:https://nodejs.org")
304
- print("正在建立 Clipen 操作介面…", file=stream)
313
+ raise BootstrapError(
314
+ tr(
315
+ "從原始碼執行 Clipen 需要 Node.js 18 以上來建立操作介面:https://nodejs.org",
316
+ "Running Clipen from source needs Node.js 18 or later to build the interface: https://nodejs.org",
317
+ )
318
+ )
305
319
  quiet = {"cwd": web, "check": True, "stdout": subprocess.DEVNULL}
306
- if not (web / "node_modules").is_dir():
307
- subprocess.run([npm, "ci", "--no-audit", "--no-fund"], **quiet)
308
- subprocess.run([npm, "run", "build"], **quiet)
309
- print("✓ 操作介面建立完成", file=stream)
320
+ with Terminal(stream).spinner(tr("正在建立 Clipen 操作介面", "Building the Clipen interface")) as spinner:
321
+ if not (web / "node_modules").is_dir():
322
+ subprocess.run([npm, "ci", "--no-audit", "--no-fund"], **quiet)
323
+ subprocess.run([npm, "run", "build"], **quiet)
324
+ spinner.done(tr("操作介面建立完成", "Interface built"))
310
325
 
311
326
 
312
327
  def _install_hint(repo_root: Path) -> str:
@@ -323,18 +338,27 @@ def _chrome_ready(home: Path) -> bool:
323
338
  def _ensure_chrome(runtime: Path, data_root: Path, home: Path, stdout: TextIO) -> None:
324
339
  if _chrome_ready(home):
325
340
  return
326
- print("這台 Mac 沒有 Google Chrome;正在下載 Clipen 畫元件用的 Chromium(約 150 MB)…", file=stdout)
327
341
  log_root = data_root / "logs"
328
342
  log_root.mkdir(mode=0o700, parents=True, exist_ok=True)
329
- with (log_root / "bootstrap-chromium.log").open("w", encoding="utf-8") as log:
343
+ with (
344
+ Terminal(stdout).spinner(
345
+ tr("正在下載繪製畫面用的瀏覽器(Chromium)", "Downloading the browser used to draw graphics (Chromium)")
346
+ ) as spinner,
347
+ (log_root / "bootstrap-chromium.log").open("w", encoding="utf-8") as log,
348
+ ):
330
349
  _run_logged((str(runtime_python(runtime)), "-m", "playwright", "install", "chromium"), cwd=runtime, log=log)
331
- print("✓ Chromium 準備完成", file=stdout)
350
+ spinner.done(tr("瀏覽器就緒", "Browser ready"))
332
351
 
333
352
 
334
353
  def _command_script(repo_root: Path) -> str:
335
354
  launcher = repo_root.resolve(strict=True) / "clipen"
336
355
  if launcher.is_symlink() or not launcher.is_file() or not os.access(launcher, os.X_OK):
337
- raise BootstrapError("Repo 內的 clipen launcher 不存在或不可執行")
356
+ raise BootstrapError(
357
+ tr(
358
+ "Repo 內的 clipen launcher 不存在或不可執行",
359
+ "The clipen launcher in the repository is missing or not executable",
360
+ )
361
+ )
338
362
  # Run the launcher with the Python that set Clipen up: a Mac's own python3 is too old.
339
363
  python = Path(sys.executable).resolve()
340
364
  # -I: the person's PYTHONPATH, PYTHONHOME and user site never reach Clipen's Python.
@@ -347,7 +371,12 @@ def _shell_profile(home: Path, environment: Mapping[str, str]) -> Path:
347
371
  return home / ".zshrc"
348
372
  if shell == "bash":
349
373
  return home / (".bash_profile" if sys.platform == "darwin" else ".bashrc")
350
- raise BootstrapError("目前只能自動設定 zsh 或 bash;請將 Clipen 的 bin 目錄手動加入 PATH")
374
+ raise BootstrapError(
375
+ tr(
376
+ "目前只能自動設定 zsh 或 bash;請將 Clipen 的 bin 目錄手動加入 PATH",
377
+ "Only zsh and bash can be set up automatically; add Clipen's bin folder to PATH yourself",
378
+ )
379
+ )
351
380
 
352
381
 
353
382
  def _profile_block(bin_root: Path) -> str:
@@ -356,11 +385,21 @@ def _profile_block(bin_root: Path) -> str:
356
385
 
357
386
  def _replace_profile_block(contents: str, block: str) -> str:
358
387
  if contents.count(_PROFILE_START) > 1 or contents.count(_PROFILE_END) > 1:
359
- raise BootstrapError("shell 設定中有重複的 Clipen PATH 區塊,請先保留並回報問題")
388
+ raise BootstrapError(
389
+ tr(
390
+ "shell 設定中有重複的 Clipen PATH 區塊,請先保留並回報問題",
391
+ "Your shell settings have a duplicate Clipen PATH block; keep it and report the problem",
392
+ )
393
+ )
360
394
  start = contents.find(_PROFILE_START)
361
395
  end = contents.find(_PROFILE_END)
362
396
  if (start < 0) != (end < 0) or (start >= 0 and end < start):
363
- raise BootstrapError("shell 設定中的 Clipen PATH 區塊不完整,請先保留並回報問題")
397
+ raise BootstrapError(
398
+ tr(
399
+ "shell 設定中的 Clipen PATH 區塊不完整,請先保留並回報問題",
400
+ "The Clipen PATH block in your shell settings is incomplete; keep it and report the problem",
401
+ )
402
+ )
364
403
  if start >= 0:
365
404
  end += len(_PROFILE_END)
366
405
  updated = contents[:start] + block + contents[end:]
@@ -372,11 +411,21 @@ def _replace_profile_block(contents: str, block: str) -> str:
372
411
 
373
412
  def _remove_profile_block(contents: str) -> str:
374
413
  if contents.count(_PROFILE_START) > 1 or contents.count(_PROFILE_END) > 1:
375
- raise BootstrapError("shell 設定中有重複的 Clipen PATH 區塊,未進行移除")
414
+ raise BootstrapError(
415
+ tr(
416
+ "shell 設定中有重複的 Clipen PATH 區塊,未進行移除",
417
+ "Your shell settings have a duplicate Clipen PATH block, so nothing was removed",
418
+ )
419
+ )
376
420
  start = contents.find(_PROFILE_START)
377
421
  end = contents.find(_PROFILE_END)
378
422
  if (start < 0) != (end < 0) or (start >= 0 and end < start):
379
- raise BootstrapError("shell 設定中的 Clipen PATH 區塊不完整,未進行移除")
423
+ raise BootstrapError(
424
+ tr(
425
+ "shell 設定中的 Clipen PATH 區塊不完整,未進行移除",
426
+ "The Clipen PATH block in your shell settings is incomplete, so nothing was removed",
427
+ )
428
+ )
380
429
  if start < 0:
381
430
  return contents
382
431
  end += len(_PROFILE_END)
@@ -409,28 +458,44 @@ def _install_command(
409
458
  ) -> tuple[Path, Path]:
410
459
  bin_root = data_root / "bin"
411
460
  if bin_root.exists() and (bin_root.is_symlink() or not bin_root.is_dir()):
412
- raise BootstrapError("Clipen bin 目錄不是安全的實體目錄")
461
+ raise BootstrapError(tr("Clipen bin 目錄不是安全的實體目錄", "Clipen's bin folder is not a safe, real folder"))
413
462
  bin_root.mkdir(mode=0o700, parents=True, exist_ok=True)
414
463
  command_path = bin_root / "clipen"
415
464
  script = _command_script(repo_root)
416
465
  if command_path.exists() or command_path.is_symlink():
417
466
  if command_path.is_symlink() or not command_path.is_file():
418
- raise BootstrapError("Clipen 指令位置已被不安全的檔案占用")
467
+ raise BootstrapError(
468
+ tr("Clipen 指令位置已被不安全的檔案占用", "An unsafe file is in the way of the clipen command")
469
+ )
419
470
  try:
420
471
  existing_command = command_path.read_text(encoding="utf-8")
421
472
  except (OSError, UnicodeError) as error:
422
- raise BootstrapError("無法安全讀取既有的 Clipen 指令") from error
473
+ raise BootstrapError(
474
+ tr("無法安全讀取既有的 Clipen 指令", "The existing clipen command cannot be read safely")
475
+ ) from error
423
476
  if _COMMAND_MARKER not in existing_command:
424
- raise BootstrapError("Clipen 指令位置已有其他程式,未進行覆寫")
477
+ raise BootstrapError(
478
+ tr(
479
+ "Clipen 指令位置已有其他程式,未進行覆寫",
480
+ "Another program already uses the clipen command, so it was not overwritten",
481
+ )
482
+ )
425
483
 
426
484
  profile_path = _shell_profile(home, environment)
427
485
  if profile_path.exists() or profile_path.is_symlink():
428
486
  if profile_path.is_symlink() or not profile_path.is_file():
429
- raise BootstrapError("shell 設定檔不是安全的實體檔案,未進行修改")
487
+ raise BootstrapError(
488
+ tr(
489
+ "shell 設定檔不是安全的實體檔案,未進行修改",
490
+ "Your shell settings file is not a safe, real file, so it was not changed",
491
+ )
492
+ )
430
493
  try:
431
494
  profile = profile_path.read_text(encoding="utf-8")
432
495
  except (OSError, UnicodeError) as error:
433
- raise BootstrapError("無法安全讀取 shell 設定檔") from error
496
+ raise BootstrapError(
497
+ tr("無法安全讀取 shell 設定檔", "Your shell settings file cannot be read safely")
498
+ ) from error
434
499
  profile_mode = stat.S_IMODE(profile_path.stat().st_mode)
435
500
  else:
436
501
  profile = ""
@@ -488,14 +553,19 @@ def _run_logged(command: Sequence[str], *, cwd: Path, log: TextIO) -> None:
488
553
  env=sealed_environment(os.environ),
489
554
  )
490
555
  if completed.returncode != 0:
491
- raise BootstrapError(f"runtime 安裝命令失敗(結束代碼 {completed.returncode})")
556
+ raise BootstrapError(
557
+ tr(
558
+ f"runtime 安裝命令失敗(結束代碼 {completed.returncode})",
559
+ f"The runtime install command failed (exit code {completed.returncode})",
560
+ )
561
+ )
492
562
 
493
563
 
494
564
  def _install_runtime(staging: Path, repo_root: Path, fingerprint: str, log_path: Path) -> None:
495
565
  venv.EnvBuilder(with_pip=True, clear=False, symlinks=False).create(staging)
496
566
  python = runtime_python(staging)
497
567
  if not python.is_file():
498
- raise BootstrapError("無法建立 Clipen Python runtime")
568
+ raise BootstrapError(tr("無法建立 Clipen Python runtime", "Could not create Clipen's Python runtime"))
499
569
 
500
570
  with log_path.open("w", encoding="utf-8") as log:
501
571
  _run_logged(
@@ -569,8 +639,9 @@ def _install_asr_bundle(
569
639
  )
570
640
  captured = 0
571
641
  process: subprocess.Popen[str] | None = None
642
+ terminal = Terminal(stdout)
572
643
  progress_active = False
573
- progress_width = 0
644
+ frame = 0
574
645
  try:
575
646
  with log_path.open("w", encoding="utf-8") as log:
576
647
  process = subprocess.Popen(
@@ -593,32 +664,33 @@ def _install_asr_bundle(
593
664
  captured += len(line.encode("utf-8"))
594
665
  if captured > 4 * 1024 * 1024:
595
666
  process.terminate()
596
- raise BootstrapError("語音辨識設定輸出超過安全上限")
667
+ raise BootstrapError(
668
+ tr("語音辨識設定輸出超過安全上限", "The speech recognition setup printed more than allowed")
669
+ )
597
670
  is_progress = line.startswith(PROGRESS_RECORD_PREFIX)
598
671
  visible_line = line[len(PROGRESS_RECORD_PREFIX) :].rstrip("\r\n") if is_progress else line
599
672
  log.write(f"{visible_line}\n" if is_progress else visible_line)
600
673
  log.flush()
601
- if is_progress and stdout.isatty():
602
- padding = " " * max(0, progress_width - len(visible_line))
603
- stdout.write(f"\r{visible_line}{padding}")
674
+ if is_progress and terminal.live:
675
+ terminal.overwrite(_progress_display(terminal, visible_line, frame))
604
676
  progress_active = True
605
- progress_width = len(visible_line)
677
+ frame += 1
678
+ continue
679
+ if progress_active:
680
+ terminal.write()
681
+ progress_active = False
682
+ text = visible_line.rstrip("\r\n")
683
+ if text.startswith("✓ "):
684
+ terminal.step(text[2:])
606
685
  else:
607
- if progress_active:
608
- stdout.write("\n")
609
- progress_active = False
610
- progress_width = 0
611
- stdout.write(f"{visible_line}\n" if is_progress else visible_line)
612
- stdout.flush()
613
- returncode = process.wait()
686
+ terminal.write(f"{terminal.paint('90', '│')} {text}")
614
687
  if progress_active:
615
- stdout.write("\n")
616
- stdout.flush()
688
+ terminal.write()
617
689
  progress_active = False
690
+ returncode = process.wait()
618
691
  except BaseException:
619
692
  if progress_active:
620
- stdout.write("\n")
621
- stdout.flush()
693
+ terminal.write()
622
694
  if process is not None and process.poll() is None:
623
695
  process.terminate()
624
696
  try:
@@ -628,7 +700,21 @@ def _install_asr_bundle(
628
700
  process.wait(timeout=5)
629
701
  raise
630
702
  if returncode != 0:
631
- raise BootstrapError(f"本機語音辨識設定失敗;診斷紀錄:{log_path}")
703
+ raise BootstrapError(
704
+ tr(
705
+ f"本機語音辨識設定失敗;診斷紀錄:{log_path}",
706
+ f"Setting up local speech recognition failed; log: {log_path}",
707
+ )
708
+ )
709
+
710
+
711
+ def _progress_display(terminal: Terminal, line: str, frame: int) -> str:
712
+ """The installer's progress record, redrawn with a spinner and the brand-coloured bar."""
713
+ bar = re.match(r"([━─]+) +(\d+)%(.*)", line)
714
+ symbol = terminal.paint("35", "◒◐◓◑"[frame % 4])
715
+ if bar is None:
716
+ return f"{symbol} {line}"
717
+ return f"{symbol} {terminal.progress_bar(int(bar.group(2)), len(bar.group(1)))} {terminal.bold(bar.group(2) + '%')}{bar.group(3)}"
632
718
 
633
719
 
634
720
  def ensure_runtime(
@@ -644,7 +730,9 @@ def ensure_runtime(
644
730
  root = (data_root or clipen_data_root()) / "runtimes"
645
731
  root.mkdir(mode=0o700, parents=True, exist_ok=True)
646
732
  if root.is_symlink():
647
- raise BootstrapError("Clipen runtime 根目錄不能是 symbolic link")
733
+ raise BootstrapError(
734
+ tr("Clipen runtime 根目錄不能是 symbolic link", "Clipen's runtime folder cannot be a symbolic link")
735
+ )
648
736
  runtime = root / fingerprint
649
737
 
650
738
  with _bootstrap_lock(root):
@@ -652,25 +740,30 @@ def ensure_runtime(
652
740
  if ready is not None:
653
741
  return ready
654
742
  if runtime.exists():
655
- raise BootstrapError(f"Clipen runtime 不完整,請先保留此目錄並回報問題:{runtime}")
656
- if not confirmed and not _confirm_setup(runtime, stdin, stdout):
657
- print("已取消,沒有建立 Clipen runtime。", file=stdout)
743
+ raise BootstrapError(
744
+ tr(
745
+ f"Clipen runtime 不完整,請先保留此目錄並回報問題:{runtime}",
746
+ f"Clipen's runtime is incomplete; keep this folder and report the problem: {runtime}",
747
+ )
748
+ )
749
+ if not confirmed and not _confirm_setup(stdin, stdout):
750
+ Terminal(stdout).outro(tr("已取消,沒有建立 Clipen runtime。", "Cancelled; no Clipen runtime was created."))
658
751
  return None
659
752
 
660
753
  staging = root / f".{fingerprint}.staging-{uuid.uuid4().hex}"
661
754
  log_root = (data_root or clipen_data_root()) / "logs"
662
755
  log_root.mkdir(mode=0o700, parents=True, exist_ok=True)
663
756
  log_path = log_root / f"bootstrap-{fingerprint}.log"
664
- print("正在建立 Clipen 執行環境…", file=stdout)
665
757
  try:
666
- staging.mkdir(mode=0o700)
667
- _install_runtime(staging, repo_root, fingerprint, log_path)
668
- staging.rename(runtime)
758
+ with Terminal(stdout).spinner(tr("正在準備 Clipen 執行環境", "Preparing Clipen's runtime")) as spinner:
759
+ staging.mkdir(mode=0o700)
760
+ _install_runtime(staging, repo_root, fingerprint, log_path)
761
+ staging.rename(runtime)
762
+ spinner.done(tr("執行環境就緒", "Runtime ready"))
669
763
  except Exception:
670
764
  if staging.exists() and not staging.is_symlink():
671
765
  shutil.rmtree(staging)
672
766
  raise
673
- print("✓ Clipen 執行環境建立完成", file=stdout)
674
767
  return runtime
675
768
 
676
769
 
@@ -688,7 +781,7 @@ def ensure_installation(
688
781
  selected_home = home or Path.home()
689
782
  selected_environment = environment if environment is not None else os.environ
690
783
  if platform.system() != "Darwin" or platform.machine() != "arm64":
691
- raise BootstrapError("目前完整設定只支援 Apple 晶片的 macOS")
784
+ raise BootstrapError(tr("目前完整設定只支援 Apple 晶片的 macOS", "Full setup supports only Apple silicon Macs"))
692
785
  fingerprint = runtime_fingerprint(repo_root)
693
786
  ready = _ready_runtime(selected_data_root / "runtimes", fingerprint, repo_root)
694
787
  runtime = ready or selected_data_root / "runtimes" / fingerprint
@@ -701,7 +794,6 @@ def ensure_installation(
701
794
  command_path = selected_data_root / "bin" / "clipen"
702
795
  profile_path = _shell_profile(selected_home, selected_environment)
703
796
  if not _confirm_setup(
704
- runtime,
705
797
  stdin,
706
798
  stdout,
707
799
  command_path=None if command_ready else command_path,
@@ -709,7 +801,9 @@ def ensure_installation(
709
801
  asr_root=None if asr_ready else release_root(selected_data_root),
710
802
  include_runtime=not runtime_ready,
711
803
  ):
712
- print("已取消,既有 Clipen 資料沒有變動。", file=stdout)
804
+ Terminal(stdout).outro(
805
+ tr("已取消,既有 Clipen 資料沒有變動。", "Cancelled; your Clipen data is unchanged.")
806
+ )
713
807
  return None
714
808
  if not runtime_ready:
715
809
  installed_runtime = ensure_runtime(
@@ -727,9 +821,11 @@ def ensure_installation(
727
821
  log_root = selected_data_root / "logs"
728
822
  log_root.mkdir(mode=0o700, parents=True, exist_ok=True)
729
823
  if log_root.is_symlink():
730
- raise BootstrapError("Clipen log 目錄不能是 symbolic link")
824
+ raise BootstrapError(
825
+ tr("Clipen log 目錄不能是 symbolic link", "Clipen's log folder cannot be a symbolic link")
826
+ )
731
827
  asr_log = log_root / f"bootstrap-asr-{fingerprint}.log"
732
- print("正在準備本機語音辨識與固定模型…", file=stdout)
828
+ Terminal(stdout).write(Terminal(stdout).paint("90", "│"))
733
829
  _install_asr_bundle(
734
830
  runtime,
735
831
  repo_root,
@@ -738,16 +834,16 @@ def ensure_installation(
738
834
  stdout,
739
835
  )
740
836
  if not quick_release_is_ready(selected_data_root, asr_requirements):
741
- raise BootstrapError(f"語音辨識安裝未通過啟動檢查;診斷紀錄:{asr_log}")
837
+ raise BootstrapError(
838
+ tr(
839
+ f"語音辨識安裝未通過啟動檢查;診斷紀錄:{asr_log}",
840
+ f"The speech recognition install failed its start-up check; log: {asr_log}",
841
+ )
842
+ )
742
843
  _ensure_chrome(runtime, selected_data_root, selected_home, stdout)
743
844
  if not command_ready:
744
- command_path, profile_path = _install_command(
745
- repo_root, selected_data_root, selected_home, selected_environment
746
- )
747
- print(f"✓ 已建立指令:{command_path}", file=stdout)
748
- print(f"✓ 已更新 PATH:{profile_path}", file=stdout)
749
- print("下次開啟 Terminal 後可直接輸入:clipen codex(或 clipen claude)", file=stdout)
750
- print("✓ Clipen 完整設定完成", file=stdout)
845
+ _install_command(repo_root, selected_data_root, selected_home, selected_environment)
846
+ Terminal(stdout).step(tr("已新增 clipen 指令", "Added the clipen command"))
751
847
  return runtime
752
848
 
753
849
  if stdin.isatty():
@@ -756,21 +852,28 @@ def ensure_installation(
756
852
  if not command_ready:
757
853
  if not stdin.isatty():
758
854
  return runtime
759
- print("Clipen 需要完成一次指令設定。", file=stdout)
760
- print(f"將建立:{selected_data_root / 'bin' / 'clipen'}", file=stdout)
855
+ terminal = Terminal(stdout)
761
856
  profile_path = _shell_profile(selected_home, selected_environment)
762
- print(f"將更新 PATH:{profile_path}", file=stdout)
763
- stdout.write("完成設定?[Y/n] ")
764
- stdout.flush()
765
- if stdin.readline().strip().lower() not in {"", "y", "yes"}:
766
- print(f"已略過;可再次執行 {_install_hint(repo_root)} 完成指令設定。", file=stdout)
767
- return runtime
768
- command_path, profile_path = _install_command(
769
- repo_root, selected_data_root, selected_home, selected_environment
857
+ terminal.note(
858
+ tr("Clipen 需要完成一次指令設定", "Clipen needs to set up its command once"),
859
+ [
860
+ tr(
861
+ f"將建立:{selected_data_root / 'bin' / 'clipen'}",
862
+ f"Creates: {selected_data_root / 'bin' / 'clipen'}",
863
+ ),
864
+ tr(f"將更新 PATH:{profile_path}", f"Updates PATH in: {profile_path}"),
865
+ ],
770
866
  )
771
- print(f"✓ 已建立指令:{command_path}", file=stdout)
772
- print(f"✓ 已更新 PATH:{profile_path}", file=stdout)
773
- print("下次開啟 Terminal 後可直接輸入:clipen codex(或 clipen claude)", file=stdout)
867
+ if not terminal.confirm(tr("完成設定?", "Finish setting up?"), stdin):
868
+ terminal.warn(
869
+ tr(
870
+ f"已略過;可再次執行 {_install_hint(repo_root)} 完成指令設定。",
871
+ f"Skipped; run {_install_hint(repo_root)} again to set up the command.",
872
+ )
873
+ )
874
+ return runtime
875
+ _install_command(repo_root, selected_data_root, selected_home, selected_environment)
876
+ Terminal(stdout).step(tr("已新增 clipen 指令", "Added the clipen command"))
774
877
  return runtime
775
878
 
776
879
 
@@ -780,14 +883,17 @@ def completed_runtime(repo_root: Path, *, data_root: Path | None = None) -> Path
780
883
  repo_root = repo_root.resolve(strict=True)
781
884
  selected_data_root = data_root or clipen_data_root()
782
885
  if platform.system() != "Darwin" or platform.machine() != "arm64":
783
- raise BootstrapError("目前只支援 Apple 晶片的 macOS")
886
+ raise BootstrapError(tr("目前只支援 Apple 晶片的 macOS", "Supports only Apple silicon Macs"))
784
887
  fingerprint = runtime_fingerprint(repo_root)
785
888
  runtime = _ready_runtime(selected_data_root / "runtimes", fingerprint, repo_root)
786
889
  requirements = repo_root / "requirements" / "asr-runtime.txt"
787
890
  if runtime is None or not quick_release_is_ready(selected_data_root, requirements):
788
891
  raise BootstrapError(
789
- f"Clipen 尚未完成安裝;第一次請執行 {_install_hint(repo_root)},"
790
- "已有 clipen 指令時可執行 clipen install 修復"
892
+ tr(
893
+ f"Clipen 尚未完成安裝;第一次請執行 {_install_hint(repo_root)},已有 clipen 指令時可執行 clipen install 修復",
894
+ f"Clipen is not fully installed. The first time, run {_install_hint(repo_root)}; "
895
+ "if you have the clipen command, clipen install repairs it",
896
+ )
791
897
  )
792
898
  return runtime
793
899
 
@@ -801,11 +907,13 @@ def _controller_is_running(data_root: Path) -> bool:
801
907
  try:
802
908
  descriptor = os.open(lock_path, flags)
803
909
  except OSError as error:
804
- raise BootstrapError("無法安全檢查 Clipen 是否仍在執行") from error
910
+ raise BootstrapError(
911
+ tr("無法安全檢查 Clipen 是否仍在執行", "Cannot safely check whether Clipen is still running")
912
+ ) from error
805
913
  try:
806
914
  info = os.fstat(descriptor)
807
915
  if not stat.S_ISREG(info.st_mode):
808
- raise BootstrapError("Clipen 執行鎖不是安全的實體檔案")
916
+ raise BootstrapError(tr("Clipen 執行鎖不是安全的實體檔案", "Clipen's run lock is not a safe, real file"))
809
917
  try:
810
918
  locking.flock(descriptor, locking.LOCK_EX | locking.LOCK_NB)
811
919
  except BlockingIOError:
@@ -820,17 +928,28 @@ def _validate_removable_path(path: Path, data_root: Path, *, directory: bool) ->
820
928
  if not path.exists() and not path.is_symlink():
821
929
  return
822
930
  if path.is_symlink() or path.parent.resolve(strict=True) != data_root:
823
- raise BootstrapError(f"拒絕移除不安全的 Clipen 路徑:{path}")
931
+ raise BootstrapError(
932
+ tr(f"拒絕移除不安全的 Clipen 路徑:{path}", f"Refused to remove an unsafe Clipen path: {path}")
933
+ )
824
934
  if directory:
825
935
  if not path.is_dir() or path.is_mount():
826
- raise BootstrapError(f"拒絕移除非一般目錄:{path}")
936
+ raise BootstrapError(
937
+ tr(f"拒絕移除非一般目錄:{path}", f"Refused to remove something that is not a plain folder: {path}")
938
+ )
827
939
  for current, directories, _files in os.walk(path, followlinks=False):
828
940
  for name in directories:
829
941
  candidate = Path(current) / name
830
942
  if not candidate.is_symlink() and candidate.is_mount():
831
- raise BootstrapError(f"拒絕移除包含 mount point 的目錄:{candidate}")
943
+ raise BootstrapError(
944
+ tr(
945
+ f"拒絕移除包含 mount point 的目錄:{candidate}",
946
+ f"Refused to remove a folder containing a mount point: {candidate}",
947
+ )
948
+ )
832
949
  elif not path.is_file():
833
- raise BootstrapError(f"拒絕移除非一般檔案:{path}")
950
+ raise BootstrapError(
951
+ tr(f"拒絕移除非一般檔案:{path}", f"Refused to remove something that is not a plain file: {path}")
952
+ )
834
953
 
835
954
 
836
955
  def uninstall_installation(
@@ -850,26 +969,47 @@ def uninstall_installation(
850
969
  bin_root = selected_data_root / "bin"
851
970
  command_path = bin_root / "clipen"
852
971
 
853
- print("移除 Clipen", file=stdout)
854
- print("將會移除:", file=stdout)
855
- print(" • Clipen 專用的 Python、程式、runtime 與本機語音辨識和對齊模型", file=stdout)
856
- print(f" • `clipen` 指令:{command_path}", file=stdout)
857
- print(f" • PATH 設定:{profile_path}", file=stdout)
858
- print("會保留 Clipen 作品資料、毛片、參考作品與匯出檔案。", file=stdout)
972
+ terminal = Terminal(stdout)
973
+ terminal.intro("Clipen")
974
+ terminal.note(
975
+ tr("移除 Clipen", "Remove Clipen"),
976
+ [
977
+ tr(
978
+ f"會移除 Clipen 程式、語音辨識模型和 {terminal.bold('clipen')} 指令",
979
+ f"Removes the Clipen program, the speech model and the {terminal.bold('clipen')} command",
980
+ )
981
+ ],
982
+ [
983
+ tr(
984
+ "你的作品、毛片、參考作品和匯出檔都會保留",
985
+ "Your projects, footage, reference work and exports are all kept",
986
+ )
987
+ ],
988
+ )
859
989
  if not stdin.isatty():
860
- raise BootstrapError("移除 Clipen 需要在互動式 Terminal 中確認")
861
- stdout.write("確定移除?[y/N] ")
862
- stdout.flush()
863
- if stdin.readline().strip().lower() not in {"y", "yes"}:
864
- print("已取消,沒有移除任何內容。", file=stdout)
990
+ raise BootstrapError(
991
+ tr(
992
+ "移除 Clipen 需要在互動式 Terminal 中確認",
993
+ "Removing Clipen needs confirming in an interactive Terminal",
994
+ )
995
+ )
996
+ if not terminal.confirm(tr("確定移除?", "Remove it?"), stdin, default=False):
997
+ terminal.outro(tr("已取消,沒有移除任何內容。", "Cancelled; nothing was removed."))
865
998
  return False
866
999
 
867
1000
  if selected_data_root.exists() or selected_data_root.is_symlink():
868
1001
  if selected_data_root.is_symlink() or not selected_data_root.is_dir():
869
- raise BootstrapError("Clipen 資料根目錄不安全,未進行移除")
1002
+ raise BootstrapError(
1003
+ tr("Clipen 資料根目錄不安全,未進行移除", "Clipen's data folder is not safe, so nothing was removed")
1004
+ )
870
1005
  resolved_data_root = selected_data_root.resolve(strict=True)
871
1006
  if _controller_is_running(resolved_data_root):
872
- raise BootstrapError("Clipen 仍在執行;請先在啟動它的 Terminal 按 Ctrl+C")
1007
+ raise BootstrapError(
1008
+ tr(
1009
+ "Clipen 仍在執行;請先在啟動它的 Terminal 按 Ctrl+C",
1010
+ "Clipen is still running; press Ctrl+C in the Terminal that started it",
1011
+ )
1012
+ )
873
1013
  else:
874
1014
  resolved_data_root = selected_data_root
875
1015
 
@@ -878,20 +1018,37 @@ def uninstall_installation(
878
1018
  profile_mode = 0o600
879
1019
  if profile_path.exists() or profile_path.is_symlink():
880
1020
  if profile_path.is_symlink() or not profile_path.is_file():
881
- raise BootstrapError("shell 設定檔不是安全的實體檔案,未進行移除")
1021
+ raise BootstrapError(
1022
+ tr(
1023
+ "shell 設定檔不是安全的實體檔案,未進行移除",
1024
+ "Your shell settings file is not a safe, real file, so nothing was removed",
1025
+ )
1026
+ )
882
1027
  profile = profile_path.read_text(encoding="utf-8")
883
1028
  updated_profile = _remove_profile_block(profile)
884
1029
  profile_mode = stat.S_IMODE(profile_path.stat().st_mode)
885
1030
 
886
1031
  if bin_root.exists() or bin_root.is_symlink():
887
1032
  if bin_root.is_symlink() or not bin_root.is_dir():
888
- raise BootstrapError("Clipen bin 目錄不安全,未進行移除")
1033
+ raise BootstrapError(
1034
+ tr("Clipen bin 目錄不安全,未進行移除", "Clipen's bin folder is not safe, so nothing was removed")
1035
+ )
889
1036
  if command_path.exists() or command_path.is_symlink():
890
1037
  if command_path.is_symlink() or not command_path.is_file():
891
- raise BootstrapError("clipen 指令位置不是安全的實體檔案,未進行移除")
1038
+ raise BootstrapError(
1039
+ tr(
1040
+ "clipen 指令位置不是安全的實體檔案,未進行移除",
1041
+ "The clipen command is not a safe, real file, so nothing was removed",
1042
+ )
1043
+ )
892
1044
  command = command_path.read_text(encoding="utf-8")
893
1045
  if not any(line.startswith(_MANAGED_COMMAND_PREFIX) for line in command.splitlines()[:3]):
894
- raise BootstrapError("clipen 指令不是由 Clipen 管理,未進行移除")
1046
+ raise BootstrapError(
1047
+ tr(
1048
+ "clipen 指令不是由 Clipen 管理,未進行移除",
1049
+ "The clipen command is not managed by Clipen, so nothing was removed",
1050
+ )
1051
+ )
895
1052
 
896
1053
  if selected_data_root.exists():
897
1054
  for name in _REMOVABLE_DIRECTORIES:
@@ -920,19 +1077,64 @@ def uninstall_installation(
920
1077
  path = resolved_data_root / name
921
1078
  if selected_data_root.exists() and path.exists():
922
1079
  shutil.rmtree(path)
923
- print("✓ Clipen 已移除", file=stdout)
924
- print("作品資料與所有毛片均已保留。", file=stdout)
1080
+ terminal.step(tr("Clipen 已移除", "Clipen removed"))
1081
+ terminal.outro(tr("作品資料與所有毛片均已保留。", "Your projects and all your footage are kept."))
925
1082
  return True
926
1083
 
927
1084
 
928
1085
  def _print_usage(stream: TextIO, repo_root: Path | None = None) -> None:
929
1086
  npm = repo_root is not None and (repo_root / ".clipen-npm").is_file()
930
- print(f"第一次安裝:{'npx @clipen/clipen-cli' if npm else './clipen install'}", file=stream)
931
- print("啟動 Clipen:clipen codex 或 clipen claude", file=stream)
932
- print(f"移除 Clipen:{'clipen uninstall' if npm else './clipen uninstall'}", file=stream)
1087
+ print(
1088
+ tr(
1089
+ f"第一次安裝:{'npx @clipen/clipen-cli' if npm else './clipen install'}",
1090
+ f"First install: {'npx @clipen/clipen-cli' if npm else './clipen install'}",
1091
+ ),
1092
+ file=stream,
1093
+ )
1094
+ print(tr("啟動 Clipen:clipen codex 或 clipen claude", "Start Clipen: clipen codex or clipen claude"), file=stream)
1095
+ print(
1096
+ tr(
1097
+ f"移除 Clipen:{'clipen uninstall' if npm else './clipen uninstall'}",
1098
+ f"Remove Clipen: {'clipen uninstall' if npm else './clipen uninstall'}",
1099
+ ),
1100
+ file=stream,
1101
+ )
1102
+ print(tr("介面語言:clipen language en|zh-TW|auto", "Language: clipen language en | zh-TW | auto"), file=stream)
1103
+
1104
+
1105
+ def _language(arguments: Sequence[str]) -> int:
1106
+ """`clipen language` shows the language Clipen speaks; with en, zh-TW or auto it changes it."""
1107
+ terminal = Terminal()
1108
+ if len(arguments) == 2:
1109
+ choice = arguments[1].strip().lower()
1110
+ if choice == "auto":
1111
+ save_language(None)
1112
+ elif normalize(choice):
1113
+ save_language(normalize(choice))
1114
+ else:
1115
+ Terminal(sys.stderr).error(tr("請選 en、zh-TW 或 auto", "Choose en, zh-TW or auto"))
1116
+ return 2
1117
+ with speaking(system_language()):
1118
+ names = {"en": "English", "zh-TW": "繁體中文"}
1119
+ chosen = saved_language()
1120
+ terminal.step(
1121
+ tr(f"Clipen 使用 {names[current()]}", f"Clipen speaks {names[current()]}")
1122
+ + terminal.dim(
1123
+ tr("(手動設定)", " (set by you)") if chosen else tr("(跟著系統)", " (following the system)")
1124
+ )
1125
+ )
1126
+ return 0
933
1127
 
934
1128
 
935
1129
  def main(repo_root: Path, arguments: Sequence[str]) -> int:
1130
+ if arguments and arguments[0] == "language" and len(arguments) <= 2:
1131
+ return _language(arguments)
1132
+ # The installer speaks the language of the Mac, or the one chosen with `clipen language`.
1133
+ with speaking(system_language()):
1134
+ return _main(repo_root, arguments)
1135
+
1136
+
1137
+ def _main(repo_root: Path, arguments: Sequence[str]) -> int:
936
1138
  if list(arguments) in (["--help"], ["-h"]):
937
1139
  _print_usage(sys.stdout, repo_root)
938
1140
  return 0
@@ -945,15 +1147,34 @@ def main(repo_root: Path, arguments: Sequence[str]) -> int:
945
1147
  try:
946
1148
  _require_posix_file_locking()
947
1149
  if list(arguments) == ["install"]:
1150
+ terminal = Terminal()
1151
+ # Installed through npx, the launcher has already drawn the logo and opened the frame.
1152
+ if not os.environ.get(FRAME_OPEN):
1153
+ terminal.logo(tr(f"v{__version__} · AI 剪輯工作台", f"v{__version__} · AI video editing studio"))
1154
+ terminal.intro(f"Clipen {__version__}")
948
1155
  ensure_web_build(repo_root)
949
1156
  runtime = ensure_installation(repo_root)
950
1157
  if runtime is not None:
951
- print("✓ Clipen 已安裝完成")
952
- print("\n接下來:")
953
- print("1. 開啟新的 Terminal")
954
- print("2. cd 到你想存放 Clipen 作品資料的目錄")
955
- print("3. 執行:clipen codex(或 clipen claude)")
956
- print("\n不需要回到 Clipen 程式碼目錄;毛片也可以放在其他位置。")
1158
+ terminal.note(
1159
+ tr("安裝完成,接下來這樣開始", "Installed. Here is how to start"),
1160
+ [
1161
+ tr(
1162
+ f"{terminal.brand('1')} 開一個新的 Terminal 視窗",
1163
+ f"{terminal.brand('1')} Open a new Terminal window",
1164
+ ),
1165
+ tr(
1166
+ f"{terminal.brand('2')} cd 到你想放作品的資料夾",
1167
+ f"{terminal.brand('2')} cd to the folder for your projects",
1168
+ ),
1169
+ tr(
1170
+ f"{terminal.brand('3')} 輸入 {terminal.bold('clipen codex')}",
1171
+ f"{terminal.brand('3')} Type {terminal.bold('clipen codex')}",
1172
+ ),
1173
+ ],
1174
+ )
1175
+ terminal.outro(
1176
+ terminal.dim(tr("想改用 Claude Code?輸入 clipen claude", "Prefer Claude Code? Type clipen claude"))
1177
+ )
957
1178
  return 0
958
1179
  if list(arguments) == ["uninstall"]:
959
1180
  uninstall_installation()
@@ -961,15 +1182,19 @@ def main(repo_root: Path, arguments: Sequence[str]) -> int:
961
1182
  ensure_web_build(repo_root)
962
1183
  runtime = completed_runtime(repo_root)
963
1184
  except KeyboardInterrupt:
964
- action = "移除" if list(arguments) == ["uninstall"] else "設定"
965
- print(f"\nClipen {action}已取消", file=sys.stderr)
1185
+ removing = list(arguments) == ["uninstall"]
1186
+ Terminal(sys.stderr).error(
1187
+ tr(
1188
+ f"Clipen {'移除' if removing else '設定'}已取消",
1189
+ f"Clipen {'removal' if removing else 'setup'} cancelled",
1190
+ )
1191
+ )
966
1192
  return 130
967
1193
  except (BootstrapError, OSError, subprocess.SubprocessError) as error:
968
- action = {
969
- "install": "安裝",
970
- "uninstall": "移除",
971
- }.get(list(arguments)[0], "啟動")
972
- print(f"Clipen {action}失敗:{error}", file=sys.stderr)
1194
+ action = {"install": ("安裝", "install"), "uninstall": ("移除", "removal")}.get(
1195
+ list(arguments)[0], ("啟動", "start")
1196
+ )
1197
+ Terminal(sys.stderr).error(tr(f"Clipen {action[0]}失敗:{error}", f"Clipen {action[1]} failed: {error}"))
973
1198
  return 1
974
1199
  if runtime is None:
975
1200
  return 0