nx-kv 0.64.0 → 0.65.2

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.
Files changed (151) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/assets/nx-kv/SKILL.md +5 -2
  3. package/assets/nx-kv/references/A03-/346/226/207/346/241/243/344/270/216/345/275/222/345/261/236.md +6 -0
  4. package/assets/nx-kv/references/A04-/344/273/223/345/272/223/344/270/216/351/241/271/347/233/256/347/273/204.md +79 -6
  5. package/assets/nx-kv/templates/ref-main-doc.md +46 -0
  6. package/package.json +1 -1
  7. package/src/core/db/seed-templates.ts +2 -86
  8. package/src/modules/localtask/task-lifecycle.ts +1 -1
  9. package/src/modules/promptplug/actions/_manifest.generated.ts +9 -0
  10. package/src/modules/promptplug/actions/prompt-registry.ts +4 -1
  11. package/src/modules/promptplug/actions/prompt-template-activate.ts +31 -0
  12. package/src/modules/promptplug/actions/prompt-template-delete.ts +30 -0
  13. package/src/modules/promptplug/actions/prompt-template-save.ts +52 -0
  14. package/src/modules/promptplug/delivery.ts +151 -0
  15. package/src/modules/promptplug/factory.ts +16 -8
  16. package/src/modules/promptplug/index.ts +3 -1
  17. package/src/modules/promptplug/plugins/doneguard.ts +3 -0
  18. package/src/modules/promptplug/plugins/getloop.ts +8 -7
  19. package/src/modules/{tasktool/plugins/goal-template.ts → promptplug/plugins/goal-prompt.ts} +57 -4
  20. package/src/modules/promptplug/plugins/goal-shape.ts +17 -0
  21. package/src/modules/promptplug/plugins/goalhint.ts +22 -9
  22. package/src/modules/promptplug/plugins/timecheck.ts +25 -14
  23. package/src/modules/promptplug/registry.ts +3 -3
  24. package/src/modules/promptplug/template-store.ts +145 -0
  25. package/src/modules/tasktool/delivery.ts +231 -0
  26. package/src/modules/tasktool/get.ts +2 -2
  27. package/src/modules/tasktool/plugins/taskgoal-store.ts +28 -22
  28. package/src/modules/tasktool/plugins/timegoal-task-store.ts +70 -5
  29. package/src/modules/tasktool/plugins/waitgoal-config.ts +1 -25
  30. package/src/modules/tasktool/plugins/waitgoal.ts +0 -4
  31. package/src/modules/tasktool/preview.ts +3 -4
  32. package/src/modules/tasktool/wait.ts +16 -284
  33. package/src/modules/templates/actions/templates-default.ts +2 -5
  34. package/src/modules/templates/actions/templates-update.ts +1 -3
  35. package/src/modules/templates/service.ts +11 -13
  36. package/src/modules/templates/support.ts +0 -15
  37. package/src/web/frontend/App.tsx +0 -12
  38. package/src/web/frontend/api/cli-tree.json +58 -0
  39. package/src/web/frontend/api/client.generated.ts +32 -2
  40. package/src/web/frontend/components/doc/doc-head.tsx +13 -4
  41. package/src/web/frontend/components/icons.tsx +9 -199
  42. package/src/web/frontend/components/md/live-block.tsx +1 -5
  43. package/src/web/frontend/components/md/md-panes-root.tsx +0 -4
  44. package/src/web/frontend/components/md/md-panes.tsx +1 -11
  45. package/src/web/frontend/components/md/tool-bar.tsx +9 -0
  46. package/src/web/frontend/components/sidebar/index.tsx +13 -2
  47. package/src/web/frontend/components/sidebar/model.ts +3 -0
  48. package/src/web/frontend/components/tool-acts/bar.tsx +40 -29
  49. package/src/web/frontend/components/tool-acts/layout-panel.tsx +7 -3
  50. package/src/web/frontend/components/tool-acts/modules.ts +53 -51
  51. package/src/web/frontend/components/tool-acts/style.css +7 -3
  52. package/src/web/frontend/modules/md/styles/docs.css +0 -7
  53. package/src/web/frontend/modules/md/styles/editor.css +0 -17
  54. package/src/web/frontend/modules/md/styles/shell.css +3 -0
  55. package/src/web/frontend/modules/md/use-templates.ts +3 -13
  56. package/src/web/frontend/page/dir/index.tsx +3 -15
  57. package/src/web/frontend/page/dir/task-actions.ts +1 -16
  58. package/src/web/frontend/page/dir/task.tsx +2 -16
  59. package/src/web/frontend/page/group/index.tsx +6 -19
  60. package/src/web/frontend/page/repos/branch-persist.ts +32 -0
  61. package/src/web/frontend/page/repos/icons.tsx +47 -229
  62. package/src/web/frontend/page/repos/index.tsx +12 -8
  63. package/src/web/frontend/page/repos/repo-table.tsx +24 -3
  64. package/src/web/frontend/page/settings/api.ts +20 -0
  65. package/src/web/frontend/page/settings/index.tsx +1 -1
  66. package/src/web/frontend/page/settings/prompt-template-editor.tsx +180 -0
  67. package/src/web/frontend/page/settings/prompt-templates-section.tsx +39 -34
  68. package/src/web/frontend/page/settings/style.css +30 -0
  69. package/src/web/frontend/page/templates/index.tsx +5 -54
  70. package/src/web/frontend/page/templates/manage.tsx +1 -5
  71. package/src/web/frontend/page/templates/style.css +1 -43
  72. package/src/web/frontend/page/templates/template-list.tsx +7 -15
  73. package/src/web/frontend/routes/route-eq.ts +2 -3
  74. package/src/web/frontend/routes/static.ts +2 -2
  75. package/src/web/frontend/routes/templates.ts +0 -10
  76. package/src/web/frontend/styles/repos.css +22 -0
  77. package/src/web/frontend/styles-v2/shell.css +7 -0
  78. package/src/web/frontend/svghub/catalog-act.ts +168 -0
  79. package/src/web/frontend/svghub/catalog-doc.ts +102 -0
  80. package/src/web/frontend/svghub/catalog-nav.ts +192 -0
  81. package/src/web/frontend/svghub/catalog-repo.ts +102 -0
  82. package/src/web/frontend/svghub/catalog-state.ts +70 -0
  83. package/src/web/frontend/svghub/icon.tsx +95 -0
  84. package/src/web/frontend/svghub/index.ts +66 -0
  85. package/src/web/frontend/svghub/serialize.ts +39 -0
  86. package/src/web/frontend/svghub/types.ts +67 -0
  87. package/src/web/frontend/types.ts +2 -1
  88. package/src/web/public/assets/app-context-BqCBcDsx.js +1 -0
  89. package/src/web/public/assets/bar-Dc5Tq1eE.js +1 -0
  90. package/src/web/public/assets/{button-BEWXOABr.js → button-3JlUeln_.js} +1 -1
  91. package/src/web/public/assets/{composer-launch-DRi9mZE1.js → composer-launch-fp2IzGzQ.js} +1 -1
  92. package/src/web/public/assets/{composer-panel-swmDqlPw.js → composer-panel-Dh681iO6.js} +1 -1
  93. package/src/web/public/assets/dag-DnaU0I_z.js +1 -0
  94. package/src/web/public/assets/dir-d16q1GLe.js +3 -0
  95. package/src/web/public/assets/doc-DRSKD0Re.js +6 -0
  96. package/src/web/public/assets/group-Dc3ZgW24.js +1 -0
  97. package/src/web/public/assets/index-BIVxGd6t.css +1 -0
  98. package/src/web/public/assets/index-Bg0m8gbJ.js +2 -0
  99. package/src/web/public/assets/{list-filter-D-x94TvA.js → list-filter-CWxiOSg_.js} +1 -1
  100. package/src/web/public/assets/md-history-CLIs9Dr0.css +1 -0
  101. package/src/web/public/assets/md-history-DNtgaIdH.js +39 -0
  102. package/src/web/public/assets/{member-picker-Cvbv24IK.js → member-picker-BZgE3HGb.js} +1 -1
  103. package/src/web/public/assets/model-CtG2jIDv.js +2 -0
  104. package/src/web/public/assets/{overview-CctJfO3D.js → overview-C68QpcT9.js} +1 -1
  105. package/src/web/public/assets/popup-DZ2Khv2c.js +1 -0
  106. package/src/web/public/assets/progress-CEmAFxo9.js +3 -0
  107. package/src/web/public/assets/refs-TzxZYy7T.js +2 -0
  108. package/src/web/public/assets/repo-form-modal-Dg3hJWUV.js +1 -0
  109. package/src/web/public/assets/repos-uNqSR5YB.js +12 -0
  110. package/src/web/public/assets/{route-crumb-BcDPd7Ht.js → route-crumb-C4DgkJ8G.js} +1 -1
  111. package/src/web/public/assets/{settings-Cc6puKd5.css → settings-BWHjNegB.css} +1 -1
  112. package/src/web/public/assets/settings-BzIllshQ.js +1 -0
  113. package/src/web/public/assets/{status-tag-BD_0iWMB.js → status-tag-8cLH8hl9.js} +1 -1
  114. package/src/web/public/assets/task-DuFOXLPC.js +11 -0
  115. package/src/web/public/assets/{task-row-CQgzQmzu.js → task-row-CRjuAfKW.js} +1 -1
  116. package/src/web/public/assets/{task-utils-bJH1-Cjy.js → task-utils-DAPxKm4c.js} +1 -1
  117. package/src/web/public/assets/templates-CwYDIBYn.css +1 -0
  118. package/src/web/public/assets/templates-DNiGvmdq.js +10 -0
  119. package/src/web/public/assets/{use-rail-drag-ufwy2XZB.js → use-rail-drag-DxIYcszo.js} +1 -1
  120. package/src/web/public/assets/{workspace-D3jbcTwf.js → workspace-DojQ3RP4.js} +2 -2
  121. package/src/web/public/index.html +15 -16
  122. package/src/web/frontend/modules/md/fill-session.ts +0 -36
  123. package/src/web/frontend/modules/md/new-task-from-template.ts +0 -22
  124. package/src/web/frontend/modules/md/task-intent.ts +0 -29
  125. package/src/web/frontend/modules/prompts/render-template-body.ts +0 -14
  126. package/src/web/frontend/modules/prompts/template-preview.ts +0 -62
  127. package/src/web/frontend/page/templates/fill.tsx +0 -124
  128. package/src/web/public/assets/app-context-DDQnrPSP.js +0 -1
  129. package/src/web/public/assets/bar-j14ON7uZ.js +0 -1
  130. package/src/web/public/assets/dag-BzdFYMml.js +0 -1
  131. package/src/web/public/assets/dir-DhsB1ZhL.js +0 -3
  132. package/src/web/public/assets/doc-D4po3sDc.js +0 -6
  133. package/src/web/public/assets/fill-session-fHxQHFaD.js +0 -1
  134. package/src/web/public/assets/group-BxmSNzIB.js +0 -1
  135. package/src/web/public/assets/index-CMjG5NVU.js +0 -2
  136. package/src/web/public/assets/index-uMjSWNVr.css +0 -1
  137. package/src/web/public/assets/md-history-1h2zairf.css +0 -1
  138. package/src/web/public/assets/md-history-CZUF_FhN.js +0 -39
  139. package/src/web/public/assets/model-Cc2EoUQp.js +0 -2
  140. package/src/web/public/assets/new-task-from-template-DDWu4yR4.js +0 -1
  141. package/src/web/public/assets/popup-D8KWI6-Q.js +0 -1
  142. package/src/web/public/assets/progress-CawQRCQf.js +0 -3
  143. package/src/web/public/assets/refs-TuuoaRs7.js +0 -2
  144. package/src/web/public/assets/render-template-body-bXdedFig.js +0 -1
  145. package/src/web/public/assets/repo-form-modal-BD4N37MI.js +0 -1
  146. package/src/web/public/assets/repos-BPeuX4N9.js +0 -12
  147. package/src/web/public/assets/settings-CZJaKLZW.js +0 -1
  148. package/src/web/public/assets/task-DgbbF5gy.js +0 -11
  149. package/src/web/public/assets/task-intent-CX5DZccN.js +0 -1
  150. package/src/web/public/assets/templates-CBXlwyof.js +0 -11
  151. package/src/web/public/assets/templates-plA8R7jJ.css +0 -1
