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.
@@ -7,6 +7,46 @@ function showUnsupportedSkillsTargetMessage(vm, app) {
7
7
  vm.showMessage(`不支持的 Skills 安装目标:${String(app)}`, 'error');
8
8
  }
9
9
 
10
+ const MAX_SKILLS_ZIP_SIZE = 20 * 1024 * 1024;
11
+
12
+ async function restoreSkillsFromBackup(event) {
13
+ const input = event.target;
14
+ const file = input.files?.[0];
15
+ const targetApp = input.dataset.targetApp;
16
+ delete input.dataset.targetApp;
17
+ input.value = '';
18
+ if (!file) return;
19
+ if (targetApp !== this.skillsTargetApp) {
20
+ this.showMessage(this.t('market.backup.targetChanged'), 'error');
21
+ return;
22
+ }
23
+ if (this.loading || this.initError || this.skillsMarketBusy) return;
24
+ if (file.size > MAX_SKILLS_ZIP_SIZE) {
25
+ this.showMessage(this.t('market.backup.tooLarge'), 'error');
26
+ return;
27
+ }
28
+ this.skillsZipImporting = true;
29
+ let refresh = false;
30
+ try {
31
+ const result = await this.uploadSkillsZipStream(file, { targetApp, restoreBackup: true });
32
+ if (result.error || !Array.isArray(result.imported) || !Array.isArray(result.skipped) || !Array.isArray(result.failed)) {
33
+ const key = result.backupError === 'invalid' ? 'invalid'
34
+ : result.backupError === 'tooLarge' ? 'tooLarge' : 'importFailed';
35
+ this.showMessage(this.t(`market.backup.${key}`), 'error');
36
+ return;
37
+ }
38
+ const counts = { restored: result.imported.length, skipped: result.skipped.length, failed: result.failed.length };
39
+ this.showMessage(this.t('market.backup.result', counts), counts.failed ? 'error' : counts.skipped ? 'info' : 'success');
40
+ refresh = counts.restored > 0 || counts.failed > 0;
41
+ if (refresh) await this.refreshSkillsList({ silent: true });
42
+ } catch (error) {
43
+ this.showMessage(this.t('market.backup.importFailed'), 'error');
44
+ } finally {
45
+ this.skillsZipImporting = false;
46
+ if (refresh) await this.scanImportableSkills({ silent: true });
47
+ }
48
+ }
49
+
10
50
  export function createSkillsMethods({ api }) {
11
51
  return {
12
52
  normalizeSkillsTargetApp(app) {
@@ -24,6 +64,8 @@ export function createSkillsMethods({ api }) {
24
64
  this.skillsMarketSelectedNames = [];
25
65
  this.skillsKeyword = '';
26
66
  this.skillsStatusFilter = 'all';
67
+ const backupInput = this.$refs?.skillsBackupImportInput;
68
+ if (backupInput) delete backupInput.dataset.targetApp;
27
69
  this.skillsRootPath = '';
28
70
  this.skillsList = [];
29
71
  this.skillsImportList = [];
@@ -299,15 +341,19 @@ export function createSkillsMethods({ api }) {
299
341
  }
300
342
  },
301
343
 
302
- triggerSkillsZipImport() {
303
- const input = this.$refs.skillsZipImportInput;
344
+ triggerSkillsZipImport(mode) {
345
+ const isBackup = mode === 'backup';
346
+ if (isBackup && (this.loading || this.initError || this.skillsMarketBusy)) return;
347
+ const input = isBackup ? this.$refs.skillsBackupImportInput : this.$refs.skillsZipImportInput;
304
348
  if (input) {
305
349
  input.value = '';
350
+ if (isBackup) input.dataset.targetApp = this.skillsTargetApp;
306
351
  input.click();
307
352
  }
308
353
  },
309
354
 
310
- handleSkillsZipImportChange(event) {
355
+ handleSkillsZipImportChange(event, mode) {
356
+ if (mode === 'backup') return restoreSkillsFromBackup.call(this, event);
311
357
  const file = event && event.target && event.target.files ? event.target.files[0] : null;
312
358
  if (file) {
313
359
  void this.importSkillsFromZipFile(file);
@@ -321,11 +367,12 @@ export function createSkillsMethods({ api }) {
321
367
  }
322
368
  },
323
369
 
324
- async uploadSkillsZipStream(file) {
370
+ async uploadSkillsZipStream(file, { targetApp = this.skillsTargetApp, restoreBackup = false } = {}) {
325
371
  const fileName = (file && typeof file.name === 'string' && file.name.trim())
326
372
  ? file.name.trim()
327
- : `${this.skillsTargetApp}-skills.zip`;
328
- const response = await fetch(`/api/import-skills-zip?targetApp=${encodeURIComponent(this.skillsTargetApp)}`, {
373
+ : `${targetApp}-skills.zip`;
374
+ const mode = restoreBackup ? '&mode=backup' : '';
375
+ const response = await fetch(`/api/import-skills-zip?targetApp=${encodeURIComponent(targetApp)}${mode}`, {
329
376
  method: 'POST',
330
377
  headers: authorizationHeaders({
331
378
  'x-codexmate-file-name': encodeURIComponent(fileName)
@@ -350,8 +397,7 @@ export function createSkillsMethods({ api }) {
350
397
 
351
398
  async importSkillsFromZipFile(file) {
352
399
  if (this.skillsDeleting || this.skillsScanningImports || this.skillsZipImporting || this.skillsImporting || this.skillsExporting || this.skillsBackingUp) return;
353
- const maxSize = 20 * 1024 * 1024;
354
- if (file.size > maxSize) {
400
+ if (file.size > MAX_SKILLS_ZIP_SIZE) {
355
401
  this.showMessage('ZIP 文件过大,限制 20MB', 'error');
356
402
  this.resetSkillsZipImportInput();
357
403
  return;
@@ -441,12 +487,8 @@ export function createSkillsMethods({ api }) {
441
487
  this.skillsBackingUp = true;
442
488
  try {
443
489
  const res = await api('backup-skills', { targetApp: this.skillsTargetApp });
444
- if (res && res.error) {
445
- this.showMessage(res.error, 'error');
446
- return;
447
- }
448
- if (!res || !res.fileName) {
449
- this.showMessage('备份失败:未生成压缩包', 'error');
490
+ if (res?.error || !res?.fileName) {
491
+ this.showMessage(this.t('market.backup.exportFailed'), 'error');
450
492
  return;
451
493
  }
452
494
  const link = document.createElement('a');
@@ -456,9 +498,12 @@ export function createSkillsMethods({ api }) {
456
498
  link.click();
457
499
  document.body.removeChild(link);
458
500
  const count = Array.isArray(res.exported) ? res.exported.length : 0;
459
- this.showMessage(`已备份 ${this.skillsTargetLabel} 的 ${count} 个 skill`, 'success');
501
+ const failed = Array.isArray(res.failed) ? res.failed.length : 0;
502
+ const summary = this.t(failed ? 'market.backup.exportPartial' : 'market.backup.exportResult', { count, failed });
503
+ const message = res.restoreWarning ? `${summary} ${this.t('market.backup.exportLimited')}` : summary;
504
+ this.showMessage(message, failed || res.restoreWarning ? 'error' : 'success');
460
505
  } catch (e) {
461
- this.showMessage('备份 skill 失败', 'error');
506
+ this.showMessage(this.t('market.backup.exportFailed'), 'error');
462
507
  } finally {
463
508
  this.skillsBackingUp = false;
464
509
  }
@@ -412,47 +412,46 @@
412
412
  </div>
413
413
  </div>
414
414
 
415
- <div class="side-rail-lang">
416
- <div class="side-rail-lang-actions">
417
- <div class="side-language-menu">
415
+ <div class="side-rail-footer">
416
+ <button
417
+ type="button"
418
+ class="side-rail-action side-announcement-button"
419
+ @click="openProviderCacheAnnouncementModal">
420
+ <svg class="side-rail-action-icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
421
+ <path d="M15 8.5a5 5 0 0 0-10 0c0 2.75-1 4.25-2 5.5h14c-1-1.25-2-2.75-2-5.5Z"/>
422
+ <path d="M8 16a2 2 0 0 0 4 0"/>
423
+ </svg>
424
+ <span>{{ t('announcement.providerCache.open') }}</span>
425
+ <svg class="side-rail-action-chevron" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 4l4 4-4 4"/></svg>
426
+ </button>
427
+ <div class="side-language-menu">
428
+ <button
429
+ type="button"
430
+ class="side-rail-action"
431
+ :aria-label="t('settings.language.sideLabel', { language: currentLanguageLabel() })"
432
+ :aria-expanded="languageMenuOpen ? 'true' : 'false'"
433
+ aria-haspopup="menu"
434
+ @click="toggleLanguageMenu"
435
+ @keydown.esc.prevent="closeLanguageMenu">
436
+ <svg class="side-rail-action-icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" aria-hidden="true"><circle cx="10" cy="10" r="7.5"/><ellipse cx="10" cy="10" rx="3.25" ry="7.5"/><path d="M2.5 10h15"/></svg>
437
+ <span>{{ currentLanguageLabel() }}</span>
438
+ <svg class="side-rail-action-chevron" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 6l4 4 4-4"/></svg>
439
+ </button>
440
+ <div v-if="languageMenuOpen" class="side-language-dropdown" role="menu" @focusout="handleLanguageMenuFocusOut">
418
441
  <button
442
+ v-for="option in languageOptions()"
443
+ :key="option.code"
419
444
  type="button"
420
- class="language-settings-link"
421
- :aria-label="t('settings.language.sideLabel', { language: currentLanguageLabel() })"
422
- :aria-expanded="languageMenuOpen ? 'true' : 'false'"
423
- aria-haspopup="menu"
424
- @click="toggleLanguageMenu"
425
- @keydown.esc.prevent="closeLanguageMenu">
426
- {{ currentLanguageLabel() }}
427
- <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 6l4 4 4-4"/></svg>
445
+ class="side-language-option"
446
+ :class="{ active: option.code === lang }"
447
+ role="menuitemradio"
448
+ :aria-checked="option.code === lang ? 'true' : 'false'"
449
+ @click="selectLanguage(option.code)">
450
+ <span>{{ option.nativeName }}</span>
451
+ <small>{{ option.englishName }}</small>
452
+ <svg v-if="option.code === lang" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3.5 8.5l3 3 6-7"/></svg>
428
453
  </button>
429
- <div v-if="languageMenuOpen" class="side-language-dropdown" role="menu" @focusout="handleLanguageMenuFocusOut">
430
- <button
431
- v-for="option in languageOptions()"
432
- :key="option.code"
433
- type="button"
434
- class="side-language-option"
435
- :class="{ active: option.code === lang }"
436
- role="menuitemradio"
437
- :aria-checked="option.code === lang ? 'true' : 'false'"
438
- @click="selectLanguage(option.code)">
439
- <span>{{ option.nativeName }}</span>
440
- <small>{{ option.englishName }}</small>
441
- <svg v-if="option.code === lang" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3.5 8.5l3 3 6-7"/></svg>
442
- </button>
443
- </div>
444
454
  </div>
445
- <button
446
- type="button"
447
- class="side-announcement-button"
448
- :aria-label="t('announcement.providerCache.open')"
449
- :title="t('announcement.providerCache.open')"
450
- @click="openProviderCacheAnnouncementModal">
451
- <svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" width="16" height="16" aria-hidden="true">
452
- <path d="M15 8.5a5 5 0 0 0-10 0c0 2.75-1 4.25-2 5.5h14c-1-1.25-2-2.75-2-5.5Z"/>
453
- <path d="M8 16a2 2 0 0 0 4 0"/>
454
- </svg>
455
- </button>
456
455
  </div>
457
456
  </div>
458
457
  </aside>
@@ -50,9 +50,6 @@
50
50
  <span class="skills-flow-count">{{ skillsList.length }}</span>
51
51
  </div>
52
52
  <div class="skills-flow-actions">
53
- <button type="button" class="skills-action-btn" @click="backupCurrentSkills" :disabled="loading || !!initError || skillsMarketBusy || skillsList.length === 0">
54
- {{ skillsBackingUp ? t('market.backup.running') : t('market.backup.action') }}
55
- </button>
56
53
  <button type="button" class="skills-action-btn" @click="exportMarketSelectedSkills" :disabled="loading || !!initError || skillsMarketBusy || skillsMarketSelectedCount === 0">
57
54
  {{ skillsExporting ? t('market.export.running') : t('market.export.action') }} ({{ skillsMarketSelectedCount }})
58
55
  </button>
@@ -62,6 +59,16 @@
62
59
  </button>
63
60
  </div>
64
61
  </div>
62
+ <div class="skills-flow-actions">
63
+ <button type="button" class="skills-action-btn" @click="backupCurrentSkills" :disabled="loading || !!initError || skillsMarketBusy || skillsList.length === 0">
64
+ {{ skillsBackingUp ? t('market.backup.running') : t('market.backup.export') }}
65
+ </button>
66
+ <button type="button" class="skills-action-btn" @click="triggerSkillsZipImport('backup')" :disabled="loading || !!initError || skillsMarketBusy">
67
+ {{ skillsZipImporting ? t('modal.skills.actions.zipImporting') : t('market.backup.import') }}
68
+ </button>
69
+ <input ref="skillsBackupImportInput" type="file" accept=".zip,application/zip" hidden
70
+ @change="handleSkillsZipImportChange($event, 'backup')" @cancel="delete $event.target.dataset.targetApp">
71
+ </div>
65
72
  <div v-if="skillsList.length > 0" class="skills-market-selection-bar">
66
73
  <label class="skills-market-select-all">
67
74
  <input type="checkbox" :checked="skillsMarketAllSelected" @change="toggleAllSkillsMarketSelection" :disabled="skillsMarketBusy">
@@ -6,13 +6,13 @@
6
6
  role="tabpanel"
7
7
  aria-labelledby="tab-prompts">
8
8
  <div class="prompts-md-tabs" role="tablist" :aria-label="t('tab.prompts')">
9
- <button type="button" :class="['prompts-md-tab', { active: promptsSubTab === 'codex' }]" role="tab" :aria-selected="promptsSubTab === 'codex'" @click="switchPromptsSubTab('codex')">{{ t('prompts.subTab.codex') }}</button>
10
- <button type="button" :class="['prompts-md-tab', { active: promptsSubTab === 'opencode' }]" role="tab" :aria-selected="promptsSubTab === 'opencode'" @click="switchPromptsSubTab('opencode')">{{ t('prompts.subTab.opencode') }}</button>
11
- <button type="button" :class="['prompts-md-tab', { active: promptsSubTab === 'claude-project' }]" role="tab" :aria-selected="promptsSubTab === 'claude-project'" @click="switchPromptsSubTab('claude-project')">{{ t('prompts.subTab.project') }}</button>
12
- <button type="button" :class="['prompts-md-tab', { active: promptsSubTab === 'system' }]" role="tab" :aria-selected="promptsSubTab === 'system'" @click="switchPromptsSubTab('system')">{{ t('prompts.subTab.system') }}</button>
9
+ <button type="button" :class="['prompts-md-tab', { active: promptsSubTab === 'codex' }]" role="tab" :aria-selected="promptsSubTab === 'codex'" @click="switchPromptsSubTab('codex')"><span>AGENTS.md</span><span class="prompts-file-badge">Codex</span></button>
10
+ <button type="button" :class="['prompts-md-tab', { active: promptsSubTab === 'opencode' }]" role="tab" :aria-selected="promptsSubTab === 'opencode'" @click="switchPromptsSubTab('opencode')"><span>AGENTS.md</span><span class="prompts-file-badge">OpenCode</span></button>
11
+ <button type="button" :class="['prompts-md-tab', { active: promptsSubTab === 'claude-project' }]" role="tab" :aria-selected="promptsSubTab === 'claude-project'" @click="switchPromptsSubTab('claude-project')"><span>CLAUDE.md</span><span class="prompts-file-badge">Claude</span></button>
12
+ <button type="button" :class="['prompts-md-tab', { active: promptsSubTab === 'system' }]" role="tab" :aria-selected="promptsSubTab === 'system'" @click="switchPromptsSubTab('system')"><span>SYSTEM.md</span><span class="prompts-file-badge">Pi</span></button>
13
13
  </div>
14
14
 
15
- <div v-if="promptsSubTab === 'claude-project'" class="project-path-selector">
15
+ <div v-if="promptsSubTab === 'claude-project'" class="project-path-selector prompts-target-card">
16
16
  <label class="project-path-label">{{ t('prompts.project.pathLabel') }}</label>
17
17
  <div class="project-path-row">
18
18
  <select
@@ -89,6 +89,14 @@
89
89
  <svg class="btn-icon-sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 8v4l3 2"/><path d="M3 12a9 9 0 1 0 9-9 9 9 0 0 0-7.5 4M3 4v4h4"/></svg>
90
90
  </button>
91
91
  </div>
92
+ <div v-if="promptsPreviewEnabled && !agentsDiffVisible" class="prompts-editor-group prompts-editor-group--reading">
93
+ <button type="button" class="btn-mini prompts-outline-toggle" :aria-expanded="!promptsOutlineCollapsed" aria-controls="prompts-agents-outline" :aria-label="t('prompts.editor.outline')" :title="t('prompts.editor.outline')" @click="promptsOutlineCollapsed = !promptsOutlineCollapsed">
94
+ <svg class="btn-icon-sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M10 4v16"/></svg>
95
+ </button>
96
+ <button type="button" class="btn-mini prompts-split-collapse-btn" :aria-pressed="!promptsPreviewCollapsed" :title="promptsPreviewCollapsed ? t('prompts.editor.expandPreview') : t('prompts.editor.collapsePreview')" :aria-label="promptsPreviewCollapsed ? t('prompts.editor.expandPreview') : t('prompts.editor.collapsePreview')" @click="togglePromptsPreviewCollapsed()">
97
+ <svg class="btn-icon-sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12Z"/><circle cx="12" cy="12" r="3"/></svg>
98
+ </button>
99
+ </div>
92
100
  <div class="prompts-editor-group prompts-editor-group--workflow prompts-editor-group--view" role="group" :aria-label="t('prompts.actions.view')">
93
101
  <button class="btn-mini" @click="agentsDiffVisible ? resetAgentsDiffState() : loadPromptsContent()" :disabled="agentsSaving || agentsDiffLoading" :title="t('common.cancel')">
94
102
  <svg class="btn-icon-sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 6L6 18M6 6l12 12"/></svg>
@@ -234,10 +242,12 @@
234
242
  </div>
235
243
  </div>
236
244
  </div>
237
- <div :class="['editor-frame prompts-editor-frame', { 'editor-frame--loading': agentsLoading, 'prompts-editor-frame--split': promptsPreviewEnabled, 'prompts-editor-frame--preview-collapsed': promptsPreviewCollapsed, 'prompts-editor-frame--mobile-preview': promptsPreviewEnabled && promptsMobileView === 'preview' }]">
238
- <button v-if="promptsPreviewEnabled" type="button" class="prompts-split-collapse-btn" :class="{ 'prompts-split-collapse-btn--collapsed': promptsPreviewCollapsed }" :title="promptsPreviewCollapsed ? t('prompts.editor.expandPreview') : t('prompts.editor.collapsePreview')" :aria-label="promptsPreviewCollapsed ? t('prompts.editor.expandPreview') : t('prompts.editor.collapsePreview')" @click="togglePromptsPreviewCollapsed()">
239
- <svg class="prompts-split-collapse-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 6l6 6-6 6"/></svg>
240
- </button>
245
+ <div :class="['editor-frame prompts-editor-frame', { 'prompts-editor-frame--outline': promptsPreviewEnabled && !promptsOutlineCollapsed, 'editor-frame--loading': agentsLoading, 'prompts-editor-frame--split': promptsPreviewEnabled, 'prompts-editor-frame--preview-collapsed': promptsPreviewCollapsed, 'prompts-editor-frame--mobile-preview': promptsPreviewEnabled && promptsMobileView === 'preview' }]">
246
+ <nav v-if="promptsPreviewEnabled" v-show="!promptsOutlineCollapsed" id="prompts-agents-outline" class="prompts-outline" :aria-label="t('prompts.editor.outline')">
247
+ <div class="prompts-outline-title">{{ t('prompts.editor.outline') }}</div>
248
+ <p v-if="!agentsPreviewHeadings.length" class="form-hint">{{ t('prompts.editor.outlineEmpty') }}</p>
249
+ <button v-for="heading in agentsPreviewHeadings" :key="heading.index" type="button" class="prompts-outline-item" :style="{ '--outline-depth': heading.depth }" @click="jumpToPromptsHeading('agents', heading.index)">{{ heading.text }}</button>
250
+ </nav>
241
251
  <div v-if="agentsLoading" class="editor-skeleton">
242
252
  <div class="skeleton-line" v-for="i in 6" :key="i"></div>
243
253
  </div>
@@ -252,7 +262,7 @@
252
262
  @input="onAgentsContentInput"
253
263
  :placeholder="t(promptsSubTab === 'claude-project' ? 'modal.agents.placeholder.claudeProject' : 'modal.agents.placeholder')"></textarea>
254
264
  </div>
255
- <div v-if="promptsPreviewEnabled" class="prompts-preview-pane">
265
+ <div v-if="promptsPreviewEnabled" ref="promptsAgentsPreviewPane" class="prompts-preview-pane">
256
266
  <div v-if="promptsPreviewLibsMissing" class="state-message error">{{ t('prompts.editor.previewUnavailable') }}</div>
257
267
  <div v-else-if="!agentsPreviewHtml" class="state-message">{{ t('prompts.editor.previewEmpty') }}</div>
258
268
  <div v-else class="prompts-preview-body" v-html="agentsPreviewHtml"></div>
@@ -267,7 +277,7 @@
267
277
  </div>
268
278
 
269
279
  <div v-if="promptsSubTab === 'system'">
270
- <div class="sys-prompt-controls">
280
+ <div class="sys-prompt-controls prompts-target-card">
271
281
  <div class="sys-prompt-control-group">
272
282
  <label class="form-label" for="sys-prompt-file-select">{{ t('sysPrompt.fileLabel') }}</label>
273
283
  <select id="sys-prompt-file-select" class="form-input sys-prompt-select" :value="currentSysPromptFileName()" :aria-busy="sysPromptFilesLoading" :disabled="sysPromptLoading || sysPromptSaving || sysPromptDiffVisible" @focus="loadSystemPromptFiles" @pointerdown="loadSystemPromptFiles" @keydown.enter="loadSystemPromptFiles" @keydown.space="loadSystemPromptFiles" @change="switchSysPromptFileName($event.target.value, $event)">
@@ -277,15 +287,15 @@
277
287
  <div v-if="sysPromptFilesLoading" class="form-hint" role="status">{{ t('sysPrompt.filesLoading') }}</div>
278
288
  </div>
279
289
  <div class="sys-prompt-control-group">
280
- <label class="form-label">{{ t('sysPrompt.scope.label') }}</label>
281
- <select class="form-input sys-prompt-select" :value="sysPromptScope" @change="switchSysPromptScope($event.target.value)" :disabled="sysPromptLoading || sysPromptSaving || sysPromptDiffVisible || hasSysPromptContentChanged()">
290
+ <label class="form-label" for="sys-prompt-scope-select">{{ t('sysPrompt.scope.label') }}</label>
291
+ <select id="sys-prompt-scope-select" class="form-input sys-prompt-select" :value="sysPromptScope" @change="switchSysPromptScope($event.target.value)" :disabled="sysPromptLoading || sysPromptSaving || sysPromptDiffVisible || hasSysPromptContentChanged()">
282
292
  <option value="global">{{ t('sysPrompt.scope.global') }}</option>
283
293
  <option value="project">{{ t('sysPrompt.scope.project') }}</option>
284
294
  </select>
285
295
  </div>
286
296
  <div v-if="!isSysPromptCustomFile()" class="sys-prompt-control-group">
287
- <label class="form-label">{{ t('sysPrompt.mode.label') }}</label>
288
- <select class="form-input sys-prompt-select" :value="sysPromptMode" @change="switchSysPromptMode($event.target.value)" :disabled="sysPromptLoading || sysPromptSaving || sysPromptDiffVisible || hasSysPromptContentChanged()">
297
+ <label class="form-label" for="sys-prompt-mode-select">{{ t('sysPrompt.mode.label') }}</label>
298
+ <select id="sys-prompt-mode-select" class="form-input sys-prompt-select" :value="sysPromptMode" @change="switchSysPromptMode($event.target.value)" :disabled="sysPromptLoading || sysPromptSaving || sysPromptDiffVisible || hasSysPromptContentChanged()">
289
299
  <option value="append">{{ t('sysPrompt.mode.append') }}</option>
290
300
  <option value="system">{{ t('sysPrompt.mode.system') }}</option>
291
301
  </select>
@@ -334,6 +344,14 @@
334
344
  <svg class="btn-icon-sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 8v4l3 2"/><path d="M3 12a9 9 0 1 0 9-9 9 9 0 0 0-7.5 4M3 4v4h4"/></svg>
335
345
  </button>
336
346
  </div>
347
+ <div v-if="promptsPreviewEnabled && !sysPromptDiffVisible" class="prompts-editor-group prompts-editor-group--reading">
348
+ <button type="button" class="btn-mini prompts-outline-toggle" :aria-expanded="!promptsOutlineCollapsed" aria-controls="prompts-sys-outline" :aria-label="t('prompts.editor.outline')" :title="t('prompts.editor.outline')" @click="promptsOutlineCollapsed = !promptsOutlineCollapsed">
349
+ <svg class="btn-icon-sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M10 4v16"/></svg>
350
+ </button>
351
+ <button type="button" class="btn-mini prompts-split-collapse-btn" :aria-pressed="!promptsPreviewCollapsed" :title="promptsPreviewCollapsed ? t('prompts.editor.expandPreview') : t('prompts.editor.collapsePreview')" :aria-label="promptsPreviewCollapsed ? t('prompts.editor.expandPreview') : t('prompts.editor.collapsePreview')" @click="togglePromptsPreviewCollapsed()">
352
+ <svg class="btn-icon-sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12Z"/><circle cx="12" cy="12" r="3"/></svg>
353
+ </button>
354
+ </div>
337
355
  <div class="prompts-editor-group prompts-editor-group--workflow prompts-editor-group--view" role="group" :aria-label="t('prompts.actions.view')">
338
356
  <button class="btn-mini" @click="sysPromptDiffVisible ? resetSysPromptDiffState() : cancelSysPromptEdit()" :disabled="sysPromptSaving || sysPromptDiffLoading" :title="t('common.cancel')">
339
357
  <svg class="btn-icon-sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 6L6 18M6 6l12 12"/></svg>
@@ -417,10 +435,12 @@
417
435
  </div>
418
436
  </div>
419
437
  </div>
420
- <div :class="['editor-frame prompts-editor-frame', { 'editor-frame--loading': sysPromptLoading, 'prompts-editor-frame--split': promptsPreviewEnabled, 'prompts-editor-frame--preview-collapsed': promptsPreviewCollapsed, 'prompts-editor-frame--mobile-preview': promptsPreviewEnabled && promptsMobileView === 'preview' }]">
421
- <button v-if="promptsPreviewEnabled" type="button" class="prompts-split-collapse-btn" :class="{ 'prompts-split-collapse-btn--collapsed': promptsPreviewCollapsed }" :title="promptsPreviewCollapsed ? t('prompts.editor.expandPreview') : t('prompts.editor.collapsePreview')" :aria-label="promptsPreviewCollapsed ? t('prompts.editor.expandPreview') : t('prompts.editor.collapsePreview')" @click="togglePromptsPreviewCollapsed()">
422
- <svg class="prompts-split-collapse-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 6l6 6-6 6"/></svg>
423
- </button>
438
+ <div :class="['editor-frame prompts-editor-frame', { 'prompts-editor-frame--outline': promptsPreviewEnabled && !promptsOutlineCollapsed, 'editor-frame--loading': sysPromptLoading, 'prompts-editor-frame--split': promptsPreviewEnabled, 'prompts-editor-frame--preview-collapsed': promptsPreviewCollapsed, 'prompts-editor-frame--mobile-preview': promptsPreviewEnabled && promptsMobileView === 'preview' }]">
439
+ <nav v-if="promptsPreviewEnabled" v-show="!promptsOutlineCollapsed" id="prompts-sys-outline" class="prompts-outline" :aria-label="t('prompts.editor.outline')">
440
+ <div class="prompts-outline-title">{{ t('prompts.editor.outline') }}</div>
441
+ <p v-if="!sysPreviewHeadings.length" class="form-hint">{{ t('prompts.editor.outlineEmpty') }}</p>
442
+ <button v-for="heading in sysPreviewHeadings" :key="heading.index" type="button" class="prompts-outline-item" :style="{ '--outline-depth': heading.depth }" @click="jumpToPromptsHeading('sys', heading.index)">{{ heading.text }}</button>
443
+ </nav>
424
444
  <div v-if="sysPromptLoading" class="editor-skeleton">
425
445
  <div class="skeleton-line" v-for="i in 6" :key="i"></div>
426
446
  </div>
@@ -434,7 +454,7 @@
434
454
  :readonly="sysPromptLoading || sysPromptSaving || sysPromptDiffVisible"
435
455
  :placeholder="t('sysPrompt.placeholder')"></textarea>
436
456
  </div>
437
- <div v-if="promptsPreviewEnabled" class="prompts-preview-pane">
457
+ <div v-if="promptsPreviewEnabled" ref="promptsSysPreviewPane" class="prompts-preview-pane">
438
458
  <div v-if="promptsPreviewLibsMissing" class="state-message error">{{ t('prompts.editor.previewUnavailable') }}</div>
439
459
  <div v-else-if="!sysPromptPreviewHtml" class="state-message">{{ t('prompts.editor.previewEmpty') }}</div>
440
460
  <div v-else class="prompts-preview-body" v-html="sysPromptPreviewHtml"></div>
@@ -38,13 +38,30 @@
38
38
  <p class="feature-meta">{{ t('features.coverage', { scanned: indexResults.scanned, total: indexResults.candidates }) }}</p>
39
39
  <p v-if="!indexResults.complete" class="feature-hint">{{ t('features.partial') }}</p>
40
40
  <p v-if="!indexResults.results.length" class="feature-empty">{{ t('features.empty') }}</p>
41
- <article v-for="result in indexResults.results" :key="result.session.key + result.nodeId" class="feature-record">
42
- <header class="feature-record-heading"><h4>{{ result.session.title || result.session.sessionId }}</h4><span class="feature-source">{{ result.session.source }}</span></header>
43
- <small class="feature-path" :title="result.session.cwd">{{ result.session.cwd }}</small>
44
- <pre class="feature-excerpt">{{ result.snippet }}</pre>
45
- <div class="feature-record-actions"><button type="button" class="btn-mini" @click="openIndexedMessage(result)">{{ t('features.source') }}</button><label class="evidence-select"><input type="checkbox" :checked="isEvidenceSelected(result)" @change="toggleEvidence(result)">{{ t('evidence.select') }}</label></div>
46
- <details class="feature-disclosure"><summary>{{ t('features.context') }}</summary><pre>{{ result.before }}</pre><pre>{{ result.after }}</pre></details>
47
- </article>
41
+ <template v-else>
42
+ <div class="feature-actions index-result-views" role="group" :aria-label="t('features.resultView')">
43
+ <button type="button" class="btn-mini" :aria-pressed="indexResultView === 'messages'" @click="setIndexResultView('messages')">{{ t('features.byMessage') }}</button>
44
+ <button type="button" class="btn-mini" :aria-pressed="indexResultView === 'sessions'" @click="setIndexResultView('sessions')">{{ t('features.bySession') }}</button>
45
+ </div>
46
+ <p v-if="indexResultView === 'sessions' && indexResults.truncated" class="feature-hint">{{ t('features.groupedTruncated') }}</p>
47
+ <component v-for="row in indexResultRows" :key="row.key" :is="indexResultView === 'sessions' ? 'details' : 'div'" :class="indexResultView === 'sessions' ? 'feature-disclosure index-result-group' : 'index-message-row'">
48
+ <summary v-if="indexResultView === 'sessions'">
49
+ <strong>{{ row.session.title || row.session.sessionId }}</strong>
50
+ <span class="feature-source">{{ row.session.source }}</span>
51
+ <span class="feature-meta">{{ t('features.returnedMatches', { count: row.hits.length }) }}</span>
52
+ <span v-if="row.session.cwd" class="index-group-path" :title="row.session.cwd">{{ row.session.cwd }}</span>
53
+ </summary>
54
+ <article v-for="result in row.hits" :key="result.nodeId" class="feature-record">
55
+ <template v-if="indexResultView === 'messages'">
56
+ <header class="feature-record-heading"><h4>{{ result.session.title || result.session.sessionId }}</h4><span class="feature-source">{{ result.session.source }}</span></header>
57
+ <small class="feature-path" :title="result.session.cwd">{{ result.session.cwd }}</small>
58
+ </template>
59
+ <pre class="feature-excerpt">{{ result.snippet }}</pre>
60
+ <div class="feature-record-actions"><button type="button" class="btn-mini" @click="openIndexedMessage(result)">{{ t('features.source') }}</button><label class="evidence-select"><input type="checkbox" :checked="isEvidenceSelected(result)" @change="toggleEvidence(result)">{{ t('evidence.select') }}</label></div>
61
+ <details class="feature-disclosure"><summary>{{ t('features.context') }}</summary><pre>{{ result.before }}</pre><pre>{{ result.after }}</pre></details>
62
+ </article>
63
+ </component>
64
+ </template>
48
65
  </template>
49
66
  </div>
50
67
  <details class="feature-disclosure evidence-collections" :open="collectionsOpen" @toggle="toggleCollections($event)">