@tano.page/workbench 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/package.json +50 -16
  2. package/src/App.vue +82 -752
  3. package/src/appearance/appearance.ts +14 -4
  4. package/src/appearance/components/ThemePresetPreview.vue +52 -8
  5. package/src/appearance/interface-font.ts +99 -0
  6. package/src/appearance/theme.ts +26 -10
  7. package/src/appearance/use-interface-font.ts +30 -0
  8. package/src/assets/mail-provider-icons/NOTICE.txt +27 -0
  9. package/src/assets/mail-provider-icons/aliyun-mail.svg +3 -0
  10. package/src/assets/mail-provider-icons/gmail.svg +1 -0
  11. package/src/assets/mail-provider-icons/icloud.svg +12 -0
  12. package/src/assets/mail-provider-icons/netease-126.svg +5 -0
  13. package/src/assets/mail-provider-icons/netease-163.svg +5 -0
  14. package/src/assets/mail-provider-icons/qq.svg +9 -0
  15. package/src/assets/mail-provider-icons/tencent-exmail.svg +4 -0
  16. package/src/assistant/agent-identities.ts +1 -97
  17. package/src/assistant/agent-task-context.ts +1 -54
  18. package/src/assistant/attachments.ts +1 -1
  19. package/src/assistant/completion.ts +1 -61
  20. package/src/assistant/components/AssistantChangeList.vue +98 -21
  21. package/src/assistant/components/AssistantPanel.vue +425 -8
  22. package/src/assistant/components/PluginToolProposalCard.vue +235 -0
  23. package/src/assistant/connection-actions.ts +237 -0
  24. package/src/assistant/document-mentions.ts +1 -33
  25. package/src/assistant/engine.ts +1 -532
  26. package/src/assistant/execution.ts +6 -33
  27. package/src/assistant/files.ts +5 -13
  28. package/src/assistant/hash.ts +1 -4
  29. package/src/assistant/inbox.ts +1 -148
  30. package/src/assistant/language.ts +10 -37
  31. package/src/assistant/mention-autocomplete.ts +69 -0
  32. package/src/assistant/plugin-bridge-builder.ts +146 -0
  33. package/src/assistant/prompts.ts +1 -58
  34. package/src/assistant/proposal-actions.ts +336 -0
  35. package/src/assistant/results.ts +20 -86
  36. package/src/assistant/store.ts +167 -327
  37. package/src/assistant/structures.ts +1 -155
  38. package/src/assistant/tasks.ts +8 -96
  39. package/src/assistant/tool-rules.ts +1 -7
  40. package/src/assistant/workspace-bridge.ts +1 -1
  41. package/src/composables/use-document-actions.ts +38 -20
  42. package/src/composables/use-file-tree-controller.ts +7 -12
  43. package/src/composables/use-workbench-help.ts +177 -0
  44. package/src/composables/use-workbench-history.ts +2 -4
  45. package/src/composables/use-workbench-lifecycle.ts +249 -0
  46. package/src/composables/use-workbench-modals.ts +6 -1
  47. package/src/composables/use-workbench-outline.ts +0 -5
  48. package/src/composables/use-workbench-settings.ts +185 -0
  49. package/src/composables/use-workbench-shortcuts.ts +40 -1021
  50. package/src/composables/use-workbench-views.ts +325 -0
  51. package/src/data-tables/data-tables.ts +1 -2
  52. package/src/documents/components/DocumentActionMenu.vue +279 -0
  53. package/src/documents/components/DocumentHistoryPanel.vue +3 -1
  54. package/src/documents/components/DocumentInspector.vue +168 -0
  55. package/src/documents/components/DocumentPane.vue +482 -0
  56. package/src/documents/description-merge.ts +1 -9
  57. package/src/features.ts +1 -0
  58. package/src/files/components/FileMetadataPanel.vue +49 -15
  59. package/src/fonts/Inter-Latin-Italic.woff2 +0 -0
  60. package/src/fonts/Inter-Latin.woff2 +0 -0
  61. package/src/fonts/TanoUISansSC-Bold.woff2 +0 -0
  62. package/src/fonts/TanoUISansSC-Medium.woff2 +0 -0
  63. package/src/fonts/TanoUISansSC-Regular.woff2 +0 -0
  64. package/src/help/help-milestones.ts +3 -5
  65. package/src/i18n/locale-catalogs.ts +7 -6
  66. package/src/i18n/locale-registry.ts +8 -6
  67. package/src/i18n/locales/de-DE.json +371 -3
  68. package/src/i18n/locales/en-US.json +371 -2
  69. package/src/i18n/locales/es-ES.json +371 -3
  70. package/src/i18n/locales/ja-JP.json +370 -2
  71. package/src/i18n/locales/zh-TW.json +370 -2
  72. package/src/mail/components/MailAccountDialog.vue +450 -0
  73. package/src/mail/components/MailComposerDialog.vue +326 -0
  74. package/src/mail/components/MailProviderIcon.vue +30 -0
  75. package/src/mail/components/MailWorkspaceView.vue +821 -0
  76. package/src/mail/components/SidebarMail.vue +134 -0
  77. package/src/mail/mail-avatar.ts +17 -0
  78. package/src/mail/mail-bridge.ts +68 -0
  79. package/src/mail/mail-calendar.ts +208 -0
  80. package/src/mail/mail-markdown.ts +195 -0
  81. package/src/mail/types.ts +226 -0
  82. package/src/objects/components/ObjectDetailModal.vue +1001 -0
  83. package/src/objects/content-references.ts +6 -56
  84. package/src/objects/wiki-links.ts +1 -48
  85. package/src/objects/workspace-objects.ts +3 -4
  86. package/src/plan-sync/types.ts +6 -3
  87. package/src/plans/calendar-interaction.ts +194 -0
  88. package/src/plans/calendar.ts +65 -9
  89. package/src/plans/components/CalendarAgendaView.vue +165 -0
  90. package/src/plans/components/CalendarDayPopover.vue +172 -39
  91. package/src/plans/components/CalendarFilterBar.vue +128 -0
  92. package/src/plans/components/CalendarMonthView.vue +224 -0
  93. package/src/plans/components/CalendarQuickCreateDialog.vue +269 -0
  94. package/src/plans/components/CalendarTimelineView.vue +517 -0
  95. package/src/plans/components/CalendarTopbarControls.vue +101 -0
  96. package/src/plans/components/CalendarView.vue +264 -748
  97. package/src/plans/components/CalendarYearView.vue +138 -0
  98. package/src/plans/components/PlanArchiveDialog.vue +295 -0
  99. package/src/plans/components/PlanConnectionsDialog.vue +1 -1
  100. package/src/plans/components/PlanDateField.vue +6 -4
  101. package/src/plans/components/PlanDetailPanel.vue +227 -32
  102. package/src/plans/components/PlanEventList.vue +16 -4
  103. package/src/plans/components/SidebarPlan.vue +22 -15
  104. package/src/plans/components/TaskRepeatControls.vue +169 -30
  105. package/src/plans/components/calendar-shared.css +192 -0
  106. package/src/plans/composables/use-calendar-interactions.ts +396 -0
  107. package/src/plans/composables/use-calendar-scroll.ts +420 -0
  108. package/src/plans/local-reminders.ts +149 -0
  109. package/src/plans/personal-plans.ts +10 -1
  110. package/src/plans/plan-date.ts +8 -1
  111. package/src/plans/plan-migration.ts +95 -0
  112. package/src/plans/recurrence.ts +95 -0
  113. package/src/plans/task-repeat.ts +8 -8
  114. package/src/plans/timeline-layout.ts +92 -0
  115. package/src/plugins/assistant-bridge.ts +520 -0
  116. package/src/plugins/attachment-reader.ts +3 -1
  117. package/src/plugins/cache-storage.ts +42 -2
  118. package/src/plugins/components/PluginAutomations.vue +3 -3
  119. package/src/plugins/components/PluginCatalogBrowser.vue +17 -8
  120. package/src/plugins/components/PluginChangeSummary.vue +16 -3
  121. package/src/plugins/components/PluginConnections.vue +1 -1
  122. package/src/plugins/components/PluginCustomView.vue +2 -2
  123. package/src/plugins/components/PluginDetailPage.vue +136 -57
  124. package/src/plugins/components/PluginDeveloperArea.vue +192 -0
  125. package/src/plugins/components/PluginDocumentSlot.vue +63 -0
  126. package/src/plugins/components/PluginExplorer.vue +21 -25
  127. package/src/plugins/components/PluginImportDialog.vue +410 -0
  128. package/src/plugins/components/PluginInstaller.vue +273 -288
  129. package/src/plugins/components/PluginListItem.vue +3 -0
  130. package/src/plugins/components/PluginMaintenance.vue +37 -34
  131. package/src/plugins/components/PluginRepositoryStorage.vue +4 -2
  132. package/src/plugins/components/PluginRuntimePanel.vue +3 -3
  133. package/src/plugins/components/PluginSettingsForm.vue +112 -0
  134. package/src/plugins/components/PluginStatusBar.vue +161 -0
  135. package/src/plugins/components/PluginSurface.vue +18 -6
  136. package/src/plugins/components/PluginUiDialog.vue +452 -0
  137. package/src/plugins/components/PluginsTabPage.vue +61 -0
  138. package/src/plugins/components/plugin-center.css +5 -0
  139. package/src/plugins/data.ts +9 -86
  140. package/src/plugins/editor-plugin-adapters.ts +169 -0
  141. package/src/plugins/excalidraw/bundle.tano-plugin.json +1 -1
  142. package/src/plugins/excalidraw/manifest.json +12 -1
  143. package/src/plugins/host.ts +662 -43
  144. package/src/plugins/native.ts +2 -10
  145. package/src/plugins/overlay-mapping.ts +125 -0
  146. package/src/plugins/packages.ts +73 -1
  147. package/src/plugins/plugin-data.ts +2 -3
  148. package/src/plugins/plugin-permissions.ts +57 -0
  149. package/src/plugins/plugin-rpc-router.ts +558 -0
  150. package/src/plugins/plugin-sdk.ts +1 -94
  151. package/src/plugins/plugin-ui-dialogs.ts +167 -0
  152. package/src/plugins/policy.ts +53 -3
  153. package/src/plugins/presentation-preview/bundle.tano-plugin.json +1 -1
  154. package/src/plugins/presentation-preview/manifest.json +2 -1
  155. package/src/plugins/queries.ts +1 -73
  156. package/src/plugins/sandbox.ts +15 -1
  157. package/src/plugins/use-plugin-actions.ts +67 -20
  158. package/src/plugins/user-plugins.ts +254 -0
  159. package/src/plugins/view-header.ts +2 -7
  160. package/src/plugins/word-preview/bundle.tano-plugin.json +1 -1
  161. package/src/plugins/word-preview/manifest.json +13 -1
  162. package/src/plugins/workbench.ts +175 -2
  163. package/src/plugins/worker.js +105 -8
  164. package/src/plugins/workspace-plugin-runtime.ts +23 -7
  165. package/src/plugins/workspace-plugins.ts +212 -21
  166. package/src/runtime.ts +103 -4
  167. package/src/settings/components/SettingsAppearancePage.vue +46 -0
  168. package/src/settings/components/SettingsDocumentsPage.vue +0 -1
  169. package/src/settings/components/SettingsPanel.vue +8 -3
  170. package/src/settings/components/WorkbenchSettings.vue +20 -7
  171. package/src/settings/components/settings-context.ts +1 -1
  172. package/src/settings/components/settings-search.ts +2 -3
  173. package/src/settings/settings-tab.ts +1 -0
  174. package/src/shell/command-palette.ts +3 -3
  175. package/src/shell/components/EditorToolbar.vue +8 -9
  176. package/src/shell/components/EditorTools.vue +1 -5
  177. package/src/shell/components/PaneTopbar.vue +393 -0
  178. package/src/shell/components/SelectionToolbar.vue +0 -2
  179. package/src/shell/components/SidebarNavigation.vue +22 -2
  180. package/src/shell/components/WorkbenchContextMenus.vue +58 -34
  181. package/src/shell/components/WorkbenchModals.vue +47 -62
  182. package/src/shell/components/WorkbenchPanes.vue +371 -1342
  183. package/src/shell/components/WorkbenchSidebar.vue +486 -0
  184. package/src/shell/components/WorkspaceBreadcrumb.vue +6 -14
  185. package/src/shell/components/WorkspaceViewSwitcher.vue +12 -7
  186. package/src/shell/pane-registry.ts +69 -0
  187. package/src/shell/use-surface-dismissal.ts +219 -0
  188. package/src/shell/use-workbench-commands.ts +599 -0
  189. package/src/shell/use-workbench-keybindings.ts +337 -0
  190. package/src/shell/use-workbench.ts +531 -1153
  191. package/src/shell/workbench-async-components.ts +14 -5
  192. package/src/shell/workbench-context.ts +30 -3
  193. package/src/stores/mail.ts +414 -0
  194. package/src/stores/plan-sync.ts +2 -1
  195. package/src/stores/plans.ts +2 -9
  196. package/src/stores/workspace-document-io.ts +807 -0
  197. package/src/stores/workspace-file-ops.ts +1 -1
  198. package/src/stores/workspace-knowledge.ts +2 -114
  199. package/src/stores/workspace-lifecycle.ts +459 -0
  200. package/src/stores/workspace-plugins-state.ts +254 -259
  201. package/src/stores/workspace-session.ts +287 -0
  202. package/src/stores/workspace-tabs-layout.ts +6 -44
  203. package/src/stores/workspace-types.ts +50 -0
  204. package/src/stores/workspace.ts +184 -1363
  205. package/src/styles/agent-diff-modals.css +0 -7
  206. package/src/styles/dark-theme.css +3 -3
  207. package/src/styles/inspector.css +0 -59
  208. package/src/styles/layout-themes.css +346 -0
  209. package/src/styles/mail.css +1568 -0
  210. package/src/styles/mobile.css +2 -2
  211. package/src/styles/recent-and-media.css +0 -17
  212. package/src/styles/theme-contract.css +3 -3
  213. package/src/styles/workbench-shell.css +110 -17
  214. package/src/styles/workspace-states.css +9 -33
  215. package/src/styles.css +0 -1
  216. package/src/tabs/components/DesktopTabs.vue +19 -14
  217. package/src/tabs/components/NewTabPicker.vue +10 -4
  218. package/src/tabs/tab-label.ts +0 -1
  219. package/src/windows/AuxiliaryWindows.vue +2 -2
  220. package/src/windows/use-window-event-bridge.ts +152 -0
  221. package/src/workspace/components/TemplateLibrary.vue +1 -1
  222. package/src/workspace/components/WorkspaceGeneralSettings.vue +0 -13
  223. package/src/workspace/components/WorkspaceIconPicker.vue +30 -7
  224. package/src/workspace/components/WorkspacePickerMenu.vue +317 -0
  225. package/src/workspace/workspace-comments.ts +11 -151
  226. package/src/workspace/workspace-welcome.ts +1 -1
  227. package/src/assistant/locales/de-DE.json +0 -126
  228. package/src/assistant/locales/en-US.json +0 -126
  229. package/src/assistant/locales/es-ES.json +0 -126
  230. package/src/assistant/locales/ja-JP.json +0 -126
  231. package/src/assistant/locales/zh-CN.json +0 -126
  232. package/src/assistant/locales/zh-TW.json +0 -126
  233. package/src/assistant/task-prompts.json +0 -39
  234. package/src/documents/components/FormulaMenu.vue +0 -50
  235. package/src/files/components/FileDatabasePage.vue +0 -152
  236. package/src/files/components/FolderHomeIcon.vue +0 -12
  237. package/src/objects/components/ObjectDatabasePage.vue +0 -100
  238. package/src/objects/components/ObjectPanel.vue +0 -554
  239. package/src/plans/components/PersonalPlanDialog.vue +0 -105
  240. package/src/shell/components/WorkspaceViewPage.vue +0 -127
  241. package/src/shell/components/WorkspaceViewTab.vue +0 -24
  242. package/src/styles/object-panel.css +0 -163
  243. package/src/workspace/components/GitInspectionPanel.vue +0 -35
  244. package/src/workspace/components/WorkspaceSyncPanel.vue +0 -50
  245. package/src/workspace/welcome-slogans.ts +0 -11
  246. package/src/workspace/workspace-git.ts +0 -35
  247. package/src/workspace/workspace-sync.ts +0 -46
  248. package/src/workspace/workspace-views.ts +0 -48