@@ -1,230 +1,48 @@
1
- // 仓库管理页的图标集(#143):一律内联 SVG,不引图标库。
1
+ // 仓库管理页的图标集(#143)——图形本体已迁进 svghub 资产库。
2
2
  //
3
- // 口径:24×24 viewBox、`stroke="currentColor"`、线宽 1.6、圆角端点——
4
- // 这样颜色跟着文字走(主题切换不用改 SVG),尺寸靠 CSS 的 width/height 控制。
5
- // 图标只表达「这是哪一类东西」,不做装饰:分支 ⑂ / 仓库 ◈ / 参考仓库 ⑃ / 文档 ▤。
6
- import type { SVGProps } from 'react';
7
-
8
- type IconProps = SVGProps<SVGSVGElement> & { size?: number };
9
-
10
- function Svg({ size = 15, children, ...rest }: IconProps) {
11
- return (
12
- <svg
13
- width={size}
14
- height={size}
15
- viewBox="0 0 24 24"
16
- fill="none"
17
- stroke="currentColor"
18
- strokeWidth={1.6}
19
- strokeLinecap="round"
20
- strokeLinejoin="round"
21
- aria-hidden="true"
22
- focusable="false"
23
- {...rest}
24
- >
25
- {children}
26
- </svg>
27
- );
28
- }
29
-
30
- /** 分支(组):一条主干 + 一条分出又并回的分支。 */
31
- export function IconBranch(p: IconProps) {
32
- return (
33
- <Svg {...p}>
34
- <circle cx="6" cy="5" r="2.2" />
35
- <circle cx="6" cy="19" r="2.2" />
36
- <circle cx="18" cy="12" r="2.2" />
37
- <path d="M6 7.2v9.6" />
38
- <path d="M6 12h6.6a2 2 0 0 1 2 2v-4a2 2 0 0 1 2-2" />
39
- </Svg>
40
- );
41
- }
42
-
43
- /** 仓库(开发仓库):一个盒子。 */
44
- export function IconRepo(p: IconProps) {
45
- return (
46
- <Svg {...p}>
47
- <path d="M4 8.5 12 4l8 4.5v7L12 20l-8-4.5z" />
48
- <path d="M4 8.5 12 13l8-4.5" />
49
- <path d="M12 13v7" />
50
- </Svg>
51
- );
52
- }
53
-
54
- /** 参考仓库:盒子 + 指向它的箭头(「拿来看的」)。 */
55
- export function IconRefRepo(p: IconProps) {
56
- return (
57
- <Svg {...p}>
58
- <path d="M3.5 9 10 5.4l6.5 3.6v5.6L10 18.2 3.5 14.6z" />
59
- <path d="M3.5 9 10 12.8 16.5 9" />
60
- <path d="M10 12.8v5.4" />
61
- <path d="M15.5 17.5h5" />
62
- <path d="M18.4 15.4 20.5 17.5l-2.1 2.1" />
63
- </Svg>
64
- );
65
- }
66
-
67
- /** 文档:一张带折角的纸。 */
68
- export function IconDoc(p: IconProps) {
69
- return (
70
- <Svg {...p}>
71
- <path d="M6 3.5h7.2L18 8.3V20.5H6z" />
72
- <path d="M13 3.5v5h5" />
73
- <path d="M8.8 12.6h6.4M8.8 16.2h4.4" />
74
- </Svg>
75
- );
76
- }
77
-
78
- /** 文档集(多篇):一叠纸。 */
79
- export function IconDocs(p: IconProps) {
80
- return (
81
- <Svg {...p}>
82
- <path d="M8 6.5h9.5V21H8z" />
83
- <path d="M5.5 17.5V3.5h9" />
84
- <path d="M10.6 11h4.3M10.6 14.6h3" />
85
- </Svg>
86
- );
87
- }
88
-
89
- /** 搜索。 */
90
- export function IconSearch(p: IconProps) {
91
- return (
92
- <Svg {...p}>
93
- <circle cx="10.8" cy="10.8" r="6" />
94
- <path d="m15.3 15.3 4.2 4.2" />
95
- </Svg>
96
- );
97
- }
98
-
99
- /** 加号。 */
100
- export function IconPlus(p: IconProps) {
101
- return (
102
- <Svg {...p}>
103
- <path d="M12 5.5v13M5.5 12h13" />
104
- </Svg>
105
- );
106
- }
107
-
108
- /** 同步(环形箭头)。 */
109
- export function IconSync(p: IconProps) {
110
- return (
111
- <Svg {...p}>
112
- <path d="M19.5 12a7.5 7.5 0 1 1-2.6-5.7" />
113
- <path d="M19.8 4.4v4.4h-4.4" />
114
- </Svg>
115
- );
116
- }
117
-
118
- /** 在外部打开(文件管理器 / 文档页)。 */
119
- export function IconOpen(p: IconProps) {
120
- return (
121
- <Svg {...p}>
122
- <path d="M13.5 4.5H20v6.5" />
123
- <path d="M20 4.5 11.5 13" />
124
- <path d="M17 14.5V20H4V7h5.5" />
125
- </Svg>
126
- );
127
- }
128
-
129
- /** 展开 / 收起(下拉箭头)。 */
130
- export function IconChevron(p: IconProps) {
131
- return (
132
- <Svg {...p}>
133
- <path d="m7 10 5 5 5-5" />
134
- </Svg>
135
- );
136
- }
137
-
138
- /** 勾选(当前分支)。 */
139
- export function IconCheck(p: IconProps) {
140
- return (
141
- <Svg {...p}>
142
- <path d="m5 12.5 4.6 4.5L19 7" />
143
- </Svg>
144
- );
145
- }
146
-
147
- /** 关闭。 */
148
- export function IconX(p: IconProps) {
149
- return (
150
- <Svg {...p}>
151
- <path d="M6.5 6.5l11 11M17.5 6.5l-11 11" />
152
- </Svg>
153
- );
154
- }
155
-
156
- /** 成员(人)。 */
157
- export function IconUsers(p: IconProps) {
158
- return (
159
- <Svg {...p}>
160
- <circle cx="9.5" cy="8.5" r="3.2" />
161
- <path d="M3.6 19.6c.6-3 3-4.6 5.9-4.6s5.3 1.6 5.9 4.6" />
162
- <path d="M16 5.6a3 3 0 0 1 0 5.9" />
163
- <path d="M17.4 15.3c2 .5 3.3 2 3.7 4.3" />
164
- </Svg>
165
- );
166
- }
167
-
168
- /** 文件夹。 */
169
- export function IconFolder(p: IconProps) {
170
- return (
171
- <Svg {...p}>
172
- <path d="M3.5 6.5h5l1.8 2.2h10.2V19H3.5z" />
173
- </Svg>
174
- );
175
- }
176
-
177
- /** 摘除 / 删除(减号放在盒子里:语义是「只摘绑定」)。 */
178
- export function IconUnlink(p: IconProps) {
179
- return (
180
- <Svg {...p}>
181
- <path d="M9.5 14.5 8 16a3.5 3.5 0 0 1-5-5l2.2-2.2" />
182
- <path d="M14.5 9.5 16 8a3.5 3.5 0 0 1 5 5l-2.2 2.2" />
183
- <path d="M9.8 14.2 14.2 9.8" />
184
- </Svg>
185
- );
186
- }
187
-
188
- /** 概览(main 分支):网格。 */
189
- export function IconGrid(p: IconProps) {
190
- return (
191
- <Svg {...p}>
192
- <rect x="3.6" y="3.6" width="7" height="7" rx="1.4" />
193
- <rect x="13.4" y="3.6" width="7" height="7" rx="1.4" />
194
- <rect x="3.6" y="13.4" width="7" height="7" rx="1.4" />
195
- <rect x="13.4" y="13.4" width="7" height="7" rx="1.4" />
196
- </Svg>
197
- );
198
- }
199
-
200
- /** 编辑(铅笔)。 */
201
- export function IconEdit(p: IconProps) {
202
- return (
203
- <Svg {...p}>
204
- <path d="M4.5 19.5h3.2l9.6-9.6a2.1 2.1 0 0 0 0-3l-1.7-1.7a2.1 2.1 0 0 0-3 0L3 14.8z" />
205
- <path d="m13.4 6.6 4 4" />
206
- </Svg>
207
- );
208
- }
209
-
210
- /** 删除(垃圾桶)。 */
211
- export function IconTrash(p: IconProps) {
212
- return (
213
- <Svg {...p}>
214
- <path d="M4.5 7h15" />
215
- <path d="M9.5 7V4.8h5V7" />
216
- <path d="M6.4 7l1 12.2h9.2L17.6 7" />
217
- <path d="M10.2 10.6v6M13.8 10.6v6" />
218
- </Svg>
219
- );
220
- }
221
-
222
- /** 绑定 / 链接。 */
223
- export function IconLink(p: IconProps) {
224
- return (
225
- <Svg {...p}>
226
- <path d="M10.2 13.8a3.6 3.6 0 0 0 5.1 0l2.6-2.6a3.6 3.6 0 0 0-5.1-5.1L11.6 7.3" />
227
- <path d="M13.8 10.2a3.6 3.6 0 0 0-5.1 0l-2.6 2.6a3.6 3.6 0 0 0 5.1 5.1l1.2-1.2" />
228
- </Svg>
229
- );
230
- }
3
+ // 这里只保留**组件名**:仓库页里图标是按组件用的(<IconRepo size={14} />),
4
+ // 名字承载语义(branch / repo / refRepo / doc / docs)。组件名 → 资产名的映射
5
+ // 见下;改形状去 svghub/catalog-*.ts,改语义名才动这里。
6
+ //
7
+ // 视觉口径随资产库统一:24×24、currentColor、线宽 1.8(原先这里是 1.6,
8
+ // 两套线宽并存在同一页会让图标看起来「一深一浅」)。
9
+ import { glyph } from '../../svghub/icon.jsx';
10
+
11
+ /** 分支(项目组) */
12
+ export const IconBranch = glyph('board');
13
+ /** 开发仓库 */
14
+ export const IconRepo = glyph('repo');
15
+ /** 参考仓库(只读) */
16
+ export const IconRefRepo = glyph('repo-ref');
17
+ /** 文档 */
18
+ export const IconDoc = glyph('doc');
19
+ /** 文档集 */
20
+ export const IconDocs = glyph('docs');
21
+ /** 检索 */
22
+ export const IconSearch = glyph('search');
23
+ /** 新增 */
24
+ export const IconPlus = glyph('plus');
25
+ /** 刷新 / 同步(资产库里的名字是 refresh,sync 是同一颗图形) */
26
+ export const IconSync = glyph('refresh');
27
+ /** 外部打开 */
28
+ export const IconOpen = glyph('open');
29
+ /** 下拉箭头(与侧栏的右向 chevron 不是同一颗,别混) */
30
+ export const IconChevron = glyph('chevron-down');
31
+ /** 选中 */
32
+ export const IconCheck = glyph('check');
33
+ /** 关闭 */
34
+ export const IconX = glyph('x');
35
+ /** 成员 */
36
+ export const IconUsers = glyph('users');
37
+ /** 目录 */
38
+ export const IconFolder = glyph('folder');
39
+ /** 摘除绑定 */
40
+ export const IconUnlink = glyph('unlink');
41
+ /** 概览(网格) */
42
+ export const IconGrid = glyph('overview');
43
+ /** 编辑 */
44
+ export const IconEdit = glyph('edit');
45
+ /** 删除 */
46
+ export const IconTrash = glyph('trash');
47
+ /** 绑定 / 链接 */
48
+ export const IconLink = glyph('link');
@@ -41,6 +41,7 @@ import type {
41
41
  ReposReload,
42
42
  } from './repo-table.js';
