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
package/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  本文件记录对外可见的变更。格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/)。
4
4
 
5
+ ## [0.48.2] - 2026-11-12 zod 契约内联进 action 文件(#178 第 4 轮)
6
+
7
+ ### Changed
8
+
9
+ - **不再有独立的 `schemas.ts`**:每条 action 的 zod 契约(运行期契约)直接声明在
10
+ 自己的 action 文件里,模块私有、就在类上方,命名为 `input`。12 个 `schemas.ts`
11
+ (1201 行)随之删除,154 个 action 文件各带一份契约。
12
+ 契约内容**逐字保留**——`.describe()` 是 CLI 用法串与 help 文案的来源,动了就改口径。
13
+ - **前端入参类型改为从 action 类反推**(`z.input<InstanceType<typeof XAction>['_input']>`):
14
+ 类型经基类泛型模板流到前端,契约常量降级为「文件内的实现细节」,
15
+ 生成物不再 import 后端契约文件。
16
+ - **删掉 `<camelCase(actionId)>Input` 命名约定**:旧方案靠约定拼 import 名,
17
+ 约定破了会生成指向不存在符号的代码;现在约定不再存在,也就没有破的可能。
18
+
19
+ ### Notes
20
+
21
+ - 纯结构调整,对外行为不变(契约内容与位置语义不变:字段、用法串、help 文案均不变)。
22
+ - 验证:node 侧 strict 0 错误 / 生成物及传递依赖 web 编译 0 错误 / eslint 0 error /
23
+ unit 906 / smoke 194。
24
+
5
25
  ## [0.48.1] - 2026-11-11 action 入参泛型化(#177 第 3 轮)
6
26
 
7
27
  ### Changed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx-kv",
3
- "version": "0.48.1",
3
+ "version": "0.48.2",
4
4
  "description": "nx-kv — KV 清单管理中枢(远程)+ 本机本地任务队列(localtask):serve 驱动 CLI 与 Web 面板,同源同构,附带可安装 skill 供 agent 提交 / 领取 / 阻塞接收任务",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,21 +1,28 @@
1
1
  // auth.login —— 由 .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 { authLoginInput } from '../schemas.js';
7
7
  import { configPathFromEnv as _configPathFromEnv } from '../../../core/config.js';
8
8
  import { doLogin } from '../support.js';
9
9
  const configPathFromEnv: any = _configPathFromEnv;
10
10
 