@@ -1,61 +1 @@
1
- import type { AssistantActivity, AssistantTerminationReason } from '@tano/protocol';
2
-
3
- export type AssistantTextPhase = Extract<AssistantActivity, { kind: 'text' }>['phase'];
4
- export type AssistantTextSegment = { start: number; end: number; phase: AssistantTextPhase };
5
-
6
- export class AssistantRunError extends Error {
7
- constructor(public reason: AssistantTerminationReason, message: string) { super(message); }
8
- }
9
-
10
- export function responsePhase(value: unknown): AssistantTextPhase | undefined {
11
- if (value === 'commentary' || value === 'partial_answer') return 'working';
12
- if (value === 'final_answer') return 'answer';
13
- return undefined;
14
- }
15
-
16
- const markers = [
17
- { prefix: '[[tano:progress]]', phase: 'working' },
18
- { prefix: '[[tano:final]]', phase: 'answer' },
19
- ] as const;
20
-
21
- /** Only an exact leading protocol marker is interpreted; ordinary prose is never guessed. */
22
- export class AssistantTextDecoder {
23
- private buffer = '';
24
- private started = false;
25
- private afterMarker = false;
26
- phase: AssistantTextPhase = 'pending';
27
- constructor(private emit: (text: string, phase: AssistantTextPhase) => void) {}
28
- push(text: string, nativePhase?: AssistantTextPhase) {
29
- if (nativePhase) this.phase = nativePhase;
30
- if (this.started && !this.afterMarker) { this.emit(text, this.phase); return; }
31
- this.buffer += text;
32
- if (!this.started) {
33
- const marker = markers.find(marker => this.buffer.startsWith(marker.prefix));
34
- if (marker) {
35
- this.phase = nativePhase ?? marker.phase;
36
- this.buffer = this.buffer.slice(marker.prefix.length);
37
- this.afterMarker = true;
38
- } else if (markers.some(marker => marker.prefix.startsWith(this.buffer))) return;
39
- this.started = true;
40
- }
41
- if (this.afterMarker) {
42
- if (!this.buffer || this.buffer === '\r') return;
43
- this.buffer = this.buffer.replace(/^\r?\n/, '');
44
- this.afterMarker = false;
45
- }
46
- if (this.buffer) this.emit(this.buffer, this.phase);
47
- this.buffer = '';
48
- }
49
- finish() {
50
- if (!this.started && this.buffer) throw new AssistantRunError('incomplete', '模型的回答阶段标记未完整返回');
51
- if (this.buffer) this.emit(this.buffer, this.phase);
52
- this.buffer = '';
53
- }
54
- }
55
-
56
- export function decodeAssistantText(text: string, phase?: AssistantTextPhase) {
57
- let content = '';
58
- const decoder = new AssistantTextDecoder(value => { content += value; });
59
- decoder.push(text, phase); decoder.finish();
60
- return { content, phase: phase ?? decoder.phase };
61
- }
1
+ export * from '@tano/protocol/assistant-completion';
@@ -1,10 +1,12 @@
1
1
  <script setup lang="ts">
