codexmate 0.1.36 → 0.1.38

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 (43) hide show
  1. package/README.md +1 -1
  2. package/README.vi.md +1 -1
  3. package/README.zh.md +1 -1
  4. package/cli/desktop-release.js +73 -0
  5. package/cli/skills.js +103 -4
  6. package/cli/update.js +27 -15
  7. package/cli.js +9 -3
  8. package/package.json +2 -1
  9. package/web-ui/app.js +17 -0
  10. package/web-ui/modules/app.computed.main-tabs.mjs +12 -0
  11. package/web-ui/modules/app.methods.agents.mjs +0 -3
  12. package/web-ui/modules/app.methods.install.mjs +38 -2
  13. package/web-ui/modules/app.methods.prompts-editor.mjs +30 -6
  14. package/web-ui/modules/app.methods.provider-cache.mjs +3 -0
  15. package/web-ui/modules/app.methods.startup-claude.mjs +10 -5
  16. package/web-ui/modules/i18n/locales/en.mjs +25 -0
  17. package/web-ui/modules/i18n/locales/ja.mjs +26 -1
  18. package/web-ui/modules/i18n/locales/vi.mjs +25 -0
  19. package/web-ui/modules/i18n/locales/zh-tw.mjs +25 -0
  20. package/web-ui/modules/i18n/locales/zh.mjs +25 -0
  21. package/web-ui/modules/i18n.mjs +3 -2
  22. package/web-ui/modules/session-features.mjs +25 -1
  23. package/web-ui/modules/skills.methods.mjs +61 -16
  24. package/web-ui/partials/index/layout-header.html +91 -90
  25. package/web-ui/partials/index/modals-basic.html +22 -9
  26. package/web-ui/partials/index/panel-market.html +10 -3
  27. package/web-ui/partials/index/panel-plugins.html +13 -10
  28. package/web-ui/partials/index/panel-prompts.html +40 -20
  29. package/web-ui/partials/index/plugin-file-sharing.html +4 -4
  30. package/web-ui/partials/index/session-features.html +24 -7
  31. package/web-ui/res/web-ui-render.precompiled.js +831 -268
  32. package/web-ui/styles/layout-shell.css +176 -259
  33. package/web-ui/styles/plugins-panel.css +67 -46
  34. package/web-ui/styles/prompts-editor.css +127 -27
  35. package/web-ui/styles/session-features.css +12 -1
  36. package/web-ui/styles/settings-panel.css +16 -14
  37. package/web-ui/styles/system-prompt.css +9 -4
  38. package/web-ui/styles/theme-dark-tokens.css +4 -0
  39. package/web-ui/styles/theme-dark.css +5 -31
  40. package/web-ui/styles/theme-ocean-tokens.css +3 -0
  41. package/web-ui/styles/theme-ocean.css +3 -26
  42. package/web-ui/styles/theme-violet-tokens.css +3 -0
  43. package/web-ui/styles/theme-violet.css +12 -59
