@jayyuen66/dsh-dir-prep-organize 0.1.4 → 0.1.6
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 +117 -0
- package/LICENSE +1 -1
- package/README.md +209 -104
- package/README.zh-CN.md +209 -102
- 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 +209 -141
- package/cordis.patch.yml +4 -23
- package/host.js +98 -68
- package/package.json +53 -44
- package/templates.data.mjs +9 -10
- package/types/host.d.ts +29 -21
- package/types/src/client-timeouts.d.ts +4 -4
- package/types/src/host-messages.d.ts +5 -3
- package/types/src/remote.d.ts +12 -3
- package/types/src/templates.d.ts +3 -3
- package/types/src/ui-messages.d.ts +22 -14
package/client.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// GENERATED by buildClient() in build-client.mjs — edit src/client-entry.ts, then run `node build-client.mjs`.
|
|
2
2
|
window.__ModuleLoader__.load({
|
|
3
|
-
id:
|
|
3
|
+
id: "@jayyuen66/dsh-dir-prep-organize",
|
|
4
4
|
factory: (require) => {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
'use strict';
|
|
6
|
+
const module = { exports: {} };
|
|
7
|
+
let exports = module.exports;
|
|
7
8
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
9
|
let react = require("react");
|
|
9
|
-
|
|
10
|
+
// node_modules/@jayyuen66/dsh-plugin-shared/dist/record.js
|
|
10
11
|
function e(e) {
|
|
11
12
|
return typeof e == `object` && !!e && !Array.isArray(e);
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
//#region src/templates.ts
|
|
14
|
+
// src/templates.ts
|
|
15
15
|
/** 一条提示引导词/角色模板(settings 持久化形状:全 string 字段的普通对象,
|
|
16
16
|
* 满足 dsh-settings cloneJsonShaped 的 JSON 白名单)。description/group/emoji
|
|
17
17
|
* 为必填(空串表示未设置),保证下拉与设置卡无缺字段分支。 */
|
|
@@ -47,12 +47,12 @@ function mergeImportedTemplates(existing, incoming) {
|
|
|
47
47
|
* - id 缺失或与已收集 id 撞名 → 确定性补 `tpl-<index>`(仍撞则追加
|
|
48
48
|
* `-<index>` 直到唯一)——同输入同输出,可测试;
|
|
49
49
|
* - 绝不修改输入(深比较测试锁死)。 */
|
|
50
|
-
/** 字段 → trim 后的 string;非字符串一律 ""
|
|
50
|
+
/** 字段 → trim 后的 string;非字符串一律 ""。 */
|
|
51
51
|
function trimField(value) {
|
|
52
52
|
return typeof value === "string" ? value.trim() : "";
|
|
53
53
|
}
|
|
54
54
|
/** id 缺失或与已收集 id 撞名 → 确定性补 `tpl-<index>`(仍撞则追加 `-<index>` 直到唯一)。
|
|
55
|
-
* 只负责取名,不登记 `seen
|
|
55
|
+
* 只负责取名,不登记 `seen`——登记由调用方在装配条目时按装配顺序做。 */
|
|
56
56
|
function uniqueEntryId(candidate, index, seen) {
|
|
57
57
|
if (candidate !== "" && !seen.has(candidate)) return candidate;
|
|
58
58
|
let id = `tpl-${index}`;
|
|
@@ -107,108 +107,110 @@ function sanitizeAllowRoots(raw) {
|
|
|
107
107
|
}
|
|
108
108
|
return out;
|
|
109
109
|
}
|
|
110
|
-
|
|
111
|
-
//#region src/client-timeouts.ts
|
|
110
|
+
// src/client-timeouts.ts
|
|
112
111
|
/**
|
|
113
112
|
* `setTimeout` 延时上界(Node/V8 的 2^31-1 ms)。
|
|
114
113
|
*
|
|
115
114
|
* 超了它 V8 只往 stderr 打一条 TimeoutOverflowWarning,然后把延时**静默夹成 1 ms**。
|
|
116
115
|
*/
|
|
117
116
|
const MAX_TIMER_MS = 2147483647;
|
|
117
|
+
/** 配置表单里读不到 `organizeTimeoutMs` 时的回落值(与 host 侧 ORGANIZE_TIMEOUT_MS 同值)。 */
|
|
118
|
+
const ORGANIZE_TIMEOUT_FALLBACK_MS = 12e4;
|
|
118
119
|
/** 客户端比 host 多等的余量:host 先超时,客户端留一点时间把它的回执读回来。 */
|
|
119
120
|
const ORGANIZE_TIMEOUT_SLACK_MS = 5e3;
|
|
120
121
|
/**
|
|
121
122
|
* `organizeTimeoutMs` 的前端取表。
|
|
122
123
|
*
|
|
123
124
|
* 上界与 host 同为 `[1, MAX_TIMER_MS]`:host 自己夹了上界正是为了躲开上面那个静默夹断,
|
|
124
|
-
*
|
|
125
|
+
* 而这一侧是**唯一**发起润色读面调用的地方,它要是没夹,host 夹得再对也没用。
|
|
125
126
|
*
|
|
126
127
|
* @param value - 配置表单投影值
|
|
127
128
|
* @returns `[1, MAX_TIMER_MS]` 区间内的整数;不合法时 undefined(回落默认)
|
|
128
129
|
*/
|
|
129
130
|
function rawOrganizeTimeoutMsOf(value) {
|
|
130
131
|
const raw = value["organizeTimeoutMs"];
|
|
131
|
-
return typeof raw === "number" && Number.isFinite(raw) && raw > 0 ? Math.min(Math.trunc(raw), MAX_TIMER_MS) : void 0;
|
|
132
|
+
return typeof raw === "number" && Number.isFinite(raw) && raw > 0 ? Math.min(Math.max(Math.trunc(raw), 1), MAX_TIMER_MS) : void 0;
|
|
132
133
|
}
|
|
133
134
|
/**
|
|
134
|
-
*
|
|
135
|
+
* 润色请求的客户端超时:host 的润色时限 + 余量,整条结果同样夹进 `[1, MAX_TIMER_MS]`。
|
|
135
136
|
*
|
|
136
137
|
* **加法之后还要再夹一次**,因为 `MAX_TIMER_MS + ORGANIZE_TIMEOUT_SLACK_MS` 自己就越界了
|
|
137
|
-
* (实测 V8 把 2147488647 的延时夹成 1ms
|
|
138
|
+
* (实测 V8 把 2147488647 的延时夹成 1ms,点击润色立刻回「请求超时」)。
|
|
138
139
|
*
|
|
139
|
-
* @param raw -
|
|
140
|
+
* @param raw - 配置表单投影里的润色时限(未夹)
|
|
140
141
|
* @returns 可安全交给 setTimeout 的毫秒数
|
|
141
142
|
*/
|
|
142
143
|
function organizeFetchTimeoutMs(raw) {
|
|
143
|
-
return Math.min((raw
|
|
144
|
+
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));
|
|
144
145
|
}
|
|
145
|
-
|
|
146
|
-
//#region src/client-styles.ts
|
|
146
|
+
// src/client-styles.ts
|
|
147
147
|
const CARD_STYLES = [
|
|
148
|
-
".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}",
|
|
149
|
-
".dpi-btn:hover:not(:disabled){border-color:var(--dsw-alias-label-dimmed);background:var(--dsw-alias-bg-layer-2)}",
|
|
148
|
+
".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}",
|
|
149
|
+
".dpi-btn:hover:not(:disabled){border-color:var(--dsw-alias-label-dimmed,currentColor);background:var(--dsw-alias-bg-layer-2,transparent)}",
|
|
150
150
|
".dpi-btn:disabled{opacity:.55;cursor:not-allowed}",
|
|
151
151
|
".dpi-btn:disabled[data-state=\"loading\"]{cursor:progress}",
|
|
152
|
-
".dpi-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}",
|
|
152
|
+
".dpi-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:1px}",
|
|
153
153
|
".dpi-btn svg{width:14px;height:14px;flex:none}",
|
|
154
|
-
".dpi-btn-err{border-color:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-state-error-secondary)}",
|
|
154
|
+
".dpi-btn-err{border-color:var(--dsw-alias-state-error-primary,currentColor);color:var(--dsw-alias-state-error-secondary,currentColor)}",
|
|
155
|
+
".dpi-btn-err:hover:not(:disabled){border-color:var(--dsw-alias-state-error-primary,currentColor)}",
|
|
155
156
|
".dpi-spin{animation:dpi-rotate .8s linear infinite}",
|
|
156
157
|
"@keyframes dpi-rotate{to{transform:rotate(360deg)}}",
|
|
157
|
-
".dpi-
|
|
158
|
-
".dpi-
|
|
159
|
-
".dpi-
|
|
160
|
-
".dpi-item:
|
|
161
|
-
".dpi-item-
|
|
158
|
+
"@media (prefers-reduced-motion:reduce){.dpi-spin{animation:none}.dpi-btn,.dpic-card,.dpic-chevron{transition:none}}",
|
|
159
|
+
".dpi-wrap{position:relative;display:inline-flex;isolation:isolate}",
|
|
160
|
+
".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)}",
|
|
161
|
+
".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}",
|
|
162
|
+
".dpi-item:hover,.dpi-item:focus-visible{background:var(--dsw-alias-bg-layer-2,transparent)}",
|
|
163
|
+
".dpi-item-empty{color:var(--dsw-alias-label-tertiary,inherit);cursor:default;font-size:12px;padding:8px 10px;white-space:nowrap}",
|
|
162
164
|
".dpi-split{display:inline-flex;align-items:stretch}",
|
|
163
165
|
".dpi-split .dpi-main{border-top-right-radius:0;border-bottom-right-radius:0;padding-right:8px}",
|
|
164
166
|
".dpi-split .dpi-caret{border-left:none;border-top-left-radius:0;border-bottom-left-radius:0;padding-left:4px;padding-right:6px}",
|
|
165
167
|
".dpi-split .dpi-caret svg{width:10px;height:10px}",
|
|
166
168
|
".dpi-group{padding:2px 0}",
|
|
167
|
-
".dpi-grouph{font-size:11px;font-weight:600;color:var(--dsw-alias-label-tertiary);padding:6px 10px 2px;letter-spacing:.02em}",
|
|
168
|
-
".dpic-card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:12px;list-style:none;transition:border-color .16s,background .16s}",
|
|
169
|
-
".dpic-card:hover{border-color:var(--dsw-alias-label-dimmed)}",
|
|
170
|
-
".dpic-card-open{background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-label-dimmed)}",
|
|
169
|
+
".dpi-grouph{font-size:11px;font-weight:600;color:var(--dsw-alias-label-tertiary,inherit);padding:6px 10px 2px;letter-spacing:.02em}",
|
|
170
|
+
".dpic-card{border:1px solid var(--dsw-alias-border-l2,currentColor);background:var(--dsw-alias-bg-layer-3,transparent);border-radius:12px;list-style:none;transition:border-color .16s,background .16s}",
|
|
171
|
+
".dpic-card:hover{border-color:var(--dsw-alias-label-dimmed,currentColor)}",
|
|
172
|
+
".dpic-card-open{background:var(--dsw-alias-bg-layer-2,transparent);border-color:var(--dsw-alias-label-dimmed,currentColor)}",
|
|
171
173
|
".dpic-header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:transparent;border:0;border-radius:12px;align-items:center;gap:12px;padding:14px 16px;display:flex}",
|
|
172
174
|
".dpic-head{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}",
|
|
173
|
-
".dpic-title{color:var(--dsw-alias-label-primary);font-size:15px;font-weight:600;line-height:1.4}",
|
|
174
|
-
".dpic-
|
|
175
|
-
".dpic-chevron{color:var(--dsw-alias-label-tertiary);flex:none;transition:transform .16s}",
|
|
175
|
+
".dpic-title{color:var(--dsw-alias-label-primary,inherit);font-size:15px;font-weight:600;line-height:1.4}",
|
|
176
|
+
".dpic-cardsub{color:var(--dsw-alias-label-tertiary,inherit);font-size:13px;line-height:1.5}",
|
|
177
|
+
".dpic-chevron{color:var(--dsw-alias-label-tertiary,inherit);flex:none;transition:transform .16s}",
|
|
176
178
|
".dpic-chevron-open{transform:rotate(180deg)}",
|
|
177
|
-
".dpic-body{border-top:1px solid var(--dsw-alias-border-l2);margin:0 16px;padding:8px 0 12px;list-style:none}",
|
|
178
|
-
".dpic-row{padding:10px 0;border-bottom:1px dashed var(--dsw-alias-border-l2)}",
|
|
179
|
+
".dpic-body{border-top:1px solid var(--dsw-alias-border-l2,currentColor);margin:0 16px;padding:8px 0 12px;list-style:none}",
|
|
180
|
+
".dpic-row{padding:10px 0;border-bottom:1px dashed var(--dsw-alias-border-l2,currentColor)}",
|
|
179
181
|
".dpic-rowhead{display:flex;gap:8px;align-items:center}",
|
|
180
|
-
".dpic-idx{font-size:12px;color:var(--dsw-alias-label-tertiary);flex:none;min-width:26px}",
|
|
181
|
-
".dpic-name{
|
|
182
|
-
".dpic-
|
|
183
|
-
".dpic-del:
|
|
182
|
+
".dpic-idx{font-size:12px;color:var(--dsw-alias-label-tertiary,inherit);flex:none;min-width:26px}",
|
|
183
|
+
".dpic-name,.dpic-text,.dpic-emoji,.dpic-group,.dpic-desc,.dpic-importpath{box-sizing:border-box;font:inherit;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}",
|
|
184
|
+
".dpic-name{flex:1;min-width:0;font-size:12px;padding:6px 8px}",
|
|
185
|
+
".dpic-del{appearance:none;border:1px solid var(--dsw-alias-border-l2,currentColor);background:transparent;color:var(--dsw-alias-label-tertiary,inherit);font:inherit;font-size:12px;border-radius:6px;padding:4px 8px;cursor:pointer;flex:none}",
|
|
186
|
+
".dpic-del:hover:not(:disabled){border-color:var(--dsw-alias-state-error-primary,currentColor);color:var(--dsw-alias-state-error-primary,currentColor)}",
|
|
184
187
|
".dpic-del:disabled{opacity:.55;cursor:not-allowed}",
|
|
185
|
-
".dpic-
|
|
186
|
-
".dpic-
|
|
187
|
-
".dpic-
|
|
188
|
-
".dpic-
|
|
189
|
-
".dpic-
|
|
190
|
-
".dpic-
|
|
191
|
-
".dpic-
|
|
192
|
-
".dpic-
|
|
193
|
-
".dpic-importpath
|
|
188
|
+
".dpic-header:focus-visible,.dpic-del:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:1px}",
|
|
189
|
+
".dpic-text{width:100%;font-size:12px;line-height:1.6;padding:8px;margin-top:6px;min-height:96px;resize:vertical}",
|
|
190
|
+
".dpic-name:focus,.dpic-text:focus,.dpic-emoji:focus,.dpic-group:focus,.dpic-desc:focus,.dpic-importpath:focus{outline:none;border-color:var(--dsw-alias-brand-primary,currentColor)}",
|
|
191
|
+
".dpic-name:focus-visible,.dpic-text:focus-visible,.dpic-emoji:focus-visible,.dpic-group:focus-visible,.dpic-desc:focus-visible,.dpic-importpath:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:1px}",
|
|
192
|
+
".dpic-emoji{width:44px;flex:none;font-size:13px;text-align:center;padding:6px 4px}",
|
|
193
|
+
".dpic-group{width:84px;flex:none;font-size:12px;padding:6px 8px}",
|
|
194
|
+
".dpic-desc{width:100%;font-size:12px;padding:6px 8px;margin-top:6px}",
|
|
195
|
+
".dpic-importrow{padding:12px 0;border-bottom:1px dashed var(--dsw-alias-border-l2,currentColor)}",
|
|
196
|
+
".dpic-importpath{flex:1;min-width:0;font-size:12px;padding:6px 8px}",
|
|
194
197
|
".dpic-foot{display:flex;gap:8px;align-items:center;padding-top:10px;flex-wrap:wrap}",
|
|
195
|
-
".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}",
|
|
196
|
-
".dpic-btn:hover:not(:disabled){border-color:var(--dsw-alias-label-dimmed);background:var(--dsw-alias-bg-layer-2)}",
|
|
197
|
-
".dpic-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}",
|
|
198
|
+
".dpic-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;border-radius:8px;padding:6px 10px;cursor:pointer}",
|
|
199
|
+
".dpic-btn:hover:not(:disabled){border-color:var(--dsw-alias-label-dimmed,currentColor);background:var(--dsw-alias-bg-layer-2,transparent)}",
|
|
200
|
+
".dpic-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:1px}",
|
|
198
201
|
".dpic-btn:disabled{opacity:.55;cursor:not-allowed}",
|
|
199
|
-
".dpic-btn-primary{background:var(--dsw-alias-brand-primary);border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary-foreground)}",
|
|
200
|
-
".dpic-btn-primary:disabled{
|
|
201
|
-
".dpic-btn-danger{color:var(--dsw-alias-state-error-primary)}",
|
|
202
|
-
".dpic-btn-danger:hover:not(:disabled){border-color:var(--dsw-alias-state-error-primary)}",
|
|
203
|
-
".dpic-hint{font-size:12px;color:var(--dsw-alias-label-tertiary);line-height:1.5;padding-top:6px}",
|
|
204
|
-
".dpic-err{color:var(--dsw-alias-state-error-primary)}"
|
|
202
|
+
".dpic-btn-primary{background:var(--dsw-alias-brand-primary,currentColor);border-color:var(--dsw-alias-brand-primary,currentColor);color:var(--dsw-alias-label-primary-foreground,#fff)}",
|
|
203
|
+
".dpic-btn-primary:hover:not(:disabled){background:var(--dsw-alias-brand-primary,currentColor);border-color:var(--dsw-alias-brand-primary,currentColor);filter:brightness(.92)}",
|
|
204
|
+
".dpic-btn-danger{color:var(--dsw-alias-state-error-primary,currentColor)}",
|
|
205
|
+
".dpic-btn-danger:hover:not(:disabled){border-color:var(--dsw-alias-state-error-primary,currentColor)}",
|
|
206
|
+
".dpic-hint{font-size:12px;color:var(--dsw-alias-label-tertiary,inherit);line-height:1.5;padding-top:6px}",
|
|
207
|
+
".dpic-err{color:var(--dsw-alias-state-error-primary,currentColor)}"
|
|
205
208
|
].join("\n");
|
|
206
|
-
|
|
207
|
-
//#region src/ui-messages.ts
|
|
209
|
+
// src/ui-messages.ts
|
|
208
210
|
const UI_MESSAGES = {
|
|
209
211
|
zh: {
|
|
210
|
-
cardTitle: "
|
|
211
|
-
cardDescription: "
|
|
212
|
+
cardTitle: "模板库(输入框「模板」下拉与「润色」▾ 共用)",
|
|
213
|
+
cardDescription: "输入框「模板」下拉与「润色」▾ 角色菜单共用这一份列表,空表即回落到内置精选角色集(生成自插件 agents/ 角色库)。留空点「导入角色」可一键导入内置全部;填路径则按「会话 cwd + 内置角色库 + 下方导入允许目录」放行。编辑后点「保存」生效,重启不丢。",
|
|
212
214
|
statusReadOnly: "设置源不可写:编辑已禁用;下拉仍按当前列表生效。",
|
|
213
215
|
statusNotReady: "设置源未就绪:显示当前生效列表,就绪后可编辑。",
|
|
214
216
|
addTemplate: "+ 新增模板",
|
|
@@ -218,12 +220,11 @@ const UI_MESSAGES = {
|
|
|
218
220
|
save: "保存",
|
|
219
221
|
revert: "撤销",
|
|
220
222
|
resetTitle: "丢弃模板列表的全部自定义,回到内置默认(不影响已登记的导入允许目录;两步确认,点击即生效)",
|
|
221
|
-
resetConfirm: "确认恢复默认?再点一次(
|
|
223
|
+
resetConfirm: "确认恢复默认?再点一次({seconds} 秒内)",
|
|
222
224
|
resetDefault: "恢复默认",
|
|
223
225
|
footHint: "说明:编辑/新增/删除先在本地暂存,点「保存」一次写入(模板与导入允许目录同理);清空名称或正文的条目保存时会被剔除(删除请用行内「删除」);恢复默认只回滚模板列表。",
|
|
224
226
|
saveFailed: "保存失败:",
|
|
225
227
|
newTemplateName: "新模板 {index}",
|
|
226
|
-
newTemplateText: "(填写模板正文:发给 AI 的引导词;[product] 类占位符用户发送前填写)",
|
|
227
228
|
persistUnconfirmed: "{action}结果不可确认:设置源未就绪(宿主未回读成功)",
|
|
228
229
|
persistRejected: "{action}未生效:宿主拒绝了本次写入(当前 revision {revision})",
|
|
229
230
|
rowAriaEmoji: "模板 {index} 视觉标记",
|
|
@@ -237,7 +238,7 @@ const UI_MESSAGES = {
|
|
|
237
238
|
rowDelete: "删除",
|
|
238
239
|
rowPlaceholderDescription: "一句话介绍(下拉悬停时显示;如:威胁建模与 OWASP 代码审计)",
|
|
239
240
|
rowAriaDescription: "模板 {index} 一句话介绍",
|
|
240
|
-
rowPlaceholderText: "
|
|
241
|
+
rowPlaceholderText: "模板正文(点选后插入输入框,随你的消息一起发给模型)",
|
|
241
242
|
rowAriaText: "模板 {index} 正文",
|
|
242
243
|
importFailedUnknown: "导入失败(未知错误)",
|
|
243
244
|
importEmpty: "目录下没有符合条件的角色 .md(需含 name 的 frontmatter)",
|
|
@@ -267,32 +268,37 @@ const UI_MESSAGES = {
|
|
|
267
268
|
rootsAddTitle: "加入待保存的允许目录列表",
|
|
268
269
|
rootsAdd: "登记目录",
|
|
269
270
|
rootsHint: "绝对路径默认拒绝:只有「当前会话 cwd」「插件内置角色库 agents/」与本列表登记的目录之内可导入。设置页没有会话上下文,卡上填的路径必须落在内置库或本列表内。改完点底部「保存」生效。",
|
|
270
|
-
dockOrganizeEntry: "
|
|
271
|
+
dockOrganizeEntry: "润色",
|
|
271
272
|
dockTemplatesEntry: "模板",
|
|
272
|
-
organizeIdle: "
|
|
273
|
-
organizeLoading: "
|
|
273
|
+
organizeIdle: "润色",
|
|
274
|
+
organizeLoading: "润色中",
|
|
274
275
|
organizeFailedShort: "失败",
|
|
275
|
-
organizeIdleTitle: "
|
|
276
|
-
organizeFailedTitle: "
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
276
|
+
organizeIdleTitle: "结合当前目录润色输入框内容(主键直接润色;▾ 可选角色风格)",
|
|
277
|
+
organizeFailedTitle: "润色失败:{message}",
|
|
278
|
+
organizeErrContextFailed: "目录上下文读取失败:{message}",
|
|
279
|
+
organizeErrModelFailed: "读取模型失败:{message}",
|
|
280
|
+
organizeErrEmpty: "输入框为空,无内容可润色",
|
|
281
|
+
organizeErrUnknownReason: "未知错误",
|
|
282
|
+
organizeErrUnknown: "润色失败(未知错误)",
|
|
283
|
+
organizeCaretAria: "选择润色的角色风格",
|
|
284
|
+
organizeCaretTitle: "按某个角色的风格润色(角色来自下方模板库)",
|
|
285
|
+
organizeMainAria: "润色输入框内容",
|
|
286
|
+
organizeDirectItem: "直接润色(默认,不带角色)",
|
|
287
|
+
organizeNoTemplates: "无模板可选作角色风格",
|
|
288
|
+
organizeRoleItem: "以「{name}」的风格润色",
|
|
283
289
|
organizeWriteBackUnavailable: "输入框动作不可用,无法写回",
|
|
284
|
-
templatesIdleTitle: "
|
|
290
|
+
templatesIdleTitle: "选择一条模板插入输入框(空则填入,非空则空一行追加;按分组展示)",
|
|
285
291
|
templatesBrokenTitle: "输入框动作不可用,无法插入",
|
|
286
292
|
templatesGroupCommon: "通用",
|
|
287
|
-
templatesAria: "
|
|
288
|
-
templatesEmptyHint: "
|
|
293
|
+
templatesAria: "插入模板",
|
|
294
|
+
templatesEmptyHint: "无模板:在设置页「模板库」中添加或恢复默认",
|
|
289
295
|
builtinLoading: "正在载入内置角色模板…",
|
|
290
296
|
builtinFailed: "内置模板加载失败:{message}",
|
|
291
297
|
builtinRetry: "重试"
|
|
292
298
|
},
|
|
293
299
|
en: {
|
|
294
|
-
cardTitle: "
|
|
295
|
-
cardDescription: "
|
|
300
|
+
cardTitle: "Template library (shared by the \"Template\" dropdown and the \"Polish\" ▾ menu)",
|
|
301
|
+
cardDescription: "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.",
|
|
296
302
|
statusReadOnly: "Settings source is read-only: editing is disabled; the dropdown still uses the current list.",
|
|
297
303
|
statusNotReady: "Settings source is not ready yet: showing the list currently in effect, editing unlocks once it is ready.",
|
|
298
304
|
addTemplate: "+ Add template",
|
|
@@ -302,12 +308,11 @@ const UI_MESSAGES = {
|
|
|
302
308
|
save: "Save",
|
|
303
309
|
revert: "Revert",
|
|
304
310
|
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)",
|
|
305
|
-
resetConfirm: "Restore defaults? Click once more (within
|
|
311
|
+
resetConfirm: "Restore defaults? Click once more (within {seconds}s)",
|
|
306
312
|
resetDefault: "Restore defaults",
|
|
307
313
|
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.",
|
|
308
314
|
saveFailed: "Save failed: ",
|
|
309
315
|
newTemplateName: "New template {index}",
|
|
310
|
-
newTemplateText: "(Template body: the prompt sent to the AI; fill [product]-style placeholders yourself before sending)",
|
|
311
316
|
persistUnconfirmed: "{action} cannot be confirmed: the settings source is not ready (host read-back failed)",
|
|
312
317
|
persistRejected: "{action} did not take effect: the host rejected this write (current revision {revision})",
|
|
313
318
|
rowAriaEmoji: "Visual mark of template {index}",
|
|
@@ -321,7 +326,7 @@ const UI_MESSAGES = {
|
|
|
321
326
|
rowDelete: "Delete",
|
|
322
327
|
rowPlaceholderDescription: "One-line intro (shown on dropdown hover; e.g. threat modelling and OWASP code auditing)",
|
|
323
328
|
rowAriaDescription: "One-line intro of template {index}",
|
|
324
|
-
rowPlaceholderText: "Template body (the
|
|
329
|
+
rowPlaceholderText: "Template body (inserted into the input box and sent to the model with your message)",
|
|
325
330
|
rowAriaText: "Body of template {index}",
|
|
326
331
|
importFailedUnknown: "Import failed (unknown error)",
|
|
327
332
|
importEmpty: "No qualifying role .md in that directory (frontmatter must contain name)",
|
|
@@ -351,32 +356,36 @@ const UI_MESSAGES = {
|
|
|
351
356
|
rootsAddTitle: "Add it to the pending allowed-directory list",
|
|
352
357
|
rootsAdd: "Register directory",
|
|
353
358
|
rootsHint: "Absolute paths are refused by default: imports only succeed inside \"the current session cwd\", \"the plugin's built-in role library agents/\" and the directories registered below. The settings page has no session context, so a path typed here must fall inside the built-in library or this list. Press \"Save\" at the bottom to apply.",
|
|
354
|
-
dockOrganizeEntry: "
|
|
359
|
+
dockOrganizeEntry: "Polish",
|
|
355
360
|
dockTemplatesEntry: "Templates",
|
|
356
|
-
organizeIdle: "
|
|
357
|
-
organizeLoading: "
|
|
361
|
+
organizeIdle: "Polish",
|
|
362
|
+
organizeLoading: "Polishing",
|
|
358
363
|
organizeFailedShort: "Failed",
|
|
359
|
-
organizeIdleTitle: "
|
|
360
|
-
organizeFailedTitle: "
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
364
|
+
organizeIdleTitle: "Polish the input-box content against the current directory (main key polishes directly; ▾ picks a role style)",
|
|
365
|
+
organizeFailedTitle: "Polish failed: {message}",
|
|
366
|
+
organizeErrContextFailed: "Failed to read the directory context: {message}",
|
|
367
|
+
organizeErrModelFailed: "Failed to read the model: {message}",
|
|
368
|
+
organizeErrEmpty: "The input box is empty; nothing to polish",
|
|
369
|
+
organizeErrUnknownReason: "unknown error",
|
|
370
|
+
organizeErrUnknown: "Polish failed (unknown error)",
|
|
371
|
+
organizeCaretAria: "Choose a role style to polish with",
|
|
372
|
+
organizeCaretTitle: "Polish in a role's style (roles come from the template library below)",
|
|
373
|
+
organizeMainAria: "Polish the input-box content",
|
|
374
|
+
organizeDirectItem: "Polish directly (default, no role)",
|
|
375
|
+
organizeNoTemplates: "No templates available as a role style",
|
|
376
|
+
organizeRoleItem: "Polish in the style of \"{name}\"",
|
|
367
377
|
organizeWriteBackUnavailable: "Input-box actions unavailable; cannot write back",
|
|
368
|
-
templatesIdleTitle: "Pick a
|
|
378
|
+
templatesIdleTitle: "Pick a template to insert into the input box (an empty draft is filled, a non-empty one gets a blank line plus the template; shown grouped)",
|
|
369
379
|
templatesBrokenTitle: "Input-box actions unavailable; cannot insert",
|
|
370
380
|
templatesGroupCommon: "General",
|
|
371
|
-
templatesAria: "Insert a
|
|
372
|
-
templatesEmptyHint: "No templates: add or restore defaults under \"
|
|
381
|
+
templatesAria: "Insert a template",
|
|
382
|
+
templatesEmptyHint: "No templates: add or restore defaults under \"Template library\" in the settings page",
|
|
373
383
|
builtinLoading: "Loading built-in role templates…",
|
|
374
384
|
builtinFailed: "Failed to load built-in templates: {message}",
|
|
375
385
|
builtinRetry: "Retry"
|
|
376
386
|
}
|
|
377
387
|
};
|
|
378
|
-
|
|
379
|
-
//#region node_modules/.pnpm/@jayyuen66+dsh-plugin-shared@0.1.6_@deepseek-ai+cordis@4.0.5_@deepseek-ai+dsh-client-lo_421050e71de450f7d7bae78e31868f4a/node_modules/@jayyuen66/dsh-plugin-shared/dist/errors.js
|
|
388
|
+
// node_modules/@jayyuen66/dsh-plugin-shared/dist/errors.js
|
|
380
389
|
function t(e) {
|
|
381
390
|
let t = Object.getOwnPropertyDescriptor(e, `message`);
|
|
382
391
|
return t !== void 0 && `value` in t && typeof t.value == `string` ? t.value : void 0;
|
|
@@ -388,11 +397,11 @@ function n(e, r) {
|
|
|
388
397
|
if (!(e instanceof Error)) {
|
|
389
398
|
if (typeof e == `object` && e) {
|
|
390
399
|
let n = t(e);
|
|
391
|
-
if (n !== void 0) return n;
|
|
400
|
+
if (n !== void 0 && n !== ``) return n;
|
|
392
401
|
}
|
|
393
402
|
return String(e);
|
|
394
403
|
}
|
|
395
|
-
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);
|
|
404
|
+
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(e, r)).join(`; `)}]` : ``, o = e.cause === void 0 || e.cause === null ? `` : n(e.cause, r);
|
|
396
405
|
return `${i}${a}${o === `` || o === i ? `` : `: ${o}`}`;
|
|
397
406
|
} catch {
|
|
398
407
|
return `<unrenderable value>`;
|
|
@@ -403,10 +412,12 @@ function n(e, r) {
|
|
|
403
412
|
function r(e) {
|
|
404
413
|
return n(e, /* @__PURE__ */ new Set());
|
|
405
414
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
*
|
|
415
|
+
// src/remote.ts
|
|
416
|
+
/** Typert Remote 命名空间(client 半这一侧的唯一一枚)。
|
|
417
|
+
*
|
|
418
|
+
* 宿主半的注册键在 host.ts 的 `DIR_PREP_REMOTE_NAMESPACE`——两半各自打包、client 包
|
|
419
|
+
* 不能 import host.ts,所以这一枚字面量必然有两份。两边取值必须一致:写岔了的表现是
|
|
420
|
+
* 网关挂上的是 A、报错文案说的是 B,而没有任何运行期信号。 */
|
|
410
421
|
const DIR_PREP_NAMESPACE = "dirPrepOrganize";
|
|
411
422
|
const DIR_PREP_SERVICE_KEY = `remote.${DIR_PREP_NAMESPACE}`;
|
|
412
423
|
const PACKAGE_NAME = "@jayyuen66/dsh-dir-prep-organize";
|
|
@@ -511,9 +522,15 @@ const DIR_PREP_DESCRIPTORS = [
|
|
|
511
522
|
];
|
|
512
523
|
const isMounter = (value) => e(value) && typeof value["$mount"] === "function";
|
|
513
524
|
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";
|
|
514
|
-
const unwrap = (
|
|
515
|
-
if (!
|
|
516
|
-
|
|
525
|
+
const unwrap = (raw) => {
|
|
526
|
+
if (!e(raw) || typeof raw["ok"] !== "boolean") throw new TypeError("Typert Remote 应答不是 RemoteResult:缺少布尔字段 ok");
|
|
527
|
+
if (!raw["ok"]) {
|
|
528
|
+
const { error } = raw;
|
|
529
|
+
if (!e(error) || typeof error["code"] !== "string" || typeof error["message"] !== "string") throw new TypeError("Typert Remote 应答的 error 分支缺 code/message");
|
|
530
|
+
throw new Error(`${error["code"]}: ${error["message"]}`);
|
|
531
|
+
}
|
|
532
|
+
if (!("value" in raw)) throw new TypeError("Typert Remote 应答的 ok 分支缺 value 字段");
|
|
533
|
+
return raw["value"];
|
|
517
534
|
};
|
|
518
535
|
function buildReader(ctx, remote) {
|
|
519
536
|
let mounted;
|
|
@@ -522,7 +539,12 @@ function buildReader(ctx, remote) {
|
|
|
522
539
|
package: PACKAGE_NAME,
|
|
523
540
|
descriptors: DIR_PREP_DESCRIPTORS
|
|
524
541
|
});
|
|
525
|
-
|
|
542
|
+
try {
|
|
543
|
+
await mounted;
|
|
544
|
+
} catch (error) {
|
|
545
|
+
mounted = void 0;
|
|
546
|
+
throw error;
|
|
547
|
+
}
|
|
526
548
|
const namespace = ctx.get?.(DIR_PREP_SERVICE_KEY, false);
|
|
527
549
|
if (!isNamespace(namespace)) throw new Error(`${DIR_PREP_SERVICE_KEY} 未提供:宿主网关没有挂上这枚命名空间`);
|
|
528
550
|
return namespace;
|
|
@@ -539,17 +561,27 @@ function buildReader(ctx, remote) {
|
|
|
539
561
|
importTemplates: async (args) => call((namespace) => namespace.importTemplates(args))
|
|
540
562
|
};
|
|
541
563
|
}
|
|
542
|
-
/** 造读取器;当前部署没有远程面时 undefined(卡片只显示读不到)。
|
|
564
|
+
/** 造读取器;当前部署没有远程面时 undefined(卡片只显示读不到)。
|
|
565
|
+
*
|
|
566
|
+
* `get` 的两个口径与 buildReader 里查命名空间时保持一致,都显式传 `strict = false`:
|
|
567
|
+
* 不传时 cordis 默认只返回「提供者 fiber 当前 active」的实现,而设置卡可能在 fiber
|
|
568
|
+
* 就绪前就挂上——那时读面会拿到 undefined 并显示「读不到」,看起来是插件没装。
|
|
569
|
+
* `get` 本身也可能抛(宿主版本演进后反射面可能不再接受 bool),兜住它只是为了把这
|
|
570
|
+
* 一栏降级成「读不到」,不让整张卡片跟着炸。 */
|
|
543
571
|
function createDirPrepReader(ctx) {
|
|
544
|
-
|
|
572
|
+
let remote;
|
|
573
|
+
try {
|
|
574
|
+
remote = ctx.get?.("remote", false);
|
|
575
|
+
} catch {
|
|
576
|
+
remote = void 0;
|
|
577
|
+
}
|
|
545
578
|
return isMounter(remote) ? buildReader(ctx, remote) : void 0;
|
|
546
579
|
}
|
|
547
|
-
|
|
548
|
-
//#region src/client-entry.ts
|
|
580
|
+
// src/client-entry.ts
|
|
549
581
|
const NS = "dir-prep-organize";
|
|
550
582
|
const BUNDLE_PKG = "@jayyuen66/dsh-dir-prep-organize";
|
|
551
583
|
const ERROR_FLASH_MS = 4e3;
|
|
552
|
-
/**
|
|
584
|
+
/** 非润色读面的等待上限。润色那一发有自己的超时(来自设置卡的 organizeTimeoutMs)。 */
|
|
553
585
|
const REMOTE_TIMEOUT_MS = 125e3;
|
|
554
586
|
const RESET_CONFIRM_MS = 4e3;
|
|
555
587
|
const EMOJI_PLACEHOLDER = "😀";
|
|
@@ -674,6 +706,11 @@ const builtinInitial = {
|
|
|
674
706
|
};
|
|
675
707
|
let builtinState = builtinInitial;
|
|
676
708
|
let builtinInflight = null;
|
|
709
|
+
/**
|
|
710
|
+
* 在飞 Promise 的世代。reset 之后新一代重新起跑,上一代晚到的结果不许再写进 store,
|
|
711
|
+
* 否则用户点了「恢复默认」却拿回恢复前那次请求的快照。
|
|
712
|
+
*/
|
|
713
|
+
let builtinGeneration = 0;
|
|
677
714
|
const builtinListeners = /* @__PURE__ */ new Set();
|
|
678
715
|
function setBuiltinState(next) {
|
|
679
716
|
if (next === builtinState) return builtinState;
|
|
@@ -693,7 +730,7 @@ function requireReader() {
|
|
|
693
730
|
if (dirPrepReader === void 0) throw new Error(`远程读面不可用:宿主网关没有挂上 ${DIR_PREP_NAMESPACE}`);
|
|
694
731
|
return dirPrepReader;
|
|
695
732
|
}
|
|
696
|
-
/**
|
|
733
|
+
/** 客户端超时只影响等待:宿主侧的润色超时仍由它自己的 AbortController 收口。 */
|
|
697
734
|
async function within(pending, timeoutMs) {
|
|
698
735
|
const gate = Promise.withResolvers();
|
|
699
736
|
const timer = setTimeout(() => {
|
|
@@ -708,6 +745,7 @@ async function within(pending, timeoutMs) {
|
|
|
708
745
|
async function loadBuiltinTemplates() {
|
|
709
746
|
if (builtinState.phase === "ready") return builtinState;
|
|
710
747
|
if (builtinInflight !== null) return await builtinInflight;
|
|
748
|
+
const generation = builtinGeneration;
|
|
711
749
|
builtinInflight = (async () => {
|
|
712
750
|
setBuiltinState({
|
|
713
751
|
phase: "loading",
|
|
@@ -737,9 +775,9 @@ async function loadBuiltinTemplates() {
|
|
|
737
775
|
error: r(error)
|
|
738
776
|
};
|
|
739
777
|
} finally {
|
|
740
|
-
builtinInflight = null;
|
|
778
|
+
if (builtinGeneration === generation) builtinInflight = null;
|
|
741
779
|
}
|
|
742
|
-
return setBuiltinState(settled);
|
|
780
|
+
return builtinGeneration === generation ? setBuiltinState(settled) : settled;
|
|
743
781
|
})();
|
|
744
782
|
return await builtinInflight;
|
|
745
783
|
}
|
|
@@ -750,6 +788,7 @@ function subscribeBuiltinTemplates(listener) {
|
|
|
750
788
|
};
|
|
751
789
|
}
|
|
752
790
|
function resetBuiltinTemplates() {
|
|
791
|
+
builtinGeneration += 1;
|
|
753
792
|
builtinInflight = null;
|
|
754
793
|
setBuiltinState(builtinInitial);
|
|
755
794
|
}
|
|
@@ -760,7 +799,7 @@ function builtinStatusRow(snap, t) {
|
|
|
760
799
|
};
|
|
761
800
|
const retryButton = (0, react.createElement)("button", {
|
|
762
801
|
type: "button",
|
|
763
|
-
className: "
|
|
802
|
+
className: "dpic-btn",
|
|
764
803
|
"data-field": "dpi-builtin-retry",
|
|
765
804
|
onClick: () => {
|
|
766
805
|
loadBuiltinTemplates();
|
|
@@ -770,10 +809,25 @@ function builtinStatusRow(snap, t) {
|
|
|
770
809
|
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"));
|
|
771
810
|
return row;
|
|
772
811
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
812
|
+
/**
|
|
813
|
+
* 润色链路里由客户端自己产生的错误:messageKey 指向 ui-messages 的键,捕获侧用当前
|
|
814
|
+
* 语言的 t 渲染成 tooltip——把文案直接写进 Error.message 会让英文界面看到硬编码中文。
|
|
815
|
+
* 宿主回执携带的原文(ctxRes.error / modelRes.error)不翻译,作为 {message} 原样带出。
|
|
816
|
+
*/
|
|
817
|
+
var LocalizedOrganizeError = class extends Error {
|
|
818
|
+
messageKey;
|
|
819
|
+
params;
|
|
820
|
+
constructor(messageKey, params = {}) {
|
|
821
|
+
super(messageKey);
|
|
822
|
+
this.name = "LocalizedOrganizeError";
|
|
823
|
+
this.messageKey = messageKey;
|
|
824
|
+
this.params = params;
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
function assertOrganizeReady(ctxRes, modelRes, prompt, unknownReason) {
|
|
828
|
+
if (!ctxRes.ok) throw new LocalizedOrganizeError("organizeErrContextFailed", { message: ctxRes.error ?? unknownReason });
|
|
829
|
+
if (!modelRes.ok || modelRes.provider === void 0 || modelRes.model === void 0) throw new LocalizedOrganizeError("organizeErrModelFailed", { message: modelRes.error ?? unknownReason });
|
|
830
|
+
if (prompt.trim().length === 0) throw new LocalizedOrganizeError("organizeErrEmpty");
|
|
777
831
|
}
|
|
778
832
|
async function requestOrganize(args) {
|
|
779
833
|
const { ctxRes, prompt, sessionId, roleText, timeoutMs } = args;
|
|
@@ -784,14 +838,14 @@ async function requestOrganize(args) {
|
|
|
784
838
|
entriesSummary,
|
|
785
839
|
...roleText === void 0 ? {} : { roleText }
|
|
786
840
|
}), timeoutMs));
|
|
787
|
-
if (!orgRes.ok || orgRes.content === void 0) throw
|
|
841
|
+
if (!orgRes.ok || orgRes.content === void 0) throw orgRes.error === void 0 ? new LocalizedOrganizeError("organizeErrUnknown") : new Error(orgRes.error);
|
|
788
842
|
return orgRes.content;
|
|
789
843
|
}
|
|
790
844
|
async function runOrganizeFlow(args) {
|
|
791
845
|
const reader = requireReader();
|
|
792
846
|
const [ctxRaw, modelRaw] = await Promise.all([within(reader.context(args.sessionId), REMOTE_TIMEOUT_MS), within(reader.model(args.sessionId), REMOTE_TIMEOUT_MS)]);
|
|
793
847
|
const ctxRes = parseContextResponse(ctxRaw);
|
|
794
|
-
assertOrganizeReady(ctxRes, parseModelResponse(modelRaw), args.prompt);
|
|
848
|
+
assertOrganizeReady(ctxRes, parseModelResponse(modelRaw), args.prompt, args.unknownReason);
|
|
795
849
|
return requestOrganize({
|
|
796
850
|
ctxRes,
|
|
797
851
|
prompt: args.prompt,
|
|
@@ -1001,8 +1055,9 @@ function useMenuDismiss(open, wrapRef, close) {
|
|
|
1001
1055
|
]);
|
|
1002
1056
|
}
|
|
1003
1057
|
async function runOrganizeClick(args) {
|
|
1004
|
-
const { loading, seq, prompt, sessionId, timeoutMs, roleText, setLoading, setMenuOpen, setFailed, flashTimer, writeDraft } = args;
|
|
1005
|
-
if (loading) return;
|
|
1058
|
+
const { t, loading, inFlight, seq, prompt, sessionId, timeoutMs, roleText, setLoading, setMenuOpen, setFailed, flashTimer, writeDraft } = args;
|
|
1059
|
+
if (loading || inFlight.current) return;
|
|
1060
|
+
inFlight.current = true;
|
|
1006
1061
|
seq.current += 1;
|
|
1007
1062
|
const mySeq = seq.current;
|
|
1008
1063
|
setLoading(true);
|
|
@@ -1013,22 +1068,24 @@ async function runOrganizeClick(args) {
|
|
|
1013
1068
|
prompt,
|
|
1014
1069
|
sessionId,
|
|
1015
1070
|
...roleText === void 0 ? {} : { roleText },
|
|
1016
|
-
timeoutMs
|
|
1071
|
+
timeoutMs,
|
|
1072
|
+
unknownReason: t("organizeErrUnknownReason")
|
|
1017
1073
|
});
|
|
1018
1074
|
if (seq.current !== mySeq) return;
|
|
1019
1075
|
writeDraft(content);
|
|
1020
1076
|
} catch (error) {
|
|
1021
1077
|
if (seq.current !== mySeq) return;
|
|
1022
|
-
setFailed(r(error));
|
|
1078
|
+
setFailed(error instanceof LocalizedOrganizeError ? t(error.messageKey, error.params) : r(error));
|
|
1023
1079
|
if (flashTimer.current !== null) clearTimeout(flashTimer.current);
|
|
1024
1080
|
flashTimer.current = setTimeout(() => {
|
|
1025
1081
|
setFailed(void 0);
|
|
1026
1082
|
}, ERROR_FLASH_MS);
|
|
1027
1083
|
} finally {
|
|
1084
|
+
inFlight.current = false;
|
|
1028
1085
|
if (seq.current === mySeq) setLoading(false);
|
|
1029
1086
|
}
|
|
1030
1087
|
}
|
|
1031
|
-
/**
|
|
1088
|
+
/** 润色结果无处可写时的主按钮 title(与模板项那一档同一句话,同一套判据)。 */
|
|
1032
1089
|
const NO_WRITE_BACK_TITLE_KEY = "organizeWriteBackUnavailable";
|
|
1033
1090
|
function createOrganizeMainButton(ui) {
|
|
1034
1091
|
const { t, icon, label, state, errClass, errTitle, loading, canWrite, onRun } = ui;
|
|
@@ -1061,7 +1118,9 @@ function createOrganizeCaret(ui) {
|
|
|
1061
1118
|
}, (0, react.createElement)(CaretIcon));
|
|
1062
1119
|
}
|
|
1063
1120
|
function createOrganizeRoleMenu(ui) {
|
|
1064
|
-
const { t, templates, onRun, directItemLabel, noTemplatesLabel, builtinRow } = ui;
|
|
1121
|
+
const { t, templates, onRun, directItemLabel, noTemplatesLabel, builtinRow, loading, canWrite, errTitle } = ui;
|
|
1122
|
+
const blocked = loading || !canWrite;
|
|
1123
|
+
const blockedTitle = canWrite ? void 0 : errTitle;
|
|
1065
1124
|
return (0, react.createElement)("div", {
|
|
1066
1125
|
className: "dpi-menu",
|
|
1067
1126
|
role: "menu",
|
|
@@ -1071,6 +1130,8 @@ function createOrganizeRoleMenu(ui) {
|
|
|
1071
1130
|
className: "dpi-item",
|
|
1072
1131
|
role: "menuitem",
|
|
1073
1132
|
"data-field": "dpi-organize-role-direct",
|
|
1133
|
+
disabled: blocked,
|
|
1134
|
+
...blockedTitle === void 0 ? {} : { title: blockedTitle },
|
|
1074
1135
|
onClick: () => {
|
|
1075
1136
|
onRun();
|
|
1076
1137
|
}
|
|
@@ -1080,7 +1141,8 @@ function createOrganizeRoleMenu(ui) {
|
|
|
1080
1141
|
className: "dpi-item",
|
|
1081
1142
|
role: "menuitem",
|
|
1082
1143
|
"data-field": "dpi-organize-role-item",
|
|
1083
|
-
|
|
1144
|
+
disabled: blocked,
|
|
1145
|
+
title: blockedTitle ?? (tpl.description === "" ? tpl.text : tpl.description),
|
|
1084
1146
|
onClick: () => {
|
|
1085
1147
|
onRun(tpl.text);
|
|
1086
1148
|
}
|
|
@@ -1092,6 +1154,7 @@ function createOrganizeButton() {
|
|
|
1092
1154
|
const [failed, setFailed] = (0, react.useState)(void 0);
|
|
1093
1155
|
const [menuOpen, setMenuOpen] = (0, react.useState)(false);
|
|
1094
1156
|
const seq = (0, react.useRef)(0);
|
|
1157
|
+
const inFlight = (0, react.useRef)(false);
|
|
1095
1158
|
const flashTimer = (0, react.useRef)(null);
|
|
1096
1159
|
const wrapRef = (0, react.useRef)(null);
|
|
1097
1160
|
const draft = props.useInput === void 0 ? "" : props.useInput((state) => state.draft) ?? "";
|
|
@@ -1106,7 +1169,9 @@ function createOrganizeButton() {
|
|
|
1106
1169
|
}, []);
|
|
1107
1170
|
async function handleOrganize(roleText) {
|
|
1108
1171
|
await runOrganizeClick({
|
|
1172
|
+
t: props.t,
|
|
1109
1173
|
loading,
|
|
1174
|
+
inFlight,
|
|
1110
1175
|
seq,
|
|
1111
1176
|
prompt: draft,
|
|
1112
1177
|
sessionId: props.sessionId ?? "",
|
|
@@ -1552,7 +1617,7 @@ function cardFootLabels(t) {
|
|
|
1552
1617
|
saving: t("saving"),
|
|
1553
1618
|
revert: t("revert"),
|
|
1554
1619
|
reset: t("resetDefault"),
|
|
1555
|
-
resetConfirm: t("resetConfirm"),
|
|
1620
|
+
resetConfirm: t("resetConfirm", { seconds: RESET_CONFIRM_MS / 1e3 }),
|
|
1556
1621
|
saveTitleDirty: t("saveTitleDirty"),
|
|
1557
1622
|
saveTitleClean: t("saveTitleClean"),
|
|
1558
1623
|
resetTitle: t("resetTitle")
|
|
@@ -1567,7 +1632,7 @@ function cardStatusHint(snap, t) {
|
|
|
1567
1632
|
function createCardHeader(view) {
|
|
1568
1633
|
const { t, open, setOpen } = view;
|
|
1569
1634
|
const headTitle = (0, react.createElement)("div", { className: "dpic-title" }, t("cardTitle"));
|
|
1570
|
-
const headDesc = (0, react.createElement)("div", { className: "dpic-
|
|
1635
|
+
const headDesc = (0, react.createElement)("div", { className: "dpic-cardsub" }, t("cardDescription"));
|
|
1571
1636
|
const headBlock = (0, react.createElement)("div", { className: "dpic-head" }, headTitle, headDesc);
|
|
1572
1637
|
const chevronPath = (0, react.createElement)("path", svgPathProps("M3 5l4 4 4-4", true));
|
|
1573
1638
|
const chevron = (0, react.createElement)("svg", {
|
|
@@ -1601,7 +1666,7 @@ function createDraftActions(t, draft, rootsDraft, setDraft, setRootsDraft) {
|
|
|
1601
1666
|
id: newTemplateId(),
|
|
1602
1667
|
name: t("newTemplateName", { index: draft.length + 1 }),
|
|
1603
1668
|
description: "",
|
|
1604
|
-
text:
|
|
1669
|
+
text: "",
|
|
1605
1670
|
group: "",
|
|
1606
1671
|
emoji: ""
|
|
1607
1672
|
}]);
|
|
@@ -1676,6 +1741,7 @@ function createPersistActions(args) {
|
|
|
1676
1741
|
return;
|
|
1677
1742
|
}
|
|
1678
1743
|
setConfirmReset(false);
|
|
1744
|
+
setBusy(true);
|
|
1679
1745
|
(async () => {
|
|
1680
1746
|
try {
|
|
1681
1747
|
const builtin = await loadBuiltinTemplates();
|
|
@@ -1688,6 +1754,8 @@ function createPersistActions(args) {
|
|
|
1688
1754
|
setRootsDraft(allowRoots);
|
|
1689
1755
|
} catch (error) {
|
|
1690
1756
|
reportError(error);
|
|
1757
|
+
} finally {
|
|
1758
|
+
setBusy(false);
|
|
1691
1759
|
}
|
|
1692
1760
|
})();
|
|
1693
1761
|
}
|
|
@@ -1707,7 +1775,7 @@ function createCardBody(view) {
|
|
|
1707
1775
|
t,
|
|
1708
1776
|
index: idx,
|
|
1709
1777
|
template: tpl,
|
|
1710
|
-
disabled: !editable,
|
|
1778
|
+
disabled: !editable || busy,
|
|
1711
1779
|
onCommit,
|
|
1712
1780
|
onDelete
|
|
1713
1781
|
})), (0, react.createElement)(CardFootBar, {
|
|
@@ -1722,12 +1790,12 @@ function createCardBody(view) {
|
|
|
1722
1790
|
onReset
|
|
1723
1791
|
}), (0, react.createElement)(ImportPanel, {
|
|
1724
1792
|
t,
|
|
1725
|
-
editable,
|
|
1793
|
+
editable: editable && !busy,
|
|
1726
1794
|
onImported
|
|
1727
1795
|
}), (0, react.createElement)(AllowRootsPanel, {
|
|
1728
1796
|
t,
|
|
1729
1797
|
roots: rootsDraft,
|
|
1730
|
-
disabled: !editable,
|
|
1798
|
+
disabled: !editable || busy,
|
|
1731
1799
|
onChangeRoot: onRootChange,
|
|
1732
1800
|
onDeleteRoot: onRootDelete,
|
|
1733
1801
|
onAddRoot: onRootAdd
|
|
@@ -1823,7 +1891,7 @@ const inject = [
|
|
|
1823
1891
|
"configForms",
|
|
1824
1892
|
"locale"
|
|
1825
1893
|
];
|
|
1826
|
-
/**
|
|
1894
|
+
/** 注入输入框右侧的「润色」「模板」两个按钮(两枚共用同一份 store 与 t)。
|
|
1827
1895
|
*
|
|
1828
1896
|
* 一次 inject 挂两枚:它们的 inject 面完全相同(都只要 store 这一份 card hook),
|
|
1829
1897
|
* 分成两次 inject 会让宿主多跑一轮 occupant 装配,而拆开的唯一好处只是少几行。 */
|
|
@@ -1852,7 +1920,8 @@ function injectDock(ctx, store, t) {
|
|
|
1852
1920
|
};
|
|
1853
1921
|
});
|
|
1854
1922
|
}
|
|
1855
|
-
/**
|
|
1923
|
+
/** 注入设置页的「模板库」卡(插件自带卡片,宿主不再生成自动表单页)。
|
|
1924
|
+
* 这张卡管的就是「模板」下拉与「润色」▾ 共用的那一份列表。
|
|
1856
1925
|
*
|
|
1857
1926
|
* scope 作为参数传进来而不是就地取:卡片 inject 闭包里的 set/unset 必须落到
|
|
1858
1927
|
* apply 期取的那**同一份**配置表单上(中途再 get 一次未必是同一个 provider 对象),
|
|
@@ -1894,7 +1963,6 @@ function apply(ctx) {
|
|
|
1894
1963
|
injectDock(ctx, store, t);
|
|
1895
1964
|
injectCard(ctx, store, t, scope);
|
|
1896
1965
|
}
|
|
1897
|
-
//#endregion
|
|
1898
1966
|
exports.apply = apply;
|
|
1899
1967
|
exports.applyTemplateToDraft = applyTemplateToDraft;
|
|
1900
1968
|
exports.builtinTemplatesSnapshot = builtinTemplatesSnapshot;
|