dsh-plugin-trim 0.0.0-stage → 0.2.5
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/LICENSE +21 -0
- package/README.md +108 -2
- package/client.js +1540 -0
- package/cordis.patch.yml +4 -0
- package/dist/index.d.ts +663 -0
- package/dist/index.js +4676 -0
- package/icon.png +0 -0
- package/package.json +102 -4
package/client.js
ADDED
|
@@ -0,0 +1,1540 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: 'dsh-plugin-trim',
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} }
|
|
5
|
+
var exports = module.exports
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
|
|
7
|
+
|
|
8
|
+
const React = require('react')
|
|
9
|
+
const { useState, useEffect, useCallback, useMemo } = React
|
|
10
|
+
const h = React.createElement
|
|
11
|
+
|
|
12
|
+
const API = '/api/dsh-experience-optimizer'
|
|
13
|
+
const RECIPE_API = API + '/recipe'
|
|
14
|
+
const CSS_ID = 'dsh-experience-optimizer-ui'
|
|
15
|
+
const TASK_TAGS = [
|
|
16
|
+
['unknown', '自动识别'],
|
|
17
|
+
['bugfix', '修 Bug'],
|
|
18
|
+
['feature', '新功能'],
|
|
19
|
+
['review', '代码审查'],
|
|
20
|
+
['docs', '文档'],
|
|
21
|
+
['release', '发布'],
|
|
22
|
+
['report', '报告 / 周报'],
|
|
23
|
+
['research', '调研'],
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
const CSS = `
|
|
27
|
+
.eo-root{--eo-primary:var(--dsw-alias-label-primary,#1a1a1a);--eo-secondary:var(--dsw-alias-label-secondary,#5f6b7a);--eo-tertiary:var(--dsw-alias-label-tertiary,#8b96a5);--eo-border:var(--dsw-alias-border-l2,rgba(127,127,127,.16));--eo-border-strong:var(--dsw-alias-border-l3,rgba(127,127,127,.24));--eo-card-bg:var(--dsw-alias-settings-card-fill,transparent);--eo-card-stroke:var(--dsw-alias-settings-card-stroke,var(--dsw-alias-border-l2,rgba(127,127,127,.16)));--eo-hover:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.06));--eo-error:var(--dsw-alias-state-error-primary,#c4314b);--eo-success:var(--dsw-alias-state-success-primary,#1a7f37);--eo-code:var(--ds-font-family-code,"JetBrains Maple Mono",ui-monospace,monospace);--eo-radius:var(--dsw-radius-lg,12px);max-width:760px;color:var(--eo-primary);font-size:13px;line-height:20px;display:flex;flex-direction:column;gap:14px}
|
|
28
|
+
.eo-root *{box-sizing:border-box}
|
|
29
|
+
.eo-hero{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;padding:0 0 2px}
|
|
30
|
+
.eo-hero-copy{min-width:0}
|
|
31
|
+
.eo-title{margin:0;font-size:18px;line-height:26px;font-weight:600;letter-spacing:-.01em}
|
|
32
|
+
.eo-sub{margin:4px 0 0;color:var(--eo-tertiary);font-size:13px;line-height:20px}
|
|
33
|
+
.eo-hero-actions{display:flex;align-items:center;gap:8px;flex:0 0 auto}
|
|
34
|
+
.eo-status{font:400 11px/1 var(--eo-code);color:var(--eo-tertiary);max-width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
35
|
+
.eo-tabs{display:flex;gap:18px;border-bottom:.5px solid var(--eo-border);margin:0}
|
|
36
|
+
.eo-tab{appearance:none;border:0;background:transparent;color:var(--eo-tertiary);font:inherit;font-size:13px;line-height:20px;padding:7px 1px 9px;cursor:pointer;position:relative;border-radius:0}
|
|
37
|
+
.eo-tab:hover{color:var(--eo-primary)}
|
|
38
|
+
.eo-tab-active{color:var(--eo-primary);font-weight:500}
|
|
39
|
+
.eo-tab-active:after{content:"";position:absolute;left:0;right:0;bottom:-1px;height:1.5px;background:var(--eo-primary);border-radius:1px}
|
|
40
|
+
.eo-stack{display:flex;flex-direction:column;gap:14px}
|
|
41
|
+
.eo-stack>.eo-metrics{order:0}
|
|
42
|
+
.eo-stack>[data-section="draft"]{order:1}
|
|
43
|
+
.eo-stack>[data-section="compat"]{order:2}
|
|
44
|
+
.eo-stack>[data-section="context"]{order:3}
|
|
45
|
+
.eo-stack>[data-section="result"]{order:4}
|
|
46
|
+
.eo-stack>[data-section="dedupe"]{order:5}
|
|
47
|
+
.eo-stack>[data-section="diagnostics"]{order:6}
|
|
48
|
+
.eo-grid{display:grid;gap:10px}
|
|
49
|
+
.eo-metrics{grid-template-columns:repeat(4,minmax(0,1fr));gap:0;border:.5px solid var(--eo-card-stroke);border-radius:var(--eo-radius);background:var(--eo-card-bg);overflow:hidden}
|
|
50
|
+
.eo-metric{padding:12px 14px;border-right:.5px solid var(--eo-border);min-width:0}
|
|
51
|
+
.eo-metric:last-child{border-right:0}
|
|
52
|
+
.eo-metric-label{font-size:11px;line-height:16px;color:var(--eo-tertiary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
53
|
+
.eo-metric-value{font-size:18px;line-height:26px;font-weight:600;letter-spacing:-.02em;margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
54
|
+
.eo-metric-value[data-tone="danger"]{color:var(--eo-error)}
|
|
55
|
+
.eo-metric-value[data-tone="warn"]{color:var(--dsw-alias-state-warning-primary,#9a6700)}
|
|
56
|
+
.eo-metric-value[data-tone="ok"]{color:var(--eo-success)}
|
|
57
|
+
.eo-metric-hint{font-size:11px;line-height:16px;color:var(--eo-tertiary);margin-top:1px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
58
|
+
.eo-card{padding:14px;border:.5px solid var(--eo-card-stroke);border-radius:var(--eo-radius);background:var(--eo-card-bg)}
|
|
59
|
+
.eo-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:10px}
|
|
60
|
+
.eo-card-title{margin:0;font-size:14px;line-height:22px;font-weight:500;letter-spacing:0}
|
|
61
|
+
.eo-card-sub{margin:2px 0 0;font-size:12px;line-height:18px;color:var(--eo-tertiary)}
|
|
62
|
+
.eo-btn{appearance:none;height:32px;padding:0 12px;border:.5px solid var(--eo-border-strong);border-radius:var(--dsw-radius-md,8px);background:transparent;color:var(--eo-primary);font:inherit;font-size:13px;line-height:20px;font-weight:500;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:6px;white-space:nowrap;transition:background .14s ease,border-color .14s ease,opacity .14s ease}
|
|
63
|
+
.eo-btn:hover:not(:disabled){background:var(--eo-hover)}
|
|
64
|
+
.eo-btn:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary,#1a1a1a));outline-offset:2px}
|
|
65
|
+
.eo-btn:disabled{opacity:.4;cursor:not-allowed}
|
|
66
|
+
.eo-btn-accent{background:var(--dsw-alias-button-primary-fill,var(--eo-primary));border-color:var(--dsw-alias-button-primary-fill,var(--eo-primary));color:var(--dsw-alias-label-primary-inverted,#fff)}
|
|
67
|
+
.eo-btn-accent:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover,var(--eo-primary));border-color:var(--dsw-alias-button-primary-hover,var(--eo-primary));opacity:1}
|
|
68
|
+
.eo-btn-ghost{border-color:transparent;color:var(--eo-secondary);padding:0 8px}
|
|
69
|
+
.eo-btn-ghost:hover:not(:disabled){background:var(--eo-hover);color:var(--eo-primary)}
|
|
70
|
+
.eo-btn-danger{color:var(--eo-error);border-color:var(--dsw-alias-state-error-primary,var(--eo-error))}
|
|
71
|
+
.eo-badge{display:inline-flex;align-items:center;gap:4px;font:400 11px/16px var(--eo-code);padding:0 6px;border-radius:var(--dsw-radius-xs,4px);background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.08));color:var(--eo-secondary);border:0;white-space:nowrap}
|
|
72
|
+
.eo-badge-ok{color:var(--eo-success)}
|
|
73
|
+
.eo-badge-warn{color:var(--dsw-alias-state-warning-primary,#9a6700)}
|
|
74
|
+
.eo-badge-danger{color:var(--eo-error)}
|
|
75
|
+
.eo-badge-info{color:var(--dsw-alias-state-business-primary,#1a5fb4)}
|
|
76
|
+
.eo-dot{width:6px;height:6px;border-radius:50%;display:inline-block;flex:0 0 auto}
|
|
77
|
+
.eo-dot-error{background:var(--eo-error)}
|
|
78
|
+
.eo-dot-warn{background:var(--dsw-alias-state-warning-primary,#c98a00)}
|
|
79
|
+
.eo-dot-info{background:var(--dsw-alias-state-business-primary,#4a7fd6)}
|
|
80
|
+
.eo-toolbar{display:flex;gap:8px;align-items:flex-end;flex-wrap:wrap}
|
|
81
|
+
.eo-toolbar .eo-field{min-width:140px;flex:1}
|
|
82
|
+
.eo-field{display:flex;flex-direction:column;gap:4px;min-width:0}
|
|
83
|
+
.eo-field-label{font-size:12px;line-height:18px;font-weight:500;color:var(--eo-secondary)}
|
|
84
|
+
.eo-field-hint{font-size:11px;line-height:16px;color:var(--eo-tertiary)}
|
|
85
|
+
.eo-input,.eo-select,.eo-textarea{width:100%;height:36px;border:.5px solid var(--dsw-alias-border-l4,var(--eo-border-strong));border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-1,transparent);color:var(--eo-primary);padding:0 10px;font:inherit;font-size:13px;line-height:20px;outline:none}
|
|
86
|
+
.eo-input::placeholder,.eo-textarea::placeholder{color:var(--eo-tertiary)}
|
|
87
|
+
.eo-input:focus,.eo-select:focus,.eo-textarea:focus{border-color:var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary,#1a1a1a));box-shadow:0 0 0 2px color-mix(in srgb,var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary,#1a1a1a)) 16%,transparent)}
|
|
88
|
+
.eo-textarea{height:auto;min-height:76px;padding:8px 10px;resize:vertical}
|
|
89
|
+
.eo-form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
|
|
90
|
+
.eo-form-grid .eo-wide{grid-column:1/-1}
|
|
91
|
+
.eo-summary{display:flex;gap:6px;flex-wrap:wrap;margin:0 0 10px}
|
|
92
|
+
.eo-list{display:flex;flex-direction:column;gap:0}
|
|
93
|
+
.eo-item{display:flex;gap:10px;align-items:flex-start;padding:10px 0;border:0;border-bottom:.5px solid var(--eo-border);border-radius:0;background:transparent}
|
|
94
|
+
.eo-item:first-child{padding-top:0}
|
|
95
|
+
.eo-item:last-child{border-bottom:0}
|
|
96
|
+
.eo-item:hover{background:transparent}
|
|
97
|
+
.eo-item input[type=checkbox]{margin-top:3px;accent-color:var(--eo-primary);width:14px;height:14px;cursor:pointer;flex:0 0 auto}
|
|
98
|
+
.eo-item-main{min-width:0;flex:1}
|
|
99
|
+
.eo-item-title{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
|
|
100
|
+
.eo-item-name{font-size:13px;line-height:20px;font-weight:500;word-break:break-all}
|
|
101
|
+
.eo-item-reason{margin-top:2px;color:var(--eo-tertiary);font-size:12px;line-height:18px}
|
|
102
|
+
.eo-item-evidence{display:flex;flex-wrap:wrap;gap:8px;margin-top:3px}
|
|
103
|
+
.eo-evidence{font-size:11px;line-height:16px;color:var(--eo-tertiary);background:transparent;border:0;padding:0}
|
|
104
|
+
.eo-evidence:before{content:"·";margin-right:4px;color:var(--eo-tertiary)}
|
|
105
|
+
.eo-item-side{display:none}
|
|
106
|
+
.eo-lock{display:none}
|
|
107
|
+
.eo-applybar{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;margin-top:12px;padding-top:12px;border-top:.5px solid var(--eo-border)}
|
|
108
|
+
.eo-applybar-text{font-size:12px;line-height:18px;color:var(--eo-tertiary)}
|
|
109
|
+
.eo-findings{display:flex;flex-direction:column;gap:0}
|
|
110
|
+
.eo-finding{display:flex;gap:8px;padding:10px 0;border-bottom:.5px solid var(--eo-border)}
|
|
111
|
+
.eo-finding:first-child{padding-top:0}
|
|
112
|
+
.eo-finding:last-child{border-bottom:0;padding-bottom:0}
|
|
113
|
+
.eo-finding-body{min-width:0;flex:1}
|
|
114
|
+
.eo-finding-title{font-size:13px;line-height:20px;font-weight:500}
|
|
115
|
+
.eo-finding-title code{font:400 11px/16px var(--eo-code);color:var(--eo-secondary);background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.08));border:0;padding:0 5px;border-radius:var(--dsw-radius-xs,4px);margin-right:6px}
|
|
116
|
+
.eo-finding-meta{font-size:12px;line-height:18px;color:var(--eo-tertiary);margin-top:1px;word-break:break-word}
|
|
117
|
+
.eo-finding-fix{font-size:12px;line-height:18px;color:var(--eo-tertiary);margin-top:2px}
|
|
118
|
+
.eo-empty{padding:16px;text-align:center;color:var(--eo-tertiary);font-size:12px;line-height:18px;border:.5px dashed var(--eo-border-strong);border-radius:var(--dsw-radius-md,8px)}
|
|
119
|
+
.eo-table{width:100%;border-collapse:collapse;font-size:12px;line-height:18px}
|
|
120
|
+
.eo-table th{text-align:left;font-weight:500;color:var(--eo-tertiary);font-size:11px;line-height:16px;padding:0 8px 7px 0;border-bottom:.5px solid var(--eo-border)}
|
|
121
|
+
.eo-table td{padding:7px 8px 7px 0;border-bottom:.5px solid var(--eo-border);vertical-align:top}
|
|
122
|
+
.eo-table tr:last-child td{border-bottom:0}
|
|
123
|
+
.eo-table code{font:400 11px/16px var(--eo-code);color:var(--eo-secondary)}
|
|
124
|
+
.eo-owner-list{display:flex;flex-direction:column;gap:7px}
|
|
125
|
+
.eo-owner-head{display:flex;justify-content:space-between;gap:10px;font-size:12px;line-height:18px;color:var(--eo-tertiary)}
|
|
126
|
+
.eo-owner-head span:first-child{font-family:var(--eo-code);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
127
|
+
.eo-bar{height:3px;border-radius:3px;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.1));margin-top:4px;overflow:hidden}
|
|
128
|
+
.eo-bar i{display:block;height:100%;border-radius:3px;background:var(--eo-primary);opacity:.55}
|
|
129
|
+
.eo-issue{display:flex;gap:8px;align-items:flex-start;padding:8px 10px;border-radius:var(--dsw-radius-md,8px);font-size:12px;line-height:18px;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.06));border:.5px solid var(--eo-border)}
|
|
130
|
+
.eo-issue-error{border-color:color-mix(in srgb,var(--eo-error) 35%,transparent);color:var(--eo-error)}
|
|
131
|
+
.eo-issue-warn{border-color:color-mix(in srgb,var(--dsw-alias-state-warning-primary,#9a6700) 35%,transparent)}
|
|
132
|
+
.eo-issue code{font:400 11px/16px var(--eo-code);color:var(--eo-secondary);margin-right:4px}
|
|
133
|
+
.eo-modal-backdrop{position:fixed;inset:0;background:var(--dsw-alias-bg-mask-1,rgba(0,0,0,.36));display:grid;place-items:center;z-index:80;padding:20px}
|
|
134
|
+
.eo-modal{width:min(520px,100%);max-height:80vh;overflow:auto;border-radius:var(--dsw-radius-xl,16px);background:var(--dsw-alias-bg-layer-1,#fff);border:.5px solid var(--eo-border-strong);box-shadow:0 16px 48px rgba(0,0,0,.18);padding:18px}
|
|
135
|
+
.eo-modal h3{margin:0 0 6px;font-size:16px;line-height:24px;font-weight:600}
|
|
136
|
+
.eo-modal p{color:var(--eo-tertiary);font-size:12px;line-height:18px;margin:0 0 10px}
|
|
137
|
+
.eo-modal-list{display:flex;flex-direction:column;gap:0;margin:8px 0 12px;max-height:34vh;overflow:auto}
|
|
138
|
+
.eo-modal-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:14px}
|
|
139
|
+
.eo-toast{position:fixed;right:20px;bottom:20px;z-index:90;max-width:360px;padding:9px 12px;border-radius:var(--dsw-radius-md,8px);font-size:12px;line-height:18px;background:var(--dsw-alias-bg-layer-1,#fff);border:.5px solid var(--eo-border-strong);box-shadow:0 8px 30px rgba(0,0,0,.16);animation:eo-in .16s ease}
|
|
140
|
+
.eo-toast-ok{border-color:color-mix(in srgb,var(--eo-success) 45%,transparent)}
|
|
141
|
+
.eo-toast-warn{border-color:color-mix(in srgb,var(--dsw-alias-state-warning-primary,#9a6700) 45%,transparent)}
|
|
142
|
+
.eo-toast-error{border-color:color-mix(in srgb,var(--eo-error) 45%,transparent)}
|
|
143
|
+
.eo-loading{display:flex;align-items:center;justify-content:center;gap:8px;padding:24px;color:var(--eo-tertiary);font-size:12px}
|
|
144
|
+
.eo-spinner{width:13px;height:13px;border-radius:50%;border:2px solid var(--eo-border-strong);border-top-color:var(--eo-primary);animation:eo-spin .8s linear infinite}
|
|
145
|
+
.eo-error{padding:10px 12px;border-radius:var(--dsw-radius-md,8px);background:color-mix(in srgb,var(--eo-error) 7%,transparent);border:.5px solid color-mix(in srgb,var(--eo-error) 35%,transparent);color:var(--eo-error);font-size:12px;line-height:18px;display:flex;gap:10px;align-items:center;justify-content:space-between}
|
|
146
|
+
.eo-muted{color:var(--eo-tertiary);font-size:12px;line-height:18px}
|
|
147
|
+
.eo-code{font:400 11px/16px var(--eo-code);color:var(--eo-secondary);word-break:break-all}
|
|
148
|
+
.eo-inline{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
|
|
149
|
+
.eo-spacer{height:0}
|
|
150
|
+
@keyframes eo-spin{to{transform:rotate(360deg)}}
|
|
151
|
+
@keyframes eo-in{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
|
|
152
|
+
@media(max-width:820px){.eo-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.eo-metric:nth-child(2){border-right:0}.eo-metric:nth-child(-n+2){border-bottom:.5px solid var(--eo-border)}.eo-form-grid{grid-template-columns:1fr}.eo-hero{flex-wrap:wrap}.eo-hero-actions{margin-left:0}}
|
|
153
|
+
@media(max-width:520px){.eo-metrics{grid-template-columns:1fr}.eo-metric{border-right:0;border-bottom:.5px solid var(--eo-border)}.eo-metric:last-child{border-bottom:0}}
|
|
154
|
+
`
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
function injectCss() {
|
|
158
|
+
if (typeof document === 'undefined') return
|
|
159
|
+
if (document.querySelector('style[data-plugin-css="' + CSS_ID + '"]')) return
|
|
160
|
+
const tag = document.createElement('style')
|
|
161
|
+
tag.dataset.pluginCss = CSS_ID
|
|
162
|
+
tag.textContent = CSS
|
|
163
|
+
document.head.appendChild(tag)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function Button({ children, onClick, variant = 'secondary', disabled = false, title, className = '' }) {
|
|
167
|
+
return h(
|
|
168
|
+
'button',
|
|
169
|
+
{
|
|
170
|
+
type: 'button',
|
|
171
|
+
className: 'eo-btn eo-btn-' + variant + (className ? ' ' + className : ''),
|
|
172
|
+
onClick,
|
|
173
|
+
disabled,
|
|
174
|
+
title,
|
|
175
|
+
},
|
|
176
|
+
children,
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function Badge({ children, tone = 'neutral' }) {
|
|
181
|
+
return h('span', { className: 'eo-badge eo-badge-' + tone }, children)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function Metric({ label, value, hint, tone = 'neutral' }) {
|
|
185
|
+
return h(
|
|
186
|
+
'div',
|
|
187
|
+
{ className: 'eo-metric' },
|
|
188
|
+
h('div', { className: 'eo-metric-label' }, label),
|
|
189
|
+
h('div', { className: 'eo-metric-value', 'data-tone': tone }, value),
|
|
190
|
+
hint ? h('div', { className: 'eo-metric-hint' }, hint) : null,
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function Card({ title, subtitle, extra, children, className = '', section }) {
|
|
195
|
+
return h(
|
|
196
|
+
'section',
|
|
197
|
+
{ className: 'eo-card ' + className, 'data-section': section },
|
|
198
|
+
title || extra
|
|
199
|
+
? h(
|
|
200
|
+
'div',
|
|
201
|
+
{ className: 'eo-card-head' },
|
|
202
|
+
h(
|
|
203
|
+
'div',
|
|
204
|
+
null,
|
|
205
|
+
title ? h('h3', { className: 'eo-card-title' }, title) : null,
|
|
206
|
+
subtitle ? h('p', { className: 'eo-card-sub' }, subtitle) : null,
|
|
207
|
+
),
|
|
208
|
+
extra || null,
|
|
209
|
+
)
|
|
210
|
+
: null,
|
|
211
|
+
children,
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function Field({ label, hint, children, className = '' }) {
|
|
216
|
+
return h(
|
|
217
|
+
'label',
|
|
218
|
+
{ className: 'eo-field ' + className },
|
|
219
|
+
label ? h('span', { className: 'eo-field-label' }, label) : null,
|
|
220
|
+
children,
|
|
221
|
+
hint ? h('span', { className: 'eo-field-hint' }, hint) : null,
|
|
222
|
+
)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function Dot({ severity }) {
|
|
226
|
+
return h('span', { className: 'eo-dot eo-dot-' + severity, 'aria-hidden': 'true' })
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function formatNumber(value) {
|
|
230
|
+
return new Intl.NumberFormat('zh-CN').format(Number(value) || 0)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function formatTokens(value) {
|
|
234
|
+
const n = Number(value) || 0
|
|
235
|
+
if (n >= 10000) return (n / 1000).toFixed(1) + 'k'
|
|
236
|
+
return formatNumber(n)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function actionLabel(action) {
|
|
240
|
+
return (
|
|
241
|
+
{
|
|
242
|
+
keep: '保留',
|
|
243
|
+
enable: '建议启用',
|
|
244
|
+
'suggest-disable': '建议禁用',
|
|
245
|
+
'disable-if-unused': '未用可禁用',
|
|
246
|
+
review: '人工复核',
|
|
247
|
+
}[action] || action
|
|
248
|
+
)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function actionTone(action) {
|
|
252
|
+
return (
|
|
253
|
+
{
|
|
254
|
+
keep: 'neutral',
|
|
255
|
+
enable: 'ok',
|
|
256
|
+
'suggest-disable': 'danger',
|
|
257
|
+
'disable-if-unused': 'warn',
|
|
258
|
+
review: 'info',
|
|
259
|
+
}[action] || 'neutral'
|
|
260
|
+
)
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function riskTone(risk) {
|
|
264
|
+
return { low: 'ok', medium: 'warn', high: 'danger' }[risk] || 'neutral'
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function severityTone(severity) {
|
|
268
|
+
return { error: 'danger', warn: 'warn', info: 'info' }[severity] || 'neutral'
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function domainLabel(domain) {
|
|
272
|
+
return (
|
|
273
|
+
{
|
|
274
|
+
'plugin-runtime': '插件 ↔ DSH',
|
|
275
|
+
'plugin-plugin': '插件 ↔ 插件',
|
|
276
|
+
profile: 'Profile',
|
|
277
|
+
workspace: '工作区',
|
|
278
|
+
}[domain] || domain
|
|
279
|
+
)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function isEligible(item) {
|
|
283
|
+
return (
|
|
284
|
+
item.protected !== true &&
|
|
285
|
+
item.risk === 'low' &&
|
|
286
|
+
(item.action === 'suggest-disable' || item.action === 'enable')
|
|
287
|
+
)
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function splitList(value) {
|
|
291
|
+
return String(value || '')
|
|
292
|
+
.split(/[,,\n]/)
|
|
293
|
+
.map((item) => item.trim())
|
|
294
|
+
.filter(Boolean)
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
async function fetchJson(path, options) {
|
|
298
|
+
const request = {
|
|
299
|
+
...options,
|
|
300
|
+
headers: { ...(options && options.headers ? options.headers : {}) },
|
|
301
|
+
}
|
|
302
|
+
if (request.body !== undefined) request.headers['content-type'] = 'application/json'
|
|
303
|
+
const response = await fetch(path, request)
|
|
304
|
+
let body = null
|
|
305
|
+
try {
|
|
306
|
+
body = await response.json()
|
|
307
|
+
} catch {
|
|
308
|
+
body = null
|
|
309
|
+
}
|
|
310
|
+
if (!response.ok || !body || body.ok !== true) {
|
|
311
|
+
const message =
|
|
312
|
+
body && body.error && body.error.message
|
|
313
|
+
? body.error.message
|
|
314
|
+
: 'HTTP ' + response.status + ' ' + response.statusText
|
|
315
|
+
throw new Error(message)
|
|
316
|
+
}
|
|
317
|
+
return body.data
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function ExperiencePanel() {
|
|
321
|
+
const [tab, setTab] = useState('trim')
|
|
322
|
+
const [overview, setOverview] = useState(null)
|
|
323
|
+
const [loading, setLoading] = useState(true)
|
|
324
|
+
const [error, setError] = useState('')
|
|
325
|
+
const [toast, setToast] = useState(null)
|
|
326
|
+
const [showInfo, setShowInfo] = useState(false)
|
|
327
|
+
const [showAllFindings, setShowAllFindings] = useState(false)
|
|
328
|
+
const [showContext, setShowContext] = useState(false)
|
|
329
|
+
const [taskTag, setTaskTag] = useState('unknown')
|
|
330
|
+
const [goal, setGoal] = useState('')
|
|
331
|
+
const [draft, setDraft] = useState(null)
|
|
332
|
+
const [draftBusy, setDraftBusy] = useState(false)
|
|
333
|
+
const [selected, setSelected] = useState({})
|
|
334
|
+
const [confirmState, setConfirmState] = useState(null)
|
|
335
|
+
const [applyResult, setApplyResult] = useState(null)
|
|
336
|
+
const [rollbackToken, setRollbackToken] = useState('')
|
|
337
|
+
const [recipeForm, setRecipeForm] = useState({
|
|
338
|
+
goal: '我想每周自动整理项目周报,数据来自 Git log',
|
|
339
|
+
scope: '当前工作区',
|
|
340
|
+
frequency: '每周一 09:00',
|
|
341
|
+
sources: 'Git log',
|
|
342
|
+
outputFormat: 'Markdown',
|
|
343
|
+
delivery: '对话内交付(present)',
|
|
344
|
+
onFailure: '保留草稿并在对话中通知',
|
|
345
|
+
acceptance: '时间范围正确, 输出内容可读, 失败可恢复',
|
|
346
|
+
})
|
|
347
|
+
const [recipeResult, setRecipeResult] = useState(null)
|
|
348
|
+
const [recipeBusy, setRecipeBusy] = useState(false)
|
|
349
|
+
|
|
350
|
+
const notify = useCallback((message, kind) => {
|
|
351
|
+
setToast({ message, kind: kind || 'ok', id: Date.now() })
|
|
352
|
+
}, [])
|
|
353
|
+
|
|
354
|
+
useEffect(() => {
|
|
355
|
+
if (!toast) return undefined
|
|
356
|
+
const timer = setTimeout(() => setToast(null), 4200)
|
|
357
|
+
return () => clearTimeout(timer)
|
|
358
|
+
}, [toast])
|
|
359
|
+
|
|
360
|
+
const refresh = useCallback(async () => {
|
|
361
|
+
setLoading(true)
|
|
362
|
+
setError('')
|
|
363
|
+
try {
|
|
364
|
+
const data = await fetchJson(API + '/overview')
|
|
365
|
+
setOverview(data)
|
|
366
|
+
} catch (err) {
|
|
367
|
+
setError(err instanceof Error ? err.message : String(err))
|
|
368
|
+
} finally {
|
|
369
|
+
setLoading(false)
|
|
370
|
+
}
|
|
371
|
+
}, [])
|
|
372
|
+
|
|
373
|
+
useEffect(() => {
|
|
374
|
+
void refresh()
|
|
375
|
+
}, [refresh])
|
|
376
|
+
|
|
377
|
+
const findings = useMemo(() => {
|
|
378
|
+
if (!overview) return []
|
|
379
|
+
return overview.findings.filter((finding) => showInfo || finding.severity !== 'info')
|
|
380
|
+
}, [overview, showInfo])
|
|
381
|
+
|
|
382
|
+
const enabledBundles = overview
|
|
383
|
+
? overview.bundles.filter((bundle) => bundle.enabled).length
|
|
384
|
+
: 0
|
|
385
|
+
const totalBundles = overview ? overview.bundles.length : 0
|
|
386
|
+
const compat = overview ? overview.compat : { error: 0, warn: 0, info: 0 }
|
|
387
|
+
const byOwner = overview ? overview.context.byOwner : []
|
|
388
|
+
const maxOwner = Math.max(1, ...byOwner.map((owner) => owner.tokens))
|
|
389
|
+
const selectedIds = Object.keys(selected).filter((id) => selected[id])
|
|
390
|
+
const selectedCount = selectedIds.length
|
|
391
|
+
const draftItems = draft ? draft.items : []
|
|
392
|
+
const actionableDraftItems = draftItems.filter(
|
|
393
|
+
(item) => item.action !== 'keep' && item.protected !== true,
|
|
394
|
+
)
|
|
395
|
+
|
|
396
|
+
const generateDraft = useCallback(async () => {
|
|
397
|
+
setDraftBusy(true)
|
|
398
|
+
setError('')
|
|
399
|
+
try {
|
|
400
|
+
const data = await fetchJson(API + '/suggest', {
|
|
401
|
+
method: 'POST',
|
|
402
|
+
body: JSON.stringify({
|
|
403
|
+
taskTag: taskTag === 'unknown' ? undefined : taskTag,
|
|
404
|
+
goal: goal.trim() || undefined,
|
|
405
|
+
includeReview: true,
|
|
406
|
+
}),
|
|
407
|
+
})
|
|
408
|
+
setDraft(data.profile)
|
|
409
|
+
setApplyResult(null)
|
|
410
|
+
const nextSelected = {}
|
|
411
|
+
for (const item of data.profile.items) {
|
|
412
|
+
if (isEligible(item)) nextSelected[item.id] = true
|
|
413
|
+
}
|
|
414
|
+
setSelected(nextSelected)
|
|
415
|
+
notify(
|
|
416
|
+
'已生成 ' +
|
|
417
|
+
data.profile.items.length +
|
|
418
|
+
' 条建议,其中 ' +
|
|
419
|
+
Object.keys(nextSelected).length +
|
|
420
|
+
' 条可应用',
|
|
421
|
+
)
|
|
422
|
+
} catch (err) {
|
|
423
|
+
const message = err instanceof Error ? err.message : String(err)
|
|
424
|
+
setError(message)
|
|
425
|
+
notify(message, 'error')
|
|
426
|
+
} finally {
|
|
427
|
+
setDraftBusy(false)
|
|
428
|
+
}
|
|
429
|
+
}, [goal, notify, taskTag])
|
|
430
|
+
|
|
431
|
+
const toggleItem = useCallback((id) => {
|
|
432
|
+
setSelected((previous) => ({ ...previous, [id]: !previous[id] }))
|
|
433
|
+
}, [])
|
|
434
|
+
|
|
435
|
+
const selectAll = useCallback(() => {
|
|
436
|
+
const next = {}
|
|
437
|
+
for (const item of draftItems) if (isEligible(item)) next[item.id] = true
|
|
438
|
+
setSelected(next)
|
|
439
|
+
}, [draftItems])
|
|
440
|
+
|
|
441
|
+
const clearSelection = useCallback(() => setSelected({}), [])
|
|
442
|
+
|
|
443
|
+
const openApply = useCallback(() => {
|
|
444
|
+
if (selectedCount === 0) {
|
|
445
|
+
notify('请先勾选要应用的低风险项', 'warn')
|
|
446
|
+
return
|
|
447
|
+
}
|
|
448
|
+
setConfirmState({ type: 'apply', ids: selectedIds })
|
|
449
|
+
}, [notify, selectedCount, selectedIds])
|
|
450
|
+
|
|
451
|
+
const doApply = useCallback(async () => {
|
|
452
|
+
if (!draft) return
|
|
453
|
+
const ids = confirmState && confirmState.ids ? confirmState.ids : []
|
|
454
|
+
setConfirmState(null)
|
|
455
|
+
setDraftBusy(true)
|
|
456
|
+
try {
|
|
457
|
+
const result = await fetchJson(API + '/apply', {
|
|
458
|
+
method: 'POST',
|
|
459
|
+
body: JSON.stringify({ profileId: draft.id, confirm: true, items: ids }),
|
|
460
|
+
})
|
|
461
|
+
setApplyResult(result)
|
|
462
|
+
if (result.token) setRollbackToken(result.token)
|
|
463
|
+
notify(
|
|
464
|
+
result.rolledBack
|
|
465
|
+
? '应用未完成,已自动回滚'
|
|
466
|
+
: '已应用 ' +
|
|
467
|
+
result.items.filter((item) => item.status === 'applied').length +
|
|
468
|
+
' 项',
|
|
469
|
+
result.rolledBack ? 'warn' : 'ok',
|
|
470
|
+
)
|
|
471
|
+
await refresh()
|
|
472
|
+
} catch (err) {
|
|
473
|
+
const message = err instanceof Error ? err.message : String(err)
|
|
474
|
+
notify(message, 'error')
|
|
475
|
+
} finally {
|
|
476
|
+
setDraftBusy(false)
|
|
477
|
+
}
|
|
478
|
+
}, [confirmState, draft, notify, refresh])
|
|
479
|
+
|
|
480
|
+
const openRollback = useCallback(() => {
|
|
481
|
+
setConfirmState({ type: 'rollback' })
|
|
482
|
+
}, [])
|
|
483
|
+
|
|
484
|
+
const doRollback = useCallback(async () => {
|
|
485
|
+
setConfirmState(null)
|
|
486
|
+
setDraftBusy(true)
|
|
487
|
+
try {
|
|
488
|
+
const result = await fetchJson(API + '/rollback', {
|
|
489
|
+
method: 'POST',
|
|
490
|
+
body: JSON.stringify({ token: rollbackToken || undefined }),
|
|
491
|
+
})
|
|
492
|
+
setApplyResult(null)
|
|
493
|
+
setRollbackToken('')
|
|
494
|
+
notify(
|
|
495
|
+
'已回滚 ' +
|
|
496
|
+
result.items.filter((item) => item.status === 'restored').length +
|
|
497
|
+
' 项',
|
|
498
|
+
)
|
|
499
|
+
await refresh()
|
|
500
|
+
} catch (err) {
|
|
501
|
+
const message = err instanceof Error ? err.message : String(err)
|
|
502
|
+
notify(message, 'error')
|
|
503
|
+
} finally {
|
|
504
|
+
setDraftBusy(false)
|
|
505
|
+
}
|
|
506
|
+
}, [notify, refresh, rollbackToken])
|
|
507
|
+
|
|
508
|
+
const generateRecipe = useCallback(async () => {
|
|
509
|
+
if (!recipeForm.goal.trim()) {
|
|
510
|
+
notify('请先填写业务目标', 'warn')
|
|
511
|
+
return
|
|
512
|
+
}
|
|
513
|
+
setRecipeBusy(true)
|
|
514
|
+
try {
|
|
515
|
+
const data = await fetchJson(RECIPE_API + '/plan', {
|
|
516
|
+
method: 'POST',
|
|
517
|
+
body: JSON.stringify({
|
|
518
|
+
goal: recipeForm.goal.trim(),
|
|
519
|
+
forceBlueprint: true,
|
|
520
|
+
answers: {
|
|
521
|
+
scope: recipeForm.scope,
|
|
522
|
+
frequency: recipeForm.frequency,
|
|
523
|
+
sources: splitList(recipeForm.sources),
|
|
524
|
+
outputFormat: recipeForm.outputFormat,
|
|
525
|
+
delivery: recipeForm.delivery,
|
|
526
|
+
onFailure: recipeForm.onFailure,
|
|
527
|
+
acceptance: splitList(recipeForm.acceptance),
|
|
528
|
+
},
|
|
529
|
+
}),
|
|
530
|
+
})
|
|
531
|
+
setRecipeResult(data)
|
|
532
|
+
notify('蓝图已生成:' + data.blueprint.steps.length + ' 个步骤')
|
|
533
|
+
} catch (err) {
|
|
534
|
+
const message = err instanceof Error ? err.message : String(err)
|
|
535
|
+
notify(message, 'error')
|
|
536
|
+
} finally {
|
|
537
|
+
setRecipeBusy(false)
|
|
538
|
+
}
|
|
539
|
+
}, [notify, recipeForm])
|
|
540
|
+
|
|
541
|
+
const exportRecipe = useCallback(async () => {
|
|
542
|
+
if (!recipeResult) return
|
|
543
|
+
try {
|
|
544
|
+
const data = await fetchJson(RECIPE_API + '/export', {
|
|
545
|
+
method: 'POST',
|
|
546
|
+
body: JSON.stringify({ blueprint: recipeResult.blueprint, format: 'both' }),
|
|
547
|
+
})
|
|
548
|
+
notify('已导出运行手册:' + (data.markdownPath || data.jsonPath || ''))
|
|
549
|
+
} catch (err) {
|
|
550
|
+
const message = err instanceof Error ? err.message : String(err)
|
|
551
|
+
notify(message, 'error')
|
|
552
|
+
}
|
|
553
|
+
}, [notify, recipeResult])
|
|
554
|
+
|
|
555
|
+
const updateRecipe = useCallback((key, value) => {
|
|
556
|
+
setRecipeForm((previous) => ({ ...previous, [key]: value }))
|
|
557
|
+
}, [])
|
|
558
|
+
|
|
559
|
+
return h(
|
|
560
|
+
'div',
|
|
561
|
+
{ className: 'eo-root' },
|
|
562
|
+
h(
|
|
563
|
+
'div',
|
|
564
|
+
{ className: 'eo-hero' },
|
|
565
|
+
h(
|
|
566
|
+
'div',
|
|
567
|
+
{ className: 'eo-hero-copy' },
|
|
568
|
+
h('h2', { className: 'eo-title' }, '体验优化'),
|
|
569
|
+
h('p', { className: 'eo-sub' }, '插件减负、兼容性体检与工作流蓝图。'),
|
|
570
|
+
),
|
|
571
|
+
h(
|
|
572
|
+
'div',
|
|
573
|
+
{ className: 'eo-hero-actions' },
|
|
574
|
+
h(
|
|
575
|
+
'span',
|
|
576
|
+
{ className: 'eo-status', title: overview ? overview.profile.dir : '' },
|
|
577
|
+
overview ? 'profile: ' + overview.profile.name : '读取中',
|
|
578
|
+
),
|
|
579
|
+
h(
|
|
580
|
+
Button,
|
|
581
|
+
{ onClick: refresh, disabled: loading, variant: 'ghost' },
|
|
582
|
+
loading ? '刷新中…' : '刷新',
|
|
583
|
+
),
|
|
584
|
+
),
|
|
585
|
+
),
|
|
586
|
+
h(
|
|
587
|
+
'div',
|
|
588
|
+
{ className: 'eo-tabs' },
|
|
589
|
+
h(
|
|
590
|
+
'button',
|
|
591
|
+
{
|
|
592
|
+
type: 'button',
|
|
593
|
+
className: 'eo-tab' + (tab === 'trim' ? ' eo-tab-active' : ''),
|
|
594
|
+
onClick: () => setTab('trim'),
|
|
595
|
+
},
|
|
596
|
+
'减负与兼容',
|
|
597
|
+
),
|
|
598
|
+
h(
|
|
599
|
+
'button',
|
|
600
|
+
{
|
|
601
|
+
type: 'button',
|
|
602
|
+
className: 'eo-tab' + (tab === 'recipe' ? ' eo-tab-active' : ''),
|
|
603
|
+
onClick: () => setTab('recipe'),
|
|
604
|
+
},
|
|
605
|
+
'工作流配方',
|
|
606
|
+
),
|
|
607
|
+
),
|
|
608
|
+
error
|
|
609
|
+
? h(
|
|
610
|
+
'div',
|
|
611
|
+
{ className: 'eo-error' },
|
|
612
|
+
h('span', null, error),
|
|
613
|
+
h(Button, { onClick: refresh, variant: 'ghost' }, '重试'),
|
|
614
|
+
)
|
|
615
|
+
: null,
|
|
616
|
+
loading && !overview
|
|
617
|
+
? h(
|
|
618
|
+
'div',
|
|
619
|
+
{ className: 'eo-loading' },
|
|
620
|
+
h('span', { className: 'eo-spinner' }),
|
|
621
|
+
'正在读取插件画像与兼容性数据…',
|
|
622
|
+
)
|
|
623
|
+
: null,
|
|
624
|
+
overview
|
|
625
|
+
? tab === 'trim'
|
|
626
|
+
? renderTrim()
|
|
627
|
+
: renderRecipe()
|
|
628
|
+
: null,
|
|
629
|
+
confirmState
|
|
630
|
+
? h(ConfirmModal, {
|
|
631
|
+
state: confirmState,
|
|
632
|
+
draft,
|
|
633
|
+
busy: draftBusy,
|
|
634
|
+
onCancel: () => setConfirmState(null),
|
|
635
|
+
onConfirm: confirmState.type === 'apply' ? doApply : doRollback,
|
|
636
|
+
})
|
|
637
|
+
: null,
|
|
638
|
+
toast
|
|
639
|
+
? h('div', { className: 'eo-toast eo-toast-' + toast.kind }, toast.message)
|
|
640
|
+
: null,
|
|
641
|
+
)
|
|
642
|
+
|
|
643
|
+
function renderTrim() {
|
|
644
|
+
return h(
|
|
645
|
+
'div',
|
|
646
|
+
{ className: 'eo-stack' },
|
|
647
|
+
h('div', { className: 'eo-grid eo-metrics' }, [
|
|
648
|
+
h(Metric, {
|
|
649
|
+
key: 'tokens',
|
|
650
|
+
label: '可归属上下文',
|
|
651
|
+
value: formatTokens(overview.context.totalTokens),
|
|
652
|
+
hint: 'tokens · 不含未归属部分',
|
|
653
|
+
}),
|
|
654
|
+
h(Metric, {
|
|
655
|
+
key: 'bundles',
|
|
656
|
+
label: '启用插件',
|
|
657
|
+
value: enabledBundles + ' / ' + totalBundles,
|
|
658
|
+
hint: 'enabled / total bundles',
|
|
659
|
+
}),
|
|
660
|
+
h(Metric, {
|
|
661
|
+
key: 'compat',
|
|
662
|
+
label: '兼容性',
|
|
663
|
+
value: compat.error + 'E · ' + compat.warn + 'W',
|
|
664
|
+
hint: 'error / warn · info ' + compat.info,
|
|
665
|
+
tone: compat.error > 0 ? 'danger' : compat.warn > 0 ? 'warn' : 'ok',
|
|
666
|
+
}),
|
|
667
|
+
h(Metric, {
|
|
668
|
+
key: 'manage',
|
|
669
|
+
label: '写操作',
|
|
670
|
+
value: overview.managementAvailable ? '可应用' : '只读',
|
|
671
|
+
hint: overview.managementAvailable ? 'pluginManager 可用' : '缺少 pluginManager',
|
|
672
|
+
tone: overview.managementAvailable ? 'ok' : 'danger',
|
|
673
|
+
}),
|
|
674
|
+
]),
|
|
675
|
+
h(
|
|
676
|
+
Card,
|
|
677
|
+
{
|
|
678
|
+
title: '兼容性矩阵',
|
|
679
|
+
subtitle: '插件 ↔ 插件 · 插件 ↔ DSH · Profile / 工作区',
|
|
680
|
+
section: 'compat',
|
|
681
|
+
extra: h(
|
|
682
|
+
'div',
|
|
683
|
+
{ className: 'eo-inline' },
|
|
684
|
+
findings.length > 5
|
|
685
|
+
? h(
|
|
686
|
+
Button,
|
|
687
|
+
{
|
|
688
|
+
variant: 'ghost',
|
|
689
|
+
onClick: () => setShowAllFindings((value) => !value),
|
|
690
|
+
},
|
|
691
|
+
showAllFindings ? '收起' : '查看全部 ' + findings.length,
|
|
692
|
+
)
|
|
693
|
+
: null,
|
|
694
|
+
h(
|
|
695
|
+
Button,
|
|
696
|
+
{
|
|
697
|
+
variant: 'ghost',
|
|
698
|
+
onClick: () => setShowInfo((value) => !value),
|
|
699
|
+
},
|
|
700
|
+
showInfo ? '隐藏 info' : '显示 info',
|
|
701
|
+
),
|
|
702
|
+
h(Badge, { tone: compat.error ? 'danger' : 'ok' }, compat.error ? '需要处理' : '无阻断'),
|
|
703
|
+
),
|
|
704
|
+
},
|
|
705
|
+
findings.length === 0
|
|
706
|
+
? h('div', { className: 'eo-empty' }, '未发现需要处理的兼容性问题。')
|
|
707
|
+
: h(
|
|
708
|
+
'div',
|
|
709
|
+
{ className: 'eo-findings' },
|
|
710
|
+
findings.slice(0, showAllFindings ? 60 : 5).map((finding, index) =>
|
|
711
|
+
h(
|
|
712
|
+
'div',
|
|
713
|
+
{ className: 'eo-finding', key: finding.code + index },
|
|
714
|
+
h(Dot, { severity: finding.severity }),
|
|
715
|
+
h(
|
|
716
|
+
'div',
|
|
717
|
+
{ className: 'eo-finding-body' },
|
|
718
|
+
h(
|
|
719
|
+
'div',
|
|
720
|
+
{ className: 'eo-finding-title' },
|
|
721
|
+
h('code', null, finding.code),
|
|
722
|
+
finding.title,
|
|
723
|
+
),
|
|
724
|
+
h(
|
|
725
|
+
'div',
|
|
726
|
+
{ className: 'eo-finding-meta' },
|
|
727
|
+
domainLabel(finding.domain) +
|
|
728
|
+
' · ' +
|
|
729
|
+
finding.confidence +
|
|
730
|
+
' · ' +
|
|
731
|
+
finding.subjects.join(', '),
|
|
732
|
+
),
|
|
733
|
+
finding.fix && finding.fix.summary
|
|
734
|
+
? h(
|
|
735
|
+
'div',
|
|
736
|
+
{ className: 'eo-finding-fix' },
|
|
737
|
+
'修复:' + finding.fix.summary,
|
|
738
|
+
)
|
|
739
|
+
: null,
|
|
740
|
+
),
|
|
741
|
+
),
|
|
742
|
+
),
|
|
743
|
+
),
|
|
744
|
+
),
|
|
745
|
+
h(
|
|
746
|
+
Card,
|
|
747
|
+
{
|
|
748
|
+
title: '上下文成本',
|
|
749
|
+
section: 'context',
|
|
750
|
+
subtitle:
|
|
751
|
+
'总计 ' +
|
|
752
|
+
formatNumber(overview.context.totalTokens) +
|
|
753
|
+
' tokens,未归属 ' +
|
|
754
|
+
formatNumber(overview.context.unattributedTokens),
|
|
755
|
+
extra: h(
|
|
756
|
+
Button,
|
|
757
|
+
{ variant: 'ghost', onClick: () => setShowContext((value) => !value) },
|
|
758
|
+
showContext ? '收起明细' : '查看明细',
|
|
759
|
+
),
|
|
760
|
+
},
|
|
761
|
+
h(
|
|
762
|
+
'div',
|
|
763
|
+
{ className: 'eo-owner-list' },
|
|
764
|
+
byOwner.slice(0, 7).map((owner) =>
|
|
765
|
+
h(
|
|
766
|
+
'div',
|
|
767
|
+
{ className: 'eo-owner', key: owner.owner },
|
|
768
|
+
h(
|
|
769
|
+
'div',
|
|
770
|
+
{ className: 'eo-owner-head' },
|
|
771
|
+
h('span', null, owner.owner),
|
|
772
|
+
h('span', null, formatNumber(owner.tokens)),
|
|
773
|
+
),
|
|
774
|
+
h(
|
|
775
|
+
'div',
|
|
776
|
+
{ className: 'eo-bar' },
|
|
777
|
+
h('i', {
|
|
778
|
+
style: { width: Math.max(3, (owner.tokens / maxOwner) * 100) + '%' },
|
|
779
|
+
}),
|
|
780
|
+
),
|
|
781
|
+
),
|
|
782
|
+
),
|
|
783
|
+
),
|
|
784
|
+
showContext
|
|
785
|
+
? h(
|
|
786
|
+
'table',
|
|
787
|
+
{ className: 'eo-table' },
|
|
788
|
+
h(
|
|
789
|
+
'thead',
|
|
790
|
+
null,
|
|
791
|
+
h(
|
|
792
|
+
'tr',
|
|
793
|
+
null,
|
|
794
|
+
h('th', null, 'Section / Tool'),
|
|
795
|
+
h('th', null, 'Owner'),
|
|
796
|
+
h('th', null, 'Tokens'),
|
|
797
|
+
),
|
|
798
|
+
),
|
|
799
|
+
h(
|
|
800
|
+
'tbody',
|
|
801
|
+
null,
|
|
802
|
+
[
|
|
803
|
+
...overview.context.topSections.map((section) => ({
|
|
804
|
+
name: section.name,
|
|
805
|
+
owner: section.owner,
|
|
806
|
+
tokens: section.tokens,
|
|
807
|
+
kind: section.source === 'context' ? 'context' : 'section',
|
|
808
|
+
})),
|
|
809
|
+
...overview.context.topTools.map((tool) => ({
|
|
810
|
+
name: tool.name,
|
|
811
|
+
owner: tool.owner,
|
|
812
|
+
tokens: tool.tokens,
|
|
813
|
+
kind: 'tool',
|
|
814
|
+
})),
|
|
815
|
+
]
|
|
816
|
+
.sort((left, right) => right.tokens - left.tokens)
|
|
817
|
+
.slice(0, 10)
|
|
818
|
+
.map((row, index) =>
|
|
819
|
+
h(
|
|
820
|
+
'tr',
|
|
821
|
+
{ key: row.kind + ':' + row.name + index },
|
|
822
|
+
h(
|
|
823
|
+
'td',
|
|
824
|
+
null,
|
|
825
|
+
h('code', null, row.kind + ' · ' + row.name),
|
|
826
|
+
),
|
|
827
|
+
h('td', { className: 'eo-muted' }, row.owner || 'unattributed'),
|
|
828
|
+
h('td', null, formatNumber(row.tokens)),
|
|
829
|
+
),
|
|
830
|
+
),
|
|
831
|
+
),
|
|
832
|
+
)
|
|
833
|
+
: null,
|
|
834
|
+
),
|
|
835
|
+
h(
|
|
836
|
+
Card,
|
|
837
|
+
{
|
|
838
|
+
title: '精简方案',
|
|
839
|
+
subtitle: '先建议,后确认;受保护项永不改动',
|
|
840
|
+
section: 'draft',
|
|
841
|
+
},
|
|
842
|
+
h(
|
|
843
|
+
'div',
|
|
844
|
+
{ className: 'eo-toolbar' },
|
|
845
|
+
h(
|
|
846
|
+
Field,
|
|
847
|
+
{ label: '任务类型' },
|
|
848
|
+
h(
|
|
849
|
+
'select',
|
|
850
|
+
{
|
|
851
|
+
className: 'eo-select',
|
|
852
|
+
value: taskTag,
|
|
853
|
+
onChange: (event) => setTaskTag(event.target.value),
|
|
854
|
+
},
|
|
855
|
+
TASK_TAGS.map(([value, label]) =>
|
|
856
|
+
h('option', { value, key: value }, label),
|
|
857
|
+
),
|
|
858
|
+
),
|
|
859
|
+
),
|
|
860
|
+
h(
|
|
861
|
+
Field,
|
|
862
|
+
{ label: '任务目标(可选)' },
|
|
863
|
+
h('input', {
|
|
864
|
+
className: 'eo-input',
|
|
865
|
+
value: goal,
|
|
866
|
+
placeholder: '例如:修复登录页崩溃',
|
|
867
|
+
onChange: (event) => setGoal(event.target.value),
|
|
868
|
+
onKeyDown: (event) => {
|
|
869
|
+
if (event.key === 'Enter') void generateDraft()
|
|
870
|
+
},
|
|
871
|
+
}),
|
|
872
|
+
),
|
|
873
|
+
h(
|
|
874
|
+
Button,
|
|
875
|
+
{ variant: 'accent', onClick: generateDraft, disabled: draftBusy },
|
|
876
|
+
draftBusy ? '生成中…' : '生成方案',
|
|
877
|
+
),
|
|
878
|
+
),
|
|
879
|
+
draft
|
|
880
|
+
? h(
|
|
881
|
+
'div',
|
|
882
|
+
null,
|
|
883
|
+
h(
|
|
884
|
+
'div',
|
|
885
|
+
{ className: 'eo-summary' },
|
|
886
|
+
h(Badge, { tone: 'neutral' }, '保留 ' + draft.summary.keep),
|
|
887
|
+
h(Badge, { tone: 'ok' }, '启用 ' + draft.summary.enable),
|
|
888
|
+
h(Badge, { tone: 'danger' }, '禁用 ' + draft.summary.disable),
|
|
889
|
+
h(Badge, { tone: 'info' }, '复核 ' + draft.summary.review),
|
|
890
|
+
h(Badge, { tone: 'neutral' }, '受保护 ' + draft.summary.protected),
|
|
891
|
+
h(Badge, { tone: 'warn' }, 'task: ' + draft.task.tag),
|
|
892
|
+
),
|
|
893
|
+
actionableDraftItems.length === 0
|
|
894
|
+
? h(
|
|
895
|
+
'div',
|
|
896
|
+
{ className: 'eo-empty' },
|
|
897
|
+
'当前没有可裁剪项:所有插件均受保护,或与当前任务匹配。',
|
|
898
|
+
)
|
|
899
|
+
: h(
|
|
900
|
+
'div',
|
|
901
|
+
{ className: 'eo-list' },
|
|
902
|
+
actionableDraftItems
|
|
903
|
+
.slice(0, 60)
|
|
904
|
+
.map((item) =>
|
|
905
|
+
h(
|
|
906
|
+
'div',
|
|
907
|
+
{
|
|
908
|
+
className:
|
|
909
|
+
'eo-item' + (selected[item.id] ? ' eo-item-selected' : ''),
|
|
910
|
+
key: item.id,
|
|
911
|
+
},
|
|
912
|
+
isEligible(item)
|
|
913
|
+
? h('input', {
|
|
914
|
+
type: 'checkbox',
|
|
915
|
+
checked: selected[item.id] === true,
|
|
916
|
+
onChange: () => toggleItem(item.id),
|
|
917
|
+
'aria-label': '选择 ' + item.name,
|
|
918
|
+
})
|
|
919
|
+
: h('span', { className: 'eo-lock', title: '受保护或非低风险' }),
|
|
920
|
+
h(
|
|
921
|
+
'div',
|
|
922
|
+
{ className: 'eo-item-main' },
|
|
923
|
+
h(
|
|
924
|
+
'div',
|
|
925
|
+
{ className: 'eo-item-title' },
|
|
926
|
+
h('span', { className: 'eo-item-name' }, item.name),
|
|
927
|
+
h(
|
|
928
|
+
Badge,
|
|
929
|
+
{ tone: actionTone(item.action) },
|
|
930
|
+
actionLabel(item.action),
|
|
931
|
+
),
|
|
932
|
+
h(Badge, { tone: riskTone(item.risk) }, 'risk: ' + item.risk),
|
|
933
|
+
item.protected ? h(Badge, { tone: 'neutral' }, '受保护') : null,
|
|
934
|
+
),
|
|
935
|
+
h('div', { className: 'eo-item-reason' }, item.reason),
|
|
936
|
+
h(
|
|
937
|
+
'div',
|
|
938
|
+
{ className: 'eo-item-evidence' },
|
|
939
|
+
item.evidence.slice(0, 4).map((evidence, index) =>
|
|
940
|
+
h(
|
|
941
|
+
'span',
|
|
942
|
+
{ className: 'eo-evidence', key: index },
|
|
943
|
+
evidence.summary,
|
|
944
|
+
),
|
|
945
|
+
),
|
|
946
|
+
),
|
|
947
|
+
),
|
|
948
|
+
h(
|
|
949
|
+
'div',
|
|
950
|
+
{ className: 'eo-item-side' },
|
|
951
|
+
h('span', null, Number(item.score).toFixed(2)),
|
|
952
|
+
h('small', null, 'score'),
|
|
953
|
+
),
|
|
954
|
+
),
|
|
955
|
+
),
|
|
956
|
+
),
|
|
957
|
+
h(
|
|
958
|
+
'div',
|
|
959
|
+
{ className: 'eo-applybar' },
|
|
960
|
+
h(
|
|
961
|
+
'span',
|
|
962
|
+
{ className: 'eo-applybar-text' },
|
|
963
|
+
selectedCount + ' 个低风险项已选择 · 应用前会写入回滚快照',
|
|
964
|
+
),
|
|
965
|
+
h(
|
|
966
|
+
'div',
|
|
967
|
+
{ className: 'eo-inline' },
|
|
968
|
+
h(Button, { variant: 'ghost', onClick: selectAll }, '全选低风险'),
|
|
969
|
+
h(Button, { variant: 'ghost', onClick: clearSelection }, '清空'),
|
|
970
|
+
h(
|
|
971
|
+
Button,
|
|
972
|
+
{
|
|
973
|
+
variant: 'accent',
|
|
974
|
+
onClick: openApply,
|
|
975
|
+
disabled: selectedCount === 0 || draftBusy,
|
|
976
|
+
},
|
|
977
|
+
'应用选中',
|
|
978
|
+
),
|
|
979
|
+
h(
|
|
980
|
+
Button,
|
|
981
|
+
{ variant: 'danger', onClick: openRollback, disabled: draftBusy },
|
|
982
|
+
'回滚最近',
|
|
983
|
+
),
|
|
984
|
+
),
|
|
985
|
+
),
|
|
986
|
+
)
|
|
987
|
+
: h(
|
|
988
|
+
'div',
|
|
989
|
+
{ className: 'eo-empty' },
|
|
990
|
+
'生成方案后,这里会出现可解释的保留/启用/禁用建议。建议默认不会改动任何插件。',
|
|
991
|
+
),
|
|
992
|
+
),
|
|
993
|
+
applyResult
|
|
994
|
+
? h(
|
|
995
|
+
Card,
|
|
996
|
+
{
|
|
997
|
+
title: '应用结果',
|
|
998
|
+
subtitle: applyResult.rolledBack ? '中途失败,已自动回滚' : '变更已写入 profile',
|
|
999
|
+
section: 'result',
|
|
1000
|
+
extra: h(
|
|
1001
|
+
Badge,
|
|
1002
|
+
{ tone: applyResult.rolledBack ? 'warn' : 'ok' },
|
|
1003
|
+
applyResult.rolledBack ? '已回滚' : '完成',
|
|
1004
|
+
),
|
|
1005
|
+
},
|
|
1006
|
+
h(
|
|
1007
|
+
'table',
|
|
1008
|
+
{ className: 'eo-table' },
|
|
1009
|
+
h(
|
|
1010
|
+
'thead',
|
|
1011
|
+
null,
|
|
1012
|
+
h(
|
|
1013
|
+
'tr',
|
|
1014
|
+
null,
|
|
1015
|
+
h('th', null, 'Item'),
|
|
1016
|
+
h('th', null, 'Status'),
|
|
1017
|
+
h('th', null, 'Application'),
|
|
1018
|
+
h('th', null, 'Note'),
|
|
1019
|
+
),
|
|
1020
|
+
),
|
|
1021
|
+
h(
|
|
1022
|
+
'tbody',
|
|
1023
|
+
null,
|
|
1024
|
+
applyResult.items.map((item) =>
|
|
1025
|
+
h(
|
|
1026
|
+
'tr',
|
|
1027
|
+
{ key: item.id },
|
|
1028
|
+
h('td', null, h('code', null, item.id)),
|
|
1029
|
+
h(
|
|
1030
|
+
'td',
|
|
1031
|
+
null,
|
|
1032
|
+
h(
|
|
1033
|
+
Badge,
|
|
1034
|
+
{
|
|
1035
|
+
tone:
|
|
1036
|
+
item.status === 'applied'
|
|
1037
|
+
? 'ok'
|
|
1038
|
+
: item.status === 'failed'
|
|
1039
|
+
? 'danger'
|
|
1040
|
+
: item.status === 'stale' ||
|
|
1041
|
+
item.status === 'blocked-by-compat'
|
|
1042
|
+
? 'warn'
|
|
1043
|
+
: 'neutral',
|
|
1044
|
+
},
|
|
1045
|
+
item.status,
|
|
1046
|
+
),
|
|
1047
|
+
),
|
|
1048
|
+
h('td', { className: 'eo-muted' }, item.application || '—'),
|
|
1049
|
+
h('td', { className: 'eo-muted' }, item.error || item.fixKind || ''),
|
|
1050
|
+
),
|
|
1051
|
+
),
|
|
1052
|
+
),
|
|
1053
|
+
),
|
|
1054
|
+
applyResult.token
|
|
1055
|
+
? h(
|
|
1056
|
+
'div',
|
|
1057
|
+
{ className: 'eo-applybar' },
|
|
1058
|
+
h(
|
|
1059
|
+
'span',
|
|
1060
|
+
{ className: 'eo-code' },
|
|
1061
|
+
'rollbackToken: ' + applyResult.token,
|
|
1062
|
+
),
|
|
1063
|
+
h(
|
|
1064
|
+
Button,
|
|
1065
|
+
{
|
|
1066
|
+
variant: 'ghost',
|
|
1067
|
+
onClick: () => {
|
|
1068
|
+
if (navigator.clipboard) {
|
|
1069
|
+
void navigator.clipboard.writeText(applyResult.token)
|
|
1070
|
+
notify('token 已复制')
|
|
1071
|
+
}
|
|
1072
|
+
},
|
|
1073
|
+
},
|
|
1074
|
+
'复制 token',
|
|
1075
|
+
),
|
|
1076
|
+
)
|
|
1077
|
+
: null,
|
|
1078
|
+
applyResult.restartRequired
|
|
1079
|
+
? h(
|
|
1080
|
+
'div',
|
|
1081
|
+
{ className: 'eo-issue eo-issue-warn' },
|
|
1082
|
+
h('span', null, '部分变更需要重启 DSH 后生效。'),
|
|
1083
|
+
)
|
|
1084
|
+
: null,
|
|
1085
|
+
)
|
|
1086
|
+
: null,
|
|
1087
|
+
draft && draft.dedupe && draft.dedupe.length > 0
|
|
1088
|
+
? h(
|
|
1089
|
+
Card,
|
|
1090
|
+
{ title: '跨插件 prompt 重复', subtitle: '只建议,不修改第三方源码', section: 'dedupe' },
|
|
1091
|
+
h(
|
|
1092
|
+
'div',
|
|
1093
|
+
{ className: 'eo-list' },
|
|
1094
|
+
draft.dedupe.slice(0, 8).map((group) =>
|
|
1095
|
+
h(
|
|
1096
|
+
'div',
|
|
1097
|
+
{ className: 'eo-issue' + (group.conflict ? ' eo-issue-warn' : ''), key: group.fingerprint },
|
|
1098
|
+
h(
|
|
1099
|
+
'div',
|
|
1100
|
+
null,
|
|
1101
|
+
h('strong', null, '权威:' + group.authority),
|
|
1102
|
+
h('div', { className: 'eo-muted' }, group.reason),
|
|
1103
|
+
h(
|
|
1104
|
+
'div',
|
|
1105
|
+
{ className: 'eo-muted' },
|
|
1106
|
+
group.members
|
|
1107
|
+
.filter((member) => member.section !== group.authority)
|
|
1108
|
+
.map((member) => member.section)
|
|
1109
|
+
.join(', '),
|
|
1110
|
+
),
|
|
1111
|
+
),
|
|
1112
|
+
),
|
|
1113
|
+
),
|
|
1114
|
+
),
|
|
1115
|
+
)
|
|
1116
|
+
: null,
|
|
1117
|
+
overview.diagnostics && overview.diagnostics.length > 0
|
|
1118
|
+
? h(
|
|
1119
|
+
'details',
|
|
1120
|
+
{ className: 'eo-card', 'data-section': 'diagnostics' },
|
|
1121
|
+
h(
|
|
1122
|
+
'summary',
|
|
1123
|
+
{ className: 'eo-card-title', style: { cursor: 'pointer' } },
|
|
1124
|
+
'分析诊断(' + overview.diagnostics.length + ')',
|
|
1125
|
+
),
|
|
1126
|
+
h(
|
|
1127
|
+
'div',
|
|
1128
|
+
{ className: 'eo-list', style: { marginTop: '10px' } },
|
|
1129
|
+
overview.diagnostics.slice(0, 10).map((diagnostic, index) =>
|
|
1130
|
+
h('div', { className: 'eo-muted', key: index }, diagnostic),
|
|
1131
|
+
),
|
|
1132
|
+
),
|
|
1133
|
+
)
|
|
1134
|
+
: null,
|
|
1135
|
+
)
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
function renderRecipe() {
|
|
1139
|
+
return h(
|
|
1140
|
+
'div',
|
|
1141
|
+
{ className: 'eo-stack' },
|
|
1142
|
+
h(
|
|
1143
|
+
Card,
|
|
1144
|
+
{
|
|
1145
|
+
title: '工作流配方',
|
|
1146
|
+
subtitle: '把业务目标翻译成可校验、可导出的工作流蓝图',
|
|
1147
|
+
extra: h(Badge, { tone: 'info' }, '最多 4 组追问'),
|
|
1148
|
+
},
|
|
1149
|
+
h(
|
|
1150
|
+
'div',
|
|
1151
|
+
{ className: 'eo-form-grid' },
|
|
1152
|
+
h(
|
|
1153
|
+
Field,
|
|
1154
|
+
{ label: '业务目标', className: 'eo-wide' },
|
|
1155
|
+
h('textarea', {
|
|
1156
|
+
className: 'eo-textarea',
|
|
1157
|
+
value: recipeForm.goal,
|
|
1158
|
+
placeholder: '例如:我想每周自动整理项目周报,数据来自 Git log',
|
|
1159
|
+
onChange: (event) => updateRecipe('goal', event.target.value),
|
|
1160
|
+
}),
|
|
1161
|
+
),
|
|
1162
|
+
h(
|
|
1163
|
+
Field,
|
|
1164
|
+
{ label: '项目 / 范围' },
|
|
1165
|
+
h('input', {
|
|
1166
|
+
className: 'eo-input',
|
|
1167
|
+
value: recipeForm.scope,
|
|
1168
|
+
onChange: (event) => updateRecipe('scope', event.target.value),
|
|
1169
|
+
}),
|
|
1170
|
+
),
|
|
1171
|
+
h(
|
|
1172
|
+
Field,
|
|
1173
|
+
{ label: '频率' },
|
|
1174
|
+
h('input', {
|
|
1175
|
+
className: 'eo-input',
|
|
1176
|
+
value: recipeForm.frequency,
|
|
1177
|
+
onChange: (event) => updateRecipe('frequency', event.target.value),
|
|
1178
|
+
}),
|
|
1179
|
+
),
|
|
1180
|
+
h(
|
|
1181
|
+
Field,
|
|
1182
|
+
{ label: '数据来源', hint: '逗号分隔' },
|
|
1183
|
+
h('input', {
|
|
1184
|
+
className: 'eo-input',
|
|
1185
|
+
value: recipeForm.sources,
|
|
1186
|
+
onChange: (event) => updateRecipe('sources', event.target.value),
|
|
1187
|
+
}),
|
|
1188
|
+
),
|
|
1189
|
+
h(
|
|
1190
|
+
Field,
|
|
1191
|
+
{ label: '输出格式' },
|
|
1192
|
+
h('input', {
|
|
1193
|
+
className: 'eo-input',
|
|
1194
|
+
value: recipeForm.outputFormat,
|
|
1195
|
+
onChange: (event) => updateRecipe('outputFormat', event.target.value),
|
|
1196
|
+
}),
|
|
1197
|
+
),
|
|
1198
|
+
h(
|
|
1199
|
+
Field,
|
|
1200
|
+
{ label: '交付方式' },
|
|
1201
|
+
h('input', {
|
|
1202
|
+
className: 'eo-input',
|
|
1203
|
+
value: recipeForm.delivery,
|
|
1204
|
+
onChange: (event) => updateRecipe('delivery', event.target.value),
|
|
1205
|
+
}),
|
|
1206
|
+
),
|
|
1207
|
+
h(
|
|
1208
|
+
Field,
|
|
1209
|
+
{ label: '失败处理' },
|
|
1210
|
+
h('input', {
|
|
1211
|
+
className: 'eo-input',
|
|
1212
|
+
value: recipeForm.onFailure,
|
|
1213
|
+
onChange: (event) => updateRecipe('onFailure', event.target.value),
|
|
1214
|
+
}),
|
|
1215
|
+
),
|
|
1216
|
+
h(
|
|
1217
|
+
Field,
|
|
1218
|
+
{ label: '验收标准', hint: '逗号分隔', className: 'eo-wide' },
|
|
1219
|
+
h('input', {
|
|
1220
|
+
className: 'eo-input',
|
|
1221
|
+
value: recipeForm.acceptance,
|
|
1222
|
+
onChange: (event) => updateRecipe('acceptance', event.target.value),
|
|
1223
|
+
}),
|
|
1224
|
+
),
|
|
1225
|
+
),
|
|
1226
|
+
h(
|
|
1227
|
+
'div',
|
|
1228
|
+
{ className: 'eo-applybar' },
|
|
1229
|
+
h(
|
|
1230
|
+
'span',
|
|
1231
|
+
{ className: 'eo-muted' },
|
|
1232
|
+
'UI 预览按内置能力目录判断可用性;精确 agent-scope 校验以 recipe_plan_workflow 工具为准。',
|
|
1233
|
+
),
|
|
1234
|
+
h(
|
|
1235
|
+
Button,
|
|
1236
|
+
{ variant: 'accent', onClick: generateRecipe, disabled: recipeBusy },
|
|
1237
|
+
recipeBusy ? '生成中…' : '生成工作流蓝图',
|
|
1238
|
+
),
|
|
1239
|
+
),
|
|
1240
|
+
),
|
|
1241
|
+
recipeResult
|
|
1242
|
+
? renderRecipeResult(recipeResult)
|
|
1243
|
+
: h(
|
|
1244
|
+
'div',
|
|
1245
|
+
{ className: 'eo-empty' },
|
|
1246
|
+
'填写目标后生成蓝图。这里只生成计划,不会创建 schedule,也不会修改插件。',
|
|
1247
|
+
),
|
|
1248
|
+
)
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
function renderRecipeResult(result) {
|
|
1252
|
+
const blueprint = result.blueprint
|
|
1253
|
+
return h(
|
|
1254
|
+
'div',
|
|
1255
|
+
{ className: 'eo-stack' },
|
|
1256
|
+
h(
|
|
1257
|
+
Card,
|
|
1258
|
+
{
|
|
1259
|
+
title: '蓝图预览',
|
|
1260
|
+
subtitle:
|
|
1261
|
+
'模板 ' +
|
|
1262
|
+
blueprint.template +
|
|
1263
|
+
' · ' +
|
|
1264
|
+
blueprint.steps.length +
|
|
1265
|
+
' 个步骤 · ' +
|
|
1266
|
+
blueprint.minPluginSet.length +
|
|
1267
|
+
' 个最小插件',
|
|
1268
|
+
extra: h(
|
|
1269
|
+
'div',
|
|
1270
|
+
{ className: 'eo-inline' },
|
|
1271
|
+
h(Button, { variant: 'ghost', onClick: exportRecipe }, '导出运行手册'),
|
|
1272
|
+
),
|
|
1273
|
+
},
|
|
1274
|
+
h(
|
|
1275
|
+
'div',
|
|
1276
|
+
{ className: 'eo-summary' },
|
|
1277
|
+
h(Badge, { tone: 'info' }, 'template: ' + blueprint.template),
|
|
1278
|
+
h(Badge, { tone: 'neutral' }, 'permissions: ' + blueprint.permissions.length),
|
|
1279
|
+
h(Badge, { tone: 'neutral' }, 'confirm: ' + blueprint.steps.filter((step) => step.needsConfirm).length),
|
|
1280
|
+
h(Badge, { tone: 'neutral' }, 'min plugins: ' + blueprint.minPluginSet.length),
|
|
1281
|
+
),
|
|
1282
|
+
h(
|
|
1283
|
+
'table',
|
|
1284
|
+
{ className: 'eo-table' },
|
|
1285
|
+
h(
|
|
1286
|
+
'thead',
|
|
1287
|
+
null,
|
|
1288
|
+
h(
|
|
1289
|
+
'tr',
|
|
1290
|
+
null,
|
|
1291
|
+
h('th', null, '#'),
|
|
1292
|
+
h('th', null, '意图'),
|
|
1293
|
+
h('th', null, '类型'),
|
|
1294
|
+
h('th', null, '能力'),
|
|
1295
|
+
h('th', null, '工具'),
|
|
1296
|
+
h('th', null, '确认'),
|
|
1297
|
+
),
|
|
1298
|
+
),
|
|
1299
|
+
h(
|
|
1300
|
+
'tbody',
|
|
1301
|
+
null,
|
|
1302
|
+
blueprint.steps.map((step) =>
|
|
1303
|
+
h(
|
|
1304
|
+
'tr',
|
|
1305
|
+
{ key: step.id },
|
|
1306
|
+
h('td', null, h('code', null, step.id)),
|
|
1307
|
+
h('td', null, step.intent),
|
|
1308
|
+
h('td', null, h(Badge, { tone: step.kind === 'schedule' ? 'warn' : 'neutral' }, step.kind)),
|
|
1309
|
+
h('td', { className: 'eo-muted' }, step.capabilityId || '—'),
|
|
1310
|
+
h('td', { className: 'eo-muted' }, step.toolNames.join(', ') || '—'),
|
|
1311
|
+
h(
|
|
1312
|
+
'td',
|
|
1313
|
+
null,
|
|
1314
|
+
h(
|
|
1315
|
+
Badge,
|
|
1316
|
+
{ tone: step.needsConfirm ? 'warn' : 'neutral' },
|
|
1317
|
+
step.needsConfirm ? 'yes' : 'no',
|
|
1318
|
+
),
|
|
1319
|
+
),
|
|
1320
|
+
),
|
|
1321
|
+
),
|
|
1322
|
+
),
|
|
1323
|
+
),
|
|
1324
|
+
h(
|
|
1325
|
+
'div',
|
|
1326
|
+
{ className: 'eo-summary', style: { marginTop: '12px' } },
|
|
1327
|
+
blueprint.minPluginSet.map((plugin) =>
|
|
1328
|
+
h(Badge, { tone: 'info', key: plugin }, plugin),
|
|
1329
|
+
),
|
|
1330
|
+
),
|
|
1331
|
+
h(
|
|
1332
|
+
'div',
|
|
1333
|
+
{ className: 'eo-list' },
|
|
1334
|
+
h(
|
|
1335
|
+
'div',
|
|
1336
|
+
{ className: 'eo-issue' },
|
|
1337
|
+
h('span', null, h('strong', null, '失败策略:'), blueprint.failurePolicy),
|
|
1338
|
+
),
|
|
1339
|
+
h(
|
|
1340
|
+
'div',
|
|
1341
|
+
{ className: 'eo-issue' },
|
|
1342
|
+
h('span', null, h('strong', null, '回滚:'), blueprint.rollback),
|
|
1343
|
+
),
|
|
1344
|
+
),
|
|
1345
|
+
h(
|
|
1346
|
+
'div',
|
|
1347
|
+
{ className: 'eo-spacer' },
|
|
1348
|
+
),
|
|
1349
|
+
h(
|
|
1350
|
+
'div',
|
|
1351
|
+
{ className: 'eo-field-label' },
|
|
1352
|
+
'验收清单',
|
|
1353
|
+
),
|
|
1354
|
+
h(
|
|
1355
|
+
'div',
|
|
1356
|
+
{ className: 'eo-list', style: { marginTop: '6px' } },
|
|
1357
|
+
blueprint.acceptance.map((item, index) =>
|
|
1358
|
+
h('div', { className: 'eo-muted', key: index }, '☐ ' + item),
|
|
1359
|
+
),
|
|
1360
|
+
),
|
|
1361
|
+
),
|
|
1362
|
+
h(
|
|
1363
|
+
Card,
|
|
1364
|
+
{
|
|
1365
|
+
title: '校验与不确定性',
|
|
1366
|
+
subtitle:
|
|
1367
|
+
result.issues.filter((issue) => issue.level === 'error').length +
|
|
1368
|
+
' error / ' +
|
|
1369
|
+
result.issues.filter((issue) => issue.level === 'warn').length +
|
|
1370
|
+
' warn',
|
|
1371
|
+
},
|
|
1372
|
+
result.isWorkflow === false
|
|
1373
|
+
? h(
|
|
1374
|
+
'div',
|
|
1375
|
+
{ className: 'eo-issue eo-issue-warn' },
|
|
1376
|
+
h('span', null, '这个目标看起来更像普通问答,蓝图可能不适用。'),
|
|
1377
|
+
)
|
|
1378
|
+
: null,
|
|
1379
|
+
h(
|
|
1380
|
+
'div',
|
|
1381
|
+
{ className: 'eo-list' },
|
|
1382
|
+
result.issues.length === 0
|
|
1383
|
+
? h('div', { className: 'eo-empty' }, '校验通过,未发现 error 或 warn。')
|
|
1384
|
+
: result.issues.slice(0, 20).map((issue, index) =>
|
|
1385
|
+
h(
|
|
1386
|
+
'div',
|
|
1387
|
+
{
|
|
1388
|
+
className:
|
|
1389
|
+
'eo-issue ' + (issue.level === 'error' ? 'eo-issue-error' : 'eo-issue-warn'),
|
|
1390
|
+
key: index,
|
|
1391
|
+
},
|
|
1392
|
+
h('code', null, issue.code),
|
|
1393
|
+
h(
|
|
1394
|
+
'span',
|
|
1395
|
+
null,
|
|
1396
|
+
issue.message + (issue.stepId ? '(' + issue.stepId + ')' : ''),
|
|
1397
|
+
),
|
|
1398
|
+
),
|
|
1399
|
+
),
|
|
1400
|
+
),
|
|
1401
|
+
blueprint.uncertainties.length > 0
|
|
1402
|
+
? h(
|
|
1403
|
+
'div',
|
|
1404
|
+
{ style: { marginTop: '12px' } },
|
|
1405
|
+
h('div', { className: 'eo-field-label' }, '不确定性'),
|
|
1406
|
+
h(
|
|
1407
|
+
'div',
|
|
1408
|
+
{ className: 'eo-list', style: { marginTop: '6px' } },
|
|
1409
|
+
blueprint.uncertainties.map((item, index) =>
|
|
1410
|
+
h('div', { className: 'eo-issue', key: index }, h('span', null, item)),
|
|
1411
|
+
),
|
|
1412
|
+
),
|
|
1413
|
+
)
|
|
1414
|
+
: null,
|
|
1415
|
+
),
|
|
1416
|
+
)
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
function ConfirmModal({ state, draft, busy, onCancel, onConfirm }) {
|
|
1421
|
+
const isApply = state.type === 'apply'
|
|
1422
|
+
const items =
|
|
1423
|
+
isApply && draft
|
|
1424
|
+
? draft.items.filter((item) => state.ids.includes(item.id))
|
|
1425
|
+
: []
|
|
1426
|
+
return h(
|
|
1427
|
+
'div',
|
|
1428
|
+
{ className: 'eo-modal-backdrop', onClick: onCancel },
|
|
1429
|
+
h(
|
|
1430
|
+
'div',
|
|
1431
|
+
{ className: 'eo-modal', onClick: (event) => event.stopPropagation() },
|
|
1432
|
+
h('h3', null, isApply ? '确认应用精简方案' : '确认回滚'),
|
|
1433
|
+
h(
|
|
1434
|
+
'p',
|
|
1435
|
+
null,
|
|
1436
|
+
isApply
|
|
1437
|
+
? '只会应用低风险项;受保护项不会被改动。应用前会写入可回滚快照。'
|
|
1438
|
+
: '将恢复最近一次应用前的插件启用状态;已被外部改动的项会跳过。',
|
|
1439
|
+
),
|
|
1440
|
+
isApply
|
|
1441
|
+
? h(
|
|
1442
|
+
'div',
|
|
1443
|
+
{ className: 'eo-modal-list' },
|
|
1444
|
+
items.map((item) =>
|
|
1445
|
+
h(
|
|
1446
|
+
'div',
|
|
1447
|
+
{ className: 'eo-item', key: item.id },
|
|
1448
|
+
h(
|
|
1449
|
+
'div',
|
|
1450
|
+
{ className: 'eo-item-main' },
|
|
1451
|
+
h(
|
|
1452
|
+
'div',
|
|
1453
|
+
{ className: 'eo-item-title' },
|
|
1454
|
+
h('span', { className: 'eo-item-name' }, item.name),
|
|
1455
|
+
h(Badge, { tone: actionTone(item.action) }, actionLabel(item.action)),
|
|
1456
|
+
h(Badge, { tone: riskTone(item.risk) }, 'risk: ' + item.risk),
|
|
1457
|
+
),
|
|
1458
|
+
h('div', { className: 'eo-item-reason' }, item.reason),
|
|
1459
|
+
),
|
|
1460
|
+
),
|
|
1461
|
+
),
|
|
1462
|
+
)
|
|
1463
|
+
: null,
|
|
1464
|
+
h(
|
|
1465
|
+
'div',
|
|
1466
|
+
{ className: 'eo-modal-actions' },
|
|
1467
|
+
h(Button, { variant: 'ghost', onClick: onCancel, disabled: busy }, '取消'),
|
|
1468
|
+
h(
|
|
1469
|
+
Button,
|
|
1470
|
+
{ variant: isApply ? 'accent' : 'danger', onClick: onConfirm, disabled: busy },
|
|
1471
|
+
busy ? '处理中…' : isApply ? '确认应用' : '确认回滚',
|
|
1472
|
+
),
|
|
1473
|
+
),
|
|
1474
|
+
),
|
|
1475
|
+
)
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
function ExperienceOptimizerIcon({ size = 16, active = false }) {
|
|
1479
|
+
return h(
|
|
1480
|
+
'svg',
|
|
1481
|
+
{
|
|
1482
|
+
width: size,
|
|
1483
|
+
height: size,
|
|
1484
|
+
viewBox: '0 0 16 16',
|
|
1485
|
+
fill: 'none',
|
|
1486
|
+
stroke: 'currentColor',
|
|
1487
|
+
strokeWidth: active ? 1.6 : 1.4,
|
|
1488
|
+
strokeLinecap: 'round',
|
|
1489
|
+
strokeLinejoin: 'round',
|
|
1490
|
+
'aria-hidden': 'true',
|
|
1491
|
+
},
|
|
1492
|
+
h('path', { d: 'M2.8 4h10.4' }),
|
|
1493
|
+
h('circle', { cx: 6, cy: 4, r: 1.45 }),
|
|
1494
|
+
h('path', { d: 'M2.8 8h10.4' }),
|
|
1495
|
+
h('circle', { cx: 10.2, cy: 8, r: 1.45 }),
|
|
1496
|
+
h('path', { d: 'M2.8 12h10.4' }),
|
|
1497
|
+
h('circle', { cx: 7.2, cy: 12, r: 1.45 }),
|
|
1498
|
+
)
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
function apply(ctx) {
|
|
1502
|
+
injectCss()
|
|
1503
|
+
ctx.slots.inject('settings.plugins.tab', () =>
|
|
1504
|
+
ctx.slots.register(
|
|
1505
|
+
{
|
|
1506
|
+
name: 'settings.plugins.tab',
|
|
1507
|
+
id: 'experience-optimizer',
|
|
1508
|
+
order: 40,
|
|
1509
|
+
label: () => '体验优化',
|
|
1510
|
+
},
|
|
1511
|
+
ExperiencePanel,
|
|
1512
|
+
),
|
|
1513
|
+
)
|
|
1514
|
+
ctx.slots.inject('settings.section', () =>
|
|
1515
|
+
ctx.slots.register(
|
|
1516
|
+
{
|
|
1517
|
+
name: 'settings.section',
|
|
1518
|
+
id: 'experience-optimizer',
|
|
1519
|
+
order: 25,
|
|
1520
|
+
label: () => '体验优化',
|
|
1521
|
+
},
|
|
1522
|
+
ExperiencePanel,
|
|
1523
|
+
),
|
|
1524
|
+
)
|
|
1525
|
+
ctx.slots.inject('settings.section.icon', () =>
|
|
1526
|
+
ctx.slots.register(
|
|
1527
|
+
{
|
|
1528
|
+
name: 'settings.section.icon',
|
|
1529
|
+
id: 'experience-optimizer',
|
|
1530
|
+
},
|
|
1531
|
+
ExperienceOptimizerIcon,
|
|
1532
|
+
),
|
|
1533
|
+
)
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
exports.apply = apply
|
|
1537
|
+
exports.inject = ['slots']
|
|
1538
|
+
return module.exports
|
|
1539
|
+
},
|
|
1540
|
+
})
|