nx-kv 0.48.1 → 0.48.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 (241) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/package.json +1 -1
  3. package/src/modules/auth/actions/auth-login.ts +11 -4
  4. package/src/modules/auth/actions/auth-logout.ts +9 -4
  5. package/src/modules/auth/actions/auth-me.ts +9 -4
  6. package/src/modules/auth/actions/auth-status.ts +9 -4
  7. package/src/modules/bundled/actions/bundled-get.ts +12 -4
  8. package/src/modules/bundled/actions/bundled-groups.ts +9 -4
  9. package/src/modules/bundled/actions/bundled-install.ts +13 -4
  10. package/src/modules/bundled/actions/bundled-list.ts +9 -4
  11. package/src/modules/db/actions/db-backup.ts +10 -4
  12. package/src/modules/db/actions/db-migrate.ts +10 -4
  13. package/src/modules/db/actions/db-status.ts +9 -4
  14. package/src/modules/db/actions/db-verify.ts +9 -4
  15. package/src/modules/docs/actions/doc-add.ts +12 -4
  16. package/src/modules/docs/actions/doc-attach-note.ts +11 -4
  17. package/src/modules/docs/actions/doc-attach.ts +18 -4
  18. package/src/modules/docs/actions/doc-attachments.ts +9 -4
  19. package/src/modules/docs/actions/doc-detach.ts +11 -4
  20. package/src/modules/docs/actions/doc-get.ts +9 -4
  21. package/src/modules/docs/actions/doc-list.ts +9 -4
  22. package/src/modules/docs/actions/doc-remove.ts +9 -4
  23. package/src/modules/docs/actions/doc-update.ts +12 -4
  24. package/src/modules/docs/actions/docs-bind.ts +13 -4
  25. package/src/modules/docs/actions/docs-index.ts +9 -4
  26. package/src/modules/docs/actions/docs-link.ts +14 -4
  27. package/src/modules/docs/actions/docs-notebind.ts +13 -4
  28. package/src/modules/docs/actions/docs-seed.ts +9 -4
  29. package/src/modules/file/actions/file-content.ts +10 -4
  30. package/src/modules/file/actions/file-get.ts +10 -4
  31. package/src/modules/file/actions/file-list.ts +11 -4
  32. package/src/modules/file/actions/file-orphans.ts +9 -4
  33. package/src/modules/file/actions/file-prune.ts +10 -4
  34. package/src/modules/file/actions/file-remove.ts +10 -4
  35. package/src/modules/file/actions/file-sync.ts +13 -4
  36. package/src/modules/file/actions/file-upload.ts +15 -4
  37. package/src/modules/localtask/actions/localtask-add.ts +24 -4
  38. package/src/modules/localtask/actions/localtask-attach-note.ts +13 -4
  39. package/src/modules/localtask/actions/localtask-attach.ts +22 -4
  40. package/src/modules/localtask/actions/localtask-attachments.ts +11 -4
  41. package/src/modules/localtask/actions/localtask-cancel.ts +10 -4
  42. package/src/modules/localtask/actions/localtask-cancelMany.ts +11 -4
  43. package/src/modules/localtask/actions/localtask-chain.ts +11 -4
  44. package/src/modules/localtask/actions/localtask-claim.ts +12 -4
  45. package/src/modules/localtask/actions/localtask-clone.ts +11 -4
  46. package/src/modules/localtask/actions/localtask-closeMany.ts +13 -4
  47. package/src/modules/localtask/actions/localtask-config.ts +19 -4
  48. package/src/modules/localtask/actions/localtask-detach.ts +13 -4
  49. package/src/modules/localtask/actions/localtask-done.ts +12 -4
  50. package/src/modules/localtask/actions/localtask-events.ts +12 -4
  51. package/src/modules/localtask/actions/localtask-fork.ts +11 -4
  52. package/src/modules/localtask/actions/localtask-get.ts +11 -4
  53. package/src/modules/localtask/actions/localtask-importRemote.ts +13 -4
  54. package/src/modules/localtask/actions/localtask-list.ts +9 -4
  55. package/src/modules/localtask/actions/localtask-presence.ts +9 -4
  56. package/src/modules/localtask/actions/localtask-preview.ts +13 -4
  57. package/src/modules/localtask/actions/localtask-prune.ts +10 -4
  58. package/src/modules/localtask/actions/localtask-remove.ts +12 -4
  59. package/src/modules/localtask/actions/localtask-removeMany.ts +12 -4
  60. package/src/modules/localtask/actions/localtask-reopen.ts +17 -4
  61. package/src/modules/localtask/actions/localtask-reorder.ts +15 -4
  62. package/src/modules/localtask/actions/localtask-task-restore.ts +11 -4
  63. package/src/modules/localtask/actions/localtask-timegoalLog.ts +11 -4
  64. package/src/modules/localtask/actions/localtask-topic-add.ts +10 -4
  65. package/src/modules/localtask/actions/localtask-topic-remove.ts +11 -4
  66. package/src/modules/localtask/actions/localtask-topic-removeMany.ts +12 -4
  67. package/src/modules/localtask/actions/localtask-update.ts +22 -4
  68. package/src/modules/localtask/actions/localtask-wait.ts +13 -4
  69. package/src/modules/localtask/actions/task-move.ts +21 -4
  70. package/src/modules/repos/actions/board-add.ts +10 -4
  71. package/src/modules/repos/actions/board-assign.ts +12 -4
  72. package/src/modules/repos/actions/board-export.ts +9 -4
  73. package/src/modules/repos/actions/board-get.ts +9 -4
  74. package/src/modules/repos/actions/board-import.ts +9 -4
  75. package/src/modules/repos/actions/board-list.ts +9 -4
  76. package/src/modules/repos/actions/board-note.ts +11 -4
  77. package/src/modules/repos/actions/board-prefix.ts +10 -4
  78. package/src/modules/repos/actions/board-prune.ts +11 -4
  79. package/src/modules/repos/actions/board-rekey.ts +11 -4
  80. package/src/modules/repos/actions/board-remove.ts +9 -4
  81. package/src/modules/repos/actions/board-update.ts +11 -4
  82. package/src/modules/repos/actions/repo-add.ts +17 -4
  83. package/src/modules/repos/actions/repo-bind-topics.ts +10 -4
  84. package/src/modules/repos/actions/repo-bind.ts +12 -4
  85. package/src/modules/repos/actions/repo-clone.ts +14 -4
  86. package/src/modules/repos/actions/repo-detect.ts +9 -4
  87. package/src/modules/repos/actions/repo-doc-add.ts +15 -4
  88. package/src/modules/repos/actions/repo-doc-list.ts +9 -4
  89. package/src/modules/repos/actions/repo-doc-remove.ts +10 -4
  90. package/src/modules/repos/actions/repo-export.ts +12 -4
  91. package/src/modules/repos/actions/repo-get.ts +9 -4
  92. package/src/modules/repos/actions/repo-import-diff.ts +10 -4
  93. package/src/modules/repos/actions/repo-import.ts +14 -4
  94. package/src/modules/repos/actions/repo-key-migrate.ts +9 -4
  95. package/src/modules/repos/actions/repo-key-refresh.ts +11 -4
  96. package/src/modules/repos/actions/repo-key-set.ts +11 -4
  97. package/src/modules/repos/actions/repo-knowledge.ts +10 -4
  98. package/src/modules/repos/actions/repo-list.ts +9 -4
  99. package/src/modules/repos/actions/repo-open.ts +9 -4
  100. package/src/modules/repos/actions/repo-ref-add.ts +13 -4
  101. package/src/modules/repos/actions/repo-ref-backfill.ts +10 -4
  102. package/src/modules/repos/actions/repo-ref-check.ts +9 -4
  103. package/src/modules/repos/actions/repo-ref-clone.ts +16 -4
  104. package/src/modules/repos/actions/repo-ref-note.ts +12 -4
  105. package/src/modules/repos/actions/repo-ref-of.ts +9 -4
  106. package/src/modules/repos/actions/repo-ref-sync.ts +10 -4
  107. package/src/modules/repos/actions/repo-remote-check.ts +10 -4
  108. package/src/modules/repos/actions/repo-remote-list.ts +9 -4
  109. package/src/modules/repos/actions/repo-remote-pick.ts +10 -4
  110. package/src/modules/repos/actions/repo-remote.ts +11 -4
  111. package/src/modules/repos/actions/repo-remove.ts +9 -4
  112. package/src/modules/repos/actions/repo-scan.ts +11 -4
  113. package/src/modules/repos/actions/repo-update.ts +21 -4
  114. package/src/modules/setting/actions/setting-get.ts +9 -4
  115. package/src/modules/setting/actions/setting-set.ts +12 -4
  116. package/src/modules/system/actions/bootstrap.ts +7 -4
  117. package/src/modules/system/actions/health.ts +6 -3
  118. package/src/modules/system/actions/routes.ts +11 -3
  119. package/src/modules/system/routes.ts +1 -1
  120. package/src/modules/tasktool/actions/timegoal-check.ts +11 -4
  121. package/src/modules/tasktool/actions/timegoal-clear.ts +9 -4
  122. package/src/modules/tasktool/actions/timegoal-list.ts +9 -4
  123. package/src/modules/tasktool/actions/timegoal-log.ts +9 -4
  124. package/src/modules/tasktool/actions/timegoal-prune.ts +9 -4
  125. package/src/modules/tasktool/actions/timegoal-set.ts +11 -4
  126. package/src/modules/tasktool/actions/timegoal-show.ts +10 -4
  127. package/src/modules/tasktool/actions/timegoal-update.ts +11 -4
  128. package/src/modules/templates/actions/templates-add.ts +17 -4
  129. package/src/modules/templates/actions/templates-default.ts +13 -4
  130. package/src/modules/templates/actions/templates-list.ts +11 -4
  131. package/src/modules/templates/actions/templates-remove.ts +9 -4
  132. package/src/modules/templates/actions/templates-update.ts +15 -4
  133. package/src/modules/todo/actions/group-add.ts +10 -4
  134. package/src/modules/todo/actions/group-current.ts +9 -4
  135. package/src/modules/todo/actions/group-get.ts +9 -4
  136. package/src/modules/todo/actions/group-list.ts +9 -4
  137. package/src/modules/todo/actions/group-members.ts +9 -4
  138. package/src/modules/todo/actions/group-remove.ts +9 -4
  139. package/src/modules/todo/actions/group-update.ts +11 -4
  140. package/src/modules/todo/actions/group-use.ts +9 -4
  141. package/src/modules/todo/actions/prompt-get.ts +10 -4
  142. package/src/modules/todo/actions/prompt-remove.ts +10 -4
  143. package/src/modules/todo/actions/prompt-set.ts +11 -4
  144. package/src/modules/todo/actions/todo-add.ts +11 -4
  145. package/src/modules/todo/actions/todo-archive.ts +10 -4
  146. package/src/modules/todo/actions/todo-attach.ts +17 -4
  147. package/src/modules/todo/actions/todo-attachments.ts +12 -4
  148. package/src/modules/todo/actions/todo-done.ts +13 -4
  149. package/src/modules/todo/actions/todo-freeze.ts +12 -4
  150. package/src/modules/todo/actions/todo-get.ts +12 -4
  151. package/src/modules/todo/actions/todo-list.ts +11 -4
  152. package/src/modules/todo/actions/todo-remove.ts +12 -4
  153. package/src/modules/todo/actions/todo-unfreeze.ts +12 -4
  154. package/src/modules/todo/actions/todo-update.ts +15 -4
  155. package/src/modules/todo/actions/topic-add.ts +10 -4
  156. package/src/modules/todo/actions/topic-list.ts +9 -4
  157. package/src/modules/todo/actions/topic-remove.ts +10 -4
  158. package/src/runtime/action-decorator.ts +2 -2
  159. package/src/runtime/codegen.ts +26 -41
  160. package/src/runtime/registry.ts +2 -2
  161. package/src/web/frontend/api/client.generated.ts +384 -532
  162. package/src/web/frontend/page/cloud/api.ts +99 -0
  163. package/src/web/frontend/page/cloud/index.tsx +13 -32
  164. package/src/web/frontend/page/dag/api.ts +20 -0
  165. package/src/web/frontend/page/dag/index.tsx +2 -5
  166. package/src/web/frontend/page/dir/api.ts +135 -0
  167. package/src/web/frontend/page/dir/index.tsx +37 -57
  168. package/src/web/frontend/page/dir/task-actions.ts +39 -59
  169. package/src/web/frontend/page/dir/task-chain.ts +2 -2
  170. package/src/web/frontend/page/dir/task-feedback.ts +19 -23
  171. package/src/web/frontend/page/dir/task-goal.ts +3 -3
  172. package/src/web/frontend/page/dir/task.tsx +3 -3
  173. package/src/web/frontend/page/doc/api.ts +82 -0
  174. package/src/web/frontend/page/doc/index.tsx +29 -32
  175. package/src/web/frontend/page/group/api.ts +24 -0
  176. package/src/web/frontend/page/group/index.tsx +7 -16
  177. package/src/web/frontend/page/overview/api.ts +16 -0
  178. package/src/web/frontend/page/overview/index.tsx +2 -2
  179. package/src/web/frontend/page/progress/api.ts +20 -0
  180. package/src/web/frontend/page/progress/index.tsx +3 -6
  181. package/src/web/frontend/page/refs/api.ts +14 -0
  182. package/src/web/frontend/page/refs/index.tsx +2 -4
  183. package/src/web/frontend/page/repos/api.ts +197 -0
  184. package/src/web/frontend/page/repos/bind-modals.tsx +4 -7
  185. package/src/web/frontend/page/repos/board-admin.tsx +6 -6
  186. package/src/web/frontend/page/repos/doc-search-modal.tsx +4 -4
  187. package/src/web/frontend/page/repos/index.tsx +10 -14
  188. package/src/web/frontend/page/repos/pending-section.tsx +7 -13
  189. package/src/web/frontend/page/repos/ref-panel.tsx +9 -14
  190. package/src/web/frontend/page/repos/remote-modal.tsx +4 -28
  191. package/src/web/frontend/page/repos/repo-form-modal.tsx +4 -4
  192. package/src/web/frontend/page/settings/api.ts +29 -0
  193. package/src/web/frontend/page/settings/index.tsx +3 -3
  194. package/src/web/frontend/page/settings/prompt-templates-section.tsx +4 -4
  195. package/src/web/frontend/page/settings/sidebar-section.tsx +2 -2
  196. package/src/web/public/assets/Introduction-Du_dycft.js +6 -0
  197. package/src/web/public/assets/{bar-B9WWmCpt.js → bar-B52NTf_v.js} +1 -1
  198. package/src/web/public/assets/cloud-Droja_aT.js +3 -0
  199. package/src/web/public/assets/{composer-panel-ByezS8Xv.js → composer-panel-DpiU2h50.js} +1 -1
  200. package/src/web/public/assets/dag-Ca-wjIxQ.js +1 -0
  201. package/src/web/public/assets/{deleted-panel-BcbtctNF.js → deleted-panel-K9GgfR8t.js} +1 -1
  202. package/src/web/public/assets/dir-DacRpcBt.js +5 -0
  203. package/src/web/public/assets/group-TPuU-QVc.js +2 -0
  204. package/src/web/public/assets/{index-D8MvtVAm.js → index-BkLkooKe.js} +2 -2
  205. package/src/web/public/assets/{md-history-BqZvzWiD.js → md-history-0GBWw4qr.js} +1 -1
  206. package/src/web/public/assets/overview-B3kHI66i.js +1 -0
  207. package/src/web/public/assets/progress-CdhFz0Lz.js +3 -0
  208. package/src/web/public/assets/refs-BDxfuH6R.js +1 -0
  209. package/src/web/public/assets/repos-C8jRM7wS.js +15 -0
  210. package/src/web/public/assets/{route-crumb-CWVu80du.js → route-crumb-QvahotvN.js} +1 -1
  211. package/src/web/public/assets/settings-BBcdGLTc.js +1 -0
  212. package/src/web/public/assets/{status-tag-DRl9E2Os.js → status-tag-BheHByek.js} +1 -1
  213. package/src/web/public/assets/task-CUkQaLBZ.js +11 -0
  214. package/src/web/public/assets/task-utils-_JAWRAz6.js +12 -0
  215. package/src/web/public/assets/{templates-Df__0k-F.js → templates-CbRyW3PJ.js} +1 -1
  216. package/src/web/public/assets/{tool-bar-Cv7f6p4v.js → tool-bar-BAmT-BI-.js} +1 -1
  217. package/src/web/public/index.html +1 -1
  218. package/src/modules/auth/schemas.ts +0 -27
  219. package/src/modules/bundled/schemas.ts +0 -32
  220. package/src/modules/db/schemas.ts +0 -27
  221. package/src/modules/docs/schemas.ts +0 -107
  222. package/src/modules/file/schemas.ts +0 -61
  223. package/src/modules/localtask/schemas.ts +0 -310
  224. package/src/modules/repos/schemas.ts +0 -310
  225. package/src/modules/setting/schemas.ts +0 -18
  226. package/src/modules/system/schemas.ts +0 -30
  227. package/src/modules/tasktool/schemas.ts +0 -52
  228. package/src/modules/templates/schemas.ts +0 -50
  229. package/src/modules/todo/schemas.ts +0 -177
  230. package/src/web/public/assets/Introduction-aQCeCLrV.js +0 -6
  231. package/src/web/public/assets/cloud-C4b8SU7C.js +0 -3
  232. package/src/web/public/assets/dag-jvrjx4i7.js +0 -1
  233. package/src/web/public/assets/dir-B82XBb1J.js +0 -5
  234. package/src/web/public/assets/group-BPUOO_QM.js +0 -2
  235. package/src/web/public/assets/overview-DMihuyzh.js +0 -1
  236. package/src/web/public/assets/progress-D-rMgz3w.js +0 -3
  237. package/src/web/public/assets/refs-D21jmrn6.js +0 -1
  238. package/src/web/public/assets/repos-B94tMDGs.js +0 -15
  239. package/src/web/public/assets/settings-DgTt4JG5.js +0 -1
  240. package/src/web/public/assets/task-B2x5GoV3.js +0 -11
  241. package/src/web/public/assets/task-utils-By8gLpHY.js +0 -12