2
2
  import { t } from '../../i18n/i18n';
3
- import { computed, ref } from 'vue';
4
- import { Check, ChevronRight, FileText, Pencil, Search, Undo2, X } from 'lucide-vue-next';
3
+ import { computed, ref, watch } from 'vue';
4
+ import { Check, ChevronRight, FileText, Pencil, Plug, Search, Undo2, X } from 'lucide-vue-next';
5
5
  import type { AssistantProposal, ReferenceIdentity } from '@tano/protocol';
6
6
  import { isDataTableFilePath } from '@tano/protocol';
7
+ import { resolveAssistantExtension, useWorkbenchRuntime, type WorkbenchAssistantProposalCardDescriptor } from '../../runtime';
7
8
  import ChangeDiff from './ChangeDiff.vue';
9
+ import PluginToolProposalCard from './PluginToolProposalCard.vue';
8
10
  import TaskProposalPreview from './TaskProposalPreview.vue';
9
11
 
10
12
  const props = defineProps<{ proposals: AssistantProposal[]; busy: boolean }>();
@@ -12,66 +14,140 @@ const emit = defineEmits<{
12
14
  review: [proposal: AssistantProposal, apply?: boolean]; reject: [proposal: AssistantProposal];
13
15
  verify: [proposal: AssistantProposal]; undo: [proposal: AssistantProposal];
14
16
  suggestions: [proposal: AssistantProposal]; openReference: [identity: ReferenceIdentity];
17
+ sendFollowUp: [payload: { prompt: string; autoSend?: boolean }];
15
18
  }>();
