codexmate 0.1.36 → 0.1.37
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/cli/skills.js +103 -4
- package/cli.js +4 -1
- package/package.json +1 -1
- package/web-ui/app.js +12 -0
- package/web-ui/modules/app.computed.main-tabs.mjs +12 -0
- package/web-ui/modules/app.methods.agents.mjs +0 -3
- package/web-ui/modules/app.methods.prompts-editor.mjs +30 -6
- package/web-ui/modules/app.methods.startup-claude.mjs +10 -5
- package/web-ui/modules/i18n/locales/en.mjs +18 -0
- package/web-ui/modules/i18n/locales/ja.mjs +18 -0
- package/web-ui/modules/i18n/locales/vi.mjs +18 -0
- package/web-ui/modules/i18n/locales/zh-tw.mjs +18 -0
- package/web-ui/modules/i18n/locales/zh.mjs +18 -0
- package/web-ui/modules/session-features.mjs +25 -1
- package/web-ui/modules/skills.methods.mjs +61 -16
- package/web-ui/partials/index/layout-header.html +36 -37
- package/web-ui/partials/index/panel-market.html +10 -3
- package/web-ui/partials/index/panel-prompts.html +40 -20
- package/web-ui/partials/index/session-features.html +24 -7
- package/web-ui/res/web-ui-render.precompiled.js +407 -160
- package/web-ui/styles/layout-shell.css +41 -70
- package/web-ui/styles/prompts-editor.css +127 -27
- package/web-ui/styles/session-features.css +12 -1
- package/web-ui/styles/system-prompt.css +9 -4
- package/web-ui/styles/theme-dark.css +0 -18
- package/web-ui/styles/theme-ocean.css +0 -14
- package/web-ui/styles/theme-violet.css +0 -23
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:
|
|
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,
|
|
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.js
CHANGED
|
@@ -14389,6 +14389,8 @@ async function handleImportSkillsZipUpload(req, res, options = {}) {
|
|
|
14389
14389
|
writeJsonResponse(res, 400, { error: '目标宿主不支持' });
|
|
14390
14390
|
return;
|
|
14391
14391
|
}
|
|
14392
|
+
const restoreBackup = !forcedTargetApp
|
|
14393
|
+
&& new URL(req.url || '/', 'http://localhost').searchParams.get('mode') === 'backup';
|
|
14392
14394
|
const fileName = resolveUploadFileNameFromRequest(req, `${targetApp}-skills.zip`);
|
|
14393
14395
|
const upload = await writeUploadZipStream(
|
|
14394
14396
|
req,
|
|
@@ -14399,7 +14401,8 @@ async function handleImportSkillsZipUpload(req, res, options = {}) {
|
|
|
14399
14401
|
const result = await importSkillsFromZipFile(upload.zipPath, {
|
|
14400
14402
|
tempDir: upload.tempDir,
|
|
14401
14403
|
fallbackName: fileName,
|
|
14402
|
-
targetApp
|
|
14404
|
+
targetApp,
|
|
14405
|
+
...(restoreBackup ? { restoreBackup: true } : {})
|
|
14403
14406
|
});
|
|
14404
14407
|
writeJsonResponse(res, 200, result || {});
|
|
14405
14408
|
} catch (e) {
|
package/package.json
CHANGED
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,
|
|
@@ -893,6 +896,15 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
893
896
|
},
|
|
894
897
|
|
|
895
898
|
watch: {
|
|
899
|
+
mainPanelTabKey: {
|
|
900
|
+
flush: 'post',
|
|
901
|
+
handler() {
|
|
902
|
+
const root = document.getElementById('app');
|
|
903
|
+
root?.querySelector('.main-panel')?.scrollTo({ top: 0, left: 0, behavior: 'instant' });
|
|
904
|
+
// The outer app container owns vertical scroll in the narrow touch layout.
|
|
905
|
+
if (root?.scrollTop) root.scrollTo({ top: 0, behavior: 'instant' });
|
|
906
|
+
}
|
|
907
|
+
},
|
|
896
908
|
mainTab(newTab) {
|
|
897
909
|
if (typeof this.isMainTabDisabled === 'function' && this.isMainTabDisabled(newTab)) {
|
|
898
910
|
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() {
|
|
@@ -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
|
-
|
|
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;
|
|
@@ -67,11 +67,16 @@ export function createStartupClaudeMethods(options = {}) {
|
|
|
67
67
|
this.currentModels = statusRes.currentModels && typeof statusRes.currentModels === 'object'
|
|
68
68
|
? { ...statusRes.currentModels }
|
|
69
69
|
: {};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
// config.toml is the active selection; the dictionary only remembers choices when switching providers.
|
|
71
|
+
const configuredModel = typeof statusRes.model === 'string' ? statusRes.model.trim() : '';
|
|
72
|
+
this.currentModel = configuredModel === '未设置' ? '' : configuredModel;
|
|
73
|
+
if (this.currentProvider && this.currentProvider !== '未设置') {
|
|
74
|
+
if (this.currentModel) {
|
|
75
|
+
this.currentModels[this.currentProvider] = this.currentModel;
|
|
76
|
+
} else {
|
|
77
|
+
delete this.currentModels[this.currentProvider];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
75
80
|
try {
|
|
76
81
|
const installRes = await withRequestDeadline(signal => api('install-status', {}, { signal }), { timeoutMs: Math.max(0, Math.min(1200, timeLeftMs())) });
|
|
77
82
|
if (installRes && !installRes.error) {
|
|
@@ -135,6 +135,11 @@ const en = Object.freeze({
|
|
|
135
135
|
"features.indexFailures": "{count} read failures; these records are not covered",
|
|
136
136
|
"features.coverage": "Searched {scanned}/{total} indexed sessions",
|
|
137
137
|
"features.partial": "Partial coverage; at most 100 matches are shown",
|
|
138
|
+
"features.resultView": "Result view",
|
|
139
|
+
"features.byMessage": "By message",
|
|
140
|
+
"features.bySession": "By session",
|
|
141
|
+
"features.returnedMatches": "{count} returned matches",
|
|
142
|
+
"features.groupedTruncated": "Result limit reached; groups count only returned matches.",
|
|
138
143
|
"features.context": "Surrounding context",
|
|
139
144
|
"features.generateDraft": "Generate handoff draft ({count})",
|
|
140
145
|
"features.draftReview": "Draft not sent. Review evidence and edit next steps before sending.",
|
|
@@ -555,6 +560,8 @@ const en = Object.freeze({
|
|
|
555
560
|
'prompts.editor.preview': 'Preview',
|
|
556
561
|
'prompts.editor.previewUnavailable': 'Preview components missing (marked / DOMPurify), please refresh the page',
|
|
557
562
|
'prompts.editor.previewEmpty': 'Nothing to preview yet',
|
|
563
|
+
'prompts.editor.outline': 'Document outline',
|
|
564
|
+
'prompts.editor.outlineEmpty': 'No headings',
|
|
558
565
|
'prompts.editor.changeAxis': 'Change navigation axis',
|
|
559
566
|
'prompts.editor.changeAxisTick': 'Line {line} (+{added} / -{removed})',
|
|
560
567
|
'prompts.tokenCount.hint': '~{count} tokens',
|
|
@@ -1645,6 +1652,17 @@ const en = Object.freeze({
|
|
|
1645
1652
|
|
|
1646
1653
|
'market.backup.action': 'Back up current target',
|
|
1647
1654
|
'market.backup.running': 'Backing up...',
|
|
1655
|
+
'market.backup.export': 'Export backup',
|
|
1656
|
+
'market.backup.import': 'Import backup',
|
|
1657
|
+
'market.backup.targetChanged': 'Target changed. Select the backup again.',
|
|
1658
|
+
'market.backup.tooLarge': 'The backup exceeds the 20 MiB import limit.',
|
|
1659
|
+
'market.backup.invalid': 'Select a valid v1 Skills backup.',
|
|
1660
|
+
'market.backup.importFailed': 'Could not import the backup.',
|
|
1661
|
+
'market.backup.result': 'Restored: {restored}. Skipped: {skipped}. Failed: {failed}.',
|
|
1662
|
+
'market.backup.exportFailed': 'Could not export the backup.',
|
|
1663
|
+
'market.backup.exportPartial': 'Exported: {count}. Failed: {failed}.',
|
|
1664
|
+
'market.backup.exportResult': 'Exported {count} entries.',
|
|
1665
|
+
'market.backup.exportLimited': 'Keep this ZIP for offline recovery; it cannot be imported through the web page.',
|
|
1648
1666
|
'market.export.action': 'Export selected',
|
|
1649
1667
|
'market.export.running': 'Exporting...',
|
|
1650
1668
|
'market.selection.all': 'Select all',
|
|
@@ -135,6 +135,11 @@ const ja = Object.freeze({
|
|
|
135
135
|
"features.indexFailures": "{count} 件の読み込み失敗。該当記録は対象外です",
|
|
136
136
|
"features.coverage": "登録済みセッション {scanned}/{total} 件を検索",
|
|
137
137
|
"features.partial": "対象範囲は一部のみ。最大 100 件を表示",
|
|
138
|
+
"features.resultView": "結果の表示形式",
|
|
139
|
+
"features.byMessage": "メッセージ別",
|
|
140
|
+
"features.bySession": "セッション別",
|
|
141
|
+
"features.returnedMatches": "表示対象 {count} 件",
|
|
142
|
+
"features.groupedTruncated": "結果が上限に達しました。グループの件数は取得済みの結果のみを数えます。",
|
|
138
143
|
"features.context": "前後の文脈",
|
|
139
144
|
"features.generateDraft": "引き継ぎ下書きを作成({count} 件)",
|
|
140
145
|
"features.draftReview": "下書きは未送信です。根拠を確認し、次の手順を編集してください。",
|
|
@@ -556,6 +561,8 @@ const ja = Object.freeze({
|
|
|
556
561
|
'prompts.editor.preview': 'プレビュー',
|
|
557
562
|
'prompts.editor.previewUnavailable': 'プレビュー用コンポーネント(marked / DOMPurify)が読み込まれていません。ページを再読み込みしてください',
|
|
558
563
|
'prompts.editor.previewEmpty': 'プレビューする内容がありません',
|
|
564
|
+
'prompts.editor.outline': 'ドキュメントの目次',
|
|
565
|
+
'prompts.editor.outlineEmpty': '見出しがありません',
|
|
559
566
|
'prompts.editor.changeAxis': '変更ナビゲーション軸',
|
|
560
567
|
'prompts.editor.changeAxisTick': '{line} 行目(+{added} / -{removed})',
|
|
561
568
|
'prompts.tokenCount.hint': '約 {count} トークン',
|
|
@@ -1647,6 +1654,17 @@ const ja = Object.freeze({
|
|
|
1647
1654
|
|
|
1648
1655
|
'market.backup.action': '現在のターゲットをバックアップ',
|
|
1649
1656
|
'market.backup.running': 'バックアップ中...',
|
|
1657
|
+
'market.backup.export': 'バックアップをエクスポート',
|
|
1658
|
+
'market.backup.import': 'バックアップをインポート',
|
|
1659
|
+
'market.backup.targetChanged': 'ターゲットが変わりました。バックアップを選び直してください。',
|
|
1660
|
+
'market.backup.tooLarge': 'バックアップが 20 MiB を超えているため、インポートできません。',
|
|
1661
|
+
'market.backup.invalid': '有効な v1 Skills バックアップを選択してください。',
|
|
1662
|
+
'market.backup.importFailed': 'バックアップのインポートに失敗しました。',
|
|
1663
|
+
'market.backup.result': '復元 {restored} 件、スキップ {skipped} 件、失敗 {failed} 件。',
|
|
1664
|
+
'market.backup.exportFailed': 'バックアップのエクスポートに失敗しました。',
|
|
1665
|
+
'market.backup.exportPartial': 'エクスポート {count} 件、失敗 {failed} 件。',
|
|
1666
|
+
'market.backup.exportResult': '{count} 件をエクスポートしました。',
|
|
1667
|
+
'market.backup.exportLimited': 'この ZIP はオフライン用です。Web ページからはインポートできません。',
|
|
1650
1668
|
'market.export.action': '選択をエクスポート',
|
|
1651
1669
|
'market.export.running': 'エクスポート中...',
|
|
1652
1670
|
'market.selection.all': 'すべて選択',
|
|
@@ -135,6 +135,11 @@ const vi = Object.freeze({
|
|
|
135
135
|
"features.indexFailures": "Không đọc được {count} mục; kết quả không bao gồm các mục này",
|
|
136
136
|
"features.coverage": "Đã tìm {scanned}/{total} phiên được lập chỉ mục",
|
|
137
137
|
"features.partial": "Kết quả chưa bao phủ toàn bộ phạm vi; hiển thị tối đa 100 kết quả",
|
|
138
|
+
"features.resultView": "Chế độ xem kết quả",
|
|
139
|
+
"features.byMessage": "Theo tin nhắn",
|
|
140
|
+
"features.bySession": "Theo phiên",
|
|
141
|
+
"features.returnedMatches": "{count} kết quả trả về",
|
|
142
|
+
"features.groupedTruncated": "Đã đạt giới hạn; nhóm chỉ đếm các kết quả được trả về.",
|
|
138
143
|
"features.context": "Ngữ cảnh xung quanh",
|
|
139
144
|
"features.generateDraft": "Tạo bản nháp bàn giao ({count})",
|
|
140
145
|
"features.draftReview": "Bản nháp chưa được gửi. Kiểm tra bằng chứng và sửa bước tiếp theo trước khi gửi.",
|
|
@@ -602,6 +607,8 @@ const vi = Object.freeze({
|
|
|
602
607
|
'prompts.editor.preview': 'Xem trước',
|
|
603
608
|
'prompts.editor.previewUnavailable': 'Thư viện xem trước (marked / DOMPurify) chưa được tải, hãy tải lại trang',
|
|
604
609
|
'prompts.editor.previewEmpty': 'Chưa có nội dung để xem trước',
|
|
610
|
+
'prompts.editor.outline': 'Mục lục tài liệu',
|
|
611
|
+
'prompts.editor.outlineEmpty': 'Không có tiêu đề',
|
|
605
612
|
'prompts.editor.changeAxis': 'Trục điều hướng thay đổi',
|
|
606
613
|
'prompts.editor.changeAxisTick': 'Dòng {line} (+{added} / -{removed})',
|
|
607
614
|
'prompts.tokenCount.hint': '~{count} token',
|
|
@@ -1635,6 +1642,17 @@ const vi = Object.freeze({
|
|
|
1635
1642
|
'market.root.fallback': 'Đường dẫn mặc định',
|
|
1636
1643
|
'market.backup.action': 'Sao lưu mục tiêu hiện tại',
|
|
1637
1644
|
'market.backup.running': 'Đang sao lưu...',
|
|
1645
|
+
'market.backup.export': 'Xuất bản sao lưu',
|
|
1646
|
+
'market.backup.import': 'Nhập bản sao lưu',
|
|
1647
|
+
'market.backup.targetChanged': 'Đích đã thay đổi. Hãy chọn lại bản sao lưu.',
|
|
1648
|
+
'market.backup.tooLarge': 'Bản sao lưu vượt giới hạn nhập 20 MiB.',
|
|
1649
|
+
'market.backup.invalid': 'Hãy chọn bản sao lưu Skills v1 hợp lệ.',
|
|
1650
|
+
'market.backup.importFailed': 'Không thể nhập bản sao lưu.',
|
|
1651
|
+
'market.backup.result': 'Đã khôi phục: {restored}. Bỏ qua: {skipped}. Thất bại: {failed}.',
|
|
1652
|
+
'market.backup.exportFailed': 'Không thể xuất bản sao lưu.',
|
|
1653
|
+
'market.backup.exportPartial': 'Đã xuất: {count}. Thất bại: {failed}.',
|
|
1654
|
+
'market.backup.exportResult': 'Đã xuất {count} mục.',
|
|
1655
|
+
'market.backup.exportLimited': 'Giữ tệp ZIP này để khôi phục ngoại tuyến; không thể nhập qua trang web.',
|
|
1638
1656
|
'market.export.action': 'Xuất đã chọn',
|
|
1639
1657
|
'market.export.running': 'Đang xuất...',
|
|
1640
1658
|
'market.selection.all': 'Chọn tất cả',
|
|
@@ -135,6 +135,11 @@ const zhTw = Object.freeze({
|
|
|
135
135
|
"features.indexFailures": "{count} 項讀取失敗;結果未涵蓋這些記錄",
|
|
136
136
|
"features.coverage": "已查 {scanned}/{total} 個已索引會話",
|
|
137
137
|
"features.partial": "結果未完整涵蓋目前範圍;最多顯示 100 條命中",
|
|
138
|
+
"features.resultView": "結果檢視",
|
|
139
|
+
"features.byMessage": "按訊息",
|
|
140
|
+
"features.bySession": "按會話",
|
|
141
|
+
"features.returnedMatches": "已傳回 {count} 筆命中",
|
|
142
|
+
"features.groupedTruncated": "已達結果上限;會話分組只統計已傳回的命中。",
|
|
138
143
|
"features.context": "前後文",
|
|
139
144
|
"features.generateDraft": "產生交接草稿({count} 條)",
|
|
140
145
|
"features.draftReview": "草稿未傳送;先核對證據,再填寫或修改後續步驟。",
|
|
@@ -555,6 +560,8 @@ const zhTw = Object.freeze({
|
|
|
555
560
|
'prompts.editor.preview': '預覽',
|
|
556
561
|
'prompts.editor.previewUnavailable': '預覽元件未載入(marked / DOMPurify 缺失),請重新整理頁面',
|
|
557
562
|
'prompts.editor.previewEmpty': '尚無內容可預覽',
|
|
563
|
+
'prompts.editor.outline': '文件大綱',
|
|
564
|
+
'prompts.editor.outlineEmpty': '暫無標題',
|
|
558
565
|
'prompts.editor.changeAxis': '改動導覽軸',
|
|
559
566
|
'prompts.editor.changeAxisTick': '第 {line} 行(+{added} / -{removed})',
|
|
560
567
|
'prompts.tokenCount.hint': '約 {count} tokens',
|
|
@@ -1643,6 +1650,17 @@ const zhTw = Object.freeze({
|
|
|
1643
1650
|
|
|
1644
1651
|
'market.backup.action': '備份目前目標',
|
|
1645
1652
|
'market.backup.running': '備份中...',
|
|
1653
|
+
'market.backup.export': '匯出備份',
|
|
1654
|
+
'market.backup.import': '匯入備份',
|
|
1655
|
+
'market.backup.targetChanged': '目標已切換,請重新選擇備份。',
|
|
1656
|
+
'market.backup.tooLarge': '備份超過 20 MiB,無法匯入。',
|
|
1657
|
+
'market.backup.invalid': '請選擇有效的 v1 Skills 備份。',
|
|
1658
|
+
'market.backup.importFailed': '匯入備份失敗。',
|
|
1659
|
+
'market.backup.result': '已還原 {restored} 項,略過 {skipped} 項,失敗 {failed} 項。',
|
|
1660
|
+
'market.backup.exportFailed': '匯出備份失敗。',
|
|
1661
|
+
'market.backup.exportPartial': '已匯出 {count} 項,失敗 {failed} 項。',
|
|
1662
|
+
'market.backup.exportResult': '已匯出 {count} 項。',
|
|
1663
|
+
'market.backup.exportLimited': '此 ZIP 可保留作離線備份,無法透過網頁匯入。',
|
|
1646
1664
|
'market.export.action': '匯出選中',
|
|
1647
1665
|
'market.export.running': '匯出中...',
|
|
1648
1666
|
'market.selection.all': '全選',
|
|
@@ -135,6 +135,11 @@ const zh = Object.freeze({
|
|
|
135
135
|
"features.indexFailures": "{count} 项读取失败;结果未覆盖这些记录",
|
|
136
136
|
"features.coverage": "已查 {scanned}/{total} 条已索引会话",
|
|
137
137
|
"features.partial": "结果未完整覆盖当前范围;最多展示 100 条命中",
|
|
138
|
+
"features.resultView": "结果视图",
|
|
139
|
+
"features.byMessage": "按消息",
|
|
140
|
+
"features.bySession": "按会话",
|
|
141
|
+
"features.returnedMatches": "已返回 {count} 条命中",
|
|
142
|
+
"features.groupedTruncated": "已达结果上限;会话分组只统计已返回的命中。",
|
|
138
143
|
"features.context": "前后文",
|
|
139
144
|
"features.generateDraft": "生成交接草稿({count} 条)",
|
|
140
145
|
"features.draftReview": "草稿未发送;先核对证据,再填写或修改后续步骤。",
|
|
@@ -555,6 +560,8 @@ const zh = Object.freeze({
|
|
|
555
560
|
'prompts.editor.preview': '预览',
|
|
556
561
|
'prompts.editor.previewUnavailable': '预览组件未加载(marked / DOMPurify 缺失),请刷新页面',
|
|
557
562
|
'prompts.editor.previewEmpty': '暂无内容可预览',
|
|
563
|
+
'prompts.editor.outline': '文档大纲',
|
|
564
|
+
'prompts.editor.outlineEmpty': '暂无标题',
|
|
558
565
|
'prompts.editor.changeAxis': '改动导航轴',
|
|
559
566
|
'prompts.editor.changeAxisTick': '第 {line} 行(+{added} / -{removed})',
|
|
560
567
|
'prompts.tokenCount.hint': '约 {count} tokens',
|
|
@@ -1643,6 +1650,17 @@ const zh = Object.freeze({
|
|
|
1643
1650
|
|
|
1644
1651
|
'market.backup.action': '备份当前目标',
|
|
1645
1652
|
'market.backup.running': '备份中...',
|
|
1653
|
+
'market.backup.export': '导出备份',
|
|
1654
|
+
'market.backup.import': '导入备份',
|
|
1655
|
+
'market.backup.targetChanged': '目标已切换,请重新选择备份。',
|
|
1656
|
+
'market.backup.tooLarge': '备份超过 20 MiB,无法导入。',
|
|
1657
|
+
'market.backup.invalid': '请选择有效的 v1 Skills 备份。',
|
|
1658
|
+
'market.backup.importFailed': '导入备份失败。',
|
|
1659
|
+
'market.backup.result': '恢复 {restored} 项,跳过 {skipped} 项,失败 {failed} 项。',
|
|
1660
|
+
'market.backup.exportFailed': '导出备份失败。',
|
|
1661
|
+
'market.backup.exportPartial': '已导出 {count} 项,失败 {failed} 项。',
|
|
1662
|
+
'market.backup.exportResult': '已导出 {count} 项。',
|
|
1663
|
+
'market.backup.exportLimited': '此 ZIP 可保留作离线备份,无法通过网页导入。',
|
|
1646
1664
|
'market.export.action': '导出选中',
|
|
1647
1665
|
'market.export.running': '导出中...',
|
|
1648
1666
|
'market.selection.all': '全选',
|
|
@@ -3,6 +3,11 @@ import { sessionEvidenceMixin } from './session-evidence.mjs';
|
|
|
3
3
|
import { usagePricingMixin } from './usage-pricing.mjs';
|
|
4
4
|
import { sessionGitMixin } from './session-git.mjs';
|
|
5
5
|
import { contextWindowReference } from '../logic.context-window.mjs';
|
|
6
|
+
const INDEX_RESULT_VIEW_KEY = 'codexmateSessionIndexResultView';
|
|
7
|
+
function readIndexResultView() {
|
|
8
|
+
try { return globalThis.localStorage?.getItem(INDEX_RESULT_VIEW_KEY) === 'sessions' ? 'sessions' : 'messages'; }
|
|
9
|
+
catch (_) { return 'messages'; }
|
|
10
|
+
}
|
|
6
11
|
const SessionMessageActions = {
|
|
7
12
|
props: { message: { type: Object, required: true } },
|
|
8
13
|
render() {
|
|
@@ -29,10 +34,23 @@ export const sessionFeaturesMixin = {
|
|
|
29
34
|
return { featureView: '', featureBusy: false, featureError: '', bookmarks: [], bookmarkRevision: '',
|
|
30
35
|
bookmarkQuery: '', bookmarkTag: '', bookmarkProject: '', bookmarkEditor: null,
|
|
31
36
|
selectedContextIds: [], featureFocus: null, featureRequestSeq: 0,
|
|
32
|
-
indexReport: null, indexResults: null, indexQuery: '', indexTimer: null, handoffDraftEvidence: [], handoffUnverified: [], projectReport: null, projectSelected: '', projectAlias: '', projectPrompt: null, contextWindowInput: '', contextSelectedModel: '', contextFeatureSettings: null, contextSettingsRevision: '', diagnosticsReport: null, diagnosticsMarkdown: '', diagnosticsRemote: false,
|
|
37
|
+
indexReport: null, indexResults: null, indexQuery: '', indexTimer: null, indexResultView: readIndexResultView(), handoffDraftEvidence: [], handoffUnverified: [], projectReport: null, projectSelected: '', projectAlias: '', projectPrompt: null, contextWindowInput: '', contextSelectedModel: '', contextFeatureSettings: null, contextSettingsRevision: '', diagnosticsReport: null, diagnosticsMarkdown: '', diagnosticsRemote: false,
|
|
33
38
|
diagnosticsTargets: [], diagnosticsSelected: [], diagnosticsTimer: null };
|
|
34
39
|
},
|
|
35
40
|
computed: {
|
|
41
|
+
indexResultRows() {
|
|
42
|
+
const hits = this.indexResults?.results || [];
|
|
43
|
+
if (this.indexResultView === 'messages') {
|
|
44
|
+
return hits.map(hit => ({ key: `message:${hit.session.key}:${hit.nodeId}`, session: hit.session, hits: [hit] }));
|
|
45
|
+
}
|
|
46
|
+
const sessions = new Map();
|
|
47
|
+
for (const hit of hits) {
|
|
48
|
+
const key = `session:${hit.session.key}`;
|
|
49
|
+
if (!sessions.has(key)) sessions.set(key, { key, session: hit.session, hits: [] });
|
|
50
|
+
sessions.get(key).hits.push(hit);
|
|
51
|
+
}
|
|
52
|
+
return [...sessions.values()];
|
|
53
|
+
},
|
|
36
54
|
indexCatalogTime() {
|
|
37
55
|
const timestamp = this.indexReport?.updatedAt;
|
|
38
56
|
const parsed = typeof timestamp === 'string' ? Date.parse(timestamp) : NaN;
|
|
@@ -162,6 +180,12 @@ export const sessionFeaturesMixin = {
|
|
|
162
180
|
try { await this.featureCall('session-index-cancel'); await this.pollSessionIndex(); }
|
|
163
181
|
catch (error) { this.featureError = this.featureErrorText(error); }
|
|
164
182
|
},
|
|
183
|
+
setIndexResultView(view) {
|
|
184
|
+
if (view !== 'messages' && view !== 'sessions') return;
|
|
185
|
+
this.indexResultView = view;
|
|
186
|
+
try { globalThis.localStorage?.setItem(INDEX_RESULT_VIEW_KEY, view); }
|
|
187
|
+
catch (_) { /* Keep the view usable when browser storage is disabled. */ }
|
|
188
|
+
},
|
|
165
189
|
async searchSessionIndex() {
|
|
166
190
|
if (this.featureBusy) return;
|
|
167
191
|
const seq = ++this.featureRequestSeq;
|