@kangyishuai/dsh-casefile 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -15,6 +15,7 @@ window.__ModuleLoader__.load({
15
15
  var useEffect = React.useEffect;
16
16
  var useState = React.useState;
17
17
  var useCallback = React.useCallback;
18
+ var useRef = React.useRef;
18
19
 
19
20
  var NS = "casefile";
20
21
  var PANEL_ID = "casefile";
@@ -24,34 +25,89 @@ window.__ModuleLoader__.load({
24
25
  "panel.title": "案卷",
25
26
  "panel.subtitle": "证据 · 义务 · 运行",
26
27
  "panel.empty": "还没有项目。建一个,把目标、证据和结论收进来。",
28
+ "panel.emptyTitle": "把调查过程留成可复查的案卷",
29
+ "panel.emptyWhat":
30
+ "案卷把一次逆向 / 审计调查里的观察、结论和验收条件记录在本机:每条结论带出处,每个义务要能复算。",
31
+ "panel.emptyWho": "适合做安全研究、软件审计与取证的人;也适合让 AI 一边分析一边留证据。",
32
+ "panel.emptyFirst":
33
+ "第一步:点右上角「新建项目」,填一个目标(文件路径或网址)。之后在对话里让 AI 往里记证据和结论。",
34
+ "panel.emptyTools":
35
+ "在对话里可以直接调用:case_project(项目)、case_evidence(证据)、case_claim(结论)、case_obligation(义务)、case_build(构建)、case_check(检查)。REA 未接入时采集类工具不可用,但手工 / 让 AI 记录仍然可用。",
36
+ "advanced.title": "给开发者 / AI 的说明",
27
37
  "panel.new": "新建项目",
28
38
  "panel.createTitle": "项目标题",
39
+ "panel.createTitleLabel": "项目标题(必填)",
29
40
  "panel.createTarget": "目标(路径 / URL)",
30
- "panel.createKind": "目标类型",
31
- "panel.createAuth": "授权档",
41
+ "panel.createKind": "对象类型",
42
+ "panel.createAuth": "授权范围",
43
+ "panel.titlePlaceholder": "例如:某 App 1.2 的登录流程",
44
+ "panel.targetPlaceholder": "文件路径或网址(可留空,默认用标题)",
45
+ "panel.titleRequired": "请填写项目标题(必填)。",
46
+ "panel.createFailed": "创建失败:{reason}",
32
47
  "panel.create": "创建",
33
48
  "panel.creating": "创建中…",
34
49
  "panel.cancel": "取消",
50
+ "kind.binary": "可执行文件",
51
+ "kind.web": "网页 / URL",
52
+ "kind.app": "应用包",
53
+ "kind.game": "游戏",
54
+ "kind.artifact": "产物文件",
55
+ "kind.other": "其他",
56
+ "scope.all": "全部范围",
57
+ "scope.selected": "选定范围",
58
+ "authOption.owned": "自有:自己的软件",
59
+ "authOption.authorized": "已授权:有书面许可",
60
+ "authOption.research": "研究:只分析,不重建",
61
+ "checkStatus.pass": "通过",
62
+ "checkStatus.fail": "失败",
63
+ "checkStatus.running": "进行中",
64
+ "checkStatus.error": "出错",
65
+ "checkStatus.unknown": "无法判定",
66
+ "confidence.observed": "实测",
67
+ "confidence.derived": "推导",
68
+ "confidence.inferred": "推断",
69
+ "authority.shipped-artifact": "随包产物",
70
+ "authority.controlled-replay": "受控复现",
71
+ "authority.live-observation": "实测观察",
72
+ "authority.external": "外部",
35
73
  "panel.refresh": "刷新",
36
74
  "panel.loading": "加载中…",
37
75
  "panel.error": "加载失败:{reason}",
38
76
  "panel.projects": "{count} 个项目",
39
77
  "panel.back": "返回列表",
78
+ "trash.toggle": "回收站",
79
+ "trash.title": "回收站(可恢复)",
80
+ "trash.empty": "回收站是空的。",
81
+ "trash.meta": "{id} · {files} 个文件 · {bytes}",
82
+ "trash.restore": "恢复",
83
+ "trash.back": "返回项目列表",
84
+ "trash.purge": "清空回收站",
85
+ "trash.purgePreview":
86
+ "将硬删 {count} 个条目({bytes},不可恢复);{skipped} 个来历不明的条目会保留。",
87
+ "trash.purgeConfirm": "确认清空",
88
+ "trash.cancel": "取消",
40
89
  "tab.evidence": "证据",
41
90
  "tab.obligation": "义务",
42
91
  "tab.run": "运行",
43
92
  "tab.evidence.count": "证据 {evidence} · 结论 {claims} · 选中 {selected}",
44
93
  "tab.obligation.count": "开 {open} · 已关 {passed} · 未知 {unknowns}",
45
94
  "claims.title": "结论(每条带出处与局限)",
46
- "claims.empty": "还没有结论。用 case_claim 记录一条。",
95
+ "claims.empty": "还没有结论。结论是这次调查里能引用的一句话,需要有证据支撑。",
96
+ "claims.emptyHint": "在对话里让 AI 调 case_claim add 记录一条;参数见工具说明。",
47
97
  "claims.selected": "已选中",
48
98
  "claims.evidence": "证据 {count}",
49
99
  "claims.limits": "局限:{text}",
50
100
  "evidence.title": "证据",
51
- "evidence.empty": "还没有证据。用 case_evidence 记录一条。",
101
+ "evidence.empty":
102
+ "还没有证据。证据是一条带出处的观察,例如「登录请求里带了一个硬编码的 key」。",
103
+ "evidence.emptyHint":
104
+ "在对话里让 AI 调 case_evidence add 记录一条;REA 接通后也可以直接摄入 REA 的产出。",
52
105
  "evidence.confidence": "{confidence} / {authority}",
53
106
  "obligation.title": "义务(关闭必须有新鲜 PASS 检查)",
54
- "obligation.empty": "还没有义务。用 case_obligation 加一条可验收的断言。",
107
+ "obligation.empty":
108
+ "还没有义务。义务是一条可验收的断言,例如「登录页有两个输入框」;关闭前必须有一条新的通过检查。",
109
+ "obligation.emptyHint":
110
+ "在对话里让 AI 调 case_obligation add 加一条,再用 case_check run 跑检查。",
55
111
  "obligation.open": "待关闭",
56
112
  "obligation.pass": "已关闭",
57
113
  "obligation.fail": "失败",
@@ -62,7 +118,8 @@ window.__ModuleLoader__.load({
62
118
  "obligation.closing": "关闭中…",
63
119
  "obligation.blockedReason": "还不能关闭:缺新鲜 PASS 检查",
64
120
  "run.title": "构建与验收",
65
- "run.empty": "还没有构建记录。用 case_build 起一轮构建。",
121
+ "run.empty": "还没有构建记录。构建用于复算实现:跑一条命令,并记下它的摘要。",
122
+ "run.emptyHint": "在对话里让 AI 调 case_build start 起一轮构建。",
66
123
  "run.builds": "构建轮次",
67
124
  "run.checks": "检查结论",
68
125
  "run.round": "第 {round} 轮",
@@ -84,8 +141,16 @@ window.__ModuleLoader__.load({
84
141
  "blocker.blockedObligations": "有阻塞的义务",
85
142
  "blocker.coverageBelow": "覆盖率不足",
86
143
  "autonomy.label": "自主性",
87
- "autonomy.hint":
88
- "L3 无人值守仅对 scope=selected 且义务全带检查配方的项目开放;任一失败即停。",
144
+ "autonomy.hint": "让 AI 自己反复尝试的权限等级;等级越高越自动,任何一次失败都会停下。",
145
+ "autonomy.scale": "L0–L3:L3 = 无人值守,仅限「选定范围」且义务全带检查配方的项目",
146
+ "danger.title": "危险操作",
147
+ "danger.dropHint": "把整个项目移进本机回收站;可以恢复,不会硬删。",
148
+ "danger.drop": "移入回收站…",
149
+ "danger.dropPreview":
150
+ "将把项目 {id}({files} 个文件 / {bytes})移进回收站;可以在「回收站」里恢复。",
151
+ "danger.dropConfirm": "确认移入回收站",
152
+ "danger.dropCancel": "取消",
153
+ "danger.dropBusy": "移动中…",
89
154
  "wait.title": "案卷:等待登录",
90
155
  "wait.hint": "请在弹出的浏览器窗口里完成登录;就绪后会自动继续。",
91
156
  "wait.elapsed": "已等待 {seconds}s",
@@ -95,9 +160,13 @@ window.__ModuleLoader__.load({
95
160
  "settings.section": "案卷",
96
161
  "settings.summary": "{count} 个项目",
97
162
  "settings.dataRoot": "数据根目录",
98
- "settings.rea": "REA 能力",
99
- "settings.reaMissing": "未检测到 mcp__rea__*(先接好 REA)",
100
- "settings.reaOk": "已连接({count} 个工具)",
163
+ "settings.rea": "REA 接入",
164
+ "settings.reaMissing": "未接入(可选)",
165
+ "settings.reaMissingHint":
166
+ "不影响建项目和手工记录证据;要自动采集与分析,先注册 REA 的 MCP 服务器(见 README 的 Requirements)。",
167
+ "settings.reaDetailMissing": "检测结果:本会话未发现 mcp__rea__* 工具。",
168
+ "settings.reaDetailOk": "检测结果:找到 {count} 个 mcp__rea__* 工具。",
169
+ "settings.reaOk": "已接入({count} 个工具)",
101
170
  "settings.hint": "项目数据只在本机;规格包默认脱敏,但分享前请自己过一遍。",
102
171
  "nav.title": "案卷",
103
172
  "auth.owned": "自有",
@@ -119,34 +188,92 @@ window.__ModuleLoader__.load({
119
188
  "panel.title": "Casefile",
120
189
  "panel.subtitle": "Evidence · Obligations · Runs",
121
190
  "panel.empty": "No projects yet. Create one and collect targets, evidence, and claims.",
191
+ "panel.emptyTitle": "Keep an investigation reviewable as a case file",
192
+ "panel.emptyWhat":
193
+ "A case file records the observations, claims and acceptance criteria of one investigation on this machine: every claim keeps its sources, every obligation must be recomputable.",
194
+ "panel.emptyWho":
195
+ "For people doing security research, software audit or forensics — and for letting the AI leave evidence as it works.",
196
+ "panel.emptyFirst":
197
+ "First step: click “New project” at the top right and enter a target (a file path or a URL). Then ask the AI to record evidence and claims as you go.",
198
+ "panel.emptyTools":
199
+ "In the chat you can call: case_project (projects), case_evidence (evidence), case_claim (claims), case_obligation (obligations), case_build (builds) and case_check (checks). Without REA the acquisition tools are unavailable, but manual / AI-recorded evidence still works.",
200
+ "advanced.title": "For developers / the AI agent",
122
201
  "panel.new": "New project",
123
202
  "panel.createTitle": "Project title",
203
+ "panel.createTitleLabel": "Project title (required)",
124
204
  "panel.createTarget": "Target (path / URL)",
125
205
  "panel.createKind": "Target kind",
126
206
  "panel.createAuth": "Authorization",
207
+ "panel.titlePlaceholder": "e.g. the sign-in flow of App 1.2",
208
+ "panel.targetPlaceholder": "File path or URL (optional; defaults to the title)",
209
+ "panel.titleRequired": "Please enter a project title (required).",
210
+ "panel.createFailed": "Create failed: {reason}",
127
211
  "panel.create": "Create",
128
212
  "panel.creating": "Creating…",
129
213
  "panel.cancel": "Cancel",
214
+ "kind.binary": "Binary",
215
+ "kind.web": "Web / URL",
216
+ "kind.app": "App bundle",
217
+ "kind.game": "Game",
218
+ "kind.artifact": "Artifact",
219
+ "kind.other": "Other",
220
+ "scope.all": "All scope",
221
+ "scope.selected": "Selected scope",
222
+ "authOption.owned": "Owned: my own software",
223
+ "authOption.authorized": "Authorized: written permission",
224
+ "authOption.research": "Research: analyze only, no rebuild",
225
+ "checkStatus.pass": "pass",
226
+ "checkStatus.fail": "fail",
227
+ "checkStatus.running": "running",
228
+ "checkStatus.error": "error",
229
+ "checkStatus.unknown": "unknown",
230
+ "confidence.observed": "observed",
231
+ "confidence.derived": "derived",
232
+ "confidence.inferred": "inferred",
233
+ "authority.shipped-artifact": "shipped artifact",
234
+ "authority.controlled-replay": "controlled replay",
235
+ "authority.live-observation": "live observation",
236
+ "authority.external": "external",
130
237
  "panel.refresh": "Refresh",
131
238
  "panel.loading": "Loading…",
132
239
  "panel.error": "Failed to load: {reason}",
133
240
  "panel.projects": "{count} projects",
134
241
  "panel.back": "Back to list",
242
+ "trash.toggle": "Trash",
243
+ "trash.title": "Trash (restorable)",
244
+ "trash.empty": "The trash is empty.",
245
+ "trash.meta": "{id} · {files} files · {bytes}",
246
+ "trash.restore": "Restore",
247
+ "trash.back": "Back to projects",
248
+ "trash.purge": "Empty trash",
249
+ "trash.purgePreview":
250
+ "Permanently deletes {count} entries ({bytes}); {skipped} unknown entries are kept.",
251
+ "trash.purgeConfirm": "Empty it",
252
+ "trash.cancel": "Cancel",
135
253
  "tab.evidence": "Evidence",
136
254
  "tab.obligation": "Obligations",
137
255
  "tab.run": "Runs",
138
256
  "tab.evidence.count": "{evidence} evidence · {claims} claims · {selected} selected",
139
257
  "tab.obligation.count": "{open} open · {passed} closed · {unknowns} unknowns",
140
258
  "claims.title": "Claims (each with provenance and limits)",
141
- "claims.empty": "No claims yet. Record one with case_claim.",
259
+ "claims.empty":
260
+ "No claims yet. A claim is one sentence you can cite from this investigation; it needs evidence behind it.",
261
+ "claims.emptyHint":
262
+ "Ask the AI to record one with case_claim add; see the tool description for arguments.",
142
263
  "claims.selected": "selected",
143
264
  "claims.evidence": "evidence {count}",
144
265
  "claims.limits": "limits: {text}",
145
266
  "evidence.title": "Evidence",
146
- "evidence.empty": "No evidence yet. Record one with case_evidence.",
267
+ "evidence.empty":
268
+ "No evidence yet. Evidence is an observation with a source, e.g. “the sign-in request carries a hard-coded key”.",
269
+ "evidence.emptyHint":
270
+ "Ask the AI to record one with case_evidence add; once REA is connected you can also ingest REA output.",
147
271
  "evidence.confidence": "{confidence} / {authority}",
148
272
  "obligation.title": "Obligations (closing needs a fresh PASS check)",
149
- "obligation.empty": "No obligations yet. Add a verifiable statement with case_obligation.",
273
+ "obligation.empty":
274
+ "No obligations yet. An obligation is a verifiable statement, e.g. “the sign-in page has two inputs”; closing it needs a new passing check.",
275
+ "obligation.emptyHint":
276
+ "Ask the AI to add one with case_obligation add, then run a check with case_check run.",
150
277
  "obligation.open": "open",
151
278
  "obligation.pass": "closed",
152
279
  "obligation.fail": "failed",
@@ -157,7 +284,9 @@ window.__ModuleLoader__.load({
157
284
  "obligation.closing": "Closing…",
158
285
  "obligation.blockedReason": "Cannot close yet: needs a fresh PASS check",
159
286
  "run.title": "Build & verification",
160
- "run.empty": "No builds yet. Start one with case_build.",
287
+ "run.empty":
288
+ "No builds yet. A build recomputes the implementation: run one command and record its summary.",
289
+ "run.emptyHint": "Ask the AI to start one with case_build start.",
161
290
  "run.builds": "Build rounds",
162
291
  "run.checks": "Check verdicts",
163
292
  "run.round": "Round {round}",
@@ -180,7 +309,18 @@ window.__ModuleLoader__.load({
180
309
  "blocker.coverageBelow": "coverage below target",
181
310
  "autonomy.label": "Autonomy",
182
311
  "autonomy.hint":
183
- "L3 unattended runs are limited to scope=selected projects whose obligations all carry check recipes; any failure stops the loop.",
312
+ "How far the AI may retry on its own; higher levels are more automatic and any failure stops the run.",
313
+ "autonomy.scale":
314
+ "L0–L3; L3 = unattended, only for “selected scope” projects whose obligations all carry check recipes",
315
+ "danger.title": "Danger zone",
316
+ "danger.dropHint":
317
+ "Move the whole project into this machine's trash; it stays restorable and is never hard-deleted.",
318
+ "danger.drop": "Move to trash…",
319
+ "danger.dropPreview":
320
+ "This moves project {id} ({files} files / {bytes}) to the trash; you can restore it from “Trash”.",
321
+ "danger.dropConfirm": "Move to trash",
322
+ "danger.dropCancel": "Cancel",
323
+ "danger.dropBusy": "Moving…",
184
324
  "wait.title": "Casefile: waiting for sign-in",
185
325
  "wait.hint":
186
326
  "Finish signing in in the browser window; it continues automatically once ready.",
@@ -191,8 +331,12 @@ window.__ModuleLoader__.load({
191
331
  "settings.section": "Casefile",
192
332
  "settings.summary": "{count} projects",
193
333
  "settings.dataRoot": "Data root",
194
- "settings.rea": "REA capability",
195
- "settings.reaMissing": "No mcp__rea__* detected (connect REA first)",
334
+ "settings.rea": "REA connection",
335
+ "settings.reaMissing": "Not connected (optional)",
336
+ "settings.reaMissingHint":
337
+ "Creating projects and recording evidence by hand still works; for automatic acquisition and analysis, register REA's MCP server first (see Requirements in the README).",
338
+ "settings.reaDetailMissing": "Detection: no mcp__rea__* tools in this session.",
339
+ "settings.reaDetailOk": "Detection: {count} mcp__rea__* tools found.",
196
340
  "settings.reaOk": "Connected ({count} tools)",
197
341
  "settings.hint":
198
342
  "Project data stays local; spec packs are redacted by default but review them before sharing.",
@@ -228,6 +372,18 @@ window.__ModuleLoader__.load({
228
372
  );
229
373
  }
230
374
 
375
+ /**
376
+ * 字节数转短文本(回收站条目影响面用)。
377
+ * @param {number} value
378
+ * @returns {string}
379
+ */
380
+ function formatBytes(value) {
381
+ var bytes = Number(value) || 0;
382
+ if (bytes < 1024) return bytes + " B";
383
+ if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + " KB";
384
+ return (bytes / (1024 * 1024)).toFixed(1) + " MB";
385
+ }
386
+
231
387
  // 业务拒绝里的 blocker 令牌 → 文案 key(与 actions 产出的字符串一一对应)。
232
388
  var BLOCKER_KEYS = {
233
389
  "no-fresh-check": "blocker.noFreshCheck",
@@ -250,6 +406,29 @@ window.__ModuleLoader__.load({
250
406
  "check-stale": "blocker.checkStale",
251
407
  };
252
408
 
409
+ // 中英混排收敛:UI 里出现的枚举值(目标类型 / 范围 / 状态 / 可信度 / 权威性)
410
+ // 按组查文案;未知值原样回退,绝不把新值悄悄吞掉。
411
+ var VOCAB = {
412
+ kind: ["binary", "web", "app", "game", "artifact", "other"],
413
+ scope: ["all", "selected"],
414
+ checkStatus: ["pass", "fail", "running", "error", "unknown"],
415
+ confidence: ["observed", "derived", "inferred"],
416
+ authority: ["shipped-artifact", "controlled-replay", "live-observation", "external"],
417
+ };
418
+
419
+ /**
420
+ * @param {any} t
421
+ * @param {string} group
422
+ * @param {any} value
423
+ * @returns {string}
424
+ */
425
+ function vocab(t, group, value) {
426
+ var raw = value === undefined || value === null ? "" : String(value);
427
+ var known = /** @type {Record<string, string[]>} */ (VOCAB)[group] || [];
428
+ if (raw !== "" && known.indexOf(raw) >= 0) return text(t, group + "." + raw);
429
+ return raw;
430
+ }
431
+
253
432
  /**
254
433
  * 把宿主返回的错误变成人能读的一句话:去掉 `[code]` 前缀,
255
434
  * 把 `:a、b:2` 里的 blocker 令牌翻成文案。
@@ -344,6 +523,24 @@ window.__ModuleLoader__.load({
344
523
  ".cf-settings{padding:4px 0}",
345
524
  ".cf-kv{display:flex;gap:8px;padding:2px 0;font-size:12px}",
346
525
  ".cf-kv b{font-weight:500;flex:none;min-width:92px;color:var(--dsw-alias-label-secondary)}",
526
+ ".cf-empty-guide{max-width:640px;margin:0 auto;padding:28px 20px;text-align:left;display:flex;flex-direction:column;gap:8px}",
527
+ ".cf-empty-guide h3{font-size:15px;margin:0;font-weight:600;color:var(--dsw-alias-label-primary)}",
528
+ ".cf-empty-guide p{margin:0;line-height:1.6;color:var(--dsw-alias-label-secondary);font-size:12px}",
529
+ ".cf-empty-guide .cf-empty-step{color:var(--dsw-alias-label-primary)}",
530
+ ".cf-advanced{margin-top:8px;font-size:11px;color:var(--dsw-alias-label-secondary);text-align:left}",
531
+ ".cf-advanced summary{cursor:pointer;font-size:11px;color:var(--dsw-alias-label-secondary)}",
532
+ ".cf-advanced-body{margin-top:4px;line-height:1.6;word-break:break-word}",
533
+ ".cf-field{display:flex;flex-direction:column;gap:2px;flex:1 1 180px;min-width:0}",
534
+ ".cf-field-label{font-size:11px;color:var(--dsw-alias-label-secondary)}",
535
+ ".cf-field .cf-input,.cf-field .cf-select{width:100%;box-sizing:border-box}",
536
+ ".cf-input[data-invalid=true]{border-color:var(--dsw-alias-state-error-primary)}",
537
+ ".cf-form-error{flex:1 1 100%;color:var(--dsw-alias-state-error-primary);font-size:12px;line-height:1.5}",
538
+ ".cf-info{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:8px;padding:8px 10px;font-size:12px;line-height:1.55}",
539
+ ".cf-info-title{font-weight:500}",
540
+ ".cf-info[data-state=unavailable]{color:var(--dsw-alias-label-secondary)}",
541
+ ".cf-danger{margin-top:20px;border-top:1px dashed var(--dsw-alias-border-l1);padding-top:10px}",
542
+ ".cf-danger summary{cursor:pointer;font-size:12px;color:var(--dsw-alias-label-secondary)}",
543
+ ".cf-danger-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-top:8px}",
347
544
  ].join("\n");
348
545
 
349
546
  /**
@@ -374,6 +571,53 @@ window.__ModuleLoader__.load({
374
571
  );
375
572
  }
376
573
 
574
+ /**
575
+ * 「高级 / 开发者」折叠:工具名与检测细节都收在这里,普通用户默认看不到。
576
+ * @param {{ t: any, children?: any }} props
577
+ */
578
+ function AdvancedHint(props) {
579
+ return h(
580
+ "details",
581
+ { className: "cf-advanced", "data-casefile-advanced": "1" },
582
+ h("summary", null, text(props.t, "advanced.title")),
583
+ h("div", { className: "cf-advanced-body" }, props.children),
584
+ );
585
+ }
586
+
587
+ /**
588
+ * 页签空态:人话在前,工具名收进高级折叠。
589
+ * @param {{ t: any, kind: string, human: string, hint: string }} props
590
+ */
591
+ function EmptyHint(props) {
592
+ return h(
593
+ "div",
594
+ { className: "cf-empty", "data-casefile-empty": props.kind },
595
+ h("div", null, props.human),
596
+ h(AdvancedHint, { t: props.t }, props.hint),
597
+ );
598
+ }
599
+
600
+ /**
601
+ * 项目列表空态:这是什么、适合谁、第一步做什么;工具名收进高级折叠。
602
+ * @param {{ t: any }} props
603
+ */
604
+ function ProjectEmptyGuide(props) {
605
+ var t = props.t;
606
+ return h(
607
+ "div",
608
+ { className: "cf-empty", "data-casefile-empty": "projects" },
609
+ h(
610
+ "div",
611
+ { className: "cf-empty-guide" },
612
+ h("h3", null, text(t, "panel.emptyTitle")),
613
+ h("p", null, text(t, "panel.emptyWhat")),
614
+ h("p", null, text(t, "panel.emptyWho")),
615
+ h("p", { className: "cf-empty-step" }, text(t, "panel.emptyFirst")),
616
+ h(AdvancedHint, { t: t }, text(t, "panel.emptyTools")),
617
+ ),
618
+ );
619
+ }
620
+
377
621
  /** @param {{ t: any, project: any, active: boolean, onClick: () => void }} props */
378
622
  function ProjectRow(props) {
379
623
  var project = props.project;
@@ -394,7 +638,9 @@ window.__ModuleLoader__.load({
394
638
  h(
395
639
  "div",
396
640
  { className: "cf-row-meta" },
397
- project.target ? `${project.target.kind} · ${project.target.ref}` : project.id,
641
+ project.target
642
+ ? `${vocab(props.t, "kind", project.target.kind)} · ${project.target.ref}`
643
+ : project.id,
398
644
  ),
399
645
  h(
400
646
  "div",
@@ -431,7 +677,7 @@ window.__ModuleLoader__.load({
431
677
  ? "warn"
432
678
  : "neutral",
433
679
  },
434
- claim.status,
680
+ vocab(props.t, "confidence", claim.status),
435
681
  ),
436
682
  claim.selected
437
683
  ? h(Tag, { t: props.t, tone: "ok" }, text(props.t, "claims.selected"))
@@ -466,7 +712,11 @@ window.__ModuleLoader__.load({
466
712
  h(
467
713
  Tag,
468
714
  { t: props.t, tone: item.confidence === "observed" ? "ok" : "warn" },
469
- `${item.confidence} / ${item.authority}`,
715
+ `${vocab(props.t, "confidence", item.confidence)} / ${vocab(
716
+ props.t,
717
+ "authority",
718
+ item.authority,
719
+ )}`,
470
720
  ),
471
721
  ),
472
722
  h(
@@ -519,7 +769,13 @@ window.__ModuleLoader__.load({
519
769
  obligation.status === "pass" ? "obligation.status.pass" : "obligation.status.open",
520
770
  ),
521
771
  ),
522
- h(Tag, { t: props.t }, obligation.authorityRequired),
772
+ h(
773
+ Tag,
774
+ { t: props.t },
775
+ obligation.authorityRequired
776
+ ? vocab(props.t, "authority", obligation.authorityRequired)
777
+ : "",
778
+ ),
523
779
  ),
524
780
  h(
525
781
  "div",
@@ -683,6 +939,59 @@ window.__ModuleLoader__.load({
683
939
  var busyState = useState(false);
684
940
  var busy = busyState[0];
685
941
  var setBusy = busyState[1];
942
+ var showTrashState = useState(false);
943
+ var showTrash = showTrashState[0];
944
+ var setShowTrash = showTrashState[1];
945
+ var trashState = useState(null);
946
+ var trash = trashState[0];
947
+ var setTrash = trashState[1];
948
+ var trashBusyState = useState(false);
949
+ var trashBusy = trashBusyState[0];
950
+ var setTrashBusy = trashBusyState[1];
951
+ var purgePreviewState = useState(null);
952
+ var purgePreview = purgePreviewState[0];
953
+ var setPurgePreview = purgePreviewState[1];
954
+ // 新建表单:必填反馈(失焦或提交过才显示)+ 表单内错误(不顶掉全局错误)
955
+ var titleTouchedState = useState(false);
956
+ var titleTouched = titleTouchedState[0];
957
+ var setTitleTouched = titleTouchedState[1];
958
+ var submitAttemptedState = useState(false);
959
+ var submitAttempted = submitAttemptedState[0];
960
+ var setSubmitAttempted = submitAttemptedState[1];
961
+ var formErrorState = useState("");
962
+ var formError = formErrorState[0];
963
+ var setFormError = formErrorState[1];
964
+ // 危险操作:先 dry-run 拿影响面,再显式确认(ADR 0002)
965
+ var dropPreviewState = useState(null);
966
+ var dropPreview = dropPreviewState[0];
967
+ var setDropPreview = dropPreviewState[1];
968
+ var dropBusyState = useState(false);
969
+ var dropBusy = dropBusyState[0];
970
+ var setDropBusy = dropBusyState[1];
971
+ // 危险操作的焦点契约(复审 A3 / plugin-conventions §7.4.2):
972
+ // - 展开「危险操作」时焦点进主按钮(入口本身只做 dry-run,不破坏数据);
973
+ // - 预览卡出现时焦点移到「取消」(安全项)——以前入口按钮被替换掉,焦点直接掉到 body;
974
+ // - 取消收起后焦点还回入口,键盘/屏读用户不用从页面开头重新 Tab。
975
+ var dropEntryRef = useRef(null);
976
+ var dropCancelRef = useRef(null);
977
+ var dropHadPreviewRef = useRef(false);
978
+ useEffect(() => {
979
+ if (dropPreview) {
980
+ dropHadPreviewRef.current = true;
981
+ if (dropCancelRef.current && typeof dropCancelRef.current.focus === "function") {
982
+ dropCancelRef.current.focus();
983
+ }
984
+ return;
985
+ }
986
+ if (dropHadPreviewRef.current) {
987
+ dropHadPreviewRef.current = false;
988
+ if (dropEntryRef.current && typeof dropEntryRef.current.focus === "function") {
989
+ dropEntryRef.current.focus();
990
+ }
991
+ }
992
+ }, [dropPreview]);
993
+
994
+ var titleInvalid = (titleTouched || submitAttempted) && title.trim() === "";
686
995
 
687
996
  var loadList = useCallback(() => {
688
997
  setLoading(true);
@@ -706,6 +1015,7 @@ window.__ModuleLoader__.load({
706
1015
  return call(ctx, "projectDetail", { projectId: id })
707
1016
  .then((value) => {
708
1017
  setDetail(value);
1018
+ setDropPreview(null);
709
1019
  setError("");
710
1020
  })
711
1021
  .catch((/** @type {any} */ err) => {
@@ -722,8 +1032,93 @@ window.__ModuleLoader__.load({
722
1032
  loadList();
723
1033
  }, [loadList]);
724
1034
 
1035
+ // ---------- 回收站(ADR 0002:能查看 / 恢复 / 清空) ----------
1036
+
1037
+ var loadTrash = useCallback(() => {
1038
+ setLoading(true);
1039
+ return call(ctx, "listTrash")
1040
+ .then((value) => {
1041
+ setTrash(value || []);
1042
+ setError("");
1043
+ })
1044
+ .catch((/** @type {any} */ err) => {
1045
+ setError(err?.message ? err.message : String(err));
1046
+ })
1047
+ .finally(() => {
1048
+ setLoading(false);
1049
+ });
1050
+ }, [ctx]);
1051
+
1052
+ var openTrash = () => {
1053
+ setShowTrash(true);
1054
+ setDetail(null);
1055
+ setPurgePreview(null);
1056
+ loadTrash();
1057
+ };
1058
+
1059
+ var closeTrash = () => {
1060
+ setShowTrash(false);
1061
+ setPurgePreview(null);
1062
+ setTrash(null);
1063
+ };
1064
+
1065
+ var restoreEntry = (/** @type {string} */ name) => {
1066
+ if (trashBusy) return;
1067
+ setTrashBusy(true);
1068
+ call(ctx, "restoreTrashEntry", { name: name })
1069
+ .then(() => {
1070
+ setPurgePreview(null);
1071
+ return loadTrash();
1072
+ })
1073
+ .then(() => loadList())
1074
+ .catch((/** @type {any} */ err) => {
1075
+ setError(humanizeError(err, t));
1076
+ })
1077
+ .finally(() => {
1078
+ setTrashBusy(false);
1079
+ });
1080
+ };
1081
+
1082
+ var previewPurge = () => {
1083
+ if (trashBusy) return;
1084
+ setTrashBusy(true);
1085
+ call(ctx, "purgeTrash", { options: { dryRun: true } })
1086
+ .then((value) => {
1087
+ setPurgePreview(value || null);
1088
+ setError("");
1089
+ })
1090
+ .catch((/** @type {any} */ err) => {
1091
+ setError(humanizeError(err, t));
1092
+ })
1093
+ .finally(() => {
1094
+ setTrashBusy(false);
1095
+ });
1096
+ };
1097
+
1098
+ var confirmPurge = () => {
1099
+ if (trashBusy) return;
1100
+ setTrashBusy(true);
1101
+ call(ctx, "purgeTrash", { options: { confirm: true } })
1102
+ .then(() => {
1103
+ setPurgePreview(null);
1104
+ return loadTrash();
1105
+ })
1106
+ .catch((/** @type {any} */ err) => {
1107
+ setError(humanizeError(err, t));
1108
+ })
1109
+ .finally(() => {
1110
+ setTrashBusy(false);
1111
+ });
1112
+ };
1113
+
725
1114
  var create = () => {
726
1115
  if (busy) return;
1116
+ // 必填校验失败必须有可见反馈(点「创建」不能像没反应)
1117
+ if (title.trim() === "") {
1118
+ setSubmitAttempted(true);
1119
+ return;
1120
+ }
1121
+ setFormError("");
727
1122
  setBusy(true);
728
1123
  call(ctx, "createProject", {
729
1124
  input: {
@@ -736,16 +1131,54 @@ window.__ModuleLoader__.load({
736
1131
  setShowForm(false);
737
1132
  setTitle("");
738
1133
  setTarget("");
1134
+ setTitleTouched(false);
1135
+ setSubmitAttempted(false);
1136
+ setFormError("");
739
1137
  return loadList().then(() => openProject(project.id));
740
1138
  })
741
1139
  .catch((/** @type {any} */ err) => {
742
- setError(err?.message ? err.message : String(err));
1140
+ setFormError(text(t, "panel.createFailed", { reason: humanizeError(err, t) }));
743
1141
  })
744
1142
  .finally(() => {
745
1143
  setBusy(false);
746
1144
  });
747
1145
  };
748
1146
 
1147
+ var previewDrop = () => {
1148
+ if (dropBusy || !detail) return;
1149
+ setDropBusy(true);
1150
+ call(ctx, "dropProject", { projectId: detail.project.id, options: { dryRun: true } })
1151
+ .then((value) => {
1152
+ setDropPreview(value || null);
1153
+ setError("");
1154
+ })
1155
+ .catch((/** @type {any} */ err) => {
1156
+ setError(humanizeError(err, t));
1157
+ })
1158
+ .finally(() => {
1159
+ setDropBusy(false);
1160
+ });
1161
+ };
1162
+
1163
+ var confirmDrop = () => {
1164
+ if (dropBusy || !detail) return;
1165
+ setDropBusy(true);
1166
+ call(ctx, "dropProject", { projectId: detail.project.id, options: { confirm: true } })
1167
+ .then(() => {
1168
+ setDropPreview(null);
1169
+ setDetail(null);
1170
+ setShowTrash(true);
1171
+ setPurgePreview(null);
1172
+ return Promise.all([loadList(), loadTrash()]);
1173
+ })
1174
+ .catch((/** @type {any} */ err) => {
1175
+ setError(humanizeError(err, t));
1176
+ })
1177
+ .finally(() => {
1178
+ setDropBusy(false);
1179
+ });
1180
+ };
1181
+
749
1182
  var closeObligation = useCallback(
750
1183
  (/** @type {string} */ id) => {
751
1184
  if (!detail) return Promise.resolve();
@@ -770,7 +1203,118 @@ window.__ModuleLoader__.load({
770
1203
  var builds;
771
1204
  var checks;
772
1205
  var tabs;
773
- if (detail) {
1206
+ if (showTrash) {
1207
+ body = h(
1208
+ "div",
1209
+ { className: "cf-body" },
1210
+ h(
1211
+ "div",
1212
+ { className: "cf-detail", "data-casefile-trash-view": "1" },
1213
+ h(
1214
+ "div",
1215
+ { style: { display: "flex", gap: 8, alignItems: "baseline", marginBottom: 8 } },
1216
+ h("h3", { style: { fontSize: 14, margin: 0 } }, text(t, "trash.title")),
1217
+ h("span", { className: "cf-grow" }),
1218
+ h(
1219
+ "button",
1220
+ { className: "cf-btn", "data-casefile-trash-back": "1", onClick: closeTrash },
1221
+ text(t, "trash.back"),
1222
+ ),
1223
+ ),
1224
+ (trash || []).length === 0
1225
+ ? h(
1226
+ "div",
1227
+ { className: "cf-empty", "data-casefile-trash-empty": "1" },
1228
+ text(t, "trash.empty"),
1229
+ )
1230
+ : h(
1231
+ "div",
1232
+ null,
1233
+ (trash || []).map((/** @type {any} */ entry) =>
1234
+ h(
1235
+ "div",
1236
+ {
1237
+ key: entry.name,
1238
+ className: "cf-card",
1239
+ "data-casefile-trash-row": entry.name,
1240
+ },
1241
+ h(
1242
+ "div",
1243
+ { className: "cf-row-text" },
1244
+ h("div", { className: "cf-card-title" }, entry.title || entry.projectId),
1245
+ h(
1246
+ "div",
1247
+ { className: "cf-row-meta" },
1248
+ text(t, "trash.meta", {
1249
+ id: entry.projectId,
1250
+ files: entry.files,
1251
+ bytes: formatBytes(entry.bytes),
1252
+ }),
1253
+ ),
1254
+ ),
1255
+ h(
1256
+ "button",
1257
+ {
1258
+ className: "cf-btn",
1259
+ "data-casefile-trash-restore": entry.name,
1260
+ disabled: trashBusy,
1261
+ onClick: () => {
1262
+ restoreEntry(entry.name);
1263
+ },
1264
+ },
1265
+ text(t, "trash.restore"),
1266
+ ),
1267
+ ),
1268
+ ),
1269
+ purgePreview
1270
+ ? h(
1271
+ "div",
1272
+ { className: "cf-card", "data-casefile-trash-purge-preview": "1" },
1273
+ h(
1274
+ "div",
1275
+ null,
1276
+ text(t, "trash.purgePreview", {
1277
+ count: purgePreview.count ?? 0,
1278
+ bytes: formatBytes(purgePreview.bytes),
1279
+ skipped: purgePreview.skipped ?? 0,
1280
+ }),
1281
+ ),
1282
+ h(
1283
+ "button",
1284
+ {
1285
+ className: "cf-btn cf-btn-primary",
1286
+ "data-casefile-trash-purge-confirm": "1",
1287
+ disabled: trashBusy,
1288
+ onClick: confirmPurge,
1289
+ },
1290
+ text(t, "trash.purgeConfirm"),
1291
+ ),
1292
+ h(
1293
+ "button",
1294
+ {
1295
+ className: "cf-btn",
1296
+ disabled: trashBusy,
1297
+ onClick: () => {
1298
+ setPurgePreview(null);
1299
+ },
1300
+ },
1301
+ text(t, "trash.cancel"),
1302
+ ),
1303
+ )
1304
+ : h(
1305
+ "button",
1306
+ {
1307
+ className: "cf-btn",
1308
+ "data-casefile-trash-purge": "1",
1309
+ disabled: trashBusy,
1310
+ onClick: previewPurge,
1311
+ },
1312
+ text(t, "trash.purge"),
1313
+ ),
1314
+ ),
1315
+ ),
1316
+ );
1317
+ } else if (detail) {
774
1318
  stats = detail.stats || {};
775
1319
  claims = detail.claims || [];
776
1320
  evidence = detail.evidence || [];
@@ -797,21 +1341,23 @@ window.__ModuleLoader__.load({
797
1341
  ),
798
1342
  h("h3", { style: { fontSize: 13, margin: "12px 0 8px" } }, text(t, "claims.title")),
799
1343
  claims.length === 0
800
- ? h(
801
- "div",
802
- { className: "cf-empty", "data-casefile-empty": "claims" },
803
- text(t, "claims.empty"),
804
- )
1344
+ ? h(EmptyHint, {
1345
+ t: t,
1346
+ kind: "claims",
1347
+ human: text(t, "claims.empty"),
1348
+ hint: text(t, "claims.emptyHint"),
1349
+ })
805
1350
  : claims.map((/** @type {any} */ claim) =>
806
1351
  h(ClaimCard, { key: claim.id, t: t, claim: claim }),
807
1352
  ),
808
1353
  h("h3", { style: { fontSize: 13, margin: "16px 0 8px" } }, text(t, "evidence.title")),
809
1354
  evidence.length === 0
810
- ? h(
811
- "div",
812
- { className: "cf-empty", "data-casefile-empty": "evidence" },
813
- text(t, "evidence.empty"),
814
- )
1355
+ ? h(EmptyHint, {
1356
+ t: t,
1357
+ kind: "evidence",
1358
+ human: text(t, "evidence.empty"),
1359
+ hint: text(t, "evidence.emptyHint"),
1360
+ })
815
1361
  : evidence.map((/** @type {any} */ item) =>
816
1362
  h(EvidenceCard, { key: item.id, t: t, item: item }),
817
1363
  ),
@@ -831,11 +1377,12 @@ window.__ModuleLoader__.load({
831
1377
  ),
832
1378
  h("h3", { style: { fontSize: 13, margin: "12px 0 8px" } }, text(t, "obligation.title")),
833
1379
  obligations.length === 0
834
- ? h(
835
- "div",
836
- { className: "cf-empty", "data-casefile-empty": "obligations" },
837
- text(t, "obligation.empty"),
838
- )
1380
+ ? h(EmptyHint, {
1381
+ t: t,
1382
+ kind: "obligations",
1383
+ human: text(t, "obligation.empty"),
1384
+ hint: text(t, "obligation.emptyHint"),
1385
+ })
839
1386
  : obligations.map((/** @type {any} */ item) =>
840
1387
  h(ObligationCard, {
841
1388
  key: item.id,
@@ -865,19 +1412,20 @@ window.__ModuleLoader__.load({
865
1412
  content = h(
866
1413
  "div",
867
1414
  null,
868
- h(
869
- "div",
870
- { className: "cf-muted", style: { marginBottom: 8 } },
871
- builds.length === 0
872
- ? text(t, "run.empty")
873
- : `${text(t, "run.builds")} · ${builds.length}`,
874
- ),
875
1415
  builds.length === 0
876
- ? h(
1416
+ ? null
1417
+ : h(
877
1418
  "div",
878
- { className: "cf-empty", "data-casefile-empty": "runs" },
879
- text(t, "run.empty"),
880
- )
1419
+ { className: "cf-muted", style: { marginBottom: 8 } },
1420
+ `${text(t, "run.builds")} · ${builds.length}`,
1421
+ ),
1422
+ builds.length === 0
1423
+ ? h(EmptyHint, {
1424
+ t: t,
1425
+ kind: "runs",
1426
+ human: text(t, "run.empty"),
1427
+ hint: text(t, "run.emptyHint"),
1428
+ })
881
1429
  : builds
882
1430
  .slice()
883
1431
  .sort(
@@ -908,7 +1456,7 @@ window.__ModuleLoader__.load({
908
1456
  ? "err"
909
1457
  : "warn",
910
1458
  },
911
- build.status,
1459
+ vocab(t, "checkStatus", build.status),
912
1460
  ),
913
1461
  h("span", null, text(t, "run.round", { round: build.round })),
914
1462
  build.implementationDigest
@@ -956,7 +1504,7 @@ window.__ModuleLoader__.load({
956
1504
  ? "err"
957
1505
  : "warn",
958
1506
  },
959
- check.verdict,
1507
+ vocab(t, "checkStatus", check.verdict),
960
1508
  ),
961
1509
  h(
962
1510
  "span",
@@ -1006,9 +1554,13 @@ window.__ModuleLoader__.load({
1006
1554
  "div",
1007
1555
  { style: { display: "flex", gap: 8, alignItems: "baseline", marginBottom: 4 } },
1008
1556
  h("h3", { style: { fontSize: 14, margin: 0 } }, detail.project.title),
1009
- h(Tag, { t: t }, detail.project.target ? detail.project.target.kind : "other"),
1557
+ h(
1558
+ Tag,
1559
+ { t: t },
1560
+ vocab(t, "kind", detail.project.target ? detail.project.target.kind : "other"),
1561
+ ),
1010
1562
  h(Tag, { t: t, tone: "warn" }, text(t, `auth.${detail.project.authTier}`)),
1011
- h(Tag, { t: t }, detail.project.scope === "selected" ? "selected" : "all"),
1563
+ h(Tag, { t: t }, vocab(t, "scope", detail.project.scope)),
1012
1564
  ),
1013
1565
  h(
1014
1566
  "div",
@@ -1038,6 +1590,89 @@ window.__ModuleLoader__.load({
1038
1590
  ),
1039
1591
  ),
1040
1592
  content,
1593
+ h(
1594
+ "details",
1595
+ {
1596
+ className: "cf-danger",
1597
+ "data-casefile-danger": "1",
1598
+ onToggle: (/** @type {any} */ event) => {
1599
+ // 展开时把焦点送到主按钮(§7.4.2);收起不抢焦点。
1600
+ if (event?.currentTarget?.open !== true) return;
1601
+ if (typeof dropEntryRef.current?.focus === "function") {
1602
+ dropEntryRef.current.focus();
1603
+ }
1604
+ },
1605
+ },
1606
+ h("summary", null, text(t, "danger.title")),
1607
+ h(
1608
+ "p",
1609
+ { className: "cf-muted", style: { fontSize: 11, margin: "8px 0 0" } },
1610
+ text(t, "danger.dropHint"),
1611
+ ),
1612
+ dropPreview
1613
+ ? h(
1614
+ "div",
1615
+ {
1616
+ className: "cf-card",
1617
+ "data-casefile-drop-preview": "1",
1618
+ // 影响面是安全信息:出现即播报(以前没有任何 live region,屏读用户听不到)。
1619
+ role: "alert",
1620
+ "aria-live": "polite",
1621
+ style: { marginTop: 8 },
1622
+ },
1623
+ h(
1624
+ "div",
1625
+ null,
1626
+ text(t, "danger.dropPreview", {
1627
+ id: detail.project.id,
1628
+ files: dropPreview.files ?? 0,
1629
+ bytes: formatBytes(dropPreview.bytes),
1630
+ }),
1631
+ ),
1632
+ h(
1633
+ "div",
1634
+ { className: "cf-danger-row" },
1635
+ h(
1636
+ "button",
1637
+ {
1638
+ className: "cf-btn cf-btn-primary",
1639
+ "data-casefile-drop-confirm": "1",
1640
+ disabled: dropBusy,
1641
+ onClick: confirmDrop,
1642
+ },
1643
+ dropBusy ? text(t, "danger.dropBusy") : text(t, "danger.dropConfirm"),
1644
+ ),
1645
+ h(
1646
+ "button",
1647
+ {
1648
+ className: "cf-btn",
1649
+ "data-casefile-drop-cancel": "1",
1650
+ ref: dropCancelRef,
1651
+ disabled: dropBusy,
1652
+ onClick: () => {
1653
+ setDropPreview(null);
1654
+ },
1655
+ },
1656
+ text(t, "danger.dropCancel"),
1657
+ ),
1658
+ ),
1659
+ )
1660
+ : h(
1661
+ "div",
1662
+ { className: "cf-danger-row" },
1663
+ h(
1664
+ "button",
1665
+ {
1666
+ className: "cf-btn",
1667
+ "data-casefile-drop": "1",
1668
+ ref: dropEntryRef,
1669
+ disabled: dropBusy,
1670
+ onClick: previewDrop,
1671
+ },
1672
+ text(t, "danger.drop"),
1673
+ ),
1674
+ ),
1675
+ ),
1041
1676
  ),
1042
1677
  );
1043
1678
  } else {
@@ -1068,11 +1703,7 @@ window.__ModuleLoader__.load({
1068
1703
  )
1069
1704
  : null,
1070
1705
  projects.length === 0
1071
- ? h(
1072
- "div",
1073
- { className: "cf-empty", "data-casefile-empty": "projects" },
1074
- text(t, "panel.empty"),
1075
- )
1706
+ ? h(ProjectEmptyGuide, { t: t })
1076
1707
  : h(
1077
1708
  "div",
1078
1709
  null,
@@ -1107,7 +1738,7 @@ window.__ModuleLoader__.load({
1107
1738
  {
1108
1739
  className: "cf-muted",
1109
1740
  "data-casefile-autonomy": detail?.autonomy?.level || "L2",
1110
- title: text(t, "autonomy.hint"),
1741
+ title: `${text(t, "autonomy.hint")}\n${text(t, "autonomy.scale")}`,
1111
1742
  style: { marginRight: 8 },
1112
1743
  },
1113
1744
  `${text(t, "autonomy.label")} ${detail?.autonomy?.level || "L2"}`,
@@ -1122,6 +1753,16 @@ window.__ModuleLoader__.load({
1122
1753
  },
1123
1754
  text(t, "panel.refresh"),
1124
1755
  ),
1756
+ h(
1757
+ "button",
1758
+ {
1759
+ className: "cf-btn",
1760
+ "data-casefile-trash-toggle": "1",
1761
+ "data-active": showTrash ? "true" : "false",
1762
+ onClick: showTrash ? closeTrash : openTrash,
1763
+ },
1764
+ text(t, "trash.toggle"),
1765
+ ),
1125
1766
  h(
1126
1767
  "button",
1127
1768
  {
@@ -1138,54 +1779,103 @@ window.__ModuleLoader__.load({
1138
1779
  ? h(
1139
1780
  "div",
1140
1781
  { className: "cf-form", "data-casefile-create": "1" },
1141
- h("input", {
1142
- className: "cf-input",
1143
- placeholder: text(t, "panel.createTitle"),
1144
- value: title,
1145
- onInput: (/** @type {any} */ event) => {
1146
- setTitle(event.target.value);
1147
- },
1148
- }),
1149
- h("input", {
1150
- className: "cf-input",
1151
- placeholder: text(t, "panel.createTarget"),
1152
- value: target,
1153
- onInput: (/** @type {any} */ event) => {
1154
- setTarget(event.target.value);
1155
- },
1156
- }),
1157
1782
  h(
1158
- "select",
1159
- {
1160
- className: "cf-select",
1161
- value: kind,
1162
- onChange: (/** @type {any} */ event) => {
1163
- setKind(event.target.value);
1783
+ "label",
1784
+ { className: "cf-field", "data-casefile-field": "title" },
1785
+ h("span", { className: "cf-field-label" }, text(t, "panel.createTitleLabel")),
1786
+ h("input", {
1787
+ className: "cf-input",
1788
+ "data-casefile-field-input": "title",
1789
+ "data-invalid": titleInvalid ? "true" : "false",
1790
+ "aria-label": text(t, "panel.createTitle"),
1791
+ "aria-required": "true",
1792
+ required: true,
1793
+ disabled: busy,
1794
+ placeholder: text(t, "panel.titlePlaceholder"),
1795
+ value: title,
1796
+ onInput: (/** @type {any} */ event) => {
1797
+ setTitle(event.target.value);
1164
1798
  },
1165
- },
1166
- ["binary", "web", "app", "game", "artifact", "other"].map((item) =>
1167
- h("option", { key: item, value: item }, item),
1799
+ onBlur: () => {
1800
+ setTitleTouched(true);
1801
+ },
1802
+ }),
1803
+ ),
1804
+ h(
1805
+ "label",
1806
+ { className: "cf-field", "data-casefile-field": "target" },
1807
+ h("span", { className: "cf-field-label" }, text(t, "panel.createTarget")),
1808
+ h("input", {
1809
+ className: "cf-input",
1810
+ "data-casefile-field-input": "target",
1811
+ "aria-label": text(t, "panel.createTarget"),
1812
+ disabled: busy,
1813
+ placeholder: text(t, "panel.targetPlaceholder"),
1814
+ value: target,
1815
+ onInput: (/** @type {any} */ event) => {
1816
+ setTarget(event.target.value);
1817
+ },
1818
+ }),
1819
+ ),
1820
+ h(
1821
+ "label",
1822
+ { className: "cf-field", "data-casefile-field": "kind" },
1823
+ h("span", { className: "cf-field-label" }, text(t, "panel.createKind")),
1824
+ h(
1825
+ "select",
1826
+ {
1827
+ className: "cf-select",
1828
+ "data-casefile-field-input": "kind",
1829
+ "aria-label": text(t, "panel.createKind"),
1830
+ disabled: busy,
1831
+ value: kind,
1832
+ onChange: (/** @type {any} */ event) => {
1833
+ setKind(event.target.value);
1834
+ },
1835
+ },
1836
+ ["binary", "web", "app", "game", "artifact", "other"].map((item) =>
1837
+ h("option", { key: item, value: item }, vocab(t, "kind", item)),
1838
+ ),
1168
1839
  ),
1169
1840
  ),
1170
1841
  h(
1171
- "select",
1172
- {
1173
- className: "cf-select",
1174
- value: auth,
1175
- onChange: (/** @type {any} */ event) => {
1176
- setAuth(event.target.value);
1842
+ "label",
1843
+ { className: "cf-field", "data-casefile-field": "auth" },
1844
+ h("span", { className: "cf-field-label" }, text(t, "panel.createAuth")),
1845
+ h(
1846
+ "select",
1847
+ {
1848
+ className: "cf-select",
1849
+ "data-casefile-field-input": "auth",
1850
+ "aria-label": text(t, "panel.createAuth"),
1851
+ disabled: busy,
1852
+ value: auth,
1853
+ onChange: (/** @type {any} */ event) => {
1854
+ setAuth(event.target.value);
1855
+ },
1177
1856
  },
1178
- },
1179
- ["owned", "authorized", "research"].map((item) =>
1180
- h("option", { key: item, value: item }, text(t, `auth.${item}`)),
1857
+ ["owned", "authorized", "research"].map((item) =>
1858
+ h("option", { key: item, value: item }, text(t, `authOption.${item}`)),
1859
+ ),
1181
1860
  ),
1182
1861
  ),
1862
+ formError !== "" || titleInvalid
1863
+ ? h(
1864
+ "div",
1865
+ {
1866
+ className: "cf-form-error",
1867
+ role: "alert",
1868
+ "data-casefile-create-error": "1",
1869
+ },
1870
+ formError !== "" ? formError : text(t, "panel.titleRequired"),
1871
+ )
1872
+ : null,
1183
1873
  h(
1184
1874
  "button",
1185
1875
  {
1186
1876
  className: "cf-btn cf-btn-primary",
1187
1877
  "data-casefile-submit": "1",
1188
- disabled: busy || title.trim() === "",
1878
+ disabled: busy,
1189
1879
  onClick: create,
1190
1880
  },
1191
1881
  busy ? text(t, "panel.creating") : text(t, "panel.create"),
@@ -1194,6 +1884,8 @@ window.__ModuleLoader__.load({
1194
1884
  "button",
1195
1885
  {
1196
1886
  className: "cf-btn",
1887
+ "data-casefile-cancel": "1",
1888
+ disabled: busy,
1197
1889
  onClick: () => {
1198
1890
  setShowForm(false);
1199
1891
  },
@@ -1295,14 +1987,35 @@ window.__ModuleLoader__.load({
1295
1987
  ),
1296
1988
  h(
1297
1989
  "div",
1298
- { className: "cf-kv" },
1299
- h("b", null, text(t, "settings.rea")),
1990
+ {
1991
+ className: "cf-info",
1992
+ "data-casefile-rea-notice": "1",
1993
+ "data-state": grade.ok ? "connected" : "unavailable",
1994
+ },
1300
1995
  h(
1301
- "span",
1302
- { "data-casefile-rea": grade.level || "unknown" },
1996
+ "div",
1997
+ { className: "cf-info-title" },
1998
+ `${text(t, "settings.rea")} · `,
1999
+ h(
2000
+ "span",
2001
+ {
2002
+ "data-casefile-rea": grade.level || "unknown",
2003
+ "data-state": grade.ok ? "connected" : "unavailable",
2004
+ },
2005
+ grade.ok
2006
+ ? text(t, "settings.reaOk", { count: rea.availableTools || 0 })
2007
+ : text(t, "settings.reaMissing"),
2008
+ ),
2009
+ ),
2010
+ grade.ok
2011
+ ? null
2012
+ : h("div", { style: { marginTop: 2 } }, text(t, "settings.reaMissingHint")),
2013
+ h(
2014
+ AdvancedHint,
2015
+ { t: t },
1303
2016
  grade.ok
1304
- ? text(t, "settings.reaOk", { count: rea.availableTools || 0 })
1305
- : text(t, "settings.reaMissing"),
2017
+ ? text(t, "settings.reaDetailOk", { count: rea.availableTools || 0 })
2018
+ : text(t, "settings.reaDetailMissing"),
1306
2019
  ),
1307
2020
  ),
1308
2021
  h(
@@ -1356,7 +2069,7 @@ window.__ModuleLoader__.load({
1356
2069
  {
1357
2070
  name: "settings.section",
1358
2071
  id: PANEL_ID,
1359
- order: 94,
2072
+ order: 96,
1360
2073
  label: () => text(t, "settings.section"),
1361
2074
  locale: NS,
1362
2075
  inject: () => ({ api: api, t: t }),