16
19
  const checks = ref<Record<string, boolean>>({});
17
20
  const expanded = ref<Record<string, boolean>>({});
21
+ const assistantExtension = computed(() => {
22
+ try {
23
+ return resolveAssistantExtension(useWorkbenchRuntime());
24
+ } catch {
25
+ return undefined;
26
+ }
27
+ });
28
+ const isPluginOrExtension = (proposal: AssistantProposal) =>
29
+ proposal.kind === 'plugin' || proposal.kind === 'extension';
30
+ const proposalEffect = (proposal: AssistantProposal) =>
31
+ proposal.kind === 'extension' ? proposal.extensionAction?.effect : proposal.pluginAction?.effect;
32
+ function extensionCard(proposal: AssistantProposal): WorkbenchAssistantProposalCardDescriptor | undefined {
33
+ return isPluginOrExtension(proposal) ? assistantExtension.value?.proposalCard?.(proposal) : undefined;
34
+ }
18
35
  const statuses = { ready: '', get applying() { return t('正在应用'); }, applied: '', get rejected() { return t('已放弃'); }, get conflicted() { return t('存在冲突'); }, get unknown() { return t('结果待核对'); } };
19
- const labels = { get create() { return t('新增'); }, get edit() { return t('修改'); }, get delete() { return t('删除'); }, get rename() { return t('重命名'); }, get move() { return t('移动'); }, get object() { return t('对象'); }, get relation() { return t('关系'); } };
20
- const isFile = (proposal: AssistantProposal) => !['object', 'relation'].includes(proposal.kind);
21
- const canUndo = (proposal: AssistantProposal) => proposal.status === 'applied' &&
22
- (proposal.kind === 'edit' || proposal.kind === 'create' && !isDataTableFilePath(proposal.path));
36
+ const labels = { get create() { return t('新增'); }, get edit() { return t('修改'); }, get delete() { return t('删除'); }, get rename() { return t('重命名'); }, get move() { return t('移动'); }, get object() { return t('对象'); }, get relation() { return t('关系'); }, get plugin() { return t('插件操作'); }, get extension() { return t('扩展操作'); } };
37
+ const isFile = (proposal: AssistantProposal) => !['object', 'relation', 'plugin', 'extension'].includes(proposal.kind);
38
+ const canUndo = (proposal: AssistantProposal) => {
39
+ if (proposal.status !== 'applied') return false;
40
+ if (isPluginOrExtension(proposal)) return !!assistantExtension.value?.canUndoProposal?.(proposal);
41
+ return proposal.kind === 'edit' || (proposal.kind === 'create' && !isDataTableFilePath(proposal.path));
42
+ };
23
43
  const groups = computed(() => {
24
44
  const result = new Map<string, { key: string; file: boolean; proposals: AssistantProposal[] }>();
25
45
  for (const proposal of props.proposals) {
26
46
  const file = isFile(proposal);
27
- const key = file ? `file:${proposal.fileId ?? proposal.applied?.fileId ?? proposal.path}` : `${proposal.kind}:${proposal.fileId ?? proposal.path}`;
47
+ const key = file
48
+ ? `file:${proposal.fileId ?? proposal.applied?.fileId ?? proposal.path}`
49
+ : isPluginOrExtension(proposal)
50
+ ? `${proposal.kind}:${proposal.id}`
51
+ : `${proposal.kind}:${proposal.fileId ?? proposal.path}`;
28
52
  if (!result.has(key)) result.set(key, { key, file, proposals: [] });
29
53
  result.get(key)!.proposals.push(proposal);
30
54
  }
31
55
  return [...result.values()];
32
56
  });
