@jayyuen66/dsh-dir-prep-organize 0.1.5 → 0.1.7
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/CHANGELOG.md +146 -0
- package/LICENSE +1 -1
- package/README.md +25 -21
- package/README.zh-CN.md +25 -21
- package/THIRD_PARTY_NOTICES.md +3 -1
- package/agents/academic/academic-statistician.md +143 -0
- package/agents/design/design-inclusive-visuals-specialist.md +4 -3
- package/agents/design/design-ui-designer.md +6 -3
- package/agents/design/design-ux-architect.md +20 -7
- package/agents/design/design-whimsy-injector.md +23 -1
- package/agents/engineering/engineering-autonomous-optimization-architect.md +31 -22
- package/agents/engineering/engineering-backend-architect.md +43 -54
- package/agents/engineering/engineering-data-engineer.md +21 -6
- package/agents/engineering/engineering-database-optimizer.md +22 -10
- package/agents/engineering/engineering-devops-automator.md +12 -3
- package/agents/engineering/engineering-email-intelligence-engineer.md +41 -4
- package/agents/engineering/engineering-embedded-firmware-engineer.md +27 -5
- package/agents/engineering/engineering-feishu-integration-developer.md +10 -2
- package/agents/engineering/engineering-frontend-developer.md +24 -18
- package/agents/engineering/engineering-git-workflow-master.md +16 -4
- package/agents/engineering/engineering-incident-response-commander.md +3 -3
- package/agents/engineering/engineering-prompt-engineer.md +7 -2
- package/agents/engineering/engineering-rapid-prototyper.md +7 -3
- package/agents/engineering/engineering-security-engineer.md +2 -0
- package/agents/engineering/engineering-solidity-smart-contract-engineer.md +1 -1
- package/agents/engineering/engineering-technical-writer.md +4 -4
- package/agents/engineering/engineering-threat-detection-engineer.md +2 -0
- package/agents/engineering/engineering-voice-ai-integration-engineer.md +39 -16
- package/agents/engineering/engineering-wechat-mini-program-developer.md +7 -2
- package/agents/game-development/blender/blender-addon-engineer.md +12 -3
- package/agents/game-development/economy-designer.md +155 -0
- package/agents/game-development/godot/godot-gameplay-scripter.md +4 -0
- package/agents/game-development/godot/godot-multiplayer-engineer.md +6 -2
- package/agents/game-development/godot/godot-shader-developer.md +4 -3
- package/agents/game-development/roblox-studio/roblox-experience-designer.md +7 -6
- package/agents/game-development/roblox-studio/roblox-systems-scripter.md +7 -0
- package/agents/game-development/technical-artist.md +4 -0
- package/agents/game-development/unity/unity-multiplayer-engineer.md +67 -0
- package/agents/game-development/unreal-engine/unreal-multiplayer-architect.md +82 -31
- package/agents/game-development/unreal-engine/unreal-systems-engineer.md +13 -1
- package/agents/marketing/marketing-agentic-search-optimizer.md +50 -87
- package/agents/marketing/marketing-carousel-growth-engine.md +49 -35
- package/agents/marketing/marketing-private-domain-operator.md +2 -2
- package/agents/marketing/marketing-seo-specialist.md +22 -0
- package/agents/product/product-behavioral-nudge-engine.md +3 -0
- package/agents/project-management/project-management-jira-workflow-steward.md +5 -2
- package/agents/security/security-appsec-engineer.md +75 -43
- package/agents/security/security-threat-detection-engineer.md +6 -0
- package/agents/security/security-threat-intelligence-analyst.md +32 -15
- package/agents/specialized/accounts-payable-agent.md +39 -45
- package/agents/specialized/grant-writer.md +2 -2
- package/agents/specialized/healthcare-aging-parent-care-companion.md +396 -0
- package/agents/specialized/identity-graph-operator.md +24 -3
- package/agents/specialized/lsp-index-engineer.md +17 -15
- package/agents/specialized/recruitment-specialist.md +17 -11
- package/agents/specialized/specialized-developer-advocate.md +4 -4
- package/agents/specialized/specialized-fedramp-rmf-compliance.md +379 -0
- package/agents/specialized/specialized-focus-music-architect.md +176 -0
- package/agents/specialized/specialized-french-consulting-market.md +17 -15
- package/agents/specialized/specialized-model-qa.md +78 -34
- package/agents/specialized/specialized-salesforce-architect.md +17 -15
- package/agents/specialized/specialized-workflow-architect.md +2 -2
- package/agents/supply-chain/supply-chain-strategist.md +12 -3
- package/agents/support/support-analytics-reporter.md +48 -30
- package/agents/support/support-finance-tracker.md +36 -18
- package/agents/support/support-infrastructure-maintainer.md +2 -2
- package/agents/support/support-support-responder.md +43 -26
- package/agents/testing/testing-api-tester.md +37 -27
- package/agents/testing/testing-performance-benchmarker.md +82 -47
- package/agents/testing/testing-test-results-analyzer.md +37 -18
- package/agents/testing/testing-tool-evaluator.md +30 -10
- package/client.js +470 -287
- package/cordis.patch.yml +4 -23
- package/docs/DETAIL.md +26 -0
- package/docs/DETAIL.zh.md +26 -0
- package/host.js +84 -25
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +61 -52
- package/templates.data.mjs +9 -10
- package/types/host.d.ts +36 -4
- package/types/src/client-entry.d.ts +2 -3
- package/types/src/host-messages.d.ts +2 -0
- package/types/src/input-writeback.d.ts +32 -0
- package/types/src/remote.d.ts +7 -1
- package/types/src/ui-messages.d.ts +19 -6
package/client.js
CHANGED
|
@@ -7,12 +7,12 @@ window.__ModuleLoader__.load({
|
|
|
7
7
|
let exports = module.exports;
|
|
8
8
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
9
9
|
let react = require("react");
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
let zod = require("zod");
|
|
11
|
+
// node_modules/@jayyuen66/dsh-plugin-shared/dist/record.js
|
|
12
|
+
function e$1(e) {
|
|
12
13
|
return typeof e == `object` && !!e && !Array.isArray(e);
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
//#region src/templates.ts
|
|
15
|
+
// src/templates.ts
|
|
16
16
|
/** 一条提示引导词/角色模板(settings 持久化形状:全 string 字段的普通对象,
|
|
17
17
|
* 满足 dsh-settings cloneJsonShaped 的 JSON 白名单)。description/group/emoji
|
|
18
18
|
* 为必填(空串表示未设置),保证下拉与设置卡无缺字段分支。 */
|
|
@@ -64,7 +64,7 @@ function uniqueEntryId(candidate, index, seen) {
|
|
|
64
64
|
* 返回 undefined 表示该条应被剔除。 */
|
|
65
65
|
function normalizeEntry(item, index, seen) {
|
|
66
66
|
let result;
|
|
67
|
-
if (e(item)) {
|
|
67
|
+
if (e$1(item)) {
|
|
68
68
|
const { id, name, description, text, group, emoji } = item;
|
|
69
69
|
const nextName = trimField(name);
|
|
70
70
|
const nextText = trimField(text);
|
|
@@ -108,14 +108,15 @@ function sanitizeAllowRoots(raw) {
|
|
|
108
108
|
}
|
|
109
109
|
return out;
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
//#region src/client-timeouts.ts
|
|
111
|
+
// src/client-timeouts.ts
|
|
113
112
|
/**
|
|
114
113
|
* `setTimeout` 延时上界(Node/V8 的 2^31-1 ms)。
|
|
115
114
|
*
|
|
116
115
|
* 超了它 V8 只往 stderr 打一条 TimeoutOverflowWarning,然后把延时**静默夹成 1 ms**。
|
|
117
116
|
*/
|
|
118
117
|
const MAX_TIMER_MS = 2147483647;
|
|
118
|
+
/** 配置表单里读不到 `organizeTimeoutMs` 时的回落值(与 host 侧 ORGANIZE_TIMEOUT_MS 同值)。 */
|
|
119
|
+
const ORGANIZE_TIMEOUT_FALLBACK_MS = 12e4;
|
|
119
120
|
/** 客户端比 host 多等的余量:host 先超时,客户端留一点时间把它的回执读回来。 */
|
|
120
121
|
const ORGANIZE_TIMEOUT_SLACK_MS = 5e3;
|
|
121
122
|
/**
|
|
@@ -141,77 +142,54 @@ function rawOrganizeTimeoutMsOf(value) {
|
|
|
141
142
|
* @returns 可安全交给 setTimeout 的毫秒数
|
|
142
143
|
*/
|
|
143
144
|
function organizeFetchTimeoutMs(raw) {
|
|
144
|
-
return Math.min(Math.max((raw
|
|
145
|
+
return Math.trunc(Math.min(Math.max((typeof raw === "number" && Number.isFinite(raw) && raw > 0 ? raw : ORGANIZE_TIMEOUT_FALLBACK_MS) + ORGANIZE_TIMEOUT_SLACK_MS, 1), MAX_TIMER_MS));
|
|
145
146
|
}
|
|
146
|
-
|
|
147
|
-
//#region src/client-styles.ts
|
|
147
|
+
// src/client-styles.ts
|
|
148
148
|
const CARD_STYLES = [
|
|
149
|
-
".dpi-btn{appearance:none;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;line-height:1;border-radius:8px;padding:6px 10px;cursor:pointer;display:inline-flex;align-items:center;gap:6px;transition:background .16s,border-color .16s,color .16s}",
|
|
150
|
-
".dpi-btn:hover:not(:disabled){border-color:var(--dsw-alias-label-dimmed);background:var(--dsw-alias-bg-layer-2)}",
|
|
149
|
+
".dpi-btn{appearance:none;border:1px solid var(--dsw-alias-border-l2,currentColor);background:var(--dsw-alias-bg-layer-1,transparent);color:var(--dsw-alias-label-primary,inherit);font:inherit;font-size:12px;line-height:1;border-radius:8px;padding:6px 10px;cursor:pointer;display:inline-flex;align-items:center;gap:6px;transition:background .16s,border-color .16s,color .16s}",
|
|
150
|
+
".dpi-btn:hover:not(:disabled){border-color:var(--dsw-alias-label-dimmed,currentColor);background:var(--dsw-alias-bg-layer-2,transparent)}",
|
|
151
151
|
".dpi-btn:disabled{opacity:.55;cursor:not-allowed}",
|
|
152
152
|
".dpi-btn:disabled[data-state=\"loading\"]{cursor:progress}",
|
|
153
|
-
".dpi-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}",
|
|
153
|
+
".dpi-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:1px}",
|
|
154
154
|
".dpi-btn svg{width:14px;height:14px;flex:none}",
|
|
155
|
-
".dpi-btn-err{border-color:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-state-error-secondary)}",
|
|
155
|
+
".dpi-btn-err{border-color:var(--dsw-alias-state-error-primary,currentColor);color:var(--dsw-alias-state-error-secondary,currentColor)}",
|
|
156
|
+
".dpi-btn-err:hover:not(:disabled){border-color:var(--dsw-alias-state-error-primary,currentColor)}",
|
|
156
157
|
".dpi-spin{animation:dpi-rotate .8s linear infinite}",
|
|
157
158
|
"@keyframes dpi-rotate{to{transform:rotate(360deg)}}",
|
|
158
|
-
".dpi-
|
|
159
|
-
".dpi-
|
|
160
|
-
".dpi-
|
|
161
|
-
".dpi-item:
|
|
162
|
-
".dpi-item-
|
|
159
|
+
"@media (prefers-reduced-motion:reduce){.dpi-spin{animation:none}.dpi-btn{transition:none}}",
|
|
160
|
+
".dpi-wrap{position:relative;display:inline-flex;isolation:isolate}",
|
|
161
|
+
".dpi-menu{position:absolute;bottom:calc(100% + 6px);right:0;z-index:50;min-width:224px;max-height:340px;overflow-y:auto;background:var(--dsw-menu-surface-fill,transparent);backdrop-filter:var(--dsw-menu-backdrop-filter,none);border:0;border-radius:10px;padding:4px;display:flex;flex-direction:column;gap:2px;box-shadow:var(--dsw-elevation-panel,none)}",
|
|
162
|
+
".dpi-item{appearance:none;border:none;background:transparent;color:var(--dsw-alias-label-primary,inherit);font:inherit;font-size:12px;line-height:1.4;text-align:left;border-radius:6px;padding:8px 10px;cursor:pointer;white-space:nowrap}",
|
|
163
|
+
".dpi-item:hover,.dpi-item:focus-visible{background:var(--dsw-alias-bg-layer-2,transparent)}",
|
|
164
|
+
".dpi-item-empty{color:var(--dsw-alias-label-tertiary,inherit);cursor:default;font-size:12px;padding:8px 10px;white-space:nowrap}",
|
|
163
165
|
".dpi-split{display:inline-flex;align-items:stretch}",
|
|
164
166
|
".dpi-split .dpi-main{border-top-right-radius:0;border-bottom-right-radius:0;padding-right:8px}",
|
|
165
167
|
".dpi-split .dpi-caret{border-left:none;border-top-left-radius:0;border-bottom-left-radius:0;padding-left:4px;padding-right:6px}",
|
|
166
168
|
".dpi-split .dpi-caret svg{width:10px;height:10px}",
|
|
167
169
|
".dpi-group{padding:2px 0}",
|
|
168
|
-
".dpi-grouph{font-size:11px;font-weight:600;color:var(--dsw-alias-label-tertiary);padding:6px 10px 2px;letter-spacing:.02em}",
|
|
169
|
-
".dpic-
|
|
170
|
-
".dpic-
|
|
171
|
-
".dpic-
|
|
172
|
-
".dpic-
|
|
173
|
-
".dpic-
|
|
174
|
-
".dpic-
|
|
175
|
-
".dpic-
|
|
176
|
-
".dpic-
|
|
177
|
-
".dpic-
|
|
178
|
-
".dpic-
|
|
179
|
-
".dpic-
|
|
170
|
+
".dpi-grouph{font-size:11px;font-weight:600;color:var(--dsw-alias-label-tertiary,inherit);padding:6px 10px 2px;letter-spacing:.02em}",
|
|
171
|
+
".dpic-row{padding:10px 0;border-bottom:1px dashed var(--dsw-alias-border-l2,currentColor)}",
|
|
172
|
+
".dpic-name{flex:1;min-width:0}",
|
|
173
|
+
".dpic-rowhead .dpic-name{width:auto}",
|
|
174
|
+
".dpic-rowhead .dpic-emoji{width:44px;flex:none;text-align:center}",
|
|
175
|
+
".dpic-rowhead .dpic-group{width:84px;flex:none}",
|
|
176
|
+
".dpic-desc{width:100%;margin-top:6px}",
|
|
177
|
+
".dpic-text{width:100%;margin-top:6px}",
|
|
178
|
+
".dpic-importpath{flex:1;min-width:0}",
|
|
179
|
+
".dpic-rowhead .dpic-importpath{width:auto}",
|
|
180
|
+
".dpic-del{flex:none}",
|
|
181
|
+
".dpic-toolbar{display:flex;gap:8px;flex-wrap:wrap;padding:8px 0}",
|
|
180
182
|
".dpic-rowhead{display:flex;gap:8px;align-items:center}",
|
|
181
|
-
".dpic-idx{font-size:12px;color:var(--dsw-alias-label-tertiary);flex:none;min-width:26px}",
|
|
182
|
-
".dpic-
|
|
183
|
-
".dpic-
|
|
184
|
-
".dpic-
|
|
185
|
-
".dpic-del:disabled{opacity:.55;cursor:not-allowed}",
|
|
186
|
-
".dpic-header:focus-visible,.dpic-del:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}",
|
|
187
|
-
".dpic-text{width:100%;box-sizing:border-box;font:inherit;font-size:12px;line-height:1.6;color:var(--dsw-alias-label-primary,inherit);background:var(--dsw-alias-bg-layer-1,transparent);border:1px solid var(--dsw-alias-border-l2,transparent);border-radius:8px;padding:8px;margin-top:6px;min-height:96px;resize:vertical}",
|
|
188
|
-
".dpic-name:focus,.dpic-text:focus{outline:none;border-color:var(--dsw-alias-brand-primary)}",
|
|
189
|
-
".dpic-emoji{width:44px;flex:none;box-sizing:border-box;font:inherit;font-size:13px;text-align:center;color:var(--dsw-alias-label-primary,inherit);background:var(--dsw-alias-bg-layer-1,transparent);border:1px solid var(--dsw-alias-border-l2,transparent);border-radius:8px;padding:6px 4px}",
|
|
190
|
-
".dpic-group{width:84px;flex:none;box-sizing:border-box;font:inherit;font-size:12px;color:var(--dsw-alias-label-primary,inherit);background:var(--dsw-alias-bg-layer-1,transparent);border:1px solid var(--dsw-alias-border-l2,transparent);border-radius:8px;padding:6px 8px}",
|
|
191
|
-
".dpic-desc{width:100%;box-sizing:border-box;font:inherit;font-size:12px;color:var(--dsw-alias-label-primary,inherit);background:var(--dsw-alias-bg-layer-1,transparent);border:1px solid var(--dsw-alias-border-l2,transparent);border-radius:8px;padding:6px 8px;margin-top:6px}",
|
|
192
|
-
".dpic-emoji:focus,.dpic-group:focus,.dpic-desc:focus{outline:none;border-color:var(--dsw-alias-brand-primary)}",
|
|
193
|
-
".dpic-importrow{padding:12px 0;border-bottom:1px dashed var(--dsw-alias-border-l2)}",
|
|
194
|
-
".dpic-importpath{flex:1;min-width:0;box-sizing:border-box;font:inherit;font-size:12px;color:var(--dsw-alias-label-primary,inherit);background:var(--dsw-alias-bg-layer-1,transparent);border:1px solid var(--dsw-alias-border-l2,transparent);border-radius:8px;padding:6px 8px}",
|
|
195
|
-
".dpic-importpath:focus{outline:none;border-color:var(--dsw-alias-brand-primary)}",
|
|
196
|
-
".dpic-foot{display:flex;gap:8px;align-items:center;padding-top:10px;flex-wrap:wrap}",
|
|
197
|
-
".dpic-btn{appearance:none;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;border-radius:8px;padding:6px 10px;cursor:pointer}",
|
|
198
|
-
".dpic-btn:hover:not(:disabled){border-color:var(--dsw-alias-label-dimmed);background:var(--dsw-alias-bg-layer-2)}",
|
|
199
|
-
".dpic-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}",
|
|
200
|
-
".dpic-btn:disabled{opacity:.55;cursor:not-allowed}",
|
|
201
|
-
".dpic-btn-primary{background:var(--dsw-alias-brand-primary);border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary-foreground)}",
|
|
202
|
-
".dpic-btn-primary:hover:not(:disabled){background:var(--dsw-alias-brand-primary);border-color:var(--dsw-alias-brand-primary)}",
|
|
203
|
-
".dpic-btn-primary:disabled{opacity:.55;cursor:not-allowed}",
|
|
204
|
-
".dpic-btn-danger{color:var(--dsw-alias-state-error-primary)}",
|
|
205
|
-
".dpic-btn-danger:hover:not(:disabled){border-color:var(--dsw-alias-state-error-primary)}",
|
|
206
|
-
".dpic-hint{font-size:12px;color:var(--dsw-alias-label-tertiary);line-height:1.5;padding-top:6px}",
|
|
207
|
-
".dpic-err{color:var(--dsw-alias-state-error-primary)}"
|
|
183
|
+
".dpic-idx{font-size:12px;color:var(--dsw-alias-label-tertiary,inherit);flex:none;min-width:26px}",
|
|
184
|
+
".dpic-importrow{padding:12px 0;border-bottom:1px dashed var(--dsw-alias-border-l2,currentColor)}",
|
|
185
|
+
".dpic-hint{font-size:12px;color:var(--dsw-alias-label-tertiary,inherit);line-height:1.5;padding-top:6px}",
|
|
186
|
+
".dpic-err{color:var(--dsw-alias-state-error-primary,currentColor)}"
|
|
208
187
|
].join("\n");
|
|
209
|
-
|
|
210
|
-
//#region src/ui-messages.ts
|
|
188
|
+
// src/ui-messages.ts
|
|
211
189
|
const UI_MESSAGES = {
|
|
212
190
|
zh: {
|
|
213
|
-
|
|
214
|
-
|
|
191
|
+
rolesSection: "角色库",
|
|
192
|
+
rolesHint: "输入框「模板」下拉与「润色」▾ 角色菜单共用这一份列表,空表即回落到内置精选角色集(生成自插件 agents/ 角色库)。留空点「导入角色」可一键导入内置全部;填路径则按「会话 cwd + 内置角色库 + 下方导入允许目录」放行。编辑后点「保存」生效,重启不丢。",
|
|
215
193
|
statusReadOnly: "设置源不可写:编辑已禁用;下拉仍按当前列表生效。",
|
|
216
194
|
statusNotReady: "设置源未就绪:显示当前生效列表,就绪后可编辑。",
|
|
217
195
|
addTemplate: "+ 新增模板",
|
|
@@ -221,12 +199,11 @@ const UI_MESSAGES = {
|
|
|
221
199
|
save: "保存",
|
|
222
200
|
revert: "撤销",
|
|
223
201
|
resetTitle: "丢弃模板列表的全部自定义,回到内置默认(不影响已登记的导入允许目录;两步确认,点击即生效)",
|
|
224
|
-
resetConfirm: "确认恢复默认?再点一次(
|
|
202
|
+
resetConfirm: "确认恢复默认?再点一次({seconds} 秒内)",
|
|
225
203
|
resetDefault: "恢复默认",
|
|
226
204
|
footHint: "说明:编辑/新增/删除先在本地暂存,点「保存」一次写入(模板与导入允许目录同理);清空名称或正文的条目保存时会被剔除(删除请用行内「删除」);恢复默认只回滚模板列表。",
|
|
227
205
|
saveFailed: "保存失败:",
|
|
228
206
|
newTemplateName: "新模板 {index}",
|
|
229
|
-
newTemplateText: "(填写模板正文:点选后插入输入框、随消息发给模型的文字)",
|
|
230
207
|
persistUnconfirmed: "{action}结果不可确认:设置源未就绪(宿主未回读成功)",
|
|
231
208
|
persistRejected: "{action}未生效:宿主拒绝了本次写入(当前 revision {revision})",
|
|
232
209
|
rowAriaEmoji: "模板 {index} 视觉标记",
|
|
@@ -277,6 +254,11 @@ const UI_MESSAGES = {
|
|
|
277
254
|
organizeFailedShort: "失败",
|
|
278
255
|
organizeIdleTitle: "结合当前目录润色输入框内容(主键直接润色;▾ 可选角色风格)",
|
|
279
256
|
organizeFailedTitle: "润色失败:{message}",
|
|
257
|
+
organizeErrContextFailed: "目录上下文读取失败:{message}",
|
|
258
|
+
organizeErrModelFailed: "读取模型失败:{message}",
|
|
259
|
+
organizeErrEmpty: "输入框为空,无内容可润色",
|
|
260
|
+
organizeErrUnknownReason: "未知错误",
|
|
261
|
+
organizeErrUnknown: "润色失败(未知错误)",
|
|
280
262
|
organizeCaretAria: "选择润色的角色风格",
|
|
281
263
|
organizeCaretTitle: "按某个角色的风格润色(角色来自下方模板库)",
|
|
282
264
|
organizeMainAria: "润色输入框内容",
|
|
@@ -284,18 +266,21 @@ const UI_MESSAGES = {
|
|
|
284
266
|
organizeNoTemplates: "无模板可选作角色风格",
|
|
285
267
|
organizeRoleItem: "以「{name}」的风格润色",
|
|
286
268
|
organizeWriteBackUnavailable: "输入框动作不可用,无法写回",
|
|
287
|
-
|
|
269
|
+
organizeWriteBackStale: "输入框内容已变化,润色结果未写回",
|
|
270
|
+
organizeBusyTitle: "输入框正在提交,暂不能润色",
|
|
271
|
+
templatesIdleTitle: "选择一条模板插入光标处(按分组展示)",
|
|
288
272
|
templatesBrokenTitle: "输入框动作不可用,无法插入",
|
|
273
|
+
templatesBusyTitle: "输入框正在提交,暂不能插入模板",
|
|
289
274
|
templatesGroupCommon: "通用",
|
|
290
275
|
templatesAria: "插入模板",
|
|
291
|
-
templatesEmptyHint: "
|
|
276
|
+
templatesEmptyHint: "无模板:在设置页「角色库」中添加或恢复默认",
|
|
292
277
|
builtinLoading: "正在载入内置角色模板…",
|
|
293
278
|
builtinFailed: "内置模板加载失败:{message}",
|
|
294
279
|
builtinRetry: "重试"
|
|
295
280
|
},
|
|
296
281
|
en: {
|
|
297
|
-
|
|
298
|
-
|
|
282
|
+
rolesSection: "Role library",
|
|
283
|
+
rolesHint: "The input-box \"Template\" dropdown and the \"Polish\" ▾ role menu share this one list; an empty list falls back to the built-in curated role set (generated from this plugin's agents/ role library). Leave the path empty and press \"Import roles\" to import the whole built-in library; an explicit path is allowed within \"session cwd + built-in role library + the import allowed directories below\". Press \"Save\" after editing — it survives restarts.",
|
|
299
284
|
statusReadOnly: "Settings source is read-only: editing is disabled; the dropdown still uses the current list.",
|
|
300
285
|
statusNotReady: "Settings source is not ready yet: showing the list currently in effect, editing unlocks once it is ready.",
|
|
301
286
|
addTemplate: "+ Add template",
|
|
@@ -305,12 +290,11 @@ const UI_MESSAGES = {
|
|
|
305
290
|
save: "Save",
|
|
306
291
|
revert: "Revert",
|
|
307
292
|
resetTitle: "Discard every customization of the template list and go back to the built-in defaults (registered import directories are untouched; two-step confirm, takes effect on the next click)",
|
|
308
|
-
resetConfirm: "Restore defaults? Click once more (within
|
|
293
|
+
resetConfirm: "Restore defaults? Click once more (within {seconds}s)",
|
|
309
294
|
resetDefault: "Restore defaults",
|
|
310
295
|
footHint: "Note: edits, additions and deletions are staged locally first and written in one go when you press \"Save\" (same for templates and import directories); entries whose name or body is empty are dropped on save (use the inline \"Delete\" instead); \"Restore defaults\" only rolls back the template list.",
|
|
311
296
|
saveFailed: "Save failed: ",
|
|
312
297
|
newTemplateName: "New template {index}",
|
|
313
|
-
newTemplateText: "(Template body: the text inserted into the input box and sent to the model with your message)",
|
|
314
298
|
persistUnconfirmed: "{action} cannot be confirmed: the settings source is not ready (host read-back failed)",
|
|
315
299
|
persistRejected: "{action} did not take effect: the host rejected this write (current revision {revision})",
|
|
316
300
|
rowAriaEmoji: "Visual mark of template {index}",
|
|
@@ -361,6 +345,11 @@ const UI_MESSAGES = {
|
|
|
361
345
|
organizeFailedShort: "Failed",
|
|
362
346
|
organizeIdleTitle: "Polish the input-box content against the current directory (main key polishes directly; ▾ picks a role style)",
|
|
363
347
|
organizeFailedTitle: "Polish failed: {message}",
|
|
348
|
+
organizeErrContextFailed: "Failed to read the directory context: {message}",
|
|
349
|
+
organizeErrModelFailed: "Failed to read the model: {message}",
|
|
350
|
+
organizeErrEmpty: "The input box is empty; nothing to polish",
|
|
351
|
+
organizeErrUnknownReason: "unknown error",
|
|
352
|
+
organizeErrUnknown: "Polish failed (unknown error)",
|
|
364
353
|
organizeCaretAria: "Choose a role style to polish with",
|
|
365
354
|
organizeCaretTitle: "Polish in a role's style (roles come from the template library below)",
|
|
366
355
|
organizeMainAria: "Polish the input-box content",
|
|
@@ -368,34 +357,36 @@ const UI_MESSAGES = {
|
|
|
368
357
|
organizeNoTemplates: "No templates available as a role style",
|
|
369
358
|
organizeRoleItem: "Polish in the style of \"{name}\"",
|
|
370
359
|
organizeWriteBackUnavailable: "Input-box actions unavailable; cannot write back",
|
|
371
|
-
|
|
360
|
+
organizeWriteBackStale: "The input box changed; the polished text was not applied",
|
|
361
|
+
organizeBusyTitle: "The input box is submitting; cannot polish right now",
|
|
362
|
+
templatesIdleTitle: "Pick a template to insert at the caret (shown grouped)",
|
|
372
363
|
templatesBrokenTitle: "Input-box actions unavailable; cannot insert",
|
|
364
|
+
templatesBusyTitle: "The input box is submitting; cannot insert a template",
|
|
373
365
|
templatesGroupCommon: "General",
|
|
374
366
|
templatesAria: "Insert a template",
|
|
375
|
-
templatesEmptyHint: "No templates: add or restore defaults under \"
|
|
367
|
+
templatesEmptyHint: "No templates: add or restore defaults under \"Role library\" in the settings page",
|
|
376
368
|
builtinLoading: "Loading built-in role templates…",
|
|
377
369
|
builtinFailed: "Failed to load built-in templates: {message}",
|
|
378
370
|
builtinRetry: "Retry"
|
|
379
371
|
}
|
|
380
372
|
};
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
function t(e) {
|
|
373
|
+
// node_modules/@jayyuen66/dsh-plugin-shared/dist/errors.js
|
|
374
|
+
function t$1(e) {
|
|
384
375
|
let t = Object.getOwnPropertyDescriptor(e, `message`);
|
|
385
376
|
return t !== void 0 && `value` in t && typeof t.value == `string` ? t.value : void 0;
|
|
386
377
|
}
|
|
387
|
-
function n(e, r) {
|
|
378
|
+
function n$1(e, r) {
|
|
388
379
|
if (r.has(e)) return `<circular cause>`;
|
|
389
380
|
r.add(e);
|
|
390
381
|
try {
|
|
391
382
|
if (!(e instanceof Error)) {
|
|
392
383
|
if (typeof e == `object` && e) {
|
|
393
|
-
let n = t(e);
|
|
394
|
-
if (n !== void 0) return n;
|
|
384
|
+
let n = t$1(e);
|
|
385
|
+
if (n !== void 0 && n !== ``) return n;
|
|
395
386
|
}
|
|
396
387
|
return String(e);
|
|
397
388
|
}
|
|
398
|
-
let i = e.message === `` ? e.name : e.message, a = e instanceof AggregateError && e.errors.length > 0 ? ` [${e.errors.map((e) => n(e, r)).join(`; `)}]` : ``, o = e.cause === void 0 || e.cause === null ? `` : n(e.cause, r);
|
|
389
|
+
let i = e.message === `` ? e.name : e.message, a = typeof globalThis.AggregateError == `function` && e instanceof AggregateError && e.errors.length > 0 ? ` [${e.errors.map((e) => n$1(e, r)).join(`; `)}]` : ``, o = e.cause === void 0 || e.cause === null ? `` : n$1(e.cause, r);
|
|
399
390
|
return `${i}${a}${o === `` || o === i ? `` : `: ${o}`}`;
|
|
400
391
|
} catch {
|
|
401
392
|
return `<unrenderable value>`;
|
|
@@ -403,11 +394,167 @@ function n(e, r) {
|
|
|
403
394
|
r.delete(e);
|
|
404
395
|
}
|
|
405
396
|
}
|
|
406
|
-
function r(e) {
|
|
407
|
-
return n(e, /* @__PURE__ */ new Set());
|
|
397
|
+
function r$1(e) {
|
|
398
|
+
return n$1(e, /* @__PURE__ */ new Set());
|
|
399
|
+
}
|
|
400
|
+
// node_modules/@jayyuen66/dsh-plugin-shared/dist/card-ui.js
|
|
401
|
+
const c = `
|
|
402
|
+
.dsu-form{display:flex;flex-direction:column}
|
|
403
|
+
.dsu-section{margin-top:24px;padding-top:24px;border-top:.5px solid var(--dsw-alias-border-l1)}
|
|
404
|
+
.dsu-form>.dsu-section:first-child{margin-top:0;padding-top:0;border-top:0}
|
|
405
|
+
.dsu-sectionTitle{margin:0;font-size:15px;font-weight:600;line-height:1.4;color:var(--dsw-alias-label-primary)}
|
|
406
|
+
.dsu-sectionHint{margin:4px 0 0;font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}
|
|
407
|
+
.dsu-statusbar{display:flex;flex-wrap:wrap;gap:4px 8px;margin-top:8px;font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}
|
|
408
|
+
.dsu-field{display:grid;grid-template-columns:minmax(0,1fr) minmax(240px,360px);column-gap:32px;align-items:center;padding:12px 0;border-top:.5px solid var(--dsw-alias-border-l2)}
|
|
409
|
+
.dsu-fieldMeta{display:flex;flex-direction:column;gap:4px;min-width:0}
|
|
410
|
+
.dsu-labelRow{display:flex;align-items:center;gap:6px;min-width:0}
|
|
411
|
+
.dsu-label{font-size:13px;font-weight:500;line-height:1.5;color:var(--dsw-alias-label-primary)}
|
|
412
|
+
.dsu-labelMono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12px}
|
|
413
|
+
.dsu-hint{margin:0;font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}
|
|
414
|
+
.dsu-control{min-width:0;display:flex;align-items:center;gap:8px}
|
|
415
|
+
.dsu-fieldWide{grid-template-columns:minmax(0,1fr);align-items:start}
|
|
416
|
+
.dsu-fieldWide .dsu-control{width:100%;max-width:720px;margin-top:2px}
|
|
417
|
+
.dsu-help{display:inline-flex;align-items:center;gap:6px;min-width:0}
|
|
418
|
+
.dsu-helpBtn{appearance:none;border:0;background:transparent;padding:0;width:16px;height:16px;display:inline-flex;align-items:center;justify-content:center;color:var(--dsw-alias-label-tertiary);cursor:help;border-radius:50%;flex:none}
|
|
419
|
+
.dsu-help:hover .dsu-helpBtn,.dsu-helpBtn:focus-visible{color:var(--dsw-alias-label-primary)}
|
|
420
|
+
.dsu-helpBtn:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:1px}
|
|
421
|
+
.dsu-tip{position:fixed;z-index:60;box-sizing:border-box;max-width:min(340px,calc(100vw - 16px));max-height:calc(100vh - 16px);overflow:auto;overflow-wrap:anywhere;padding:10px 12px;border-radius:10px;background:var(--dsw-alias-bg-layer-2);border:.5px solid var(--dsw-alias-border-l3);box-shadow:0 12px 32px rgb(0 0 0 / 45%);font-size:12px;line-height:1.6;font-weight:400;color:var(--dsw-alias-label-secondary)}
|
|
422
|
+
.dsu-input{width:100%;height:34px;padding:0 12px;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px}
|
|
423
|
+
.dsu-input:focus-visible{outline:none;border-color:var(--dsw-alias-state-business-primary)}
|
|
424
|
+
.dsu-input[aria-invalid="true"]{border-color:var(--dsw-alias-state-error-primary)}
|
|
425
|
+
.dsu-input:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}
|
|
426
|
+
.dsu-input::placeholder{color:var(--dsw-alias-label-tertiary)}
|
|
427
|
+
.dsu-textarea{height:auto;min-height:96px;padding:8px 12px;line-height:1.6;resize:vertical}
|
|
428
|
+
.dsu-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
|
|
429
|
+
.dsu-numberWrap{display:flex;flex-direction:column;gap:4px;width:100%;min-width:0}
|
|
430
|
+
.dsu-number{display:flex;align-items:center;gap:8px;min-width:0}
|
|
431
|
+
.dsu-number .dsu-input{min-width:0}
|
|
432
|
+
.dsu-unit{flex:none;font-size:12px;color:var(--dsw-alias-label-tertiary)}
|
|
433
|
+
.dsu-error{margin:0;font-size:12px;line-height:1.5;color:var(--dsw-alias-state-error-primary)}
|
|
434
|
+
.dsu-switch{appearance:none;width:36px;height:20px;border-radius:999px;border:0;padding:2px;background:var(--dsw-alias-border-l3);display:flex;align-items:center;cursor:pointer;flex:none;transition:background-color .16s}
|
|
435
|
+
.dsu-knob{width:16px;height:16px;border-radius:50%;background:var(--dsw-alias-label-primary);transition:transform .16s,background-color .16s}
|
|
436
|
+
.dsu-switch[aria-checked="true"]{background:var(--dsw-alias-label-primary)}
|
|
437
|
+
.dsu-switch[aria-checked="true"] .dsu-knob{transform:translateX(16px);background:var(--dsw-alias-label-primary-foreground)}
|
|
438
|
+
.dsu-switch:disabled{opacity:.4;cursor:not-allowed}
|
|
439
|
+
.dsu-switch:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}
|
|
440
|
+
.dsu-selectWrap{position:relative;width:100%;min-width:0}
|
|
441
|
+
.dsu-select{display:flex;align-items:center;justify-content:space-between;gap:8px;text-align:left;cursor:pointer}
|
|
442
|
+
.dsu-select[aria-expanded="true"]{border-color:var(--dsw-alias-state-business-primary)}
|
|
443
|
+
.dsu-selectValue{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
444
|
+
.dsu-chevron{flex:none;color:var(--dsw-alias-label-tertiary);transition:transform .16s}
|
|
445
|
+
.dsu-select[aria-expanded="true"] .dsu-chevron{transform:rotate(180deg)}
|
|
446
|
+
.dsu-menu{position:fixed;z-index:70;padding:4px;background:var(--dsw-alias-bg-layer-2);border:.5px solid var(--dsw-alias-border-l3);border-radius:12px;box-shadow:0 12px 32px rgb(0 0 0 / 50%);max-height:280px;overflow:auto}
|
|
447
|
+
.dsu-option{appearance:none;border:0;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:1.4;width:100%;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 10px;border-radius:8px;cursor:pointer;text-align:left}
|
|
448
|
+
.dsu-option:hover,.dsu-option[data-active="true"]{background:var(--dsw-alias-bg-layer-3)}
|
|
449
|
+
.dsu-option:disabled{color:var(--dsw-alias-label-tertiary);cursor:not-allowed}
|
|
450
|
+
.dsu-option:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:-2px}
|
|
451
|
+
.dsu-optionGroup{padding:6px 10px 2px;font-size:11px;font-weight:600;color:var(--dsw-alias-label-tertiary)}
|
|
452
|
+
.dsu-check{opacity:0;flex:none}
|
|
453
|
+
.dsu-option[aria-selected="true"] .dsu-check{opacity:1}
|
|
454
|
+
.dsu-savebar{display:flex;align-items:center;gap:8px;padding:12px 0;margin-top:24px;border-top:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-base)}
|
|
455
|
+
.dsu-savebar[data-dirty="true"]{position:sticky;bottom:0;z-index:2;box-shadow:0 -12px 24px rgb(0 0 0 / 35%)}
|
|
456
|
+
.dsu-btn{appearance:none;border:.5px solid var(--dsw-alias-border-l2);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:1.5;border-radius:var(--dsw-radius-md);padding:5px 14px;cursor:pointer;transition:background-color .12s,border-color .12s,color .12s,filter .12s}
|
|
457
|
+
.dsu-btn:hover:not(:disabled){background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-border-l3)}
|
|
458
|
+
.dsu-btn:active:not(:disabled){background:var(--dsw-alias-bg-layer-1)}
|
|
459
|
+
.dsu-btn:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:1px}
|
|
460
|
+
.dsu-btn:disabled{opacity:.4;cursor:not-allowed}
|
|
461
|
+
.dsu-btnPrimary{background:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}
|
|
462
|
+
.dsu-btnPrimary:hover:not(:disabled){background:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-primary);filter:brightness(.9)}
|
|
463
|
+
.dsu-btnPrimary:active:not(:disabled){background:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-primary);filter:brightness(.84)}
|
|
464
|
+
.dsu-btnDanger{color:var(--dsw-alias-state-error-primary)}
|
|
465
|
+
.dsu-btnDanger:hover:not(:disabled){color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-primary);background:var(--dsw-alias-bg-layer-2)}
|
|
466
|
+
.dsu-status{margin-left:auto;font-size:12px;color:var(--dsw-alias-label-tertiary)}
|
|
467
|
+
.dsu-statusError{color:var(--dsw-alias-state-error-primary)}
|
|
468
|
+
.dsu-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(200px,100%),1fr));gap:0 24px}
|
|
469
|
+
.dsu-grid>.dsu-field{display:flex;flex-direction:column;align-items:stretch;gap:6px;padding:10px 0;border-top:.5px solid var(--dsw-alias-border-l1)}
|
|
470
|
+
.dsu-grid>.dsu-field .dsu-control{width:100%}
|
|
471
|
+
@media (max-width:640px){
|
|
472
|
+
.dsu-field{grid-template-columns:minmax(0,1fr);align-items:start}
|
|
473
|
+
.dsu-control{width:100%;max-width:720px}
|
|
474
|
+
.dsu-section{margin-top:20px;padding-top:20px}
|
|
475
|
+
}
|
|
476
|
+
@media (prefers-reduced-motion:reduce){
|
|
477
|
+
.dsu-switch,.dsu-knob,.dsu-chevron,.dsu-btn{transition:none}
|
|
478
|
+
}
|
|
479
|
+
`;
|
|
480
|
+
function u(t) {
|
|
481
|
+
return (0, react.createElement)(`div`, { className: `dsu-form` }, t.children);
|
|
482
|
+
}
|
|
483
|
+
function d(t) {
|
|
484
|
+
return (0, react.createElement)(`section`, { className: `dsu-section` }, (0, react.createElement)(`h2`, { className: `dsu-sectionTitle` }, t.title), t.hint === void 0 ? null : (0, react.createElement)(`p`, { className: `dsu-sectionHint` }, t.hint), t.children);
|
|
485
|
+
}
|
|
486
|
+
function S(t) {
|
|
487
|
+
let n = !t.writable || t.busy || !t.dirty, r;
|
|
488
|
+
return r = t.error === null ? t.writable ? t.dirty ? t.dirtyLabel : t.cleanLabel : t.readOnlyLabel : t.error, (0, react.createElement)(`div`, {
|
|
489
|
+
className: `dsu-savebar`,
|
|
490
|
+
"data-dirty": t.dirty
|
|
491
|
+
}, (0, react.createElement)(`button`, {
|
|
492
|
+
type: `button`,
|
|
493
|
+
className: `dsu-btn dsu-btnPrimary`,
|
|
494
|
+
"data-field": `save`,
|
|
495
|
+
disabled: n,
|
|
496
|
+
onClick: t.onSave
|
|
497
|
+
}, t.busy ? t.savingLabel : t.saveLabel), (0, react.createElement)(`button`, {
|
|
498
|
+
type: `button`,
|
|
499
|
+
className: `dsu-btn`,
|
|
500
|
+
"data-field": `discard`,
|
|
501
|
+
disabled: n,
|
|
502
|
+
onClick: t.onDiscard
|
|
503
|
+
}, t.revertLabel), (0, react.createElement)(`span`, { className: t.error === null ? `dsu-status` : `dsu-status dsu-statusError` }, r));
|
|
504
|
+
}
|
|
505
|
+
// src/input-writeback.ts
|
|
506
|
+
/**
|
|
507
|
+
* 输入框异步写回的凭据与判定。
|
|
508
|
+
*
|
|
509
|
+
* 润色结果是整稿替换:发起时记下会话、草稿版本与输入动作面,返回时用**最新一帧**
|
|
510
|
+
* 核对。任一项在途中变了(用户继续编辑、宿主进入提交期、会话被切换、组件重挂成
|
|
511
|
+
* 另一份 facade),结果都不许落地——宁可报「未写回」,也不能覆盖用户后来的输入。
|
|
512
|
+
* 模板走插入语义(captureInsertion + insertText),由宿主按发起的选区做版本校验。
|
|
513
|
+
*/
|
|
514
|
+
/** 宿主是否给了整稿替换面(润色结果最后落到 setDraft)。 */
|
|
515
|
+
function hasDraftFace(actions) {
|
|
516
|
+
return actions !== void 0 && typeof actions.setDraft === "function";
|
|
517
|
+
}
|
|
518
|
+
/** 宿主是否给了版本校验插入面(模板走这一对,不整稿覆盖)。 */
|
|
519
|
+
function hasInsertFace(actions) {
|
|
520
|
+
return actions !== void 0 && typeof actions.captureInsertion === "function" && typeof actions.insertText === "function";
|
|
521
|
+
}
|
|
522
|
+
/** 提交期(`phase !== "plain"`)也算失效:发送成功后编辑器会被清空,失败时原稿要留着,
|
|
523
|
+
* 两种情况下在途的润色结果都不该再写进草稿。 */
|
|
524
|
+
function useWriteBack(input, messages) {
|
|
525
|
+
const latest = (0, react.useRef)(input);
|
|
526
|
+
const active = (0, react.useRef)(void 0);
|
|
527
|
+
(0, react.useEffect)(() => {
|
|
528
|
+
latest.current = input;
|
|
529
|
+
const ticket = active.current;
|
|
530
|
+
if (ticket === void 0) return;
|
|
531
|
+
if (ticket.sessionId !== input.sessionId || ticket.actions !== input.actions || input.phase !== "plain") ticket.invalidated = true;
|
|
532
|
+
}, [input]);
|
|
533
|
+
return {
|
|
534
|
+
begin: () => {
|
|
535
|
+
const ticket = {
|
|
536
|
+
sessionId: latest.current.sessionId,
|
|
537
|
+
draftRev: latest.current.draftRev,
|
|
538
|
+
actions: latest.current.actions,
|
|
539
|
+
invalidated: false
|
|
540
|
+
};
|
|
541
|
+
active.current = ticket;
|
|
542
|
+
return ticket;
|
|
543
|
+
},
|
|
544
|
+
finish: (ticket) => {
|
|
545
|
+
if (active.current === ticket) active.current = void 0;
|
|
546
|
+
},
|
|
547
|
+
commit: (content, ticket) => {
|
|
548
|
+
const { actions } = latest.current;
|
|
549
|
+
if (!hasDraftFace(actions)) throw new Error(messages.unavailable);
|
|
550
|
+
let liveRev = latest.current.draftRev;
|
|
551
|
+
if (hasInsertFace(actions)) liveRev = actions.captureInsertion().draftRev;
|
|
552
|
+
if (ticket.invalidated || liveRev !== ticket.draftRev) throw new Error(messages.stale);
|
|
553
|
+
actions.setDraft(content);
|
|
554
|
+
}
|
|
555
|
+
};
|
|
408
556
|
}
|
|
409
|
-
|
|
410
|
-
//#region src/remote.ts
|
|
557
|
+
// src/remote.ts
|
|
411
558
|
/** Typert Remote 命名空间(client 半这一侧的唯一一枚)。
|
|
412
559
|
*
|
|
413
560
|
* 宿主半的注册键在 host.ts 的 `DIR_PREP_REMOTE_NAMESPACE`——两半各自打包、client 包
|
|
@@ -416,12 +563,31 @@ function r(e) {
|
|
|
416
563
|
const DIR_PREP_NAMESPACE = "dirPrepOrganize";
|
|
417
564
|
const DIR_PREP_SERVICE_KEY = `remote.${DIR_PREP_NAMESPACE}`;
|
|
418
565
|
const PACKAGE_NAME = "@jayyuen66/dsh-dir-prep-organize";
|
|
566
|
+
/** strict codec 的统一出口:失败交给 zod 的 `prettifyError`,读到的是一份带字段路径的说明。 */
|
|
567
|
+
function parseOrThrow(schema, value) {
|
|
568
|
+
const parsed = schema.safeParse(value);
|
|
569
|
+
if (!parsed.success) throw new TypeError(zod.z.prettifyError(parsed.error));
|
|
570
|
+
return parsed.data;
|
|
571
|
+
}
|
|
572
|
+
const SESSION_MESSAGE = "session request requires a string sessionId";
|
|
573
|
+
const SESSION_SCHEMA = zod.z.object({ sessionId: zod.z.string({ error: SESSION_MESSAGE }) }, { error: SESSION_MESSAGE });
|
|
574
|
+
const ORGANIZE_MESSAGE = "organize request requires string sessionId, prompt and entriesSummary";
|
|
575
|
+
const ORGANIZE_SCHEMA = zod.z.object({
|
|
576
|
+
sessionId: zod.z.string({ error: ORGANIZE_MESSAGE }),
|
|
577
|
+
prompt: zod.z.string({ error: ORGANIZE_MESSAGE }),
|
|
578
|
+
entriesSummary: zod.z.string({ error: ORGANIZE_MESSAGE }),
|
|
579
|
+
roleText: zod.z.string({ error: "organize request roleText must be a string when present" }).optional()
|
|
580
|
+
}, { error: ORGANIZE_MESSAGE });
|
|
581
|
+
const IMPORT_MESSAGE = "import request requires string path and sessionId";
|
|
582
|
+
const IMPORT_SCHEMA = zod.z.object({
|
|
583
|
+
path: zod.z.string({ error: IMPORT_MESSAGE }),
|
|
584
|
+
sessionId: zod.z.string({ error: IMPORT_MESSAGE })
|
|
585
|
+
}, { error: IMPORT_MESSAGE });
|
|
419
586
|
const SESSION_CODEC = {
|
|
420
587
|
mode: "strict",
|
|
421
588
|
typeSymbol: `${PACKAGE_NAME}#session-request`,
|
|
422
589
|
create: () => ({ parse(value) {
|
|
423
|
-
|
|
424
|
-
return { sessionId: value["sessionId"] };
|
|
590
|
+
return parseOrThrow(SESSION_SCHEMA, value);
|
|
425
591
|
} })
|
|
426
592
|
};
|
|
427
593
|
const DIR_PREP_DESCRIPTORS = [
|
|
@@ -476,14 +642,14 @@ const DIR_PREP_DESCRIPTORS = [
|
|
|
476
642
|
mode: "strict",
|
|
477
643
|
typeSymbol: `${PACKAGE_NAME}#organize-request`,
|
|
478
644
|
create: () => ({ parse(value) {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
645
|
+
const request = parseOrThrow(ORGANIZE_SCHEMA, value);
|
|
646
|
+
return request.roleText === void 0 ? {
|
|
647
|
+
sessionId: request.sessionId,
|
|
648
|
+
prompt: request.prompt,
|
|
649
|
+
entriesSummary: request.entriesSummary
|
|
650
|
+
} : {
|
|
651
|
+
...request,
|
|
652
|
+
roleText: request.roleText
|
|
487
653
|
};
|
|
488
654
|
} })
|
|
489
655
|
}
|
|
@@ -504,26 +670,23 @@ const DIR_PREP_DESCRIPTORS = [
|
|
|
504
670
|
mode: "strict",
|
|
505
671
|
typeSymbol: `${PACKAGE_NAME}#import-request`,
|
|
506
672
|
create: () => ({ parse(value) {
|
|
507
|
-
|
|
508
|
-
return {
|
|
509
|
-
path: value["path"],
|
|
510
|
-
sessionId: value["sessionId"]
|
|
511
|
-
};
|
|
673
|
+
return parseOrThrow(IMPORT_SCHEMA, value);
|
|
512
674
|
} })
|
|
513
675
|
}
|
|
514
676
|
}],
|
|
515
677
|
result: { mode: "src-json" }
|
|
516
678
|
}
|
|
517
679
|
];
|
|
518
|
-
const isMounter = (value) => e(value) && typeof value["$mount"] === "function";
|
|
519
|
-
const isNamespace = (value) => e(value) && typeof value["defaults"] === "function" && typeof value["context"] === "function" && typeof value["model"] === "function" && typeof value["organize"] === "function" && typeof value["importTemplates"] === "function";
|
|
680
|
+
const isMounter = (value) => e$1(value) && typeof value["$mount"] === "function";
|
|
681
|
+
const isNamespace = (value) => e$1(value) && typeof value["defaults"] === "function" && typeof value["context"] === "function" && typeof value["model"] === "function" && typeof value["organize"] === "function" && typeof value["importTemplates"] === "function";
|
|
520
682
|
const unwrap = (raw) => {
|
|
521
|
-
if (!e(raw) || typeof raw["ok"] !== "boolean") throw new TypeError("Typert Remote 应答不是 RemoteResult:缺少布尔字段 ok");
|
|
683
|
+
if (!e$1(raw) || typeof raw["ok"] !== "boolean") throw new TypeError("Typert Remote 应答不是 RemoteResult:缺少布尔字段 ok");
|
|
522
684
|
if (!raw["ok"]) {
|
|
523
685
|
const { error } = raw;
|
|
524
|
-
if (!e(error) || typeof error["code"] !== "string" || typeof error["message"] !== "string") throw new TypeError("Typert Remote 应答的 error 分支缺 code/message");
|
|
686
|
+
if (!e$1(error) || typeof error["code"] !== "string" || typeof error["message"] !== "string") throw new TypeError("Typert Remote 应答的 error 分支缺 code/message");
|
|
525
687
|
throw new Error(`${error["code"]}: ${error["message"]}`);
|
|
526
688
|
}
|
|
689
|
+
if (!("value" in raw)) throw new TypeError("Typert Remote 应答的 ok 分支缺 value 字段");
|
|
527
690
|
return raw["value"];
|
|
528
691
|
};
|
|
529
692
|
function buildReader(ctx, remote) {
|
|
@@ -555,13 +718,23 @@ function buildReader(ctx, remote) {
|
|
|
555
718
|
importTemplates: async (args) => call((namespace) => namespace.importTemplates(args))
|
|
556
719
|
};
|
|
557
720
|
}
|
|
558
|
-
/** 造读取器;当前部署没有远程面时 undefined(卡片只显示读不到)。
|
|
721
|
+
/** 造读取器;当前部署没有远程面时 undefined(卡片只显示读不到)。
|
|
722
|
+
*
|
|
723
|
+
* `get` 的两个口径与 buildReader 里查命名空间时保持一致,都显式传 `strict = false`:
|
|
724
|
+
* 不传时 cordis 默认只返回「提供者 fiber 当前 active」的实现,而设置卡可能在 fiber
|
|
725
|
+
* 就绪前就挂上——那时读面会拿到 undefined 并显示「读不到」,看起来是插件没装。
|
|
726
|
+
* `get` 本身也可能抛(宿主版本演进后反射面可能不再接受 bool),兜住它只是为了把这
|
|
727
|
+
* 一栏降级成「读不到」,不让整张卡片跟着炸。 */
|
|
559
728
|
function createDirPrepReader(ctx) {
|
|
560
|
-
|
|
729
|
+
let remote;
|
|
730
|
+
try {
|
|
731
|
+
remote = ctx.get?.("remote", false);
|
|
732
|
+
} catch {
|
|
733
|
+
remote = void 0;
|
|
734
|
+
}
|
|
561
735
|
return isMounter(remote) ? buildReader(ctx, remote) : void 0;
|
|
562
736
|
}
|
|
563
|
-
|
|
564
|
-
//#region src/client-entry.ts
|
|
737
|
+
// src/client-entry.ts
|
|
565
738
|
const NS = "dir-prep-organize";
|
|
566
739
|
const BUNDLE_PKG = "@jayyuen66/dsh-dir-prep-organize";
|
|
567
740
|
const ERROR_FLASH_MS = 4e3;
|
|
@@ -575,7 +748,7 @@ const CLASS_ROW_HEAD = "dpic-rowhead";
|
|
|
575
748
|
const CLASS_IMPORT_PATH = "dpic-importpath";
|
|
576
749
|
const SLOT_INPUT_RIGHT = "conversation.input.right";
|
|
577
750
|
function parseDirEntry(raw) {
|
|
578
|
-
const { name, isDir, sizeBytes, snippet } = e(raw) ? raw : {};
|
|
751
|
+
const { name, isDir, sizeBytes, snippet } = e$1(raw) ? raw : {};
|
|
579
752
|
return {
|
|
580
753
|
name: typeof name === "string" ? name : "",
|
|
581
754
|
isDir: isDir === true,
|
|
@@ -606,7 +779,7 @@ function skipCountsOf(skips) {
|
|
|
606
779
|
];
|
|
607
780
|
}
|
|
608
781
|
function parseContextResponse(raw) {
|
|
609
|
-
const rec = e(raw) ? raw : {};
|
|
782
|
+
const rec = e$1(raw) ? raw : {};
|
|
610
783
|
const { ok, truncated, entries } = rec;
|
|
611
784
|
const parsedEntries = Array.isArray(entries) ? entries.map((entry) => parseDirEntry(entry)) : void 0;
|
|
612
785
|
return {
|
|
@@ -618,7 +791,7 @@ function parseContextResponse(raw) {
|
|
|
618
791
|
};
|
|
619
792
|
}
|
|
620
793
|
function parseModelResponse(raw) {
|
|
621
|
-
const rec = e(raw) ? raw : {};
|
|
794
|
+
const rec = e$1(raw) ? raw : {};
|
|
622
795
|
return {
|
|
623
796
|
ok: rec["ok"] === true,
|
|
624
797
|
...spreadIfDefined(optionalString(rec, "error"), "error"),
|
|
@@ -628,7 +801,7 @@ function parseModelResponse(raw) {
|
|
|
628
801
|
};
|
|
629
802
|
}
|
|
630
803
|
function parseOrganizeResponse(raw) {
|
|
631
|
-
const rec = e(raw) ? raw : {};
|
|
804
|
+
const rec = e$1(raw) ? raw : {};
|
|
632
805
|
return {
|
|
633
806
|
ok: rec["ok"] === true,
|
|
634
807
|
...spreadIfDefined(optionalString(rec, "error"), "error"),
|
|
@@ -656,14 +829,14 @@ function formatImportSkips(t, skips) {
|
|
|
656
829
|
return parts.length === 0 ? "" : t("skipSummary", { list: parts.join(t("skipSeparator")) });
|
|
657
830
|
}
|
|
658
831
|
function parseImportResponse(raw) {
|
|
659
|
-
const { ok, error, count, truncated, skipped, entries } = e(raw) ? raw : {};
|
|
832
|
+
const { ok, error, count, truncated, skipped, entries } = e$1(raw) ? raw : {};
|
|
660
833
|
const parsedEntries = Array.isArray(entries) ? sanitizeTemplateList(entries) : void 0;
|
|
661
834
|
return {
|
|
662
835
|
ok: ok === true,
|
|
663
836
|
...typeof error === "string" ? { error } : {},
|
|
664
837
|
...typeof count === "number" ? { count } : {},
|
|
665
838
|
...truncated === true ? { truncated: true } : {},
|
|
666
|
-
...e(skipped) ? { skipped: parseImportSkips(skipped) } : {},
|
|
839
|
+
...e$1(skipped) ? { skipped: parseImportSkips(skipped) } : {},
|
|
667
840
|
...parsedEntries === void 0 ? {} : { entries: parsedEntries }
|
|
668
841
|
};
|
|
669
842
|
}
|
|
@@ -739,7 +912,7 @@ async function loadBuiltinTemplates() {
|
|
|
739
912
|
let settled;
|
|
740
913
|
try {
|
|
741
914
|
const body = await within(requireReader().defaults(), REMOTE_TIMEOUT_MS);
|
|
742
|
-
const payload = e(body) ? body : void 0;
|
|
915
|
+
const payload = e$1(body) ? body : void 0;
|
|
743
916
|
const okKey = "ok";
|
|
744
917
|
const templatesKey = "templates";
|
|
745
918
|
const rawReason = payload?.["error"];
|
|
@@ -756,7 +929,7 @@ async function loadBuiltinTemplates() {
|
|
|
756
929
|
settled = {
|
|
757
930
|
phase: "error",
|
|
758
931
|
list: [],
|
|
759
|
-
error: r(error)
|
|
932
|
+
error: r$1(error)
|
|
760
933
|
};
|
|
761
934
|
} finally {
|
|
762
935
|
if (builtinGeneration === generation) builtinInflight = null;
|
|
@@ -783,7 +956,7 @@ function builtinStatusRow(snap, t) {
|
|
|
783
956
|
};
|
|
784
957
|
const retryButton = (0, react.createElement)("button", {
|
|
785
958
|
type: "button",
|
|
786
|
-
className: "
|
|
959
|
+
className: "dsu-btn",
|
|
787
960
|
"data-field": "dpi-builtin-retry",
|
|
788
961
|
onClick: () => {
|
|
789
962
|
loadBuiltinTemplates();
|
|
@@ -793,10 +966,25 @@ function builtinStatusRow(snap, t) {
|
|
|
793
966
|
if (!snap.fromSettings && snap.builtinPhase !== "ready") row = snap.builtinPhase === "error" ? (0, react.createElement)("div", attrs, t("builtinFailed", { message: snap.builtinError }), retryButton) : (0, react.createElement)("div", attrs, t("builtinLoading"));
|
|
794
967
|
return row;
|
|
795
968
|
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
969
|
+
/**
|
|
970
|
+
* 润色链路里由客户端自己产生的错误:messageKey 指向 ui-messages 的键,捕获侧用当前
|
|
971
|
+
* 语言的 t 渲染成 tooltip——把文案直接写进 Error.message 会让英文界面看到硬编码中文。
|
|
972
|
+
* 宿主回执携带的原文(ctxRes.error / modelRes.error)不翻译,作为 {message} 原样带出。
|
|
973
|
+
*/
|
|
974
|
+
var LocalizedOrganizeError = class extends Error {
|
|
975
|
+
messageKey;
|
|
976
|
+
params;
|
|
977
|
+
constructor(messageKey, params = {}) {
|
|
978
|
+
super(messageKey);
|
|
979
|
+
this.name = "LocalizedOrganizeError";
|
|
980
|
+
this.messageKey = messageKey;
|
|
981
|
+
this.params = params;
|
|
982
|
+
}
|
|
983
|
+
};
|
|
984
|
+
function assertOrganizeReady(ctxRes, modelRes, prompt, unknownReason) {
|
|
985
|
+
if (!ctxRes.ok) throw new LocalizedOrganizeError("organizeErrContextFailed", { message: ctxRes.error ?? unknownReason });
|
|
986
|
+
if (!modelRes.ok || modelRes.provider === void 0 || modelRes.model === void 0) throw new LocalizedOrganizeError("organizeErrModelFailed", { message: modelRes.error ?? unknownReason });
|
|
987
|
+
if (prompt.trim().length === 0) throw new LocalizedOrganizeError("organizeErrEmpty");
|
|
800
988
|
}
|
|
801
989
|
async function requestOrganize(args) {
|
|
802
990
|
const { ctxRes, prompt, sessionId, roleText, timeoutMs } = args;
|
|
@@ -807,14 +995,14 @@ async function requestOrganize(args) {
|
|
|
807
995
|
entriesSummary,
|
|
808
996
|
...roleText === void 0 ? {} : { roleText }
|
|
809
997
|
}), timeoutMs));
|
|
810
|
-
if (!orgRes.ok || orgRes.content === void 0) throw
|
|
998
|
+
if (!orgRes.ok || orgRes.content === void 0) throw orgRes.error === void 0 ? new LocalizedOrganizeError("organizeErrUnknown") : new Error(orgRes.error);
|
|
811
999
|
return orgRes.content;
|
|
812
1000
|
}
|
|
813
1001
|
async function runOrganizeFlow(args) {
|
|
814
1002
|
const reader = requireReader();
|
|
815
1003
|
const [ctxRaw, modelRaw] = await Promise.all([within(reader.context(args.sessionId), REMOTE_TIMEOUT_MS), within(reader.model(args.sessionId), REMOTE_TIMEOUT_MS)]);
|
|
816
1004
|
const ctxRes = parseContextResponse(ctxRaw);
|
|
817
|
-
assertOrganizeReady(ctxRes, parseModelResponse(modelRaw), args.prompt);
|
|
1005
|
+
assertOrganizeReady(ctxRes, parseModelResponse(modelRaw), args.prompt, args.unknownReason);
|
|
818
1006
|
return requestOrganize({
|
|
819
1007
|
ctxRes,
|
|
820
1008
|
prompt: args.prompt,
|
|
@@ -910,11 +1098,6 @@ function rootsPersistError(t, persisted, expected, action) {
|
|
|
910
1098
|
});
|
|
911
1099
|
return message;
|
|
912
1100
|
}
|
|
913
|
-
function applyTemplateToDraft(current, template) {
|
|
914
|
-
const base = typeof current === "string" ? current.trimEnd() : "";
|
|
915
|
-
if (base.length === 0) return template;
|
|
916
|
-
return `${base}\n\n${template}`;
|
|
917
|
-
}
|
|
918
1101
|
/** 菜单项文字:有 emoji 就前缀一个(emoji 是用户自填的视觉标记,空串 = 不显示)。 */
|
|
919
1102
|
function templateItemLabel(tpl) {
|
|
920
1103
|
return `${tpl.emoji === "" ? "" : `${tpl.emoji} `}${tpl.name}`;
|
|
@@ -932,7 +1115,7 @@ function groupTemplatesBy(templates, t) {
|
|
|
932
1115
|
bucket.push(tpl);
|
|
933
1116
|
buckets.set(key, bucket);
|
|
934
1117
|
}
|
|
935
|
-
return
|
|
1118
|
+
return Array.from(buckets.entries(), ([group, items]) => ({
|
|
936
1119
|
group,
|
|
937
1120
|
items
|
|
938
1121
|
}));
|
|
@@ -1024,8 +1207,9 @@ function useMenuDismiss(open, wrapRef, close) {
|
|
|
1024
1207
|
]);
|
|
1025
1208
|
}
|
|
1026
1209
|
async function runOrganizeClick(args) {
|
|
1027
|
-
const { loading, seq, prompt, sessionId, timeoutMs, roleText, setLoading, setMenuOpen, setFailed, flashTimer, writeDraft } = args;
|
|
1028
|
-
if (loading) return;
|
|
1210
|
+
const { t, loading, inFlight, seq, prompt, sessionId, timeoutMs, roleText, setLoading, setMenuOpen, setFailed, flashTimer, writeDraft } = args;
|
|
1211
|
+
if (loading || inFlight.current) return;
|
|
1212
|
+
inFlight.current = true;
|
|
1029
1213
|
seq.current += 1;
|
|
1030
1214
|
const mySeq = seq.current;
|
|
1031
1215
|
setLoading(true);
|
|
@@ -1036,18 +1220,20 @@ async function runOrganizeClick(args) {
|
|
|
1036
1220
|
prompt,
|
|
1037
1221
|
sessionId,
|
|
1038
1222
|
...roleText === void 0 ? {} : { roleText },
|
|
1039
|
-
timeoutMs
|
|
1223
|
+
timeoutMs,
|
|
1224
|
+
unknownReason: t("organizeErrUnknownReason")
|
|
1040
1225
|
});
|
|
1041
1226
|
if (seq.current !== mySeq) return;
|
|
1042
1227
|
writeDraft(content);
|
|
1043
1228
|
} catch (error) {
|
|
1044
1229
|
if (seq.current !== mySeq) return;
|
|
1045
|
-
setFailed(r(error));
|
|
1230
|
+
setFailed(error instanceof LocalizedOrganizeError ? t(error.messageKey, error.params) : r$1(error));
|
|
1046
1231
|
if (flashTimer.current !== null) clearTimeout(flashTimer.current);
|
|
1047
1232
|
flashTimer.current = setTimeout(() => {
|
|
1048
1233
|
setFailed(void 0);
|
|
1049
1234
|
}, ERROR_FLASH_MS);
|
|
1050
1235
|
} finally {
|
|
1236
|
+
inFlight.current = false;
|
|
1051
1237
|
if (seq.current === mySeq) setLoading(false);
|
|
1052
1238
|
}
|
|
1053
1239
|
}
|
|
@@ -1114,17 +1300,47 @@ function createOrganizeRoleMenu(ui) {
|
|
|
1114
1300
|
}
|
|
1115
1301
|
}, `${tpl.emoji === "" ? "" : `${tpl.emoji} `}${t("organizeRoleItem", { name: tpl.name })}`)));
|
|
1116
1302
|
}
|
|
1303
|
+
/** 主键的三态外观:失败 > 在途 > 空闲(三者互斥,按同一优先级判)。 */
|
|
1304
|
+
function organizeBadge(failed, loading, t) {
|
|
1305
|
+
if (failed !== void 0) return {
|
|
1306
|
+
icon: (0, react.createElement)(FailIcon),
|
|
1307
|
+
label: t("organizeFailedShort"),
|
|
1308
|
+
state: "error"
|
|
1309
|
+
};
|
|
1310
|
+
if (loading) return {
|
|
1311
|
+
icon: (0, react.createElement)(SpinIcon),
|
|
1312
|
+
label: t("organizeLoading"),
|
|
1313
|
+
state: "loading"
|
|
1314
|
+
};
|
|
1315
|
+
return {
|
|
1316
|
+
icon: (0, react.createElement)(TidyIcon),
|
|
1317
|
+
label: t("organizeIdle"),
|
|
1318
|
+
state: "idle"
|
|
1319
|
+
};
|
|
1320
|
+
}
|
|
1117
1321
|
function createOrganizeButton() {
|
|
1118
1322
|
return function OrganizeButton(props) {
|
|
1119
1323
|
const [loading, setLoading] = (0, react.useState)(false);
|
|
1120
1324
|
const [failed, setFailed] = (0, react.useState)(void 0);
|
|
1121
1325
|
const [menuOpen, setMenuOpen] = (0, react.useState)(false);
|
|
1122
1326
|
const seq = (0, react.useRef)(0);
|
|
1327
|
+
const inFlight = (0, react.useRef)(false);
|
|
1123
1328
|
const flashTimer = (0, react.useRef)(null);
|
|
1124
1329
|
const wrapRef = (0, react.useRef)(null);
|
|
1125
1330
|
const draft = props.useInput === void 0 ? "" : props.useInput((state) => state.draft) ?? "";
|
|
1331
|
+
const draftRev = props.useInput === void 0 ? 0 : props.useInput((state) => state.draftRev);
|
|
1332
|
+
const phase = props.useInput === void 0 ? "plain" : props.useInput((state) => state.phase);
|
|
1126
1333
|
const snap = props.useCard((state) => state);
|
|
1127
1334
|
const { templates } = snap;
|
|
1335
|
+
const writeBack = useWriteBack({
|
|
1336
|
+
sessionId: props.sessionId ?? "",
|
|
1337
|
+
actions: props.inputActions,
|
|
1338
|
+
draftRev,
|
|
1339
|
+
phase
|
|
1340
|
+
}, {
|
|
1341
|
+
unavailable: props.t(NO_WRITE_BACK_TITLE_KEY),
|
|
1342
|
+
stale: props.t("organizeWriteBackStale")
|
|
1343
|
+
});
|
|
1128
1344
|
useMenuDismiss(menuOpen, wrapRef, () => {
|
|
1129
1345
|
setMenuOpen(false);
|
|
1130
1346
|
});
|
|
@@ -1133,54 +1349,46 @@ function createOrganizeButton() {
|
|
|
1133
1349
|
if (flashTimer.current !== null) clearTimeout(flashTimer.current);
|
|
1134
1350
|
}, []);
|
|
1135
1351
|
async function handleOrganize(roleText) {
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1352
|
+
const ticket = writeBack.begin();
|
|
1353
|
+
try {
|
|
1354
|
+
await runOrganizeClick({
|
|
1355
|
+
t: props.t,
|
|
1356
|
+
loading,
|
|
1357
|
+
inFlight,
|
|
1358
|
+
seq,
|
|
1359
|
+
prompt: draft,
|
|
1360
|
+
sessionId: props.sessionId ?? "",
|
|
1361
|
+
timeoutMs: organizeFetchTimeoutMs(snap.organizeTimeoutMs),
|
|
1362
|
+
roleText,
|
|
1363
|
+
setLoading,
|
|
1364
|
+
setMenuOpen,
|
|
1365
|
+
setFailed,
|
|
1366
|
+
flashTimer,
|
|
1367
|
+
writeDraft: (content) => {
|
|
1368
|
+
writeBack.commit(content, ticket);
|
|
1369
|
+
}
|
|
1370
|
+
});
|
|
1371
|
+
} finally {
|
|
1372
|
+
writeBack.finish(ticket);
|
|
1373
|
+
}
|
|
1153
1374
|
}
|
|
1154
1375
|
function openMenu() {
|
|
1155
1376
|
if (!snap.fromSettings) loadBuiltinTemplates();
|
|
1156
1377
|
setMenuOpen((prev) => !prev);
|
|
1157
1378
|
}
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
if (failed !== void 0) {
|
|
1162
|
-
icon = (0, react.createElement)(FailIcon);
|
|
1163
|
-
label = props.t("organizeFailedShort");
|
|
1164
|
-
state = "error";
|
|
1165
|
-
} else if (loading) {
|
|
1166
|
-
icon = (0, react.createElement)(SpinIcon);
|
|
1167
|
-
label = props.t("organizeLoading");
|
|
1168
|
-
state = "loading";
|
|
1169
|
-
} else {
|
|
1170
|
-
icon = (0, react.createElement)(TidyIcon);
|
|
1171
|
-
label = props.t("organizeIdle");
|
|
1172
|
-
state = "idle";
|
|
1173
|
-
}
|
|
1174
|
-
const canWrite = props.inputActions !== void 0 && typeof props.inputActions.setDraft === "function";
|
|
1379
|
+
const badge = organizeBadge(failed, loading, props.t);
|
|
1380
|
+
const replaceable = hasDraftFace(props.inputActions);
|
|
1381
|
+
const canWrite = replaceable && phase === "plain";
|
|
1175
1382
|
let errTitle = props.t("organizeIdleTitle");
|
|
1176
1383
|
if (failed !== void 0) errTitle = props.t("organizeFailedTitle", { message: failed });
|
|
1177
|
-
else if (!
|
|
1384
|
+
else if (!replaceable) errTitle = props.t(NO_WRITE_BACK_TITLE_KEY);
|
|
1385
|
+
else if (phase !== "plain") errTitle = props.t("organizeBusyTitle");
|
|
1178
1386
|
const ui = {
|
|
1179
1387
|
t: props.t,
|
|
1180
1388
|
errTitle,
|
|
1181
|
-
icon,
|
|
1182
|
-
label,
|
|
1183
|
-
state,
|
|
1389
|
+
icon: badge.icon,
|
|
1390
|
+
label: badge.label,
|
|
1391
|
+
state: badge.state,
|
|
1184
1392
|
errClass: failed === void 0 ? "" : " dpi-btn-err",
|
|
1185
1393
|
directItemLabel: props.t("organizeDirectItem"),
|
|
1186
1394
|
noTemplatesLabel: props.t("organizeNoTemplates"),
|
|
@@ -1202,7 +1410,7 @@ function createTemplateButton() {
|
|
|
1202
1410
|
return function TemplateButton(props) {
|
|
1203
1411
|
const [open, setOpen] = (0, react.useState)(false);
|
|
1204
1412
|
const wrapRef = (0, react.useRef)(null);
|
|
1205
|
-
const
|
|
1413
|
+
const phase = props.useInput === void 0 ? "plain" : props.useInput((state) => state.phase);
|
|
1206
1414
|
const snap = props.useCard((state) => state);
|
|
1207
1415
|
const { templates } = snap;
|
|
1208
1416
|
useMenuDismiss(open, wrapRef, () => {
|
|
@@ -1211,11 +1419,14 @@ function createTemplateButton() {
|
|
|
1211
1419
|
function pick(text) {
|
|
1212
1420
|
setOpen(false);
|
|
1213
1421
|
const actions = props.inputActions;
|
|
1214
|
-
if (actions
|
|
1215
|
-
actions.
|
|
1422
|
+
if (!hasInsertFace(actions)) return;
|
|
1423
|
+
actions.insertText(text, actions.captureInsertion());
|
|
1216
1424
|
}
|
|
1217
|
-
const
|
|
1218
|
-
const
|
|
1425
|
+
const insertable = hasInsertFace(props.inputActions);
|
|
1426
|
+
const canWrite = insertable && phase === "plain";
|
|
1427
|
+
let title = props.t("templatesBrokenTitle");
|
|
1428
|
+
if (canWrite) title = props.t("templatesIdleTitle");
|
|
1429
|
+
else if (insertable) title = props.t("templatesBusyTitle");
|
|
1219
1430
|
const grouped = groupTemplatesBy(templates, props.t);
|
|
1220
1431
|
const emptyHintLabel = props.t("templatesEmptyHint");
|
|
1221
1432
|
const builtinRow = builtinStatusRow(snap, props.t);
|
|
@@ -1273,7 +1484,7 @@ function createTemplateRowElement(view) {
|
|
|
1273
1484
|
const indexMark = (0, react.createElement)("span", { className: "dpic-idx" }, `#${rowNum}`);
|
|
1274
1485
|
const emojiInput = (0, react.createElement)("input", {
|
|
1275
1486
|
type: "text",
|
|
1276
|
-
className: "dpic-emoji",
|
|
1487
|
+
className: "dpic-emoji dsu-input",
|
|
1277
1488
|
value: values.emoji,
|
|
1278
1489
|
placeholder: EMOJI_PLACEHOLDER,
|
|
1279
1490
|
disabled,
|
|
@@ -1286,7 +1497,7 @@ function createTemplateRowElement(view) {
|
|
|
1286
1497
|
});
|
|
1287
1498
|
const nameInput = (0, react.createElement)("input", {
|
|
1288
1499
|
type: "text",
|
|
1289
|
-
className: "dpic-name",
|
|
1500
|
+
className: "dpic-name dsu-input",
|
|
1290
1501
|
value: values.name,
|
|
1291
1502
|
placeholder: t("rowPlaceholderName"),
|
|
1292
1503
|
disabled,
|
|
@@ -1298,7 +1509,7 @@ function createTemplateRowElement(view) {
|
|
|
1298
1509
|
});
|
|
1299
1510
|
const groupInput = (0, react.createElement)("input", {
|
|
1300
1511
|
type: "text",
|
|
1301
|
-
className: "dpic-group",
|
|
1512
|
+
className: "dpic-group dsu-input",
|
|
1302
1513
|
value: values.group,
|
|
1303
1514
|
placeholder: t("rowPlaceholderGroup"),
|
|
1304
1515
|
disabled,
|
|
@@ -1311,7 +1522,7 @@ function createTemplateRowElement(view) {
|
|
|
1311
1522
|
});
|
|
1312
1523
|
const deleteButton = (0, react.createElement)("button", {
|
|
1313
1524
|
type: "button",
|
|
1314
|
-
className: "dpic-del",
|
|
1525
|
+
className: "dpic-del dsu-btn dsu-btnDanger",
|
|
1315
1526
|
disabled,
|
|
1316
1527
|
title: t("rowDeleteTitle"),
|
|
1317
1528
|
onClick: () => {
|
|
@@ -1320,7 +1531,7 @@ function createTemplateRowElement(view) {
|
|
|
1320
1531
|
}, t("rowDelete"));
|
|
1321
1532
|
const descriptionInput = (0, react.createElement)("input", {
|
|
1322
1533
|
type: "text",
|
|
1323
|
-
className: "dpic-desc",
|
|
1534
|
+
className: "dpic-desc dsu-input",
|
|
1324
1535
|
value: values.description,
|
|
1325
1536
|
placeholder: t("rowPlaceholderDescription"),
|
|
1326
1537
|
disabled,
|
|
@@ -1331,7 +1542,7 @@ function createTemplateRowElement(view) {
|
|
|
1331
1542
|
onBlur: view.onBlur
|
|
1332
1543
|
});
|
|
1333
1544
|
const textArea = (0, react.createElement)("textarea", {
|
|
1334
|
-
className: "dpic-text",
|
|
1545
|
+
className: "dpic-text dsu-input dsu-textarea dsu-mono",
|
|
1335
1546
|
value: values.text,
|
|
1336
1547
|
rows: 6,
|
|
1337
1548
|
placeholder: t("rowPlaceholderText"),
|
|
@@ -1342,7 +1553,7 @@ function createTemplateRowElement(view) {
|
|
|
1342
1553
|
},
|
|
1343
1554
|
onBlur: view.onBlur
|
|
1344
1555
|
});
|
|
1345
|
-
return (0, react.createElement)("
|
|
1556
|
+
return (0, react.createElement)("div", { className: "dpic-row" }, (0, react.createElement)("div", { className: CLASS_ROW_HEAD }, indexMark, emojiInput, nameInput, groupInput, deleteButton), descriptionInput, textArea);
|
|
1346
1557
|
}
|
|
1347
1558
|
function TemplateRow(props) {
|
|
1348
1559
|
const { t } = props;
|
|
@@ -1441,7 +1652,7 @@ function ImportPanel(props) {
|
|
|
1441
1652
|
skips: skipNote
|
|
1442
1653
|
}));
|
|
1443
1654
|
} catch (error) {
|
|
1444
|
-
setImportError(r(error));
|
|
1655
|
+
setImportError(r$1(error));
|
|
1445
1656
|
} finally {
|
|
1446
1657
|
setImportBusy(false);
|
|
1447
1658
|
}
|
|
@@ -1449,7 +1660,7 @@ function ImportPanel(props) {
|
|
|
1449
1660
|
const canImport = props.editable && !importBusy;
|
|
1450
1661
|
const importPathInput = (0, react.createElement)("input", {
|
|
1451
1662
|
type: "text",
|
|
1452
|
-
className: CLASS_IMPORT_PATH
|
|
1663
|
+
className: `${CLASS_IMPORT_PATH} dsu-input`,
|
|
1453
1664
|
value: importPath,
|
|
1454
1665
|
placeholder: t("importPlaceholder"),
|
|
1455
1666
|
disabled: !canImport,
|
|
@@ -1463,7 +1674,7 @@ function ImportPanel(props) {
|
|
|
1463
1674
|
});
|
|
1464
1675
|
const importBtn = (0, react.createElement)("button", {
|
|
1465
1676
|
type: "button",
|
|
1466
|
-
className: "
|
|
1677
|
+
className: "dsu-btn",
|
|
1467
1678
|
disabled: !canImport,
|
|
1468
1679
|
title: t("importBtnTitle"),
|
|
1469
1680
|
onClick: onImport
|
|
@@ -1471,7 +1682,7 @@ function ImportPanel(props) {
|
|
|
1471
1682
|
const importMsgEl = importMsg === "" ? null : (0, react.createElement)("div", { className: "dpic-hint" }, importMsg);
|
|
1472
1683
|
const importErrorEl = importError === "" ? null : (0, react.createElement)("div", { className: "dpic-hint dpic-err" }, `${t("importErrorPrefix")}${importError}`);
|
|
1473
1684
|
const importHintEl = (0, react.createElement)("div", { className: "dpic-hint" }, t("importHint"));
|
|
1474
|
-
return (0, react.createElement)("
|
|
1685
|
+
return (0, react.createElement)("div", { className: "dpic-importrow" }, (0, react.createElement)("div", { className: CLASS_ROW_HEAD }, importPathInput, importBtn), importMsgEl, importErrorEl, importHintEl);
|
|
1475
1686
|
}
|
|
1476
1687
|
function AllowRootsPanel(props) {
|
|
1477
1688
|
const { t } = props;
|
|
@@ -1484,7 +1695,7 @@ function AllowRootsPanel(props) {
|
|
|
1484
1695
|
const rowAria = t("rootsAriaRow", { index: index + 1 });
|
|
1485
1696
|
const rowInput = (0, react.createElement)("input", {
|
|
1486
1697
|
type: "text",
|
|
1487
|
-
className: CLASS_IMPORT_PATH
|
|
1698
|
+
className: `${CLASS_IMPORT_PATH} dsu-input`,
|
|
1488
1699
|
value: root,
|
|
1489
1700
|
placeholder: ROOT_PATH_PLACEHOLDER,
|
|
1490
1701
|
disabled: props.disabled,
|
|
@@ -1496,7 +1707,7 @@ function AllowRootsPanel(props) {
|
|
|
1496
1707
|
});
|
|
1497
1708
|
const rowButton = (0, react.createElement)("button", {
|
|
1498
1709
|
type: "button",
|
|
1499
|
-
className: "dpic-del",
|
|
1710
|
+
className: "dpic-del dsu-btn dsu-btnDanger",
|
|
1500
1711
|
disabled: props.disabled,
|
|
1501
1712
|
title: removeTitle,
|
|
1502
1713
|
onClick: () => {
|
|
@@ -1514,7 +1725,7 @@ function AllowRootsPanel(props) {
|
|
|
1514
1725
|
const addLabel = t("rootsAdd");
|
|
1515
1726
|
const addInput = (0, react.createElement)("input", {
|
|
1516
1727
|
type: "text",
|
|
1517
|
-
className: CLASS_IMPORT_PATH
|
|
1728
|
+
className: `${CLASS_IMPORT_PATH} dsu-input`,
|
|
1518
1729
|
value: pending,
|
|
1519
1730
|
placeholder: addPlaceholder,
|
|
1520
1731
|
disabled: props.disabled,
|
|
@@ -1531,7 +1742,7 @@ function AllowRootsPanel(props) {
|
|
|
1531
1742
|
});
|
|
1532
1743
|
const addButton = (0, react.createElement)("button", {
|
|
1533
1744
|
type: "button",
|
|
1534
|
-
className: "
|
|
1745
|
+
className: "dsu-btn",
|
|
1535
1746
|
disabled: !canAdd,
|
|
1536
1747
|
title: addTitle,
|
|
1537
1748
|
onClick: () => {
|
|
@@ -1540,34 +1751,22 @@ function AllowRootsPanel(props) {
|
|
|
1540
1751
|
}
|
|
1541
1752
|
}, addLabel);
|
|
1542
1753
|
const addRow = (0, react.createElement)("div", { className: CLASS_ROW_HEAD }, addInput, addButton);
|
|
1543
|
-
return (0, react.createElement)("
|
|
1754
|
+
return (0, react.createElement)("div", {
|
|
1544
1755
|
className: "dpic-importrow",
|
|
1545
1756
|
"data-field": "allow-roots"
|
|
1546
1757
|
}, (0, react.createElement)("div", { className: "dpic-hint" }, t("rootsHeading")), rows, addRow, (0, react.createElement)("div", { className: "dpic-hint" }, t("rootsHint")));
|
|
1547
1758
|
}
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1759
|
+
/** 工具条:新增角色与恢复默认(保存/撤销交给卡片底部统一的 SaveBar)。 */
|
|
1760
|
+
function CardToolbar(props) {
|
|
1761
|
+
const { foot, editable, busy, confirmReset } = props;
|
|
1762
|
+
return (0, react.createElement)("div", { className: "dpic-toolbar" }, (0, react.createElement)("button", {
|
|
1551
1763
|
type: "button",
|
|
1552
|
-
className: "
|
|
1764
|
+
className: "dsu-btn",
|
|
1553
1765
|
disabled: !editable,
|
|
1554
1766
|
onClick: props.onAdd
|
|
1555
1767
|
}, foot.add), (0, react.createElement)("button", {
|
|
1556
1768
|
type: "button",
|
|
1557
|
-
className: "
|
|
1558
|
-
"data-field": "save",
|
|
1559
|
-
disabled: !editable || !anythingDirty || busy,
|
|
1560
|
-
title: anythingDirty ? foot.saveTitleDirty : foot.saveTitleClean,
|
|
1561
|
-
onClick: props.onSave
|
|
1562
|
-
}, busy ? foot.saving : foot.save), (0, react.createElement)("button", {
|
|
1563
|
-
type: "button",
|
|
1564
|
-
className: "dpic-btn",
|
|
1565
|
-
"data-field": "discard",
|
|
1566
|
-
disabled: !editable || !anythingDirty || busy,
|
|
1567
|
-
onClick: props.onDiscard
|
|
1568
|
-
}, foot.revert), (0, react.createElement)("button", {
|
|
1569
|
-
type: "button",
|
|
1570
|
-
className: "dpic-btn dpic-btn-danger",
|
|
1769
|
+
className: "dsu-btn dsu-btnDanger",
|
|
1571
1770
|
disabled: !editable || busy,
|
|
1572
1771
|
title: foot.resetTitle,
|
|
1573
1772
|
onClick: props.onReset
|
|
@@ -1580,7 +1779,7 @@ function cardFootLabels(t) {
|
|
|
1580
1779
|
saving: t("saving"),
|
|
1581
1780
|
revert: t("revert"),
|
|
1582
1781
|
reset: t("resetDefault"),
|
|
1583
|
-
resetConfirm: t("resetConfirm"),
|
|
1782
|
+
resetConfirm: t("resetConfirm", { seconds: RESET_CONFIRM_MS / 1e3 }),
|
|
1584
1783
|
saveTitleDirty: t("saveTitleDirty"),
|
|
1585
1784
|
saveTitleClean: t("saveTitleClean"),
|
|
1586
1785
|
resetTitle: t("resetTitle")
|
|
@@ -1592,28 +1791,6 @@ function cardStatusHint(snap, t) {
|
|
|
1592
1791
|
else hint = t("statusNotReady");
|
|
1593
1792
|
return hint;
|
|
1594
1793
|
}
|
|
1595
|
-
function createCardHeader(view) {
|
|
1596
|
-
const { t, open, setOpen } = view;
|
|
1597
|
-
const headTitle = (0, react.createElement)("div", { className: "dpic-title" }, t("cardTitle"));
|
|
1598
|
-
const headDesc = (0, react.createElement)("div", { className: "dpic-cardsub" }, t("cardDescription"));
|
|
1599
|
-
const headBlock = (0, react.createElement)("div", { className: "dpic-head" }, headTitle, headDesc);
|
|
1600
|
-
const chevronPath = (0, react.createElement)("path", svgPathProps("M3 5l4 4 4-4", true));
|
|
1601
|
-
const chevron = (0, react.createElement)("svg", {
|
|
1602
|
-
width: 14,
|
|
1603
|
-
height: 14,
|
|
1604
|
-
viewBox: "0 0 14 14",
|
|
1605
|
-
"aria-hidden": true,
|
|
1606
|
-
className: `dpic-chevron${open ? " dpic-chevron-open" : ""}`
|
|
1607
|
-
}, chevronPath);
|
|
1608
|
-
return (0, react.createElement)("button", {
|
|
1609
|
-
type: "button",
|
|
1610
|
-
className: "dpic-header",
|
|
1611
|
-
"aria-expanded": open,
|
|
1612
|
-
onClick: () => {
|
|
1613
|
-
setOpen((prev) => !prev);
|
|
1614
|
-
}
|
|
1615
|
-
}, headBlock, chevron);
|
|
1616
|
-
}
|
|
1617
1794
|
function createDraftActions(t, draft, rootsDraft, setDraft, setRootsDraft) {
|
|
1618
1795
|
function onCommit(id, fields) {
|
|
1619
1796
|
setDraft(draft.map((tpl) => tpl.id === id ? {
|
|
@@ -1629,7 +1806,7 @@ function createDraftActions(t, draft, rootsDraft, setDraft, setRootsDraft) {
|
|
|
1629
1806
|
id: newTemplateId(),
|
|
1630
1807
|
name: t("newTemplateName", { index: draft.length + 1 }),
|
|
1631
1808
|
description: "",
|
|
1632
|
-
text:
|
|
1809
|
+
text: "",
|
|
1633
1810
|
group: "",
|
|
1634
1811
|
emoji: ""
|
|
1635
1812
|
}]);
|
|
@@ -1668,7 +1845,7 @@ function createPersistActions(args) {
|
|
|
1668
1845
|
const { t, editable, dirty, rootsDirty, anythingDirty, confirmReset, templates, allowRoots, draft, rootsDraft, set, unset, readBack, setDraft, setDraftFor, setRootsDraft, setBusy, setSaveError, setConfirmReset } = args;
|
|
1669
1846
|
function reportError(err) {
|
|
1670
1847
|
console.error("[dir-prep-organize] templates settings write failed:", err);
|
|
1671
|
-
setSaveError(r(err));
|
|
1848
|
+
setSaveError(r$1(err));
|
|
1672
1849
|
}
|
|
1673
1850
|
async function onSave() {
|
|
1674
1851
|
if (!editable || !anythingDirty) return;
|
|
@@ -1728,45 +1905,61 @@ function createPersistActions(args) {
|
|
|
1728
1905
|
onReset
|
|
1729
1906
|
};
|
|
1730
1907
|
}
|
|
1731
|
-
/**
|
|
1908
|
+
/** 卡片正文:状态提示 + 工具条 + 角色行表 + 导入面 + 允许目录面 + 保存条。 */
|
|
1732
1909
|
function createCardBody(view) {
|
|
1733
1910
|
const { t, statusHint, draft, rootsDraft, foot, editable, anythingDirty, busy, confirmReset, saveError } = view;
|
|
1734
1911
|
const { onCommit, onDelete, onAdd, onImported, onRootChange, onRootDelete, onRootAdd } = view.draftActions;
|
|
1735
1912
|
const { onSave, onDiscard, onReset } = view.persistActions;
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1913
|
+
const footHint = (0, react.createElement)("p", { className: "dpic-hint" }, t("footHint"));
|
|
1914
|
+
const saveBar = (0, react.createElement)(S, {
|
|
1915
|
+
dirty: anythingDirty,
|
|
1916
|
+
busy,
|
|
1917
|
+
writable: editable,
|
|
1918
|
+
error: saveError === "" ? null : `${t("saveFailed")}${saveError}`,
|
|
1919
|
+
saveLabel: t("save"),
|
|
1920
|
+
savingLabel: t("saving"),
|
|
1921
|
+
revertLabel: t("revert"),
|
|
1922
|
+
dirtyLabel: t("saveTitleDirty"),
|
|
1923
|
+
cleanLabel: t("saveTitleClean"),
|
|
1924
|
+
readOnlyLabel: t("statusReadOnly"),
|
|
1925
|
+
onSave: () => {
|
|
1926
|
+
onSave();
|
|
1927
|
+
},
|
|
1928
|
+
onDiscard
|
|
1929
|
+
});
|
|
1930
|
+
return (0, react.createElement)(u, null, statusHint === "" ? null : (0, react.createElement)("p", { className: "dpic-hint" }, statusHint), (0, react.createElement)(d, {
|
|
1931
|
+
title: t("rolesSection"),
|
|
1932
|
+
hint: t("rolesHint")
|
|
1933
|
+
}, (0, react.createElement)(CardToolbar, {
|
|
1745
1934
|
foot,
|
|
1746
1935
|
editable,
|
|
1747
|
-
anythingDirty,
|
|
1748
1936
|
busy,
|
|
1749
1937
|
confirmReset,
|
|
1750
1938
|
onAdd,
|
|
1751
|
-
onSave,
|
|
1752
|
-
onDiscard,
|
|
1753
1939
|
onReset
|
|
1754
|
-
}), (0, react.createElement)(
|
|
1940
|
+
}), draft.map((tpl, idx) => (0, react.createElement)(TemplateRow, {
|
|
1941
|
+
key: tpl.id,
|
|
1755
1942
|
t,
|
|
1756
|
-
|
|
1943
|
+
index: idx,
|
|
1944
|
+
template: tpl,
|
|
1945
|
+
disabled: !editable || busy,
|
|
1946
|
+
onCommit,
|
|
1947
|
+
onDelete
|
|
1948
|
+
})), (0, react.createElement)(ImportPanel, {
|
|
1949
|
+
t,
|
|
1950
|
+
editable: editable && !busy,
|
|
1757
1951
|
onImported
|
|
1758
1952
|
}), (0, react.createElement)(AllowRootsPanel, {
|
|
1759
1953
|
t,
|
|
1760
1954
|
roots: rootsDraft,
|
|
1761
|
-
disabled: !editable,
|
|
1955
|
+
disabled: !editable || busy,
|
|
1762
1956
|
onChangeRoot: onRootChange,
|
|
1763
1957
|
onDeleteRoot: onRootDelete,
|
|
1764
1958
|
onAddRoot: onRootAdd
|
|
1765
|
-
}),
|
|
1959
|
+
}), footHint), saveBar);
|
|
1766
1960
|
}
|
|
1767
1961
|
function TemplatesCard(props) {
|
|
1768
1962
|
const { t } = props;
|
|
1769
|
-
const [open, setOpen] = (0, react.useState)(false);
|
|
1770
1963
|
const [confirmReset, setConfirmReset] = (0, react.useState)(false);
|
|
1771
1964
|
const [saveError, setSaveError] = (0, react.useState)("");
|
|
1772
1965
|
const [busy, setBusy] = (0, react.useState)(false);
|
|
@@ -1806,34 +1999,7 @@ function TemplatesCard(props) {
|
|
|
1806
1999
|
const dirty = JSON.stringify(draft) !== JSON.stringify(templates);
|
|
1807
2000
|
const rootsDirty = JSON.stringify(sanitizeAllowRoots(rootsDraft)) !== JSON.stringify(snap.allowRoots);
|
|
1808
2001
|
const anythingDirty = dirty || rootsDirty;
|
|
1809
|
-
|
|
1810
|
-
const persistActions = createPersistActions({
|
|
1811
|
-
t,
|
|
1812
|
-
editable,
|
|
1813
|
-
dirty,
|
|
1814
|
-
rootsDirty,
|
|
1815
|
-
anythingDirty,
|
|
1816
|
-
confirmReset,
|
|
1817
|
-
templates,
|
|
1818
|
-
allowRoots: snap.allowRoots,
|
|
1819
|
-
draft,
|
|
1820
|
-
rootsDraft,
|
|
1821
|
-
set: props.set,
|
|
1822
|
-
unset: props.unset,
|
|
1823
|
-
readBack: props.readBack,
|
|
1824
|
-
setDraft,
|
|
1825
|
-
setDraftFor,
|
|
1826
|
-
setRootsDraft,
|
|
1827
|
-
setBusy,
|
|
1828
|
-
setSaveError,
|
|
1829
|
-
setConfirmReset
|
|
1830
|
-
});
|
|
1831
|
-
const headerBtn = createCardHeader({
|
|
1832
|
-
t,
|
|
1833
|
-
open,
|
|
1834
|
-
setOpen
|
|
1835
|
-
});
|
|
1836
|
-
const bodyList = open ? createCardBody({
|
|
2002
|
+
return createCardBody({
|
|
1837
2003
|
t,
|
|
1838
2004
|
statusHint,
|
|
1839
2005
|
draft,
|
|
@@ -1844,10 +2010,29 @@ function TemplatesCard(props) {
|
|
|
1844
2010
|
busy,
|
|
1845
2011
|
confirmReset,
|
|
1846
2012
|
saveError,
|
|
1847
|
-
draftActions,
|
|
1848
|
-
persistActions
|
|
1849
|
-
|
|
1850
|
-
|
|
2013
|
+
draftActions: createDraftActions(t, draft, rootsDraft, setDraft, setRootsDraft),
|
|
2014
|
+
persistActions: createPersistActions({
|
|
2015
|
+
t,
|
|
2016
|
+
editable,
|
|
2017
|
+
dirty,
|
|
2018
|
+
rootsDirty,
|
|
2019
|
+
anythingDirty,
|
|
2020
|
+
confirmReset,
|
|
2021
|
+
templates,
|
|
2022
|
+
allowRoots: snap.allowRoots,
|
|
2023
|
+
draft,
|
|
2024
|
+
rootsDraft,
|
|
2025
|
+
set: props.set,
|
|
2026
|
+
unset: props.unset,
|
|
2027
|
+
readBack: props.readBack,
|
|
2028
|
+
setDraft,
|
|
2029
|
+
setDraftFor,
|
|
2030
|
+
setRootsDraft,
|
|
2031
|
+
setBusy,
|
|
2032
|
+
setSaveError,
|
|
2033
|
+
setConfirmReset
|
|
2034
|
+
})
|
|
2035
|
+
});
|
|
1851
2036
|
}
|
|
1852
2037
|
const inject = [
|
|
1853
2038
|
"slots",
|
|
@@ -1883,7 +2068,7 @@ function injectDock(ctx, store, t) {
|
|
|
1883
2068
|
};
|
|
1884
2069
|
});
|
|
1885
2070
|
}
|
|
1886
|
-
/**
|
|
2071
|
+
/** 注入设置页的「角色库」卡(插件自带卡片,宿主不再生成自动表单页)。
|
|
1887
2072
|
* 这张卡管的就是「模板」下拉与「润色」▾ 共用的那一份列表。
|
|
1888
2073
|
*
|
|
1889
2074
|
* scope 作为参数传进来而不是就地取:卡片 inject 闭包里的 set/unset 必须落到
|
|
@@ -1913,7 +2098,7 @@ function apply(ctx) {
|
|
|
1913
2098
|
ctx.effect(() => {
|
|
1914
2099
|
const tag = document.createElement("style");
|
|
1915
2100
|
tag.id = "dir-prep-organize-css";
|
|
1916
|
-
tag.textContent = CARD_STYLES
|
|
2101
|
+
tag.textContent = `${CARD_STYLES}\n${c}`;
|
|
1917
2102
|
document.head.append(tag);
|
|
1918
2103
|
return () => {
|
|
1919
2104
|
tag.remove();
|
|
@@ -1926,9 +2111,7 @@ function apply(ctx) {
|
|
|
1926
2111
|
injectDock(ctx, store, t);
|
|
1927
2112
|
injectCard(ctx, store, t, scope);
|
|
1928
2113
|
}
|
|
1929
|
-
//#endregion
|
|
1930
2114
|
exports.apply = apply;
|
|
1931
|
-
exports.applyTemplateToDraft = applyTemplateToDraft;
|
|
1932
2115
|
exports.builtinTemplatesSnapshot = builtinTemplatesSnapshot;
|
|
1933
2116
|
exports.formatContextSummary = formatContextSummary;
|
|
1934
2117
|
exports.formatImportSkips = formatImportSkips;
|