@@ -17,6 +17,8 @@ export function createProviderCacheMethods(options = {}) {
17
17
 
18
18
  async openProviderCacheAnnouncementModal() {
19
19
  this.showProviderCacheAnnouncementModal = true;
20
+ this.hasReadSideAnnouncement = true;
21
+ this.$nextTick?.(() => this.$refs.sideAnnouncementClose?.focus());
20
22
  if (!this.providerCacheLoadedOnce) {
21
23
  await this.loadProviderCacheRecords();
22
24
  }
@@ -24,6 +26,7 @@ export function createProviderCacheMethods(options = {}) {
24
26
 
25
27
  closeProviderCacheAnnouncementModal() {
26
28
  this.showProviderCacheAnnouncementModal = false;
29
+ this.$nextTick?.(() => this.$refs.sideAnnouncementTrigger?.focus());
27
30
  },
28
31
 
29
32
  async openProviderCacheDetailsFromAnnouncement() {
@@ -67,11 +67,16 @@ export function createStartupClaudeMethods(options = {}) {
67
67
  this.currentModels = statusRes.currentModels && typeof statusRes.currentModels === 'object'
68
68
  ? { ...statusRes.currentModels }
69
69
  : {};
70
- const dictModelForCurrent = this.currentProvider
71
- && typeof this.currentModels[this.currentProvider] === 'string'
72
- ? this.currentModels[this.currentProvider].trim()
73
- : '';
74
- this.currentModel = dictModelForCurrent || statusRes.model;
70
+ // config.toml is the active selection; the dictionary only remembers choices when switching providers.
71
+ const configuredModel = typeof statusRes.model === 'string' ? statusRes.model.trim() : '';
72
+ this.currentModel = configuredModel === '未设置' ? '' : configuredModel;
73
+ if (this.currentProvider && this.currentProvider !== '未设置') {
74
+ if (this.currentModel) {
75
+ this.currentModels[this.currentProvider] = this.currentModel;
76
+ } else {
77
+ delete this.currentModels[this.currentProvider];
78
+ }
79
+ }
75
80
  try {
76
81
  const installRes = await withRequestDeadline(signal => api('install-status', {}, { signal }), { timeoutMs: Math.max(0, Math.min(1200, timeLeftMs())) });
77
82
  if (installRes && !installRes.error) {
@@ -135,6 +135,11 @@ const en = Object.freeze({
135
135
  "features.indexFailures": "{count} read failures; these records are not covered",
136
136
  "features.coverage": "Searched {scanned}/{total} indexed sessions",
137
137
  "features.partial": "Partial coverage; at most 100 matches are shown",
138
+ "features.resultView": "Result view",
139
+ "features.byMessage": "By message",
140
+ "features.bySession": "By session",
141
+ "features.returnedMatches": "{count} returned matches",
142
+ "features.groupedTruncated": "Result limit reached; groups count only returned matches.",
138
143
  "features.context": "Surrounding context",
139
144
  "features.generateDraft": "Generate handoff draft ({count})",
140
145
  "features.draftReview": "Draft not sent. Review evidence and edit next steps before sending.",
@@ -467,6 +472,13 @@ const en = Object.freeze({
467
472
  'side.update.meta': 'Open update command',
468
473
  'side.update.metaVersions': 'Current v{current} → latest v{latest}',
469
474
  'side.update.commandHint': 'Run this in a terminal on the host running Codex Mate. Restart the service after a successful update.',
475
+ 'side.update.downloadPackage': 'Download installer',
476
+ 'side.update.downloading': 'Downloading…',
477
+ 'side.update.assetUnavailable': 'The matching installer is not available yet. Check again.',
478
+ 'side.update.download.completed': 'Download complete.',
479
+ 'side.update.download.cancelled': 'Download cancelled.',
480
+ 'side.update.download.failed': 'Download failed. Try again.',
481
+ 'side.update.download.unavailable': 'The installer has changed. Check for updates again.',
470
482
  'side.update.checkFailed': 'Failed to check latest version',
471
483
  'side.update.check': 'Check for updates',
472
484
  'side.update.checking': 'Checking for updates…',
@@ -555,6 +567,8 @@ const en = Object.freeze({
555
567
  'prompts.editor.preview': 'Preview',
556
568
  'prompts.editor.previewUnavailable': 'Preview components missing (marked / DOMPurify), please refresh the page',
557
569
  'prompts.editor.previewEmpty': 'Nothing to preview yet',
570
+ 'prompts.editor.outline': 'Document outline',
571
+ 'prompts.editor.outlineEmpty': 'No headings',
558
572
  'prompts.editor.changeAxis': 'Change navigation axis',
559
573
  'prompts.editor.changeAxisTick': 'Line {line} (+{added} / -{removed})',
560
574
  'prompts.tokenCount.hint': '~{count} tokens',
@@ -1645,6 +1659,17 @@ const en = Object.freeze({
1645
1659
 
1646
1660
  'market.backup.action': 'Back up current target',
1647
1661
  'market.backup.running': 'Backing up...',
1662
+ 'market.backup.export': 'Export backup',
1663
+ 'market.backup.import': 'Import backup',
1664
+ 'market.backup.targetChanged': 'Target changed. Select the backup again.',
1665
+ 'market.backup.tooLarge': 'The backup exceeds the 20 MiB import limit.',
1666
+ 'market.backup.invalid': 'Select a valid v1 Skills backup.',
1667
+ 'market.backup.importFailed': 'Could not import the backup.',
1668
+ 'market.backup.result': 'Restored: {restored}. Skipped: {skipped}. Failed: {failed}.',
1669
+ 'market.backup.exportFailed': 'Could not export the backup.',
1670
+ 'market.backup.exportPartial': 'Exported: {count}. Failed: {failed}.',
1671
+ 'market.backup.exportResult': 'Exported {count} entries.',
1672
+ 'market.backup.exportLimited': 'Keep this ZIP for offline recovery; it cannot be imported through the web page.',
1648
1673
  'market.export.action': 'Export selected',
1649
1674
  'market.export.running': 'Exporting...',
1650
1675
  'market.selection.all': 'Select all',
@@ -135,6 +135,11 @@ const ja = Object.freeze({
135
135
  "features.indexFailures": "{count} 件の読み込み失敗。該当記録は対象外です",
136
136
  "features.coverage": "登録済みセッション {scanned}/{total} 件を検索",
137
137
  "features.partial": "対象範囲は一部のみ。最大 100 件を表示",
138
+ "features.resultView": "結果の表示形式",
139
+ "features.byMessage": "メッセージ別",
140
+ "features.bySession": "セッション別",
141
+ "features.returnedMatches": "表示対象 {count} 件",
142
+ "features.groupedTruncated": "結果が上限に達しました。グループの件数は取得済みの結果のみを数えます。",
138
143
  "features.context": "前後の文脈",
139
144
  "features.generateDraft": "引き継ぎ下書きを作成({count} 件)",
140
145
  "features.draftReview": "下書きは未送信です。根拠を確認し、次の手順を編集してください。",
@@ -464,10 +469,17 @@ const ja = Object.freeze({
464
469
  'side.docs.cliInstall': 'CLI インストール',
465
470
  'side.docs.cliInstall.meta': 'インストール / 更新 / 削除',
466
471
  'side.update.available': '新しいバージョンがあります',
467
- 'side.update.availableWithVersion': '新しいバージョン v{version}',
472
+ 'side.update.availableWithVersion': 'v{version} 更新あり',
468
473
  'side.update.meta': '更新コマンドを開く',
469
474
  'side.update.metaVersions': '現在 v{current} → 最新 v{latest}',
470
475
  'side.update.commandHint': 'Codex Mate を実行しているホストのターミナルで実行してください。更新成功後、サービスを再起動してください。',
476
+ 'side.update.downloadPackage': 'インストーラーをダウンロード',
477
+ 'side.update.downloading': 'ダウンロード中…',
478
+ 'side.update.assetUnavailable': 'このバージョンの対応インストーラーはまだ利用できません。更新を再確認してください。',
479
+ 'side.update.download.completed': 'ダウンロードが完了しました。',
480
+ 'side.update.download.cancelled': 'ダウンロードをキャンセルしました。',
481
+ 'side.update.download.failed': 'ダウンロードに失敗しました。再試行してください。',
482
+ 'side.update.download.unavailable': 'インストーラーが変更されました。更新を再確認してください。',
471
483
  'side.update.checkFailed': '最新バージョンの確認に失敗しました',
472
484
  'side.update.check': '更新を確認',
473
485
  'side.update.checking': '更新を確認中…',
@@ -556,6 +568,8 @@ const ja = Object.freeze({
556
568
  'prompts.editor.preview': 'プレビュー',
557
569
  'prompts.editor.previewUnavailable': 'プレビュー用コンポーネント(marked / DOMPurify)が読み込まれていません。ページを再読み込みしてください',
558
570
  'prompts.editor.previewEmpty': 'プレビューする内容がありません',
571
+ 'prompts.editor.outline': 'ドキュメントの目次',
572
+ 'prompts.editor.outlineEmpty': '見出しがありません',
559
573
  'prompts.editor.changeAxis': '変更ナビゲーション軸',
560
574
  'prompts.editor.changeAxisTick': '{line} 行目(+{added} / -{removed})',
561
575
  'prompts.tokenCount.hint': '約 {count} トークン',
@@ -1647,6 +1661,17 @@ const ja = Object.freeze({
1647
1661
 
1648
1662
  'market.backup.action': '現在のターゲットをバックアップ',
1649
1663
  'market.backup.running': 'バックアップ中...',
1664
+ 'market.backup.export': 'バックアップをエクスポート',
1665
+ 'market.backup.import': 'バックアップをインポート',
1666
+ 'market.backup.targetChanged': 'ターゲットが変わりました。バックアップを選び直してください。',
1667
+ 'market.backup.tooLarge': 'バックアップが 20 MiB を超えているため、インポートできません。',
1668
+ 'market.backup.invalid': '有効な v1 Skills バックアップを選択してください。',
1669
+ 'market.backup.importFailed': 'バックアップのインポートに失敗しました。',
1670
+ 'market.backup.result': '復元 {restored} 件、スキップ {skipped} 件、失敗 {failed} 件。',
1671
+ 'market.backup.exportFailed': 'バックアップのエクスポートに失敗しました。',
1672
+ 'market.backup.exportPartial': 'エクスポート {count} 件、失敗 {failed} 件。',
1673
+ 'market.backup.exportResult': '{count} 件をエクスポートしました。',
1674
+ 'market.backup.exportLimited': 'この ZIP はオフライン用です。Web ページからはインポートできません。',
1650
1675
  'market.export.action': '選択をエクスポート',
1651
1676
  'market.export.running': 'エクスポート中...',
1652
1677
  'market.selection.all': 'すべて選択',
@@ -135,6 +135,11 @@ const vi = Object.freeze({
135
135
  "features.indexFailures": "Không đọc được {count} mục; kết quả không bao gồm các mục này",
136
136
  "features.coverage": "Đã tìm {scanned}/{total} phiên được lập chỉ mục",
137
137
  "features.partial": "Kết quả chưa bao phủ toàn bộ phạm vi; hiển thị tối đa 100 kết quả",
138
+ "features.resultView": "Chế độ xem kết quả",
139
+ "features.byMessage": "Theo tin nhắn",
140
+ "features.bySession": "Theo phiên",
141
+ "features.returnedMatches": "{count} kết quả trả về",
142
+ "features.groupedTruncated": "Đã đạt giới hạn; nhóm chỉ đếm các kết quả được trả về.",
138
143
  "features.context": "Ngữ cảnh xung quanh",
139
144
  "features.generateDraft": "Tạo bản nháp bàn giao ({count})",
140
145
  "features.draftReview": "Bản nháp chưa được gửi. Kiểm tra bằng chứng và sửa bước tiếp theo trước khi gửi.",
@@ -456,6 +461,13 @@ const vi = Object.freeze({
456
461
  'side.update.meta': 'Mở lệnh cập nhật',
457
462
  'side.update.metaVersions': 'Hiện tại v{current} → mới nhất v{latest}',
458
463
  'side.update.commandHint': 'Chạy lệnh trong terminal trên máy đang chạy Codex Mate. Khởi động lại dịch vụ sau khi cập nhật thành công.',
464
+ 'side.update.downloadPackage': 'Tải bộ cài',
465
+ 'side.update.downloading': 'Đang tải…',
466
+ 'side.update.assetUnavailable': 'Chưa có bộ cài phù hợp cho phiên bản này. Hãy kiểm tra lại.',
467
+ 'side.update.download.completed': 'Đã tải xong.',
468
+ 'side.update.download.cancelled': 'Đã hủy tải xuống.',
469
+ 'side.update.download.failed': 'Không tải được. Hãy thử lại.',
470
+ 'side.update.download.unavailable': 'Bộ cài đã thay đổi. Hãy kiểm tra bản cập nhật lại.',
459
471
  'side.update.checkFailed': 'Không thể kiểm tra phiên bản mới nhất',
460
472
  'side.update.check': 'Kiểm tra cập nhật',
461
473
  'side.update.checking': 'Đang kiểm tra cập nhật…',
@@ -602,6 +614,8 @@ const vi = Object.freeze({
602
614
  'prompts.editor.preview': 'Xem trước',
603
615
  'prompts.editor.previewUnavailable': 'Thư viện xem trước (marked / DOMPurify) chưa được tải, hãy tải lại trang',
604
616
  'prompts.editor.previewEmpty': 'Chưa có nội dung để xem trước',
617
+ 'prompts.editor.outline': 'Mục lục tài liệu',
618
+ 'prompts.editor.outlineEmpty': 'Không có tiêu đề',
605
619
  'prompts.editor.changeAxis': 'Trục điều hướng thay đổi',
606
620
  'prompts.editor.changeAxisTick': 'Dòng {line} (+{added} / -{removed})',
607
621
  'prompts.tokenCount.hint': '~{count} token',
@@ -1635,6 +1649,17 @@ const vi = Object.freeze({
1635
1649
  'market.root.fallback': 'Đường dẫn mặc định',
1636
1650
  'market.backup.action': 'Sao lưu mục tiêu hiện tại',
1637
1651
  'market.backup.running': 'Đang sao lưu...',
1652
+ 'market.backup.export': 'Xuất bản sao lưu',
1653
+ 'market.backup.import': 'Nhập bản sao lưu',
1654
+ 'market.backup.targetChanged': 'Đích đã thay đổi. Hãy chọn lại bản sao lưu.',
1655
+ 'market.backup.tooLarge': 'Bản sao lưu vượt giới hạn nhập 20 MiB.',
1656
+ 'market.backup.invalid': 'Hãy chọn bản sao lưu Skills v1 hợp lệ.',
1657
+ 'market.backup.importFailed': 'Không thể nhập bản sao lưu.',
1658
+ 'market.backup.result': 'Đã khôi phục: {restored}. Bỏ qua: {skipped}. Thất bại: {failed}.',
1659
+ 'market.backup.exportFailed': 'Không thể xuất bản sao lưu.',
1660
+ 'market.backup.exportPartial': 'Đã xuất: {count}. Thất bại: {failed}.',
1661
+ 'market.backup.exportResult': 'Đã xuất {count} mục.',
1662
+ 'market.backup.exportLimited': 'Giữ tệp ZIP này để khôi phục ngoại tuyến; không thể nhập qua trang web.',
1638
1663
  'market.export.action': 'Xuất đã chọn',
1639
1664
  'market.export.running': 'Đang xuất...',
1640
1665
  'market.selection.all': 'Chọn tất cả',
@@ -135,6 +135,11 @@ const zhTw = Object.freeze({
135
135
  "features.indexFailures": "{count} 項讀取失敗;結果未涵蓋這些記錄",
136
136
  "features.coverage": "已查 {scanned}/{total} 個已索引會話",
137
137
  "features.partial": "結果未完整涵蓋目前範圍;最多顯示 100 條命中",
138
+ "features.resultView": "結果檢視",
139
+ "features.byMessage": "按訊息",
140
+ "features.bySession": "按會話",
141
+ "features.returnedMatches": "已傳回 {count} 筆命中",
142
+ "features.groupedTruncated": "已達結果上限;會話分組只統計已傳回的命中。",
138
143
  "features.context": "前後文",
139
144
  "features.generateDraft": "產生交接草稿({count} 條)",
140
145
  "features.draftReview": "草稿未傳送;先核對證據,再填寫或修改後續步驟。",
@@ -467,6 +472,13 @@ const zhTw = Object.freeze({
467
472
  'side.update.meta': '點擊查看更新命令',
468
473
  'side.update.metaVersions': '目前 v{current} → 最新 v{latest}',
469
474
  'side.update.commandHint': '在執行 Codex Mate 的主機終端執行。更新成功後重新啟動服務。',
475
+ 'side.update.downloadPackage': '下載安裝包',
476
+ 'side.update.downloading': '正在下載…',
477
+ 'side.update.assetUnavailable': '此版本的對應安裝包尚未就緒,請重試檢查。',
478
+ 'side.update.download.completed': '下載完成。',
479
+ 'side.update.download.cancelled': '已取消下載。',
480
+ 'side.update.download.failed': '下載失敗,請重試。',
481
+ 'side.update.download.unavailable': '安裝包已變更,請重新檢查更新。',
470
482
  'side.update.checkFailed': '檢查最新版本失敗',
471
483
  'side.update.check': '檢查更新',
472
484
  'side.update.checking': '正在檢查更新…',
@@ -555,6 +567,8 @@ const zhTw = Object.freeze({
555
567
  'prompts.editor.preview': '預覽',
556
568
  'prompts.editor.previewUnavailable': '預覽元件未載入(marked / DOMPurify 缺失),請重新整理頁面',
557
569
  'prompts.editor.previewEmpty': '尚無內容可預覽',
570
+ 'prompts.editor.outline': '文件大綱',
571
+ 'prompts.editor.outlineEmpty': '暫無標題',
558
572
  'prompts.editor.changeAxis': '改動導覽軸',
559
573
  'prompts.editor.changeAxisTick': '第 {line} 行(+{added} / -{removed})',
560
574
  'prompts.tokenCount.hint': '約 {count} tokens',
@@ -1643,6 +1657,17 @@ const zhTw = Object.freeze({
1643
1657
 
1644
1658
  'market.backup.action': '備份目前目標',
1645
1659
  'market.backup.running': '備份中...',
1660
+ 'market.backup.export': '匯出備份',
1661
+ 'market.backup.import': '匯入備份',
1662
+ 'market.backup.targetChanged': '目標已切換,請重新選擇備份。',
1663
+ 'market.backup.tooLarge': '備份超過 20 MiB,無法匯入。',
1664
+ 'market.backup.invalid': '請選擇有效的 v1 Skills 備份。',
1665
+ 'market.backup.importFailed': '匯入備份失敗。',
1666
+ 'market.backup.result': '已還原 {restored} 項,略過 {skipped} 項,失敗 {failed} 項。',
1667
+ 'market.backup.exportFailed': '匯出備份失敗。',
1668
+ 'market.backup.exportPartial': '已匯出 {count} 項,失敗 {failed} 項。',
1669
+ 'market.backup.exportResult': '已匯出 {count} 項。',
1670
+ 'market.backup.exportLimited': '此 ZIP 可保留作離線備份,無法透過網頁匯入。',
1646
1671
  'market.export.action': '匯出選中',
1647
1672
  'market.export.running': '匯出中...',
1648
1673
  'market.selection.all': '全選',
@@ -135,6 +135,11 @@ const zh = Object.freeze({
135
135
  "features.indexFailures": "{count} 项读取失败;结果未覆盖这些记录",
136
136
  "features.coverage": "已查 {scanned}/{total} 条已索引会话",
137
137
  "features.partial": "结果未完整覆盖当前范围;最多展示 100 条命中",
138
+ "features.resultView": "结果视图",
139
+ "features.byMessage": "按消息",
140
+ "features.bySession": "按会话",
141
+ "features.returnedMatches": "已返回 {count} 条命中",
142
+ "features.groupedTruncated": "已达结果上限;会话分组只统计已返回的命中。",
138
143
  "features.context": "前后文",
139
144
  "features.generateDraft": "生成交接草稿({count} 条)",
140
145
  "features.draftReview": "草稿未发送;先核对证据,再填写或修改后续步骤。",
@@ -467,6 +472,13 @@ const zh = Object.freeze({
467
472
  'side.update.meta': '点击查看更新命令',
468
473
  'side.update.metaVersions': '当前 v{current} → 最新 v{latest}',
469
474
  'side.update.commandHint': '在运行 Codex Mate 的主机终端执行。更新成功后重启服务。',
475
+ 'side.update.downloadPackage': '下载安装包',
476
+ 'side.update.downloading': '正在下载…',
477
+ 'side.update.assetUnavailable': '此版本的对应安装包尚未就绪,请重试检查。',
478
+ 'side.update.download.completed': '下载完成。',
479
+ 'side.update.download.cancelled': '已取消下载。',
480
+ 'side.update.download.failed': '下载失败,请重试。',
481
+ 'side.update.download.unavailable': '安装包已变更,请重新检查更新。',
470
482
  'side.update.checkFailed': '检查最新版本失败',
471
483
  'side.update.check': '检查更新',
472
484
  'side.update.checking': '正在检查更新…',
@@ -555,6 +567,8 @@ const zh = Object.freeze({
555
567
  'prompts.editor.preview': '预览',
556
568
  'prompts.editor.previewUnavailable': '预览组件未加载(marked / DOMPurify 缺失),请刷新页面',
557
569
  'prompts.editor.previewEmpty': '暂无内容可预览',
570
+ 'prompts.editor.outline': '文档大纲',
571
+ 'prompts.editor.outlineEmpty': '暂无标题',
558
572
  'prompts.editor.changeAxis': '改动导航轴',
559
573
  'prompts.editor.changeAxisTick': '第 {line} 行(+{added} / -{removed})',
560
574
  'prompts.tokenCount.hint': '约 {count} tokens',
@@ -1643,6 +1657,17 @@ const zh = Object.freeze({
1643
1657
 
1644
1658
  'market.backup.action': '备份当前目标',
1645
1659
  'market.backup.running': '备份中...',
1660
+ 'market.backup.export': '导出备份',
1661
+ 'market.backup.import': '导入备份',
1662
+ 'market.backup.targetChanged': '目标已切换,请重新选择备份。',
1663
+ 'market.backup.tooLarge': '备份超过 20 MiB,无法导入。',
1664
+ 'market.backup.invalid': '请选择有效的 v1 Skills 备份。',
1665
+ 'market.backup.importFailed': '导入备份失败。',
1666
+ 'market.backup.result': '恢复 {restored} 项,跳过 {skipped} 项,失败 {failed} 项。',
1667
+ 'market.backup.exportFailed': '导出备份失败。',
1668
+ 'market.backup.exportPartial': '已导出 {count} 项,失败 {failed} 项。',
1669
+ 'market.backup.exportResult': '已导出 {count} 项。',
1670
+ 'market.backup.exportLimited': '此 ZIP 可保留作离线备份,无法通过网页导入。',
1646
1671
  'market.export.action': '导出选中',
1647
1672
  'market.export.running': '导出中...',
1648
1673
  'market.selection.all': '全选',
@@ -70,12 +70,13 @@ export function createI18nMethods() {
70
70
  toggleLanguageMenu() {
71
71
  this.languageMenuOpen = !this.languageMenuOpen;
72
72
  },
73
- closeLanguageMenu() {
73
+ closeLanguageMenu(restoreFocus = false) {
74
74
  this.languageMenuOpen = false;
75
+ if (restoreFocus) this.$refs?.sideLanguageTrigger?.focus();
75
76
  },
76
77
  selectLanguage(nextLang) {
77
78
  this.setLang(nextLang);
78
- this.languageMenuOpen = false;
79
+ this.closeLanguageMenu(true);
79
80
  },
80
81
  handleLanguageMenuFocusOut(event) {
81
82
  const currentTarget = event && event.currentTarget;
@@ -3,6 +3,11 @@ import { sessionEvidenceMixin } from './session-evidence.mjs';
3
3
  import { usagePricingMixin } from './usage-pricing.mjs';
4
4
  import { sessionGitMixin } from './session-git.mjs';
5
5
  import { contextWindowReference } from '../logic.context-window.mjs';
6
+ const INDEX_RESULT_VIEW_KEY = 'codexmateSessionIndexResultView';
7
+ function readIndexResultView() {
8
+ try { return globalThis.localStorage?.getItem(INDEX_RESULT_VIEW_KEY) === 'sessions' ? 'sessions' : 'messages'; }
9
+ catch (_) { return 'messages'; }
10
+ }
6
11
  const SessionMessageActions = {
7
12
  props: { message: { type: Object, required: true } },
8
13
  render() {
@@ -29,10 +34,23 @@ export const sessionFeaturesMixin = {
29
34
  return { featureView: '', featureBusy: false, featureError: '', bookmarks: [], bookmarkRevision: '',
30
35
  bookmarkQuery: '', bookmarkTag: '', bookmarkProject: '', bookmarkEditor: null,
31
36
  selectedContextIds: [], featureFocus: null, featureRequestSeq: 0,
32
- indexReport: null, indexResults: null, indexQuery: '', indexTimer: null, handoffDraftEvidence: [], handoffUnverified: [], projectReport: null, projectSelected: '', projectAlias: '', projectPrompt: null, contextWindowInput: '', contextSelectedModel: '', contextFeatureSettings: null, contextSettingsRevision: '', diagnosticsReport: null, diagnosticsMarkdown: '', diagnosticsRemote: false,
37
+ indexReport: null, indexResults: null, indexQuery: '', indexTimer: null, indexResultView: readIndexResultView(), handoffDraftEvidence: [], handoffUnverified: [], projectReport: null, projectSelected: '', projectAlias: '', projectPrompt: null, contextWindowInput: '', contextSelectedModel: '', contextFeatureSettings: null, contextSettingsRevision: '', diagnosticsReport: null, diagnosticsMarkdown: '', diagnosticsRemote: false,
33
38
  diagnosticsTargets: [], diagnosticsSelected: [], diagnosticsTimer: null };
34
39
  },
35
40
  computed: {
41
+ indexResultRows() {
42
+ const hits = this.indexResults?.results || [];
43
+ if (this.indexResultView === 'messages') {
44
+ return hits.map(hit => ({ key: `message:${hit.session.key}:${hit.nodeId}`, session: hit.session, hits: [hit] }));
45
+ }
46
+ const sessions = new Map();
47
+ for (const hit of hits) {
48
+ const key = `session:${hit.session.key}`;
49
+ if (!sessions.has(key)) sessions.set(key, { key, session: hit.session, hits: [] });
50
+ sessions.get(key).hits.push(hit);
51
+ }
52
+ return [...sessions.values()];
53
+ },
36
54
  indexCatalogTime() {
37
55
  const timestamp = this.indexReport?.updatedAt;
38
56
  const parsed = typeof timestamp === 'string' ? Date.parse(timestamp) : NaN;
@@ -162,6 +180,12 @@ export const sessionFeaturesMixin = {
162
180
  try { await this.featureCall('session-index-cancel'); await this.pollSessionIndex(); }
163
181
  catch (error) { this.featureError = this.featureErrorText(error); }
164
182
  },
183
+ setIndexResultView(view) {
184
+ if (view !== 'messages' && view !== 'sessions') return;
185
+ this.indexResultView = view;
186
+ try { globalThis.localStorage?.setItem(INDEX_RESULT_VIEW_KEY, view); }
187
+ catch (_) { /* Keep the view usable when browser storage is disabled. */ }
188
+ },
165
189
  async searchSessionIndex() {
166
190
  if (this.featureBusy) return;
167
191
  const seq = ++this.featureRequestSeq;
@@ -7,6 +7,46 @@ function showUnsupportedSkillsTargetMessage(vm, app) {
7
7
  vm.showMessage(`不支持的 Skills 安装目标:${String(app)}`, 'error');
8
8
  }
9
9
 
10
+ const MAX_SKILLS_ZIP_SIZE = 20 * 1024 * 1024;
11
+
12
+ async function restoreSkillsFromBackup(event) {
13
+ const input = event.target;
14
+ const file = input.files?.[0];
15
+ const targetApp = input.dataset.targetApp;
16
+ delete input.dataset.targetApp;
17
+ input.value = '';
18
+ if (!file) return;
19
+ if (targetApp !== this.skillsTargetApp) {
20
+ this.showMessage(this.t('market.backup.targetChanged'), 'error');
21
+ return;
22
+ }
23
+ if (this.loading || this.initError || this.skillsMarketBusy) return;
24
+ if (file.size > MAX_SKILLS_ZIP_SIZE) {
25
+ this.showMessage(this.t('market.backup.tooLarge'), 'error');
26
+ return;
27
+ }
28
+ this.skillsZipImporting = true;
29
+ let refresh = false;
30
+ try {
31
+ const result = await this.uploadSkillsZipStream(file, { targetApp, restoreBackup: true });
32
+ if (result.error || !Array.isArray(result.imported) || !Array.isArray(result.skipped) || !Array.isArray(result.failed)) {
33
+ const key = result.backupError === 'invalid' ? 'invalid'
34
+ : result.backupError === 'tooLarge' ? 'tooLarge' : 'importFailed';
35
+ this.showMessage(this.t(`market.backup.${key}`), 'error');
36
+ return;
37
+ }
38
+ const counts = { restored: result.imported.length, skipped: result.skipped.length, failed: result.failed.length };
39
+ this.showMessage(this.t('market.backup.result', counts), counts.failed ? 'error' : counts.skipped ? 'info' : 'success');
40
+ refresh = counts.restored > 0 || counts.failed > 0;
41
+ if (refresh) await this.refreshSkillsList({ silent: true });
42
+ } catch (error) {
43
+ this.showMessage(this.t('market.backup.importFailed'), 'error');
44
+ } finally {
45
+ this.skillsZipImporting = false;
46
+ if (refresh) await this.scanImportableSkills({ silent: true });
47
+ }
48
+ }
49
+
10
50
  export function createSkillsMethods({ api }) {
11
51
  return {
12
52
  normalizeSkillsTargetApp(app) {
@@ -24,6 +64,8 @@ export function createSkillsMethods({ api }) {
24
64
  this.skillsMarketSelectedNames = [];
25
65
  this.skillsKeyword = '';
26
66
  this.skillsStatusFilter = 'all';
67
+ const backupInput = this.$refs?.skillsBackupImportInput;
68
+ if (backupInput) delete backupInput.dataset.targetApp;
27
69
  this.skillsRootPath = '';
28
70
  this.skillsList = [];
29
71
  this.skillsImportList = [];
@@ -299,15 +341,19 @@ export function createSkillsMethods({ api }) {
299
341
  }
300
342
  },
301
343
 
302
- triggerSkillsZipImport() {
303
- const input = this.$refs.skillsZipImportInput;
344
+ triggerSkillsZipImport(mode) {
345
+ const isBackup = mode === 'backup';
346
+ if (isBackup && (this.loading || this.initError || this.skillsMarketBusy)) return;
347
+ const input = isBackup ? this.$refs.skillsBackupImportInput : this.$refs.skillsZipImportInput;
304
348
  if (input) {
305
349
  input.value = '';
350
+ if (isBackup) input.dataset.targetApp = this.skillsTargetApp;
306
351
  input.click();
307
352
  }
308
353
  },
309
354
 
310
- handleSkillsZipImportChange(event) {
355
+ handleSkillsZipImportChange(event, mode) {
356
+ if (mode === 'backup') return restoreSkillsFromBackup.call(this, event);
311
357
  const file = event && event.target && event.target.files ? event.target.files[0] : null;
312
358
  if (file) {
313
359
  void this.importSkillsFromZipFile(file);
@@ -321,11 +367,12 @@ export function createSkillsMethods({ api }) {
321
367
  }
322
368
  },
323
369
 
324
- async uploadSkillsZipStream(file) {
370
+ async uploadSkillsZipStream(file, { targetApp = this.skillsTargetApp, restoreBackup = false } = {}) {
325
371
  const fileName = (file && typeof file.name === 'string' && file.name.trim())
326
372
  ? file.name.trim()
327
- : `${this.skillsTargetApp}-skills.zip`;
328
- const response = await fetch(`/api/import-skills-zip?targetApp=${encodeURIComponent(this.skillsTargetApp)}`, {
373
+ : `${targetApp}-skills.zip`;
374
+ const mode = restoreBackup ? '&mode=backup' : '';
375
+ const response = await fetch(`/api/import-skills-zip?targetApp=${encodeURIComponent(targetApp)}${mode}`, {
329
376
  method: 'POST',
330
377
  headers: authorizationHeaders({
331
378
  'x-codexmate-file-name': encodeURIComponent(fileName)
@@ -350,8 +397,7 @@ export function createSkillsMethods({ api }) {
350
397
 
351
398
  async importSkillsFromZipFile(file) {
352
399
  if (this.skillsDeleting || this.skillsScanningImports || this.skillsZipImporting || this.skillsImporting || this.skillsExporting || this.skillsBackingUp) return;
353
- const maxSize = 20 * 1024 * 1024;
354
- if (file.size > maxSize) {
400
+ if (file.size > MAX_SKILLS_ZIP_SIZE) {
355
401
  this.showMessage('ZIP 文件过大,限制 20MB', 'error');
356
402
  this.resetSkillsZipImportInput();
357
403
  return;
@@ -441,12 +487,8 @@ export function createSkillsMethods({ api }) {
441
487
  this.skillsBackingUp = true;
442
488
  try {
443
489
  const res = await api('backup-skills', { targetApp: this.skillsTargetApp });
444
- if (res && res.error) {
445
- this.showMessage(res.error, 'error');
446
- return;
447
- }
448
- if (!res || !res.fileName) {
449
- this.showMessage('备份失败:未生成压缩包', 'error');
490
+ if (res?.error || !res?.fileName) {
491
+ this.showMessage(this.t('market.backup.exportFailed'), 'error');
450
492
  return;
451
493
  }
452
494
  const link = document.createElement('a');
@@ -456,9 +498,12 @@ export function createSkillsMethods({ api }) {
456
498
  link.click();
457
499
  document.body.removeChild(link);
458
500
  const count = Array.isArray(res.exported) ? res.exported.length : 0;
459
- this.showMessage(`已备份 ${this.skillsTargetLabel} 的 ${count} 个 skill`, 'success');
501
+ const failed = Array.isArray(res.failed) ? res.failed.length : 0;
502
+ const summary = this.t(failed ? 'market.backup.exportPartial' : 'market.backup.exportResult', { count, failed });
503
+ const message = res.restoreWarning ? `${summary} ${this.t('market.backup.exportLimited')}` : summary;
504
+ this.showMessage(message, failed || res.restoreWarning ? 'error' : 'success');
460
505
  } catch (e) {
461
- this.showMessage('备份 skill 失败', 'error');
506
+ this.showMessage(this.t('market.backup.exportFailed'), 'error');
462
507
  } finally {
463
508
  this.skillsBackingUp = false;
464
509
  }