33
57
  const fileCount = computed(() => groups.value.filter(group => group.file).length);
34
- const groupLabel = (proposals: AssistantProposal[]) => [...new Set(proposals.map(proposal => labels[proposal.kind]))].join('、');
58
+ const proposalKindLabel = (proposal: AssistantProposal) => {
59
+ if (isPluginOrExtension(proposal)) {
60
+ const custom = extensionCard(proposal);
61
+ if (custom?.kindLabel) return custom.kindLabel;
62
+ if (proposal.kind === 'extension') {
63
+ return proposal.extensionAction?.label || (proposalEffect(proposal) === 'external' ? t('外部调用') : t('扩展操作'));
64
+ }
65
+ return proposalEffect(proposal) === 'external' ? t('外部调用') : t('插件写入');
66
+ }
67
+ return labels[proposal.kind];
68
+ };
69
+ const groupLabel = (proposals: AssistantProposal[]) => [...new Set(proposals.map(proposalKindLabel))].join('、');
35
70
  const proposalStatus = (proposal: AssistantProposal) => proposal.suggestionGroupId ? t('文档中审阅') : proposal.execution === 'direct' && proposal.status === 'ready' ? t('未完成') : statuses[proposal.status];
36
71
  const groupStatus = (proposals: AssistantProposal[]) => [...new Set(proposals.map(proposalStatus).filter(Boolean))].join(' · ');
