zcode-pro 1.6.2 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +3 -2
- package/README.md +3 -2
- package/dist/inject.js +1428 -240
- package/package.json +2 -2
- package/src/host/helper.mjs +360 -37
- package/src/host/mcp-bridge.mjs +488 -0
- package/src/host/session-import/index.mjs +140 -0
- package/src/host/session-import/sources.mjs +839 -0
- package/src/host/session-import/util.mjs +239 -0
- package/src/host/session-import/write.mjs +405 -0
- package/src/host/session-import/zstd.mjs +68 -0
- package/src/host/taskIndex.mjs +374 -0
- package/src/inject/core.js +118 -13
- package/src/inject/features/idle-reclaim.js +48 -23
- package/src/inject/features/plugin-updates.js +58 -0
- package/src/inject/features/session-import.js +367 -0
- package/src/inject/features/session-link.js +3 -1
- package/src/inject/features/session-switch.js +10 -7
- package/src/inject/features/settings-dialog.js +92 -15
- package/src/inject/features/status-bar.js +88 -36
- package/src/inject/features/subagent-icon.js +472 -0
- package/src/inject/features/turn-usage.js +89 -32
- package/src/inject/features/ws-running.js +40 -10
- package/src/inject/index.js +2 -0
- package/src/inject/ui.js +10 -0
package/src/inject/core.js
CHANGED
|
@@ -67,22 +67,25 @@ export const DEFAULT_SHORTCUTS = {
|
|
|
67
67
|
|
|
68
68
|
// 状态栏任务统计项的两个组:会话级跟随当前会话,全局级始终显示;
|
|
69
69
|
// 设置里两节各自排序,保存时归一化为会话组在前(状态栏两组间一道竖线)
|
|
70
|
-
export const STATUS_SESSION_IDS = new Set(['ctx', 'questions', 'tokRate']);
|
|
70
|
+
export const STATUS_SESSION_IDS = new Set(['ctx', 'questions', 'tokRate', 'inOut', 'avgHit']);
|
|
71
71
|
export const STATUS_GLOBAL_IDS = new Set(['todayTokens', 'totalTokens', 'tasks']);
|
|
72
72
|
|
|
73
73
|
// 状态栏统计项的默认清单(顺序即默认显示顺序);设置 → 外观 → 状态栏里
|
|
74
74
|
// 可调顺序与显隐,配置存在 config.statusBar.items(整表覆盖)
|
|
75
|
-
// 每轮回答统计项(turn-usage.js
|
|
75
|
+
// 每轮回答统计项(turn-usage.js):回答末尾标注的四段,各自可显隐(顺序固定)
|
|
76
76
|
export const DEFAULT_TURN_ITEMS = [
|
|
77
77
|
{ id: 'turnIn', on: true }, // 输入
|
|
78
78
|
{ id: 'turnOut', on: true }, // 输出
|
|
79
|
+
{ id: 'turnTps', on: true }, // TPS(输出 ÷ 净生成秒数,官方口径)
|
|
79
80
|
{ id: 'turnCache', on: true }, // 缓存命中率
|
|
80
81
|
];
|
|
81
82
|
|
|
82
83
|
export const DEFAULT_STATUS_ITEMS = [
|
|
83
84
|
{ id: 'tokRate', on: true }, // 最近输出 tokens/s(60 秒窗口,本会话)
|
|
85
|
+
{ id: 'avgHit', on: true }, // 平均缓存命中率(本会话)
|
|
86
|
+
{ id: 'inOut', on: true }, // 累计输入/输出(本会话主轮请求)
|
|
84
87
|
{ id: 'ctx', on: true }, // 上下文占用
|
|
85
|
-
{ id: 'questions', on: true }, //
|
|
88
|
+
{ id: 'questions', on: true }, // 主请求数(官方 model_usage 口径)
|
|
86
89
|
{ id: 'todayTokens', on: true }, // 今日 token(今天的会话记录完整,数据准确)
|
|
87
90
|
{ id: 'totalTokens', on: true }, // 累计 token(官方使用统计,全历史)
|
|
88
91
|
{ id: 'tasks', on: true }, // 任务总数
|
|
@@ -174,7 +177,7 @@ const zh = {
|
|
|
174
177
|
proxyPlaceholder: 'http://127.0.0.1:7890',
|
|
175
178
|
proxySave: '保存',
|
|
176
179
|
proxySaved: '代理设置已保存',
|
|
177
|
-
proxyHint: '
|
|
180
|
+
proxyHint: '留空保存即清除手填代理:Windows 跟随系统代理,其他平台直连。',
|
|
178
181
|
proxyTest: '检测',
|
|
179
182
|
proxyTesting: '检测中…',
|
|
180
183
|
proxyTestEmpty: '请先输入代理地址',
|
|
@@ -186,7 +189,34 @@ const zh = {
|
|
|
186
189
|
proxyScopeSync: '同步',
|
|
187
190
|
proxyScopeSyncDesc: 'WebDAV 上传与下载走代理。',
|
|
188
191
|
tabSync: '同步',
|
|
192
|
+
tabImport: '导入会话',
|
|
189
193
|
tabDebug: '调试',
|
|
194
|
+
importDesc: '把 Codex、Claude Code、dsh、pi 的历史会话复制成 ZCode 任务。导入是快照,之后源会话的变化不会再同步。',
|
|
195
|
+
importSearch: '搜索标题或目录',
|
|
196
|
+
importRefresh: '刷新',
|
|
197
|
+
importShowAll: '显示全部',
|
|
198
|
+
importShowAllTip: '显示子代理会话、pi 里从 Codex 导入的副本,以及没有真实对话的 Claude 会话;已归档始终显示',
|
|
199
|
+
importOnlyProject: '只看所选项目',
|
|
200
|
+
importSelectAll: '全选',
|
|
201
|
+
importSelected: '导入所选({n})',
|
|
202
|
+
importImporting: '导入中…',
|
|
203
|
+
importLoading: '加载中…',
|
|
204
|
+
importNoSessions: '没有可导入的会话',
|
|
205
|
+
importNoSource: '没有找到该工具的会话目录',
|
|
206
|
+
importSourceMissing: '没有检测到会话目录',
|
|
207
|
+
importAlready: '已导入',
|
|
208
|
+
importAlreadyArchived: '已导入(任务已归档)',
|
|
209
|
+
importArchivedTaskTip: '导入的任务已归档;取消归档或删除后才能重新导入',
|
|
210
|
+
importArchived: '已归档',
|
|
211
|
+
importSubagent: '子代理',
|
|
212
|
+
importCodexCopy: 'Codex 副本',
|
|
213
|
+
importLarge: '大文件',
|
|
214
|
+
importCwdMissing: '原目录不存在',
|
|
215
|
+
importProjectNone: '不选项目(归到“任务”)',
|
|
216
|
+
importProjectHint: '项目只决定侧边栏归类,不改变会话原来的工作目录',
|
|
217
|
+
importConfirmLarge: '所选会话里有超过 20MB 的大文件,导入可能需要一些时间,继续吗?',
|
|
218
|
+
importDone: '导入完成:成功 {ok},跳过 {skip},失败 {fail}',
|
|
219
|
+
importFailed: '导入失败',
|
|
190
220
|
testNoSessionHint: '选择“跟随当前会话[当前模型]”时,选择上次会话中使用的供应商[模型]',
|
|
191
221
|
syncDesc: '手动把 ZCode Pro 设置与模型设置备份到 WebDAV,或在新电脑上恢复。两项各自独立成文件,可只上传或只覆盖其中一项;每次上传会额外保留一份带时间戳的历史版本(保留多少个见“历史版本”一行,上传后自动删除超出的最旧版本),下载时任选一个版本恢复;仅在点击按钮时传输,不做自动同步。',
|
|
192
222
|
syncUrlPlaceholder: 'https://dav.jianguoyun.com/dav/',
|
|
@@ -246,6 +276,8 @@ const zh = {
|
|
|
246
276
|
devReload: '重载 ZCode Pro',
|
|
247
277
|
devReloading: '重载中…',
|
|
248
278
|
devReloadDesc: '点击后约 2-3 秒内所有 ZCode 窗口自动刷新一次并加载新脚本。',
|
|
279
|
+
devToolsSwitch: '开发者工具',
|
|
280
|
+
devToolsSwitchDesc: '官方侧栏的“开发者工具”面板(Token 调试 / 网络状态),默认关闭。改动写入官方每秒轮询的开关,1 秒内生效。',
|
|
249
281
|
rowGapName: '段落间距',
|
|
250
282
|
rowGapDesc: '会话中段落等文本块之间的垂直间距(回合之间、答案内部)。',
|
|
251
283
|
listSpacingName: '列表上下边距',
|
|
@@ -315,6 +347,10 @@ const zh = {
|
|
|
315
347
|
autoRenameDone: '已重命名:',
|
|
316
348
|
featureWsRunning: '折叠时任务运行中提示',
|
|
317
349
|
featureWsRunningDesc: '有会话运行时,折叠的项目与任务分区头显示加载图标,全部结束消失。',
|
|
350
|
+
featureSubagentIcon: '子代理运行中提示',
|
|
351
|
+
featureSubagentIconDesc: '后台子代理在跑显机器人、后台终端命令在跑显终端图标(同时在跑机器人优先);未读圆点让位到行尾常显;会话运行中始终显示转圈图标;项目未读徽标忽略错误行。',
|
|
352
|
+
subagentRobotTip: '子代理运行中',
|
|
353
|
+
subagentTermTip: '后台命令运行中',
|
|
318
354
|
tabPerformance: '性能',
|
|
319
355
|
perfDesc: 'ZCode 为每个打开过的项目常驻一个会话进程,应用自身不会回收,项目多了内存占用就高。开启后,长时间未使用且没有任务在跑的项目会被自动释放:会话记录不受影响,再次打开时自动恢复,仅首次回复有几秒等待。正在使用的项目、运行中的会话与后台命令、定时任务都不会被回收。后台命令检测依赖系统进程信息(Linux / macOS / Windows 各走系统自带工具),检测不可用时功能自动停用。',
|
|
320
356
|
featureIdleReclaim: '空闲项目内存回收',
|
|
@@ -366,7 +402,7 @@ const zh = {
|
|
|
366
402
|
tabStatusPane: '状态栏',
|
|
367
403
|
themeColorsPane: '主题',
|
|
368
404
|
themeBgRegions: '分区背景',
|
|
369
|
-
themeBgRegionFollow: '
|
|
405
|
+
themeBgRegionFollow: '默认(全局壁纸)',
|
|
370
406
|
themeBgRegionLeft: '左侧边栏',
|
|
371
407
|
themeBgRegionCenter: '中间区域',
|
|
372
408
|
themeBgRegionRight: '右侧边栏',
|
|
@@ -419,7 +455,7 @@ const zh = {
|
|
|
419
455
|
themeBgDialogFrost: '设置弹窗磨砂',
|
|
420
456
|
themeBgMisc: '其他',
|
|
421
457
|
themeBgFollowGlobal: '跟随全局',
|
|
422
|
-
themeBgRegionsHint: '
|
|
458
|
+
themeBgRegionsHint: '来源选“默认(全局壁纸)”即该区不单独设置、直接显示全局壁纸;每行的缩放、遮罩可单独设置,选“跟随全局”即跟随“画面”的值;模糊、转场、播放仅作用于全局壁纸(分区只能铺图,不能播视频)。分区用文件夹时,轮换间隔与随机顺序沿用全局设置。',
|
|
423
459
|
themeBgPlayback: '播放(视频壁纸)',
|
|
424
460
|
themeBgVolume: '音量',
|
|
425
461
|
themeBgVolumeHint: '视频壁纸的音轨音量,0 = 静音(默认)',
|
|
@@ -439,7 +475,9 @@ const zh = {
|
|
|
439
475
|
tableCopied: '表格已复制',
|
|
440
476
|
sbItemCtx: '上下文占用',
|
|
441
477
|
sbItemTokRate: '最近输出 tokens/s',
|
|
442
|
-
sbItemQuestions: '
|
|
478
|
+
sbItemQuestions: '主请求数(本会话)',
|
|
479
|
+
sbItemInOut: '累计输入/输出(本会话主轮请求)',
|
|
480
|
+
sbItemHit: '平均缓存命中率(本会话)',
|
|
443
481
|
sbMaster: '启用统计',
|
|
444
482
|
sbMasterDesc: '总开关:关闭后输入框右下角的统计行与每轮回答的用量标注一起停用。',
|
|
445
483
|
sbGroupSession: '会话统计(跟随当前会话)',
|
|
@@ -448,8 +486,11 @@ const zh = {
|
|
|
448
486
|
sbLabelIn: '输入',
|
|
449
487
|
sbLabelOut: '输出',
|
|
450
488
|
sbLabelCache: '缓存',
|
|
489
|
+
sbLabelTps: '输出 tok/s',
|
|
490
|
+
sbLabelInOut: '输入/输出',
|
|
491
|
+
sbLabelHit: '平均命中',
|
|
451
492
|
turnUsageTitle: '本轮 token',
|
|
452
|
-
sbLabelQuestions: '
|
|
493
|
+
sbLabelQuestions: '主请求数',
|
|
453
494
|
sbItemTodayTokens: '今日 token',
|
|
454
495
|
sbItemTasks: '任务总数',
|
|
455
496
|
sbLabelCtx: '上下文',
|
|
@@ -495,6 +536,8 @@ const zh = {
|
|
|
495
536
|
featureSessionLink: '会话 ID 显示为任务名链接',
|
|
496
537
|
featureSessionLinkDesc: '提问与回答里的会话 ID(sess_ / session_ 开头)显示为任务名,点击切换到该会话,悬停可看原始 ID。',
|
|
497
538
|
featureComposerProviderDesc: '模型名前显示供应商名(如 BigModel-Max1 / glm-5.3),区分同名模型。',
|
|
539
|
+
featureSessionImport: '导入会话',
|
|
540
|
+
featureSessionImportDesc: '在设置弹窗里把 Codex、Claude Code、dsh、pi 的历史会话导入成 ZCode 任务。',
|
|
498
541
|
imageCopy: '复制图片',
|
|
499
542
|
imageCopied: '图片已复制到剪贴板',
|
|
500
543
|
imageCopyFailed: '复制图片失败',
|
|
@@ -638,6 +681,10 @@ const zh = {
|
|
|
638
681
|
headroomInterval: '监视间隔',
|
|
639
682
|
headroomIntervalDesc: '省电监视器轮询电源状态的间隔(10–3600 秒,默认 60);保存后从下一轮巡检起生效。',
|
|
640
683
|
headroomSecUnit: '秒',
|
|
684
|
+
serenaSwitch: 'Serena 语义检索',
|
|
685
|
+
serenaSwitchDesc: '注册 Serena MCP:用符号定位、引用查找等语义工具代替整文件读取,省 token。写入 ZCode MCP 配置,重启会话后生效。',
|
|
686
|
+
serenaEnabled: '已开启 Serena,重启会话后生效',
|
|
687
|
+
serenaDisabled: '已关闭 Serena,重启会话后移除',
|
|
641
688
|
upgradeCheck: '检查更新',
|
|
642
689
|
upgradeChecking: '检查中…',
|
|
643
690
|
upgradeUpToDate: '已是最新({v})',
|
|
@@ -761,7 +808,7 @@ const en = {
|
|
|
761
808
|
proxyPlaceholder: 'http://127.0.0.1:7890',
|
|
762
809
|
proxySave: 'Save',
|
|
763
810
|
proxySaved: 'Proxy settings saved.',
|
|
764
|
-
proxyHint: 'Save empty to clear the proxy.',
|
|
811
|
+
proxyHint: 'Save empty to clear the manual proxy; Windows then follows the system proxy, other platforms connect directly.',
|
|
765
812
|
proxyTest: 'Test',
|
|
766
813
|
proxyTesting: 'Testing…',
|
|
767
814
|
proxyTestEmpty: 'Enter a proxy address first',
|
|
@@ -773,7 +820,34 @@ const en = {
|
|
|
773
820
|
proxyScopeSync: 'Sync',
|
|
774
821
|
proxyScopeSyncDesc: 'WebDAV upload and download go through the proxy.',
|
|
775
822
|
tabSync: 'Sync',
|
|
823
|
+
tabImport: 'Session import',
|
|
776
824
|
tabDebug: 'Debug',
|
|
825
|
+
importDesc: 'Copy sessions from Codex, Claude Code, dsh and pi into ZCode tasks. The copy is a snapshot; later changes in the source session are not synced.',
|
|
826
|
+
importSearch: 'Search title or folder',
|
|
827
|
+
importRefresh: 'Refresh',
|
|
828
|
+
importShowAll: 'Show all',
|
|
829
|
+
importShowAllTip: 'Show subagent sessions, pi copies imported from Codex, and Claude sessions without real conversation; archived sessions are always shown',
|
|
830
|
+
importOnlyProject: 'Only the selected project',
|
|
831
|
+
importSelectAll: 'Select all',
|
|
832
|
+
importSelected: 'Import selected ({n})',
|
|
833
|
+
importImporting: 'Importing…',
|
|
834
|
+
importLoading: 'Loading…',
|
|
835
|
+
importNoSessions: 'No sessions to import',
|
|
836
|
+
importNoSource: 'The session folder for this tool was not found',
|
|
837
|
+
importSourceMissing: 'No session folder detected',
|
|
838
|
+
importAlready: 'Imported',
|
|
839
|
+
importAlreadyArchived: 'Imported (task archived)',
|
|
840
|
+
importArchivedTaskTip: 'The imported task is archived; unarchive or delete it before importing again',
|
|
841
|
+
importArchived: 'Archived',
|
|
842
|
+
importSubagent: 'Subagent',
|
|
843
|
+
importCodexCopy: 'Codex copy',
|
|
844
|
+
importLarge: 'Large',
|
|
845
|
+
importCwdMissing: 'Original folder missing',
|
|
846
|
+
importProjectNone: 'No project (Tasks section)',
|
|
847
|
+
importProjectHint: 'The project only controls the sidebar group; the session keeps its original working folder',
|
|
848
|
+
importConfirmLarge: 'The selection includes files larger than 20MB. Importing may take a while. Continue?',
|
|
849
|
+
importDone: 'Import finished: {ok} imported, {skip} skipped, {fail} failed',
|
|
850
|
+
importFailed: 'Import failed',
|
|
777
851
|
testNoSessionHint: 'With "Follow current session" selected, the provider and model of the last session are used (the label shows the model name in brackets).',
|
|
778
852
|
syncDesc: 'Manually back up ZCode Pro settings and model settings to WebDAV, or restore them on a new computer. The two items are stored as separate files, so you can upload or overwrite either one alone; every upload also keeps a timestamped history version (how many to keep is set in the "History" row; older ones are removed automatically after upload) and download lets you pick any of them. Data moves only when you click, never automatically.',
|
|
779
853
|
syncUrlPlaceholder: 'https://dav.example.com/dav/',
|
|
@@ -831,6 +905,8 @@ const en = {
|
|
|
831
905
|
syncVerSaved: 'Saved to',
|
|
832
906
|
devModeDesc: 'For development: after changing zcode-pro code, click "Reload ZCode Pro" instead of restarting ZCode. It builds automatically (when running from the source repo), restarts the ZCode Pro launcher process (fresh helper and injected script), and every ZCode window refreshes and re-injects. The ZCode app itself and all sessions stay untouched.',
|
|
833
907
|
devReload: 'Reload ZCode Pro',
|
|
908
|
+
devToolsSwitch: 'Developer tools',
|
|
909
|
+
devToolsSwitchDesc: 'The official "Developer tools" side pane (Token debug / Network status), off by default. The change goes to the flag the official app polls every second.',
|
|
834
910
|
devReloading: 'Reloading…',
|
|
835
911
|
devReloadDesc: 'Every ZCode window refreshes automatically within 2-3 seconds to load the new script.',
|
|
836
912
|
rowGapName: 'Paragraph spacing',
|
|
@@ -901,6 +977,10 @@ const en = {
|
|
|
901
977
|
autoRenameDone: 'Renamed: ',
|
|
902
978
|
featureWsRunning: 'Running indicator when collapsed',
|
|
903
979
|
featureWsRunningDesc: 'Collapsed project and task headers show a loader while sessions run.',
|
|
980
|
+
featureSubagentIcon: 'Subagent running indicator',
|
|
981
|
+
featureSubagentIconDesc: 'Task rows show a robot icon while subagents run and a terminal icon while background commands run (robot wins when both); the unread dot moves to the row end; running sessions always show a spinner; project unread badges ignore error rows.',
|
|
982
|
+
subagentRobotTip: 'Subagents running',
|
|
983
|
+
subagentTermTip: 'Background commands running',
|
|
904
984
|
tabPerformance: 'Performance',
|
|
905
985
|
perfDesc: 'ZCode keeps a session process resident for every project you have opened and never reclaims it, so memory grows with projects. When enabled, projects unused for a while with nothing running release their memory automatically: sessions are untouched and reload when reopened, with a few seconds\' wait on the first reply. The project in use, running sessions, background commands and scheduled tasks are never reclaimed. Background-command detection reads system process info via built-in tools (Linux / macOS / Windows); when unavailable, the feature disables itself.',
|
|
906
986
|
featureIdleReclaim: 'Idle project memory reclaim',
|
|
@@ -952,7 +1032,7 @@ const en = {
|
|
|
952
1032
|
tabStatusPane: 'Status bar',
|
|
953
1033
|
themeColorsPane: 'Theme',
|
|
954
1034
|
themeBgRegions: 'Regional backgrounds',
|
|
955
|
-
themeBgRegionFollow: '
|
|
1035
|
+
themeBgRegionFollow: 'Default (global)',
|
|
956
1036
|
themeBgRegionLeft: 'Left sidebar',
|
|
957
1037
|
themeBgRegionCenter: 'Center area',
|
|
958
1038
|
themeBgRegionRight: 'Right sidebar',
|
|
@@ -1005,7 +1085,7 @@ const en = {
|
|
|
1005
1085
|
themeBgDialogFrost: 'Frosted settings window',
|
|
1006
1086
|
themeBgMisc: 'Other',
|
|
1007
1087
|
themeBgFollowGlobal: 'Follow global',
|
|
1008
|
-
themeBgRegionsHint: 'Fit and mask can be set per row; "Follow global" uses the Display values. Blur, transition and playback apply only to the global wallpaper (regions are static images, no video). Region folders reuse the global rotation interval and order settings.',
|
|
1088
|
+
themeBgRegionsHint: '"Default (global)" means the region is not set on its own and just shows the global wallpaper. Fit and mask can be set per row; "Follow global" uses the Display values. Blur, transition and playback apply only to the global wallpaper (regions are static images, no video). Region folders reuse the global rotation interval and order settings.',
|
|
1009
1089
|
themeBgPlayback: 'Playback (video)',
|
|
1010
1090
|
themeBgVolume: 'Volume',
|
|
1011
1091
|
themeBgVolumeHint: 'Audio track volume of video wallpapers, 0 = muted (default)',
|
|
@@ -1025,7 +1105,9 @@ const en = {
|
|
|
1025
1105
|
tableCopied: 'Table copied',
|
|
1026
1106
|
sbItemCtx: 'Context usage',
|
|
1027
1107
|
sbItemTokRate: 'Recent output tokens/s',
|
|
1028
|
-
sbItemQuestions: '
|
|
1108
|
+
sbItemQuestions: 'Main requests (this session)',
|
|
1109
|
+
sbItemInOut: 'Total input/output (main requests, this session)',
|
|
1110
|
+
sbItemHit: 'Average cache hit rate (this session)',
|
|
1029
1111
|
sbMaster: 'Enable statistics',
|
|
1030
1112
|
sbMasterDesc: 'Master switch: turning this off disables both the input-box statistics and per-turn labels.',
|
|
1031
1113
|
sbGroupSession: 'Session statistics (follows the current session)',
|
|
@@ -1034,8 +1116,11 @@ const en = {
|
|
|
1034
1116
|
sbLabelIn: 'in',
|
|
1035
1117
|
sbLabelOut: 'out',
|
|
1036
1118
|
sbLabelCache: 'cache',
|
|
1119
|
+
sbLabelTps: 'out tok/s',
|
|
1120
|
+
sbLabelInOut: 'in/out',
|
|
1121
|
+
sbLabelHit: 'avg hit',
|
|
1037
1122
|
turnUsageTitle: 'Turn tokens',
|
|
1038
|
-
sbLabelQuestions: '
|
|
1123
|
+
sbLabelQuestions: 'reqs',
|
|
1039
1124
|
sbItemTodayTokens: 'Tokens today',
|
|
1040
1125
|
sbItemTasks: 'Tasks',
|
|
1041
1126
|
sbLabelCtx: 'ctx',
|
|
@@ -1081,6 +1166,8 @@ const en = {
|
|
|
1081
1166
|
featureSessionLink: 'Session ID links',
|
|
1082
1167
|
featureSessionLinkDesc: 'Shows session IDs (sess_ / session_) in chat as task names; click to switch to that session, hover for the raw ID.',
|
|
1083
1168
|
featureComposerProviderDesc: 'Shows the provider before the model name (e.g. BigModel-Max1 / glm-5.3).',
|
|
1169
|
+
featureSessionImport: 'Session import',
|
|
1170
|
+
featureSessionImportDesc: 'Import sessions from Codex, Claude Code, dsh and pi as ZCode tasks from the settings dialog.',
|
|
1084
1171
|
imageCopy: 'Copy image',
|
|
1085
1172
|
imageCopied: 'Image copied to the clipboard.',
|
|
1086
1173
|
imageCopyFailed: 'Failed to copy the image.',
|
|
@@ -1224,6 +1311,10 @@ const en = {
|
|
|
1224
1311
|
headroomInterval: 'Watch interval',
|
|
1225
1312
|
headroomIntervalDesc: 'Seconds between power checks (10–3600, default 60); applies from the next round.',
|
|
1226
1313
|
headroomSecUnit: 's',
|
|
1314
|
+
serenaSwitch: 'Serena semantic search',
|
|
1315
|
+
serenaSwitchDesc: 'Registers the Serena MCP: symbol lookup and reference search instead of reading whole files, saving tokens. Written to the ZCode MCP config; takes effect after restarting the session.',
|
|
1316
|
+
serenaEnabled: 'Serena enabled; takes effect after restarting the session',
|
|
1317
|
+
serenaDisabled: 'Serena disabled; removed after restarting the session',
|
|
1227
1318
|
upgradeCheck: 'Check for updates',
|
|
1228
1319
|
upgradeChecking: 'Checking…',
|
|
1229
1320
|
upgradeUpToDate: 'Up to date ({v})',
|
|
@@ -1357,6 +1448,17 @@ const errEn = {
|
|
|
1357
1448
|
'index-remap-failed': 'Failed to update the task index (config changes rolled back)',
|
|
1358
1449
|
'index-error': 'Task index error',
|
|
1359
1450
|
'index-busy': 'The task index is busy. Please retry shortly.',
|
|
1451
|
+
'bad-source': 'Unknown session source',
|
|
1452
|
+
'source-unavailable': 'No session folder found for this tool',
|
|
1453
|
+
'bad-request': 'Invalid import request',
|
|
1454
|
+
'too-many-items': 'At most 1000 sessions per import; split the selection',
|
|
1455
|
+
'project-not-found': 'Project not found or has no folder',
|
|
1456
|
+
'bad-source-path': 'The session file is outside the source folder or no longer exists',
|
|
1457
|
+
'session-mismatch': 'The session id does not match the file content',
|
|
1458
|
+
'empty-session': 'No messages to import',
|
|
1459
|
+
'db-missing': 'The ZCode session database or task index is missing',
|
|
1460
|
+
'import-failed': 'Import failed',
|
|
1461
|
+
'zstd-unavailable': 'This Node build cannot read dsh sessions (zstd support is missing)',
|
|
1360
1462
|
'vision-invalid': 'Invalid vision config',
|
|
1361
1463
|
'vision-read': 'Failed to read zcode-vision.json',
|
|
1362
1464
|
'vision-write': 'Failed to write zcode-vision.json',
|
|
@@ -1374,9 +1476,12 @@ const errEn = {
|
|
|
1374
1476
|
'headroom-action': 'The headroom action failed',
|
|
1375
1477
|
'headroom-status': 'Failed to read the headroom status',
|
|
1376
1478
|
'headroom-update': 'headroom update failed',
|
|
1479
|
+
'serena-config-unreadable': 'ZCode config is unparseable; aborted writing',
|
|
1377
1480
|
'ZCODE_NOT_FOUND': 'ZCode executable not found',
|
|
1378
1481
|
'plugins-status': 'Failed to read the plugin list',
|
|
1379
1482
|
'plugins-update': 'Failed to update plugins',
|
|
1483
|
+
'plugins-market-git': 'Git is missing and GitHub is unreachable. Install Git or set a proxy in ZCode Pro → Proxy, then retry.',
|
|
1484
|
+
'plugins-market-network': 'Cannot reach GitHub. If your network needs a proxy, set it in ZCode Pro → Proxy, then retry.',
|
|
1380
1485
|
'sync-invalid': 'Invalid sync settings',
|
|
1381
1486
|
'sync-not-configured': 'Set the sync type to WebDAV and save the config first',
|
|
1382
1487
|
'sync-remote-missing': 'No synced data on the server yet; upload from another computer first',
|
|
@@ -93,6 +93,32 @@ async function tryReclaim(ws, cooldownMs) {
|
|
|
93
93
|
blockUntil.set(ws, Date.now() + cooldownMs);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
// 挑出本轮到点的工作区并顺带维护空闲计时:启动扫(不等空闲时长)+ 空闲时长
|
|
97
|
+
// 到点的入列(入列即扣表,等调用方扫完后台命令后决定回收或重新累计)。
|
|
98
|
+
// busy 的清表、没起表的起表、冷却中的不动表只跳过(冷却过后到点即重试,与
|
|
99
|
+
// 原先每轮全量扫的节奏一致)
|
|
100
|
+
function dueForReclaim(workspaces, busy, idleSince, blockUntil, now, threshold, startupDue) {
|
|
101
|
+
const due = [];
|
|
102
|
+
const seen = new Set();
|
|
103
|
+
const add = (ws) => { if (!seen.has(ws)) { seen.add(ws); due.push(ws); } };
|
|
104
|
+
if (startupDue) {
|
|
105
|
+
for (const ws of workspaces) {
|
|
106
|
+
if (busy.has(ws) || (blockUntil.get(ws) || 0) > now) continue;
|
|
107
|
+
add(ws);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
for (const ws of workspaces) {
|
|
111
|
+
if (busy.has(ws)) { idleSince.delete(ws); continue; }
|
|
112
|
+
if (!idleSince.has(ws)) { idleSince.set(ws, now); continue; }
|
|
113
|
+
if (now - idleSince.get(ws) < threshold) continue;
|
|
114
|
+
if ((blockUntil.get(ws) || 0) > now) continue;
|
|
115
|
+
if (seen.has(ws)) continue; // 启动扫已入列:不动表,回收失败后到点再试
|
|
116
|
+
idleSince.delete(ws);
|
|
117
|
+
add(ws);
|
|
118
|
+
}
|
|
119
|
+
return due;
|
|
120
|
+
}
|
|
121
|
+
|
|
96
122
|
async function tick() {
|
|
97
123
|
if (!enabled) {
|
|
98
124
|
idleSince.clear();
|
|
@@ -125,39 +151,38 @@ async function tick() {
|
|
|
125
151
|
if (!workspaces.has(ws)) { idleSince.delete(ws); blockUntil.delete(ws); }
|
|
126
152
|
}
|
|
127
153
|
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
154
|
+
const now = Date.now();
|
|
155
|
+
// 启动一次性回收:应用启动会为每个恢复的项目预热会话进程,这次回收不等空闲
|
|
156
|
+
// 时长,到点把当时符合条件的项目一次收掉(0 = 启动后尽快回收一次;当前项目
|
|
157
|
+
// 定位不到时顺延到下一周期)。之后回归常规空闲计时
|
|
158
|
+
const startupDue = !startupSweepDone && now - bootAt >= startupMinutes * 60_000;
|
|
159
|
+
const due = dueForReclaim(workspaces, busy, idleSince, blockUntil, now, threshold, startupDue);
|
|
160
|
+
if (!due.length) {
|
|
161
|
+
if (startupDue) startupSweepDone = true;
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
// 后台命令扫描(/idle-busy,Windows 上是 PowerShell 全进程枚举)只对本轮到点
|
|
165
|
+
// 的工作区做一次,不随巡检每轮全量扫——每 30 秒扫全部候选是常驻卡顿源。
|
|
166
|
+
// 有后台命令在跑的工作区跳过回收、重新累计空闲时长;回收前照样确认没有
|
|
167
|
+
// 用户命令在跑,回收语义不变
|
|
168
|
+
const res = await rpc('/idle-busy', { method: 'POST', body: { paths: due } });
|
|
132
169
|
if (!res.ok || res.scan === false) {
|
|
133
170
|
// 无法确认后台命令状态(系统工具缺失 / helper 旧版):整体停用
|
|
134
171
|
if (!scanDisabledLogged) {
|
|
135
172
|
scanDisabledLogged = true;
|
|
136
173
|
console.info('[zcodepro] idle-reclaim: 后台命令扫描不可用,空闲回收停用');
|
|
137
174
|
}
|
|
175
|
+
// 启动扫不因失败反复重试:否则每个巡检周期(30 秒)都重新扫——扫描不可用
|
|
176
|
+
// 还每 30 秒拉一次 PowerShell 全进程枚举,正是要消除的常驻开销。下一次
|
|
177
|
+
// 尝试回到空闲阈值节奏(默认 30 分钟),扫描恢复后仍能自动接上
|
|
178
|
+
if (startupDue) startupSweepDone = true;
|
|
138
179
|
idleSince.clear();
|
|
139
180
|
return;
|
|
140
181
|
}
|
|
182
|
+
if (startupDue) startupSweepDone = true;
|
|
141
183
|
const procBusy = new Set(res.busy || []);
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
const now = Date.now();
|
|
145
|
-
// 启动一次性回收:应用启动会为每个恢复的项目预热会话进程,这次回收不等空闲
|
|
146
|
-
// 时长,到点把当时符合条件的项目一次收掉(0 = 启动后尽快回收一次;当前项目
|
|
147
|
-
// 定位不到时顺延到下一周期)。之后回归常规空闲计时
|
|
148
|
-
if (!startupSweepDone && now - bootAt >= startupMinutes * 60_000) {
|
|
149
|
-
startupSweepDone = true;
|
|
150
|
-
for (const ws of idleCandidates) {
|
|
151
|
-
if ((blockUntil.get(ws) || 0) > now) continue;
|
|
152
|
-
await tryReclaim(ws, threshold);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
for (const ws of workspaces) {
|
|
156
|
-
if (busy.has(ws) || procBusy.has(ws)) { idleSince.delete(ws); continue; }
|
|
157
|
-
if (!idleSince.has(ws)) { idleSince.set(ws, now); continue; }
|
|
158
|
-
if (now - idleSince.get(ws) < threshold) continue;
|
|
159
|
-
if ((blockUntil.get(ws) || 0) > now) continue;
|
|
160
|
-
idleSince.delete(ws);
|
|
184
|
+
for (const ws of due) {
|
|
185
|
+
if (procBusy.has(ws)) { idleSince.delete(ws); continue; }
|
|
161
186
|
await tryReclaim(ws, threshold);
|
|
162
187
|
}
|
|
163
188
|
}
|
|
@@ -5,6 +5,62 @@ import { rpc, getConfig, t } from '../core.js';
|
|
|
5
5
|
import { showToast } from '../ui.js';
|
|
6
6
|
|
|
7
7
|
const NOTIFIED_KEY = 'zcodepro-plugin-updates-notified';
|
|
8
|
+
const AUTO_UPDATE_LAUNCH_KEY = 'zcodepro-plugin-autoupdate-launch';
|
|
9
|
+
const AUTO_UPDATE_SESSION_KEY = 'zcodepro-plugin-autoupdate-session-claim';
|
|
10
|
+
|
|
11
|
+
// 当前 ZCode 启动批次的标记:页面 URL 的 zcodeLaunchMarks 带本次启动时间戳,
|
|
12
|
+
// 页面刷新不变、关掉重开变新值。取不到时退回 sessionStorage(刷新还在,
|
|
13
|
+
// 应用重启后失效),两条路都取不到时用本模块内存标记兜底。
|
|
14
|
+
function autoUpdateLaunchMark() {
|
|
15
|
+
try {
|
|
16
|
+
const raw = new URLSearchParams(location.search).get('zcodeLaunchMarks');
|
|
17
|
+
if (raw) {
|
|
18
|
+
const createdAt = JSON.parse(raw)?.createdAt;
|
|
19
|
+
if (createdAt != null) return `launch:${createdAt}`;
|
|
20
|
+
}
|
|
21
|
+
} catch { /* ignore */ }
|
|
22
|
+
try {
|
|
23
|
+
let id = sessionStorage.getItem('zcodepro-plugin-autoupdate-session');
|
|
24
|
+
if (!id) {
|
|
25
|
+
id = `session:${Date.now()}:${Math.random().toString(36).slice(2)}`;
|
|
26
|
+
sessionStorage.setItem('zcodepro-plugin-autoupdate-session', id);
|
|
27
|
+
}
|
|
28
|
+
return id;
|
|
29
|
+
} catch { return `memory:${Date.now()}:${Math.random().toString(36).slice(2)}`; }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let memoryClaimed = false;
|
|
33
|
+
|
|
34
|
+
// 注入脚本通常在页面文档开始时执行,URL 上的启动标记还在;若 Pro 后接入已加载
|
|
35
|
+
// 页面、URL 已被应用改写,退回 sessionStorage(即按窗口计)。只读一次并缓存,
|
|
36
|
+
// 应用内路由后面再改 URL 也不影响同一批次的判断。
|
|
37
|
+
const LAUNCH_MARK = autoUpdateLaunchMark();
|
|
38
|
+
|
|
39
|
+
// 在一个存储里领取:返回 true/false,存储不可用返回 null。localStorage 写失败
|
|
40
|
+
// (配额/权限)时不直接掉到内存标记,先试 sessionStorage,页面刷新后仍能记住。
|
|
41
|
+
function claimIn(storage, key, mark) {
|
|
42
|
+
try {
|
|
43
|
+
if (storage.getItem(key) === mark) return false;
|
|
44
|
+
storage.setItem(key, mark);
|
|
45
|
+
return true;
|
|
46
|
+
} catch { return null; }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// 领取本次启动的自动更新机会:同一启动批次只有第一次返回 true。
|
|
50
|
+
// 只在真要执行更新前调用——只检查没更新不占名额;更新一旦发起,本次启动不再
|
|
51
|
+
// 自动重试,失败请手动点“检查更新”或重启 ZCode。
|
|
52
|
+
export function claimAutoUpdateRun() {
|
|
53
|
+
const mark = LAUNCH_MARK;
|
|
54
|
+
const local = typeof localStorage === 'undefined' ? null : localStorage;
|
|
55
|
+
const viaLocal = local ? claimIn(local, AUTO_UPDATE_LAUNCH_KEY, mark) : null;
|
|
56
|
+
if (viaLocal !== null) return viaLocal;
|
|
57
|
+
const session = typeof sessionStorage === 'undefined' ? null : sessionStorage;
|
|
58
|
+
const viaSession = session ? claimIn(session, AUTO_UPDATE_SESSION_KEY, mark) : null;
|
|
59
|
+
if (viaSession !== null) return viaSession;
|
|
60
|
+
if (memoryClaimed) return false;
|
|
61
|
+
memoryClaimed = true;
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
8
64
|
|
|
9
65
|
export async function startPluginUpdateCheck() {
|
|
10
66
|
const status = await rpc('/plugins/status');
|
|
@@ -14,6 +70,8 @@ export async function startPluginUpdateCheck() {
|
|
|
14
70
|
|
|
15
71
|
const config = await getConfig();
|
|
16
72
|
if ((config.features || {}).autoUpdatePlugins === true) {
|
|
73
|
+
// 每次 ZCode 启动只自动更新一次:启动检查没更新过、设置弹窗先到,谁先谁占名额
|
|
74
|
+
if (!claimAutoUpdateRun()) return;
|
|
17
75
|
const res = await rpc('/plugins/update', { method: 'POST', body: {} });
|
|
18
76
|
if (res.ok) showToast(L.pluginsAutoUpdated, 'success');
|
|
19
77
|
else showToast(L.pluginsUpdateFailed + ': ' + (res.error || ''), 'error');
|