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
package/README.md CHANGED
@@ -128,7 +128,7 @@ Codex Mate manages existing tools and local records. It is not a new AI model or
128
128
  - **Usage Analytics**: Visualize message trends and top projects
129
129
  - **Prompt Templates**: Variable-fill dialog on invocation, one-template JSON sharing, and versioned plugin template configuration with history Diff and rollback. `git_diff` is pasted text, not an executed command.
130
130
  - **MCP Integration**: Expose local tools and resources via MCP stdio
131
- - **Auto Update**: Click the Web UI update notice to view versions and copy `codexmate update`. Run it on the service host, then restart the service after a successful update. Clicking or copying does not run updates
131
+ - **Updates**: Use the update notice to download the matching Windows, macOS, or Linux desktop installer from GitHub without leaving the app. Install it manually. For CLI + Web installs, copy `codexmate update`, run it on the service host, then restart the service.
132
132
 
133
133
  </details>
134
134
 
package/README.vi.md CHANGED
@@ -124,7 +124,7 @@ Codex Mate quản lý công cụ và dữ liệu cục bộ đã có. Đây khô
124
124
  - **Phân tích sử dụng**: Trực quan hóa xu hướng tin nhắn và dự án nổi bật
125
125
  - **Mẫu Prompt**: Hộp thoại điền biến khi gọi, chia sẻ một mẫu bằng JSON, lịch sử Diff và khôi phục cấu hình mẫu plugin. `git_diff` là văn bản được dán, không thực thi lệnh.
126
126
  - **Tích hợp MCP**: Expose tool và resource cục bộ qua MCP stdio
127
- - **Tự động cập nhật**: Nhấp thông báo phiên bản mới trong Web UI để xem phiên bản và sao chép `codexmate update`. Chạy trên máy chủ dịch vụ rồi khởi động lại dịch vụ sau khi cập nhật thành công. Nhấp hoặc sao chép không thực thi cập nhật
127
+ - **Cập nhật**: Với bản desktop Windows, macOS hoặc Linux, tải bộ cài tương ứng từ GitHub ngay trong hộp thoại cập nhật rồi cài thủ công. Với bản CLI + Web, sao chép `codexmate update`, chạy trên máy chủ dịch vụ rồi khởi động lại dịch vụ.
128
128
  - **Trình sửa tệp prompt**: Chỉnh sửa CLAUDE.md / AGENTS.md toàn cục và theo dự án với kho preset chung. Điền biến trước khi áp dụng preset; cần lưu thủ công để ghi tệp. Lịch sử hiển thị Diff; xác nhận khôi phục sẽ ghi phiên bản đã chọn với bản sao lưu nguyên tử và kiểm tra thay đổi bên ngoài. Tab và lựa chọn tệp đích được lưu và khôi phục sau khi tải lại. Pi giữ tệp đã chọn nếu còn trong danh sách; chỉ chuyển về mục đầu khi tệp không còn và không có bản nháp chưa lưu. Tab Pi liệt kê tệp `.md` trực tiếp trong `~/.pi/agent/` hoặc `<cwd>/.pi/`, cập nhật khi mở tab hoặc danh sách tệp; không tự động nạp prompt. Trang sửa prompt không thêm khoảng trống tải cấu hình, tránh nhảy vị trí cuộn khi quá trình tải hoàn tất. Tự động phát hiện đường dẫn dự án; tệp prompt toàn cục của OpenCode nằm tại `~/.config/opencode/AGENTS.md`.
129
129
  - **Bridge Provider Claude**: Kết nối Claude Code với provider tương thích OpenAI Chat Completions và Ollama qua proxy tương thích Claude cục bộ tích hợp.
130
130
  - **Kho Provider OpenCode**: Lưu nhiều provider trong kho riêng của CodexMate tại `~/.codexmate`, chỉ đưa provider đang chọn vào cấu hình OpenCode gốc, giữ nguyên thiết lập do người dùng quản lý.
package/README.zh.md CHANGED
@@ -127,7 +127,7 @@ Codex Mate 管理已有工具和本地记录,不是新的 AI 模型,也不
127
127
  - **Usage 统计**: 可视化消息趋势与热门项目统计
128
128
  - **提示词模板**: 调用时弹窗填写变量,支持单模板 JSON 分享、插件模板配置历史 Diff 与回滚。`git_diff` 需粘贴差异文本,不执行命令。
129
129
  - **MCP 集成**: 通过 MCP stdio 暴露本地工具与资源
130
- - **自动更新**: 点击 Web UI 的新版本提示,弹窗查看版本与复制 `codexmate update`;在服务主机终端执行,更新成功后重启服务。点击与复制不执行更新
130
+ - **版本更新**: Windows、macOS、Linux 桌面安装版可在更新弹窗下载对应的 GitHub 安装包,再手动安装。CLI + Web 版仍可复制 `codexmate update`,在服务主机执行,更新成功后重启服务。
131
131
  - **KiloCode 配置桥接**: 在 CLI 或 Web UI 配置 KiloCode Provider,写入 `~/.config/kilo/kilo.jsonc`,保留已存储的 API key。