72
+ function defaultGroupOpen(group: { key: string; file: boolean; proposals: AssistantProposal[] }): boolean {
73
+ return !group.file && group.proposals.some(proposal => {
74
+ if (!isPluginOrExtension(proposal)) return false;
75
+ const custom = extensionCard(proposal);
76
+ return custom ? custom.defaultOpen !== false : true;
77
+ });
78
+ }
79
+ watch(groups, list => {
80
+ for (const group of list) {
81
+ if (!Object.prototype.hasOwnProperty.call(expanded.value, group.key) && defaultGroupOpen(group)) {
82
+ expanded.value[group.key] = true;
83
+ }
84
+ }
85
+ }, { immediate: true });
86
+ function applyButtonLabel(proposal: AssistantProposal): string {
87
+ if (proposal.kind === 'delete') return t('删除文件');
88
+ if (proposal.kind === 'rename') return t('应用重命名');
89
+ if (proposal.kind === 'move') return t('应用移动');
90
+ if (isPluginOrExtension(proposal)) {
91
+ const custom = extensionCard(proposal);
92
+ if (custom?.applyLabel) return custom.applyLabel;
93
+ if (proposal.kind === 'extension') {
94
+ return proposal.extensionAction?.label || (proposalEffect(proposal) === 'external' ? t('确认发起外部调用') : t('确认执行扩展操作'));
95
+ }
96
+ return proposalEffect(proposal) === 'external' ? t('确认发起外部调用') : t('确认执行插件操作');
97
+ }
98
+ return t('应用修改');
99
+ }
37
100
  </script>
38
101
 
39
102
  <template>
40
103
  <section v-if="proposals.length" class="assistant-change-list" :aria-label="t('本轮文件变更清单')">
41
104
  <header>
42
105
  <div class="change-list-heading">
43
- <strong>{{ fileCount ? t('文件变更') : t('工作区变更') }}</strong><span>{{ fileCount }} {{ t('个文件 ·') }} {{ proposals.length }} {{ t('项操作') }}</span>
106
+ <strong>{{ fileCount ? t('文件变更') : t('工作区变更') }}</strong>
107
+ <span v-if="fileCount">{{ fileCount }} {{ t('个文件 ·') }} {{ proposals.length }} {{ t('项操作') }}</span>
108
+ <span v-else>{{ proposals.length }} {{ t('项操作') }}</span>
44
109
  </div>
