codexmate 0.1.34 → 0.1.35

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 (47) hide show
  1. package/README.md +15 -1
  2. package/README.vi.md +15 -1
  3. package/README.zh.md +15 -1
  4. package/cli/analytics-export-args.js +7 -0
  5. package/cli/session-usage.js +4 -1
  6. package/cli.js +29 -5
  7. package/lib/data/model-prices.json +1868 -0
  8. package/lib/session-context-health.js +5 -1
  9. package/lib/session-evidence-collections.js +85 -0
  10. package/lib/session-features.js +15 -0
  11. package/lib/session-project-git.js +65 -0
  12. package/lib/session-projects.js +12 -1
  13. package/lib/session-stories.js +67 -0
  14. package/lib/session-usage-ledger.js +77 -0
  15. package/lib/session-usage-pricing.js +42 -0
  16. package/lib/session-usage-report.js +101 -0
  17. package/package.json +4 -1
  18. package/plugins/prompt-templates/computed.mjs +9 -0
  19. package/web-ui/app.js +10 -0
  20. package/web-ui/logic.session-artifacts.mjs +39 -0
  21. package/web-ui/modules/app.methods.agents.mjs +3 -2
  22. package/web-ui/modules/app.methods.session-browser.mjs +35 -0
  23. package/web-ui/modules/app.methods.system-prompt.mjs +16 -7
  24. package/web-ui/modules/app.methods.web-ui-preferences.mjs +5 -0
  25. package/web-ui/modules/i18n/locales/en.mjs +116 -1
  26. package/web-ui/modules/i18n/locales/ja.mjs +116 -1
  27. package/web-ui/modules/i18n/locales/vi.mjs +116 -1
  28. package/web-ui/modules/i18n/locales/zh-tw.mjs +116 -1
  29. package/web-ui/modules/i18n/locales/zh.mjs +116 -1
  30. package/web-ui/modules/session-collections.mjs +65 -0
  31. package/web-ui/modules/session-evidence.mjs +81 -0
  32. package/web-ui/modules/session-features.mjs +15 -1
  33. package/web-ui/modules/session-git.mjs +39 -0
  34. package/web-ui/modules/session-stories.mjs +64 -0
  35. package/web-ui/modules/usage-pricing.mjs +30 -0
  36. package/web-ui/partials/index/layout-footer.html +1 -1
  37. package/web-ui/partials/index/panel-sessions.html +20 -20
  38. package/web-ui/partials/index/panel-usage.html +2 -0
  39. package/web-ui/partials/index/session-features.html +82 -2
  40. package/web-ui/partials/index/thread-handoff.html +73 -62
  41. package/web-ui/partials/index/usage-records.html +41 -0
  42. package/web-ui/res/web-ui-render.precompiled.js +772 -125
  43. package/web-ui/styles/session-features.css +63 -0
  44. package/web-ui/styles/sessions-list.css +74 -0
  45. package/web-ui/styles/sessions-preview.css +106 -68
  46. package/web-ui/styles/sessions-usage.css +8 -0
  47. package/web-ui/styles/theme-violet.css +9 -3