132
132
 
133
133
  </details>
@@ -0,0 +1,73 @@
1
+ 'use strict';
2
+
3
+ const https = require('https');
4
+
5
+ const REPOSITORY = 'SakuraByteCore/codexmate';
6
+ const RELEASE_API = `https://api.github.com/repos/${REPOSITORY}/releases/latest`;
7
+ const DOWNLOAD_BASE = `https://github.com/${REPOSITORY}/releases/download/`;
8
+ const RELEASE_TAG = /^v\d+\.\d+\.\d+$/;
9
+ const METADATA_LIMIT = 1024 * 1024;
10
+ const PACKAGE_NAMES = {
11
+ win32: { stem: 'codexmate-setup', extension: '.exe', defaultArch: 'x64' },
12
+ darwin: { stem: 'Codex.Mate', extension: '.dmg', defaultArch: 'x64' },
13
+ linux: { stem: 'codexmate', extension: '.AppImage', defaultArch: 'x64' }
14
+ };
15
+
16
+ function getDesktopUpdateTarget(env = process.env) {
17
+ const match = /^(win32|darwin|linux)-(x64|arm64|ia32|armv7l)$/.exec(env.CODEXMATE_DESKTOP_PACKAGE || '');
18
+ return match ? { platform: match[1], arch: match[2] } : null;
19
+ }
20
+
21
+ function selectDesktopAsset(release, { platform, arch }) {
22
+ const policy = Object.prototype.hasOwnProperty.call(PACKAGE_NAMES, platform) ? PACKAGE_NAMES[platform] : null;
23
+ if (!policy || !RELEASE_TAG.test(release?.tag_name) || !Array.isArray(release.assets)) return null;
24
+ const tag = release.tag_name;
25
+ const prefix = `${policy.stem}-${tag.slice(1)}`;
26
+ const qualified = `${prefix}-${arch}${policy.extension}`;
27
+ const defaultName = `${prefix}${policy.extension}`;
28
+ // The release workflow builds unqualified Windows/Linux assets on x64 runners.
29
+ // electron-builder's default macOS DMG name omits the suffix for x64.
30
+ const matches = release.assets.filter(asset => {
31
+ if (asset?.state !== 'uploaded' || !Number.isSafeInteger(asset.size) || asset.size <= 0) return false;
32
+ if (asset.name !== qualified && !(arch === policy.defaultArch && asset.name === defaultName)) return false;
33
+ return asset.browser_download_url === `${DOWNLOAD_BASE}${tag}/${asset.name}`;
34
+ });
35
+ if (matches.length !== 1) return null;
36
+ const { name, size, browser_download_url: url } = matches[0];
37
+ return { name, size, url };
38
+ }
39
+
40
+ function fetchDesktopRelease(timeoutMs = 5000) {
41
+ return new Promise((resolve, reject) => {
42
+ const req = https.get(RELEASE_API, { headers: { 'User-Agent': 'CodexMate', Accept: 'application/vnd.github+json' } }, (res) => {
43
+ if (res.statusCode !== 200) {
44
+ res.resume();
45
+ reject(new Error(`GitHub Release API returned ${res.statusCode}`));
46
+ return;
47
+ }
48
+ let body = '';
49
+ res.setEncoding('utf8');
50
+ res.on('data', chunk => {
51
+ body += chunk;
52
+ if (body.length > METADATA_LIMIT) req.destroy(new Error('GitHub Release metadata exceeds limit'));
53
+ });
54
+ res.on('error', reject);
55
+ res.on('end', () => {
56
+ try {
57
+ const release = JSON.parse(body);
58
+ if (!RELEASE_TAG.test(release?.tag_name) || release.draft || release.prerelease || !Array.isArray(release.assets)) {
59
+ throw new Error('Invalid GitHub Release metadata');
60
+ }
61
+ resolve(release);
62
+ } catch (err) {
63
+ reject(err);
64
+ }
65
+ });
66
+ });
67
+ const deadline = setTimeout(() => req.destroy(new Error('GitHub Release check timed out')), timeoutMs);
68
+ req.once('close', () => clearTimeout(deadline));
69
+ req.on('error', reject);
70
+ });
71
+ }
72
+
73
+ module.exports = { getDesktopUpdateTarget, fetchDesktopRelease, selectDesktopAsset };
package/cli/skills.js CHANGED
@@ -30,6 +30,9 @@ const MAX_UPLOAD_SIZE = 200 * 1024 * 1024;
30
30
  const MAX_SKILLS_ZIP_UPLOAD_SIZE = 20 * 1024 * 1024;
31
31
  const MAX_SKILLS_ZIP_ENTRY_COUNT = 2000;
32
32
  const MAX_SKILLS_ZIP_UNCOMPRESSED_BYTES = 512 * 1024 * 1024;