45
110
  </header>
46
- <details v-for="group in groups" :key="group.key" class="assistant-file-change" @toggle="expanded[group.key] = ($event.target as HTMLDetailsElement).open">
111
+ <details v-for="group in groups" :key="group.key" class="assistant-file-change" v-bind="defaultGroupOpen(group) ? { open: true } : {}" @toggle="expanded[group.key] = ($event.target as HTMLDetailsElement).open">
47
112
  <summary>
48
- <ChevronRight class="change-chevron" :size="14" /><FileText :size="14" />
113
+ <ChevronRight class="change-chevron" :size="14" /><Plug v-if="isPluginOrExtension(group.proposals[0])" :size="14" /><FileText v-else :size="14" />
49
114
  <span class="change-file-heading">
50
115
  <span class="change-file-name">{{ group.proposals[0].preview?.path ?? group.proposals[0].path }}<span v-if="group.proposals.some(proposal => proposal.destination)" class="change-destination">→ {{ group.proposals.filter(proposal => proposal.destination).at(-1)?.destination }}</span></span>
51
- <span class="change-kind" :class="`change-kind-${group.proposals[0].kind}`">{{ groupLabel(group.proposals) }}</span>
116
+ <span class="change-kind" :class="[`change-kind-${group.proposals[0].kind}`, proposalEffect(group.proposals[0]) === 'external' ? 'change-kind-external' : '']">{{ groupLabel(group.proposals) }}</span>
52
117
  <small v-if="groupStatus(group.proposals)" class="change-file-status">{{ groupStatus(group.proposals) }}</small>
53
118
  </span>
54
- <button v-if="group.proposals.length === 1 && canUndo(group.proposals[0])" class="change-undo-action" :disabled="busy" @click.stop.prevent="emit('undo', group.proposals[0])"><Undo2 :size="14" />{{ t('撤回内容') }}</button>
119
+ <button v-if="group.proposals.length === 1 && canUndo(group.proposals[0])" class="change-undo-action" :disabled="busy" @click.stop.prevent="emit('undo', group.proposals[0])"><Undo2 :size="14" />{{ isPluginOrExtension(group.proposals[0]) ? t('撤回') : t('撤回内容') }}</button>
55
120
  </summary>
56
121
  <div v-if="expanded[group.key]" class="change-file-details">
57
122
  <section v-for="proposal in group.proposals" :key="proposal.id" class="assistant-proposal" :aria-label="t('修改建议 {0}', [proposal.path])">
58
123
  <div class="assistant-proposal-heading">
59
- <strong>{{ labels[proposal.kind] }} · {{ proposal.preview?.path ?? proposal.path }}</strong><small v-if="group.proposals.length > 1 && proposalStatus(proposal)">{{ proposalStatus(proposal) }}</small>
60
- <button v-if="group.proposals.length > 1 && canUndo(proposal)" class="change-undo-action" :disabled="busy" @click="emit('undo', proposal)"><Undo2 :size="14" />{{ t('撤回内容') }}</button>
124
+ <strong>{{ proposalKindLabel(proposal) }} · {{ proposal.preview?.path ?? proposal.path }}</strong><small v-if="group.proposals.length > 1 && proposalStatus(proposal)">{{ proposalStatus(proposal) }}</small>
125
+ <button v-if="group.proposals.length > 1 && canUndo(proposal)" class="change-undo-action" :disabled="busy" @click="emit('undo', proposal)"><Undo2 :size="14" />{{ isPluginOrExtension(proposal) ? t('撤回') : t('撤回内容') }}</button>
61
126
  </div>
62
127
  <p v-if="proposal.destination" class="proposal-path">{{ proposal.preview?.path ?? proposal.path }} → {{ proposal.destination }}</p>
63
128
  <p>{{ proposal.reason }}</p>
64
129
  <p v-if="proposal.kind === 'delete'" class="delete-note">{{ proposal.status === 'applied' ? t('文件已删除。') : t('将删除此文件。') }}{{ t('桌面文件可从回收站恢复;浏览器演示存储会直接删除。') }}</p>
65
- <TaskProposalPreview v-if="!group.file" :proposal="proposal" @open-reference="emit('openReference', $event)" @ready="checks[proposal.id] = $event" />
130
+ <TaskProposalPreview v-if="!group.file && !isPluginOrExtension(proposal)" :proposal="proposal" @open-reference="emit('openReference', $event)" @ready="checks[proposal.id] = $event" />
131
+ <component
132
+ :is="extensionCard(proposal)!.component"
133
+ v-if="isPluginOrExtension(proposal) && extensionCard(proposal)"
134
+ :proposal="proposal"
135
+ :busy="busy"
136
+ @review="(target: AssistantProposal, apply?: boolean) => emit('review', target, apply)"
137
+ @reject="(target: AssistantProposal) => emit('reject', target)"
138
+ @undo="(target: AssistantProposal) => emit('undo', target)"
139
+ @send-follow-up="(payload: { prompt: string; autoSend?: boolean }) => emit('sendFollowUp', payload)"
140
+ />
141
+ <PluginToolProposalCard v-else-if="proposal.kind === 'plugin'" :proposal="proposal" :busy="busy" />
66
142
  <p v-if="proposal.error" class="assistant-message-error" role="alert">{{ proposal.error }}</p>