43
43
  import BranchPicker, { BRANCH_DEFAULT, BRANCH_MAIN } from './branch-picker.jsx';
44
+ import { loadBranchPref, saveBranchPref } from './branch-persist.js';
44
45
  import BlockTabs, { RpSearch, type BlockTab } from './block-tabs.jsx';
45
46
  import RefBlock from './ref-block.jsx';
46
47
  import DocBlock from './doc-block.jsx';
@@ -101,7 +102,10 @@ export default function ReposView() {
101
102
 
102
103
  // ---- 视图状态:分支 + 区块 + 检索 ----
103
104
  // branch:'main'(全部)/ 'default'(未分组)/ 组的 id。组是分支,不再是筛选条件。
104
- const [branch, setBranch] = useState<string>(BRANCH_MAIN);
105
+ // #158:记住上次选的分支——重开面板不再回落 main;组已删时 branches 对齐逻辑会回落并写回。
106
+ const [branch, setBranch] = useState<string>(() => loadBranchPref() || BRANCH_MAIN);
107
+ /** 所有切分支都走这里:切换即持久化(#158)。 */
108
+ const changeBranch = useCallback((id: string) => { setBranch(id); saveBranchPref(id); }, []);
105
109
  const [block, setBlock] = useState<BlockId>('repos');
106
110
  const [q, setQ] = useState('');
107
111
 
@@ -125,7 +129,7 @@ export default function ReposView() {
125
129
  const params = new URLSearchParams(s);
126
130
  const bid = params.get('board');
127
131
  if (!bid) return;
128
- setBranch(bid);
132
+ changeBranch(bid);
129
133
  setBlock('repos');
130
134
  if (params.get('add')) setImpBoardId(bid);
131
135
  };
@@ -259,7 +263,7 @@ export default function ReposView() {
259
263
  if (!nm) return;
260
264
  const res = await createBoard({ name: nm });
261
265
  await loadBoards();
262
- if (res && res.id) { setBranch(res.id); setBlock('repos'); setQ(''); }
266
+ if (res && res.id) { changeBranch(res.id); setBlock('repos'); setQ(''); }
263
267
  toast(`已建分组「${nm}」——把仓库加进来就是这一组的成员`);
264
268
  });