33
+ const SKILLS_BACKUP_FORMAT = 'codexmate-skills-backup';
34
+ const SKILLS_BACKUP_MANIFEST = `${SKILLS_BACKUP_FORMAT}.json`;
35
+ const MAX_SKILLS_BACKUP_MANIFEST_BYTES = 2 * 1024 * 1024;
33
36
 
34
37
  function getCodexSkillsDir() {
35
38
  const joinPath = (basePath, ...segments) => {
@@ -753,6 +756,83 @@ function resolveSkillNameFromImportedDirectory(skillDir, extractionRoot, fallbac
753
756
  return normalizeCodexSkillName(candidate);
754
757
  }
755
758
 
759
+ function readSkillsBackupEntries(extractionRoot) {
760
+ const topLevel = fs.readdirSync(extractionRoot, { withFileTypes: true });
761
+ if (!topLevel.some((entry) => entry.name === SKILLS_BACKUP_MANIFEST && entry.isFile())) return null;
762
+ const manifestPath = path.join(extractionRoot, SKILLS_BACKUP_MANIFEST);
763
+ if (fs.statSync(manifestPath).size > MAX_SKILLS_BACKUP_MANIFEST_BYTES) return null;
764
+ let manifest;
765
+ try {
766
+ manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
767
+ } catch (error) {
768
+ if (error instanceof SyntaxError) return null;
769
+ throw error;
770
+ }
771
+ if (manifest?.format !== SKILLS_BACKUP_FORMAT || manifest.version !== 1
772
+ || !Array.isArray(manifest.skills) || !manifest.skills.length) return null;
773
+
774
+ const directories = new Set(topLevel.filter((entry) => entry.isDirectory()).map((entry) => entry.name));
775
+ const names = new Set();
776
+ for (const item of manifest.skills) {
777
+ const { name } = normalizeCodexSkillName(item?.name);
778
+ if (!name || name !== item.name || names.has(name) || !directories.has(name)
779
+ || typeof item.hasSkillFile !== 'boolean') return null;
780
+ const sourcePath = path.join(extractionRoot, name);
781
+ if (path.relative(extractionRoot, sourcePath) !== name) return null;
782
+ const entries = fs.readdirSync(sourcePath, { withFileTypes: true });
783
+ // v1 export copies regular contents, never archived links. Validate before touching the target.
784
+ const pending = entries.map((entry) => ({ entry, parent: sourcePath }));
785
+ while (pending.length) {
786
+ const { entry, parent } = pending.pop();
787
+ if (entry.isFile()) continue;
788
+ if (!entry.isDirectory()) return null;
789
+ const directory = path.join(parent, entry.name);
790
+ for (const child of fs.readdirSync(directory, { withFileTypes: true })) {
791
+ pending.push({ entry: child, parent: directory });
792
+ }
793
+ }
794
+ names.add(name);
795
+ }
796
+ return names;
797
+ }
798
+
799
+ function restoreSkillsBackup(extractionRoot, target, targetRoot) {
800
+ const names = readSkillsBackupEntries(extractionRoot);
801
+ if (!names) return { error: '不是有效的 v1 Skills 备份', backupError: 'invalid' };
802
+ if (isPathInside(targetRoot, extractionRoot)) return { error: '目标路径不能位于备份解压目录内' };
803
+
804
+ const imported = [];
805
+ const skipped = [];
806
+ const failed = [];
807
+ ensureDir(targetRoot);
808
+ for (const name of names) {
809
+ const destination = path.join(targetRoot, name);
810
+ let created = false;
811
+ try {
812
+ // Reserve the name without replacing an existing directory, file or symlink.
813
+ fs.mkdirSync(destination, { mode: 0o700 });
814
+ created = true;
815
+ copyDirRecursive(path.join(extractionRoot, name), destination, { dereferenceSymlinks: false });
816
+ imported.push({ name, path: destination });
817
+ } catch (error) {
818
+ if (!created && error.code === 'EEXIST') {
819
+ skipped.push({ name });
820
+ continue;
821
+ }
822
+ let message = error.message;
823
+ if (created) {
824
+ try {
825
+ removeDirectoryRecursive(destination);
826
+ } catch (cleanupError) {
827
+ message += `;清理未完成:${cleanupError.message}`;
828
+ }
829
+ }
830
+ failed.push({ name, error: message });
831
+ }
832
+ }
833
+ return { success: failed.length === 0, imported, skipped, failed, targetApp: target.app, targetLabel: target.label, root: targetRoot };
834
+ }
835
+
756
836
  async function importSkillsFromZipFile(zipPath, options = {}) {
757
837
  const getPathApi = (basePath) => {
758
838
  const base = typeof basePath === 'string' ? basePath.trim() : '';
@@ -776,12 +856,16 @@ async function importSkillsFromZipFile(zipPath, options = {}) {
776
856
  }
777
857
  targetRoot = resolveCopyTargetRoot(target.dir);
778
858
  const targetPathApi = getPathApi(targetRoot);
859
+ if (options.restoreBackup === true && fs.statSync(zipPath).size > MAX_SKILLS_ZIP_UPLOAD_SIZE) {
860
+ return { error: '备份文件过大(>20MB)', backupError: 'tooLarge' };
861
+ }
779
862
  await inspectZipArchiveLimits(zipPath, {
780
863
  maxEntryCount: MAX_SKILLS_ZIP_ENTRY_COUNT,
781
864
  maxUncompressedBytes: MAX_SKILLS_ZIP_UNCOMPRESSED_BYTES
782
865
  });
783
866
 
784
867
  await extractUploadZip(zipPath, extractionRoot);
868
+ if (options.restoreBackup === true) return restoreSkillsBackup(extractionRoot, target, targetRoot);
785
869
  const discovery = collectSkillDirectoriesFromRoot(extractionRoot, MAX_SKILLS_ZIP_ENTRY_COUNT);
786
870
  const discoveredDirs = discovery.results;
787
871
  if (discoveredDirs.length === 0) {
@@ -951,7 +1035,7 @@ async function exportSkills(params = {}) {
951
1035
  const exported = [];
952
1036
  const failed = [];
953
1037
  const manifest = {
954
- format: 'codexmate-skills-backup',
1038
+ format: SKILLS_BACKUP_FORMAT,
955
1039
  version: 1,
956
1040
  createdAt: new Date().toISOString(),
957
1041
  targetApp: target.app,
@@ -980,6 +1064,7 @@ async function exportSkills(params = {}) {
980
1064
  continue;
981
1065
  }
982
1066
 
1067
+ const targetPath = path.join(stagingRoot, normalizedName.name);
983
1068
  try {
984
1069
  const lstat = fs.lstatSync(sourcePath);
985
1070
  if (!lstat.isDirectory() && !lstat.isSymbolicLink()) {
@@ -992,7 +1077,6 @@ async function exportSkills(params = {}) {
992
1077
  failed.push({ name: normalizedName.name, error: '来源 skill 无法读取' });
993
1078
  continue;
994
1079
  }
995
- const targetPath = path.join(stagingRoot, normalizedName.name);
996
1080
  const visitedRealPaths = new Set([sourceDirForCopy]);
997
1081
  copyDirRecursive(sourceDirForCopy, targetPath, {
998
1082
  dereferenceSymlinks: true,
@@ -1009,6 +1093,7 @@ async function exportSkills(params = {}) {
1009
1093
  hasSkillFile: fs.existsSync(path.join(targetPath, 'SKILL.md'))
1010
1094
  });
1011
1095
  } catch (e) {
1096
+ if (includeAll) fs.rmSync(targetPath, { recursive: true, force: true });
1012
1097
  failed.push({
1013
1098
  name: normalizedName.name,
1014
1099
  error: e && e.message ? e.message : '导出失败'
@@ -1038,9 +1123,22 @@ async function exportSkills(params = {}) {
1038
1123
  } catch (_) {}
1039
1124
  }
1040
1125
  if (includeAll) {
1041
- fs.writeFileSync(path.join(stagingRoot, 'codexmate-skills-backup.json'), JSON.stringify(manifest, null, 2), 'utf8');
1126
+ fs.writeFileSync(path.join(stagingRoot, SKILLS_BACKUP_MANIFEST), JSON.stringify(manifest, null, 2), 'utf8');
1042
1127
  }
1043
1128
  await zipLib.archiveFolder(stagingRoot, zipFilePath);
1129
+ let restoreWarning = '';
1130
+ if (includeAll) {
1131
+ try {
1132
+ if (fs.statSync(zipFilePath).size > MAX_SKILLS_ZIP_UPLOAD_SIZE
1133
+ || fs.statSync(path.join(stagingRoot, SKILLS_BACKUP_MANIFEST)).size > MAX_SKILLS_BACKUP_MANIFEST_BYTES) {
1134
+ restoreWarning = '备份超过网页导入限制';
1135
+ } else {
1136
+ await inspectZipArchiveLimits(zipFilePath);
1137
+ }
1138
+ } catch (error) {
1139
+ restoreWarning = error.message;
1140
+ }
1141
+ }
1044
1142
  const artifact = registerDownloadArtifact(zipFilePath, {
1045
1143
  fileName: zipFileName,
1046
1144
  deleteAfterDownload: true
@@ -1055,7 +1153,8 @@ async function exportSkills(params = {}) {
1055
1153
  targetApp: target.app,
1056
1154
  targetLabel: target.label,
1057
1155
  root: target.dir,
1058
- backup: includeAll ? manifest : null
1156
+ backup: includeAll ? manifest : null,
1157
+ ...(restoreWarning ? { restoreWarning } : {})
1059
1158
  };
1060
1159
  } catch (e) {
1061
1160
  return {
package/cli/update.js CHANGED
@@ -3,6 +3,7 @@ const path = require('path');
3
3
  const os = require('os');
4
4
  const https = require('https');
5
5
  const { execSync, spawn } = require('child_process');
6
+ const { fetchDesktopRelease, selectDesktopAsset } = require('./desktop-release');
6
7
 
7
8
  /**
8
9
  * 快速更新命令实现
@@ -125,29 +126,40 @@ function comparePackageVersions(left, right) {
125
126
  return 0;
126
127
  }
127
128
 
128
- let latestVersionStatusCache = null;
129
+ const latestVersionStatusCache = new Map();
129
130
 
130
131
  async function fetchLatestVersionStatus(options = {}) {
132
+ const { desktopTarget } = options;
131
133
  const currentVersion = normalizePackageVersion(options.currentVersion) || String(options.currentVersion || '');
132
134
  const timeoutMs = Number.isFinite(Number(options.timeoutMs)) ? Number(options.timeoutMs) : 5000;
133
135
  const cacheTtlMs = Number.isFinite(Number(options.cacheTtlMs)) ? Math.max(0, Number(options.cacheTtlMs)) : 10 * 60 * 1000;
134
136
  const now = typeof options.now === 'function' ? options.now() : Date.now();
135
- if (latestVersionStatusCache && cacheTtlMs > 0 && now - latestVersionStatusCache.checkedAtMs < cacheTtlMs) {
136
- return { ...latestVersionStatusCache.payload, cached: true };
137
+ const source = desktopTarget ? 'github' : 'npm';
138
+ const cacheKey = desktopTarget ? `${source}:${desktopTarget.platform}:${desktopTarget.arch}` : source;
139
+ const cached = latestVersionStatusCache.get(cacheKey);
140
+ const useCache = cached && cacheTtlMs > 0 && now - cached.checkedAtMs < cacheTtlMs;
141
+ if (!useCache) latestVersionStatusCache.delete(cacheKey);
142
+
143
+ let metadata;
144
+ if (useCache) {
145
+ metadata = cached.metadata;
146
+ } else if (desktopTarget) {
147
+ const release = await fetchDesktopRelease(timeoutMs);
148
+ metadata = { latestVersion: normalizePackageVersion(release.tag_name), asset: selectDesktopAsset(release, desktopTarget) };
149
+ } else {
150
+ const raw = await fetchLatestVersion({ timeoutMs });
151
+ metadata = { latestVersion: normalizePackageVersion(raw) || String(raw || '') };
137
152
  }
138
-
139
- const latestVersionRaw = await fetchLatestVersion({ timeoutMs });
140
- const latestVersion = normalizePackageVersion(latestVersionRaw) || String(latestVersionRaw || '');
141
- const payload = {
142
- currentVersion,
143
- latestVersion,
144
- updateAvailable: !!currentVersion && !!latestVersion && comparePackageVersions(currentVersion, latestVersion) < 0,
145
- source: 'npm',
146
- checkedAt: new Date(now).toISOString(),
147
- cached: false
153
+ const { latestVersion, asset } = metadata;
154
+ const checkedAtMs = useCache ? cached.checkedAtMs : now;
155
+ latestVersionStatusCache.set(cacheKey, { checkedAtMs, metadata });
156
+ const updateAvailable = !!currentVersion && !!latestVersion && comparePackageVersions(currentVersion, latestVersion) < 0;
157
+ return {
158
+ currentVersion, latestVersion, updateAvailable, source,
159
+ checkedAt: new Date(checkedAtMs).toISOString(),
160
+ cached: !!useCache,
161
+ ...(desktopTarget ? { updateAction: 'download', asset: updateAvailable ? asset : null } : {})
148
162
  };
149
- latestVersionStatusCache = { checkedAtMs: now, payload };
150
- return payload;
151
163
  }
152
164
 
153
165
  function detectInstallMethod() {
package/cli.js CHANGED
@@ -182,6 +182,7 @@ const {
182
182
  } = require('./cli/skills');
183
183
  const { cmdImportSkills: cmdImportSkillsFromUrl } = require('./cli/import-skills-url');
184
184
  const { cmdToolUpdate, fetchLatestVersionStatus } = require('./cli/update');
185
+ const { getDesktopUpdateTarget } = require('./cli/desktop-release');
185
186
  const {
186
187
  getFileStatSafe,
187
188
  isBootstrapLikeText,
@@ -14389,6 +14390,8 @@ async function handleImportSkillsZipUpload(req, res, options = {}) {
14389
14390
  writeJsonResponse(res, 400, { error: '目标宿主不支持' });
14390
14391
  return;
14391
14392
  }
14393
+ const restoreBackup = !forcedTargetApp
14394
+ && new URL(req.url || '/', 'http://localhost').searchParams.get('mode') === 'backup';
14392
14395
  const fileName = resolveUploadFileNameFromRequest(req, `${targetApp}-skills.zip`);
14393
14396
  const upload = await writeUploadZipStream(
14394
14397
  req,
@@ -14399,7 +14402,8 @@ async function handleImportSkillsZipUpload(req, res, options = {}) {
14399
14402
  const result = await importSkillsFromZipFile(upload.zipPath, {
14400
14403
  tempDir: upload.tempDir,
14401
14404
  fallbackName: fileName,
14402
- targetApp
14405
+ targetApp,
14406
+ ...(restoreBackup ? { restoreBackup: true } : {})
14403
14407
  });
14404
14408
  writeJsonResponse(res, 200, result || {});
14405
14409
  } catch (e) {
@@ -14715,15 +14719,17 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
14715
14719
  return '';
14716
14720
  }
14717
14721
  })();
14722
+ const desktopTarget = getDesktopUpdateTarget();
14718
14723
  try {
14719
14724
  const force = !!(params && params.force);
14720
- result = await fetchLatestVersionStatus({ currentVersion, timeoutMs: 2000, cacheTtlMs: force ? 0 : undefined });
14725
+ result = await fetchLatestVersionStatus({ currentVersion, desktopTarget, timeoutMs: desktopTarget ? 5000 : 2000, cacheTtlMs: force ? 0 : undefined });
14721
14726
  } catch (e) {
14722
14727
  result = {
14723
14728
  currentVersion,
14724
14729
  latestVersion: '',
14725
14730
  updateAvailable: false,
14726
- source: 'npm',
14731
+ source: desktopTarget ? 'github' : 'npm',
14732
+ ...(desktopTarget ? { updateAction: 'download', asset: null } : {}),
14727
14733
  checkedAt: new Date().toISOString(),
14728
14734
  cached: false,
14729
14735
  error: e && e.message ? e.message : '获取最新版本失败'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexmate",
3
- "version": "0.1.36",
3
+ "version": "0.1.38",
4
4
  "description": "Codex/Claude Code/OpenClaw 配置、会话与任务编排 CLI + Web 工具",
5
5
  "main": "cli.js",
6
6
  "bin": {
@@ -23,6 +23,7 @@
23
23
  ".": "./cli.js",
24
24
  "./lib/*": "./lib/*.js",
25
25
  "./web-ui/*": "./web-ui/*",
26
+ "./desktop-release": "./cli/desktop-release.js",
26
27
  "./res/*": "./web-ui/res/*"
27
28
  },
28
29
  "scripts": {
package/web-ui/app.js CHANGED
@@ -114,6 +114,7 @@ document.addEventListener('DOMContentLoaded', () => {
114
114
  promptsSubTab: 'codex',
115
115
  promptsPreviewEnabled: true,
116
116
  promptsPreviewCollapsed: true,
117
+ promptsOutlineCollapsed: false,
117
118
  agentsChangeAxis: { mode: 'edit', ticks: [], truncated: false, totalLines: 0, added: 0, removed: 0 },
118
119
  sysChangeAxis: { mode: 'edit', ticks: [], truncated: false, totalLines: 0, added: 0, removed: 0 },
119
120
  promptsMobileView: 'edit',
@@ -123,6 +124,8 @@ document.addEventListener('DOMContentLoaded', () => {
123
124
  promptsPathReferenceCacheKey: '',
124
125
  agentsPreviewHtml: '',
125
126
  sysPromptPreviewHtml: '',
127
+ agentsPreviewHeadings: [],
128
+ sysPreviewHeadings: [],
126
129
  projectClaudeMdPath: '',
127
130
  promptHistoryVisible: false,
128
131
  promptHistoryLoading: false,
@@ -143,6 +146,7 @@ document.addEventListener('DOMContentLoaded', () => {
143
146
  showHealthCheckModal: false,
144
147
  showProviderCacheModal: false,
145
148
  showProviderCacheAnnouncementModal: false,
149
+ hasReadSideAnnouncement: false,
146
150
  showCodexBridgePoolModal: false,
147
151
  showClaudeBridgePoolModal: false,
148
152
  showWebhookModal: false,
@@ -459,6 +463,10 @@ document.addEventListener('DOMContentLoaded', () => {
459
463
  installStatusTargets: null,
460
464
  appLatestVersion: '',
461
465
  showAppUpdateModal: false,
466
+ appUpdateAction: 'command',
467
+ appUpdateAsset: null,
468
+ appUpdateDownloadPending: false,
469
+ appUpdateDownloadStatus: '',
462
470
  appVersionStatusLoading: false,
463
471
  appVersionStatusError: '',
464
472
  appVersionStatusChecked: false,
@@ -893,6 +901,15 @@ document.addEventListener('DOMContentLoaded', () => {
893
901
  },
894
902
 
895
903
  watch: {
904
+ mainPanelTabKey: {
905
+ flush: 'post',
906
+ handler() {
907
+ const root = document.getElementById('app');
908
+ root?.querySelector('.main-panel')?.scrollTo({ top: 0, left: 0, behavior: 'instant' });
909
+ // The outer app container owns vertical scroll in the narrow touch layout.
910
+ if (root?.scrollTop) root.scrollTo({ top: 0, behavior: 'instant' });
911
+ }
912
+ },
896
913
  mainTab(newTab) {
897
914
  if (typeof this.isMainTabDisabled === 'function' && this.isMainTabDisabled(newTab)) {
898
915
  const fallbackTab = typeof this.getFirstSelectableMainTab === 'function'
@@ -1,5 +1,17 @@
1
1
  export function createMainTabsComputed() {
2
2
  return {
3
+ mainPanelTabKey() {
4
+ switch (this.mainTab) {
5
+ case 'config': return `config:${this.configMode}`;
6
+ case 'settings': return `settings:${this.settingsTab}`;
7
+ case 'prompts': return `prompts:${this.promptsSubTab}`;
8
+ case 'plugins':
9
+ if (this.pluginsActiveId === 'prompt-templates') return `plugins:prompt-templates:${this.promptTemplatesMode}`;
10
+ if (this.pluginsActiveId === 'text-tools') return `plugins:text-tools:${this.textToolsActiveToolId}`;
11
+ return `plugins:${this.pluginsActiveId}`;
12
+ default: return this.mainTab;
13
+ }
14
+ },
3
15
  mainTabKicker() {
4
16
  if (this.mainTab === 'dashboard') return this.t('kicker.dashboard');
5
17
  if (this.mainTab === 'config') return this.t('kicker.config');
@@ -1082,9 +1082,6 @@ export function createAgentsMethods(options = {}) {
1082
1082
  this.__skipNextPromptsSubTabLoad = true;
1083
1083
  this.promptsSubTab = normalized;
1084
1084
  if (typeof this.loadPromptsTabContent === 'function') this.loadPromptsTabContent();
1085
- this.$nextTick(() => {
1086
- document.querySelector('.main-panel')?.scrollTo({ top: 0, left: 0, behavior: 'auto' });
1087
- });
1088
1085
  },
1089
1086
 
1090
1087
  async loadPromptsTabContent() {
@@ -72,7 +72,7 @@ export function createInstallMethods(options = {}) {
72
72
  },
73
73
 
74
74
  appUpdateNoticeMeta() {
75
- if (this.appVersionStatusLoading) return this.t('side.update.checkingMeta');
75
+ if (this.appVersionStatusLoading) return this.t(this.appUpdateAction === 'download' ? 'side.update.checking' : 'side.update.checkingMeta');
76
76
  if (this.appVersionStatusError) return this.appVersionStatusError;
77
77
  const current = this.normalizePackageVersion(this.appVersion);
78
78
  const latest = this.normalizePackageVersion(this.appLatestVersion);
@@ -106,10 +106,39 @@ export function createInstallMethods(options = {}) {
106
106
  return APP_UPDATE_COMMAND;
107
107
  },
108
108
 
109
+ hasNativeAppUpdateDownload() {
110
+ return typeof window !== 'undefined' && typeof window.desktopBridge?.downloadUpdate === 'function';
111
+ },
112
+
113
+ async downloadAppUpdate() {
114
+ const asset = this.appUpdateAsset;
115
+ if (this.appUpdateAction !== 'download' || !asset || this.appUpdateDownloadPending || !this.hasNativeAppUpdateDownload()) return;
116
+ this.appUpdateDownloadStatus = '';
117
+ this.appUpdateDownloadPending = true;
118
+ try {
119
+ const result = await window.desktopBridge.downloadUpdate(asset.url);
120
+ if (this.appUpdateAsset === asset) {
121
+ this.appUpdateDownloadStatus = ['completed', 'cancelled', 'unavailable'].includes(result?.status)
122
+ ? result.status : 'failed';
123
+ }
124
+ } catch (_) {
125
+ if (this.appUpdateAsset === asset) this.appUpdateDownloadStatus = 'failed';
126
+ } finally {
127
+ this.appUpdateDownloadPending = false;
128
+ if (this.showAppUpdateModal) this.$nextTick(() => (document.getElementById('app-update-primary') || document.getElementById('app-update-close'))?.focus());
129
+ }
130
+ },
131
+
132
+ async retryAppUpdateDownloadCheck() {
133
+ await this.loadAppVersionStatus({ silent: true, force: true });
134
+ if (this.showAppUpdateModal) this.$nextTick(() => (document.getElementById('app-update-primary') || document.getElementById('app-update-close'))?.focus());
135
+ },
136
+
109
137
  openAppUpdateModal(trigger) {
110
138
  this._appUpdateTrigger = trigger || document.activeElement;
111
139
  this.showAppUpdateModal = true;
112
- this.$nextTick(() => document.getElementById('app-update-command')?.focus());
140
+ const focusId = this.appUpdateAction === 'download' ? 'app-update-primary' : 'app-update-command';
141
+ this.$nextTick(() => document.getElementById(focusId)?.focus());
113
142
  },
114
143
 
115
144
  closeAppUpdateModal() {
@@ -126,6 +155,8 @@ export function createInstallMethods(options = {}) {
126
155
  this.appVersionStatusError = '';
127
156
  this.appVersionStatusChecked = false;
128
157
  this.appLatestVersion = '';
158
+ this.appUpdateAsset = null;
159
+ this.appUpdateDownloadStatus = '';
129
160
  this.appVersionStatusSource = '';
130
161
  this.appVersionStatusCheckedAt = '';
131
162
  try {
@@ -133,12 +164,17 @@ export function createInstallMethods(options = {}) {
133
164
  if (!this.appVersion) {
134
165
  this.appVersion = this.normalizePackageVersion(res?.currentVersion);
135
166
  }
167
+ if (res?.updateAction === 'download') this.appUpdateAction = 'download';
136
168
  if (res?.error) throw new Error(res.error);
137
169
  const latestVersion = this.normalizePackageVersion(res?.latestVersion);
138
170
  if (!latestVersion || !this.normalizePackageVersion(this.appVersion)) {
139
171
  throw new Error(this.t('side.update.checkFailed'));
140
172
  }
141
173
  this.appLatestVersion = latestVersion;
174
+ this.appUpdateAction = res.updateAction === 'download' ? 'download' : 'command';
175
+ if (this.appUpdateAction === 'download' && this.isAppUpdateAvailable() && res.asset?.url && res.asset?.name) {
176
+ this.appUpdateAsset = res.asset;
177
+ }
142
178
  this.appVersionStatusSource = typeof res.source === 'string' ? res.source : '';
143
179
  this.appVersionStatusCheckedAt = typeof res.checkedAt === 'string' ? res.checkedAt : '';
144
180
  this.appVersionStatusChecked = true;
@@ -26,12 +26,15 @@ import {
26
26
 
27
27
  const PROMPTS_PREVIEW_DEBOUNCE_MS = 300;
28
28
  const PROMPTS_AXIS_DEBOUNCE_MS = 300;
29
+ const PROMPTS_HEADING_SELECTOR = 'h1, h2, h3, h4, h5, h6';
29
30
 
30
31
  const PROMPTS_EDITOR_META = {
31
32
  agents: {
32
33
  contentField: 'agentsContent',
33
34
  originalField: 'agentsOriginalContent',
34
35
  previewField: 'agentsPreviewHtml',
36
+ headingsField: 'agentsPreviewHeadings',
37
+ previewPaneRef: 'promptsAgentsPreviewPane',
35
38
  axisField: 'agentsChangeAxis',
36
39
  diffLinesField: 'agentsDiffLines',
37
40
  diffStatsField: 'agentsDiffStats',
@@ -47,6 +50,8 @@ const PROMPTS_EDITOR_META = {
47
50
  contentField: 'sysPromptContent',
48
51
  originalField: 'sysPromptOriginalContent',
49
52
  previewField: 'sysPromptPreviewHtml',
53
+ headingsField: 'sysPreviewHeadings',
54
+ previewPaneRef: 'promptsSysPreviewPane',
50
55
  axisField: 'sysChangeAxis',
51
56
  diffLinesField: 'sysPromptDiffLines',
52
57
  diffStatsField: 'sysPromptDiffStats',
@@ -97,13 +102,19 @@ export function createPromptsEditorMethods(options = {}) {
97
102
  }
98
103
  const libs = resolvePromptsPreviewLibs();
99
104
  const state = buildMarkdownPreviewHtml(this[meta.contentField], libs.marked, libs.purify);
100
- if (state.unavailable) {
101
- this.promptsPreviewLibsMissing = true;
102
- this[meta.previewField] = '';
103
- return;
104
- }
105
- this.promptsPreviewLibsMissing = false;
105
+ this.promptsPreviewLibsMissing = Boolean(state.unavailable);
106
106
  this[meta.previewField] = state.html;
107
+ this[meta.headingsField] = [];
108
+ if (!state.html || typeof document === 'undefined') return;
109
+
110
+ // Use the sanitized preview so code fences and duplicate headings stay aligned with the rendered document.
111
+ const preview = document.createElement('template');
112
+ preview.innerHTML = state.html;
113
+ this[meta.headingsField] = Array.from(preview.content.querySelectorAll(PROMPTS_HEADING_SELECTOR), (heading, index) => ({
114
+ index,
115
+ depth: Math.min(Number(heading.tagName.slice(1)) - 1, 3),
116
+ text: heading.textContent.trim()
117
+ })).filter(heading => heading.text);
107
118
  },
108
119
 
109
120
  schedulePromptsPreview(key) {
@@ -186,6 +197,19 @@ export function createPromptsEditorMethods(options = {}) {
186
197
  }
187
198
  },
188
199
 
200
+ jumpToPromptsHeading(key, index) {
201
+ const meta = this.promptsEditorMeta(key);
202
+ if (!meta) return;
203
+ if (this.promptsPreviewCollapsed) this.togglePromptsPreviewCollapsed();
204
+ this.$nextTick(() => {
205
+ const pane = this.$refs[meta.previewPaneRef];
206
+ const heading = pane?.querySelectorAll(PROMPTS_HEADING_SELECTOR)[index];
207
+ if (!heading) return;
208
+ const top = heading.getBoundingClientRect().top - pane.getBoundingClientRect().top + pane.scrollTop;
209
+ pane.scrollTo({ top: top - 12 });
210
+ });
211
+ },
212
+
189
213
  setPromptsMobileView(view) {
190
214
  if (view === 'edit' || view === 'preview') {
191
215
  this.promptsMobileView = view;