67
143
  <p v-if="['rename', 'move'].includes(proposal.kind)" class="panel-hint">{{ t('文件内容保持不变。') }}</p>
68
- <ChangeDiff v-else :before="proposal.applied?.before ?? proposal.preview?.before ?? proposal.base" :after="proposal.applied?.after ?? proposal.preview?.after ?? proposal.content"
69
- :before-label="proposal.kind === 'create' ? t('尚未创建') : t('修改前')" :after-label="proposal.kind === 'delete' ? t('文件删除') : t('修改后')" />
70
- <div v-if="['ready', 'conflicted', 'unknown'].includes(proposal.status)" class="assistant-proposal-actions">
144
+ <ChangeDiff v-else-if="!isPluginOrExtension(proposal) || extensionCard(proposal)?.hideDefaultDiff === false" :before="proposal.applied?.before ?? proposal.preview?.before ?? proposal.base" :after="proposal.applied?.after ?? proposal.preview?.after ?? proposal.content"
145
+ :before-label="proposal.kind === 'create' ? t('尚未创建') : isPluginOrExtension(proposal) ? t('执行前') : t('修改前')" :after-label="proposal.kind === 'delete' ? t('文件删除') : isPluginOrExtension(proposal) ? (proposal.status === 'applied' ? t('执行结果') : t('调用参数')) : t('修改后')" />
146
+ <div v-if="['ready', 'conflicted', 'unknown'].includes(proposal.status) && !extensionCard(proposal)?.hideDefaultActions" class="assistant-proposal-actions">
71
147
  <button v-if="proposal.kind === 'edit' && !isDataTableFilePath(proposal.path) && ['ready', 'conflicted'].includes(proposal.status)" class="secondary-button" :disabled="busy" @click="emit('suggestions', proposal)"><Pencil :size="14" />{{ proposal.suggestionGroupId ? t('打开文档建议') : t('在文档中逐项审阅') }}</button>
72
148
  <template v-if="!proposal.suggestionGroupId && ['ready', 'conflicted'].includes(proposal.status)">
73
- <button class="secondary-button" :disabled="busy" @click="emit('review', proposal)"><Search :size="14" />{{ t('查看差异') }}</button>
74
- <button v-if="proposal.preview && proposal.status === 'ready'" class="primary-button" :class="{ destructive: proposal.kind === 'delete' }" :disabled="busy || checks[proposal.id] === false" @click="emit('review', proposal, true)"><Check :size="14" />{{ proposal.kind === 'delete' ? t('删除文件') : proposal.kind === 'rename' ? t('应用重命名') : proposal.kind === 'move' ? t('应用移动') : t('应用修改') }}</button>
149
+ <button v-if="!isPluginOrExtension(proposal)" class="secondary-button" :disabled="busy" @click="emit('review', proposal)"><Search :size="14" />{{ t('查看差异') }}</button>
150
+ <button v-if="(proposal.preview || isPluginOrExtension(proposal)) && proposal.status === 'ready'" class="primary-button" :class="{ destructive: proposal.kind === 'delete' }" :disabled="busy || checks[proposal.id] === false" @click="emit('review', proposal, true)"><Check :size="14" />{{ applyButtonLabel(proposal) }}</button>
75
151
  <button class="icon-button" :data-tooltip="t('放弃建议')" :aria-label="t('放弃修改建议')" :disabled="busy" @click="emit('reject', proposal)"><X :size="15" /></button>
76
152
  </template>
77
153
  <button v-if="proposal.status === 'unknown'" class="secondary-button" :disabled="busy" @click="emit('verify', proposal)"><Search :size="14" />{{ t('核对写入结果') }}</button>
@@ -101,6 +177,7 @@ details[open] .change-chevron { transform: rotate(90deg); }
101
177
  .change-destination { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
102
178
  .change-kind { font-size: 10px; border-radius: 4px; padding: 2px 5px; background: var(--accent); color: var(--muted); }
103
179
  .change-kind-create { color: var(--green); }
180
+ .change-kind-external { color: var(--warning, #9a620b); }
104
181
  .change-kind-delete, .delete-note, .assistant-message-error { color: var(--danger); }
105
182
  .change-file-details { padding: 0 12px 12px; }
106
183
  .assistant-proposal + .assistant-proposal { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }