@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
package/src/clipen/cli.py CHANGED
@@ -7,9 +7,12 @@ import sys
7
7
  from pathlib import Path
8
8
  from typing import Sequence
9
9
 
10
+ from clipen import __version__
10
11
  from clipen.controller import LocalSessionAuthority
11
12
  from clipen.controller.server import ServerPaths, probe_claude, probe_codex, run_server
13
+ from clipen.i18n import speaking, system_language, tr
12
14
  from clipen.provider_registry import PROVIDERS
15
+ from clipen.terminal import Terminal
13
16
  from clipen.workspace import (
14
17
  WorkspaceError,
15
18
  inspect_workspace_projects,
@@ -22,7 +25,12 @@ def _repo_root() -> Path:
22
25
  root = Path(configured) if configured else Path(__file__).resolve().parents[2]
23
26
  resolved = root.resolve(strict=True)
24
27
  if not (resolved / "apps" / "web" / "dist" / "index.html").is_file():
25
- raise RuntimeError("找不到 Clipen 操作介面,請重新安裝(npx @clipen/clipen-cli 或 ./clipen install)。")
28
+ raise RuntimeError(
29
+ tr(
30
+ "找不到 Clipen 操作介面,請重新安裝(npx @clipen/clipen-cli 或 ./clipen install)。",
31
+ "The Clipen interface is missing. Install again (npx @clipen/clipen-cli or ./clipen install).",
32
+ )
33
+ )
26
34
  return resolved
27
35
 
28
36
 
@@ -34,28 +42,42 @@ def _data_root() -> Path:
34
42
 
35
43
 
36
44
  def main(arguments: Sequence[str] | None = None) -> int:
45
+ # The terminal and the page's first look speak the Mac's language, or the one chosen with `clipen language`.
46
+ with speaking(system_language()):
47
+ return _main(arguments)
48
+
49
+
50
+ def _main(arguments: Sequence[str] | None) -> int:
37
51
  selected = list(sys.argv[1:] if arguments is None else arguments)
38
52
  if len(selected) != 1 or selected[0] not in PROVIDERS:
39
- print("用法:clipen " + "|".join(PROVIDERS), file=sys.stderr)
53
+ Terminal(sys.stderr).error(tr("用法:clipen ", "Usage: clipen ") + tr("|", " | ").join(PROVIDERS))
40
54
  return 2
41
55
  descriptor = PROVIDERS[selected[0]]
42
56
  # Resolved at call time so each probe stays a module attribute.
43
57
  probe = {"codex": probe_codex, "claude": probe_claude}[descriptor.provider_id]
58
+ terminal = Terminal()
44
59
  try:
45
60
  repo_root = _repo_root()
46
61
  data_root = _data_root()
47
62
  workspace = prepare_workspace(Path.cwd())
48
- print(f"工作區:{workspace.root}", flush=True)
49
- print("正在檢查目前目錄的 Clipen 作品…", flush=True)
50
- inspection = inspect_workspace_projects(workspace)
51
- if inspection.project_count:
52
- print(f"✓ 找到 {inspection.project_count} 個可用作品", flush=True)
53
- else:
54
- print("目前沒有作品,可在 UI 建立第一個作品。", flush=True)
55
- attempt_root = data_root / "provider-attempts"
56
- attempt_root.mkdir(mode=0o700, parents=True, exist_ok=True)
57
- print(f"正在檢查 {descriptor.display_name}…", flush=True)
58
- provider = probe(attempt_root)
63
+ terminal.logo(tr(f"v{__version__} · AI 剪輯工作台", f"v{__version__} · AI video editing studio"))
64
+ terminal.intro(f"Clipen {__version__}")
65
+ with terminal.spinner(tr("正在啟動 Clipen", "Starting Clipen")) as spinner:
66
+ inspection = inspect_workspace_projects(workspace)
67
+ attempt_root = data_root / "provider-attempts"
68
+ attempt_root.mkdir(mode=0o700, parents=True, exist_ok=True)
69
+ spinner.update(tr(f"正在連接 {descriptor.display_name}", f"Connecting to {descriptor.display_name}"))
70
+ provider = probe(attempt_root)
71
+ folder = str(workspace.root).replace(str(Path.home()), "~", 1)
72
+ count = (
73
+ tr(
74
+ f"{inspection.project_count} 個作品",
75
+ f"{inspection.project_count} {'project' if inspection.project_count == 1 else 'projects'}",
76
+ )
77
+ if inspection.project_count
78
+ else tr("還沒有作品", "no projects yet")
79
+ )
80
+ spinner.done(f"{folder} {terminal.dim(f'· {count}')}")
59
81
  return run_server(
60
82
  ServerPaths(
61
83
  static_root=repo_root / "apps" / "web" / "dist",
@@ -68,10 +90,13 @@ def main(arguments: Sequence[str] | None = None) -> int:
68
90
  LocalSessionAuthority(),
69
91
  )
70
92
  except KeyboardInterrupt:
71
- print("\nClipen 已停止", flush=True)
93
+ terminal.write()
94
+ terminal.write(
95
+ tr(f"{terminal.paint('90', '■')} Clipen 已停止", f"{terminal.paint('90', '■')} Clipen stopped")
96
+ )
72
97
  return 130
73
98
  except (OSError, RuntimeError, ValueError, WorkspaceError) as error:
74
- print(f"Clipen 無法啟動:{error}", file=sys.stderr)
99
+ Terminal(sys.stderr).error(tr(f"Clipen 無法啟動:{error}", f"Clipen could not start: {error}"))
75
100
  return 1
76
101
 
77
102
 
@@ -11,6 +11,7 @@ from dataclasses import dataclass
11
11
  from enum import Enum
12
12
  from http.cookies import SimpleCookie
13
13
  from pathlib import Path
14
+ from urllib.parse import parse_qs
14
15
 
15
16
  from starlette.applications import Starlette
16
17
  from starlette.concurrency import run_in_threadpool
@@ -30,6 +31,7 @@ from clipen.analysis import (
30
31
  from clipen.analysis.evidence_service import EvidenceService
31
32
  from clipen.annotations import AnnotationRepository
32
33
  from clipen.editing import EditAgentCoordinator
34
+ from clipen.i18n import english, speaking, tr
33
35
  from clipen.media import InventoryCoordinator, MediaPreviewRepository
34
36
  from clipen.projects import (
35
37
  DirectoryRole,
@@ -258,7 +260,7 @@ class LocalRequestGuard:
258
260
  code: str,
259
261
  ) -> None:
260
262
  response = JSONResponse(
261
- {"error": {"code": code, "message": "無法驗證本機工作台連線。"}},
263
+ {"error": {"code": code, "message": tr("無法驗證本機工作台連線。")}},
262
264
  status_code=status_code,
263
265
  )
264
266
  await response(scope, receive, self._secure_send(scope, send))
@@ -308,7 +310,7 @@ def create_app(
308
310
  {
309
311
  "error": {
310
312
  "code": "session_required",
311
- "message": "請從 Clipen Terminal 重新開啟工作台。",
313
+ "message": tr("請從 Clipen Terminal 重新開啟工作台。"),
312
314
  }
313
315
  },
314
316
  status_code=401,
@@ -320,7 +322,7 @@ def create_app(
320
322
  "id": provider.provider_id,
321
323
  "name": provider.name,
322
324
  "state": provider.state.value,
323
- "message": provider.message,
325
+ "message": tr(provider.message),
324
326
  },
325
327
  "session": {"csrf_token": credentials.csrf_token},
326
328
  }
@@ -330,7 +332,7 @@ def create_app(
330
332
  # Which model runs and how much quota is left; read-only, never calls a model.
331
333
  if authority.authenticate(_cookie_value(request.headers, _SESSION_COOKIE)) is None:
332
334
  return JSONResponse(
333
- {"error": {"code": "session_required", "message": "請從 Clipen Terminal 重新開啟工作台。"}},
335
+ {"error": {"code": "session_required", "message": tr("請從 Clipen Terminal 重新開啟工作台。")}},
334
336
  status_code=401,
335
337
  )
336
338
  details = (
@@ -344,7 +346,7 @@ def create_app(
344
346
  # Lets the UI warn before production: on battery a closed lid still sleeps the Mac.
345
347
  if authority.authenticate(_cookie_value(request.headers, _SESSION_COOKIE)) is None:
346
348
  return JSONResponse(
347
- {"error": {"code": "session_required", "message": "請從 Clipen Terminal 重新開啟工作台。"}},
349
+ {"error": {"code": "session_required", "message": tr("請從 Clipen Terminal 重新開啟工作台。")}},
348
350
  status_code=401,
349
351
  )
350
352
  from clipen.power import power_status
@@ -356,7 +358,7 @@ def create_app(
356
358
  expected = config.instance_secret
357
359
  if expected is None or supplied is None or not secrets.compare_digest(supplied, expected):
358
360
  return JSONResponse(
359
- {"error": {"code": "instance_invalid", "message": "找不到 Clipen instance。"}},
361
+ {"error": {"code": "instance_invalid", "message": tr("找不到 Clipen instance。")}},
360
362
  status_code=404,
361
363
  )
362
364
  return JSONResponse({"running": True})
@@ -481,16 +483,16 @@ def create_app(
481
483
 
482
484
  async def asr_setup_error_response(error: ASRSetupError) -> JSONResponse:
483
485
  messages = {
484
- "asr_setup_busy": "本機語音辨識正在安裝或移除,請稍候。",
485
- "asr_release_unsafe": "語音辨識安裝位置不安全,Clipen 沒有進行刪除。",
486
- "asr_remove_failed": "無法移除本機語音辨識,毛片與分析成果沒有變動。",
487
- "asr_pre_remove_failed": "無法先安全停止素材分析,語音辨識沒有被移除。",
486
+ "asr_setup_busy": tr("本機語音辨識正在安裝或移除,請稍候。"),
487
+ "asr_release_unsafe": tr("語音辨識安裝位置不安全,Clipen 沒有進行刪除。"),
488
+ "asr_remove_failed": tr("無法移除本機語音辨識,毛片與分析成果沒有變動。"),
489
+ "asr_pre_remove_failed": tr("無法先安全停止素材分析,語音辨識沒有被移除。"),
488
490
  }
489
491
  return JSONResponse(
490
492
  {
491
493
  "error": {
492
494
  "code": error.code,
493
- "message": messages.get(error.code, "Clipen 無法安全完成語音辨識設定。"),
495
+ "message": messages.get(error.code, tr("Clipen 無法安全完成語音辨識設定。")),
494
496
  }
495
497
  },
496
498
  status_code=409,
@@ -888,7 +890,7 @@ def create_app(
888
890
  payload = await read_json(request)
889
891
  require_fields(payload, {"request_id"})
890
892
  validate_request_id(payload["request_id"])
891
- folder = await run_in_threadpool(require_workspace().picker.choose_folder, "選擇要匯入的 Skill 資料夾")
893
+ folder = await run_in_threadpool(require_workspace().picker.choose_folder, tr("選擇要匯入的 Skill 資料夾"))
892
894
  if folder is None:
893
895
  return Response(status_code=204)
894
896
  package = await run_in_threadpool(skill_library().import_folder, folder)
@@ -915,7 +917,7 @@ def create_app(
915
917
  offset = int(request.query_params.get("offset", "0"))
916
918
  limit = int(request.query_params.get("limit", "30"))
917
919
  if not 0 <= offset <= 100000 or not 1 <= limit <= 100:
918
- raise ValueError("分頁參數無效。")
920
+ raise ValueError(tr("分頁參數無效。"))
919
921
  return JSONResponse(
920
922
  await run_in_threadpool(history, repository, request.query_params.get("project_id"), offset, limit)
921
923
  )
@@ -1294,9 +1296,9 @@ def create_app(
1294
1296
  "state": "ready" if preparations is not None else "setup_required",
1295
1297
  "phase": "ready" if preparations is not None else "not_installed",
1296
1298
  "message": (
1297
- "本機語音辨識可用"
1299
+ tr("本機語音辨識可用")
1298
1300
  if preparations is not None
1299
- else "需要約 1.6 GB 空間安裝隔離的本機語音辨識環境與模型"
1301
+ else tr("需要約 1.6 GB 空間安裝隔離的本機語音辨識環境與模型")
1300
1302
  ),
1301
1303
  "error_code": None,
1302
1304
  "completed_units": 3 if preparations is not None else 0,
@@ -1376,7 +1378,7 @@ def create_app(
1376
1378
  payload["request_id"],
1377
1379
  payload["expected_revision"],
1378
1380
  payload["scope_id"],
1379
- payload.get("language", "zh"),
1381
+ payload.get("language", "en" if english() else "zh"),
1380
1382
  payload.get("vocabulary", []),
1381
1383
  )
1382
1384
  return JSONResponse({"analysis": run.to_public()}, status_code=202)
@@ -1631,13 +1633,31 @@ def create_app(
1631
1633
  ],
1632
1634
  )
1633
1635
  return LocalRequestGuard(
1634
- app,
1636
+ _Speaking(app),
1635
1637
  authority=authority,
1636
1638
  origin=config.origin,
1637
1639
  allowed_hosts=config.allowed_hosts,
1638
1640
  )
1639
1641
 
1640
1642
 
1643
+ class _Speaking:
1644
+ """Answer each request in the language its page names, so messages and labels match the page."""
1645
+
1646
+ def __init__(self, app: ASGIApp) -> None:
1647
+ self.app = app
1648
+
1649
+ async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
1650
+ if scope["type"] != "http":
1651
+ await self.app(scope, receive, send)
1652
+ return
1653
+ asked = next((value.decode("latin-1") for name, value in scope["headers"] if name == b"x-clipen-locale"), None)
1654
+ if asked is None:
1655
+ # EventSource cannot set headers; the page then names its language in the address.
1656
+ asked = parse_qs(scope.get("query_string", b"").decode("latin-1")).get("lang", [None])[0]
1657
+ with speaking(asked):
1658
+ await self.app(scope, receive, send)
1659
+
1660
+
1641
1661
  def _query_integer(
1642
1662
  request: Request,
1643
1663
  name: str,
@@ -19,6 +19,8 @@ from dataclasses import dataclass
19
19
  from pathlib import Path
20
20
  from typing import Callable
21
21
 
22
+ from clipen.i18n import tr
23
+
22
24
  try:
23
25
  import fcntl as _fcntl
24
26
  except ImportError: # Windows does not provide POSIX advisory file locks.
@@ -40,6 +42,7 @@ from clipen.projects import ProjectWorkspace
40
42
  from clipen.provider_registry import exec_adapter_factory
41
43
  from clipen.providers import CodexExecAdapter, ProviderUnavailable
42
44
  from clipen.providers.claude import ClaudeCliAdapter
45
+ from clipen.terminal import Terminal, display_width
43
46
 
44
47
  from .app import (
45
48
  ControllerConfig,
@@ -72,7 +75,12 @@ class _InstanceLease:
72
75
  @classmethod
73
76
  def acquire(cls, root: Path) -> "_InstanceLease | None":
74
77
  if _fcntl is None:
75
- raise RuntimeError("這個開發版本尚不支援 Windows;本機工作台需要 POSIX 檔案鎖")
78
+ raise RuntimeError(
79
+ tr(
80
+ "這個開發版本尚不支援 Windows;本機工作台需要 POSIX 檔案鎖",
81
+ "This version does not support Windows yet; Clipen needs POSIX file locks",
82
+ )
83
+ )
76
84
  lock_path = root / ".controller.lock"
77
85
  flags = os.O_RDWR | os.O_CREAT | getattr(os, "O_NOFOLLOW", 0)
78
86
  descriptor = os.open(lock_path, flags, 0o600)
@@ -232,7 +240,9 @@ def _bind_socket(
232
240
  except OSError as error:
233
241
  listener.close()
234
242
  if port == 0 or error.errno not in (errno.EADDRINUSE, errno.EACCES):
235
- raise PortUnavailable("無法取得可用的本機連線埠,請稍後再試") from error
243
+ raise PortUnavailable(
244
+ tr("無法取得可用的本機連線埠,請稍後再試", "No local port is free; try again shortly")
245
+ ) from error
236
246
  raise AssertionError("port allocation must return a listener or raise")
237
247
 
238
248
 
@@ -306,12 +316,44 @@ def _find_existing_controller(registry_path: Path) -> ExistingController | None:
306
316
 
307
317
 
308
318
  def _print_ui_url(url: str, *, first_connection: bool = False) -> None:
309
- label = "首次連線:" if first_connection else "UI:"
310
- print(label, flush=True)
311
- if sys.stdout.isatty():
312
- print(f"\033]8;;{url}\033\\{url}\033]8;;\033\\", flush=True)
319
+ terminal = Terminal()
320
+ if first_connection:
321
+ terminal.warn(
322
+ tr(
323
+ f"瀏覽器沒有自動開啟,請點這個網址\n{terminal.link(url)}",
324
+ f"The browser did not open by itself; click this address\n{terminal.link(url)}",
325
+ )
326
+ )
313
327
  else:
314
- print(url, flush=True)
328
+ terminal.info(tr(f"網址 {terminal.link(url)}", f"Address {terminal.link(url)}"))
329
+
330
+
331
+ def _announce(provider: ProviderStatus, public_url: str, *, opened: bool, interactive: bool) -> None:
332
+ """The one panel the person sees once Clipen is serving: where to go next and how to stop."""
333
+ terminal = Terminal()
334
+ bar = terminal.paint("90", "│")
335
+ if provider.state is ProviderState.READY:
336
+ ai = f"{provider.name} {terminal.paint('32', tr('● 已連接', '● connected'))}"
337
+ else:
338
+ ai = f"{provider.name} {terminal.paint('33', f'▲ {tr(provider.message)}')}"
339
+ title = (
340
+ tr("Clipen 已在瀏覽器開啟,接下來請在瀏覽器操作", "Clipen is open in your browser; carry on there")
341
+ if opened
342
+ else tr("Clipen 已啟動,請點下面的網址開啟", "Clipen is running; click the address below to open it")
343
+ )
344
+ terminal.write(bar)
345
+ terminal.write(f"{terminal.paint('32', '◆')} {terminal.bold(title)}")
346
+ terminal.write(bar)
347
+ rows = ((tr("網址", "Address"), terminal.link(public_url)), ("AI", ai))
348
+ width = max(display_width(name) for name, _ in rows)
349
+ for name, value in rows:
350
+ terminal.write(f"{bar} {terminal.dim(name + ' ' * (width - display_width(name)))} {value}")
351
+ keys = (
352
+ tr("Enter 重新開啟網頁 · Ctrl+C 關閉 Clipen", "Enter reopens the page · Ctrl+C quits Clipen")
353
+ if interactive
354
+ else tr("Ctrl+C 關閉 Clipen", "Ctrl+C quits Clipen")
355
+ )
356
+ terminal.outro(terminal.dim(keys))
315
357
 
316
358
 
317
359
  def _terminal_reopen_loop(
@@ -331,7 +373,6 @@ def _terminal_reopen_loop(
331
373
  except Exception:
332
374
  opened = False
333
375
  if not opened:
334
- print("瀏覽器未自動開啟。", flush=True)
335
376
  _print_ui_url(public_url, first_connection=True)
336
377
 
337
378
 
@@ -430,22 +471,13 @@ async def _serve(
430
471
  while not server.started and not server.should_exit:
431
472
  await asyncio.sleep(0.02)
432
473
  if server.started:
433
- print("Clipen 已啟動", flush=True)
434
- if provider.state is ProviderState.READY:
435
- print(f"AI:{provider.name} 可用", flush=True)
436
- else:
437
- print(f"AI:{provider.name} 需要處理", flush=True)
438
- _print_ui_url(public_url)
439
- print("狀態:等待 UI 操作", flush=True)
474
+ interactive = sys.stdin.isatty()
440
475
  try:
441
476
  opened = browser_open(public_url)
442
477
  except Exception:
443
478
  opened = False
444
- if not opened:
445
- print("瀏覽器未自動開啟。", flush=True)
446
- _print_ui_url(public_url, first_connection=True)
447
- if sys.stdin.isatty():
448
- print("按 Enter 重新開啟 UI · 按 Ctrl+C 關閉 Clipen", flush=True)
479
+ _announce(provider, public_url, opened=opened, interactive=interactive)
480
+ if interactive:
449
481
  threading.Thread(
450
482
  target=_terminal_reopen_loop,
451
483
  args=(
@@ -456,8 +488,6 @@ async def _serve(
456
488
  name="clipen-terminal-reopen",
457
489
  daemon=True,
458
490
  ).start()
459
- else:
460
- print("按 Ctrl+C 關閉 Clipen", flush=True)
461
491
 
462
492
  announcement = asyncio.create_task(announce_when_started())
463
493
  previous_hup = None
@@ -500,16 +530,22 @@ def run_server(
500
530
  if lease is None:
501
531
  existing = _find_existing_controller(instance_root / ".controller.json")
502
532
  if existing is None:
503
- print("Clipen 無法連接正在啟動的本機工作台。請稍後再試。")
533
+ Terminal().error(
534
+ tr(
535
+ "Clipen 無法連接正在啟動的本機工作台。請稍後再試。",
536
+ "Clipen cannot reach the instance that is starting. Try again shortly.",
537
+ )
538
+ )
504
539
  return 1
505
- print("Clipen 已在執行", flush=True)
540
+ Terminal().step(
541
+ tr("Clipen 已在執行,已幫你重新開啟網頁", "Clipen is already running; reopened the page for you")
542
+ )
506
543
  _print_ui_url(existing.public_url)
507
544
  try:
508
545
  opened = browser_open(existing.public_url)
509
546
  except Exception:
510
547
  opened = False
511
548
  if not opened:
512
- print("瀏覽器未自動開啟。", flush=True)
513
549
  _print_ui_url(existing.public_url, first_connection=True)
514
550
  return 0
515
551
  try:
@@ -523,11 +559,13 @@ def run_server(
523
559
  )
524
560
  )
525
561
  except PortUnavailable as error:
526
- print(f"Clipen 無法啟動:{error}")
562
+ Terminal().error(tr(f"Clipen 無法啟動:{error}", f"Clipen could not start: {error}"))
527
563
  return 1
528
564
  except KeyboardInterrupt:
529
565
  pass
530
566
  finally:
531
567
  lease.close()
532
- print("Clipen 已停止", flush=True)
568
+ terminal = Terminal()
569
+ terminal.write()
570
+ terminal.write(tr(f"{terminal.paint('90', '■')} Clipen 已停止", f"{terminal.paint('90', '■')} Clipen stopped"))
533
571
  return 0
@@ -8,6 +8,7 @@ import sqlite3
8
8
  from typing import Mapping
9
9
 
10
10
  from clipen.domain import EditTimeline
11
+ from clipen.i18n import english
11
12
  from clipen.projects import ProjectError, ProjectRepository
12
13
  from clipen.projects.models import validate_project_id, validate_request_id
13
14
  from clipen.projects.storage import command_digest, utc_now
@@ -231,6 +232,8 @@ class EditAgentRepository:
231
232
  "font_style_id": selected_font,
232
233
  "target_duration_seconds": target,
233
234
  "music_choice": selected_music,
235
+ # The AI writes in the language of the person who asked.
236
+ **({"language": "en"} if english() else {}),
234
237
  }
235
238
  ),
236
239
  encoded(skill),
@@ -423,6 +426,11 @@ class EditAgentRepository:
423
426
  hand_over(intent)
424
427
  if choice is not None:
425
428
  intent["music_choice"] = choice
429
+ # A revision is written in the language of whoever asked for it.
430
+ if english():
431
+ intent["language"] = "en"
432
+ else:
433
+ intent.pop("language", None)
426
434
  db.execute("UPDATE production_sessions SET intent_json=? WHERE run_id=?", (encoded(intent), normalized))
427
435
  self._append_event(
428
436
  db,
@@ -7,6 +7,23 @@ OUTCOMES = {"done": "已處理", "partly": "部分處理", "not_done": "沒有
7
7
  # Work may be left only for one of these: the person has to decide or supply something,
8
8
  # or no Clipen tool can do it. Running out of effort is not a reason.
9
9
  REASONS = {"needs_you": "需要你決定或提供", "cannot": "Clipen 目前做不到"}
10
+ _OUTCOMES_EN = {"done": "Done", "partly": "Partly done", "not_done": "Not done", "kept": "Kept as you said"}
11
+ _REASONS_EN = {"needs_you": "Needs your decision or a file", "cannot": "Clipen can't do this yet"}
12
+
13
+
14
+ def outcome_label(outcome):
15
+ """How an answer to a note reads to the person, in their language."""
16
+ from clipen.i18n import english
17
+
18
+ return (_OUTCOMES_EN if english() else OUTCOMES).get(outcome, "")
19
+
20
+
21
+ def reason_label(reason):
22
+ from clipen.i18n import english
23
+
24
+ return (_REASONS_EN if english() else REASONS).get(reason, "")
25
+
26
+
10
27
  UNFINISHED = "change_report_unfinished"
11
28
 
12
29
 
@@ -7,6 +7,7 @@ import queue
7
7
  import threading
8
8
  from pathlib import Path
9
9
 
10
+ from clipen.i18n import tr
10
11
  from clipen.projects import ProjectError
11
12
  from clipen.providers.codex import ProviderCancelled
12
13
 
@@ -150,6 +151,9 @@ class EditAgentCoordinator:
150
151
  from .production_progress import production_activity
151
152
 
152
153
  progress = production_activity(db, latest.run_id)
154
+ from clipen.providers import liveness
155
+
156
+ progress["ai_output_at"] = liveness.last_output(latest.run_id)
153
157
  validation = next(
154
158
  (
155
159
  value
@@ -194,6 +198,8 @@ class EditAgentCoordinator:
194
198
  from clipen.rendering.stage import read_stage
195
199
 
196
200
  render["stage"] = read_stage(store.output_path(project_id, entry["render_id"], prepare=False))
201
+ if render["stage"]:
202
+ render["stage"] = tr(render["stage"])
197
203
  return {
198
204
  **render,
199
205
  "revision_id": entry["revision_id"],
@@ -10,6 +10,7 @@ from fractions import Fraction
10
10
  from pathlib import Path
11
11
 
12
12
  from clipen.domain import TrackKind
13
+ from clipen.i18n import english
13
14
  from clipen.projects import ProjectError
14
15
  from clipen.projects.storage import utc_now
15
16
 
@@ -36,7 +37,8 @@ class EvidenceTools:
36
37
  raise ProjectError("asr_unavailable", "本機語音辨識尚未就緒,請先安裝或修復本機語音環境。", status_code=409)
37
38
  request = {
38
39
  "source": span.to_storage(),
39
- "language": args.get("language", "zh"),
40
+ # Speech is recognised in the language the person works in unless the AI names another.
41
+ "language": args.get("language", "en" if english() else "zh"),
40
42
  "align_words": args.get("align_words", True),
41
43
  "model": runtime[1],
42
44
  }