Repository navigation
Expand file tree
/
Copy pathclient.js
More file actions
2523 lines (2463 loc) · 169 KB
/
Copy pathclient.js
File metadata and controls
2523 lines (2463 loc) · 169 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// dsh-codewiki — 客户端半侧(浏览器)v0.4.1
// 两个挂载点:
// 1. 「插件」页 `plugins.item`(id = codewiki,与 profile patch 条目一致)——设置表单;
// 2. 侧边栏面板 `main` + `sidebar.panellist`(参照 dsh-hindsight-on-demand)——编译任务进度与取消,
// 数据来自宿主半侧 webServer 端点 GET /api/codewiki/jobs、POST /api/codewiki/control(仅回环)。
// 设置读写经 configForms(宿主半侧 Config 服务命名空间 'codewiki');
// id 必须等于 package.json 的 name(client-modules 按 nearestPackage 的 name 校验注册者);
// 词典值必须是字符串——词典值若为函数,t() 会回退返回键名。
window.__ModuleLoader__.load({
id: '@ikliml666/dsh-codewiki',
factory(require) {
const React = require('react')
const primitives = require('@deepseek-ai/dsh-client-ui-primitives')
const { Switch, Button, Input, Tag, MarkdownText, SegmentedTabs } = primitives
const NS = 'codewiki' // profile patch 条目 id = 设置命名空间
const KEY = 'codewiki' // 面板 key;sidebar.panellist 的 id 必须与它一致
const JOBS_PATH = '/api/codewiki/jobs'
const CONTROL_PATH = '/api/codewiki/control'
const PANEL_ORDER = 52 // 排在 dsh-hindsight-on-demand(50)之后
const POLL_MS = 2000
const REPOS_PATH = '/api/codewiki/repos'
const MODELS_PATH = '/api/codewiki/models'
const EFFORTS_PATH = '/api/codewiki/model-efforts'
// 目录未声明 efforts 的模型(如 trae/mimo-v2.6-flash)在设置页展示的通用思考档位;
// 选了模型不支持的值由 llmChat 兜底剥档重试,不会失败
const GENERIC_EFFORTS = ['off', 'low', 'medium', 'high', 'xhigh', 'max']
const REPOS_POLL_MS = 10000
// queued 单列在最前:单项目串行时后提交的项目在此等待,阶段条第 0 个点亮表示排队。
// 后面五步就是编译真实发生的事,一步不多:准备(探测环境+解析代码图+聚类)→ 写作 →
// 校验 → 索引 → 提交。
// 「校对」不再单列一步:它是质量门死链检查的修复动作(检测→改正文→复检),与质量门
// 本身是一件事的两半,分两格只会让人以为有两道重复检查。细分名称仍在活动流里可见
// (NATIVE_STAGE_KEYS.proofread)。
const ACTIVE_STAGES = ['queued', 'prepare', 'articles', 'validate', 'index', 'commit']
// 「准备」一格实际是三件事,耗时还极不均衡:探测环境(秒级)、解析代码图
// (真机 3-4 分钟)、模块聚类(全量轮十几分钟)。压成一格时用户只能看到
// 0% 冻住,分不清是在解析还是卡死了。这三段只在 prepare 期间展开显示,
// 段宽来自 nativeStageTimings(引擎自己报的真实阶段耗时);老任务没有这份
// 数据就退回原来的一格,不编造比例。
const PREPARE_STAGES = ['env', 'graph', 'cluster']
const PREPARE_WEIGHT = { env: 0.08, graph: 0.62, cluster: 0.30 }
// 引擎自报 percent 是「整轮」百分比,而 prepare 覆盖 FSoft 阶段 1+2,所以
// 这三段的读数区间并不相同:env 帧直接报自身 0-100;graph 是
// percent_of(1, p) = 0..36;cluster 是 percent_of(2, p) = 36..54。
// 界值来自 lib/engine/python/stage_map.py 的
// FSOFT_STAGE_WEIGHTS={1:0.40, 2:0.20} × FSOFT_PROGRESS_CEILING=90。
// 不归一化的话,graph 跑完只显示 36%,看上去永远没跑完。
const ENGINE_PCT = { env: [0, 100], graph: [0, 36], cluster: [36, 54] }
const withinRange = (stage, pct) => {
const r = ENGINE_PCT[stage]
if (!r || !Number.isFinite(pct)) return 0
const span = r[1] - r[0] || 1
return Math.max(0, Math.min(1, (pct - r[0]) / span))
}
// 每个阶段一个固定色相,用来在同一条进度条里区分「时间花在哪一步」。
// 色相挑的是彼此相距 40° 上下、且在中低饱和下仍能分辨的几支:青→蓝→紫→琥珀→绿。
// 明度与饱和度写在 CSS(58% / 52%),两套主题下都不用改。
const STAGE_HUE = { queued: 210, prepare: 196, articles: 262, validate: 32, index: 152, commit: 220 }
// 已落盘的历史任务里可能还留着别的阶段名:不映射的话 indexOf 得 -1,步骤条在
// 失败/取消时会整条熄灭、不标红,用户看不出卡在哪一步。
const LEGACY_STAGE = { plan: 'prepare', crosscut: 'articles', review: 'validate' }
const stageOf = (job) => LEGACY_STAGE[job?.stage] ?? job?.stage
const zh = () => ({
title: 'CodeWiki',
summary: '随仓库的代码 wiki(<repo>/.codewiki/):全批量流水线编译(零子代理),侧边栏面板可看进度。',
intro: '维护各仓库 .codewiki/ 目录下的活 wiki(随仓库提交共享)。此处设置经 configForms 热生效,无需重启。',
secRun: '运行',
enabled: '启用插件',
enabledHint: '停用后 cw 与 codewiki_generate 直接报错。',
updateReminder: 'wiki 维护提醒',
updateReminderHint: '改完代码后提醒更新 wiki(仓库根需有 CodeWiki.md)。',
autoCommit: '自动提交编译产物',
autoCommitHint: '由插件在主题分支提交并合并回原分支,只动 .codewiki/ 与 CodeWiki.md。',
workspaceOnly: '只显示工作区任务',
workspaceOnlyHint: '任务页只显示已添加工作区里的任务。',
techdocs: '导出 TechDocs 站点',
techdocsHint: '每轮额外导出 Backstage TechDocs 站点到 .codewiki/_techdocs/(约 37 个文件,不进 cw 索引)。',
maxConcurrency: '默认档并发上限',
maxConcurrencyHint: '默认档请求并发 1–8。',
moduleConcurrency: '模块生成并行度',
moduleConcurrencyHint: '同层模块并行写文档;留空或 0 跟随默认档,1 = 严格串行。',
serialProjects: '单项目串行',
serialProjectsHint: '开启时只推进一个仓库;关闭后按并行上限推进。',
parallelProjects: '并行项目上限',
parallelProjectsHint: '同时推进的仓库数;需关闭单项目串行。',
queueWaitLabel: '排队',
runTimeLabel: '执行',
queueAheadLabel: '在等',
// 会话分组:与 DSH 的会话概念对齐,一个会话发起的编译放一起。
// 阶段分组(1.3.0):请求按「仓库 → 编译阶段 → 请求」三层排,组头要能一眼看出这一步在做什么、
// 跑完了几条、有没有失败。历史记录没有阶段字段,单独归一组并说明原因,不假装它属于某一步。
// 循环分组:同一轮 agentic 工作里会有几十上百次工具往返,面板把它们平铺时
// 看起来像「几十次独立失败」。按「输入上下文回落」切成循环,让「1 个循环 100 轮」
// 与「100 次请求」在视觉上分得开。
// 详情页签:默认落在「输出」上——prompt 是给模型的指令,人点开多半是想看模型答了什么。
// token 数两套说法:实测来自上游 usage(账单口径),估算按 prompt 字符折算。
// 分开显示是为了让人知道哪个数能拿去对账。
// 行内提示:没输出时直接说清是哪种情况,别让人点开才发现是空的。
// 进行时与完成时必须是两套说法:`✓ done` 的行挂「思考中」读起来像还在跑或卡住了,
// 而 agentic 写作本来就是把整轮推理写在 reasoning 里、正文由工具调用落盘。
secCompile: '编译模型',
secCompileHint: '写文章与校对共用这一个模型,全部在插件内完成。',
requestLimit: '单模块请求上限',
requestLimitHint: '单个模块写作的 LLM 请求上限(1–1000)。写不完时引擎会续发补写提醒,每次提醒各吃一份预算;大模块撞上限会让整轮从完成掉成部分完成。',
emptyStreakLimit: '空产出熔断',
emptyStreakLimitHint: '连续这么多次「上游返回 200 却没有任何正文/工具调用」就停发,不再把额度烧在注定失败的调用上;已写文章照常落盘。0 = 关闭。',
historyCompactionKeep: '历史压缩',
historyCompactionKeepHint: '保留最近几次「整篇文件读」的完整内容,更早的替换成带行数的占位符(模型需要时用 view_range 回查)。实测单次增量编译 65.7% 的输入 token 是重复重发的已读文件内容,默认 3 约省 37%。行段读与开头两轮任务定义永不裁剪。-1 = 关闭。',
batchProvider: '模型提供商',
batchProviderHint: '模型设置里已注册的提供商;凭证由宿主按它解析。',
batchProviderMissing: '目录不可用,请手填 provider id',
batchModel: '编译模型',
batchModelHint: '该提供商下的模型 id,目录外的可手填。',
batchModelManual: '手填模型 id…',
catalogLoading: '正在读取模型目录…',
catalogUnavailable: '模型目录不可用({error})——可手填提供商与模型 id。',
catalogEmptyModels: '该提供商没有可枚举的模型,请手填模型 id。',
batchReasoningEffort: '思考程度',
batchReasoningEffortHint: '取自模型目录声明的档位;留空用模型默认。',
batchReasoningEffortModel: '模型默认',
batchReasoningEffortLoading: '正在读取该模型的思考档位…',
batchReasoningEffortNone: '该模型未声明可选思考档位,只能用默认档。',
batchReasoningEffortGeneric: '该模型目录未声明可选思考档位,以下为通用档位供手动指定;若模型不支持所选值,请求会自动回落模型默认档(不会失败)。',
batchReasoningEffortError: '读取思考档位失败({error})——先用模型默认档。',
effortByStage: '按环节设档位',
effortByStageHint: '给单个环节单独指定思考档位;留空的环节用上面的「思考程度」兜底。',
effortByStageFallback: '(用兜底档)',
effortByStageGraph: '依赖图 / 模块聚类',
effortByStageArticles: '文章写作',
effortByStageProofread: '语义校对',
effortByStageValidate: '质量门',
articleLanguage: '文章语言',
articleLanguageHint: '留空则跟随当前会话语言。',
binaryPath: 'cw 可执行路径',
binaryPathHint: '留空优先用 PATH 里的 cw,其次插件自带 bin/cw.exe。',
secScale: '并发与语言',
secNative: '原生引擎',
secNativeHint: '编译由上游 FSoft 引擎完成;关掉后不编译。',
nativeEngine: '使用原生引擎',
nativeEngineHint: '需要本机 Python 3.10+;环境不闭合会明确失败,不会悄悄换通道。',
nativeEnginePython: 'Python 解释器',
nativeEnginePythonHint: '留空依次用 DSH_CODEWIKI_PYTHON、PATH 里的 python。',
nativeEngineEntry: '引擎入口脚本',
nativeEngineEntryHint: '留空用插件自带的 entry.py。',
nativeEngineTimeoutMs: '单次编译超时(毫秒)',
nativeEngineTimeoutMsHint: '0 = 默认 180 分钟;超时按 partial 保留已写文章。',
secIncremental: '增量策略(原生通道)',
secIncrementalHint: '只在增量轮生效(scope=auto/stale 且已有编译基线)。留空一律用上游默认值,改错只会让增量更保守或更激进,不会写坏文章。',
updateRung: '增量档位',
updateRungDefault: '上游默认(3)',
updateRungHint: '留空 = 3(组件级增量,全部能力)。3b = 同 3 但依赖跟两跳,影响面更大;2 = 只重写受影响的叶子页、不原地打补丁;1 = 纯规则失效,不开路由/重聚类/依赖扩散/陈旧扫描(最保守也最慢);0 = 放弃组件级增量,每轮都按文件失效重写全部文章。',
updateTauNb: 'tau_nb',
updateTauNbHint: '0–1,路由判据:一个叶子里聚集多少比例的新增组件邻居才把改动路由过去。留空 = 0.5。',
updateTauGrow: 'tau_grow',
updateTauGrowHint: '0–1:新增组件占多少比例触发整体重聚类。留空 = 0.33。',
updateTauFull: 'tau_full',
updateTauFullHint: '0–1:活跃叶子占全部叶子超过此比例就整仓重写。留空 = 0.5;调大更倾向增量(快、可能漏改),调小更倾向重写(准、慢)。',
updateTauTree: 'tau_tree',
updateTauTreeHint: '0–1:新建+删除+重聚类的叶子占比超过此值就整仓重写。留空 = 0.3。',
updateTauDefault: '默认',
autoSaveIdle: '改动会自动保存',
autoSaving: '保存中…',
autoSaved: '已保存',
autoSaveFailed: '保存失败,稍后会重试',
autoSaveRetry: '立即重试',
autoSaveHint: '改动停手 0.5 秒后自动保存,无需手动提交。',
readonlyHint: '当前配置只读,改动不会落盘。',
overviewClean: '干净',
overviewStale: '有变更',
overviewPending: '待确认',
overviewBusy: '编译中',
overviewTotal: '仓库',
loadingLabel: '加载中…',
conflict: '保存冲突:设置已被他处修改,请重试。',
invalidConcurrency: '并发上限须为 1–8 的整数。',
invalidRequestLimit: '单模块请求上限须为 1–1000 的整数。',
invalidEmptyStreakLimit: '空产出熔断阈值须为 0–20 的整数(0 = 关闭)。',
invalidHistoryCompactionKeep: '历史压缩须为 -1 或 0–20 的整数(-1 = 关闭)。',
panelTitle: '编译任务',
panelEmpty: '暂无编译任务——在会话里运行 codewiki_generate 开始编译。',
stageQueued: '排队中',
stagePrepare: '准备中',
stageArticles: '写文章中',
stageReview: '校对中',
stageValidate: '校验中',
stageIndex: '建索引中',
stageCommit: '提交产物中',
stageDone: '已完成',
stagePartial: '部分完成',
stageFailed: '失败',
stageCancelled: '已取消',
// 原生引擎(阶段 4)八段契约的真实阶段名:面板阶段条仍是粗粒度六步,
// 引擎自报的阶段另显示一行——两者不是一回事,混着显示会让人以为步骤条错了。
nativeStageLabel: '引擎阶段',
channelNative: '原生引擎',
nativeEnv: '探测环境',
nativeGraph: '解析代码图',
nativeCluster: '聚类模块',
nativeValidate: '产物校验',
nativeProofread: '语义校对',
nativeBaseline: '推进基线',
gateLabel: '质量门',
applyLabel: '落地',
stepQueued: '排队',
kindFull: '全量',
kindStale: '增量',
kindResume: '续查',
writtenLabel: '已写',
failedLabel: '失败',
unitArticle: '篇',
cancelJob: '取消',
cancelRequestedLabel: '取消中…',
settings: '设置',
elapsedLabel: '已用时',
historyLabel: '历史任务',
changedLabel: '变更文件',
autoCommitOk: '产物已自动提交',
autoCommitNone: '产物无改动,未提交',
autoCommitPending: '产物未自动提交',
wikiAt: 'wiki:',
tabOverview: '总览',
tabTasks: '任务',
tabSettings: '设置',
reposEmpty: '还没有已编译的仓库——在会话里运行 codewiki_generate 开始编译。',
stateMissing: '未初始化',
stateUncompiled: '未编译',
stateClean: '最新',
stateStale: '有变更',
stateError: '出错',
excludedTag: '已排除',
excludeRepo: '排除',
unexcludeRepo: '取消排除',
autoTag: '自动',
schedTitle: '自动更新调度',
schedOn: '开',
schedOff: '关',
schedEvery: '扫描间隔',
schedLast: '上次扫描',
schedScanning: '正在扫描…',
schedNever: '从未',
schedMinutes: '分钟',
compileNow: '更新',
compileUpToDate: '已是最新',
batchLabel: '批次',
secSchedule: '调度与排除',
autoUpdateLabel: '自动更新',
autoUpdateHint: '定时扫描已编译过的仓库,检测到变更自动增量编译。',
autoUpdateMinLabel: '扫描间隔(分钟)',
autoUpdateMinHint: '最小 5 分钟;只提交有变更的仓库。',
excludePathsLabel: '排除清单',
excludePathsHint: '不编译的目录(含子目录);换行、分号或逗号分隔。',
stepPrepare: '准备',
stepArticles: '文章',
stepReview: '校对',
stepValidate: '校验',
stepIndex: '索引',
stepCommit: '提交',
perMin: '篇/分',
etaLabel: '剩余',
batchRunLabel: '执行中',
usageIn: '输入',
usageOut: '输出',
reqLabel: '请求',
batchChannel: '批量',
realtimeChannel: '实时',
overTierLabel: '个超单请求预算(按大档装填)',
activityLabel: '活动流',
taskListLabel: '逐篇',
legendHint: '每段一个颜色代表一个阶段,段宽是这一步在总进度里占多少;当前阶段加粗,失败段标红。',
legendHintDone: '每段一个颜色代表一个阶段,段宽是该阶段真实耗时——一眼看出时间花在哪一步。',
emptyReposTitle: '还没有可编译的仓库',
emptyTasksTitle: '还没有编译记录',
emptySessionsTitle: '还没有模型请求',
loadingTitle: '正在读取',
activityHint: '最新一条已在上方常显,这里展开的是更早的条目。',
legendState_done: '已完成',
legendState_running: '进行中',
legendState_failed: '失败',
legendState_todo: '未开始',
engineLogLabel: '引擎日志',
engineLogFileLabel: '完整日志',
lastCompile: '上次编译',
nextScan: '下次扫描',
scannedLabel: '扫描',
submittedLabel: '提交',
skippedLabel: '工作区外跳过',
pendingLabel: '待确认',
needConfirmTag: '待确认',
confirmCompile: '确认编译',
confirmHint: '这个仓库还没有 wiki。自动调度不会替你做这个决定——确认后才会开始首次编译;不想要就点排除,之后不再扫到它。',
totalTimeLabel: '总耗时',
copyPath: '复制路径',
copiedLabel: '已复制',
runningCount: '个进行中',
runningLabel: '进行中',
poolHint: '进行中任务的聚合进度',
poolSlowest: '最慢',
poolQueued: '排队',
poolAllQueued: '{n} 个排队中',
agoSuffix: '前',
})
const en = () => ({
title: 'CodeWiki',
summary: 'Repo-local code wiki (<repo>/.codewiki/): all-batch pipeline (zero subagents); track progress in the sidebar panel.',
intro: 'Maintains a living wiki inside each repository at .codewiki/ (committed and shared with the repo). Settings here apply hot via configForms — no restart needed.',
secRun: 'Runtime',
enabled: 'Enable plugin',
enabledHint: 'When off, cw and codewiki_generate error immediately.',
updateReminder: 'Wiki update reminder',
updateReminderHint: 'Reminds the session to update the wiki after code changes (only when the repo root has CodeWiki.md).',
autoCommit: 'Auto-commit compiled wiki',
autoCommitHint: 'The plugin commits the artifacts on a topic branch and merges them back, touching only .codewiki/ and CodeWiki.md. Falls back to an "artifacts pending" reminder when a branch workflow or the commit is impossible.',
workspaceOnly: 'Workspace tasks only',
workspaceOnlyHint: 'The jobs tab shows only tasks belonging to added dsh workspaces.',
techdocs: 'Export TechDocs site',
techdocsHint: 'Also exports a Backstage TechDocs site to .codewiki/_techdocs/ every run (about 37 files, kept out of the cw index).',
maxConcurrency: 'Default-tier concurrency',
maxConcurrencyHint: 'In-flight requests for the default tier (batchModel), 1–8.',
moduleConcurrency: 'Module parallelism',
moduleConcurrencyHint: 'Modules on the same layer write concurrently; parents still wait for every child. Empty or 0 follows the default-tier concurrency; 1 is strictly sequential.',
serialProjects: 'One project at a time',
serialProjectsHint: 'Only one repository compiles at a time; later submissions queue. Turn off to compile several repos in parallel.',
parallelProjects: 'Parallel repo limit',
parallelProjectsHint: 'How many repos compile simultaneously; effective when "One project at a time" is off.',
queueWaitLabel: 'queued',
runTimeLabel: 'running',
queueAheadLabel: 'waiting for',
secCompile: 'Compile model',
secCompileHint: 'Articles and proofreading share this model; all inside the plugin.',
requestLimit: 'Per-module request cap',
requestLimitHint: 'LLM request budget for one module (1–1000). Unfinished modules get continuation reminders, each with its own budget; hitting the cap turns a whole run from complete into partial.',
emptyStreakLimit: 'Empty-output breaker',
emptyStreakLimitHint: 'Stop sending once the upstream returns 200 with no text and no tool call this many times in a row, so budget is not burned on calls that cannot succeed; articles already written still land. 0 = off.',
historyCompactionKeep: 'History compaction',
historyCompactionKeepHint: 'Keep the last N whole-file reads intact and replace older ones with a placeholder naming the omitted line count (the model can re-read a range with view_range). Measured: 65.7% of input tokens in one incremental compile were re-sent file contents. Default 3 saves about 37%. Ranged reads and the first two task-definition turns are never compacted. -1 = off.',
batchProvider: 'Model provider',
batchProviderHint: 'A provider from model settings; the host resolves credentials.',
batchProviderMissing: 'Catalog unavailable — type the provider id',
batchModel: 'Compile model',
batchModelHint: 'Model id under it; catalog misses can be typed in.',
batchModelManual: 'Type a model id…',
catalogLoading: 'Reading the model catalog…',
catalogUnavailable: 'Model catalog unavailable ({error}) — type the provider and model id instead.',
catalogEmptyModels: 'This provider exposes no enumerable models; type the model id.',
batchReasoningEffort: 'Reasoning effort',
batchReasoningEffortHint: 'Declared in the model catalog. Empty = model default.',
batchReasoningEffortModel: 'Model default',
batchReasoningEffortLoading: 'Reading this model\'s reasoning efforts…',
batchReasoningEffortNone: 'This model declares no selectable efforts; only the default applies.',
batchReasoningEffortGeneric: 'The model catalog declares no efforts for this model; the generic levels below can be set manually. If the model rejects the chosen level, the request automatically falls back to the model default (it will not fail).',
batchReasoningEffortError: 'Could not read reasoning efforts ({error}) — keeping the model default.',
effortByStage: 'Per-stage effort',
effortByStageHint: 'Override the reasoning effort for individual stages; a blank stage falls back to the Reasoning effort above.',
effortByStageFallback: '(use fallback)',
effortByStageGraph: 'Dependency graph / clustering',
effortByStageArticles: 'Article writing',
effortByStageProofread: 'Semantic proofread',
effortByStageValidate: 'Quality gate',
articleLanguage: 'Article language',
articleLanguageHint: 'Empty follows the current session language.',
binaryPath: 'cw binary path',
binaryPathHint: 'Empty = cw on PATH first, bundled bin/cw.exe as fallback.',
secScale: 'Concurrency & language',
secNative: 'Native engine',
secNativeHint: 'Compilation is done by the upstream FSoft engine; off means no compilation.',
nativeEngine: 'Use the native engine',
nativeEngineHint: 'Needs local Python 3.10+ with a closed dependency environment; an unclosed environment fails as engine-deps instead of silently switching channels.',
nativeEnginePython: 'Python interpreter',
nativeEnginePythonHint: 'Empty tries DSH_CODEWIKI_PYTHON, then python on PATH.',
nativeEngineEntry: 'Engine entry script',
nativeEngineEntryHint: 'Empty uses the bundled lib/engine/python/entry.py.',
nativeEngineTimeoutMs: 'Per-run timeout (ms)',
nativeEngineTimeoutMsHint: '0 = the default 180 minutes; a timeout salvages written articles as partial.',
secIncremental: 'Incremental strategy (native channel)',
secIncrementalHint: 'Applies to incremental rounds only (scope=auto/stale with an existing baseline). Empty values use upstream defaults; getting them wrong only makes updates more conservative or more aggressive, it never corrupts articles.',
updateRung: 'Incremental rung',
updateRungDefault: 'Upstream default (3)',
updateRungHint: 'Empty = 3 (component-level update, all capabilities). 3b = rung 3 with 2 dependency hops; 2 = rewrite affected leaf pages only, no in-place patching; 1 = rule-based invalidation only, no routing/re-clustering/dependents/stale scan (most conservative, slowest); 0 = drop component-level update, rewrite every page by file invalidation each round.',
updateTauNb: 'tau_nb',
updateTauNbHint: '0-1, routing threshold: the share of new-component neighbours clustered in one leaf that routes the diff there. Empty = 0.5.',
updateTauGrow: 'tau_grow',
updateTauGrowHint: '0-1: share of new components that triggers re-clustering. Empty = 0.33.',
updateTauFull: 'tau_full',
updateTauFullHint: '0-1: rewrite the whole repo once active leaves exceed this share of all leaves. Empty = 0.5; higher favours incremental (faster, may miss edits), lower favours rewrite (accurate, slower).',
updateTauTree: 'tau_tree',
updateTauTreeHint: '0-1: rewrite the whole repo once created+deleted+re-clustered leaves exceed this share. Empty = 0.3.',
updateTauDefault: 'default',
autoSaveIdle: 'Changes save automatically',
autoSaving: 'Saving…',
autoSaved: 'Saved',
autoSaveFailed: 'Save failed, will retry',
autoSaveRetry: 'Retry now',
autoSaveHint: 'Changes save automatically 0.5s after you stop editing.',
readonlyHint: 'Configuration is read-only; changes will not be saved.',
overviewClean: 'Clean',
overviewStale: 'Changed',
overviewPending: 'Needs confirm',
overviewBusy: 'Compiling',
overviewTotal: 'Repos',
loadingLabel: 'Loading…',
conflict: 'Save conflict: settings changed elsewhere, please retry.',
invalidConcurrency: 'Concurrency cap must be an integer between 1 and 8.',
invalidRequestLimit: 'Per-module request cap must be an integer between 1 and 1000.',
invalidEmptyStreakLimit: 'Empty-output breaker must be an integer between 0 and 20 (0 = off).',
invalidHistoryCompactionKeep: 'History compaction must be -1 or an integer between 0 and 20 (-1 = off).',
panelTitle: 'Compilation jobs',
panelEmpty: 'No compilation jobs yet — run codewiki_generate in a session to start one.',
stageQueued: 'Queued',
stagePrepare: 'Preparing',
stageArticles: 'Writing articles',
stageReview: 'Proofreading',
stageValidate: 'Validating',
stageIndex: 'Indexing',
stageCommit: 'Committing',
stepQueued: 'Queue',
stageDone: 'Done',
stagePartial: 'Partial',
stageFailed: 'Failed',
stageCancelled: 'Cancelled',
nativeStageLabel: 'Engine stage',
channelNative: 'Native engine',
nativeEnv: 'Probing environment',
nativeGraph: 'Parsing code graph',
nativeCluster: 'Clustering modules',
nativeValidate: 'Validating output',
nativeProofread: 'Proofreading content',
nativeBaseline: 'Advancing baseline',
gateLabel: 'Quality gate',
applyLabel: 'Apply',
kindFull: 'Full',
kindStale: 'Stale',
kindResume: 'Resume',
writtenLabel: 'written',
failedLabel: 'failed',
unitArticle: 'articles',
cancelJob: 'Cancel',
cancelRequestedLabel: 'Cancelling…',
settings: 'Settings',
elapsedLabel: 'elapsed',
historyLabel: 'History',
changedLabel: 'changed files',
autoCommitOk: 'artifacts auto-committed',
autoCommitNone: 'no artifact changes, nothing committed',
autoCommitPending: 'artifacts not committed',
wikiAt: 'wiki: ',
tabOverview: 'Overview',
tabTasks: 'Jobs',
tabSettings: 'Settings',
reposEmpty: 'No compiled repos yet — run codewiki_generate in a session to start one.',
stateMissing: 'No wiki',
stateUncompiled: 'Uncompiled',
stateClean: 'Up to date',
stateStale: 'Changed',
stateError: 'Error',
excludedTag: 'Excluded',
excludeRepo: 'Exclude',
unexcludeRepo: 'Un-exclude',
autoTag: 'Auto',
schedTitle: 'Auto-update scheduler',
schedOn: 'On',
schedOff: 'Off',
schedEvery: 'Interval',
schedLast: 'Last scan',
schedScanning: 'Scanning…',
schedNever: 'never',
schedMinutes: 'min',
compileNow: 'Update',
compileUpToDate: 'Up to date',
batchLabel: 'Batch',
secSchedule: 'Scheduler & exclusions',
autoUpdateLabel: 'Auto update',
autoUpdateHint: 'Periodically scans compiled workspaces and submits incremental recompiles when changes are detected (scope=auto).',
autoUpdateMinLabel: 'Scan interval (minutes)',
autoUpdateMinHint: 'Minimum 5. Each scan runs cw status per historical workspace and submits only changed ones.',
excludePathsLabel: 'Excluded paths',
excludePathsHint: 'Directories (subtree included) never compiled; newline / semicolon / comma separated absolute paths.',
stepPrepare: 'Prep',
stepArticles: 'Write',
stepReview: 'Proof',
stepValidate: 'Check',
stepIndex: 'Index',
stepCommit: 'Commit',
perMin: 'articles/min',
etaLabel: 'remaining',
batchRunLabel: 'Running',
usageIn: 'in',
usageOut: 'out',
reqLabel: 'requests',
batchChannel: 'batch',
realtimeChannel: 'realtime',
overTierLabel: 'over the single-request budget (large tier)',
activityLabel: 'Activity',
taskListLabel: 'Per page',
legendHint: 'Each colour is one stage; segment width is how much of the total progress it accounts for.',
legendHintDone: 'Each colour is one stage; segment width is that stage real wall time — see at a glance where the time went.',
emptyReposTitle: 'No repos to compile yet',
emptyTasksTitle: 'Nothing compiled yet',
emptySessionsTitle: 'No model requests yet',
loadingTitle: 'Loading',
activityHint: 'The latest entry is already shown above; this expands the earlier ones.',
legendState_done: 'done',
legendState_running: 'running',
legendState_failed: 'failed',
legendState_todo: 'pending',
engineLogLabel: 'Engine log',
engineLogFileLabel: 'Full log',
lastCompile: 'last compile',
nextScan: 'Next scan',
scannedLabel: 'scanned',
submittedLabel: 'submitted',
skippedLabel: 'skipped (outside workspace)',
pendingLabel: 'awaiting confirmation',
needConfirmTag: 'needs OK',
confirmCompile: 'Compile',
confirmHint: 'This repo has no wiki yet. The scheduler will not decide that for you — the first compile starts only after you confirm. Not interested? Exclude it and it will no longer be scanned.',
totalTimeLabel: 'total',
copyPath: 'Copy path',
copiedLabel: 'Copied',
runningCount: 'running',
runningLabel: 'Running',
poolHint: 'Aggregate progress across running jobs',
poolSlowest: 'slowest',
poolQueued: 'queued',
poolAllQueued: '{n} queued',
agoSuffix: 'ago',
})
const style = document.createElement('style')
style.dataset.plugin = '@ikliml666/dsh-codewiki'
style.textContent = [
'[data-dscw-page] { display: flex; flex-direction: column; gap: 16px; max-width: 1280px; padding-bottom: 28px; color: var(--dsw-alias-label-primary); }',
// 分类卡片:五个分组各成一张卡,横向按可用宽度自动排 1–3 列。
// 原来是单列长表 + 132px 标签列,宽面板里右侧大半是空白;卡片化之后
// 同样的字段占更少的纵向高度,分组边界也从「一条细线」变成实物边界。
'[data-dscw-cards] { columns: 3; column-gap: 12px; }',
'[data-dscw-cards] > [data-dscw-sec] { break-inside: avoid; break-inside: avoid-column; margin: 0 0 12px; }',
// 窄面板退成两列 / 一列:多列布局在窄容器里会把卡片压到 300px 以下,
// 长 placeholder 与整数输入框都会开始截断。
'@media (max-width: 1020px) { [data-dscw-cards] { columns: 2; } }',
'@media (max-width: 660px) { [data-dscw-cards] { columns: 1; } }',
// 分组:一条标签 + 一行细线把它和下面的字段切开。之前五个分组之间只靠 24px 空白
// 分隔,滚动时看不出「哪几行属于同一件事」;细线比再加一个描边盒子轻得多。
'[data-dscw-sec] { display: flex; flex-direction: column; gap: 6px; padding: 11px 13px 13px; border: 0.5px solid var(--dsw-alias-border-l3); border-radius: 10px; background: var(--dsw-alias-bg-layer-1, transparent); box-sizing: border-box; }',
'[data-dscw-head] { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }',
'[data-dscw-head] h4 { margin: 0; font-size: 12.5px; font-weight: 600; line-height: 18px; letter-spacing: .01em; text-transform: none; }',
'[data-dscw-hint] { font-size: 11px; line-height: 15.5px; color: var(--dsw-alias-label-tertiary); text-wrap: pretty; }',
// 卡片内一列到底:标签一行、控件一行。卡片最窄 340px,再切 132px 标签列会把
// 输入框压到 200px 以下,长 placeholder 直接被截掉。
'[data-dscw-grid] { display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; }',
'[data-dscw-grid] > label { font-size: 12px; line-height: 16px; color: var(--dsw-alias-label-secondary); margin-top: 7px; }',
'[data-dscw-grid] > label:first-child { margin-top: 0; }',
// 按环节设档位:每个环节一行「名字 + 下拉」,名字定宽让四个下拉左边对齐。
'[data-dscw-stages] { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }',
'[data-dscw-stage] { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 8px; }',
'[data-dscw-stagelabel] { font-size: 12px; line-height: 16px; color: var(--dsw-alias-label-secondary); }',
// 开关类字段:控件只有一行高,再按「标签一行 + 控件一行 + 说明三行」堆,
// 卡片里就会连续出现一片只有右边有个小圆点的空白带。改成标签与开关同行。
'[data-dscw-toggle] { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 7px; min-width: 0; }',
'[data-dscw-toggle]:first-child { margin-top: 0; }',
'[data-dscw-toggle] > label { font-size: 12px; line-height: 16px; color: var(--dsw-alias-label-secondary); min-width: 0; }',
'[data-dscw-toggle] > * { flex: none; }',
'[data-dscw-field] { display: flex; flex-direction: column; gap: 3px; min-width: 0; }',
'[data-dscw-select] { width: 100%; font: inherit; font-size: 12px; line-height: 18px; padding: 6px 8px; border: 0.5px solid var(--dsw-alias-border-l2); border-radius: 6px; background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-primary); box-sizing: border-box; transition: border-color .14s ease; }',
'[data-dscw-select]:hover { border-color: color-mix(in srgb, var(--dsw-alias-brand-primary) 35%, var(--dsw-alias-border-l2)); }',
'[data-dscw-select]:focus-visible { outline: none; border-color: var(--dsw-alias-brand-primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--dsw-alias-brand-primary) 18%, transparent); }',
// 保存条钉在底部:设置页比一屏高,滚到一半想保存时不该再滚回去找按钮。
// 自动保存状态行:粘底但不抢注意力——它报的是「已经处理好了」,
// 所以用 tertiary 色的小字,只有出错/保存中才升级成色块 + 重试按钮。
'[data-dscw-bar] { position: sticky; bottom: -1px; display: flex; align-items: center; gap: 7px; padding: 7px 10px; margin-top: 2px; border-radius: 8px; border: 0.5px solid var(--dsw-alias-border-l3); background: color-mix(in srgb, var(--dsw-alias-bg-layer-1, #fff) 88%, transparent); backdrop-filter: blur(6px); font-size: 11.5px; line-height: 16px; }',
'[data-dscw-bar]::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--dsw-alias-border-l3); }',
'[data-dscw-bar][data-state="saving"]::before { background: var(--dsw-alias-brand-primary); animation: dscw-pulse 1.2s ease-in-out infinite; }',
'[data-dscw-bar][data-state="saved"]::before { background: var(--dsw-alias-state-success-primary, var(--dsw-alias-brand-primary)); }',
'[data-dscw-bar][data-state="error"]::before { background: var(--dsw-alias-state-error-primary, var(--dsw-alias-warn, #c33)); }',
'@media (prefers-reduced-motion: reduce) { [data-dscw-bar][data-state="saving"]::before { animation: none; } }',
'[data-dscw-savestate] { color: var(--dsw-alias-label-tertiary); }',
'[data-dscw-bar][data-state="saving"] [data-dscw-savestate] { color: var(--dsw-alias-label-secondary); }',
'[data-dscw-bar][data-state="saved"] [data-dscw-savestate] { color: var(--dsw-alias-state-success-primary, var(--dsw-alias-label-secondary)); }',
'[data-dscw-bar][data-state="error"] { border-color: color-mix(in srgb, var(--dsw-alias-state-error-primary, var(--dsw-alias-warn, #c33)) 45%, var(--dsw-alias-border-l3)); }',
'[data-dscw-bar][data-state="error"] [data-dscw-savestate] { color: var(--dsw-alias-state-error-primary, var(--dsw-alias-label-primary)); }',
'[data-dscw-notice] { font-size: 11.5px; line-height: 17px; color: var(--dsw-alias-label-secondary); }',
'[data-dscw-warn] { color: var(--dsw-alias-state-warning-primary, var(--dsw-alias-state-business-primary)); font-size: 11.5px; line-height: 17px; }',
// 侧边栏面板
// 侧边栏面板:一层是「进行中」的活卡(总百分比 + 分阶段百分比),一层是历史。
'[data-dscw-p-page] { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px 20px; font-size: 13px; color: var(--dsw-alias-label-primary); box-sizing: border-box; height: 100%; overflow-y: auto; }',
'[data-dscw-p-page] * { box-sizing: border-box; }',
'[data-dscw-p-head] { display: flex; align-items: center; justify-content: space-between; gap: 8px; }',
'[data-dscw-p-head] h3 { margin: 0; font-size: 14px; font-weight: 500; line-height: 22px; letter-spacing: -0.01em; }',
'[data-dscw-p-row] { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }',
'[data-dscw-p-actions] { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }',
'[data-dscw-p-stage] { font-size: 12px; line-height: 18px; color: var(--dsw-alias-state-business-primary, var(--dsw-alias-label-secondary)); }',
'[data-dscw-p-stage][data-state="done"] { color: var(--dsw-alias-state-success-primary, var(--dsw-alias-label-secondary)); }',
'[data-dscw-p-stage][data-state="failed"] { color: var(--dsw-alias-state-error-primary, var(--dsw-alias-label-secondary)); }',
'[data-dscw-p-stage][data-state="cancelled"] { color: var(--dsw-alias-state-warning-primary, var(--dsw-alias-label-secondary)); }',
'[data-dscw-p-stage][data-state="clean"] { color: var(--dsw-alias-state-success-primary, var(--dsw-alias-label-secondary)); }',
'[data-dscw-p-stage][data-state="stale"] { color: var(--dsw-alias-state-warning-primary, var(--dsw-alias-state-business-primary)); }',
'[data-dscw-p-stage][data-state="missing"], [data-dscw-p-stage][data-state="uncompiled"] { color: var(--dsw-alias-label-tertiary); }',
'[data-dscw-p-stage][data-running="true"] { animation: dscw-pulse 1.6s ease-in-out infinite; }',
'[data-dscw-p-meta] { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-secondary); word-break: break-all; }',
'[data-dscw-p-subline] { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; font-size: 11.5px; line-height: 17px; color: var(--dsw-alias-label-secondary); font-variant-numeric: tabular-nums; }',
'[data-dscw-p-subline] > [data-dscw-p-note] { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; color: var(--dsw-alias-label-tertiary); }',
'[data-dscw-p-cwd] { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; line-height: 16px; color: var(--dsw-alias-label-tertiary); font-variant-numeric: tabular-nums; }',
// 空状态:一句灰字看起来像「没加载出来」。给一个标题 + 一句为什么是空的,
// 读者才知道这是正常状态、不是坏了。
'[data-dscw-p-empty] { display: flex; flex-direction: column; gap: 3px; padding: 18px 4px; font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }',
'[data-dscw-p-empty] > strong { font-weight: 500; color: var(--dsw-alias-label-secondary); }',
// 加载态画骨架而不是一个「…」:读者能据此判断「马上会有什么」和「大概占多高」,
// 也不会在数据到达时整块跳一下。
'[data-dscw-p-skel] { display: flex; flex-direction: column; gap: 8px; padding: 6px 0; }',
'[data-dscw-p-skel] > i { display: block; height: 10px; border-radius: 4px; background: linear-gradient(90deg, color-mix(in srgb, var(--dsw-alias-border-l3) 70%, transparent) 0%, color-mix(in srgb, var(--dsw-alias-border-l3) 30%, transparent) 50%, color-mix(in srgb, var(--dsw-alias-border-l3) 70%, transparent) 100%); background-size: 200% 100%; animation: dscw-shimmer 1.4s linear infinite; }',
'[data-dscw-p-skel] > i[data-w="100"] { width: 100%; }',
'[data-dscw-p-skel] > i[data-w="72"] { width: 72%; }',
'[data-dscw-p-skel] > i[data-w="46"] { width: 46%; }',
'@keyframes dscw-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }',
'@media (prefers-reduced-motion: reduce) { [data-dscw-p-skel] > i { animation: none; } }',
'[data-dscw-p-history] { margin-top: 4px; }',
// 可折叠行统一一个 ▸ 指示器。原生 marker 在不同字号下行高对不齐;而且
// tasklist / repofold 设了 list-style: none 之后连三角都没了——读者无从判断
// 「这行能点开」。用 ::before 画一个尺寸一致的三角,展开时旋转 90 度。
'[data-dscw-p-history] > summary, [data-dscw-p-tasklist] > summary, [data-dscw-p-engine-log] > summary, [data-dscw-p-repofold] > summary { list-style: none; }',
'[data-dscw-p-history] > summary::-webkit-details-marker, [data-dscw-p-tasklist] > summary::-webkit-details-marker, [data-dscw-p-engine-log] > summary::-webkit-details-marker, [data-dscw-p-repofold] > summary::-webkit-details-marker { display: none; }',
'[data-dscw-p-history] > summary::before, [data-dscw-p-tasklist] > summary::before, [data-dscw-p-engine-log] > summary::before, [data-dscw-p-repofold] > summary::before { content: "\u25b8"; display: inline-block; margin-right: 6px; font-size: 8px; line-height: 1; color: var(--dsw-alias-label-tertiary); transition: transform .16s ease; }',
'[data-dscw-p-history][open] > summary::before, [data-dscw-p-tasklist][open] > summary::before, [data-dscw-p-engine-log][open] > summary::before, [data-dscw-p-repofold][open] > summary::before { transform: rotate(90deg); }',
'[data-dscw-p-history] > summary { cursor: pointer; user-select: none; font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-secondary); margin-bottom: 8px; }',
'[data-dscw-p-history] > summary:hover { color: var(--dsw-alias-label-primary); }',
// 任务卡:左侧一条状态色轨代替整圈描边,进行中只加一层极淡的品牌色底。
'[data-dscw-p-job] { position: relative; display: flex; flex-direction: column; gap: 7px; padding: 10px 12px 10px 16px; border-radius: 12px; border: 0.5px solid var(--dsw-alias-border-l3); background: var(--dsw-alias-bg-layer-1, transparent); transition: border-color .18s ease, background-color .18s ease; }',
'[data-dscw-p-job]::before { content: ""; position: absolute; left: 6px; top: 11px; bottom: 11px; width: 2px; border-radius: 2px; background: var(--dsw-alias-border-l2); }',
'[data-dscw-p-job][data-active="true"] { border-color: color-mix(in srgb, var(--dsw-alias-brand-primary) 36%, transparent); background: color-mix(in srgb, var(--dsw-alias-brand-primary) 5%, var(--dsw-alias-bg-layer-1, transparent)); }',
'[data-dscw-p-job][data-active="true"]::before { background: var(--dsw-alias-brand-primary); }',
'[data-dscw-p-job][data-tone="done"]::before { background: var(--dsw-alias-state-success-primary, var(--dsw-alias-border-l2)); }',
'[data-dscw-p-job][data-tone="partial"]::before, [data-dscw-p-job][data-tone="cancelled"]::before { background: var(--dsw-alias-state-warning-primary, var(--dsw-alias-border-l2)); }',
'[data-dscw-p-job][data-tone="failed"]::before { background: var(--dsw-alias-state-error-primary, var(--dsw-alias-border-l2)); }',
// 进度一行放完:大数字 · 主进度条 · 趋势 · 当前阶段说明。分三行会白吃 60px 高度。
'[data-dscw-p-progress] { display: flex; align-items: center; gap: 10px; }',
'[data-dscw-p-pct] { display: flex; align-items: baseline; flex: none; font-size: 22px; line-height: 1; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--dsw-alias-label-primary); }',
'[data-dscw-p-pct] [data-unit] { font-size: 12px; font-weight: 500; letter-spacing: 0; color: var(--dsw-alias-label-tertiary); margin-left: 2px; }',
'[data-dscw-p-pctmeta] { display: flex; flex: none; align-items: baseline; gap: 6px; margin-left: auto; font-size: 11px; line-height: 15px; color: var(--dsw-alias-label-secondary); white-space: nowrap; }',
'[data-dscw-p-pctmeta] > span[data-faint] { color: var(--dsw-alias-label-tertiary); }',
'[data-dscw-p-bar] { position: relative; flex: 1 1 auto; min-width: 40px; height: 5px; border-radius: 3px; overflow: hidden; background: color-mix(in srgb, var(--dsw-alias-border-l3) 60%, transparent); }',
'[data-dscw-p-barfill] { height: 100%; border-radius: 999px; background: var(--dsw-alias-brand-primary); transition: width .45s cubic-bezier(.22, .61, .36, 1); }',
'[data-dscw-p-bar][data-tone="done"] [data-dscw-p-barfill] { background: var(--dsw-alias-state-success-primary, var(--dsw-alias-brand-primary)); }',
'[data-dscw-p-bar][data-tone="failed"] [data-dscw-p-barfill] { background: var(--dsw-alias-state-error-primary, var(--dsw-alias-brand-primary)); }',
'[data-dscw-p-bar][data-tone="partial"] [data-dscw-p-barfill], [data-dscw-p-bar][data-tone="cancelled"] [data-dscw-p-barfill] { background: var(--dsw-alias-state-warning-primary, var(--dsw-alias-brand-primary)); }',
// 历史区按仓库折叠:同一仓库几十轮平铺会把别的仓库挤出视野。
'[data-dscw-p-groups] { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }',
'[data-dscw-p-repofold] { border: 0.5px solid var(--dsw-alias-border-l3); border-radius: 10px; overflow: hidden; }',
'[data-dscw-p-repofold] > summary { display: flex; align-items: center; gap: 8px; padding: 7px 10px; cursor: pointer; font-size: 11.5px; color: var(--dsw-alias-label-secondary); list-style: none; }',
'[data-dscw-p-repofold] > summary::-webkit-details-marker { display: none; }',
'[data-dscw-p-repofold] > summary:hover { background: color-mix(in srgb, var(--dsw-alias-bg-layer-2) 70%, transparent); }',
'[data-dscw-p-repofold] > summary > [data-count] { margin-left: auto; color: var(--dsw-alias-label-tertiary); font-variant-numeric: tabular-nums; }',
'[data-dscw-p-repofold] > [data-body] { display: flex; flex-direction: column; gap: 6px; padding: 6px 8px 8px; }',
'[data-dscw-p-pool] { margin-left: auto; font-size: 10.5px; color: var(--dsw-alias-label-tertiary); font-variant-numeric: tabular-nums; }',
'[data-dscw-p-seclabel] { display: flex; align-items: center; gap: 6px; font-size: 11px; line-height: 16px; letter-spacing: 0.05em; color: var(--dsw-alias-label-tertiary); }',
'[data-dscw-p-seclabel]::after { content: ""; flex: 1; height: 0.5px; background: var(--dsw-alias-border-l3); }',
'[data-dscw-p-jobs] { display: flex; flex-direction: column; gap: 10px; }',
// 设置区不再套一层描边盒子:每个分组已有自己的标签与细线,盒中盒会给同一页画出两级
// 同等重量的边界,读起来像两个嵌套的表单。
'[data-dscw-p-settings] { padding: 2px 0 0; }',
// 标签条:四个等宽等分的格子,当前项用一条 2px 品牌色下划线标出来。
// 药丸式的实心块会把「当前页」画成一个按钮,和旁边的操作按钮抢注意力;
// 下划线是导航的惯用语法,读者不用想就知道自己在哪一格。
'[data-dscw-p-tabs] { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0; border-bottom: 0.5px solid var(--dsw-alias-border-l3); }',
'[data-dscw-p-tab] { position: relative; border: 0; background: transparent; color: var(--dsw-alias-label-tertiary); font: inherit; font-size: 12px; line-height: 18px; padding: 7px 4px 9px; cursor: pointer; transition: color .16s ease; }',
'[data-dscw-p-tab]:hover { color: var(--dsw-alias-label-primary); }',
'[data-dscw-p-tab]:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: -2px; border-radius: 4px; }',
'[data-dscw-p-tab]::after { content: ""; position: absolute; left: 12%; right: 12%; bottom: -0.5px; height: 2px; border-radius: 1px 1px 0 0; background: var(--dsw-alias-brand-primary); transform: scaleX(0); transform-origin: center; transition: transform .22s cubic-bezier(.22,.61,.36,1); }',
'[data-dscw-p-tab][data-on="true"] { color: var(--dsw-alias-label-primary); font-weight: 500; }',
'[data-dscw-p-tab][data-on="true"]::after { transform: scaleX(1); }',
// 总览:调度信息是一块浅底摘要(它不算「对象」,不需要边框把它框成一个卡),
// 仓库是一个列表——行之间用 0.5px 分隔线,而不是每个仓库各套一个圆角框。
// 十几个仓库各带一个框时,视觉上得到十几个同等重量的盒子,反而看不出主次。
// 总览统计条:五个数字格。这里刻意不画进度条或图表——仓库总数是个位数到十几,
// 条形图会给出「量级」的错觉;数字 + 标签在等宽数字下逐列对齐,扫一眼就能比。
'[data-dscw-p-stats] { display: grid; grid-template-columns: repeat(auto-fit, minmax(78px, 1fr)); gap: 6px; }',
'[data-dscw-p-stat] { display: flex; flex-direction: column; gap: 1px; padding: 7px 9px; border-radius: 8px; background: color-mix(in srgb, var(--dsw-alias-bg-layer-2) 70%, transparent); }',
'[data-dscw-p-stat] b { font-size: 17px; line-height: 20px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--dsw-alias-label-primary); }',
'[data-dscw-p-stat] span { font-size: 10.5px; line-height: 14px; color: var(--dsw-alias-label-tertiary); }',
'[data-dscw-p-stat][data-tone="warn"] { background: color-mix(in srgb, var(--dsw-alias-state-warning-primary, var(--dsw-alias-state-business-primary)) 12%, transparent); }',
'[data-dscw-p-stat][data-tone="warn"] b { color: var(--dsw-alias-state-warning-primary, var(--dsw-alias-state-business-primary)); }',
'[data-dscw-p-stat][data-tone="ok"] { background: color-mix(in srgb, var(--dsw-alias-state-success-primary, var(--dsw-alias-brand-primary)) 12%, transparent); }',
'[data-dscw-p-stat][data-tone="ok"] b { color: var(--dsw-alias-state-success-primary, var(--dsw-alias-brand-primary)); }',
// 待办优先的清单:需要动手的两档(待确认 / 有变更)给一点左侧强调,
// 免得排在列表顶部但和「干净」长得一样,读者还是要逐个读状态词。
'[data-dscw-p-repo][data-rank="0"] { box-shadow: inset 2px 0 0 var(--dsw-alias-state-warning-primary, var(--dsw-alias-state-business-primary)); }',
'[data-dscw-p-repo][data-rank="1"] { box-shadow: inset 2px 0 0 color-mix(in srgb, var(--dsw-alias-brand-primary) 55%, transparent); }',
'[data-dscw-p-repo][data-rank="4"] { box-shadow: inset 2px 0 0 var(--dsw-alias-state-error-primary, var(--dsw-alias-border-l3)); }',
'[data-dscw-p-sched] { display: flex; flex-direction: column; gap: 3px; padding: 9px 11px; border-radius: 10px; background: color-mix(in srgb, var(--dsw-alias-bg-layer-2) 80%, transparent); font-size: 11.5px; line-height: 17px; color: var(--dsw-alias-label-secondary); }',
'[data-dscw-p-sched] [data-dscw-p-row] { font-size: 12px; color: var(--dsw-alias-label-primary); }',
'[data-dscw-p-repolist] { display: flex; flex-direction: column; }',
'[data-dscw-p-repo] { display: flex; flex-direction: column; gap: 3px; padding: 9px 2px; border-bottom: 0.5px solid var(--dsw-alias-border-l3); }',
'[data-dscw-p-repo]:last-child { border-bottom: 0; }',
'[data-dscw-p-repo]:hover { background: color-mix(in srgb, var(--dsw-alias-bg-layer-2) 55%, transparent); }',
'[data-dscw-p-repo] [data-dscw-p-row] { gap: 6px; }',
'[data-dscw-p-tasklist] > summary { cursor: pointer; user-select: none; font-size: 11px; line-height: 16px; color: var(--dsw-alias-label-tertiary); list-style: none; }',
'[data-dscw-p-tasklist] > summary::-webkit-details-marker { display: none; }',
'[data-dscw-p-tasklist] > summary:hover { color: var(--dsw-alias-label-secondary); }',
'[data-dscw-p-tasklist] > [data-body] { display: flex; flex-direction: column; gap: 1px; max-height: 180px; overflow-y: auto; margin-top: 4px; padding-left: 8px; border-left: 2px solid var(--dsw-alias-border-l3); font-size: 11.5px; line-height: 17px; color: var(--dsw-alias-label-secondary); }',
'[data-dscw-p-task] { display: flex; gap: 6px; align-items: baseline; }',
'[data-dscw-p-task] [data-mark] { flex: none; width: 12px; text-align: center; }',
'[data-dscw-p-task][data-state="done"] [data-mark] { color: var(--dsw-alias-state-success-primary, var(--dsw-alias-label-secondary)); }',
'[data-dscw-p-task][data-state="failed"] [data-mark] { color: var(--dsw-alias-state-error-primary, var(--dsw-alias-label-secondary)); }',
'[data-dscw-p-textarea] { width: 100%; min-height: 64px; resize: vertical; font: inherit; font-size: 12px; line-height: 18px; padding: 6px 8px; border: 0.5px solid var(--dsw-alias-border-l2); border-radius: 6px; background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-primary); box-sizing: border-box; }',
// 吞吐徽标:方角,读数用等宽数字对齐
// 分段带就是进度条本体:段宽=该阶段占总时间的比例,段色=阶段身份。
// 段色用固定色相而非主题色:五个阶段必须彼此可分辨,全用 brand-primary 就退化成一条纯色。
// 明度锁在 52%,深浅两套主题下都能读;未跑完的部分用同色低透明度打底,所以
// 「这段是什么」(色相)与「这段做到哪」(填充宽度)互不占用同一个通道。
'[data-dscw-p-segbar] { display: flex; gap: 2px; flex: 1 1 auto; min-width: 40px; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--dsw-alias-border-l3) 60%, transparent); }',
// 最小宽度 3px:真机上准备段常占 99%(06:54 对 790ms),不给小段保底宽度,
// 「校验 24ms」这类阶段会缩成亚像素直接看不见——而它们恰恰是「这几步都不慢」的证据。
'[data-dscw-p-seg] { position: relative; min-width: 3px; border-radius: 2px; overflow: hidden; background: color-mix(in srgb, hsl(var(--seg-hue) 58% 52%) 20%, transparent); }',
'[data-dscw-p-seg]::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--seg-done, 100%); background: hsl(var(--seg-hue) 58% 52%); transition: width .45s cubic-bezier(.22,.61,.36,1); }',
'[data-dscw-p-seg][data-state="failed"]::after { background: var(--dsw-alias-state-error-primary, hsl(var(--seg-hue) 58% 52%)); }',
'[data-dscw-p-seg][data-state="failed"] { background: color-mix(in srgb, var(--dsw-alias-state-error-primary, hsl(var(--seg-hue) 58% 52%)) 20%, transparent); }',
// 图例:与分段带同色,把颜色和阶段绑起来。终态读耗时,进行中读百分比。
'[data-dscw-p-legend] { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 12px; font-size: 10.5px; line-height: 15px; color: var(--dsw-alias-label-tertiary); font-variant-numeric: tabular-nums; }',
'[data-dscw-p-legend] > span { display: inline-flex; align-items: center; gap: 4px; }',
'[data-dscw-p-legend] [data-swatch] { flex: none; width: 7px; height: 7px; border-radius: 2px; background: hsl(var(--seg-hue) 58% 52%); }',
'[data-dscw-p-legend] > span[data-state="todo"] [data-swatch] { opacity: .35; }',
'[data-dscw-p-legend] > span[data-state="failed"] [data-swatch] { background: var(--dsw-alias-state-error-primary, hsl(var(--seg-hue) 58% 52%)); }',
'[data-dscw-p-legend] > span[data-state="running"] { color: var(--dsw-alias-label-primary); font-weight: 600; }',
'[data-dscw-p-badge] { display: inline-flex; align-items: center; gap: 5px; padding: 1px 6px; border-radius: 4px; background: color-mix(in srgb, var(--dsw-alias-label-tertiary) 10%, transparent); font-size: 11px; line-height: 16px; color: var(--dsw-alias-label-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }',
'[data-dscw-p-badge][data-tone="live"] { color: var(--dsw-alias-state-success-primary, var(--dsw-alias-label-secondary)); background: color-mix(in srgb, var(--dsw-alias-state-success-primary, currentColor) 12%, transparent); }',
'[data-dscw-p-badge] svg { display: block; }',
'[data-dscw-p-usage] { color: var(--dsw-alias-label-tertiary); font-variant-numeric: tabular-nums; white-space: nowrap; }',
'[data-dscw-p-usage] [data-warn] { color: var(--dsw-alias-state-warning-primary, var(--dsw-alias-state-business-primary)); }',
'[data-dscw-p-error] { font-size: 12px; line-height: 18px; color: var(--dsw-alias-state-error-primary, var(--dsw-alias-label-secondary)); word-break: break-all; }',
'[data-dscw-p-activity] { margin-top: 2px; }',
'[data-dscw-p-activity] summary { cursor: pointer; user-select: none; font-size: 11px; line-height: 16px; color: var(--dsw-alias-label-tertiary); }',
'[data-dscw-p-activity] summary:hover, [data-dscw-p-engine-log] summary:hover { color: var(--dsw-alias-label-secondary); }',
'[data-dscw-p-activity] > [data-body] { display: flex; flex-direction: column; margin-top: 4px; max-height: 220px; overflow-y: auto; }',
// 每条活动一行:状态点 | 阶段标签 | 正文。竖向连线用行自身的 ::before 画,
// 这样最后一条不用单独去尾,靠 overflow 裁掉即可。
'[data-dscw-p-actrow] { position: relative; display: flex; align-items: baseline; gap: 6px; padding: 3px 0 3px 14px; font-size: 11px; line-height: 16px; }',
'[data-dscw-p-actrow]::before { content: ""; position: absolute; left: 3px; top: 0; bottom: 0; width: 1px; background: var(--dsw-alias-border-l3); }',
'[data-dscw-p-actrow] [data-dot] { position: absolute; left: 1px; top: 8px; width: 5px; height: 5px; border-radius: 50%; background: var(--dsw-alias-label-tertiary); box-shadow: 0 0 0 2px var(--dsw-alias-bg-layer-1, transparent); }',
'[data-dscw-p-actrow] [data-stage] { flex: none; padding: 0 4px; border-radius: 3px; font-size: 10px; line-height: 14px; color: var(--dsw-alias-label-tertiary); background: color-mix(in srgb, var(--dsw-alias-label-tertiary) 12%, transparent); font-family: var(--dsw-alias-font-mono, ui-monospace, monospace); }',
'[data-dscw-p-actrow] [data-text] { min-width: 0; color: var(--dsw-alias-label-secondary); word-break: break-word; }',
'[data-dscw-p-actrow][data-tone="ok"] [data-dot] { background: var(--dsw-alias-state-success-primary, var(--dsw-alias-label-tertiary)); }',
'[data-dscw-p-actrow][data-tone="warn"] [data-dot] { background: var(--dsw-alias-state-warning-primary, var(--dsw-alias-label-tertiary)); }',
'[data-dscw-p-actrow][data-tone="warn"] [data-text] { color: var(--dsw-alias-label-secondary); }',
'[data-dscw-p-actrow][data-tone="error"] [data-dot] { background: var(--dsw-alias-state-error-primary, var(--dsw-alias-label-tertiary)); }',
'[data-dscw-p-actrow][data-tone="error"] [data-text] { color: var(--dsw-alias-state-error-primary, var(--dsw-alias-label-secondary)); }',
'[data-dscw-p-engine-log] { margin-top: 2px; }',
'[data-dscw-p-engine-log] > summary { cursor: pointer; user-select: none; font-size: 11px; line-height: 16px; color: var(--dsw-alias-label-tertiary); }',
'[data-dscw-p-engine-log] > div { max-height: 180px; overflow-y: auto; margin-top: 4px; padding-left: 8px; border-left: 2px solid var(--dsw-alias-border-l3); }',
'[data-dscw-p-logline] { font-family: var(--dsw-alias-font-mono, ui-monospace, monospace); font-size: 10.5px; line-height: 15px; color: var(--dsw-alias-label-secondary); white-space: pre-wrap; word-break: break-all; font-variant-numeric: tabular-nums; }',
'[data-dscw-p-queueahead] { font-size: 11px; line-height: 16px; color: var(--dsw-alias-state-warning-primary, var(--dsw-alias-state-business-primary)); word-break: break-all; }',
// 会话视图(LLM 请求记录)
//
// 三层结构:仓库 → 编译阶段 → 请求。每一层只用一个视觉手段表达层级,不叠加:
// 仓库层用留白与字重,阶段层用一条缩进竖线与计数,请求层只剩状态点与正文。
// 之前每行都描边、每层都加框,几十条请求摊开像一叠同重的卡片,扫不出「哪条在跑」。
'[data-dscw-p-page][data-dscw-p-fixed] { overflow: hidden; }',
// 进行中任务:这两个 data 属性此前没有任何规则,渲染出来是几行裸文本。
'[data-dscw-p-active] { display: flex; flex-direction: column; gap: 5px; flex: none; }',
'[data-dscw-p-activerow] { position: relative; display: flex; align-items: baseline; gap: 8px; width: 100%; text-align: left; border: 0.5px solid color-mix(in srgb, var(--dsw-alias-state-business-primary, var(--dsw-alias-brand-primary)) 38%, var(--dsw-alias-border-l3)); border-radius: 8px; background: color-mix(in srgb, var(--dsw-alias-state-business-primary, var(--dsw-alias-brand-primary)) 6%, transparent); padding: 7px 10px; cursor: pointer; font: inherit; font-size: 12px; color: var(--dsw-alias-label-secondary); transition: background-color .14s ease; }',
'[data-dscw-p-activerow]:hover { background: color-mix(in srgb, var(--dsw-alias-state-business-primary, var(--dsw-alias-brand-primary)) 12%, transparent); }',
'[data-dscw-p-activerow]:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: -2px; }',
'[data-dscw-p-activerow] [data-dot] { flex: none; align-self: center; width: 6px; height: 6px; border-radius: 50%; background: var(--dsw-alias-brand-primary); animation: dscw-pulse 1.4s ease-in-out infinite; }',
'[data-dscw-p-activerow][data-idle="true"] { cursor: default; border-color: var(--dsw-alias-border-l3); background: transparent; }',
'[data-dscw-p-activerow][data-idle="true"] [data-dot] { background: var(--dsw-alias-border-l3); animation: none; }',
'[data-dscw-p-activerow] [data-name] { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-label-primary); font-weight: 500; }',
// 仓库名不带 jobId,两者不同时补一个短标记,否则同一仓库并行跑两个任务时分不清点的是哪一个。
'[data-dscw-p-activerow] [data-job] { flex: none; font-size: 10px; line-height: 14px; color: var(--dsw-alias-label-tertiary); font-variant-numeric: tabular-nums; }',
'[data-dscw-p-activerow] [data-sub] { flex: none; margin-left: auto; font-size: 11px; line-height: 16px; color: var(--dsw-alias-label-tertiary); font-variant-numeric: tabular-nums; }',
// 仓库层:只有标题与条数,靠上下留白和 13px 字把一节分开,不画框。
'[data-dscw-p-repohead] { display: flex; align-items: baseline; gap: 8px; width: 100%; text-align: left; border: 0; background: transparent; padding: 0 2px 6px; cursor: pointer; font: inherit; font-size: 12.5px; line-height: 18px; color: var(--dsw-alias-label-secondary); border-bottom: 0.5px solid var(--dsw-alias-border-l3); }',
'[data-dscw-p-repohead]:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 1px; border-radius: 4px; }',
'[data-dscw-p-repohead]::before { content: "\u25b8"; flex: none; font-size: 9px; color: var(--dsw-alias-label-tertiary); transition: transform .16s ease; }',
'[data-dscw-p-repohead] [data-repo] { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--dsw-alias-label-primary); }',
'[data-dscw-p-repohead] [data-count] { margin-left: auto; flex: none; font-size: 10.5px; color: var(--dsw-alias-label-tertiary); font-variant-numeric: tabular-nums; }',
'[data-dscw-p-repohead][data-live="true"] [data-repo]::after { content: ""; display: inline-block; width: 5px; height: 5px; margin-left: 6px; border-radius: 50%; background: var(--dsw-alias-state-success-primary, var(--dsw-alias-brand-primary)); animation: dscw-pulse 1.4s ease-in-out infinite; vertical-align: middle; }',
// 阶段层:左侧一条 1px 竖线把「同一步的请求」圈在一起,头行是阶段名 + 条数 + 完成情况。
// 缩进用 padding 而不是 margin,竖线才能连续贯穿整组。
'[data-dscw-p-stagegroups] { display: flex; flex-direction: column; gap: 2px; padding: 4px 0 0 2px; }',
'[data-dscw-p-stagegroup] { display: flex; flex-direction: column; min-width: 0; border-left: 1px solid var(--dsw-alias-border-l3); padding-left: 8px; }',
'[data-dscw-p-stagegroup][data-open="true"] { border-left-color: color-mix(in srgb, var(--dsw-alias-brand-primary) 32%, var(--dsw-alias-border-l3)); }',
'[data-dscw-p-stagehead] { display: flex; align-items: baseline; gap: 8px; width: 100%; text-align: left; border: 0; border-radius: 5px; background: transparent; padding: 5px 6px; cursor: pointer; font: inherit; font-size: 11.5px; line-height: 16px; color: var(--dsw-alias-label-secondary); }',
'[data-dscw-p-stagehead]:hover { background: color-mix(in srgb, var(--dsw-alias-bg-layer-2) 70%, transparent); }',
'[data-dscw-p-stagehead]:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: -2px; }',
'[data-dscw-p-stagehead]::before { content: "\u25b8"; flex: none; font-size: 8px; color: var(--dsw-alias-label-tertiary); transition: transform .16s ease; }',
'[data-dscw-p-stagegroup][data-open="true"] > [data-dscw-p-stagehead]::before { transform: rotate(90deg); }',
'[data-dscw-p-stagehead] [data-stage] { flex: none; font-weight: 500; color: var(--dsw-alias-label-primary); }',
'[data-dscw-p-stagehead] [data-count] { flex: none; font-size: 10.5px; color: var(--dsw-alias-label-tertiary); font-variant-numeric: tabular-nums; }',
'[data-dscw-p-stagehead] [data-body] { min-width: 0; margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; color: var(--dsw-alias-label-tertiary); font-variant-numeric: tabular-nums; }',
'[data-dscw-p-stagehead][data-live="true"] [data-stage] { color: var(--dsw-alias-state-success-primary, var(--dsw-alias-brand-primary)); }',
// 循环层:阶段内的 agentic 往返分组。比阶段层再淡一档——它解释「为什么这么多条」,
// 不承担流程语义,所以用点线而不是实线,字号也更小。
// 详情:一条信息栏 + 页签 + 一个滚动的正文区。三块都不设固定高度,
// 正文区吃满剩余空间自己滚——不再有「半屏内容 + 半屏空白 + 滚外层」。
'[data-dscw-p-live] { flex: none; margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: 11px; line-height: 16px; color: var(--dsw-alias-state-success-primary, var(--dsw-alias-label-secondary)); }',
'[data-dscw-p-live]::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: dscw-pulse 1.2s ease-in-out infinite; }',
// 正文排版:宿主 MarkdownText 自带结构,这里只调「面板里能读」的密度——
// 12px 正文、1.65 行高、标题与正文同一字阶、代码块横向滚而不换行。
// 提示词分块:每个 [role] 一段,段落头是一条窄标签,正文照常渲染 Markdown。
'[data-dscw-p-promptblocks] { display: flex; flex-direction: column; gap: 14px; }',
'[data-dscw-p-promptblocks] > section { display: flex; flex-direction: column; gap: 5px; min-width: 0; }',
'[data-dscw-p-rolebar] { position: sticky; top: 0; z-index: 1; align-self: flex-start; font-size: 10px; line-height: 15px; padding: 1px 6px; border-radius: 3px; color: var(--dsw-alias-label-tertiary); background: color-mix(in srgb, var(--dsw-alias-bg-layer-2) 88%, transparent); }',
'[data-dscw-p-promptblocks] > section[data-role="system"] [data-dscw-p-rolebar] { color: var(--dsw-alias-state-business-primary, var(--dsw-alias-brand-primary)); }',
// 工具调用:一条一个可折叠块,头行是工具名,展开是原始参数。
'[data-dscw-p-toollist] { display: flex; flex-direction: column; gap: 6px; }',
'[data-dscw-p-tool] { border: 0.5px solid var(--dsw-alias-border-l3); border-radius: 6px; background: color-mix(in srgb, var(--dsw-alias-bg-layer-1) 60%, transparent); }',
'[data-dscw-p-tool] > summary { display: flex; align-items: baseline; gap: 8px; padding: 6px 9px; cursor: pointer; list-style: none; font-size: 11.5px; line-height: 16px; color: var(--dsw-alias-label-secondary); }',
'[data-dscw-p-tool] > summary::-webkit-details-marker { display: none; }',
'[data-dscw-p-tool] > summary [data-toolname] { font-weight: 500; color: var(--dsw-alias-label-primary); }',
'[data-dscw-p-tool] > summary [data-toolid] { margin-left: auto; font-size: 10px; color: var(--dsw-alias-label-tertiary); font-family: var(--dsw-alias-font-mono, ui-monospace, monospace); }',
'[data-dscw-p-tool] > pre { margin: 0; padding: 2px 9px 9px; max-height: 260px; overflow: auto; font-family: var(--dsw-alias-font-mono, ui-monospace, monospace); font-size: 10.5px; line-height: 16px; color: var(--dsw-alias-label-secondary); white-space: pre-wrap; word-break: break-word; }',
'@keyframes dscw-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }',
].join('\n')
// HMR/重复加载时避免堆叠重复样式表
if (!document.head.querySelector('style[data-plugin="@ikliml666/dsh-codewiki"]')) document.head.appendChild(style)
function el(tag, props, ...children) {
return React.createElement(tag, props, ...children)
}
async function apiGet(p) {
const res = await fetch(p, { headers: { accept: 'application/json' } })
const body = await res.json().catch(() => ({}))
if (!res.ok) throw new Error(body.error || `HTTP ${res.status}`)
return body
}
async function apiPost(p, data) {
const res = await fetch(p, {
method: 'POST',
headers: { 'content-type': 'application/json', accept: 'application/json' },
body: JSON.stringify(data ?? {}),
})
const body = await res.json().catch(() => ({}))
if (!res.ok) throw new Error(body.error || `HTTP ${res.status}`)
return body
}
return {
inject: ['slots', 'locale', 'configForms'],
apply(ctx) {
const tBound = ctx.locale.bind(NS)
ctx.effect(() => ctx.locale.register(NS, { zh: zh(), en: en() }), 'dscw: dictionaries')
// 配置表单:宿主半侧 Config service 服务 'codewiki' 命名空间后即可读写。
const form = ctx.configForms.get(NS)
// 宿主服务该命名空间期间才出现(插件未加载/停用时插件页不显形)。
const mount = () => ctx.slots.inject('plugins.item', () => ctx.slots.register({
name: 'plugins.item',
id: NS,
order: 30,
label: () => tBound('title'),
locale: NS,
inject: () => ({ t: tBound }),
}, CodewikiCard))
if (typeof ctx.configForms.whileServed === 'function') {
ctx.effect(() => ctx.configForms.whileServed([NS], mount), 'dscw: plugins.item')
} else {
mount()
}
// 侧边栏面板:main slot 渲染任务列表,panellist 出入口(id 必须等于 main 的 key)。
ctx.effect(() => {
const disposers = [
ctx.slots.inject('main', () => ctx.slots.register({ name: 'main', key: KEY }, CodewikiPanel)),
ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
name: 'sidebar.panellist',
id: KEY,
order: PANEL_ORDER,
label: () => tBound('title'),
}, PanelIcon)),
]
return () => disposers.forEach((d) => { try { d?.() } catch { /* 已卸载亦可 */ } })
}, 'dscw: panel')
// -------------------------------------------------------------------
// 设置卡片组件(view='summary' 一行简介;view='page' 完整表单)
// -------------------------------------------------------------------
// 设置页可自动保存的字段表:新增字段必须同时进这里与渲染,否则改了不会落盘。
const SAVE_KEYS = [
'enabled', 'binaryPath', 'maxConcurrency', 'moduleConcurrency',
'serialProjects', 'parallelProjects', 'articleLanguage', 'updateReminder', 'autoCommit',
'workspaceOnly', 'techdocs', 'batchProvider', 'batchModel', 'batchReasoningEffort', 'effortByStage',
'excludePaths',
'autoUpdate', 'autoUpdateMin', 'requestLimit', 'emptyStreakLimit', 'historyCompactionKeep',
'nativeEngine', 'nativeEnginePython', 'nativeEngineEntry', 'nativeEngineTimeoutMs',
'updateRung', 'updateTauNb', 'updateTauGrow', 'updateTauFull', 'updateTauTree',
]
function CodewikiCard(props) {
const t = props?.t ?? tBound
const [snapshot, setSnapshot] = React.useState(() => form.getSnapshot())
const [draft, setDraft] = React.useState(null)
const [error, setError] = React.useState(null)
// 模型目录(宿主 llm 服务的 provider/model,经 /api/codewiki/models 拉取)。
// 拉不到时 catalogError 有值,设置页退回「手填」形态,不阻断保存。
const [catalog, setCatalog] = React.useState(null)
const [catalogError, setCatalogError] = React.useState(null)
React.useEffect(() => {
let alive = true
apiGet(MODELS_PATH)
.then((data) => {
if (!alive) return
if (data?.ok === false) { setCatalogError(String(data.error ?? '模型目录不可用')); return }
setCatalog(Array.isArray(data?.providers) ? data.providers : [])
setCatalogError(null)
})
.catch((err) => { if (alive) setCatalogError(String(err?.message ?? err)) })
return () => { alive = false }
}, [])
// 配置快照 + 订阅:宿主值变更(含保存成功后的回收读)才覆盖草稿。
React.useEffect(() => {
let alive = true
let lastRevision
const pull = () => {
if (!alive) return
const snap = form.getSnapshot()
setSnapshot(snap)
if (snap.status === 'ready' && snap.value && typeof snap.value === 'object'
&& lastRevision !== snap.revision) {
lastRevision = snap.revision
setDraft(structuredClone(snap.value))
setError(null)
}
}
pull()
const dispose = form.subscribe(pull)
return () => { alive = false; dispose() }
}, [])
// 摘要视图:一行简介(插件页列表项)。
if (props?.view === 'summary') return t('summary')
const setPath = (key, value) => {
setDraft((prev) => {
if (!prev) return prev
const next = structuredClone(prev)
next[key] = value
return next
})
}
// 当前选中的提供商条目(目录里没命中时为 null = 手填形态)
const selectedProvider = React.useMemo(() => {
const id = String(draft?.batchProvider ?? '').trim()
if (!id || !Array.isArray(catalog)) return null
return catalog.find((p) => p?.id === id) ?? null
}, [draft?.batchProvider, catalog])
// 思考程度档位:选中 provider/model 后二次拉取 /api/codewiki/model-efforts,
// 档位清单来自模型目录(resolveModelInfo 的 reasoning.efforts),不手填裸字符串。
// 普通档(batch)与大档(big)各一份,同一套读取逻辑。
const useEfforts = (provider, model) => {
const [state, setState] = React.useState({ for: '', efforts: [], defaultEffort: null, error: null, loading: false })
const p = String(provider ?? '').trim()
const m = String(model ?? '').trim()
React.useEffect(() => {
if (!p || !m) { setState({ for: '', efforts: [], defaultEffort: null, error: null, loading: false }); return }
const key = `${p}\u0000${m}`
let alive = true
setState((prev) => (prev.for === key ? prev : { for: key, efforts: [], defaultEffort: null, error: null, loading: true }))
const url = `${EFFORTS_PATH}?provider=${encodeURIComponent(p)}&model=${encodeURIComponent(m)}`
apiGet(url)
.then((data) => {
if (!alive) return
if (data?.ok === false) {
setState({ for: key, efforts: [], defaultEffort: null, error: String(data.error ?? '不可用'), loading: false })
return
}
setState({
for: key,
efforts: Array.isArray(data?.efforts) ? data.efforts : [],
defaultEffort: data?.defaultEffort ? String(data.defaultEffort) : null,
error: null,
loading: false,
})
})
.catch((err) => {
if (alive) setState({ for: key, efforts: [], defaultEffort: null, error: String(err?.message ?? err), loading: false })
})
return () => { alive = false }
}, [p, m])
return state
}
const effortsState = useEfforts(draft?.batchProvider, draft?.batchModel)
// 一个模型的三个字段(提供商 / 模型 / 思考程度):目录联动——换提供商清空模型
// 与旧档位、目录里的模型下拉、档位来自 model-efforts 端点。
const modelTrio = ({ pKey, mKey, eKey, state, providerPlaceholder }) => {