@@ -127,7 +127,11 @@ const zhTw = Object.freeze({
127
127
  "features.index": "全文索引",
128
128
  "features.refreshIndex": "更新索引",
129
129
  "features.indexStatus": "已索引 {count} 個會話;本輪 {processed}/{total}",
130
- "features.indexScope": "僅涵蓋已發現候選;沿用上方來源、專案與角色篩選。新訊息需更新索引。",
130
+ "features.indexCatalogTime": "索引目錄更新時間(UTC):{time}",
131
+ "features.indexSourceCoverage": "{source}:發現 {count} 個候選;發現上限 {limit}",
132
+ "features.indexUnknown": "未知",
133
+ "features.indexCoverageUnknown": "目前來源沒有涵蓋記錄;請更新索引。",
134
+ "features.indexScope": "僅搜尋已索引候選,不代表全部歷史或最新訊息。目錄時間不代表每個來源的同步時間。沿用上方來源、專案與角色篩選;新訊息需更新索引。",
131
135
  "features.indexFailures": "{count} 項讀取失敗;結果未涵蓋這些記錄",
132
136
  "features.coverage": "已查 {scanned}/{total} 個已索引會話",
133
137
  "features.partial": "結果未完整涵蓋目前範圍;最多顯示 100 條命中",
@@ -1132,6 +1136,21 @@ const zhTw = Object.freeze({
1132
1136
  'sessions.roleLabel.assistant': 'Assistant',
1133
1137
 
1134
1138
  // Usage panel
1139
+ "usage.records.title": "用量記錄明細",
1140
+ "usage.records.scope": "記錄按 UTC 日期歸屬;Codex 使用累計計數增量,Claude/Pi 使用助手用量,Gemini 使用既有 JSON 會話的 tokens。Gemini 總量含思考與工具 Token,快取是輸入子集;未提供分項保持未知。舊圖表仍按會話更新時間歸屬。完整文字估算單列,不代表費用。",
1141
+ "usage.records.coverage": "已掃描 {scanned}/{candidates} 個候選會話;無用量記錄 {unreported},未支援逐記錄來源 {unsupported}。",
1142
+ "usage.records.failed": "讀取失敗 {count} 個會話,目前結果不完整;重新整理後重試。",
1143
+ "usage.records.total": "記錄 Token",
1144
+ "usage.records.estimated": "完整文字估算 Token",
1145
+ "usage.records.cacheRead": "快取讀取",
1146
+ "usage.records.cacheWrite": "快取寫入",
1147
+ "usage.records.unknown": "未知",
1148
+ "usage.records.date": "日期 (UTC)",
1149
+ "usage.records.source": "來源",
1150
+ "usage.records.model": "模型",
1151
+ "usage.records.input": "輸入",
1152
+ "usage.records.output": "輸出",
1153
+ "usage.records.undated": "缺少記錄時間的 Token:{tokens};不分攤至某一天。",
1135
1154
  'usage.overview': 'Usage 概覽',
1136
1155
  'usage.range.aria': 'Usage 時間範圍',
1137
1156
  'usage.range.7d': '近 7 天',
@@ -1863,6 +1882,102 @@ const zhTw = Object.freeze({
1863
1882
  'sysPrompt.hint.unsaved': '有未儲存的變更',
1864
1883
  'sysPrompt.hint.twoStepSave': '點擊預覽查看差異,確認後儲存。',
1865
1884
  'sysPrompt.toast.saved': 'System prompt 已儲存',
1885
+ "evidence.title": "跨會話證據包",
1886
+ "evidence.select": "加入證據包",
1887
+ "evidence.remove": "移除",
1888
+ "evidence.goal": "交接目標",
1889
+ "evidence.generate": "產生證據包",
1890
+ "evidence.preview": "預覽({count} 字元)",
1891
+ "evidence.download": "下載 Markdown",
1892
+ "evidence.memory": "材料僅存本頁,重新整理清空;原記錄不變。",
1893
+ "evidence.scope": "僅摘錄使用者選定的歷史材料;未傳送,未驗證目前版本。",
1894
+ "evidence.path": "原文路徑",
1895
+ "evidence.status": "歷史證據狀態",
1896
+ "evidence.passed": "歷史工具記錄提示通過,目前版本未驗",
1897
+ "evidence.failed": "歷史工具記錄提示失敗",
1898
+ "evidence.unverified": "待核對",
1899
+ "evidence.changed": "原文已變更;更新索引後重新選取。",
1900
+ "evidence.limit": "最多選取 100 筆材料。",
1901
+ "artifacts.format": "輸出格式",
1902
+ "artifacts.receipt": "開發小票",
1903
+ "artifacts.relay": "多 Agent 接力包",
1904
+ "artifacts.generate.receipt": "產生開發小票",
1905
+ "artifacts.generate.relay": "產生接力包",
1906
+ "artifacts.scope": "僅基於選定歷史材料,在本機產生;未傳送、未執行、目前版本未驗收。",
1907
+ "artifacts.goal": "目標(使用者填寫)",
1908
+ "artifacts.note": "補充說明(使用者填寫,選填)",
1909
+ "artifacts.notePlaceholder": "填寫改動原因、下一步或驗收標準;不作為驗證證據。",
1910
+ "artifacts.unspecified": "尚未填寫,請人工補充。",
1911
+ "artifacts.checks": "歷史檢查記錄彙總",
1912
+ "artifacts.noVerdict": "記錄數量不代表任務完成或目前版本測試通過;原文摘錄見下方。",
1913
+ "artifacts.sources": "選定材料與來源",
1914
+ "artifacts.executor": "第一棒:執行者",
1915
+ "artifacts.executorTask": "核對目標、原文與允許修改範圍。僅按明確授權執行;目標不清或材料失效時停止。交付實際改動、檢查結果、失敗與未驗證項,不重播歷史命令。",
1916
+ "artifacts.reviewer": "第二棒:審閱者",
1917
+ "artifacts.reviewerTask": "唯讀核查執行者結果、原文來源與目前版本。區分事實、推論與缺證,不把已投遞或自報讀取當作完成。列出仍需人工驗收的步驟。",
1918
+ "artifacts.uat": "人工 UAT:待執行,未驗收",
1919
+ "artifacts.uatTask": "在待驗版本從真實入口複測目標,記錄可觀察結果與失敗判據。歷史記錄、交接或自報讀取不能替代目前驗收。",
1920
+
1921
+ "collections.title": "證據專題夾",
1922
+ "collections.scope": "僅明確儲存名稱、目標與原文引用;開啟會取代暫存材料籃。重新整理後需手動開啟,不備份原會話。",
1923
+ "collections.name": "專題名稱",
1924
+ "collections.save": "儲存專題",
1925
+ "collections.saveAs": "另存專題",
1926
+ "collections.remove": "移除專題",
1927
+ "collections.refresh": "重新整理專題",
1928
+ "collections.empty": "尚無已儲存專題",
1929
+ "collections.state.ready": "原文一致",
1930
+ "collections.state.changed": "原文已變更",
1931
+ "collections.state.unavailable": "無法讀取原文",
1932
+ "stories.title": "開發故事線",
1933
+ "stories.scope": "使用者明確關聯,不證明會話產生提交或測試通過。僅儲存本機中繼資料,不寫入 Git、不上傳。",
1934
+ "stories.linked": "使用者關聯",
1935
+ "stories.unavailable": "會話不在目前發現候選中",
1936
+ "stories.session": "關聯會話",
1937
+ "stories.choose": "選擇目前專案會話",
1938
+ "stories.note": "改動原因",
1939
+ "stories.save": "儲存關聯",
1940
+ "stories.remove": "取消關聯",
1941
+ "stories.refresh": "重新整理關聯",
1942
+ "features.error.collection-input-invalid": "檢查專題名稱、目標與選取引用",
1943
+ "features.error.collection-not-found": "專題已移除;重新整理清單",
1944
+ "features.error.collection-source-unavailable": "原文已變更或無法讀取;更新索引後重新選取",
1945
+ "features.error.story-input-invalid": "檢查專案、完整提交 SHA 與備註",
1946
+ "features.error.story-project-unavailable": "專案不在目前發現範圍",
1947
+ "features.error.story-session-unavailable": "會話不在目前專案候選中",
1948
+ "features.error.story-not-found": "關聯已移除;重新整理清單",
1949
+ "features.error.project-git-commit-invalid": "提交不在目前專案最近 30 筆記錄中",
1950
+
1951
+ "pricing.title": "費用參考(USD)",
1952
+ "pricing.scope": "依內建價格快照的基礎文字單價估算,不是帳單。不含階梯、服務層、快取時長、工具或多模態附加費;不推斷歷史計費供應商。",
1953
+ "pricing.total": "參考總額",
1954
+ "pricing.subtotal": "已知列小計",
1955
+ "pricing.coverage": "已定價 {known} 列;未知 {unknown} 列;讀取失敗 {failed};未報告 {unreported};未支援 {unsupported}",
1956
+ "pricing.basis": "依據",
1957
+ "pricing.rates": "每百萬 Token:輸入 {input} / 輸出 {output} / 快取讀取 {cached} / 快取寫入 {created}",
1958
+ "pricing.download": "下載價格參考 JSON",
1959
+ "pricing.reason.base-rate": "基礎單價估算",
1960
+ "pricing.reason.model-unknown": "模型無價格記錄",
1961
+ "pricing.reason.usage-incomplete": "Token 分項不完整",
1962
+ "pricing.reason.usage-unclassified": "存在未分類 Token",
1963
+ "pricing.reason.rate-missing": "分項單價缺失",
1964
+
1965
+ "git.title": "Git 變更關聯(唯讀)",
1966
+ "git.scope": "僅查看目前專案倉庫。依會話更新時間前後 24 小時列出提交候選,不代表因果或測試通過;不寫入 Git、不上傳會話。",
1967
+ "git.detached": "分離 HEAD",
1968
+ "git.noHead": "尚無提交",
1969
+ "git.changes": "目前變更 {count} 個檔案",
1970
+ "git.truncated": "最多顯示 30 個提交及 50 個變更檔案;目前清單已截斷。",
1971
+ "git.candidate": "時間關聯候選",
1972
+ "git.refresh": "重新整理 Git",
1973
+ "git.status.ready": "已讀取目前 Git 狀態",
1974
+ "git.status.unborn": "倉庫尚無提交",
1975
+ "git.status.not-repository": "不是 Git 倉庫",
1976
+ "git.status.path-unavailable": "專案路徑無法存取",
1977
+ "git.status.git-unavailable": "找不到 Git",
1978
+ "git.status.read-timeout": "讀取 Git 逾時",
1979
+ "git.status.read-failed": "讀取 Git 失敗",
1980
+
1866
1981
  });
1867
1982
 
1868
1983
  export { zhTw };
@@ -127,7 +127,11 @@ const zh = Object.freeze({
127
127
  "features.index": "全文索引",
128
128
  "features.refreshIndex": "更新索引",
129
129
  "features.indexStatus": "已索引 {count} 条会话;本轮 {processed}/{total}",
130
- "features.indexScope": "仅覆盖已发现候选;沿用上方来源、项目与角色筛选。新消息需更新索引。",
130
+ "features.indexCatalogTime": "索引目录更新时间(UTC):{time}",
131
+ "features.indexSourceCoverage": "{source}:发现 {count} 个候选;发现上限 {limit}",
132
+ "features.indexUnknown": "未知",
133
+ "features.indexCoverageUnknown": "当前来源没有覆盖记录;请更新索引。",
134
+ "features.indexScope": "仅搜索已索引候选,不代表全部历史或最新消息。目录时间不代表每个来源的同步时间。沿用上方来源、项目与角色筛选;新消息需更新索引。",
131
135
  "features.indexFailures": "{count} 项读取失败;结果未覆盖这些记录",
132
136
  "features.coverage": "已查 {scanned}/{total} 条已索引会话",
133
137
  "features.partial": "结果未完整覆盖当前范围;最多展示 100 条命中",
@@ -1132,6 +1136,21 @@ const zh = Object.freeze({
1132
1136
  'sessions.roleLabel.assistant': 'Assistant',
1133
1137
 
1134
1138
  // Usage panel
1139
+ "usage.records.title": "用量记录明细",
1140
+ "usage.records.scope": "记录按 UTC 日期归属;Codex 使用累计计数增量,Claude/Pi 使用助手用量,Gemini 使用既有 JSON 会话的 tokens。Gemini 总量含思考与工具 Token,缓存是输入子集;未提供分项保持未知。旧图表仍按会话更新时间归属。完整文本估算单列,不代表费用。",
1141
+ "usage.records.coverage": "已扫描 {scanned}/{candidates} 个候选会话;无用量记录 {unreported},未支持逐记录来源 {unsupported}。",
1142
+ "usage.records.failed": "读取失败 {count} 个会话,当前结果不完整;刷新后重试。",
1143
+ "usage.records.total": "记录 Token",
1144
+ "usage.records.estimated": "完整文本估算 Token",
1145
+ "usage.records.cacheRead": "缓存读取",
1146
+ "usage.records.cacheWrite": "缓存写入",
1147
+ "usage.records.unknown": "未知",
1148
+ "usage.records.date": "日期 (UTC)",
1149
+ "usage.records.source": "来源",
1150
+ "usage.records.model": "模型",
1151
+ "usage.records.input": "输入",
1152
+ "usage.records.output": "输出",
1153
+ "usage.records.undated": "缺少记录时间的 Token:{tokens};不分摊至某一天。",
1135
1154
  'usage.overview': 'Usage 概览',
1136
1155
  'usage.range.aria': 'Usage 时间范围',
1137
1156
  'usage.range.7d': '近 7 天',
@@ -1863,6 +1882,102 @@ const zh = Object.freeze({
1863
1882
  'sysPrompt.hint.unsaved': '有未保存的改动',
1864
1883
  'sysPrompt.hint.twoStepSave': '点击预览查看差异,确认后保存。',
1865
1884
  'sysPrompt.toast.saved': 'System prompt 已保存',
1885
+ "evidence.title": "跨会话证据包",
1886
+ "evidence.select": "加入证据包",
1887
+ "evidence.remove": "移除",
1888
+ "evidence.goal": "交接目标",
1889
+ "evidence.generate": "生成证据包",
1890
+ "evidence.preview": "预览({count} 字符)",
1891
+ "evidence.download": "下载 Markdown",
1892
+ "evidence.memory": "材料仅存本页,刷新清空;原记录不变。",
1893
+ "evidence.scope": "仅摘录用户选定的历史材料;未发送,未验证当前版本。",
1894
+ "evidence.path": "原文路径",
1895
+ "evidence.status": "历史证据状态",
1896
+ "evidence.passed": "历史工具日志提示通过,当前版本未验",
1897
+ "evidence.failed": "历史工具日志提示失败",
1898
+ "evidence.unverified": "待核对",
1899
+ "evidence.changed": "原文已变化;更新索引后重新选择。",
1900
+ "evidence.limit": "最多选择 100 条材料。",
1901
+ "artifacts.format": "输出格式",
1902
+ "artifacts.receipt": "开发小票",
1903
+ "artifacts.relay": "多 Agent 接力包",
1904
+ "artifacts.generate.receipt": "生成开发小票",
1905
+ "artifacts.generate.relay": "生成接力包",
1906
+ "artifacts.scope": "仅基于选定历史材料,本地生成;未发送、未执行、当前版本未验收。",
1907
+ "artifacts.goal": "目标(用户填写)",
1908
+ "artifacts.note": "补充说明(用户填写,可选)",
1909
+ "artifacts.notePlaceholder": "填写改动原因、下一步或验收标准;不作为验证证据。",
1910
+ "artifacts.unspecified": "未填写,请人工补充。",
1911
+ "artifacts.checks": "历史检查记录汇总",
1912
+ "artifacts.noVerdict": "记录数量不代表任务完成或当前版本测试通过;原文摘录见下方。",
1913
+ "artifacts.sources": "选定材料与来源",
1914
+ "artifacts.executor": "第一棒:执行者",
1915
+ "artifacts.executorTask": "核对目标、原文和允许修改范围。仅按明确授权执行;目标不清或材料失效时停止。交付实际改动、检查结果、失败与未验证项,不重放历史命令。",
1916
+ "artifacts.reviewer": "第二棒:审阅者",
1917
+ "artifacts.reviewerTask": "只读核查执行者结果、原文来源与当前版本。区分事实、推论和缺证,不把已投递或自报读取当作完成。列出仍需人工验收的步骤。",
1918
+ "artifacts.uat": "人工 UAT:待执行,未验收",
1919
+ "artifacts.uatTask": "在待验版本从真实入口复测目标,记录可观察结果与失败判据。历史日志、交接或自报读取不能替代当前验收。",
1920
+
1921
+ "collections.title": "证据专题夹",
1922
+ "collections.scope": "仅显式保存名称、目标与原文引用;打开会替换临时材料篮。刷新后需手动打开,不备份原会话。",
1923
+ "collections.name": "专题名称",
1924
+ "collections.save": "保存专题",
1925
+ "collections.saveAs": "另存专题",
1926
+ "collections.remove": "移除专题",
1927
+ "collections.refresh": "刷新专题",
1928
+ "collections.empty": "暂无已保存专题",
1929
+ "collections.state.ready": "原文一致",
1930
+ "collections.state.changed": "原文已变化",
1931
+ "collections.state.unavailable": "原文不可读取",
1932
+ "stories.title": "开发故事线",
1933
+ "stories.scope": "用户显式关联,不证明会话产生提交或测试通过。仅保存本机元数据,不写 Git、不上传。",
1934
+ "stories.linked": "用户关联",
1935
+ "stories.unavailable": "会话不在当前发现候选中",
1936
+ "stories.session": "关联会话",
1937
+ "stories.choose": "选择当前项目会话",
1938
+ "stories.note": "改动原因",
1939
+ "stories.save": "保存关联",
1940
+ "stories.remove": "取消关联",
1941
+ "stories.refresh": "刷新关联",
1942
+ "features.error.collection-input-invalid": "检查专题名称、目标与选中的引用",
1943
+ "features.error.collection-not-found": "专题已移除;刷新列表",
1944
+ "features.error.collection-source-unavailable": "原文已变化或不可读取;更新索引后重新选择",
1945
+ "features.error.story-input-invalid": "检查项目、完整提交 SHA 与备注",
1946
+ "features.error.story-project-unavailable": "项目不在当前发现范围",
1947
+ "features.error.story-session-unavailable": "会话不在当前项目候选中",
1948
+ "features.error.story-not-found": "关联已移除;刷新列表",
1949
+ "features.error.project-git-commit-invalid": "提交不在当前项目最近 30 条记录中",
1950
+
1951
+ "pricing.title": "费用参考(USD)",
1952
+ "pricing.scope": "按内置价格快照的基础文本单价估算,不是账单。不含阶梯、服务层、缓存时长、工具或多模态附加费;不推断历史计费供应商。",
1953
+ "pricing.total": "参考总额",
1954
+ "pricing.subtotal": "已知行小计",
1955
+ "pricing.coverage": "已定价 {known} 行;未知 {unknown} 行;读取失败 {failed};未报告 {unreported};未适配 {unsupported}",
1956
+ "pricing.basis": "依据",
1957
+ "pricing.rates": "每百万 Token:输入 {input} / 输出 {output} / 缓存读取 {cached} / 缓存写入 {created}",
1958
+ "pricing.download": "下载价格参考 JSON",
1959
+ "pricing.reason.base-rate": "基础单价估算",
1960
+ "pricing.reason.model-unknown": "模型无价格记录",
1961
+ "pricing.reason.usage-incomplete": "Token 分项不完整",
1962
+ "pricing.reason.usage-unclassified": "存在未归类 Token",
1963
+ "pricing.reason.rate-missing": "分项单价缺失",
1964
+
1965
+ "git.title": "Git 改动关联(只读)",
1966
+ "git.scope": "仅查看当前项目仓库。按会话更新时间前后 24 小时列出提交候选,不代表因果或测试通过;不写 Git、不上传会话。",
1967
+ "git.detached": "游离 HEAD",
1968
+ "git.noHead": "暂无提交",
1969
+ "git.changes": "当前变更 {count} 个文件",
1970
+ "git.truncated": "最多展示 30 个提交与 50 个变更文件;当前列表已截断。",
1971
+ "git.candidate": "时间关联候选",
1972
+ "git.refresh": "刷新 Git",
1973
+ "git.status.ready": "已读取当前 Git 状态",
1974
+ "git.status.unborn": "仓库尚无提交",
1975
+ "git.status.not-repository": "不是 Git 仓库",
1976
+ "git.status.path-unavailable": "项目路径不可访问",
1977
+ "git.status.git-unavailable": "未找到 Git",
1978
+ "git.status.read-timeout": "读取 Git 超时",
1979
+ "git.status.read-failed": "读取 Git 失败",
1980
+
1866
1981
  });
1867
1982
 
1868
1983
  export { zh };
@@ -0,0 +1,65 @@
1
+ export const sessionCollectionsMixin = {
2
+ data() {
3
+ return { collectionsOpen: false, collections: [], collectionRevision: '', collectionId: '', collectionName: '',
4
+ collectionBusy: false, collectionError: '', collectionSequence: 0 };
5
+ },
6
+ beforeUnmount() { this.collectionSequence++; },
7
+ methods: {
8
+ async toggleCollections(event) {
9
+ if (event.target !== event.currentTarget) return;
10
+ this.collectionsOpen = event.currentTarget.open;
11
+ if (this.collectionsOpen) await this.loadEvidenceCollections();
12
+ },
13
+ async loadEvidenceCollections() {
14
+ const sequence = ++this.collectionSequence;
15
+ this.collectionBusy = true; this.collectionError = '';
16
+ try {
17
+ const report = await this.featureCall('session-collections-list');
18
+ if (sequence !== this.collectionSequence) return;
19
+ this.collections = report.items; this.collectionRevision = report.revision;
20
+ } catch (error) { if (sequence === this.collectionSequence) this.collectionError = this.featureErrorText(error); }
21
+ finally { if (sequence === this.collectionSequence) this.collectionBusy = false; }
22
+ },
23
+ async openEvidenceCollection(item) {
24
+ if (this.collectionBusy || this.evidenceBusy) return;
25
+ const sequence = ++this.collectionSequence;
26
+ this.collectionBusy = true; this.collectionError = '';
27
+ try {
28
+ const report = await this.featureCall('session-collection-open', { id: item.id });
29
+ if (sequence !== this.collectionSequence) return;
30
+ this.evidenceSequence++; this.evidencePack = ''; this.evidenceError = '';
31
+ this.evidenceSelections = report.items; this.evidenceGoal = report.item.goal; this.evidenceNote = '';
32
+ this.collectionId = report.item.id; this.collectionName = report.item.name; this.collectionRevision = report.revision;
33
+ } catch (error) { if (sequence === this.collectionSequence) this.collectionError = this.featureErrorText(error); }
34
+ finally { if (sequence === this.collectionSequence) this.collectionBusy = false; }
35
+ },
36
+ async saveEvidenceCollection(asNew = false) {
37
+ if (this.collectionBusy || this.evidenceBusy || !this.evidenceSelections.length) return;
38
+ const sequence = ++this.collectionSequence;
39
+ this.collectionBusy = true; this.collectionError = '';
40
+ const references = this.evidenceSelections.map(item => ({ nodeId: item.nodeId, textHash: item.textHash,
41
+ session: { source: item.session.source, sessionId: item.session.sessionId || '', filePath: item.session.filePath || '',
42
+ cwd: item.session.cwd || '', title: item.session.title || '' } }));
43
+ try {
44
+ const report = await this.featureCall('session-collection-save', { id: asNew ? '' : this.collectionId,
45
+ name: this.collectionName, goal: this.evidenceGoal, references, revision: this.collectionRevision });
46
+ if (sequence !== this.collectionSequence) return;
47
+ this.collections = report.items; this.collectionRevision = report.revision;
48
+ this.collectionId = report.item.id; this.collectionName = report.item.name; this.collectionsOpen = true;
49
+ } catch (error) { if (sequence === this.collectionSequence) this.collectionError = this.featureErrorText(error); }
50
+ finally { if (sequence === this.collectionSequence) this.collectionBusy = false; }
51
+ },
52
+ async removeEvidenceCollection(item) {
53
+ if (this.collectionBusy) return;
54
+ const sequence = ++this.collectionSequence;
55
+ this.collectionBusy = true; this.collectionError = '';
56
+ try {
57
+ const report = await this.featureCall('session-collection-remove', { id: item.id, revision: this.collectionRevision });
58
+ if (sequence !== this.collectionSequence) return;
59
+ this.collections = report.items; this.collectionRevision = report.revision;
60
+ if (this.collectionId === item.id) { this.collectionId = ''; this.collectionName = ''; }
61
+ } catch (error) { if (sequence === this.collectionSequence) this.collectionError = this.featureErrorText(error); }
62
+ finally { if (sequence === this.collectionSequence) this.collectionBusy = false; }
63
+ }
64
+ }
65
+ };
@@ -0,0 +1,81 @@
1
+ import { sessionCollectionsMixin } from './session-collections.mjs';
2
+ import { renderSessionArtifact, sessionArtifactFilename } from '../logic.session-artifacts.mjs';
3
+ const MAX_SELECTIONS = 100;
4
+ const selectionKey = result => JSON.stringify([result.session.source, result.session.sessionId, result.session.filePath, result.nodeId]);
5
+
6
+ export const sessionEvidenceMixin = {
7
+ mixins: [sessionCollectionsMixin],
8
+ data() {
9
+ return { evidenceSelections: [], evidenceGoal: '', evidencePack: '', evidenceBusy: false, evidenceError: '', evidenceSequence: 0,
10
+ evidenceFormat: 'evidence', evidenceNote: '', evidenceGeneratedFormat: 'evidence' };
11
+ },
12
+ beforeUnmount() { this.evidenceSequence++; },
13
+ watch: {
14
+ evidenceGoal() { this.invalidateEvidenceArtifact(); },
15
+ evidenceFormat() { this.invalidateEvidenceArtifact(); },
16
+ evidenceNote() { this.invalidateEvidenceArtifact(); }
17
+ },
18
+ methods: {
19
+ evidenceKey: selectionKey,
20
+ invalidateEvidenceArtifact() { this.evidenceSequence++; this.evidencePack = ''; },
21
+ isEvidenceSelected(result) { return this.evidenceSelections.some(item => selectionKey(item) === selectionKey(result)); },
22
+ toggleEvidence(result) {
23
+ this.evidenceSequence++;
24
+ this.evidencePack = ''; this.evidenceError = '';
25
+ const key = selectionKey(result);
26
+ if (this.isEvidenceSelected(result)) {
27
+ this.evidenceSelections = this.evidenceSelections.filter(item => selectionKey(item) !== key);
28
+ return;
29
+ }
30
+ if (this.evidenceSelections.length >= MAX_SELECTIONS) { this.evidenceError = this.t('evidence.limit'); return; }
31
+ this.evidenceSelections = [...this.evidenceSelections, { ...result, session: { ...result.session } }];
32
+ },
33
+ async generateEvidencePack() {
34
+ if (this.evidenceBusy || !this.evidenceSelections.length) return;
35
+ const sequence = ++this.evidenceSequence;
36
+ const format = this.evidenceFormat;
37
+ const goal = this.evidenceGoal;
38
+ const note = this.evidenceNote;
39
+ const selections = [...this.evidenceSelections];
40
+ const groups = new Map();
41
+ for (const item of selections) {
42
+ const key = JSON.stringify([item.session.source, item.session.sessionId, item.session.filePath]);
43
+ if (!groups.has(key)) groups.set(key, []);
44
+ groups.get(key).push(item);
45
+ }
46
+ this.evidenceBusy = true; this.evidenceError = ''; this.evidencePack = '';
47
+ try {
48
+ const evidence = new Map();
49
+ for (const group of groups.values()) {
50
+ const draft = await this.featureCall('session-handoff-draft', { ...group[0].session, goal,
51
+ selections: group.map(item => item.nodeId) });
52
+ if (sequence !== this.evidenceSequence) return;
53
+ for (const item of group) {
54
+ const found = draft.evidence.find(entry => entry.nodeId === item.nodeId);
55
+ if (!found || found.textHash !== item.textHash) throw new Error(this.t('evidence.changed'));
56
+ evidence.set(selectionKey(item), found);
57
+ }
58
+ }
59
+ if (format !== 'evidence') {
60
+ this.evidencePack = renderSessionArtifact({ format, goal, note, selections, evidence, translate: key => this.t(key) });
61
+ } else {
62
+ const lines = [`# ${this.t('evidence.title')}`, '', this.t('evidence.scope'), '', goal.trim()];
63
+ for (const [index, item] of selections.entries()) {
64
+ const found = evidence.get(selectionKey(item));
65
+ lines.push('', `## ${index + 1}. ${item.session.title || item.session.sessionId}`, '',
66
+ `${item.session.source} · ${item.session.sessionId} · ${found.nodeId}`,
67
+ `${this.t('evidence.path')}: ${JSON.stringify(item.session.filePath || item.session.cwd || '')}`,
68
+ `SHA-256: ${found.textHash}`, `${this.t('evidence.status')}: ${this.t('evidence.' + found.status)}`, '',
69
+ ...found.excerpt.split('\n').map(line => '> ' + line));
70
+ }
71
+ this.evidencePack = lines.join('\n').trim() + '\n';
72
+ }
73
+ this.evidenceGeneratedFormat = format;
74
+ } catch (error) { if (sequence === this.evidenceSequence) this.evidenceError = error.message; }
75
+ finally { this.evidenceBusy = false; }
76
+ },
77
+ downloadEvidencePack() {
78
+ if (this.evidencePack) this.downloadTextFile(sessionArtifactFilename(this.evidenceGeneratedFormat), this.evidencePack);
79
+ }
80
+ }
81
+ };
@@ -1,4 +1,7 @@
1
1
  import { api } from './api.mjs';
2
+ import { sessionEvidenceMixin } from './session-evidence.mjs';
3
+ import { usagePricingMixin } from './usage-pricing.mjs';
4
+ import { sessionGitMixin } from './session-git.mjs';
2
5
  import { contextWindowReference } from '../logic.context-window.mjs';
3
6
  const SessionMessageActions = {
4
7
  props: { message: { type: Object, required: true } },
@@ -20,6 +23,7 @@ const SessionMessageActions = {
20
23
  }
21
24
  };
22
25
  export const sessionFeaturesMixin = {
26
+ mixins: [sessionEvidenceMixin, usagePricingMixin, sessionGitMixin],
23
27
  components: { SessionMessageActions },
24
28
  data() {
25
29
  return { featureView: '', featureBusy: false, featureError: '', bookmarks: [], bookmarkRevision: '',
@@ -29,6 +33,16 @@ export const sessionFeaturesMixin = {
29
33
  diagnosticsTargets: [], diagnosticsSelected: [], diagnosticsTimer: null };
30
34
  },
31
35
  computed: {
36
+ indexCatalogTime() {
37
+ const timestamp = this.indexReport?.updatedAt;
38
+ const parsed = typeof timestamp === 'string' ? Date.parse(timestamp) : NaN;
39
+ return Number.isFinite(parsed) ? new Date(parsed).toISOString() : this.t('features.indexUnknown');
40
+ },
41
+ indexSourceCoverage() {
42
+ const coverage = this.indexReport?.coverage;
43
+ const source = this.sessionFilterSource || 'all';
44
+ return Array.isArray(coverage) ? coverage.filter(entry => source === 'all' || entry.source === source) : [];
45
+ },
32
46
  contextPreferenceKey() {
33
47
  return `${this.handoffSessionKey}::${this.contextSelectedModel || this.sessionContextHealth?.models?.[0] || 'manual'}`;
34
48
  },
@@ -46,7 +60,7 @@ export const sessionFeaturesMixin = {
46
60
  void this.loadContextPreferences();
47
61
  },
48
62
  contextSelectedModel() { if (this.sessionContextHealth) void this.loadContextPreferences(); },
49
- handoffSessionKey() { this.contextWindowInput = ''; this.contextSelectedModel = ''; this.selectedContextIds = []; this.handoffDraftEvidence = []; this.handoffUnverified = []; this.featureFocus = null; this.featureRequestSeq++; this.featureBusy = false; }
63
+ handoffSessionKey() { this.contextWindowInput = ''; this.contextSelectedModel = ''; this.selectedContextIds = []; this.handoffDraftEvidence = []; this.handoffUnverified = []; this.featureFocus = null; this.featureBusy = false; }
50
64
  },
51
65
  methods: {
52
66
  featureErrorText(error) {
@@ -0,0 +1,39 @@
1
+ import { sessionStoriesMixin } from './session-stories.mjs';
2
+ export const sessionGitMixin = {
3
+ mixins: [sessionStoriesMixin],
4
+ data() { return { projectGitOpen: false, projectGit: null, projectGitCommit: null, projectGitBusy: false, projectGitError: '', projectGitSequence: 0 }; },
5
+ beforeUnmount() { this.projectGitSequence++; },
6
+ watch: {
7
+ projectSelected() {
8
+ this.projectGitSequence++; this.projectGit = null; this.projectGitCommit = null; this.projectGitError = ''; this.projectGitBusy = false;
9
+ if (!this.projectSelected) this.projectGitOpen = false;
10
+ else if (this.projectGitOpen) void this.loadProjectGit();
11
+ }
12
+ },
13
+ methods: {
14
+ toggleProjectGit(event) {
15
+ if (event.target !== event.currentTarget) return;
16
+ this.projectGitOpen = event.currentTarget.open;
17
+ if (this.projectGitOpen && !this.projectGit) return this.loadProjectGit();
18
+ },
19
+ async loadProjectGit() {
20
+ if (!this.projectSelected || this.projectGitBusy) return;
21
+ const sequence = ++this.projectGitSequence;
22
+ this.projectGitBusy = true; this.projectGitError = ''; this.projectGitCommit = null;
23
+ try {
24
+ const report = await this.featureCall('session-project-git', { project: this.projectSelected });
25
+ if (sequence === this.projectGitSequence) this.projectGit = report;
26
+ } catch (error) { if (sequence === this.projectGitSequence) this.projectGitError = error.message; }
27
+ finally { if (sequence === this.projectGitSequence) this.projectGitBusy = false; }
28
+ },
29
+ async loadProjectGitCommit(sha) {
30
+ const sequence = ++this.projectGitSequence;
31
+ this.projectGitBusy = true; this.projectGitError = ''; this.projectGitCommit = null;
32
+ try {
33
+ const report = await this.featureCall('session-project-git-commit', { project: this.projectSelected, sha });
34
+ if (sequence === this.projectGitSequence) this.projectGitCommit = report;
35
+ } catch (error) { if (sequence === this.projectGitSequence) this.projectGitError = error.message; }
36
+ finally { if (sequence === this.projectGitSequence) this.projectGitBusy = false; }
37
+ }
38
+ }
39
+ };
@@ -0,0 +1,64 @@
1
+ export const sessionStoriesMixin = {
2
+ data() {
3
+ return { stories: [], storySessions: [], storyRevision: '', storySession: '', storyNote: '', storyBusy: false,
4
+ storyError: '', storySequence: 0 };
5
+ },
6
+ computed: {
7
+ commitStories() { return this.stories.filter(item => item.sha === this.projectGitCommit?.sha); }
8
+ },
9
+ beforeUnmount() { this.storySequence++; },
10
+ watch: {
11
+ projectSelected() {
12
+ this.storySequence++; this.stories = []; this.storySessions = []; this.storySession = ''; this.storyNote = '';
13
+ this.storyError = ''; this.storyBusy = false; this.storyRevision = '';
14
+ },
15
+ projectGitCommit(commit) {
16
+ this.storySequence++; this.storySession = ''; this.storyNote = ''; this.storyError = ''; this.storyBusy = false;
17
+ if (commit) void this.loadProjectStories();
18
+ },
19
+ storySession(key) {
20
+ const existing = this.commitStories.find(item => this.storySessionKey(item.session) === key);
21
+ this.storyNote = existing?.note || '';
22
+ }
23
+ },
24
+ methods: {
25
+ storySessionKey(session) { return JSON.stringify([session.source, session.sessionId, session.filePath]); },
26
+ async loadProjectStories() {
27
+ if (!this.projectSelected || !this.projectGitCommit) return;
28
+ const sequence = ++this.storySequence;
29
+ this.storyBusy = true; this.storyError = '';
30
+ try {
31
+ const report = await this.featureCall('session-stories-list', { project: this.projectSelected });
32
+ if (sequence !== this.storySequence) return;
33
+ this.stories = report.items; this.storySessions = report.sessions; this.storyRevision = report.revision;
34
+ } catch (error) { if (sequence === this.storySequence) this.storyError = this.featureErrorText(error); }
35
+ finally { if (sequence === this.storySequence) this.storyBusy = false; }
36
+ },
37
+ async saveProjectStory() {
38
+ if (this.storyBusy || !this.projectGitCommit) return;
39
+ const session = this.storySessions.find(item => this.storySessionKey(item) === this.storySession);
40
+ if (!session) return;
41
+ const sequence = ++this.storySequence;
42
+ this.storyBusy = true; this.storyError = '';
43
+ try {
44
+ const report = await this.featureCall('session-story-save', { project: this.projectSelected,
45
+ sha: this.projectGitCommit.sha, session, note: this.storyNote, revision: this.storyRevision });
46
+ if (sequence !== this.storySequence) return;
47
+ this.stories = report.items; this.storySessions = report.sessions; this.storyRevision = report.revision;
48
+ } catch (error) { if (sequence === this.storySequence) this.storyError = this.featureErrorText(error); }
49
+ finally { if (sequence === this.storySequence) this.storyBusy = false; }
50
+ },
51
+ async removeProjectStory(item) {
52
+ if (this.storyBusy) return;
53
+ const sequence = ++this.storySequence;
54
+ this.storyBusy = true; this.storyError = '';
55
+ try {
56
+ const report = await this.featureCall('session-story-remove', { project: this.projectSelected, id: item.id, revision: this.storyRevision });
57
+ if (sequence !== this.storySequence) return;
58
+ this.stories = report.items; this.storySessions = report.sessions; this.storyRevision = report.revision;
59
+ if (this.storySession === this.storySessionKey(item.session)) { this.storySession = ''; this.storyNote = ''; }
60
+ } catch (error) { if (sequence === this.storySequence) this.storyError = this.featureErrorText(error); }
61
+ finally { if (sequence === this.storySequence) this.storyBusy = false; }
62
+ }
63
+ }
64
+ };
@@ -0,0 +1,30 @@
1
+ export const usagePricingMixin = {
2
+ data() { return { usagePricingOpen: false, usagePricing: null, usagePricingBusy: false, usagePricingError: '', usagePricingSequence: 0 }; },
3
+ beforeUnmount() { this.usagePricingSequence++; },
4
+ watch: { sessionsUsageTimeRange() { if (this.usagePricingOpen) void this.loadUsagePricing(); } },
5
+ methods: {
6
+ toggleUsagePricing(event) {
7
+ if (event.target !== event.currentTarget) return;
8
+ this.usagePricingOpen = event.currentTarget.open;
9
+ if (this.usagePricingOpen) return this.loadUsagePricing();
10
+ },
11
+ async loadUsagePricing() {
12
+ const sequence = ++this.usagePricingSequence;
13
+ const range = this.sessionsUsageTimeRange;
14
+ const today = new Date();
15
+ const from = new Date(Date.UTC(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate() - (range === '30d' ? 29 : 6)));
16
+ this.usagePricingBusy = true; this.usagePricingError = ''; this.usagePricing = null;
17
+ try {
18
+ const report = await this.featureCall('session-usage-pricing', { source: 'all', limit: range === 'all' ? 2000 : (range === '30d' ? 1200 : 600),
19
+ ...(range === 'all' ? {} : { from: from.toISOString().slice(0, 10), to: today.toISOString().slice(0, 10) }) });
20
+ if (sequence === this.usagePricingSequence) this.usagePricing = report;
21
+ } catch (error) { if (sequence === this.usagePricingSequence) this.usagePricingError = error.message; }
22
+ finally { if (sequence === this.usagePricingSequence) this.usagePricingBusy = false; }
23
+ },
24
+ formatPriceUsd(value) { return value === null ? this.t('usage.records.unknown') : '$' + value.toFixed(6); },
25
+ formatTokenRate(value) { return typeof value === 'number' ? (value * 1000000).toLocaleString('en-US', { maximumFractionDigits: 6 }) : this.t('usage.records.unknown'); },
26
+ downloadUsagePricing() {
27
+ if (this.usagePricing) this.downloadTextFile('codexmate-price-reference.json', JSON.stringify(this.usagePricing, null, 2), 'application/json;charset=utf-8');
28
+ }
29
+ }
30
+ };
@@ -1,5 +1,5 @@
1
1
  <!-- 加载状态 -->
2
- <div v-if="loading && mainTab !== 'usage'" class="state-message app-loading-state">
2
+ <div v-if="loading && mainTab !== 'usage' && mainTab !== 'prompts'" class="state-message app-loading-state">
3
3
  {{ t('app.loadingConfig') }}
4
4
  </div>
5
5