@@ -1,20 +1,25 @@
1
1
  // repo.remove —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
2
2
  //
3
- // 契约常量在 ../schemas.ts(zod);本文件只做「声明 + 实现」,业务在服务层。
3
+ // 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
4
4
  import { action } from '../../../runtime/action-decorator.js';
5
+ import { z } from 'zod';
5
6
  import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
6
- import { repoRemoveInput } from '../schemas.js';
7
7
  import * as serviceNs from '../service.js';
8
8
  const service: any = serviceNs;
9
9
 
10
- export class RepoRemoveAction extends ActionBase<typeof repoRemoveInput> {
10
+ /** repo.remove 的入参契约(CLI 与 HTTP 共用同一份)。 */
11
+ const input = z.object({
12
+ id: z.string(),
13
+ });
14
+
15
+ export class RepoRemoveAction extends ActionBase<typeof input> {
11
16
  @action({
12
17
  id: 'repo.remove',
13
18
  cli: ['repo', 'remove'],
14
19
  http: ['DELETE', '/api/repos/:id'],
15
20
  summary: '移除登记(不动磁盘文件)',
16
21
  args: ['id'],
17
- input: repoRemoveInput,
22
+ input,
18
23
  render: (r: any) => `已移除登记: ${r.name}(磁盘文件未动)`,
19
24
  })
20
25
  override async run(ctx: ActionInput<this['_input']>) {
@@ -1,22 +1,29 @@
1
1
  // repo.scan —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
2
2
  //
3
- // 契约常量在 ../schemas.ts(zod);本文件只做「声明 + 实现」,业务在服务层。
3
+ // 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
4
4
  import { action } from '../../../runtime/action-decorator.js';
5
+ import { z } from 'zod';
5
6
  import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
6
- import { repoScanInput } from '../schemas.js';
7
7
  import * as serviceNs from '../service.js';
8
8
  import { lastSeg as _lastSeg } from '../cli/render.js';
9
9
  const service: any = serviceNs;
10
10
  const lastSeg: any = _lastSeg;
11
11
 
12
- export class RepoScanAction extends ActionBase<typeof repoScanInput> {
12
+ /** repo.scan 的入参契约(CLI 与 HTTP 共用同一份)。 */
13
+ const input = z.object({
14
+ root: z.string().optional(),
15
+ depth: z.number().default(3),
16
+ 'dry-run': z.boolean().optional().describe("只列出发现的仓库,不登记"),
17
+ });
18
+
19
+ export class RepoScanAction extends ActionBase<typeof input> {
13
20
  @action({
14
21
  id: 'repo.scan',
15
22
  cli: ['repo', 'scan'],
16
23
  http: ['POST', '/api/repos/scan'],
17
24
  summary: '扫描目录发现 git 仓库;--dry-run 只列出(发现模式,不登记)',
18
25
  args: ['root'],
19
- input: repoScanInput,
26
+ input,
20
27
  render: (d: any) => {
21
28
  const head: any = `${d.dryRun ? '发现(未登记)' : '扫描'} ${d.root}: ${d.scanned} 个 git 仓库`;
22
29
  if (!d.scanned) return `${head}\n(这个深度下没有找到)`;
@@ -1,20 +1,37 @@
1
1
  // repo.update —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
2
2
  //
3
- // 契约常量在 ../schemas.ts(zod);本文件只做「声明 + 实现」,业务在服务层。
3
+ // 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
4
4
  import { action } from '../../../runtime/action-decorator.js';
5
+ import { z } from 'zod';
5
6
  import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
6
- import { repoUpdateInput } from '../schemas.js';
7
7
  import * as serviceNs from '../service.js';
8
8
  const service: any = serviceNs;
9
9
 
10
- export class RepoUpdateAction extends ActionBase<typeof repoUpdateInput> {
10
+ /** repo.update 的入参契约(CLI 与 HTTP 共用同一份)。 */
11
+ const input = z.object({
12
+ id: z.string(),
13
+ path: z.string().optional(),
14
+ name: z.string().optional(),
15
+ icon: z.string().optional().describe("项目图标(emoji 或单字符,≤8 字;留空 = 用默认图标)"),
16
+ desc: z.string().optional().describe("(已废弃)描述是文档:改正文用 docs set,换绑用 docs bind —— 传了会报错"),
17
+ notes: z.string().optional(),
18
+ type: z.enum(["dev", "ref"]).optional().describe("dev=开发仓库,ref=参考仓库"),
19
+ remote: z.string().optional().describe("远程 git 地址"),
20
+ key: z.string().optional().describe("自定义 key(给了就视为 keyCustom)"),
21
+ 'key-custom': z.boolean().optional().describe("key 是否自定义(true=不跟随 remote)"),
22
+ 'get-loop': z.enum(["on", "off"]).optional().describe("持续 get 开关"),
23
+ 'get-loop-minutes': z.number().optional().describe("无任务时的阻塞窗口(分钟,默认 10,上限 600s 夹制)"),
24
+ 'get-loop-template': z.string().optional().describe("领到任务时追加的「继续 get」模板——整体替换为这一条(多条在设置面板按条增删;占位符 {{task.id}}/{{task.text}} 等;置空 = 用默认模板)"),
25
+ });
26
+
27
+ export class RepoUpdateAction extends ActionBase<typeof input> {
11
28
  @action({
12
29
  id: 'repo.update',
13
30
  cli: ['repo', 'update'],
14
31
  http: ['PATCH', '/api/repos/:id'],
15
32
  summary: '修改仓库路径 / 名称 / 备注 / 类型 / 远程地址 / key;--get-loop* 配置项目级「持续 get」(waitgoal:该项目 get 无任务时阻塞等人回填 + 交付文本带继续 get 模板)。描述已改为文档,不再经这里改',
16
33
  args: ['id'],
17
- input: repoUpdateInput,
34
+ input,
18
35
  render: (r: any) => `已更新: ${r.name}(key: ${r.key})`,
19
36
  })
20
37
  override async run(ctx: ActionInput<this['_input']>) {
@@ -1,19 +1,24 @@
1
1
  // setting.get —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
2
2
  //
3
- // 契约常量在 ../schemas.ts(zod);本文件只做「声明 + 实现」,业务在服务层。
3
+ // 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
4
4
  import { action } from '../../../runtime/action-decorator.js';
5
+ import { z } from 'zod';
5
6
  import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
6
- import { settingGetInput } from '../schemas.js';
7
7
  import * as serviceNs from '../service.js';
8
8
  const service: any = serviceNs;
9
9
 
10
- export class SettingGetAction extends ActionBase<typeof settingGetInput> {
10
+ /** setting.get 的入参契约(CLI 与 HTTP 共用同一份)。 */
11
+ const input = z.object({
12
+
13
+ });
14
+
15
+ export class SettingGetAction extends ActionBase<typeof input> {
11
16
  @action({
12
17
  id: 'setting.get',
13
18
  cli: ['setting', 'get'],
14
19
  http: ['GET', '/api/setting'],
15
20
  summary: '读本机设置(附件自动下载、附件目录、参考仓库存储根)',
16
- input: settingGetInput,
21
+ input,
17
22
  render: (d: any) => service.renderSettings(d),
18
23
  })
19
24
  override async run(_ctx: ActionInput<this['_input']>) {
@@ -1,19 +1,27 @@
1
1
  // setting.set —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
2
2
  //
3
- // 契约常量在 ../schemas.ts(zod);本文件只做「声明 + 实现」,业务在服务层。
3
+ // 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
4
4
  import { action } from '../../../runtime/action-decorator.js';
5
+ import { z } from 'zod';
5
6
  import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
6
- import { settingSetInput } from '../schemas.js';
7
7
  import * as serviceNs from '../service.js';
8
8
  const service: any = serviceNs;
9
9
 
10
- export class SettingSetAction extends ActionBase<typeof settingSetInput> {
10
+ /** setting.set 的入参契约(CLI 与 HTTP 共用同一份)。 */
11
+ const input = z.object({
12
+ autoSyncAttachments: z.boolean().optional().describe("读任务时自动把附件下载到本地"),
13
+ attachmentsDir: z.string().optional().describe("附件本地目录(空 = ~/.nx-kv/attachments/<工作空间>/)"),
14
+ gitRepoRoot: z.string().optional().describe("参考仓库存储根目录(非 C 盘;空 = clone 参考仓库被拒绝)"),
15
+ gitDevRoot: z.string().optional().describe("导入布局时开发仓库的默认克隆根(空 = 只登记不克隆)"),
16
+ });
17
+
18
+ export class SettingSetAction extends ActionBase<typeof input> {
11
19
  @action({
12
20
  id: 'setting.set',
13
21
  cli: ['setting', 'set'],
14
22
  http: ['POST', '/api/setting'],
15
23
  summary: '改本机设置(只改传入项)',
16
- input: settingSetInput,
24
+ input,
17
25
  render: (d: any) => service.renderSettings(d),
18
26
  })
19
27
  override async run(ctx: ActionInput<this['_input']>) {
@@ -1,26 +1,29 @@
1
1
  // system.bootstrap —— 面板启动上下文:版本 / 登录态 / 工作空间 / 命令表。
2
2
  //
3
- // 「一条 action 一个文件」:声明(@action 元数据)与实现同文件;契约在 ../schemas.ts。
3
+ // 「一条 action 一个文件」:声明(@action 元数据)、契约(zod)与实现同文件。
4
4
  // 依赖经 IoC 容器取(this.deps.get('config'))——测试可换一整个容器,不必改构造参数。
5
5
  import { readFileSync } from 'node:fs';
6
+ import { z } from 'zod';
6
7
  import { action } from '../../../runtime/action-decorator.js';
7
8
  import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
8
9
  import { commandTable, type CommandEntry } from '../../../core/command-table.js';
9
10
  import { APP_NAME, DEFAULT_PORT } from '../../../core/paths.js';
10
- import { systemBootstrapInput } from '../schemas.js';
11
11
 
12
12
  /** package.json 的版本号(只读一次;与 cli.ts 各读各的,避免引入跨层依赖)。 */
13
13
  const VERSION: string = JSON.parse(
14
14
  readFileSync(new URL('../../../../package.json', import.meta.url), 'utf8'),
15
15
  ).version;
16
16
 
17
- export class BootstrapAction extends ActionBase<typeof systemBootstrapInput> {
17
+ /** system.bootstrap 的入参契约(CLI 与 HTTP 共用同一份)。 */
18
+ const input = z.object({});
19
+
20
+ export class BootstrapAction extends ActionBase<typeof input> {
18
21
  @action({
19
22
  id: 'system.bootstrap',
20
23
  cli: ['bootstrap'],
21
24
  http: ['GET', '/api/bootstrap'],
22
25
  summary: '聚合上下文:版本 / 登录态 / 工作空间 / 命令表',
23
- input: systemBootstrapInput,
26
+ input,
24
27
  })
25
28
  override async run(_ctx: ActionInput<this['_input']>): Promise<{
26
29
  app: { name: string; version: string };
@@ -3,9 +3,9 @@
3
3
  // 依赖经 IoC 容器取(config);后端探测是**只读**的 /api/v1/user/info,
4
4
  // 失败不算错误(health 的语义是「如实报告」,错误文案进 backendError 字段)。
5
5
  import { readFileSync } from 'node:fs';
6
+ import { z } from 'zod';
6
7
  import { action } from '../../../runtime/action-decorator.js';
7
8
  import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
8
- import { systemHealthInput } from '../schemas.js';
9
9
 
10
10
  const VERSION: string = JSON.parse(
11
11
  readFileSync(new URL('../../../../package.json', import.meta.url), 'utf8'),
@@ -21,13 +21,16 @@ export interface HealthReport {
21
21
  backendError: string;
22
22
  }
23
23
 
24
- export class HealthAction extends ActionBase<typeof systemHealthInput> {
24
+ /** system.health 的入参契约(CLI 与 HTTP 共用同一份)。 */
25
+ const input = z.object({});
26
+
27
+ export class HealthAction extends ActionBase<typeof input> {
25
28
  @action({
26
29
  id: 'system.health',
27
30
  cli: ['health'],
28
31
  http: ['GET', '/api/health'],
29
32
  summary: '健康检查(本机配置 + 后端可达性)',
30
- input: systemHealthInput,
33
+ input,
31
34
  })
32
35
  override async run(_ctx: ActionInput<this['_input']>): Promise<HealthReport> {
33
36
  const config = this.deps.get('config');
@@ -5,18 +5,26 @@
5
5
  // 看到的表与 `help --json` 看到的完全同源同长。过滤逻辑在 ../routes.ts(纯函数),
6
6
  // 这里只做声明与装配。
7
7
  import { action } from '../../../runtime/action-decorator.js';
8
+ import { z } from 'zod';
8
9
  import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
9
10
  import { commandTable, type CommandEntry } from '../../../core/command-table.js';
10
11
  import { filterRoutes, renderRoutes } from '../routes.js';
11
- import { systemRoutesInput } from '../schemas.js';
12
12
 
13
- export class RoutesAction extends ActionBase<typeof systemRoutesInput> {
13
+ /** system.routes 的入参契约(CLI 与 HTTP 共用同一份)。 */
14
+ const input = z.object({
15
+ // 模块 id 过滤(正查)
16
+ module: z.string().optional(),
17
+ // `METHOD /api/path`(反查,:param 视为通配)
18
+ http: z.string().optional(),
19
+ });
20
+
21
+ export class RoutesAction extends ActionBase<typeof input> {
14
22
  @action({
15
23
  id: 'system.routes',
16
24
  cli: ['routes'],
17
25
  http: null, // 纯 CLI:对照表本身没有 HTTP 端点(面板从 /api/bootstrap 拿同一张表)
18
26
  summary: '命令 ↔ 路由对照表(--module 过滤;--http 反查命令)',
19
- input: systemRoutesInput,
27
+ input,
20
28
  render: (list) => renderRoutes(list as CommandEntry[]),
21
29
  })
22
30
  override async run(ctx: ActionInput<this['_input']>): Promise<CommandEntry[]> {
@@ -8,7 +8,7 @@
8
8
  import { badInput, notFound } from '../../core/errors.js';
9
9
  import type { CommandEntry } from '../../core/command-table.js';
10
10
 
11
- /** routes 的输入(--module / --http,schema 见 ../schemas.ts)。 */
11
+ /** routes 的输入(--module / --http,schema 见本文件下方)。 */
12
12
  export interface RoutesCtx {
13
13
  module?: string;
14
14
  http?: string;
@@ -1,22 +1,29 @@
1
1
  // timegoal.check —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
2
2
  //
3
- // 契约常量在 ../schemas.ts(zod);本文件只做「声明 + 实现」,业务在服务层。
3
+ // 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
4
4
  import { action } from '../../../runtime/action-decorator.js';
5
+ import { z } from 'zod';
5
6
  import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
6
- import { timegoalCheckInput } from '../schemas.js';
7
7
  import * as serviceNs from '../timegoal.js';
8
8
  import { badInput as _badInput } from '../../../core/errors.js';
9
9
  import { renderCheck } from '../support.js';
10
10
  const service: any = serviceNs;
11
11
  const badInput: any = _badInput;
12
12
 
13
- export class TimegoalCheckAction extends ActionBase<typeof timegoalCheckInput> {
13
+ /** timegoal.check 的入参契约(CLI 与 HTTP 共用同一份)。 */
14
+ const input = z.object({
15
+ cwd: z.string().optional().describe("工作目录(与 --task 二选一)"),
16
+ task: z.string().optional().describe("任务级 goal key(task:<topicKey>:<taskId>;带时长任务领取时自带)"),
17
+ summary: z.string().describe("当前现状(每次 check 记录到日志,≤2000 字)"),
18
+ });
19
+
20
+ export class TimegoalCheckAction extends ActionBase<typeof input> {
14
21
  @action({
15
22
  id: 'timegoal.check',
16
23
  cli: ['timegoal', 'check'],
17
24
  http: ['GET', '/api/timegoals/check'],
18
25
  summary: '时间运算 + 原文回显 prompt + 写入一次状态日志;每次必须提供当前现状 --summary',
19
- input: timegoalCheckInput,
26
+ input,
20
27
  render: renderCheck,
21
28
  })
22
29
  override async run(ctx: ActionInput<this['_input']>) {
@@ -1,20 +1,25 @@
1
1
  // timegoal.clear —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
2
2
  //
3
- // 契约常量在 ../schemas.ts(zod);本文件只做「声明 + 实现」,业务在服务层。
3
+ // 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
4
4
  import { action } from '../../../runtime/action-decorator.js';
5
+ import { z } from 'zod';
5
6
  import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
6
- import { timegoalClearInput } from '../schemas.js';
7
7
  import * as serviceNs from '../timegoal.js';
8
8
  import { renderClear } from '../support.js';
9
9
  const service: any = serviceNs;
10
10
 
11
- export class TimegoalClearAction extends ActionBase<typeof timegoalClearInput> {
11
+ /** timegoal.clear 的入参契约(CLI 与 HTTP 共用同一份)。 */
12
+ const input = z.object({
13
+ cwd: z.string().describe("工作目录(与 timegoal 一对一)"),
14
+ });
15
+
16
+ export class TimegoalClearAction extends ActionBase<typeof input> {
12
17
  @action({
13
18
  id: 'timegoal.clear',
14
19
  cli: ['timegoal', 'clear'],
15
20
  http: ['DELETE', '/api/timegoals'],
16
21
  summary: '清空本目录 timegoal(无则 no_goal,不抛错)',
17
- input: timegoalClearInput,
22
+ input,
18
23
  render: renderClear,
19
24
  })
20
25
  override async run(ctx: ActionInput<this['_input']>) {
@@ -1,20 +1,25 @@
1
1
  // timegoal.list —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
2
2
  //
3
- // 契约常量在 ../schemas.ts(zod);本文件只做「声明 + 实现」,业务在服务层。
3
+ // 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
4
4
  import { action } from '../../../runtime/action-decorator.js';
5
+ import { z } from 'zod';
5
6
  import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
6
- import { timegoalListInput } from '../schemas.js';
7
7
  import * as serviceNs from '../timegoal.js';
8
8
  import { renderList } from '../support.js';
9
9
  const service: any = serviceNs;
10
10
 
11
- export class TimegoalListAction extends ActionBase<typeof timegoalListInput> {
11
+ /** timegoal.list 的入参契约(CLI 与 HTTP 共用同一份)。 */
12
+ const input = z.object({
13
+
14
+ });
15
+
16
+ export class TimegoalListAction extends ActionBase<typeof input> {
12
17
  @action({
13
18
  id: 'timegoal.list',
14
19
  cli: ['timegoal', 'list'],
15
20
  http: ['GET', '/api/timegoals/all'],
16
21
  summary: '列出所有有 timegoal 的目录(按截止升序;已到点的单列在归档区)',
17
- input: timegoalListInput,
22
+ input,
18
23
  render: renderList,
19
24
  })
20
25
  override async run(_ctx: ActionInput<this['_input']>) {
@@ -1,20 +1,25 @@
1
1
  // timegoal.log —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
2
2
  //
3
- // 契约常量在 ../schemas.ts(zod);本文件只做「声明 + 实现」,业务在服务层。
3
+ // 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
4
4
  import { action } from '../../../runtime/action-decorator.js';
5
+ import { z } from 'zod';
5
6
  import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
6
- import { timegoalLogInput } from '../schemas.js';
7
7
  import * as serviceNs from '../timegoal.js';
8
8
  import { fmtDur } from '../support.js';
9
9
  const service: any = serviceNs;
10
10
 
11
- export class TimegoalLogAction extends ActionBase<typeof timegoalLogInput> {
11
+ /** timegoal.log 的入参契约(CLI 与 HTTP 共用同一份)。 */
12
+ const input = z.object({
13
+ cwd: z.string().describe("工作目录(与 timegoal 一对一)"),
14
+ });
15
+
16
+ export class TimegoalLogAction extends ActionBase<typeof input> {
12
17
  @action({
13
18
  id: 'timegoal.log',
14
19
  cli: ['timegoal', 'log'],
15
20
  http: ['GET', '/api/timegoals/log'],
16
21
  summary: '查看本目录 timegoal 的检查日志(每轮 check 的现状)',
17
- input: timegoalLogInput,
22
+ input,
18
23
  render: (d: any) => {
19
24
  if (!d.hasGoal) return `[timegoal] 主题「${d.name}」暂无目标,也没有日志。`;
20
25
  if (!d.count) return `[timegoal] 主题「${d.name}」暂无检查日志。`;
@@ -1,19 +1,24 @@
1
1
  // timegoal.prune —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
2
2
  //
3
- // 契约常量在 ../schemas.ts(zod);本文件只做「声明 + 实现」,业务在服务层。
3
+ // 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
4
4
  import { action } from '../../../runtime/action-decorator.js';
5
+ import { z } from 'zod';
5
6
  import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
6
- import { timegoalPruneInput } from '../schemas.js';
7
7
  import * as serviceNs from '../timegoal.js';
8
8
  const service: any = serviceNs;
9
9
 
10
- export class TimegoalPruneAction extends ActionBase<typeof timegoalPruneInput> {
10
+ /** timegoal.prune 的入参契约(CLI 与 HTTP 共用同一份)。 */
11
+ const input = z.object({
12
+
13
+ });
14
+
15
+ export class TimegoalPruneAction extends ActionBase<typeof input> {
11
16
  @action({
12
17
  id: 'timegoal.prune',
13
18
  cli: ['timegoal', 'prune'],
14
19
  http: ['POST', '/api/timegoals/prune'],
15
20
  summary: '彻底清除已到点 / 已归档的时间目标(到点本身已自动归档,这里是连归档区一起清)',
16
- input: timegoalPruneInput,
21
+ input,
17
22
  render: (d: any) =>
18
23
  d.count
19
24
  ? `已彻底清除 ${d.count} 个到点/已归档的时间目标:\n` +
@@ -1,20 +1,27 @@
1
1
  // timegoal.set —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
2
2
  //
3
- // 契约常量在 ../schemas.ts(zod);本文件只做「声明 + 实现」,业务在服务层。
3
+ // 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
4
4
  import { action } from '../../../runtime/action-decorator.js';
5
+ import { z } from 'zod';
5
6
  import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
6
- import { timegoalSetInput } from '../schemas.js';
7
7
  import * as serviceNs from '../timegoal.js';
8
8
  import { renderSet } from '../support.js';
9
9
  const service: any = serviceNs;
10
10
 
11
- export class TimegoalSetAction extends ActionBase<typeof timegoalSetInput> {
11
+ /** timegoal.set 的入参契约(CLI 与 HTTP 共用同一份)。 */
12
+ const input = z.object({
13
+ cwd: z.string().describe("工作目录(与 timegoal 一对一)"),
14
+ duration: z.string().describe("持续时长(10800 秒 / 5h / 90m / 2d / 5小时)"),
15
+ prompt: z.string().describe("完整全局提示词(≤20000 字,每轮 check 会原文回显)"),
16
+ });
17
+
18
+ export class TimegoalSetAction extends ActionBase<typeof input> {
12
19
  @action({
13
20
  id: 'timegoal.set',
14
21
  cli: ['timegoal', 'set'],
15
22
  http: ['POST', '/api/timegoals'],
16
23
  summary: '为本目录设置/替换 timegoal:duration + 完整全局提示词(原文固化到 store)',
17
- input: timegoalSetInput,
24
+ input,
18
25
  render: renderSet,
19
26
  })
20
27
  override async run(ctx: ActionInput<this['_input']>) {
@@ -1,22 +1,28 @@
1
1
  // timegoal.show —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
2
2
  //
3
- // 契约常量在 ../schemas.ts(zod);本文件只做「声明 + 实现」,业务在服务层。
3
+ // 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
4
4
  import { action } from '../../../runtime/action-decorator.js';
5
+ import { z } from 'zod';
5
6
  import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
6
- import { timegoalShowInput } from '../schemas.js';
7
7
  import * as serviceNs from '../timegoal.js';
8
8
  import { badInput as _badInput } from '../../../core/errors.js';
9
9
  import { renderShow } from '../support.js';
10
10
  const service: any = serviceNs;
11
11
  const badInput: any = _badInput;
12
12
 
13
- export class TimegoalShowAction extends ActionBase<typeof timegoalShowInput> {
13
+ /** timegoal.show 的入参契约(CLI 与 HTTP 共用同一份)。 */
14
+ const input = z.object({
15
+ cwd: z.string().optional().describe("工作目录(与 --task 二选一)"),
16
+ task: z.string().optional().describe("任务级 goal key(task:<topicKey>:<taskId>)"),
17
+ });
18
+
19
+ export class TimegoalShowAction extends ActionBase<typeof input> {
14
20
  @action({
15
21
  id: 'timegoal.show',
16
22
  cli: ['timegoal', 'show'],
17
23
  http: ['GET', '/api/timegoals'],
18
24
  summary: '查看当前 timegoal(不算时间):--cwd 目录级,--task 任务级(key 在领取交付里自带)',
19
- input: timegoalShowInput,
25
+ input,
20
26
  render: renderShow,
21
27
  })
22
28
  override async run(ctx: ActionInput<this['_input']>) {
@@ -1,20 +1,27 @@
1
1
  // timegoal.update —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
2
2
  //
3
- // 契约常量在 ../schemas.ts(zod);本文件只做「声明 + 实现」,业务在服务层。
3
+ // 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
4
4
  import { action } from '../../../runtime/action-decorator.js';
5
+ import { z } from 'zod';
5
6
  import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
6
- import { timegoalUpdateInput } from '../schemas.js';
7
7
  import * as serviceNs from '../timegoal.js';
8
8
  import { renderUpdate } from '../support.js';
9
9
  const service: any = serviceNs;
10
10
 
11
- export class TimegoalUpdateAction extends ActionBase<typeof timegoalUpdateInput> {
11
+ /** timegoal.update 的入参契约(CLI 与 HTTP 共用同一份)。 */
12
+ const input = z.object({
13
+ cwd: z.string().describe("工作目录(与 timegoal 一对一)"),
14
+ prompt: z.string().describe("新版提示词(≤20000 字)"),
15
+ duration: z.string().optional().describe("同时改时长(10800 / 5h / 90m / 2d);省略则时长不变"),
16
+ });
17
+
18
+ export class TimegoalUpdateAction extends ActionBase<typeof input> {
12
19
  @action({
13
20
  id: 'timegoal.update',
14
21
  cli: ['timegoal', 'update'],
15
22
  http: ['PATCH', '/api/timegoals'],
16
23
  summary: '更新本目录 timegoal 的提示词(可选同时改时长,--duration;保留起点,不重置计时)',
17
- input: timegoalUpdateInput,
24
+ input,
18
25
  render: renderUpdate,
19
26
  })
20
27
  override async run(ctx: ActionInput<this['_input']>) {
@@ -1,22 +1,35 @@
1
1
  // templates.add —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
2
2
  //
3
- // 契约常量在 ../schemas.ts(zod);本文件只做「声明 + 实现」,业务在服务层。
3
+ // 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
4
4
  import { action } from '../../../runtime/action-decorator.js';
5
+ import { z } from 'zod';
5
6
  import { ActionBase, type ActionInput, type ActionRunMeta } from '../../../runtime/action-base.js';
6
- import { templatesAddInput } from '../schemas.js';
7
7
  import * as serviceNs from '../service.js';
8
8
  import { } from 'node:path';
9
9
  import { parseScope, topicFromCwd } from '../support.js';
10
10
  const service: any = serviceNs;
11
11
 
12
- export class TemplatesAddAction extends ActionBase<typeof templatesAddInput> {
12
+ /** templates.add 的入参契约(CLI 与 HTTP 共用同一份)。 */
13
+ const input = z.object({
14
+ name: z.string(),
15
+ body: z.string().optional().describe("模板正文(Markdown;首行写 `# 标题` 则提交时作为任务标题)"),
16
+ bodyFile: z.string().optional().describe("从文件读模板正文(--body 优先);`-` = 读标准输入"),
17
+ 'body-file': z.string().optional().describe("同 --bodyFile(连字符写法)"),
18
+ setDefault: z.boolean().optional().describe("新增后立即设为默认模板"),
19
+ 'set-default': z.boolean().optional().describe("同 --setDefault(连字符写法)"),
20
+ scope: z.unknown().optional().describe("可见域(#128/#131):* 全局 / topic:<key> 队列 / repo:<key> 项目 / group:<key> 组——JSON 数组或逗号短写;缺省空(未配置,不默认全局);带 --topic 时默认仅该主题"),
21
+ topic: z.string().optional().describe("创建主题锚(topics.key):默认仅该主题可见,origin_topic 记它"),
22
+ cwd: z.string().optional().describe("同 --topic,但给工作目录(按目录派生主题 key)"),
23
+ });
24
+
25
+ export class TemplatesAddAction extends ActionBase<typeof input> {
13
26
  @action({
14
27
  id: 'templates.add',
15
28
  cli: ['template', 'add'],
16
29
  http: ['POST', '/api/templates'],
17
30
  summary: '新增任务模板(--body 给 Markdown 正文;多行正文用 --body-file <文件> 或 --body - 读管道;--setDefault 同时设为默认;--scope 设可见域、--topic 记创建主题并默认仅该主题可见)',
18
31
  args: ['name'],
19
- input: templatesAddInput,
32
+ input,
20
33
  render: (d: any) =>
21
34
  `已新增模板「${d.template.name}」(${d.template.id})${d.defaultId === d.template.id ? ',并设为默认' : ''}${
22
35
  Array.isArray(d.template.scope) && !d.template.scope.includes('*')
@@ -1,22 +1,31 @@
1
1
  // templates.default —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
2
2
  //
3
- // 契约常量在 ../schemas.ts(zod);本文件只做「声明 + 实现」,业务在服务层。
3
+ // 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
4
4
  import { action } from '../../../runtime/action-decorator.js';
5
+ import { z } from 'zod';
5
6
  import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
6
- import { templatesDefaultInput } from '../schemas.js';
7
7
  import * as serviceNs from '../service.js';
8
8
  import { } from 'node:path';
9
9
  import { parseValues, parseScope } from '../support.js';
10
10
  const service: any = serviceNs;
11
11
 
12
- export class TemplatesDefaultAction extends ActionBase<typeof templatesDefaultInput> {
12
+ /** templates.default 的入参契约(CLI 与 HTTP 共用同一份)。 */
13
+ const input = z.object({
14
+ id: z.string(),
15
+ name: z.string().optional().describe("新名字(配合 --body/--scope 时改默认模板本身)"),
16
+ body: z.string().optional().describe("新正文(配合时改默认模板本身)"),
17
+ values: z.unknown().optional().describe("槽位值 JSON(CLI 传 JSON 串;HTTP 可直接给对象)"),
18
+ scope: z.unknown().optional().describe("可见域(#128):* / topic:<key> / repo:<key> / group:<key>,JSON 数组或逗号短写"),
19
+ });
20
+
21
+ export class TemplatesDefaultAction extends ActionBase<typeof input> {
13
22
  @action({
14
23
  id: 'templates.default',
15
24
  cli: ['template', 'default'],
16
25
  http: ['PATCH', '/api/templates/default'],
17
26
  summary: '设置默认模板(新建页的起始正文换成它);带 --body/--name/--scope 则改默认模板本身',
18
27
  args: ['id'],
19
- input: templatesDefaultInput,
28
+ input,
20
29
  render: (d: any) => `默认模板已设为「${d.template.name}」(${d.template.id})`,
21
30
  })
22
31
  override async run(ctx: ActionInput<this['_input']>) {