nx-kv 0.48.2 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +85 -0
- package/README.md +103 -216
- package/assets/groups.json +1 -1
- package/assets/kv-get/SKILL.md +1 -1
- package/assets/kv-get/references/localget.md +2 -2
- package/assets/kv-get/references/timegoal-workflow.md +3 -3
- package/assets/kv-get/references/timegoal.md +1 -1
- package/assets/kv-get/references/wait-workflow.md +2 -3
- package/assets/kv-get/references/waitloop.md +3 -3
- package/assets/kv-repo/SKILL.md +1 -1
- package/assets/kv-submit/SKILL.md +3 -3
- package/assets/nx-kv/SKILL.md +111 -76
- package/assets/nx-kv/references/agent-workflow.md +58 -47
- package/assets/nx-kv/references/localtask-commands.md +179 -0
- package/package.json +3 -4
- package/src/core/attachmentdb/bodies.ts +193 -0
- package/src/core/attachmentdb/docs.ts +158 -33
- package/src/core/attachmentdb/ids.ts +27 -1
- package/src/core/attachmentdb/mdfile.ts +249 -0
- package/src/core/attachmentdb/query.ts +14 -1
- package/src/core/attachmentdb/resources.ts +28 -2
- package/src/core/attachmentdb.ts +27 -0
- package/src/core/config.ts +13 -133
- package/src/core/db/bootstrap.ts +5 -5
- package/src/core/db/import-json/refs.ts +27 -13
- package/src/core/db/migrations/index.ts +9 -0
- package/src/core/db/migrations/v2-data.ts +4 -4
- package/src/core/db/migrations/v5.sql +100 -0
- package/src/core/db/migrations/v6-data.ts +261 -0
- package/src/core/db/migrations/v6.sql +67 -0
- package/src/core/db/migrations/v7.sql +8 -0
- package/src/core/db/seed-templates.ts +3 -1
- package/src/core/db/version.ts +12 -1
- package/src/core/filekind.ts +95 -0
- package/src/core/instruction-template.ts +6 -4
- package/src/core/localatt.ts +3 -6
- package/src/core/paths.ts +11 -1
- package/src/index.ts +0 -2
- package/src/modules/docs/actions/_manifest.generated.ts +18 -0
- package/src/modules/docs/actions/doc-attach.ts +2 -1
- package/src/modules/docs/actions/doc-link-file.ts +28 -0
- package/src/modules/docs/actions/doc-mdfile.ts +28 -0
- package/src/modules/docs/actions/doc-mdfiles.ts +29 -0
- package/src/modules/docs/actions/doc-ref.ts +36 -0
- package/src/modules/docs/actions/doc-unbind.ts +34 -0
- package/src/modules/docs/actions/doc-update.ts +3 -2
- package/src/modules/docs/actions/docs-bind.ts +1 -1
- package/src/modules/docs/actions/docs-bindings.ts +108 -0
- package/src/modules/docs/actions/docs-notebind.ts +1 -1
- package/src/modules/docs/attach.ts +16 -3
- package/src/modules/docs/bound-docs.ts +74 -0
- package/src/modules/docs/docref.ts +18 -3
- package/src/modules/docs/knowledge-md.ts +51 -0
- package/src/modules/docs/knowledge.ts +112 -112
- package/src/modules/docs/links.ts +7 -1
- package/src/modules/docs/mdfile.ts +24 -0
- package/src/modules/docs/paths.ts +6 -9
- package/src/modules/docs/ref-sync.ts +166 -0
- package/src/modules/docs/refs.ts +16 -5
- package/src/modules/docs/render.ts +33 -15
- package/src/modules/docs/seed.ts +1 -1
- package/src/modules/docs/service.ts +300 -30
- package/src/modules/docs/store.ts +147 -74
- package/src/modules/file/actions/_manifest.generated.ts +0 -9
- package/src/modules/file/actions/file-content.ts +3 -4
- package/src/modules/file/actions/file-get.ts +2 -3
- package/src/modules/file/actions/file-upload.ts +1 -4
- package/src/modules/file/service.ts +52 -253
- package/src/modules/localtask/action-render.ts +5 -5
- package/src/modules/localtask/actions/_manifest.generated.ts +0 -6
- package/src/modules/localtask/actions/localtask-attach.ts +4 -2
- package/src/modules/localtask/actions/localtask-cancelMany.ts +1 -1
- package/src/modules/localtask/actions/localtask-closeMany.ts +4 -3
- package/src/modules/localtask/actions/localtask-get.ts +1 -1
- package/src/modules/localtask/repo/tasks.ts +12 -6
- package/src/modules/localtask/service.ts +0 -2
- package/src/modules/localtask/task-ops.ts +4 -4
- package/src/modules/localtask/task-remove.ts +33 -16
- package/src/modules/localtask/task-templates.ts +2 -3
- package/src/modules/localtask/task-view.ts +2 -2
- package/src/modules/repos/actions/_manifest.generated.ts +0 -3
- package/src/modules/repos/actions/repo-update.ts +2 -4
- package/src/modules/repos/cli/render.ts +0 -15
- package/src/modules/repos/service/bind-topics.ts +8 -18
- package/src/modules/repos/service.ts +1 -1
- package/src/modules/repos/transfer/export.ts +4 -1
- package/src/modules/setting/actions/setting-set.ts +0 -2
- package/src/modules/setting/service.ts +6 -25
- package/src/modules/system/actions/bootstrap.ts +2 -31
- package/src/modules/system/actions/health.ts +4 -31
- package/src/modules/system/routes.ts +1 -1
- package/src/modules/tasktool/attach-resource.ts +68 -42
- package/src/modules/tasktool/attach-template.ts +73 -54
- package/src/modules/tasktool/attach.ts +98 -71
- package/src/modules/tasktool/delivery-template.ts +14 -4
- package/src/modules/tasktool/doc-inline.ts +63 -29
- package/src/modules/tasktool/get.ts +1 -1
- package/src/modules/tasktool/groupctx.ts +19 -11
- package/src/modules/tasktool/plugins/waitgoal-config.ts +24 -55
- package/src/modules/tasktool/plugins/waitgoal.ts +0 -2
- package/src/modules/tasktool/preview.ts +2 -3
- package/src/modules/tasktool/wait.ts +6 -9
- package/src/runtime/cli.ts +3 -15
- package/src/runtime/container.ts +1 -5
- package/src/runtime/help.ts +1 -4
- package/src/runtime/registry.ts +0 -6
- package/src/shared/prompt-blocks.ts +37 -33
- package/src/shared/task-status.ts +3 -3
- package/src/web/frontend/App.tsx +3 -3
- package/src/web/frontend/api/cli-tree.json +115 -608
- package/src/web/frontend/api/client.generated.ts +88 -401
- package/src/web/frontend/components/Introduction/index.tsx +26 -14
- package/src/web/frontend/components/Introduction/rail.tsx +28 -3
- package/src/web/frontend/components/Introduction/style.css +3 -33
- package/src/web/frontend/components/Introduction/use-intro.ts +0 -80
- package/src/web/frontend/components/{cloud → attach}/upload.ts +7 -20
- package/src/web/frontend/components/bindings/bind-tags.tsx +183 -0
- package/src/web/frontend/components/doc/doc-head.tsx +29 -26
- package/src/web/frontend/components/icons.tsx +0 -1
- package/src/web/frontend/components/layout/crumbs.ts +0 -2
- package/src/web/frontend/components/md/ack-rail.tsx +10 -142
- package/src/web/frontend/components/md/attach-area.tsx +64 -9
- package/src/web/frontend/components/md/attach-common.ts +8 -3
- package/src/web/frontend/components/md/attach-modal.tsx +22 -17
- package/src/web/frontend/components/md/attach-picker.tsx +2 -2
- package/src/web/frontend/components/md/attachments.ts +2 -3
- package/src/web/frontend/components/popup/dismiss.ts +1 -1
- package/src/web/frontend/components/repos/get-loop-modal.tsx +20 -207
- package/src/web/frontend/components/sidebar/index.tsx +32 -6
- package/src/web/frontend/components/sidebar/model.ts +71 -0
- package/src/web/frontend/components/sidebar/task-children.tsx +41 -20
- package/src/web/frontend/components/status-tag/model.ts +1 -1
- package/src/web/frontend/components/task-panel/index.tsx +4 -1
- package/src/web/frontend/components/task-panel/task-row.tsx +2 -2
- package/src/web/frontend/components/tool-acts/modules.ts +0 -3
- package/src/web/frontend/components/use-rail-drag.ts +177 -0
- package/src/web/frontend/modules/board/ack-rail-pos.ts +17 -7
- package/src/web/frontend/modules/board/board-view.ts +2 -2
- package/src/web/frontend/modules/board/task-search.ts +81 -0
- package/src/web/frontend/modules/md/attach-mention.ts +6 -1
- package/src/web/frontend/modules/md/doc-bus.ts +22 -0
- package/src/web/frontend/modules/md/md-render.ts +9 -2
- package/src/web/frontend/modules/md/styles/chrome.css +25 -0
- package/src/web/frontend/modules/md/styles/docs.css +32 -21
- package/src/web/frontend/modules/md/styles/shell.css +1 -10
- package/src/web/frontend/page/dir/api.ts +7 -0
- package/src/web/frontend/page/dir/index.tsx +24 -58
- package/src/web/frontend/page/dir/landing.tsx +85 -72
- package/src/web/frontend/page/dir/task-actions.ts +17 -5
- package/src/web/frontend/page/dir/task-dock-panel.tsx +87 -2
- package/src/web/frontend/page/dir/task-dock.ts +21 -10
- package/src/web/frontend/page/dir/task-goal.ts +2 -2
- package/src/web/frontend/page/dir/task-status-bar.tsx +14 -1
- package/src/web/frontend/page/dir/task.tsx +5 -3
- package/src/web/frontend/page/doc/api.ts +71 -5
- package/src/web/frontend/page/doc/bindings.tsx +240 -0
- package/src/web/frontend/page/doc/doc-dock.tsx +159 -0
- package/src/web/frontend/page/doc/index.tsx +131 -212
- package/src/web/frontend/page/doc/use-wiki-nav.ts +101 -0
- package/src/web/frontend/page/group/index.tsx +61 -87
- package/src/web/frontend/page/overview/index.tsx +1 -2
- package/src/web/frontend/page/refs/api.ts +60 -8
- package/src/web/frontend/page/refs/index.tsx +177 -90
- package/src/web/frontend/page/refs/style.css +45 -2
- package/src/web/frontend/page/repos/doc-search-modal.tsx +7 -0
- package/src/web/frontend/page/repos/index.tsx +21 -60
- package/src/web/frontend/page/repos/repo-table.tsx +85 -77
- package/src/web/frontend/page/settings/index.tsx +3 -27
- package/src/web/frontend/page/settings/prompt-template-params.ts +18 -28
- package/src/web/frontend/panels.tsx +52 -6
- package/src/web/frontend/registry.ts +1 -2
- package/src/web/frontend/routes/index.ts +1 -2
- package/src/web/frontend/routes/static.ts +2 -3
- package/src/web/frontend/store.tsx +1 -8
- package/src/web/frontend/style.css +1 -0
- package/src/web/frontend/styles/base.css +0 -17
- package/src/web/frontend/styles/bindings.css +75 -0
- package/src/web/frontend/styles/buttons-cards.css +0 -72
- package/src/web/frontend/styles/repos-admin.css +7 -5
- package/src/web/frontend/styles-v2/dir.css +1 -9
- package/src/web/frontend/styles-v2/shell.css +0 -2
- package/src/web/frontend/styles-v2/sidebar.css +12 -0
- package/src/web/frontend/styles-v2/views.css +22 -102
- package/src/web/frontend/workspace/areas.ts +0 -2
- package/src/web/public/assets/Introduction-CohW6Xit.js +6 -0
- package/src/web/public/assets/Introduction-Iuxssa-b.css +1 -0
- package/src/web/public/assets/app-context-BgpTewyA.js +1 -0
- package/src/web/public/assets/{bar-B52NTf_v.js → bar-C2mfoqmj.js} +1 -1
- package/src/web/public/assets/{board-view-DABoVkaA.js → board-view-aAIEbSQi.js} +1 -1
- package/src/web/public/assets/button-xyR2UROd.js +1 -0
- package/src/web/public/assets/composer-launch-eTktHT_f.js +1 -0
- package/src/web/public/assets/{composer-panel-DpiU2h50.js → composer-panel-C0OOIXxz.js} +1 -1
- package/src/web/public/assets/dag-Gm4RcvEg.js +1 -0
- package/src/web/public/assets/dir-PjuMRbWo.js +3 -0
- package/src/web/public/assets/group-D94y_Lq6.js +1 -0
- package/src/web/public/assets/index-CBJKsJU3.css +1 -0
- package/src/web/public/assets/index-Crxdmsux.js +2 -0
- package/src/web/public/assets/md-history-CU_1I6ht.js +39 -0
- package/src/web/public/assets/{md-parse-b6GY5eBl.js → md-parse-CLyUaUto.js} +1 -1
- package/src/web/public/assets/{member-picker-B5I7KuOR.js → member-picker-XT12VRe6.js} +1 -1
- package/src/web/public/assets/model-CWJ8_2dN.js +2 -0
- package/src/web/public/assets/{overview-B3kHI66i.js → overview-BQm8BLCG.js} +1 -1
- package/src/web/public/assets/{progress-CdhFz0Lz.js → progress-CNam3Wuj.js} +2 -2
- package/src/web/public/assets/refs-C5idWnUj.css +1 -0
- package/src/web/public/assets/refs-ClETk1cj.js +2 -0
- package/src/web/public/assets/repos-BioGejZo.js +14 -0
- package/src/web/public/assets/route-crumb-Fc68LcQ4.js +1 -0
- package/src/web/public/assets/settings-BIzumXLD.js +8 -0
- package/src/web/public/assets/status-tag-CBFf_-ae.js +1 -0
- package/src/web/public/assets/task-CGmO3I2y.js +11 -0
- package/src/web/public/assets/task-row-DRBa11tf.js +1 -0
- package/src/web/public/assets/{task-status-DSrx0i66.js → task-status-BHF-y9Aq.js} +2 -1
- package/src/web/public/assets/{task-utils-_JAWRAz6.js → task-utils-DjODjVdc.js} +2 -2
- package/src/web/public/assets/{templates-CbRyW3PJ.js → templates-j8EzXHXf.js} +1 -1
- package/src/web/public/assets/ui-Y0aL-bGk.js +1 -0
- package/src/web/public/assets/use-rail-drag-DNfz4Gcx.js +1 -0
- package/src/web/public/assets/{workspace-4tw7trV7.js → workspace-D_G-B3TX.js} +4 -4
- package/src/web/public/index.html +9 -9
- package/assets/nx-kv/references/todo-commands.md +0 -269
- package/src/core/attachstore.ts +0 -360
- package/src/core/fileapi.ts +0 -267
- package/src/core/kvapi.ts +0 -237
- package/src/modules/auth/actions/_manifest.generated.ts +0 -26
- package/src/modules/auth/actions/auth-login.ts +0 -31
- package/src/modules/auth/actions/auth-logout.ts +0 -33
- package/src/modules/auth/actions/auth-me.ts +0 -33
- package/src/modules/auth/actions/auth-status.ts +0 -41
- package/src/modules/auth/index.ts +0 -24
- package/src/modules/auth/support.ts +0 -28
- package/src/modules/file/actions/file-list.ts +0 -31
- package/src/modules/file/actions/file-remove.ts +0 -31
- package/src/modules/file/actions/file-sync.ts +0 -33
- package/src/modules/localtask/actions/localtask-importRemote.ts +0 -51
- package/src/modules/localtask/actions/task-move.ts +0 -67
- package/src/modules/localtask/move-prims.ts +0 -170
- package/src/modules/localtask/move.ts +0 -174
- package/src/modules/localtask/remote-import.ts +0 -159
- package/src/modules/repos/actions/repo-ref-backfill.ts +0 -33
- package/src/modules/repos/ref-backfill.ts +0 -219
- package/src/modules/todo/actions/_manifest.generated.ts +0 -89
- package/src/modules/todo/actions/group-add.ts +0 -34
- package/src/modules/todo/actions/group-current.ts +0 -36
- package/src/modules/todo/actions/group-get.ts +0 -43
- package/src/modules/todo/actions/group-list.ts +0 -41
- package/src/modules/todo/actions/group-members.ts +0 -41
- package/src/modules/todo/actions/group-remove.ts +0 -44
- package/src/modules/todo/actions/group-update.ts +0 -37
- package/src/modules/todo/actions/group-use.ts +0 -43
- package/src/modules/todo/actions/prompt-get.ts +0 -31
- package/src/modules/todo/actions/prompt-remove.ts +0 -31
- package/src/modules/todo/actions/prompt-set.ts +0 -32
- package/src/modules/todo/actions/todo-add.ts +0 -34
- package/src/modules/todo/actions/todo-archive.ts +0 -33
- package/src/modules/todo/actions/todo-attach.ts +0 -37
- package/src/modules/todo/actions/todo-attachments.ts +0 -33
- package/src/modules/todo/actions/todo-done.ts +0 -33
- package/src/modules/todo/actions/todo-freeze.ts +0 -32
- package/src/modules/todo/actions/todo-get.ts +0 -33
- package/src/modules/todo/actions/todo-list.ts +0 -32
- package/src/modules/todo/actions/todo-remove.ts +0 -32
- package/src/modules/todo/actions/todo-unfreeze.ts +0 -34
- package/src/modules/todo/actions/todo-update.ts +0 -42
- package/src/modules/todo/actions/topic-add.ts +0 -31
- package/src/modules/todo/actions/topic-list.ts +0 -35
- package/src/modules/todo/actions/topic-remove.ts +0 -36
- package/src/modules/todo/attachments.ts +0 -194
- package/src/modules/todo/group.ts +0 -207
- package/src/modules/todo/index.ts +0 -26
- package/src/modules/todo/locate.ts +0 -103
- package/src/modules/todo/service.ts +0 -476
- package/src/modules/todo/store.ts +0 -176
- package/src/modules/todo/support.ts +0 -93
- package/src/web/frontend/components/Introduction/docs-modal.tsx +0 -338
- package/src/web/frontend/components/cloud/editor.tsx +0 -254
- package/src/web/frontend/components/cloud/group-popup.tsx +0 -198
- package/src/web/frontend/components/cloud/markdown.tsx +0 -60
- package/src/web/frontend/components/migrate/dialog.tsx +0 -120
- package/src/web/frontend/components/migrate/undo.tsx +0 -73
- package/src/web/frontend/components/migrate/use-move.ts +0 -137
- package/src/web/frontend/page/cloud/api.ts +0 -99
- package/src/web/frontend/page/cloud/index.tsx +0 -516
- package/src/web/frontend/page/dir/deleted-panel.tsx +0 -77
- package/src/web/public/assets/Introduction-BcPrmROW.css +0 -1
- package/src/web/public/assets/Introduction-Du_dycft.js +0 -6
- package/src/web/public/assets/app-context-BASCGAA-.js +0 -1
- package/src/web/public/assets/cloud-Droja_aT.js +0 -3
- package/src/web/public/assets/composer-launch-mK9Nr6mZ.js +0 -1
- package/src/web/public/assets/dag-Ca-wjIxQ.js +0 -1
- package/src/web/public/assets/deleted-panel-K9GgfR8t.js +0 -1
- package/src/web/public/assets/dir-DacRpcBt.js +0 -5
- package/src/web/public/assets/frontmatter-CLLxCmTv.js +0 -2
- package/src/web/public/assets/group-TPuU-QVc.js +0 -2
- package/src/web/public/assets/index-BkLkooKe.js +0 -2
- package/src/web/public/assets/index-DP3qBv1o.css +0 -1
- package/src/web/public/assets/md-history-0GBWw4qr.js +0 -39
- package/src/web/public/assets/model-Bn2fG6CC.js +0 -2
- package/src/web/public/assets/prompt-blocks-BovFd039.js +0 -8
- package/src/web/public/assets/refs-BDxfuH6R.js +0 -1
- package/src/web/public/assets/refs-CY4i7PoC.css +0 -1
- package/src/web/public/assets/repos-C8jRM7wS.js +0 -15
- package/src/web/public/assets/repos-ZPiaK93i.css +0 -1
- package/src/web/public/assets/route-crumb-QvahotvN.js +0 -1
- package/src/web/public/assets/settings-BBcdGLTc.js +0 -1
- package/src/web/public/assets/status-tag-BheHByek.js +0 -1
- package/src/web/public/assets/task-CUkQaLBZ.js +0 -11
- package/src/web/public/assets/tool-bar-BAmT-BI-.js +0 -1
- package/src/web/public/assets/upload-BcMhRsMn.js +0 -1
- /package/src/web/public/assets/{prompt-blocks-DA4lNJeC.css → button-DA4lNJeC.css} +0 -0
- /package/src/web/public/assets/{tool-bar-1h2zairf.css → use-rail-drag-1h2zairf.css} +0 -0
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
// (#54 自 service.js 拆出)从远程清单(todo 模块)导入任务到本地队列:
|
|
2
|
-
// 先落本地(走 tasktool/add.js 的 submitTask 同一条派任务链路),再标远程完成——顺序不可反。
|
|
3
|
-
// 动态 import + fail-soft:没登录/远程不可达只报错这一条,不牵连本地任务其它功能。
|
|
4
|
-
import { badInput } from '../../core/errors.js';
|
|
5
|
-
import { GLOBAL_KEY, GLOBAL_NAME, GLOBAL_CWD, normalizeCwd } from './paths.js';
|
|
6
|
-
// ─── 从远程清单导入任务 ────────────────────────────────────────────────
|
|
7
|
-
//
|
|
8
|
-
// 「提交方 → 远程清单 → 本地队列」这条链的最后一公里:把远程(KV 后端)上还没人领的
|
|
9
|
-
// 任务**搬进本机的任务队列**,让本机的 agent 能领到它。
|
|
10
|
-
//
|
|
11
|
-
// 导入完成即回填远程:那条远程任务标记为已完成,note 写明「被本地哪个队列领走了」
|
|
12
|
-
// (远程清单 topic=goal 的 #74:「当从全局任务导入完成过后,就直接把这个任务标记为
|
|
13
|
-
// 已经完成,然后返回提示就是说本地的某一个队列领取了这个任务」)。
|
|
14
|
-
//
|
|
15
|
-
// 顺序是刻意的:**先落本地,再标远程完成**。反过来(先标远程)一旦本地写失败,
|
|
16
|
-
// 任务就两头都没了 —— 提交方看不到、本机也没有。
|
|
17
|
-
//
|
|
18
|
-
// 依赖边界:远程通道住在 todo 模块(另一个 store,且要登录态)。这里用**动态 import**
|
|
19
|
-
// + fail-soft:没登录 / 远程不可达 → 明确报错,但**不牵连本地任务的其它功能**。
|
|
20
|
-
|
|
21
|
-
/** todo 服务的最小投影(动态加载;跨模块依赖不静态收紧,用 any)。 */
|
|
22
|
-
type TodoModule = any;
|
|
23
|
-
|
|
24
|
-
let todoMod: TodoModule = null;
|
|
25
|
-
async function todoService(): Promise<TodoModule> {
|
|
26
|
-
if (!todoMod) todoMod = await import('../todo/service.js');
|
|
27
|
-
return todoMod;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 合并两个来源的"要导入的远程任务内容":**ref**(CLI 的 `--ref`,可给多次)与
|
|
32
|
-
* **refs**(面板发的列表)。
|
|
33
|
-
*
|
|
34
|
-
* 为什么两个键:CLI 的 flag 叫 `--ref`(沿用 todo 模块"按内容定位"的约定),
|
|
35
|
-
* 面板一次要导多条,发的是 `refs`;HTTP body 里未声明的键会原样透传,所以两个
|
|
36
|
-
* 都可能到 action 的 ctx 里。**只认一个就会整批丢掉**——曾经只读 `ctx.ref`,
|
|
37
|
-
* 面板那次导入静默地导了 0 条。
|
|
38
|
-
*
|
|
39
|
-
* 单独抽成纯函数是为了能单测(真跑导入要连远程后端,单测里连不上)。
|
|
40
|
-
*/
|
|
41
|
-
export function mergeImportRefs(refs: unknown, ref: unknown): string[] {
|
|
42
|
-
const a = Array.isArray(refs) ? refs : [];
|
|
43
|
-
const b = Array.isArray(ref) ? ref : [];
|
|
44
|
-
return [...a, ...b].map((r) => String(r ?? '').trim()).filter(Boolean);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** importRemoteTasks 的选项。 */
|
|
48
|
-
export interface ImportRemoteTasksOptions {
|
|
49
|
-
/** 目标本地目录(不给则用当前目录) */
|
|
50
|
-
cwd?: string;
|
|
51
|
-
/** true = 导入到全局共享池 */
|
|
52
|
-
global?: boolean;
|
|
53
|
-
/** 要导入的远程任务**内容整串**(面板发这个) */
|
|
54
|
-
refs?: string[];
|
|
55
|
-
/** 同上,CLI 的 `--ref` 走这个键 */
|
|
56
|
-
ref?: string[];
|
|
57
|
-
/** 远程主题(消歧用) */
|
|
58
|
-
topic?: string;
|
|
59
|
-
/** 同内容多条时的编号(消歧用) */
|
|
60
|
-
pick?: number;
|
|
61
|
-
/** 远程工作空间(缺省 = 当前) */
|
|
62
|
-
groupId?: number | string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* 从远程清单导入任务到本地队列。
|
|
67
|
-
*
|
|
68
|
-
* @param {object} opts
|
|
69
|
-
* @param {string} [opts.cwd] 目标本地目录(不给则用当前目录)
|
|
70
|
-
* @param {boolean} [opts.global] true = 导入到全局共享池
|
|
71
|
-
* @param {Array} [opts.refs] 要导入的远程任务**内容整串**(面板发这个)
|
|
72
|
-
* @param {Array} [opts.ref] 同上,CLI 的 `--ref` 走这个键
|
|
73
|
-
* @param {string} [opts.topic] 远程主题(消歧用)
|
|
74
|
-
* @param {number} [opts.pick] 同内容多条时的编号(消歧用)
|
|
75
|
-
* @param {number|string} [opts.groupId] 远程工作空间(缺省 = 当前)
|
|
76
|
-
*/
|
|
77
|
-
export async function importRemoteTasks({
|
|
78
|
-
cwd: rawCwd,
|
|
79
|
-
global: toGlobal = false,
|
|
80
|
-
refs,
|
|
81
|
-
ref,
|
|
82
|
-
topic,
|
|
83
|
-
pick,
|
|
84
|
-
groupId,
|
|
85
|
-
}: ImportRemoteTasksOptions = {}): Promise<Record<string, any>> {
|
|
86
|
-
const list = mergeImportRefs(refs, ref);
|
|
87
|
-
if (!list.length) throw badInput('要导入的远程任务不能为空(按内容指定 --ref)');
|
|
88
|
-
|
|
89
|
-
const todo = await todoService();
|
|
90
|
-
// 远程这一侧:读当前工作空间的未完成任务(不含历史,面板轮询时才不会拉一坨 done 回来)
|
|
91
|
-
const remote = await todo.listTodos({ status: 'open', groupId });
|
|
92
|
-
const openTasks = Array.isArray(remote.open) ? remote.open : [];
|
|
93
|
-
|
|
94
|
-
// 本地落点:先算清楚(global 优先;cwd 缺省用当前目录)
|
|
95
|
-
const local: { key: string; name: string; cwd: string } = toGlobal
|
|
96
|
-
? { key: GLOBAL_KEY, name: GLOBAL_NAME, cwd: GLOBAL_CWD }
|
|
97
|
-
: (() => {
|
|
98
|
-
const n = normalizeCwd(rawCwd);
|
|
99
|
-
return { key: n.key, name: n.name, cwd: n.cwd };
|
|
100
|
-
})();
|
|
101
|
-
|
|
102
|
-
const results: Array<Record<string, any>> = [];
|
|
103
|
-
for (const ref of list) {
|
|
104
|
-
const item: Record<string, any> = { ref: ref.slice(0, 60), imported: false, remoteDone: false };
|
|
105
|
-
// 1) 定位远程那条(按内容;同内容多条时用 topic/pick 消歧,绝不替用户猜)
|
|
106
|
-
let hit: any = null;
|
|
107
|
-
try {
|
|
108
|
-
hit = await todo.getTodo(ref, { topic, pick, groupId });
|
|
109
|
-
} catch (e) {
|
|
110
|
-
// 远程找不到(已被别人领走 / 内容写错)→ 如实报告这一条失败,其余照导
|
|
111
|
-
item.error = String((e && (e as Error).message) || e);
|
|
112
|
-
results.push(item);
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
const remoteTask = hit && (hit.task || hit);
|
|
116
|
-
const text = String((remoteTask && remoteTask.text) || ref);
|
|
117
|
-
|
|
118
|
-
// 2) 先落本地——走与 add 同一条**派任务链路**(tasktool/add.js 的 submitTask):
|
|
119
|
-
// 正文自带 frontmatter 时 fail-open 补齐归属语义;落点仍是用户选定的主题
|
|
120
|
-
// (cwd 是这里的显式意图,不会被挪窝)。动态 import:add.js 静态引用本模块,
|
|
121
|
-
// 反向只走动态(与 taskgoal 探针同一惯例)。
|
|
122
|
-
const { submitTask } = await import('../tasktool/add.js');
|
|
123
|
-
const added = await submitTask({ cwd: local.cwd, text, global: toGlobal });
|
|
124
|
-
item.imported = true;
|
|
125
|
-
item.localId = added.task.id;
|
|
126
|
-
item.localTopic = added.name; // addTask 返回形状:主题名在 name(没有 topic 字段)
|
|
127
|
-
|
|
128
|
-
// 3) 再把远程那条标完成,note 写明「本地的哪一个队列领走了它」
|
|
129
|
-
try {
|
|
130
|
-
await todo.doneTodo(text, {
|
|
131
|
-
result: `已导入到本地队列「${item.localTopic || local.name}」(本地 #${added.task.id})`,
|
|
132
|
-
topic: remoteTask && remoteTask.topic ? remoteTask.topic : topic,
|
|
133
|
-
pick,
|
|
134
|
-
groupId,
|
|
135
|
-
});
|
|
136
|
-
item.remoteDone = true;
|
|
137
|
-
} catch (e) {
|
|
138
|
-
// 远程标完成失败:本地已经有这条了,**如实报告**(不能装作成功)
|
|
139
|
-
item.error = `本地已导入,但远程标记失败:${String((e && (e as Error).message) || e)}`;
|
|
140
|
-
}
|
|
141
|
-
results.push(item);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const imported = results.filter((r) => r.imported).length;
|
|
145
|
-
const remoteDone = results.filter((r) => r.remoteDone).length;
|
|
146
|
-
return {
|
|
147
|
-
status: imported ? 'ok' : 'nothing',
|
|
148
|
-
target: { key: local.key, name: local.name, cwd: local.cwd, global: !!toGlobal },
|
|
149
|
-
imported,
|
|
150
|
-
remoteDone,
|
|
151
|
-
failed: results.filter((r) => !r.imported).length,
|
|
152
|
-
results,
|
|
153
|
-
openCount: openTasks.length,
|
|
154
|
-
// 人话提示(#74 要求的「本地的某一个队列领取了这个任务」)
|
|
155
|
-
message: imported
|
|
156
|
-
? `已从远程导入 ${imported} 条到「${local.name}」;远程对应任务已标记完成 ${remoteDone} 条`
|
|
157
|
-
: '没有导入任何任务',
|
|
158
|
-
};
|
|
159
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// repo.ref.backfill —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
|
-
//
|
|
3
|
-
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
|
-
import { action } from '../../../runtime/action-decorator.js';
|
|
5
|
-
import { z } from 'zod';
|
|
6
|
-
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
|
-
import * as refBackfillNs from '../ref-backfill.js';
|
|
8
|
-
import { renderBackfill as _renderBackfill } from '../cli/render.js';
|
|
9
|
-
const refBackfill: any = refBackfillNs;
|
|
10
|
-
const renderBackfill: any = _renderBackfill;
|
|
11
|
-
|
|
12
|
-
/** repo.ref.backfill 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
13
|
-
const input = z.object({
|
|
14
|
-
from: z.string(),
|
|
15
|
-
'dry-run': z.boolean().optional().describe("只算差异,不落盘"),
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
export class RepoRefBackfillAction extends ActionBase<typeof input> {
|
|
19
|
-
@action({
|
|
20
|
-
id: 'repo.ref.backfill',
|
|
21
|
-
cli: ['repo', 'ref', 'backfill'],
|
|
22
|
-
http: null,
|
|
23
|
-
summary: '从 v3 快照补录仓库级参考绑定(幂等、可重复;与组级绑定并存;--dry-run 只预览)',
|
|
24
|
-
args: ['from'],
|
|
25
|
-
input,
|
|
26
|
-
render: renderBackfill,
|
|
27
|
-
})
|
|
28
|
-
override async run(ctx: ActionInput<this['_input']>) {
|
|
29
|
-
|
|
30
|
-
return refBackfill.backfillRepoLinks({ from: ctx.from, dryRun: ctx['dry-run'] === true });
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
// 仓库级参考绑定的**补录**工具(不是迁移)。
|
|
2
|
-
//
|
|
3
|
-
// 背景(2026-11-09):v4 迁移把「ref 挂在开发仓库上」搬成了「ref 挂在组上」,
|
|
4
|
-
// 迁移完成后清掉了 dev 侧 ext.ext_linked 里的 {kind:'ref'} 条目。事后口径澄清:
|
|
5
|
-
// **组级与仓库级不是二选一**——参考仓库既可以绑到组,也可以绑到单个开发仓库,
|
|
6
|
-
// 两者并存、互不折算。因此需要把 v4 迁移时搬走的 20 条仓库级绑定恢复回来。
|
|
7
|
-
//
|
|
8
|
-
// **为什么不做成 v5 迁移**:
|
|
9
|
-
// 1. 仓库级绑定的存放位置从来没变过(repos.ext.ext_linked),这次不新增表/列,
|
|
10
|
-
// 升版本只会留下一条「对所有库都生效、但数据源是某一份外部快照」的迁移边;
|
|
11
|
-
// 2. 迁移是「结构演进」,必须对每个库都可执行;而这次的数据源是**一份特定的 v3
|
|
12
|
-
// 快照**,别的库没有这份快照,也不该被强制补录;
|
|
13
|
-
// 3. 补录要可重复、可审计、可预演(dry-run)——这正是工具命令的职责。
|
|
14
|
-
//
|
|
15
|
-
// 本工具只做一件事:读 v3(或更早)快照里每个 dev 仓库的仓库级 ref 绑定,
|
|
16
|
-
// 按 **key** 合并进当前库同名仓库的 linked。**不写 group_refs、不删不改组级绑定**。
|
|
17
|
-
// 因此重复执行是幂等的:第二次跑只会得到 0 条新增。
|
|
18
|
-
import { DatabaseSync } from 'node:sqlite';
|
|
19
|
-
import { existsSync } from 'node:fs';
|
|
20
|
-
import { resolve } from 'node:path';
|
|
21
|
-
import { badInput } from '../../core/errors.js';
|
|
22
|
-
import * as service from './service.js';
|
|
23
|
-
import type { RepoEntry, Store } from './repo/rows.js';
|
|
24
|
-
|
|
25
|
-
function parseExt(text: unknown): Record<string, any> {
|
|
26
|
-
try {
|
|
27
|
-
// ext 列读出恒为 string(空表位给 '{}');unknown 仅是迁移期标注,断言后走原 || 兜底
|
|
28
|
-
return JSON.parse((text as string) || '{}') || {};
|
|
29
|
-
} catch {
|
|
30
|
-
return {};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** 快照里一个 dev 仓库的仓库级 ref 绑定(迁移期宽松形状:落库时才补 kind:'ref')。 */
|
|
35
|
-
interface SourceRepoLinks {
|
|
36
|
-
repo: string;
|
|
37
|
-
links: Array<{ id: string; note?: string }>;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** readSource 的返回:快照版本 + 仓库级绑定清单。 */
|
|
41
|
-
interface SourceSnapshot {
|
|
42
|
-
version: number;
|
|
43
|
-
repos: SourceRepoLinks[];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 从快照读出「仓库 → 仓库级 ref 绑定」。只读打开源库,绝不改它。
|
|
48
|
-
* v4 起的快照里这些条目已被迁移清空(user_version >= 4),直接拒绝,
|
|
49
|
-
* 避免用户拿错文件后得到「0 条 = 看起来成功」的假结果。
|
|
50
|
-
*/
|
|
51
|
-
function readSource(file: string): SourceSnapshot {
|
|
52
|
-
// 快照是外部 SQLite 文件,行形状随版本漂移 → 按 any 读(只读,不落任何东西)
|
|
53
|
-
const db: any = new DatabaseSync(file, { readOnly: true } as any);
|
|
54
|
-
try {
|
|
55
|
-
const version = Number(db.prepare('PRAGMA user_version').get()?.user_version || 0);
|
|
56
|
-
if (version >= 4) {
|
|
57
|
-
throw badInput(
|
|
58
|
-
`快照是 v${version}:v4 迁移已把仓库级绑定搬到组级并清空 ext —— 请给 v3 或更早的快照(~/.nx-kv/backups/nxkv-v3-*.db)`
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
const rows = db.prepare('SELECT key, type, ext FROM repos WHERE deleted_at IS NULL').all();
|
|
62
|
-
const repos: SourceRepoLinks[] = [];
|
|
63
|
-
for (const row of rows) {
|
|
64
|
-
if (row.type === 'group') continue;
|
|
65
|
-
const ext = parseExt(row.ext);
|
|
66
|
-
if (String(ext.ext_legacy_type || 'dev') === 'ref') continue;
|
|
67
|
-
// 快照条目缺 kind(v3 写入侧就不带);kind 在落库合并时统一补 'ref'
|
|
68
|
-
const links: Array<{ id: string; note?: string }> = [];
|
|
69
|
-
const seen = new Set<string>();
|
|
70
|
-
const push = (id: unknown, note: unknown): void => {
|
|
71
|
-
const key = String(id || '').trim();
|
|
72
|
-
if (!key || seen.has(key)) return;
|
|
73
|
-
seen.add(key);
|
|
74
|
-
links.push(note ? { id: key, note: String(note) } : { id: key });
|
|
75
|
-
};
|
|
76
|
-
// v3 现在的键是 ext_linked;更早的库可能还是 ext_linked_refs(纯 id 数组)
|
|
77
|
-
for (const l of Array.isArray(ext.ext_linked) ? ext.ext_linked : []) {
|
|
78
|
-
if (l && l.kind === 'ref') push(l.id, l.note);
|
|
79
|
-
}
|
|
80
|
-
for (const id of Array.isArray(ext.ext_linked_refs) ? ext.ext_linked_refs : []) push(id, '');
|
|
81
|
-
if (links.length) repos.push({ repo: String(row.key), links });
|
|
82
|
-
}
|
|
83
|
-
return { version, repos };
|
|
84
|
-
} finally {
|
|
85
|
-
db.close();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const refKeysOf = (store: Store): Set<string> =>
|
|
90
|
-
new Set(store.repos.filter((r) => (r.type || 'dev') === 'ref').map((r) => service.deriveKey(r)));
|
|
91
|
-
|
|
92
|
-
const directIdsOf = (repo: RepoEntry): string[] => (repo.linked || []).filter((l) => l && l.kind === 'ref').map((l) => String(l.id));
|
|
93
|
-
|
|
94
|
-
const countRepoLinks = (store: Store): number =>
|
|
95
|
-
store.repos
|
|
96
|
-
.filter((r) => (r.type || 'dev') !== 'ref')
|
|
97
|
-
.reduce((n, r) => n + directIdsOf(r).length, 0);
|
|
98
|
-
|
|
99
|
-
const countGroupRefs = (store: Store): number => store.boards.reduce((n, b) => n + (b.refs || []).length, 0);
|
|
100
|
-
|
|
101
|
-
/** perRepo 的一条补录摘要。 */
|
|
102
|
-
export interface BackfillPerRepo {
|
|
103
|
-
repo: string;
|
|
104
|
-
name: string;
|
|
105
|
-
source: string[];
|
|
106
|
-
before: string[];
|
|
107
|
-
after: string[];
|
|
108
|
-
added: string[];
|
|
109
|
-
already: string[];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/** backfillRepoLinks 的返回。 */
|
|
113
|
-
export interface BackfillResult {
|
|
114
|
-
from: string;
|
|
115
|
-
sourceVersion: number;
|
|
116
|
-
dryRun: boolean;
|
|
117
|
-
counts: {
|
|
118
|
-
source: number;
|
|
119
|
-
before: number;
|
|
120
|
-
after: number;
|
|
121
|
-
added: number;
|
|
122
|
-
already: number;
|
|
123
|
-
};
|
|
124
|
-
groupRefs: {
|
|
125
|
-
before: number;
|
|
126
|
-
after: number;
|
|
127
|
-
};
|
|
128
|
-
perRepo: BackfillPerRepo[];
|
|
129
|
-
missing: { repos: string[]; refs: string[] };
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* 补录仓库级 ref 绑定。
|
|
134
|
-
* from v3 快照 db 路径(只读)
|
|
135
|
-
* dryRun 只算差异,不落盘
|
|
136
|
-
*/
|
|
137
|
-
export async function backfillRepoLinks({ from, dryRun = false }: { from?: unknown; dryRun?: boolean } = {}): Promise<BackfillResult> {
|
|
138
|
-
const raw = String(from || '').trim();
|
|
139
|
-
if (!raw) throw badInput('请给 v3 快照路径: nx-kv repo ref backfill <v3.db> [--dry-run]');
|
|
140
|
-
const file = resolve(raw);
|
|
141
|
-
if (!existsSync(file)) throw badInput('快照不存在: ' + file);
|
|
142
|
-
|
|
143
|
-
const src = readSource(file);
|
|
144
|
-
const before = await service.loadStore();
|
|
145
|
-
const refKeys = refKeysOf(before);
|
|
146
|
-
const liveByKey = new Map<string, RepoEntry>(before.repos.map((r): [string, RepoEntry] => [service.deriveKey(r), r]));
|
|
147
|
-
const missing: { repos: string[]; refs: string[] } = { repos: [], refs: [] };
|
|
148
|
-
const perRepo: BackfillPerRepo[] = [];
|
|
149
|
-
let wantAdd = 0;
|
|
150
|
-
let already = 0;
|
|
151
|
-
|
|
152
|
-
for (const item of src.repos) {
|
|
153
|
-
const live = liveByKey.get(item.repo);
|
|
154
|
-
if (!live) {
|
|
155
|
-
missing.repos.push(item.repo);
|
|
156
|
-
continue;
|
|
157
|
-
}
|
|
158
|
-
const had = new Set(directIdsOf(live));
|
|
159
|
-
const added: string[] = [];
|
|
160
|
-
const kept: string[] = [];
|
|
161
|
-
for (const l of item.links) {
|
|
162
|
-
if (!refKeys.has(l.id)) {
|
|
163
|
-
if (!missing.refs.includes(l.id)) missing.refs.push(l.id);
|
|
164
|
-
continue;
|
|
165
|
-
}
|
|
166
|
-
if (had.has(l.id)) kept.push(l.id);
|
|
167
|
-
else added.push(l.id);
|
|
168
|
-
}
|
|
169
|
-
wantAdd += added.length;
|
|
170
|
-
already += kept.length;
|
|
171
|
-
perRepo.push({
|
|
172
|
-
repo: item.repo,
|
|
173
|
-
name: live.name,
|
|
174
|
-
source: item.links.map((l) => l.id).sort(),
|
|
175
|
-
before: [...had].sort(),
|
|
176
|
-
after: [...had, ...added].sort(),
|
|
177
|
-
added: added.sort(),
|
|
178
|
-
already: kept.sort(),
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (!dryRun && wantAdd) {
|
|
183
|
-
await service.mutateStore((s) => {
|
|
184
|
-
const byKey = new Map(s.repos.map((r): [string, RepoEntry] => [service.deriveKey(r), r]));
|
|
185
|
-
const liveRefKeys = refKeysOf(s);
|
|
186
|
-
for (const item of src.repos) {
|
|
187
|
-
const live = byKey.get(item.repo);
|
|
188
|
-
if (!live) continue;
|
|
189
|
-
if (!Array.isArray(live.linked)) live.linked = [];
|
|
190
|
-
for (const l of item.links) {
|
|
191
|
-
if (!liveRefKeys.has(l.id)) continue;
|
|
192
|
-
const hit = live.linked.find((x) => x && x.kind === 'ref' && String(x.id) === l.id);
|
|
193
|
-
if (!hit) live.linked.push(l.note ? { kind: 'ref', id: l.id, note: l.note } : { kind: 'ref', id: l.id });
|
|
194
|
-
else if (l.note && !hit.note) hit.note = l.note;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const after = dryRun ? null : await service.loadStore();
|
|
201
|
-
return {
|
|
202
|
-
from: file,
|
|
203
|
-
sourceVersion: src.version,
|
|
204
|
-
dryRun,
|
|
205
|
-
counts: {
|
|
206
|
-
source: src.repos.reduce((n, x) => n + x.links.length, 0),
|
|
207
|
-
before: countRepoLinks(before),
|
|
208
|
-
after: dryRun ? countRepoLinks(before) + wantAdd : countRepoLinks(after!),
|
|
209
|
-
added: wantAdd,
|
|
210
|
-
already,
|
|
211
|
-
},
|
|
212
|
-
groupRefs: {
|
|
213
|
-
before: countGroupRefs(before),
|
|
214
|
-
after: after ? countGroupRefs(after) : countGroupRefs(before),
|
|
215
|
-
},
|
|
216
|
-
perRepo,
|
|
217
|
-
missing,
|
|
218
|
-
};
|
|
219
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
// AUTO-GENERATED —— 由 scripts/gen-actions.mjs 生成,勿手改。
|
|
2
|
-
//
|
|
3
|
-
// 收录本目录下所有继承 ActionBase 的类。**加一条 action = 新建一个文件 +
|
|
4
|
-
// 跑 `pnpm gen`**;模块的 index.ts 不需要改。
|
|
5
|
-
// 新鲜度由 tests/unit/action-registry.test.mjs 对账。
|
|
6
|
-
|
|
7
|
-
import type { ActionBase } from '../../../runtime/action-base.js';
|
|
8
|
-
import type { Container } from '../../../runtime/container.js';
|
|
9
|
-
import { GroupAddAction } from './group-add.js';
|
|
10
|
-
import { GroupCurrentAction } from './group-current.js';
|
|
11
|
-
import { GroupGetAction } from './group-get.js';
|
|
12
|
-
import { GroupListAction } from './group-list.js';
|
|
13
|
-
import { GroupMembersAction } from './group-members.js';
|
|
14
|
-
import { GroupRemoveAction } from './group-remove.js';
|
|
15
|
-
import { GroupUpdateAction } from './group-update.js';
|
|
16
|
-
import { GroupUseAction } from './group-use.js';
|
|
17
|
-
import { PromptGetAction } from './prompt-get.js';
|
|
18
|
-
import { PromptRemoveAction } from './prompt-remove.js';
|
|
19
|
-
import { PromptSetAction } from './prompt-set.js';
|
|
20
|
-
import { TodoAddAction } from './todo-add.js';
|
|
21
|
-
import { TodoArchiveAction } from './todo-archive.js';
|
|
22
|
-
import { TodoAttachAction } from './todo-attach.js';
|
|
23
|
-
import { TodoAttachmentsAction } from './todo-attachments.js';
|
|
24
|
-
import { TodoDoneAction } from './todo-done.js';
|
|
25
|
-
import { TodoFreezeAction } from './todo-freeze.js';
|
|
26
|
-
import { TodoGetAction } from './todo-get.js';
|
|
27
|
-
import { TodoListAction } from './todo-list.js';
|
|
28
|
-
import { TodoRemoveAction } from './todo-remove.js';
|
|
29
|
-
import { TodoUnfreezeAction } from './todo-unfreeze.js';
|
|
30
|
-
import { TodoUpdateAction } from './todo-update.js';
|
|
31
|
-
import { TopicAddAction } from './topic-add.js';
|
|
32
|
-
import { TopicListAction } from './topic-list.js';
|
|
33
|
-
import { TopicRemoveAction } from './topic-remove.js';
|
|
34
|
-
|
|
35
|
-
/** 本模块的全部 action 类(容器按这个顺序建实例)。 */
|
|
36
|
-
export const ACTIONS: readonly (new (deps: Container) => ActionBase)[] = [
|
|
37
|
-
GroupAddAction,
|
|
38
|
-
GroupCurrentAction,
|
|
39
|
-
GroupGetAction,
|
|
40
|
-
GroupListAction,
|
|
41
|
-
GroupMembersAction,
|
|
42
|
-
GroupRemoveAction,
|
|
43
|
-
GroupUpdateAction,
|
|
44
|
-
GroupUseAction,
|
|
45
|
-
PromptGetAction,
|
|
46
|
-
PromptRemoveAction,
|
|
47
|
-
PromptSetAction,
|
|
48
|
-
TodoAddAction,
|
|
49
|
-
TodoArchiveAction,
|
|
50
|
-
TodoAttachAction,
|
|
51
|
-
TodoAttachmentsAction,
|
|
52
|
-
TodoDoneAction,
|
|
53
|
-
TodoFreezeAction,
|
|
54
|
-
TodoGetAction,
|
|
55
|
-
TodoListAction,
|
|
56
|
-
TodoRemoveAction,
|
|
57
|
-
TodoUnfreezeAction,
|
|
58
|
-
TodoUpdateAction,
|
|
59
|
-
TopicAddAction,
|
|
60
|
-
TopicListAction,
|
|
61
|
-
TopicRemoveAction,
|
|
62
|
-
];
|
|
63
|
-
|
|
64
|
-
// 再导出类本身:前端 apiclient 的返回类型从这里 type-only 引用(实现即契约)。
|
|
65
|
-
export { GroupAddAction };
|
|
66
|
-
export { GroupCurrentAction };
|
|
67
|
-
export { GroupGetAction };
|
|
68
|
-
export { GroupListAction };
|
|
69
|
-
export { GroupMembersAction };
|
|
70
|
-
export { GroupRemoveAction };
|
|
71
|
-
export { GroupUpdateAction };
|
|
72
|
-
export { GroupUseAction };
|
|
73
|
-
export { PromptGetAction };
|
|
74
|
-
export { PromptRemoveAction };
|
|
75
|
-
export { PromptSetAction };
|
|
76
|
-
export { TodoAddAction };
|
|
77
|
-
export { TodoArchiveAction };
|
|
78
|
-
export { TodoAttachAction };
|
|
79
|
-
export { TodoAttachmentsAction };
|
|
80
|
-
export { TodoDoneAction };
|
|
81
|
-
export { TodoFreezeAction };
|
|
82
|
-
export { TodoGetAction };
|
|
83
|
-
export { TodoListAction };
|
|
84
|
-
export { TodoRemoveAction };
|
|
85
|
-
export { TodoUnfreezeAction };
|
|
86
|
-
export { TodoUpdateAction };
|
|
87
|
-
export { TopicAddAction };
|
|
88
|
-
export { TopicListAction };
|
|
89
|
-
export { TopicRemoveAction };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// group.add —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
|
-
//
|
|
3
|
-
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
|
-
import { action } from '../../../runtime/action-decorator.js';
|
|
5
|
-
import { z } from 'zod';
|
|
6
|
-
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
|
-
import { requireAuth as _requireAuth } from '../../../core/config.js';
|
|
8
|
-
import { createGroup as _createGroup } from '../../../core/kvapi.js';
|
|
9
|
-
const requireAuth: any = _requireAuth;
|
|
10
|
-
const createGroup: any = _createGroup;
|
|
11
|
-
|
|
12
|
-
/** group.add 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
13
|
-
const input = z.object({
|
|
14
|
-
name: z.string(),
|
|
15
|
-
description: z.string().optional().describe("描述"),
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
export class GroupAddAction extends ActionBase<typeof input> {
|
|
19
|
-
@action({
|
|
20
|
-
id: 'group.add',
|
|
21
|
-
cli: ['group', 'add'],
|
|
22
|
-
http: ['POST', '/api/groups'],
|
|
23
|
-
summary: '新建工作空间',
|
|
24
|
-
args: ['name'],
|
|
25
|
-
input,
|
|
26
|
-
render: (g: any) => `已新建工作空间: ${g.name}(id=${g.id})\n用 nx-kv group use ${g.id} 切过去`,
|
|
27
|
-
})
|
|
28
|
-
override async run(ctx: ActionInput<this['_input']>) {
|
|
29
|
-
|
|
30
|
-
await requireAuth();
|
|
31
|
-
return createGroup({ name: ctx.name, description: ctx.description });
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// group.current —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
|
-
//
|
|
3
|
-
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
|
-
import { action } from '../../../runtime/action-decorator.js';
|
|
5
|
-
import { z } from 'zod';
|
|
6
|
-
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
|
-
import { loadConfig as _loadConfig } from '../../../core/config.js';
|
|
8
|
-
import { listGroups as _listGroups } from '../../../core/kvapi.js';
|
|
9
|
-
const loadConfig: any = _loadConfig;
|
|
10
|
-
const listGroups: any = _listGroups;
|
|
11
|
-
|
|
12
|
-
/** group.current 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
13
|
-
const input = z.object({
|
|
14
|
-
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export class GroupCurrentAction extends ActionBase<typeof input> {
|
|
18
|
-
@action({
|
|
19
|
-
id: 'group.current',
|
|
20
|
-
cli: ['group', 'current'],
|
|
21
|
-
http: ['GET', '/api/group'],
|
|
22
|
-
summary: '查看当前工作空间',
|
|
23
|
-
input,
|
|
24
|
-
render: (d: any) => `当前工作空间: ${d.name}(${d.id === 0 ? '默认组,不传 groupId' : 'id=' + d.id})`,
|
|
25
|
-
})
|
|
26
|
-
override async run(_ctx: ActionInput<this['_input']>) {
|
|
27
|
-
|
|
28
|
-
const cfg: any = await loadConfig();
|
|
29
|
-
if (!cfg.groupId) return { id: 0, name: '默认组' };
|
|
30
|
-
// 名字是尽力而为:后端不可达时不该让「看当前是什么」失败
|
|
31
|
-
const groups: any = await listGroups().catch(() => []);
|
|
32
|
-
const hit: any = groups.find((g: any) => g.id === cfg.groupId);
|
|
33
|
-
return { id: cfg.groupId, name: hit ? hit.name : `#${cfg.groupId}` };
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// group.get —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
|
-
//
|
|
3
|
-
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
|
-
import { action } from '../../../runtime/action-decorator.js';
|
|
5
|
-
import { z } from 'zod';
|
|
6
|
-
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
|
-
import { loadConfig as _loadConfig, requireAuth as _requireAuth } from '../../../core/config.js';
|
|
8
|
-
import { findGroup } from '../support.js';
|
|
9
|
-
const loadConfig: any = _loadConfig;
|
|
10
|
-
const requireAuth: any = _requireAuth;
|
|
11
|
-
|
|
12
|
-
/** group.get 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
13
|
-
const input = z.object({
|
|
14
|
-
id: z.string(),
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export class GroupGetAction extends ActionBase<typeof input> {
|
|
18
|
-
@action({
|
|
19
|
-
id: 'group.get',
|
|
20
|
-
cli: ['group', 'get'],
|
|
21
|
-
http: ['GET', '/api/groups/:id'],
|
|
22
|
-
summary: '查看单个工作空间',
|
|
23
|
-
args: ['id'],
|
|
24
|
-
input,
|
|
25
|
-
render: (g: any) =>
|
|
26
|
-
[
|
|
27
|
-
`${g.name}${g.current ? ' ← 当前' : ''}`,
|
|
28
|
-
` id: ${g.id}`,
|
|
29
|
-
` 角色: ${g.myRole || '-'}`,
|
|
30
|
-
` 成员: ${g.memberCount} 人`,
|
|
31
|
-
` 描述: ${g.description || '-'}`,
|
|
32
|
-
` 创建: ${String(g.createdAt || '').slice(0, 10) || '-'}`,
|
|
33
|
-
].join('\n'),
|
|
34
|
-
})
|
|
35
|
-
override async run(ctx: ActionInput<this['_input']>) {
|
|
36
|
-
|
|
37
|
-
await requireAuth();
|
|
38
|
-
const g: any = await findGroup(ctx.id);
|
|
39
|
-
const cfg: any = await loadConfig();
|
|
40
|
-
return { ...g, current: g.id === cfg.groupId };
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// group.list —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
|
-
//
|
|
3
|
-
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
|
-
import { action } from '../../../runtime/action-decorator.js';
|
|
5
|
-
import { z } from 'zod';
|
|
6
|
-
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
|
-
import { loadConfig as _loadConfig, requireAuth as _requireAuth } from '../../../core/config.js';
|
|
8
|
-
import { listGroups as _listGroups } from '../../../core/kvapi.js';
|
|
9
|
-
import { renderGroupLine } from '../support.js';
|
|
10
|
-
const loadConfig: any = _loadConfig;
|
|
11
|
-
const requireAuth: any = _requireAuth;
|
|
12
|
-
const listGroups: any = _listGroups;
|
|
13
|
-
|
|
14
|
-
/** group.list 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
15
|
-
const input = z.object({
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export class GroupListAction extends ActionBase<typeof input> {
|
|
20
|
-
@action({
|
|
21
|
-
id: 'group.list',
|
|
22
|
-
cli: ['group', 'list'],
|
|
23
|
-
http: ['GET', '/api/groups'],
|
|
24
|
-
summary: '列出我的工作空间(* 为当前)',
|
|
25
|
-
input,
|
|
26
|
-
render: (d: any) => {
|
|
27
|
-
if (!d.groups.length) return '(没有可用工作空间)';
|
|
28
|
-
return d.groups.map((g: any) => renderGroupLine(g, g.current)).join('\n');
|
|
29
|
-
},
|
|
30
|
-
})
|
|
31
|
-
override async run(_ctx: ActionInput<this['_input']>) {
|
|
32
|
-
|
|
33
|
-
await requireAuth();
|
|
34
|
-
const [groups, cfg] = await Promise.all([listGroups(), loadConfig()]);
|
|
35
|
-
return {
|
|
36
|
-
current: cfg.groupId,
|
|
37
|
-
groups: groups.map((g: any) => ({ ...g, current: g.id === cfg.groupId })),
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
}
|