265
269
 
@@ -285,7 +289,7 @@ export default function ReposView() {
285
289
  if (kind === 'group') {
286
290
  const b = boardList.find((x) => x.key === target || x.id === target);
287
291
  if (!b) { toast('这个组已经不存在了'); return; }
288
- setBranch(b.id);
292
+ changeBranch(b.id);
289
293
  setBlock('repos');
290
294
  setQ('');
291
295
  return;
@@ -295,7 +299,7 @@ export default function ReposView() {
295
299
  const inBranch = branchBoard ? (branchBoard.repos || []).some((m) => m.key === target) : true;
296
300
  if (!inBranch) {
297
301
  const first = (row.boards || [])[0];
298
- setBranch(first ? first.id : BRANCH_MAIN);
302
+ changeBranch(first ? first.id : BRANCH_MAIN);
299
303
  }
300
304
  setBlock(row.type === 'ref' ? 'refs' : 'repos');
301
305
  setQ('');
@@ -321,7 +325,7 @@ export default function ReposView() {
321
325
  },
322
326
  getloop: (r) => setGlFor(r),
323
327
  docs: (r) => openRepoDocs(r),
324
- filter: (id) => setBranch(id),
328
+ filter: (id) => changeBranch(id),
325
329
  gotoRefRepo: (key) => { setRefRepoFocus(key); setRefOpen(true); },
326
330
  bind: (r) => setBindRepoFor(r),
327
331
  unbindBoard: unbindBoardOfRepo,
@@ -363,7 +367,7 @@ export default function ReposView() {
363
367
  <div className="title-block">
364
368
  <h2>仓库管理</h2>
365
369
  <BranchPicker branches={branches} value={branch}
366
- onChange={(id) => { setBranch(id); setQ(''); }}
370
+ onChange={(id) => { changeBranch(id); setQ(''); }}
367
371
  onCreate={createGroup} />
368
372
  </div>
369
373
  <div className="acts">
@@ -526,7 +530,7 @@ export default function ReposView() {
526
530
  boardList={boardList}
527
531
  unassigned={boards.unassigned}
528
532
  onClose={() => setBoardAdminOpen(false)}
529
- onFilter={(id) => { setBranch(id); setBlock('repos'); }}
533
+ onFilter={(id) => { changeBranch(id); setBlock('repos'); }}
530
534
  onMembers={setImpBoardId}
531
535
  onOpenDoc={openBoardDoc}
532
536
  reload={reload}
@@ -294,6 +294,26 @@ function RepoRow({ r, mode, filterBoard, refRepoChipsByRepo, acts }: {
294
294
  <td className="rp-cell-docs">
295
295
  <DocsEntry docs={r.descDocs} onOpen={() => acts.docs(r)} />
296
296
  </td>
297
+ {/* #162 所在组列只在 main / default 出现:本仓库属于哪些组;chip 点击跳到该组分支 */}
298
+ {mode === 'group' ? null : (
299
+ <td className="rp-boards">
300
+ {(r.boards || []).length ? (
301
+ (r.boards || []).map((b) => (
302
+ <button
303
+ key={b.id}
304
+ type="button"
305
+ className="rp-board-chip"
306
+ title={`跳到分组「${b.name}」`}
307
+ onClick={() => acts.filter?.(b.id)}
308
+ >
309
+ {b.name}
310
+ </button>
311
+ ))
312
+ ) : (
313
+ <span className="muted rp-refs-none">—</span>
314
+ )}
315
+ </td>
316
+ )}
297
317
  {/* 参考仓库列只在 main / default 出现:只放本仓库自己直接绑定的参考仓库 */}
298
318
  {mode === 'group' ? null : (
299
319
  <td className="rp-refs">
@@ -362,11 +382,12 @@ export default function RepoTable({ shown, devRepos, mode, filterBoard, refRepoC
362
382
  <thead>
363
383
  <tr>
364
384
  <th scope="col" style={{ width: isGroup ? '30%' : '22%' }}>仓库</th>
365
- <th scope="col" style={{ width: isGroup ? '46%' : '34%' }}>
385
+ <th scope="col" style={{ width: isGroup ? '46%' : '30%' }}>
366
386
  文档
367
387
  <span className="rp-th-hint">主篇标题 · 查看详情打开完整文档列表</span>
368
388
  </th>
369
- {isGroup ? null : <th scope="col" style={{ width: '18%' }}>参考仓库</th>}
389
+ {isGroup ? null : <th scope="col" style={{ width: '14%' }}>所在组</th>}
390
+ {isGroup ? null : <th scope="col" style={{ width: '16%' }}>参考仓库</th>}
370
391
  <th scope="col" style={{ width: '322px' }}>操作</th>
371
392
  </tr>
372
393
  </thead>
@@ -383,7 +404,7 @@ export default function RepoTable({ shown, devRepos, mode, filterBoard, refRepoC
383
404
  ))}
384
405
  {!shown.length ? (
385
406
  <tr>
386
- <td colSpan={isGroup ? 3 : 4} className="muted rp-empty">
407
+ <td colSpan={isGroup ? 3 : 5} className="muted rp-empty">
387
408
  {isGroup ? (
388
409
  <>
389
410
  这个分组里还没有仓库{' '}
@@ -52,6 +52,26 @@ export function getPromptRegistry(): Promise<any> {
52
52
  return api('/api/prompt/registry');
53
53
  }
54
54
 
55
+ /** 保存段模板(新建/编辑用户条目;POST /api/prompt/template/save)。 */
56
+ export function savePromptTemplate(input: {
57
+ segment: string;
58
+ id?: string;
59
+ name?: string;
60
+ text: string;
61
+ }): Promise<any> {
62
+ return api('/api/prompt/template/save', { method: 'POST', body: input });
63
+ }
64
+
65
+ /** 切换段启用的模板(POST /api/prompt/template/activate;id=builtin 回出厂)。 */
66
+ export function activatePromptTemplate(segment: string, id: string): Promise<any> {
67
+ return api('/api/prompt/template/activate', { method: 'POST', body: { segment, id } });
68
+ }
69
+
70
+ /** 删除段的一条用户模板(POST /api/prompt/template/delete)。 */
71
+ export function deletePromptTemplate(segment: string, id: string): Promise<any> {
72
+ return api('/api/prompt/template/delete', { method: 'POST', body: { segment, id } });
73
+ }
74
+
55
75
  /** 预览一条任务的交付(POST /api/localtasks/preview;与 CLI localtask preview 同一链路)。 */
56
76
  export function previewDelivery(input: {
57
77
  id?: number;
@@ -11,7 +11,7 @@
11
11
  // - 偏好:侧边栏/看板默认收起、隐藏仓库恢复——原在齿轮气泡里
12
12
  // - 工作区:重置布局
13
13
  // - 本机存储:附件根 / 仓库存储根——原散在云端页与仓库页弹窗
14
- // - 模板分两块(不混在一起):任务模板(任务正文骨架,纯字符串槽位)与
14
+ // - 模板分两块(不混在一起):任务模板(任务正文骨架,纯文字)与
15
15
  // 提示词模板(每区块各自的模板列表 / 启用项;编辑区下方给只读参数速查,语法教程只在 skill / docs)
16
16
  // - 任务工具:timegoal / waitgoal 的用法口径(时长在发布/编辑任务时显式给——CLI --duration 或编辑页「时间目标」栏,无全局默认)
17
17
  // (#145:「项目级设置」整 tab 删除——介绍/图标/持续 get 都与仓库管理页重复,
@@ -0,0 +1,180 @@
1
+ // 段模板编辑器(#161):出厂 builtin + 用户条目的多模板管理。
2
+ //
3
+ // #152 曾把这里改成纯只读(正文进代码);#161 用户要回编辑能力,但真相结构不变:
4
+ // - builtin 正文仍在插件类里(代码即出厂真相),不可改、只可「复制为新模板」;
5
+ // - 用户条目存 template-store(JSON),保存前走后端白名单校验(坏模板进不来);
6
+ // - 启用哪条自己挑(activeId),装配时 factory 把启用正文传给插件构造。
7
+ //
8
+ // 交互模型:editId(正在看的模板)与 activeId(该段当前生效的模板)分离——
9
+ // 看 builtin 时显示出厂正文,可复制为用户条目;看用户条目时可改可存可删可启用。
10
+ import { useEffect, useState } from 'react';
11
+ import { Button } from '../../components/button/index.jsx';
12
+ import { useToast } from '../../components/toast/index.jsx';
13
+ import {
14
+ activatePromptTemplate,
15
+ deletePromptTemplate,
16
+ savePromptTemplate,
17
+ } from './api.js';
18
+
19
+ /** 某段的用户层模板数据(/api/prompt/registry 的 segmentTemplates[id])。 */
20
+ export interface SegmentTemplates {
21
+ activeId: string;
22
+ items: { id: string; name: string; text: string; createdAt?: number }[];
23
+ }
24
+
25
+ interface EditorProps {
26
+ segment: string;
27
+ label: string;
28
+ /** 出厂正文(插件类 templates[0],不可改) */
29
+ builtinText: string;
30
+ /** 用户层数据(无记录 = 启用 builtin、无条目) */
31
+ seg: SegmentTemplates | undefined;
32
+ /** 任何落盘成功后回调(主组件刷新注册表) */
33
+ onChanged: () => void;
34
+ }
35
+
36
+ export default function PromptTemplateEditor({ segment, label, builtinText, seg, onChanged }: EditorProps) {
37
+ const toast = useToast();
38
+ const activeId = seg?.activeId || 'builtin';
39
+ const items = seg?.items || [];
40
+
41
+ // editId:正在看的模板('builtin' 或用户条目);选段/换启用时跟着 active 走
42
+ const [editId, setEditId] = useState<string>(activeId);
43
+ const [editName, setEditName] = useState<string>('');
44
+ const [editText, setEditText] = useState<string>(builtinText);
45
+ const [busy, setBusy] = useState(false);
46
+
47
+ useEffect(() => {
48
+ setEditId(activeId);
49
+ }, [segment, activeId]);
50
+
51
+ // editId / 段变化 → 同步编辑框内容(依赖 seg 对象引用:只在刷新后变,不打断打字)
52
+ useEffect(() => {
53
+ if (editId === 'builtin') {
54
+ setEditName('系统内置');
55
+ setEditText(builtinText);
56
+ } else {
57
+ const hit = (seg?.items || []).find((t) => t.id === editId);
58
+ setEditName(hit?.name || '');
59
+ setEditText(hit?.text || '');
60
+ }
61
+ // seg 引用即 items 快照(只在刷新后变,不打断打字)
62
+ }, [editId, segment, builtinText, seg]);
63
+
64
+ const isBuiltin = editId === 'builtin';
65
+ const hit = items.find((t) => t.id === editId);
66
+ const editingActive = editId === activeId;
67
+
68
+ const guard = (fn: () => Promise<void>) => {
69
+ if (busy) return;
70
+ setBusy(true);
71
+ fn()
72
+ .catch((e) => toast(String((e as Error).message || e)))
73
+ .finally(() => setBusy(false));
74
+ };
75
+
76
+ /** 保存:用户条目 = 更新;builtin = 禁止(另存为是唯一出口) */
77
+ const save = () =>
78
+ guard(async () => {
79
+ if (isBuiltin) return;
80
+ await savePromptTemplate({ segment, id: editId, name: editName, text: editText });
81
+ toast('模板已保存(启用中的修改即时生效)');
82
+ onChanged();
83
+ });
84
+
85
+ /** 另存为新模板(builtin 的唯一改法;也是「在原本基础上修改」的复制入口) */
86
+ const saveAsNew = () =>
87
+ guard(async () => {
88
+ await savePromptTemplate({ segment, name: editName === '系统内置' ? `${label} · 副本` : editName, text: editText });
89
+ toast('已存为新模板并启用');
90
+ onChanged();
91
+ });
92
+
93
+ const activate = (id: string) =>
94
+ guard(async () => {
95
+ await activatePromptTemplate(segment, id);
96
+ toast(id === 'builtin' ? '已切回出厂模板' : '已启用该模板');
97
+ onChanged();
98
+ });
99
+
100
+ const remove = () =>
101
+ guard(async () => {
102
+ if (!hit) return;
103
+ await deletePromptTemplate(segment, editId);
104
+ toast('已删除(回落出厂模板)');
105
+ onChanged();
106
+ });
107
+
108
+ return (
109
+ <div className='ppt-tpl-mgr'>
110
+ <div className='ppt-tpl-bar'>
111
+ <select
112
+ className='ppt-tpl-select'
113
+ value={editId}
114
+ aria-label={`${label} 的模板选择`}
115
+ onChange={(e) => setEditId(e.target.value)}
116
+ >
117
+ <option value='builtin'>出厂内置{activeId === 'builtin' ? '(启用中)' : ''}</option>
118
+ {items.map((t) => (
119
+ <option key={t.id} value={t.id}>
120
+ {t.name}
121
+ {activeId === t.id ? '(启用中)' : ''}
122
+ </option>
123
+ ))}
124
+ </select>
125
+ {!isBuiltin && (
126
+ <input
127
+ className='ppt-tpl-name'
128
+ value={editName}
129
+ placeholder='模板名'
130
+ aria-label='模板名'
131
+ onChange={(e) => setEditName(e.target.value)}
132
+ />
133
+ )}
134
+ {isBuiltin ? (
135
+ <Button variant='secondary' disabled={busy} title='以出厂正文为底稿存成一条用户模板(新建即启用)' onClick={saveAsNew}>
136
+ 复制为新模板
137
+ </Button>
138
+ ) : (
139
+ <>
140
+ <Button variant='primary' disabled={busy} title='保存这条模板的修改' onClick={save}>
141
+ 保存
142
+ </Button>
143
+ <Button variant='secondary' disabled={busy} title='以当前编辑内容为底稿再存一条' onClick={saveAsNew}>
144
+ 另存为
145
+ </Button>
146
+ {!editingActive && (
147
+ <Button variant='secondary' disabled={busy} title='让这一段使用这条模板' onClick={() => activate(editId)}>
148
+ 启用
149
+ </Button>
150
+ )}
151
+ {editingActive && <span className='ppt-pill is-write'>启用中</span>}
152
+ <Button variant='secondary' disabled={busy} title='删除这条用户模板(回落出厂)' onClick={remove}>
153
+ 删除
154
+ </Button>
155
+ </>
156
+ )}
157
+ {isBuiltin && activeId !== 'builtin' && (
158
+ <Button variant='secondary' disabled={busy} title='放弃用户模板,回到出厂正文' onClick={() => activate('builtin')}>
159
+ 回出厂
160
+ </Button>
161
+ )}
162
+ </div>
163
+
164
+ <textarea
165
+ className='ppt-tpl-area'
166
+ value={editText}
167
+ spellCheck={false}
168
+ aria-label={`${label} 的模板正文${isBuiltin ? '(出厂,只读)' : ''}`}
169
+ readOnly={isBuiltin}
170
+ onChange={(e) => setEditText(e.target.value)}
171
+ />
172
+
173
+ <div className='ppt-ro-note'>
174
+ {isBuiltin
175
+ ? '出厂正文在插件类里(modules/promptplug/plugins),这里只读——要改就「复制为新模板」后在副本上编辑。'
176
+ : '保存前会按本段变量白名单校验(引用了不存在的变量会被拒收)。启用中的模板对 get 交付与 CLI 实时生效。'}
177
+ </div>
178
+ </div>
179
+ );
180
+ }