11
- export class AuthLoginAction extends ActionBase<typeof authLoginInput> {
11
+ /** auth.login 的入参契约(CLI 与 HTTP 共用同一份)。 */
12
+ const input = z.object({
13
+ email: z.string(),
14
+ password: z.string().optional().describe("密码(省略则交互式隐藏输入)"),
15
+ baseUrl: z.string().optional().describe("后端地址,覆盖默认"),
16
+ });
17
+
18
+ export class AuthLoginAction extends ActionBase<typeof input> {
12
19
  @action({
13
20
  id: 'auth.login',
14
21
  cli: ['auth', 'login'],
15
22
  http: ['POST', '/api/auth/login'],
16
23
  summary: '登录并保存 token 到本机配置',
17
24
  args: ['email'],
18
- input: authLoginInput,
25
+ input,
19
26
  render: (d: any) => `已登录: ${d.email}(userId=${d.userId})\n配置: ${configPathFromEnv()}`,
20
27
  })
21
28
  override async run(ctx: ActionInput<this['_input']>) {
@@ -1,20 +1,25 @@
1
1
  // auth.logout —— 由 .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 { authLogoutInput } from '../schemas.js';
7
7
  import { loadConfig as _loadConfig, saveConfig as _saveConfig } from '../../../core/config.js';
8
8
  const loadConfig: any = _loadConfig;
9
9
  const saveConfig: any = _saveConfig;
10
10
 
11
- export class AuthLogoutAction extends ActionBase<typeof authLogoutInput> {
11
+ /** auth.logout 的入参契约(CLI 与 HTTP 共用同一份)。 */
12
+ const input = z.object({
13
+
14
+ });
15
+
16
+ export class AuthLogoutAction extends ActionBase<typeof input> {
12
17
  @action({
13
18
  id: 'auth.logout',
14
19
  cli: ['auth', 'logout'],
15
20
  http: ['POST', '/api/auth/logout'],
16
21
  summary: '清除本机保存的 token',
17
- input: authLogoutInput,
22
+ input,
18
23
  render: (d: any) => (d.was ? `已登出(原账号 ${d.was})` : '本就未登录'),
19
24
  })
20
25
  override async run(_ctx: ActionInput<this['_input']>) {
@@ -1,21 +1,26 @@
1
1
  // auth.me —— 由 .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 { authMeInput } from '../schemas.js';
7
7
  import { requireAuth as _requireAuth } from '../../../core/config.js';
8
8
  import { userInfo as _userInfo } from '../../../core/kvapi.js';
9
9
  const requireAuth: any = _requireAuth;
10
10
  const userInfo: any = _userInfo;
11
11
 
12
- export class AuthMeAction extends ActionBase<typeof authMeInput> {
12
+ /** auth.me 的入参契约(CLI 与 HTTP 共用同一份)。 */
13
+ const input = z.object({
14
+
15
+ });
16
+
17
+ export class AuthMeAction extends ActionBase<typeof input> {
13
18
  @action({
14
19
  id: 'auth.me',
15
20
  cli: ['auth', 'me'],
16
21
  http: ['GET', '/api/auth/me'],
17
22
  summary: '向后端确认身份(验证 token 是否仍有效)',
18
- input: authMeInput,
23
+ input,
19
24
  render: (d: any) => JSON.stringify(d, null, 2),
20
25
  })
21
26
  override async run(_ctx: ActionInput<this['_input']>) {
@@ -1,20 +1,25 @@
1
1
  // auth.status —— 由 .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 { authStatusInput } from '../schemas.js';
7
7
  import { loadConfig as _loadConfig, configPathFromEnv as _configPathFromEnv } from '../../../core/config.js';
8
8
  const loadConfig: any = _loadConfig;
9
9
  const configPathFromEnv: any = _configPathFromEnv;
10
10
 
11
- export class AuthStatusAction extends ActionBase<typeof authStatusInput> {
11
+ /** auth.status 的入参契约(CLI 与 HTTP 共用同一份)。 */
12
+ const input = z.object({
13
+
14
+ });
15
+
16
+ export class AuthStatusAction extends ActionBase<typeof input> {
12
17
  @action({
13
18
  id: 'auth.status',
14
19
  cli: ['auth', 'status'],
15
20
  http: ['GET', '/api/auth'],
16
21
  summary: '查看本机登录态(不请求后端,离线可用)',
17
- input: authStatusInput,
22
+ input,
18
23
  render: (d: any) =>
19
24
  d.loggedIn
20
25
  ? `已登录: ${d.email}(userId=${d.userId})\n后端: ${d.baseUrl}\n工作空间: ${d.groupId > 0 ? d.groupId : '默认组'}`
@@ -1,21 +1,29 @@
1
1
  // bundled.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 { bundledGetInput } from '../schemas.js';
7
7
  import * as serviceNs from '../service.js';
8
8
  import { exclusive, renderContent } from '../support.js';
9
9
  const service: any = serviceNs;
10
10
 
11
- export class BundledGetAction extends ActionBase<typeof bundledGetInput> {
11
+ /** bundled.get 的入参契约(CLI 与 HTTP 共用同一份)。 */
12
+ const input = z.object({
13
+ name: z.string().optional(),
14
+ ref: z.string().optional(),
15
+ group: z.string().optional().describe("groups.json 里的组名(与 <name> 互斥)"),
16
+ to: z.string().optional(),
17
+ });
18
+
19
+ export class BundledGetAction extends ActionBase<typeof input> {
12
20
  @action({
13
21
  id: 'bundled.get',
14
22
  cli: ['skill', 'get'],
15
23
  http: ['GET', '/api/bundled/content'],
16
24
  summary: '输出内置 skill 全文(prefix + sentinel + 正文 + install 状态),并顺手装到本机',
17
25
  args: ['name', 'ref'],
18
- input: bundledGetInput,
26
+ input,
19
27
  render: (d: any) => (d.group
20
28
  ? d.skills.map(renderContent).join('\n\n' + '─'.repeat(60) + '\n\n')
21
29
  : renderContent(d)),
@@ -1,19 +1,24 @@
1
1
  // bundled.groups —— 由 .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 { bundledGroupsInput } from '../schemas.js';
7
7
  import * as serviceNs from '../service.js';
8
8
  const service: any = serviceNs;
9
9
 
10
- export class BundledGroupsAction extends ActionBase<typeof bundledGroupsInput> {
10
+ /** bundled.groups 的入参契约(CLI 与 HTTP 共用同一份)。 */
11
+ const input = z.object({
12
+
13
+ });
14
+
15
+ export class BundledGroupsAction extends ActionBase<typeof input> {
11
16
  @action({
12
17
  id: 'bundled.groups',
13
18
  cli: [['skill', 'groups'], ['bundled', 'groups']],
14
19
  http: ['GET', '/api/bundled/groups'],
15
20
  summary: '列出可装的 group(groups.json 的组名 → 它包含哪些 skill)',
16
- input: bundledGroupsInput,
21
+ input,
17
22
  render: (d: any) => {
18
23
  const head: any = `可装的 group(来源: ${d.source}${d.defaultGroup ? ` · 默认组: ${d.defaultGroup}` : ''}):`;
19
24
  const lines: any = [head];
@@ -1,21 +1,30 @@
1
1
  // bundled.install —— 由 .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 { bundledInstallInput } from '../schemas.js';
7
7
  import * as serviceNs from '../service.js';
8
8
  import { exclusive, renderScoped } from '../support.js';
9
9
  const service: any = serviceNs;
10
10
 
11
- export class BundledInstallAction extends ActionBase<typeof bundledInstallInput> {
11
+ /** bundled.install 的入参契约(CLI 与 HTTP 共用同一份)。 */
12
+ const input = z.object({
13
+ name: z.string().optional(),
14
+ group: z.string().optional().describe("groups.json 里的组名(与 <name> 互斥)"),
15
+ to: z.string().optional(),
16
+ force: z.boolean().optional(),
17
+ all: z.boolean().optional().describe("装 assets/ 下的全部内置 skill(隐式覆盖,不需要 --force)"),
18
+ });
19
+
20
+ export class BundledInstallAction extends ActionBase<typeof input> {
12
21
  @action({
13
22
  id: 'bundled.install',
14
23
  cli: ['skill', 'install'],
15
24
  http: ['POST', '/api/bundled/install'],
16
25
  summary: '安装内置 skill 到 skills 目录(默认 nx-kv → ~/.claude/skills;--group <key> 一键装一组;--all 装全部并直接覆盖)',
17
26
  args: ['name'],
18
- input: bundledInstallInput,
27
+ input,
19
28
  render: (d: any) => {
20
29
  // 聚合形状用**显式字段**判别,不做形状嗅探(B04 §实现要点):先 group 后 all
21
30
  if (d.group) return renderScoped(`group ${d.group}`, d);
@@ -1,20 +1,25 @@
1
1
  // bundled.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, type ActionRunMeta } from '../../../runtime/action-base.js';
6
- import { bundledListInput } from '../schemas.js';
7
7
  import * as serviceNs from '../service.js';
8
8
  import { renderList } from '../support.js';
9
9
  const service: any = serviceNs;
10
10
 
11
- export class BundledListAction extends ActionBase<typeof bundledListInput> {
11
+ /** bundled.list 的入参契约(CLI 与 HTTP 共用同一份)。 */
12
+ const input = z.object({
13
+
14
+ });
15
+
16
+ export class BundledListAction extends ActionBase<typeof input> {
12
17
  @action({
13
18
  id: 'bundled.list',
14
19
  cli: [['skill', 'list'], ['skill', 'install', '--list'], ['bundled', 'list']],
15
20
  http: ['GET', '/api/bundled'],
16
21
  summary: '列出包内自带 skill(含文件数与描述)+ 默认装哪个 + 有哪些 group',
17
- input: bundledListInput,
22
+ input,
18
23
  render: renderList,
19
24
  })
20
25
  override async run(__ctx: ActionInput<this['_input']>, meta: ActionRunMeta = {}) {
@@ -1,19 +1,25 @@
1
1
  // db.backup —— 由 .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 { dbBackupInput } from '../schemas.js';
7
7
  import * as serviceNs from '../service.js';
8
8
  const service: any = serviceNs;
9
9
 
10
- export class DbBackupAction extends ActionBase<typeof dbBackupInput> {
10
+ /** db.backup 的入参契约(CLI 与 HTTP 共用同一份)。 */
11
+ const input = z.object({
12
+ dir: z.string().optional().describe("备份目录(缺省 ~/.nx-kv/backups/)"),
13
+ keep: z.number().default(5).describe("保留最近几份(0 = 不清理)"),
14
+ });
15
+
16
+ export class DbBackupAction extends ActionBase<typeof input> {
11
17
  @action({
12
18
  id: 'db.backup',
13
19
  cli: ['db', 'backup'],
14
20
  http: null,
15
21
  summary: 'VACUUM INTO 备份(WAL 下不能直接 copy .db;保留最近 5 份)',
16
- input: dbBackupInput,
22
+ input,
17
23
  render: (d: any) => service.renderBackup(d),
18
24
  })
19
25
  override async run(ctx: ActionInput<this['_input']>) {
@@ -1,19 +1,25 @@
1
1
  // db.migrate —— 由 .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 { dbMigrateInput } from '../schemas.js';
7
7
  import * as serviceNs from '../service.js';
8
8
  const service: any = serviceNs;
9
9
 
10
- export class DbMigrateAction extends ActionBase<typeof dbMigrateInput> {
10
+ /** db.migrate 的入参契约(CLI 与 HTTP 共用同一份)。 */
11
+ const input = z.object({
12
+ 'dry-run': z.boolean().optional().describe("演练:事务末尾回滚,库与 JSON 都不改"),
13
+ apply: z.boolean().optional().describe("显式执行(默认就是执行,此标志让脚本自证意图)"),
14
+ });
15
+
16
+ export class DbMigrateAction extends ActionBase<typeof input> {
11
17
  @action({
12
18
  id: 'db.migrate',
13
19
  cli: ['db', 'migrate'],
14
20
  http: null,
15
21
  summary: '迁移:无标志 = 从 legacy JSON 全量导入;版本落后 = 走升级链(含 --dry-run 演练)',
16
- input: dbMigrateInput,
22
+ input,
17
23
  render: (d: any) => service.renderMigrate(d),
18
24
  })
19
25
  override async run(ctx: ActionInput<this['_input']>) {
@@ -1,19 +1,24 @@
1
1
  // db.status —— 由 .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 { dbStatusInput } from '../schemas.js';
7
7
  import * as serviceNs from '../service.js';
8
8
  const service: any = serviceNs;
9
9
 
10
- export class DbStatusAction extends ActionBase<typeof dbStatusInput> {
10
+ /** db.status 的入参契约(CLI 与 HTTP 共用同一份)。 */
11
+ const input = z.object({
12
+
13
+ });
14
+
15
+ export class DbStatusAction extends ActionBase<typeof input> {
11
16
  @action({
12
17
  id: 'db.status',
13
18
  cli: ['db', 'status'],
14
19
  http: null,
15
20
  summary: '库状态:路径、user_version、各表行数、任务状态分布(只读,不升级)',
16
- input: dbStatusInput,
21
+ input,
17
22
  render: (d: any) => service.renderStatus(d),
18
23
  })
19
24
  override async run(_ctx: ActionInput<this['_input']>) {
@@ -1,19 +1,24 @@
1
1
  // db.verify —— 由 .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 { dbVerifyInput } from '../schemas.js';
7
7
  import * as serviceNs from '../service.js';
8
8
  const service: any = serviceNs;
9
9
 
10
- export class DbVerifyAction extends ActionBase<typeof dbVerifyInput> {
10
+ /** db.verify 的入参契约(CLI 与 HTTP 共用同一份)。 */
11
+ const input = z.object({
12
+
13
+ });
14
+
15
+ export class DbVerifyAction extends ActionBase<typeof input> {
11
16
  @action({
12
17
  id: 'db.verify',
13
18
  cli: ['db', 'verify'],
14
19
  http: null,
15
20
  summary: '逐项校验:版本/行数/状态分布/正文哈希/seq 对应/外键/完整性',
16
- input: dbVerifyInput,
21
+ input,
17
22
  render: (d: any) => service.renderVerify(d),
18
23
  })
19
24
  override async run(_ctx: ActionInput<this['_input']>) {
@@ -1,22 +1,30 @@
1
1
  // doc.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 { docAddInput } from '../schemas.js';
7
7
  import { addDoc as _addDoc } from '../service.js';
8
8
  import { renderWritten as _renderWritten } from '../render.js';
9
9
  const addDoc: any = _addDoc;
10
10
  const renderWritten: any = _renderWritten;
11
11
 
12
- export class DocAddAction extends ActionBase<typeof docAddInput> {
12
+ /** doc.add 的入参契约(CLI 与 HTTP 共用同一份)。 */
13
+ const input = z.object({
14
+ rel: 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
+ });
19
+
20
+ export class DocAddAction extends ActionBase<typeof input> {
13
21
  @action({
14
22
  id: 'doc.add',
15
23
  cli: ['docs', 'add'],
16
24
  http: ['POST', '/api/docs/item'],
17
25
  summary: '新建自有文档(--body 给 Markdown 正文;--body-file <文件> / - 读管道;已存在则报冲突)',
18
26
  args: ['rel'],
19
- input: docAddInput,
27
+ input,
20
28
  render: renderWritten,
21
29
  })
22
30
  override async run(ctx: ActionInput<this['_input']>, opts: ActionRunMeta = {}) {
@@ -1,20 +1,27 @@
1
1
  // doc.attach-note —— 由 .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 { docAttachNoteInput } from '../schemas.js';
7
7
  import { noteOnDoc as _noteOnDoc } from '../attach.js';
8
8
  const noteOnDoc: any = _noteOnDoc;
9
9
 
10
- export class DocAttachNoteAction extends ActionBase<typeof docAttachNoteInput> {
10
+ /** doc.attach-note 的入参契约(CLI 与 HTTP 共用同一份)。 */
11
+ const input = z.object({
12
+ ref: z.string(),
13
+ attachment: z.string().describe("资源 id(见 docs attachments)"),
14
+ note: z.string().optional().describe("说明文字(留空 = 清掉)"),
15
+ });
16
+
17
+ export class DocAttachNoteAction extends ActionBase<typeof input> {
11
18
  @action({
12
19
  id: 'doc.attach-note',
13
20
  cli: ['docs', 'attach-note'],
14
21
  http: ['PATCH', '/api/docs/attach-note'],
15
22
  summary: '改一条附件绑定的说明(desc):--attachment <资源 id> --note <说明>(只动说明,角色/位置不变)',
16
23
  args: ['ref'],
17
- input: docAttachNoteInput,
24
+ input,
18
25
  render: (d: any) => `已更新 ${d.attachment} 的说明:${d.note || '(清空)'}`,
19
26
  })
20
27
  override async run(ctx: ActionInput<this['_input']>) {
@@ -1,22 +1,36 @@
1
1
  // doc.attach —— 由 .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 { docAttachInput } from '../schemas.js';
7
7
  import { attachToDoc as _attachToDoc } from '../attach.js';
8
8
  import { renderAttach as _renderAttach } from '../render.js';
9
9
  const attachToDoc: any = _attachToDoc;
10
10
  const renderAttach: any = _renderAttach;
11
11
 
12
- export class DocAttachAction extends ActionBase<typeof docAttachInput> {
12
+ /** doc.attach 的入参契约(CLI 与 HTTP 共用同一份)。 */
13
+ const input = z.object({
14
+ ref: z.string(),
15
+ path: z.string().optional().describe("本机文件路径(落本机附件仓)"),
16
+ fileId: z.string().optional().describe("已有附件 id"),
17
+ url: z.string().optional().describe("外部链接(http/https)"),
18
+ task: z.string().optional().describe("任务全局 id(kind=task)"),
19
+ doc: z.string().optional().describe("另一篇文档的 ref/path(kind=ref)"),
20
+ name: z.string().optional().describe("显示名(默认取文件名/原名)"),
21
+ note: z.string().optional().describe("附件区备注"),
22
+ noEmbed: z.boolean().optional().describe("只写 ref_attach(role=attach),不改正文"),
23
+ 'no-embed': z.boolean().optional().describe("同 --noEmbed"),
24
+ });
25
+
26
+ export class DocAttachAction extends ActionBase<typeof input> {
13
27
  @action({
14
28
  id: 'doc.attach',
15
29
  cli: ['docs', 'attach'],
16
30
  http: ['POST', '/api/docs/attach'],
17
31
  summary: '给文档挂资源:--path / --fileId / --url / --task / --doc 之一;默认追加进正文,--no-embed 只挂附件区(不写正文)',
18
32
  args: ['ref'],
19
- input: docAttachInput,
33
+ input,
20
34
  render: renderAttach,
21
35
  })
22
36
  override async run(ctx: ActionInput<this['_input']>) {
@@ -1,22 +1,27 @@
1
1
  // doc.attachments —— 由 .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 { docAttachmentsInput } from '../schemas.js';
7
7
  import { listDocAttachments as _listDocAttachments } from '../attach.js';
8
8
  import { renderAttachments as _renderAttachments } from '../render.js';
9
9
  const listDocAttachments: any = _listDocAttachments;
10
10
  const renderAttachments: any = _renderAttachments;
11
11
 
12
- export class DocAttachmentsAction extends ActionBase<typeof docAttachmentsInput> {
12
+ /** doc.attachments 的入参契约(CLI 与 HTTP 共用同一份)。 */
13
+ const input = z.object({
14
+ ref: z.string(),
15
+ });
16
+
17
+ export class DocAttachmentsAction extends ActionBase<typeof input> {
13
18
  @action({
14
19
  id: 'doc.attachments',
15
20
  cli: ['docs', 'attachments'],
16
21
  http: ['GET', '/api/docs/attachments'],
17
22
  summary: '这篇文档用了哪些资源(ref_attach:图片/文件/URL/内部 task、ref 引用)',
18
23
  args: ['ref'],
19
- input: docAttachmentsInput,
24
+ input,
20
25
  render: renderAttachments,
21
26
  })
22
27
  override async run(ctx: ActionInput<this['_input']>) {
@@ -1,22 +1,29 @@
1
1
  // doc.detach —— 由 .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 { docDetachInput } from '../schemas.js';
7
7
  import { detachFromDoc as _detachFromDoc } from '../attach.js';
8
8
  import { renderDetach as _renderDetach } from '../render.js';
9
9
  const detachFromDoc: any = _detachFromDoc;
10
10
  const renderDetach: any = _renderDetach;
11
11
 
12
- export class DocDetachAction extends ActionBase<typeof docDetachInput> {
12
+ /** doc.detach 的入参契约(CLI 与 HTTP 共用同一份)。 */
13
+ const input = z.object({
14
+ ref: z.string(),
15
+ attachment: z.string().describe("资源 id(见 docs attachments)"),
16
+ purge: z.boolean().optional().describe("连资源与字节一起删(仍被引用时拒绝)"),
17
+ });
18
+
19
+ export class DocDetachAction extends ActionBase<typeof input> {
13
20
  @action({
14
21
  id: 'doc.detach',
15
22
  cli: ['docs', 'detach'],
16
23
  http: ['DELETE', '/api/docs/attach'],
17
24
  summary: '解除文档与附件的关系(默认只解除关系);--purge 无人引用时连资源行与本机字节一起删',
18
25
  args: ['ref'],
19
- input: docDetachInput,
26
+ input,
20
27
  render: renderDetach,
21
28
  })
22
29
  override async run(ctx: ActionInput<this['_input']>) {
@@ -1,22 +1,27 @@
1
1
  // doc.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 { docGetInput } from '../schemas.js';
7
7
  import { getDoc as _getDoc } from '../service.js';
8
8
  import { renderGet as _renderGet } from '../render.js';
9
9
  const getDoc: any = _getDoc;
10
10
  const renderGet: any = _renderGet;
11
11
 
12
- export class DocGetAction extends ActionBase<typeof docGetInput> {
12
+ /** doc.get 的入参契约(CLI 与 HTTP 共用同一份)。 */
13
+ const input = z.object({
14
+ ref: z.string(),
15
+ });
16
+
17
+ export class DocGetAction extends ActionBase<typeof input> {
13
18
  @action({
14
19
  id: 'doc.get',
15
20
  cli: ['docs', 'get'],
16
21
  http: ['GET', '/api/docs/item'],
17
22
  summary: '读文档全文:rel:<路径>(或裸相对路径)= 自有;path:<绝对路径> = 外部(须在绑定闭包内);约定路径缺失时惰性播种',
18
23
  args: ['ref'],
19
- input: docGetInput,
24
+ input,
20
25
  render: renderGet,
21
26
  })
22
27
  override async run(ctx: ActionInput<this['_input']>) {