nx-kv 0.69.1 → 0.70.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 +47 -0
- package/README.md +20 -2
- package/package.json +21 -8
- package/packages/plugin-dir-annotate/dist/client/client.js +3 -0
- package/packages/plugin-dir-annotate/dist/client/style.css +2 -0
- package/packages/plugin-dir-annotate/dist/server/index.js +109 -0
- package/packages/plugin-dir-annotate/package.json +31 -0
- package/packages/plugin-dir-annotate/src/client/AnnotatePage.tsx +313 -0
- package/packages/plugin-dir-annotate/src/client/SettingsPage.tsx +116 -0
- package/packages/plugin-dir-annotate/src/client/index.tsx +23 -0
- package/packages/plugin-dir-annotate/src/client/style.css +91 -0
- package/packages/plugin-dir-annotate/src/server/index.ts +43 -0
- package/packages/plugin-dir-annotate/src/server/settings.ts +75 -0
- package/packages/plugin-dir-annotate/tsconfig.client.json +13 -0
- package/packages/plugin-dir-annotate/tsconfig.server.json +16 -0
- package/packages/plugin-dir-annotate/vite.config.ts +33 -0
- package/packages/plugin-sdk/dist/client.d.ts +56 -0
- package/packages/plugin-sdk/dist/client.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/client.js +2 -0
- package/packages/plugin-sdk/dist/client.js.map +1 -0
- package/packages/plugin-sdk/dist/index.d.ts +160 -0
- package/packages/plugin-sdk/dist/index.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/index.js +28 -0
- package/packages/plugin-sdk/dist/index.js.map +1 -0
- package/packages/plugin-sdk/dist/template.d.ts +5 -0
- package/packages/plugin-sdk/dist/template.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/template.js +23 -0
- package/packages/plugin-sdk/dist/template.js.map +1 -0
- package/packages/plugin-sdk/package.json +27 -0
- package/packages/plugin-sdk/src/client.ts +63 -0
- package/packages/plugin-sdk/src/index.ts +183 -0
- package/packages/plugin-sdk/src/template.ts +24 -0
- package/packages/plugin-sdk/tsconfig.json +17 -0
- package/packages/plugin-task-template/dist/client/client.js +9 -0
- package/packages/plugin-task-template/dist/client/style.css +2 -0
- package/packages/plugin-task-template/dist/server/index.js +557 -0
- package/packages/plugin-task-template/package.json +31 -0
- package/packages/plugin-task-template/src/client/EntryForm.tsx +84 -0
- package/packages/plugin-task-template/src/client/EntryRow.tsx +15 -0
- package/packages/plugin-task-template/src/client/ManagePage.tsx +229 -0
- package/packages/plugin-task-template/src/client/index.tsx +28 -0
- package/packages/plugin-task-template/src/client/style.css +67 -0
- package/packages/plugin-task-template/src/server/builtin-body.ts +79 -0
- package/packages/plugin-task-template/src/server/index.ts +141 -0
- package/packages/plugin-task-template/src/server/scope.ts +56 -0
- package/packages/plugin-task-template/src/server/storage.ts +32 -0
- package/packages/plugin-task-template/src/server/templates.ts +317 -0
- package/packages/plugin-task-template/tsconfig.client.json +13 -0
- package/packages/plugin-task-template/tsconfig.server.json +16 -0
- package/packages/plugin-task-template/vite.config.ts +33 -0
- package/src/core/attachmentdb/resources.ts +8 -7
- package/src/core/db/bootstrap.ts +1 -10
- package/src/core/db/import-json/extras.ts +52 -32
- package/src/core/db/migrations/index.ts +8 -0
- package/src/core/db/migrations/v19-data.ts +62 -0
- package/src/core/db/migrations/v19.sql +41 -0
- package/src/core/db/migrations/v20-data.ts +71 -0
- package/src/core/db/migrations/v20.sql +6 -0
- package/src/core/db/migrations/v21.sql +7 -0
- package/src/core/db/repo-match.ts +0 -6
- package/src/core/db/verify.ts +4 -1
- package/src/core/db/version.ts +7 -1
- package/src/modules/db/actions/_manifest.generated.ts +3 -0
- package/src/modules/db/actions/db-data.ts +28 -0
- package/src/modules/db/service.ts +139 -0
- package/src/modules/localtask/actions/localtask-boardtasks.ts +3 -16
- package/src/modules/localtask/actions/localtask-reopen.ts +1 -1
- package/src/modules/localtask/actions/localtask-tasks.ts +5 -18
- package/src/modules/localtask/infra/repo/tasks.ts +3 -3
- package/src/modules/localtask/infra/repo/topics.ts +8 -45
- package/src/modules/localtask/lifecycle/task-ops.ts +14 -0
- package/src/modules/localtask/lifecycle/task-view.ts +3 -6
- package/src/modules/localtask/lifecycle/topics.ts +13 -4
- package/src/modules/localtask/ops/attach-resource.ts +1 -7
- package/src/modules/plugin/actions/_manifest.generated.ts +47 -0
- package/src/modules/plugin/actions/plugin-context.ts +41 -0
- package/src/modules/plugin/actions/plugin-entries.ts +42 -0
- package/src/modules/plugin/actions/plugin-file.ts +28 -0
- package/src/modules/plugin/actions/plugin-list.ts +30 -0
- package/src/modules/plugin/actions/plugin-rpc.ts +37 -0
- package/src/modules/plugin/actions/plugin-set-default.ts +23 -0
- package/src/modules/plugin/actions/plugin-set-state.ts +26 -0
- package/src/modules/plugin/actions/plugin-set-visibility.ts +42 -0
- package/src/modules/plugin/actions/plugin-tree.ts +31 -0
- package/src/modules/plugin/actions/plugin-visibility.ts +28 -0
- package/src/modules/plugin/actions/pretask-draft.ts +47 -0
- package/src/modules/plugin/assets.ts +51 -0
- package/src/modules/plugin/context.ts +196 -0
- package/src/modules/plugin/fs.ts +169 -0
- package/src/modules/plugin/host.ts +396 -0
- package/src/modules/plugin/index.ts +21 -0
- package/src/modules/plugin/plugins.generated.ts +14 -0
- package/src/modules/plugin/registry.ts +109 -0
- package/src/modules/plugin/repo/db.ts +12 -0
- package/src/modules/plugin/repo/legacy.ts +45 -0
- package/src/modules/plugin/repo/migrations.ts +22 -0
- package/src/modules/plugin/repo/state.ts +32 -0
- package/src/modules/plugin/repo/visibility.ts +94 -0
- package/src/modules/plugin/service.ts +12 -0
- package/src/modules/plugin/template.ts +16 -0
- package/src/modules/repos/actions/_manifest.generated.ts +3 -0
- package/src/modules/repos/actions/repo-dirs.ts +37 -0
- package/src/modules/repos/service/dirs.ts +61 -0
- package/src/runtime/registry.ts +2 -2
- package/src/runtime/server.ts +36 -0
- package/src/shared/task-title.ts +32 -0
- package/src/web/frontend/App.tsx +29 -65
- package/src/web/frontend/api/cli-tree.json +163 -49
- package/src/web/frontend/api/client.generated.ts +159 -60
- package/src/web/frontend/app-context.tsx +0 -3
- package/src/web/frontend/components/layout/crumbs.ts +13 -10
- package/src/web/frontend/components/layout/vsc-crumbs-model.ts +1 -0
- package/src/web/frontend/components/layout/vsc-crumbs.css +15 -0
- package/src/web/frontend/components/layout/vsc-crumbs.tsx +11 -0
- package/src/web/frontend/components/md/composer/composer-panel.tsx +14 -144
- package/src/web/frontend/components/md/panes/md-panes.tsx +2 -0
- package/src/web/frontend/components/md/pm/pm-editor-host.tsx +35 -0
- package/src/web/frontend/components/md/pm/pm-editor.tsx +209 -0
- package/src/web/frontend/components/md/pm/pm.css +47 -0
- package/src/web/frontend/components/popup/index.tsx +9 -0
- package/src/web/frontend/components/popup/style.css +4 -0
- package/src/web/frontend/components/sidebar/index.tsx +5 -3
- package/src/web/frontend/components/sidebar/ns-dialogs.tsx +2 -2
- package/src/web/frontend/components/sidebar/ns-manage-modal.tsx +75 -17
- package/src/web/frontend/components/sidebar/plugin-foot.tsx +30 -0
- package/src/web/frontend/components/sidebar/queue-nav.ts +15 -10
- package/src/web/frontend/components/sidebar/task-children.tsx +23 -3
- package/src/web/frontend/components/sidebar/use-ns.ts +12 -14
- package/src/web/frontend/components/tool-acts/layout-panel.tsx +2 -8
- package/src/web/frontend/components/tool-acts/style.css +0 -2
- package/src/web/frontend/modules/md/md-parse.ts +1 -1
- package/src/web/frontend/modules/md/pm/adapter.ts +99 -0
- package/src/web/frontend/modules/md/pm/inline.ts +241 -0
- package/src/web/frontend/modules/md/pm/schema.ts +150 -0
- package/src/web/frontend/modules/md/styles/panels.css +3 -0
- package/src/web/frontend/modules/pretask/menu.tsx +31 -0
- package/src/web/frontend/modules/pretask/open-entry.ts +139 -0
- package/src/web/frontend/modules/pretask/types.ts +45 -0
- package/src/web/frontend/modules/pretask/use-plugins.ts +45 -0
- package/src/web/frontend/modules/pretask/use-pretask.ts +111 -0
- package/src/web/frontend/page/data/api.ts +49 -0
- package/src/web/frontend/page/data/index.tsx +89 -0
- package/src/web/frontend/page/data/style.css +84 -0
- package/src/web/frontend/page/data/table-view.tsx +126 -0
- package/src/web/frontend/page/dir/index.tsx +52 -57
- package/src/web/frontend/page/dir/task-actions.ts +6 -5
- package/src/web/frontend/page/dir/task-preview-modal.tsx +1 -1
- package/src/web/frontend/page/dir/task-utils.ts +3 -2
- package/src/web/frontend/page/dir/task.tsx +15 -10
- package/src/web/frontend/page/doc/index.tsx +4 -2
- package/src/web/frontend/page/group/index.tsx +90 -72
- package/src/web/frontend/page/settings/index.tsx +14 -1
- package/src/web/frontend/page/settings/plugins-section.tsx +78 -0
- package/src/web/frontend/panels.tsx +15 -26
- package/src/web/frontend/plugin-host/loader.ts +92 -0
- package/src/web/frontend/plugin-host/plugin-component.tsx +22 -0
- package/src/web/frontend/plugin-host/plugin-page.tsx +103 -0
- package/src/web/frontend/plugin-host/registry.ts +80 -0
- package/src/web/frontend/plugin-host/session.ts +29 -0
- package/src/web/frontend/plugin-host/style.css +41 -0
- package/src/web/frontend/plugin-host/visibility-panel.tsx +233 -0
- package/src/web/frontend/registry.ts +2 -0
- package/src/web/frontend/routes/index.ts +4 -3
- package/src/web/frontend/routes/plugin.ts +37 -0
- package/src/web/frontend/routes/route-eq.ts +5 -1
- package/src/web/frontend/routes/static.ts +3 -0
- package/src/web/frontend/styles-v2/sidebar.css +21 -2
- package/src/web/frontend/types.ts +5 -40
- package/src/web/frontend/use-ns-persist.ts +15 -4
- package/src/web/frontend/workspace/areas.ts +2 -1
- package/src/web/frontend/workspace/open.ts +32 -1
- package/src/web/frontend/workspace/panels.ts +1 -1
- package/src/web/public/assets/app-context-DnSScbEM.js +1 -0
- package/src/web/public/assets/bar-BEUdeltT.js +1 -0
- package/src/web/public/assets/board-view-DS6VzeG9.js +1 -0
- package/src/web/public/assets/client-73i4d2M4.js +1 -0
- package/src/web/public/assets/composer-launch-BOiu_85p.js +1 -0
- package/src/web/public/assets/composer-panel-BTWUPrF4.js +1 -0
- package/src/web/public/assets/dag-HEqXue8k.js +1 -0
- package/src/web/public/assets/data-Br0MR-Xk.css +1 -0
- package/src/web/public/assets/data-DJR0eP7U.js +1 -0
- package/src/web/public/assets/dir-BvcqEReL.js +1 -0
- package/src/web/public/assets/doc-store-sv1-1xal.js +1 -0
- package/src/web/public/assets/group-DhOuMegf.js +1 -0
- package/src/web/public/assets/icons-B05qzdxw.js +1 -0
- package/src/web/public/assets/index-BTYjj0YL.css +1 -0
- package/src/web/public/assets/index-_cjoyGJr.js +27 -0
- package/src/web/public/assets/md-history-CumFTbbK.js +45 -0
- package/src/web/public/assets/md-parse-BhjiD83o.js +6 -0
- package/src/web/public/assets/member-picker-B2EiDJ87.js +1 -0
- package/src/web/public/assets/plugin-component-BL69zZxx.js +1 -0
- package/src/web/public/assets/plugin-page-CLYrGvrM.js +1 -0
- package/src/web/public/assets/popup-DqWl8bjK.js +1 -0
- package/src/web/public/assets/popup-DrRYEe1w.css +1 -0
- package/src/web/public/assets/progress-DeGuv-S0.js +3 -0
- package/src/web/public/assets/refs-XyV92GFq.js +2 -0
- package/src/web/public/assets/registry-B4536DGP.js +1 -0
- package/src/web/public/assets/{reopen-text-D0eQ2XAC.js → reopen-text-cEGm0jzz.js} +1 -1
- package/src/web/public/assets/repos-BtKLD2-Y.js +12 -0
- package/src/web/public/assets/session-y2Ujr5bl.js +1 -0
- package/src/web/public/assets/settings-C6Wp4TEN.js +1 -0
- package/src/web/public/assets/style-BjfD0mtO.css +1 -0
- package/src/web/public/assets/task-DGOTk3il.css +1 -0
- package/src/web/public/assets/task-Dntjc9kS.js +14 -0
- package/src/web/public/assets/task-ops-V0KvmOJt.js +2 -0
- package/src/web/public/assets/task-status-DmR2rgbz.js +1 -0
- package/src/web/public/assets/task-utils-BJnDgdnA.js +1 -0
- package/src/web/public/assets/toast-OkR-KSSm.css +1 -0
- package/src/web/public/assets/toast-RYmip1Zl.js +1 -0
- package/src/web/public/assets/{tool-bar-CLIs9Dr0.css → tool-bar-B3K3eMeS.css} +1 -1
- package/src/web/public/assets/tool-bar-CeRPJ9OK.js +1 -0
- package/src/web/public/assets/use-pretask-QAtAPePc.js +1 -0
- package/src/web/public/assets/visibility-panel-BhCkxAHB.js +1 -0
- package/src/web/public/assets/workspace-C7kkUJNn.js +28 -0
- package/src/web/public/index.html +20 -17
- package/src/core/db/seed-templates.ts +0 -202
- package/src/modules/templates/actions/_manifest.generated.ts +0 -32
- package/src/modules/templates/actions/template-add.ts +0 -52
- package/src/modules/templates/actions/template-default.ts +0 -45
- package/src/modules/templates/actions/template-list.ts +0 -34
- package/src/modules/templates/actions/template-remove.ts +0 -31
- package/src/modules/templates/actions/template-reorder.ts +0 -28
- package/src/modules/templates/actions/template-update.ts +0 -43
- package/src/modules/templates/index.ts +0 -24
- package/src/modules/templates/repo/index.ts +0 -16
- package/src/modules/templates/repo/open.ts +0 -72
- package/src/modules/templates/repo/templates.ts +0 -185
- package/src/modules/templates/scope.ts +0 -113
- package/src/modules/templates/service.ts +0 -409
- package/src/modules/templates/support.ts +0 -32
- package/src/web/frontend/modules/md/fill-session.ts +0 -36
- package/src/web/frontend/modules/md/manage-session.ts +0 -24
- package/src/web/frontend/modules/md/new-task-from-template.ts +0 -22
- package/src/web/frontend/modules/md/use-templates.ts +0 -183
- package/src/web/frontend/modules/prompts/render-template-body.ts +0 -14
- package/src/web/frontend/modules/prompts/template-preview.ts +0 -61
- package/src/web/frontend/page/templates/fill.tsx +0 -128
- package/src/web/frontend/page/templates/index.tsx +0 -297
- package/src/web/frontend/page/templates/manage.tsx +0 -188
- package/src/web/frontend/page/templates/style.css +0 -93
- package/src/web/frontend/page/templates/template-list.tsx +0 -175
- package/src/web/frontend/routes/templates.ts +0 -85
- package/src/web/public/assets/app-context-DPFYOrgE.js +0 -1
- package/src/web/public/assets/bar-I4qGaKTO.js +0 -1
- package/src/web/public/assets/board-view-jt8QixVg.js +0 -1
- package/src/web/public/assets/button-DA4lNJeC.css +0 -1
- package/src/web/public/assets/button-VP4pjVsx.js +0 -1
- package/src/web/public/assets/composer-launch-C20VCKMu.js +0 -1
- package/src/web/public/assets/composer-panel-C3ET4SBT.js +0 -1
- package/src/web/public/assets/dag-xQRISqLX.js +0 -1
- package/src/web/public/assets/dir-B-UPu7OY.js +0 -1
- package/src/web/public/assets/doc-Ka-2V5jn.css +0 -1
- package/src/web/public/assets/doc-zDLeR8PE.js +0 -6
- package/src/web/public/assets/group-Hh-NL_sa.js +0 -1
- package/src/web/public/assets/index-DXJxcKIU.css +0 -1
- package/src/web/public/assets/index-Di6ErKBG.js +0 -3
- package/src/web/public/assets/manage-session-CuaL7QqQ.js +0 -1
- package/src/web/public/assets/md-history-B7TamGno.js +0 -45
- package/src/web/public/assets/md-parse-BjzYV8n7.js +0 -6
- package/src/web/public/assets/member-picker-BtWykPer.js +0 -1
- package/src/web/public/assets/popup-DLfU1TXG.js +0 -1
- package/src/web/public/assets/popup-DzBICcYS.css +0 -1
- package/src/web/public/assets/progress-CQAvP9-n.js +0 -3
- package/src/web/public/assets/refs-C6rZJhnb.js +0 -2
- package/src/web/public/assets/repo-form-modal-DpwLdBYp.js +0 -1
- package/src/web/public/assets/repos-BjVw1SQ2.js +0 -12
- package/src/web/public/assets/route-crumb-DS76cmRK.js +0 -1
- package/src/web/public/assets/settings-C1NfJqNk.js +0 -1
- package/src/web/public/assets/task-Dcd2eA8B.css +0 -1
- package/src/web/public/assets/task-Ddr-iU14.js +0 -14
- package/src/web/public/assets/task-ops-s9kkuLcK.js +0 -2
- package/src/web/public/assets/task-utils-Y-j-zi8J.js +0 -1
- package/src/web/public/assets/template-preview-EM3OQ1Rc.js +0 -1
- package/src/web/public/assets/templates-BnEJVU91.js +0 -10
- package/src/web/public/assets/templates-DiEKBY-m.css +0 -1
- package/src/web/public/assets/tool-bar-NHeX0Kmo.js +0 -28
- package/src/web/public/assets/use-rail-drag-4iK6t5ab.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,53 @@
|
|
|
2
2
|
|
|
3
3
|
本文件对外可见的变更。格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/)。
|
|
4
4
|
|
|
5
|
+
## [0.70.0] - 2026-11-27 内部插件体系(任务模板迁出 + 目录批注)+ schema v19~v21
|
|
6
|
+
|
|
7
|
+
本轮主线:把 pretask 能力改造成**自封闭的内部插件**——插件自带 server 契约、client UI、自有存储与
|
|
8
|
+
自注册入口/页面/侧栏,`nx-kv` 只负责生命周期控制与调用。两个内置插件随 npm 包分发,`npx nx-kv`
|
|
9
|
+
安装后直接可用(无需另装插件)。
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **插件 SDK + 宿主**(`packages/plugin-sdk`、`src/modules/plugin/`):`definePlugin`(entries /
|
|
14
|
+
buildDraft / rpc / migrateStorage / migrateLegacy)与 client `registerPlugin`(components / pages /
|
|
15
|
+
sidebar);宿主按 `nxkv` 清单发现包、聚合入口、按 scope 控制可见性与「新建页」默认项。
|
|
16
|
+
- **第二个插件:目录批注**(`packages/plugin-dir-annotate`):新建页下拉只注册一个面板入口;
|
|
17
|
+
repo 主题直接进项目目录,group 主题先列组内仓库(选择在插件内部),给文件加批注后通过
|
|
18
|
+
`createDraft` 生成任务草稿;左下角自注册「目录批注设置」(隐藏文件 / 当前目录 / 标题前缀)。
|
|
19
|
+
- **插件上下文与宿主 HTTP 能力**:`PretaskContext` 携带完整 `topic` / `location`;
|
|
20
|
+
新增 `/api/plugins/context|tree|file`(realpath 约束、拒软链与重目录、限目录项数与文件大小)。
|
|
21
|
+
- **插件边界门禁**:`scripts/check-plugin-isolation.mjs`(清单一致、双向 import 闭合、发布面规则)
|
|
22
|
+
与通用构建 `scripts/build-plugins.mjs`(不再在根 package.json 逐个列插件)。
|
|
23
|
+
- **schema v21**:`plugin_entry_visibility.is_default`——每个 scope 可指定「+ 新建页」默认触发项
|
|
24
|
+
(草稿或面板);默认优先级:scope 配置 > 插件声明 > 首个可见草稿 > 第一个可见入口。
|
|
25
|
+
- 开发手册:`dev-nxkv` 新增 `A13-开发或扩展插件.md` + `B09-插件架构与契约.md`。
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- **任务模板整体迁为插件**(`packages/plugin-task-template`):旧 `src/modules/templates/**`、前端模板页与
|
|
30
|
+
`seed-templates.ts` 全部删除;v19 把旧 `templates` 行暂存到 `plugin_legacy_data`,插件首次激活按 id
|
|
31
|
+
幂等导入自有表,v20 删除 `templates`。
|
|
32
|
+
- 「管理任务模板…」不再出现在每个主题的新建页下拉——插件自管理页只在左下角侧栏出现。
|
|
33
|
+
- 「新建页行为」配置页:主区单选默认项,可见性多选收进默认折叠的「高级」区;下拉行移除「默认」徽标
|
|
34
|
+
(插件级默认改称「插件默认」,只在插件管理页展示)。
|
|
35
|
+
- **发布形态内置**:插件包 `private`,server 由 Vite 打成单文件(SDK 内联);根 `files` 带 `packages/`,
|
|
36
|
+
`dependencies` 不含任何 `@nx-kv/*`,`tsx` 移入 `dependencies` 供 `bin/kv.mjs` 运行时使用。
|
|
37
|
+
|
|
38
|
+
### Fixed
|
|
39
|
+
|
|
40
|
+
- 左下角两个插件页无法互切:插件页 `view/key/task` 恒空,`sameRoute` 与路由 effect 的 `routeSig` 补齐
|
|
41
|
+
`pluginId/pageId/sessionId`。
|
|
42
|
+
- 组主题下插件自选仓库时,草稿归属仍按默认成员落库:`createDraft` 支持 `{ project, board }` 覆盖。
|
|
43
|
+
- 目录批注生成的标题/正文误用默认成员名:组场景改按「组 / 所选仓库」生成。
|
|
44
|
+
|
|
45
|
+
### Verification
|
|
46
|
+
|
|
47
|
+
- `lint`(含插件闭合门禁)、`typecheck`、`build`、`test:unit`、`test:smoke` 全绿。
|
|
48
|
+
- 浏览器走查:repo 主题直接进目录、group 主题选仓库、文件批注生成草稿、左下角插件页互切、
|
|
49
|
+
新建页默认直接进插件页、插件设置页生效。
|
|
50
|
+
- 旧库自动升级到 v21;打包内容自检(tarball 含 `packages/*/dist`,依赖无 `@nx-kv/*`)。
|
|
51
|
+
|
|
5
52
|
## [0.69.1] - 2026-11-25 frontmatter 残留清零 + v18 幽灵队列修复
|
|
6
53
|
|
|
7
54
|
### Changed
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
本机任务队列 + 文档库 + 仓库登记的一体化工具。一个 `npx` 命令起一个 Web 面板,同时提供同构 CLI——
|
|
4
4
|
**面板上的每个按钮,底层都是同一条 CLI 命令**,输出 `--json` 即可被任何 agent 直接消费。
|
|
5
5
|
|
|
6
|
-
所有数据都在本机 SQLite(`~/.nx-kv/nxkv.db`,schema
|
|
6
|
+
所有数据都在本机 SQLite(`~/.nx-kv/nxkv.db`,schema 版本以 `nx-kv db status` 为准),**不需要登录、不访问任何后端**。
|
|
7
7
|
附件同样只落本机附件仓;没有云端图床、没有同步开关。
|
|
8
8
|
|
|
9
9
|
任务正文可以直接**嵌图片与文档**(标准 markdown:`` / `[文件名](fileId)`):
|
|
@@ -53,10 +53,28 @@ pnpm run vite # 只起 Vite :5181(等价于 npx vite)
|
|
|
53
53
|
# 生产模式
|
|
54
54
|
pnpm start # 构建 + 起面板
|
|
55
55
|
|
|
56
|
-
# 校验:lint + 类型检查 + 构建 +
|
|
56
|
+
# 校验:lint + 类型检查 + 构建 + 端到端冒烟 + 单元/一致性测试
|
|
57
57
|
pnpm test
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
+
## 内置插件(pretask)
|
|
61
|
+
|
|
62
|
+
`nx-kv` 自带两个**内置插件**,随 npm 包一起分发,`npx nx-kv serve` 安装后即可用(无需另装插件):
|
|
63
|
+
|
|
64
|
+
| 插件 | 能力 | 入口 |
|
|
65
|
+
|---|---|---|
|
|
66
|
+
| 任务模板 `task-template` | 新建任务的正文模板 / 槽位填写 / 模板管理 | 新建页下拉 + 左下角「任务模板」 |
|
|
67
|
+
| 目录批注 `dir-annotate` | repo 主题直接进项目目录、group 主题先选仓库;给文件加批注并生成任务草稿 | 新建页下拉 + 左下角「目录批注设置」 |
|
|
68
|
+
|
|
69
|
+
插件**自注册**入口、页面、侧栏与自有存储;`nx-kv` 只负责生命周期(发现 / 启用停用 / 迁移版本 /
|
|
70
|
+
入口聚合 / 可见性与默认项)和调用(`buildDraft` / RPC / 页面挂载)。每个主题可在「配置新建页行为…」里
|
|
71
|
+
选择下拉显示哪些入口、以及点「+ 新建页」默认触发哪一项。插件清单与状态:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
nx-kv plugin list --json
|
|
75
|
+
nx-kv plugin entries --topic <topicKey> --json
|
|
76
|
+
```
|
|
77
|
+
|
|
60
78
|
## 常用命令
|
|
61
79
|
|
|
62
80
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nx-kv",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.70.0",
|
|
4
4
|
"description": "nx-kv — 本机任务队列(localtask)+ 文档库 + 仓库登记:serve 驱动 CLI 与 Web 面板,同源同构,附带可安装 skill 供 agent 提交 / 领取 / 阻塞接收任务",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -14,16 +14,20 @@
|
|
|
14
14
|
"gen:actions": "node --import tsx scripts/gen-actions.mjs",
|
|
15
15
|
"gen:api": "node --import tsx scripts/gen-api-client.mjs",
|
|
16
16
|
"gen:dart": "node --import tsx scripts/gen-dart-client.mjs",
|
|
17
|
-
"gen": "
|
|
18
|
-
"
|
|
19
|
-
"build": "
|
|
20
|
-
"
|
|
17
|
+
"gen:plugins": "node scripts/gen-plugins.mjs",
|
|
18
|
+
"gen": "pnpm run gen:actions && pnpm run gen:api && pnpm run gen:plugins",
|
|
19
|
+
"build:sdk": "tsc -p packages/plugin-sdk/tsconfig.json",
|
|
20
|
+
"build:plugins": "node scripts/build-plugins.mjs",
|
|
21
|
+
"build:packages": "pnpm run build:sdk && pnpm run build:plugins",
|
|
22
|
+
"typecheck": "pnpm run gen && pnpm run build:packages && tsc -b tsconfig.node.json tsconfig.web.json",
|
|
23
|
+
"build": "pnpm run gen && pnpm run build:packages && tsc -b tsconfig.node.json && vite build && node scripts/link-local.mjs --auto",
|
|
24
|
+
"dev": "pnpm run build:packages && node --import tsx scripts/dev.mjs",
|
|
21
25
|
"vite": "vite",
|
|
22
|
-
"dev:serve": "node --import tsx src/runtime/cli.ts serve --no-open",
|
|
26
|
+
"dev:serve": "pnpm run build:packages && node --import tsx src/runtime/cli.ts serve --no-open",
|
|
23
27
|
"start": "pnpm run build && node --import tsx src/runtime/cli.ts serve",
|
|
24
28
|
"link:local": "node scripts/link-local.mjs",
|
|
25
29
|
"unlink:local": "node scripts/link-local.mjs --unlink",
|
|
26
|
-
"lint": "eslint . && node scripts/check-tdz.mjs --all && node scripts/check-schema-decisions.mjs && node scripts/check-lines.mjs && node scripts/check-skill-sop.mjs && node scripts/check-test-isolation.mjs && node scripts/check-service-calls.mjs",
|
|
30
|
+
"lint": "eslint . && node scripts/check-tdz.mjs --all && node scripts/check-schema-decisions.mjs && node scripts/check-lines.mjs && node scripts/check-skill-sop.mjs && node scripts/check-test-isolation.mjs && node scripts/check-service-calls.mjs && node scripts/check-plugin-isolation.mjs",
|
|
27
31
|
"check:schema": "node scripts/check-schema-decisions.mjs",
|
|
28
32
|
"check:skill": "node scripts/check-skill-sop.mjs",
|
|
29
33
|
"test": "pnpm run lint && pnpm run typecheck && pnpm run build && pnpm run test:smoke && pnpm run test:unit",
|
|
@@ -39,6 +43,7 @@
|
|
|
39
43
|
"bin/",
|
|
40
44
|
"src/",
|
|
41
45
|
"assets/",
|
|
46
|
+
"packages/",
|
|
42
47
|
"README.md",
|
|
43
48
|
"CHANGELOG.md"
|
|
44
49
|
],
|
|
@@ -55,12 +60,12 @@
|
|
|
55
60
|
},
|
|
56
61
|
"license": "MIT",
|
|
57
62
|
"devDependencies": {
|
|
63
|
+
"@nx-kv/plugin-sdk": "workspace:*",
|
|
58
64
|
"@types/node": "^26.6.6",
|
|
59
65
|
"@types/react": "^19.2.7",
|
|
60
66
|
"@types/react-dom": "^19.2.3",
|
|
61
67
|
"@vitejs/plugin-react": "^6.1.1",
|
|
62
68
|
"eslint": "^10.10.0",
|
|
63
|
-
"tsx": "^4.23.15",
|
|
64
69
|
"typescript": "^5.9.3",
|
|
65
70
|
"typescript-eslint": "^8.72.2",
|
|
66
71
|
"vite": "^8.3.0"
|
|
@@ -68,8 +73,16 @@
|
|
|
68
73
|
"dependencies": {
|
|
69
74
|
"flexlayout-react": "0.11.1",
|
|
70
75
|
"handlebars": "^4.7.10",
|
|
76
|
+
"prosemirror-commands": "^1.7.2",
|
|
77
|
+
"prosemirror-history": "^1.5.2",
|
|
78
|
+
"prosemirror-inputrules": "^1.7.0",
|
|
79
|
+
"prosemirror-keymap": "^1.2.3",
|
|
80
|
+
"prosemirror-model": "^1.25.13",
|
|
81
|
+
"prosemirror-state": "^1.4.4",
|
|
82
|
+
"prosemirror-view": "^1.44.0",
|
|
71
83
|
"react": "^19.3.0",
|
|
72
84
|
"react-dom": "^19.3.0",
|
|
85
|
+
"tsx": "^4.23.15",
|
|
73
86
|
"zod": "^4.6.7"
|
|
74
87
|
}
|
|
75
88
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
(function(e,t){var n={showHidden:!1,includeDir:!0,titlePrefix:``};function r({api:r}){let[a,o]=(0,e.useState)(null),[s,c]=(0,e.useState)(null),[l,u]=(0,e.useState)(null),[d,f]=(0,e.useState)(null),[p,m]=(0,e.useState)(``),[h,g]=(0,e.useState)([]),[_,v]=(0,e.useState)(n),[y,b]=(0,e.useState)(!0),[x,S]=(0,e.useState)(``),C=async()=>{b(!0),S(``);let e=_.showHidden;try{let t=await r.rpc(`getSettings`).catch(()=>null);if(t){let r={...n,...t};v(r),e=r.showHidden}}catch{}try{let t=await r.host.get(`/api/plugins/context`,{topicKey:r.ctx.topicKey||r.ctx.topic?.key||``,groupKey:r.ctx.groupKey||r.ctx.topic?.groupKey||``,repoKey:r.ctx.repoKey||r.ctx.topic?.repoKey||``,cwd:r.ctx.cwd||r.ctx.topic?.cwd||``});o(t),c(null),u(null),f(null),t.topic.kind!==`group`&&t.repo&&await w(t.repo,e)}catch(e){S(String(e.message||e))}finally{b(!1)}},w=async(e,t=_.showHidden)=>{c(e),f(null);try{let n=await r.host.get(`/api/plugins/tree`,{repoKey:e.key,path:``,showHidden:t});u(n)}catch(e){r.toast(String(e.message||e))}},T=async e=>{if(s)try{let t=await r.host.get(`/api/plugins/tree`,{repoKey:s.key,path:e,showHidden:_.showHidden});u(t)}catch(e){r.toast(String(e.message||e))}},E=async e=>{if(s)try{let t=await r.host.get(`/api/plugins/file`,{repoKey:s.key,path:e.path});f(t)}catch(e){r.toast(String(e.message||e))}},D=()=>{if(!d){r.toast(`先从左侧选择一个文件`);return}let e=p.trim();if(!e){r.toast(`批注不能为空`);return}g(t=>[...t,{path:d.path,note:e}]),m(``)},O=()=>{if(!a||!s)return;if(!h.length){r.toast(`还没有批注`);return}let e=a.topic.kind===`group`,t=a.group?.name||a.topic.groupName||``,n=[`## 目录批注`,``,`- 仓库:${s.name}(${s.key})`,...e?[`- 组:${t||`-`}(${a.topic.groupKey})`]:[],...e?[]:[`- 主题:${a.topic.name||`-`}(${a.topic.kind})`],..._.includeDir&&l?.path?[`- 当前目录:${l.path}`]:[],``,`### 文件批注`,``,...h.map(e=>`- \`${e.path}\`\n - ${e.note.replace(/\n/g,`
|
|
2
|
+
`)}`)],i=e?`目录批注 · ${t||s.name} / ${s.name}`:`目录批注 · ${a.topic.name||s.name}`,o=`${_.titlePrefix||``}${i}`;r.createDraft({title:o,body:n.join(`
|
|
3
|
+
`)},e?{project:s.key}:void 0)};(0,e.useEffect)(()=>{C()},[]);let k=(l?.path||``).split(`/`).filter(Boolean);return(0,t.jsxs)(`div`,{className:`rp-page da-page`,children:[(0,t.jsxs)(`div`,{className:`page-head`,children:[(0,t.jsxs)(`div`,{className:`title-block`,children:[(0,t.jsx)(`h2`,{children:`目录批注`}),(0,t.jsxs)(`p`,{className:`muted da-sub`,children:[a?.topic?.name||`未定位主题`,a?.topic?.kind===`group`?` · 组`:a?.topic?.kind===`repo`?` · 仓库`:``,s?` · ${s.name}`:``]})]}),(0,t.jsxs)(`div`,{className:`acts`,children:[(0,t.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>void C(),children:`刷新`}),(0,t.jsxs)(`button`,{type:`button`,className:`btn primary sm`,disabled:!h.length,onClick:O,children:[`生成任务(`,h.length,`)`]})]})]}),y?(0,t.jsx)(`div`,{className:`muted`,style:{padding:12},children:`读取目录上下文…`}):null,x?(0,t.jsxs)(`div`,{className:`da-error`,children:[(0,t.jsxs)(`span`,{children:[`读取失败:`,x]}),(0,t.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>void C(),children:`重试`})]}):null,!y&&!x&&a&&a.topic.kind===`group`&&!s?(0,t.jsxs)(`div`,{className:`da-repos`,children:[(0,t.jsx)(`div`,{className:`da-repos-title`,children:`选择一个仓库`}),a.repos.map(e=>(0,t.jsxs)(`div`,{className:`da-repo-card`,children:[(0,t.jsxs)(`div`,{className:`da-repo-main`,children:[(0,t.jsx)(`div`,{className:`da-repo-name`,children:e.name}),(0,t.jsx)(`div`,{className:`da-repo-key`,children:e.key}),(0,t.jsx)(`div`,{className:`da-repo-desc`,children:e.description||`(无描述)`})]}),(0,t.jsx)(`button`,{type:`button`,className:`btn primary sm`,onClick:()=>void w(e),children:`选择`})]},e.key)),a.repos.length?null:(0,t.jsx)(`div`,{className:`muted`,children:`这个组还没有成员仓库。`})]}):null,!y&&!x&&s?(0,t.jsxs)(`div`,{className:`da-split`,children:[(0,t.jsxs)(`div`,{className:`da-tree`,children:[(0,t.jsxs)(`div`,{className:`da-tree-head`,children:[(0,t.jsx)(`b`,{className:`da-tree-repo`,children:s.name}),(0,t.jsxs)(`span`,{className:`da-tree-actions`,children:[a?.topic.kind===`group`?(0,t.jsx)(`button`,{type:`button`,className:`btn ghost xs`,onClick:()=>{c(null),u(null),f(null)},children:`切换仓库`}):null,(0,t.jsx)(`button`,{type:`button`,className:`btn ghost xs`,disabled:!l?.path,onClick:()=>void T(k.slice(0,-1).join(`/`)),children:`上一级`})]})]}),(0,t.jsxs)(`div`,{className:`da-crumb`,children:[(0,t.jsx)(`button`,{type:`button`,className:`da-crumb-item`,onClick:()=>void T(``),children:s.name}),k.map((e,n)=>(0,t.jsxs)(`span`,{children:[(0,t.jsx)(`span`,{className:`da-crumb-sep`,children:`/`}),(0,t.jsx)(`button`,{type:`button`,className:`da-crumb-item`,onClick:()=>void T(k.slice(0,n+1).join(`/`)),children:e})]},`${e}-${n}`))]}),(0,t.jsxs)(`div`,{className:`da-tree-list`,children:[l?.entries.map(e=>(0,t.jsxs)(`button`,{type:`button`,className:`da-tree-row`+(e.type===`file`&&d?.path===e.path?` active`:``),onClick:()=>e.type===`dir`?void T(e.path):void E(e),children:[(0,t.jsx)(`span`,{className:`da-kind ${e.type}`,children:e.type===`dir`?`目录`:`文件`}),(0,t.jsx)(`span`,{className:`da-entry-name`,children:e.name}),e.type===`file`&&e.size?(0,t.jsx)(`span`,{className:`da-entry-size`,children:i(e.size)}):null]},e.path)),l&&!l.entries.length?(0,t.jsx)(`div`,{className:`muted`,style:{padding:10},children:`空目录`}):null,l?.truncated?(0,t.jsx)(`div`,{className:`muted`,style:{padding:10},children:`目录项过多,已截断到前 500 项。`}):null]})]}),(0,t.jsxs)(`div`,{className:`da-right`,children:[(0,t.jsx)(`div`,{className:`da-file`,children:d?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(`div`,{className:`da-file-head`,children:[(0,t.jsx)(`code`,{children:d.path}),(0,t.jsxs)(`span`,{className:`muted`,children:[i(d.size),d.truncated?` · 已截断`:``]})]}),d.binary?(0,t.jsx)(`div`,{className:`muted`,style:{padding:12},children:`二进制文件,无法预览。`}):(0,t.jsx)(`pre`,{className:`da-pre`,children:d.content})]}):(0,t.jsx)(`div`,{className:`muted`,style:{padding:12},children:`从左侧目录选择文件,再写批注。`})}),(0,t.jsxs)(`div`,{className:`da-note-box`,children:[(0,t.jsx)(`textarea`,{className:`da-note`,rows:3,value:p,placeholder:d?`给 ${d.path} 写一条批注…`:`先选文件`,disabled:!d,onChange:e=>m(e.target.value)}),(0,t.jsx)(`button`,{type:`button`,className:`btn primary sm`,disabled:!d,onClick:D,children:`添加批注`})]}),(0,t.jsxs)(`div`,{className:`da-annotations`,children:[(0,t.jsxs)(`div`,{className:`da-ann-title`,children:[`已添加批注(`,h.length,`)`]}),h.map((e,n)=>(0,t.jsxs)(`div`,{className:`da-ann-row`,children:[(0,t.jsxs)(`div`,{className:`da-ann-main`,children:[(0,t.jsx)(`code`,{children:e.path}),(0,t.jsx)(`p`,{children:e.note})]}),(0,t.jsx)(`button`,{type:`button`,className:`iconbtn`,onClick:()=>g(e=>e.filter((e,t)=>t!==n)),children:`删除`})]},`${e.path}-${n}`)),h.length?null:(0,t.jsx)(`div`,{className:`muted`,children:`还没有批注。`})]})]})]}):null]})}function i(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}var a={showHidden:!1,includeDir:!0,titlePrefix:``};function o({api:n}){let[r,i]=(0,e.useState)(a),[o,s]=(0,e.useState)(!0),[c,l]=(0,e.useState)(!1),[u,d]=(0,e.useState)(``),f=async()=>{s(!0),d(``);try{let e=await n.rpc(`getSettings`);i({...a,...e||{}})}catch(e){d(String(e.message||e))}finally{s(!1)}},p=async()=>{l(!0);try{let e=await n.rpc(`setSettings`,r);i({...a,...e||{}}),n.toast(`已保存目录批注设置`)}catch(e){n.toast(String(e.message||e))}finally{l(!1)}};return(0,e.useEffect)(()=>{f()},[]),(0,t.jsxs)(`div`,{className:`rp-page da-page da-settings`,children:[(0,t.jsxs)(`div`,{className:`page-head`,children:[(0,t.jsxs)(`div`,{className:`title-block`,children:[(0,t.jsx)(`h2`,{children:`目录批注设置`}),(0,t.jsx)(`p`,{className:`muted da-sub`,children:`这些是插件自己的默认行为,保存在插件表里,按本机生效。`})]}),(0,t.jsxs)(`div`,{className:`acts`,children:[(0,t.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:c||o,onClick:()=>void f(),children:`刷新`}),(0,t.jsx)(`button`,{type:`button`,className:`btn primary sm`,disabled:c||o,onClick:()=>void p(),children:`保存`})]})]}),o?(0,t.jsx)(`div`,{className:`muted`,style:{padding:12},children:`读取设置…`}):null,u?(0,t.jsxs)(`div`,{className:`da-error`,children:[(0,t.jsxs)(`span`,{children:[`读取失败:`,u]}),(0,t.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>void f(),children:`重试`})]}):null,!o&&!u?(0,t.jsxs)(`div`,{className:`da-setting-list`,children:[(0,t.jsxs)(`label`,{className:`da-setting-row`,children:[(0,t.jsx)(`input`,{type:`checkbox`,checked:r.showHidden,onChange:e=>i(t=>({...t,showHidden:e.target.checked}))}),(0,t.jsxs)(`span`,{className:`da-setting-main`,children:[(0,t.jsx)(`b`,{children:`显示隐藏文件`}),(0,t.jsx)(`span`,{className:`muted`,children:`目录树里显示以 . 开头的文件和目录(如 .env、.github)。`})]})]}),(0,t.jsxs)(`label`,{className:`da-setting-row`,children:[(0,t.jsx)(`input`,{type:`checkbox`,checked:r.includeDir,onChange:e=>i(t=>({...t,includeDir:e.target.checked}))}),(0,t.jsxs)(`span`,{className:`da-setting-main`,children:[(0,t.jsx)(`b`,{children:`带入当前目录`}),(0,t.jsx)(`span`,{className:`muted`,children:`生成任务时在正文里写「当前目录」,方便接手的人先定位。`})]})]}),(0,t.jsxs)(`div`,{className:`da-setting-row da-setting-col`,children:[(0,t.jsx)(`b`,{children:`任务标题前缀`}),(0,t.jsx)(`input`,{type:`text`,className:`da-setting-input`,maxLength:40,placeholder:`可空,如【批注】`,value:r.titlePrefix,onChange:e=>i(t=>({...t,titlePrefix:e.target.value}))}),(0,t.jsx)(`span`,{className:`muted`,children:`生成的任务标题形如「前缀 + 目录批注 · 仓库名」。`})]})]}):null]})}var s={api:`^1`,components:{annotate:r,settings:o},pages:{annotate:{title:`目录批注`},settings:{title:`目录批注设置`}},sidebar:[{id:`settings`,label:`目录批注设置`,icon:`gear`,order:20,page:`settings`}]};window.NxkvPluginHost?window.NxkvPluginHost.registerPlugin(`dir-annotate`,s):console.warn(`[dir-annotate] NxkvPluginHost 未注入,插件 UI 未注册`)})(NxkvReact,NxkvJsxRuntime);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.da-page{flex-direction:column;gap:12px;min-height:0;display:flex}.da-sub{margin:2px 0 0;font-size:12px}.da-error{color:#9a3b32;background:#fcf3f2;border:1px solid #e7c4c0;border-radius:8px;align-items:center;gap:10px;padding:10px 12px;font-size:12px;display:flex}.da-repos{flex-direction:column;gap:8px;max-width:760px;display:flex}.da-repos-title{color:var(--ink-2,#4b515a);margin-bottom:2px;font-size:12px;font-weight:600}.da-repo-card{border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);border-radius:10px;justify-content:space-between;align-items:center;gap:12px;padding:10px 12px;display:flex}.da-repo-main{min-width:0}.da-repo-name{color:var(--ink,#222);font-size:13px;font-weight:600}.da-repo-key{color:var(--mid,#8a8578);margin-top:2px;font-size:10.5px}.da-repo-desc{color:var(--ink-2,#4b515a);margin-top:4px;font-size:11.5px;line-height:1.6}.da-split{flex:1;grid-template-columns:minmax(260px,340px) minmax(0,1fr);gap:12px;min-height:0;display:grid}.da-tree{border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);border-radius:10px;flex-direction:column;min-height:0;display:flex;overflow:hidden}.da-tree-head{border-bottom:1px solid var(--line,#e4e2dc);justify-content:space-between;align-items:center;gap:8px;padding:8px 10px;display:flex}.da-tree-repo{color:var(--ink,#222);text-overflow:ellipsis;white-space:nowrap;font-size:12.5px;overflow:hidden}.da-tree-actions{flex:none;gap:4px;display:flex}.da-crumb{border-bottom:1px dashed var(--line,#e4e2dc);flex-wrap:wrap;align-items:center;gap:1px;padding:6px 8px;font-size:11px;display:flex}.da-crumb-item{color:var(--mid,#8a8578);cursor:pointer;text-overflow:ellipsis;white-space:nowrap;background:0 0;border:0;border-radius:4px;max-width:160px;padding:1px 3px;overflow:hidden}.da-crumb-item:hover{color:var(--ink,#222);background:var(--soft,#f1f0ec)}.da-crumb-sep{color:var(--faint,#b6b1a6);padding:0 1px}.da-tree-list{flex:1;min-height:0;padding:4px;overflow:auto}.da-tree-row{text-align:left;cursor:pointer;width:100%;color:var(--ink,#222);font:inherit;background:0 0;border:0;border-radius:6px;align-items:center;gap:7px;padding:5px 7px;display:flex}.da-tree-row:hover{background:var(--soft,#f1f0ec)}.da-tree-row.active{background:var(--mdw-accent-soft,#e8f2ee);color:var(--mdw-accent,#2f6f5e)}.da-kind{color:var(--mid,#8a8578);background:var(--soft,#f1f0ec);border-radius:4px;flex:none;padding:0 5px;font-size:9.5px;line-height:1.5}.da-kind.dir{color:#6b5a2e;background:#f7f1df}.da-entry-name{text-overflow:ellipsis;white-space:nowrap;min-width:0;font-size:12px;overflow:hidden}.da-entry-size{color:var(--faint,#b6b1a6);flex:none;margin-left:auto;font-size:10px}.da-right{flex-direction:column;gap:10px;min-width:0;min-height:0;display:flex}.da-file{border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);border-radius:10px;min-height:120px;overflow:hidden}.da-file-head{border-bottom:1px solid var(--line,#e4e2dc);justify-content:space-between;align-items:center;gap:8px;padding:7px 10px;font-size:11px;display:flex}.da-file-head code{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.da-pre{max-height:340px;color:var(--ink-2,#4b515a);background:var(--paper,#fff);white-space:pre;margin:0;padding:10px 12px;font:400 12px/1.6 ui-monospace,Consolas,monospace;overflow:auto}.da-note-box{align-items:flex-start;gap:8px;display:flex}.da-note{resize:vertical;box-sizing:border-box;min-height:64px;color:var(--ink,#222);background:var(--paper,#fff);border:1px solid var(--line,#e4e2dc);border-radius:8px;flex:1;padding:8px 10px;font:400 12.5px/1.6 inherit}.da-note:focus{border-color:var(--mdw-accent-line,#b7d4c8);outline:none}.da-annotations{flex-direction:column;gap:6px;min-height:0;display:flex;overflow:auto}.da-ann-title{color:var(--ink-2,#4b515a);font-size:11.5px;font-weight:600}.da-ann-row{border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);border-radius:8px;justify-content:space-between;align-items:flex-start;gap:8px;padding:7px 9px;display:flex}.da-ann-main{min-width:0}.da-ann-main code{color:var(--mdw-accent,#2f6f5e);font-size:11px}.da-ann-main p{color:var(--ink-2,#4b515a);white-space:pre-wrap;margin:3px 0 0;font-size:12px;line-height:1.6}.da-settings{max-width:760px}.da-setting-list{flex-direction:column;gap:8px;display:flex}.da-setting-row{border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);border-radius:10px;align-items:flex-start;gap:10px;padding:10px 12px;display:flex}.da-setting-row input[type=checkbox]{margin-top:3px}.da-setting-main{flex-direction:column;gap:2px;min-width:0;display:flex}.da-setting-main b{color:var(--ink,#222);font-size:12.5px}.da-setting-main .muted{font-size:11.5px;line-height:1.6}.da-setting-col{flex-direction:column;gap:6px}.da-setting-col b{color:var(--ink,#222);font-size:12.5px}.da-setting-col .muted{font-size:11.5px}.da-setting-input{box-sizing:border-box;width:100%;color:var(--ink,#222);background:var(--paper,#fff);border:1px solid var(--line,#e4e2dc);border-radius:8px;padding:6px 9px;font:400 12.5px/1.6 inherit}.da-setting-input:focus{border-color:var(--mdw-accent-line,#b7d4c8);outline:none}@media (width<=900px){.da-split{grid-template-columns:1fr}.da-tree{max-height:320px}}
|
|
2
|
+
/*$vite$:1*/
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
//#region packages/plugin-sdk/dist/index.js
|
|
2
|
+
/** 插件 server 入口的默认导出必须包一层,宿主据此做运行时校验。 */
|
|
3
|
+
function definePlugin(plugin) {
|
|
4
|
+
if (!plugin || typeof plugin !== "object") throw new Error("definePlugin: 需要插件对象");
|
|
5
|
+
if (!plugin.id || /[:.]/.test(plugin.id)) throw new Error(`definePlugin: 非法插件 id「${String(plugin.id)}」(只允许字母/数字/短横线)`);
|
|
6
|
+
if (!plugin.api || !/^\^1(\.|$)/.test(plugin.api)) throw new Error(`definePlugin: 不支持的 api「${String(plugin.api)}」(当前 '^1')`);
|
|
7
|
+
if (!plugin.version) throw new Error("definePlugin: 需要 version");
|
|
8
|
+
if (!plugin.name) throw new Error("definePlugin: 需要 name");
|
|
9
|
+
if (typeof plugin.entries !== "function") throw new Error("definePlugin: 需要 entries()");
|
|
10
|
+
if (typeof plugin.buildDraft !== "function") throw new Error("definePlugin: 需要 buildDraft()");
|
|
11
|
+
return plugin;
|
|
12
|
+
}
|
|
13
|
+
/** 供插件做 rpc 参数兜底:把未知值收成普通对象。 */
|
|
14
|
+
function paramsOf(raw) {
|
|
15
|
+
return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
16
|
+
}
|
|
17
|
+
var DEFAULTS = {
|
|
18
|
+
showHidden: false,
|
|
19
|
+
includeDir: true,
|
|
20
|
+
titlePrefix: ""
|
|
21
|
+
};
|
|
22
|
+
function migrateStorage(db, fromVersion) {
|
|
23
|
+
if (fromVersion < 1) db.exec(`CREATE TABLE IF NOT EXISTS dir_annotate_settings (
|
|
24
|
+
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
25
|
+
show_hidden INTEGER NOT NULL DEFAULT 0 CHECK (show_hidden IN (0, 1)),
|
|
26
|
+
include_dir INTEGER NOT NULL DEFAULT 1 CHECK (include_dir IN (0, 1)),
|
|
27
|
+
title_prefix TEXT NOT NULL DEFAULT '',
|
|
28
|
+
updated_at INTEGER NOT NULL
|
|
29
|
+
)`);
|
|
30
|
+
return 1;
|
|
31
|
+
}
|
|
32
|
+
function truthy(value, fallback) {
|
|
33
|
+
if (value === void 0 || value === null || value === "") return fallback;
|
|
34
|
+
if (typeof value === "boolean") return value;
|
|
35
|
+
const s = String(value).toLowerCase();
|
|
36
|
+
return !(s === "false" || s === "0" || s === "no" || s === "off");
|
|
37
|
+
}
|
|
38
|
+
function readSettings(db) {
|
|
39
|
+
const row = db.get("SELECT show_hidden, include_dir, title_prefix FROM dir_annotate_settings WHERE id = 1");
|
|
40
|
+
if (!row) return { ...DEFAULTS };
|
|
41
|
+
return {
|
|
42
|
+
showHidden: !!Number(row.show_hidden),
|
|
43
|
+
includeDir: !!Number(row.include_dir),
|
|
44
|
+
titlePrefix: String(row.title_prefix || "")
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** 合并写入;只认三个字段,titlePrefix 截到 40 字。 */
|
|
48
|
+
function writeSettings(db, patch) {
|
|
49
|
+
const cur = readSettings(db);
|
|
50
|
+
const next = {
|
|
51
|
+
showHidden: truthy(patch.showHidden, cur.showHidden),
|
|
52
|
+
includeDir: truthy(patch.includeDir, cur.includeDir),
|
|
53
|
+
titlePrefix: patch.titlePrefix === void 0 ? cur.titlePrefix : String(patch.titlePrefix || "").trim().slice(0, 40)
|
|
54
|
+
};
|
|
55
|
+
db.run(`INSERT INTO dir_annotate_settings (id, show_hidden, include_dir, title_prefix, updated_at)
|
|
56
|
+
VALUES (1, :hide, :dir, :prefix, :at)
|
|
57
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
58
|
+
show_hidden = excluded.show_hidden,
|
|
59
|
+
include_dir = excluded.include_dir,
|
|
60
|
+
title_prefix = excluded.title_prefix,
|
|
61
|
+
updated_at = excluded.updated_at`, {
|
|
62
|
+
hide: next.showHidden ? 1 : 0,
|
|
63
|
+
dir: next.includeDir ? 1 : 0,
|
|
64
|
+
prefix: next.titlePrefix,
|
|
65
|
+
at: Date.now()
|
|
66
|
+
});
|
|
67
|
+
return next;
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region packages/plugin-dir-annotate/src/server/index.ts
|
|
71
|
+
var server_default = definePlugin({
|
|
72
|
+
id: "dir-annotate",
|
|
73
|
+
version: "0.1.0",
|
|
74
|
+
api: "^1",
|
|
75
|
+
name: "目录批注",
|
|
76
|
+
description: "选择项目目录中的文件、添加批注,最后生成一条任务草稿。",
|
|
77
|
+
order: 20,
|
|
78
|
+
defaultEnabled: true,
|
|
79
|
+
storageVersion: 1,
|
|
80
|
+
migrateStorage,
|
|
81
|
+
entries(ctx) {
|
|
82
|
+
const kind = ctx.topic?.kind || (ctx.groupKey ? "group" : ctx.repoKey ? "repo" : "unknown");
|
|
83
|
+
if (kind === "unknown") return [];
|
|
84
|
+
return [{
|
|
85
|
+
id: "dir-annotate:open",
|
|
86
|
+
pluginId: "dir-annotate",
|
|
87
|
+
label: "目录批注…",
|
|
88
|
+
description: kind === "group" ? "先选仓库,再选文件添加批注" : "选择项目文件并添加批注",
|
|
89
|
+
icon: "folder",
|
|
90
|
+
kind: "panel",
|
|
91
|
+
order: 20,
|
|
92
|
+
ui: { panel: "annotate" },
|
|
93
|
+
panel: { title: "目录批注" }
|
|
94
|
+
}];
|
|
95
|
+
},
|
|
96
|
+
async buildDraft() {
|
|
97
|
+
throw new Error("目录批注入口通过面板生成任务,不走 pretask.draft");
|
|
98
|
+
},
|
|
99
|
+
rpc: {
|
|
100
|
+
async getSettings(ctx) {
|
|
101
|
+
return readSettings(ctx.storage);
|
|
102
|
+
},
|
|
103
|
+
async setSettings(ctx, raw) {
|
|
104
|
+
return writeSettings(ctx.storage, paramsOf(raw));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
//#endregion
|
|
109
|
+
export { server_default as default };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nx-kv/plugin-dir-annotate",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/server/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
"./server": {
|
|
9
|
+
"types": "./dist/server/index.d.ts",
|
|
10
|
+
"import": "./dist/server/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"nxkv": {
|
|
15
|
+
"api": "^1",
|
|
16
|
+
"server": "dist/server/index.js",
|
|
17
|
+
"client": "dist/client/client.js",
|
|
18
|
+
"style": "dist/client/style.css"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@nx-kv/plugin-sdk": "workspace:*"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"react": "^19.3.0",
|
|
25
|
+
"react-dom": "^19.3.0"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"package.json"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
// 目录批注页:repo topic 直接进目录;group topic 先选仓库;选文件加批注,最后生成任务草稿。
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import type {
|
|
4
|
+
PluginClientApi,
|
|
5
|
+
PluginContextView,
|
|
6
|
+
PluginFileView,
|
|
7
|
+
PluginRepoView,
|
|
8
|
+
PluginTreeEntry,
|
|
9
|
+
PluginTreeView,
|
|
10
|
+
} from '@nx-kv/plugin-sdk/client';
|
|
11
|
+
|
|
12
|
+
interface Annotation {
|
|
13
|
+
path: string;
|
|
14
|
+
note: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface Settings {
|
|
18
|
+
showHidden: boolean;
|
|
19
|
+
includeDir: boolean;
|
|
20
|
+
titlePrefix: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const DEFAULT_SETTINGS: Settings = { showHidden: false, includeDir: true, titlePrefix: '' };
|
|
24
|
+
|
|
25
|
+
export default function AnnotatePage({ api }: { api: PluginClientApi }) {
|
|
26
|
+
const [context, setContext] = useState<PluginContextView | null>(null);
|
|
27
|
+
const [repo, setRepo] = useState<PluginRepoView | null>(null);
|
|
28
|
+
const [tree, setTree] = useState<PluginTreeView | null>(null);
|
|
29
|
+
const [file, setFile] = useState<PluginFileView | null>(null);
|
|
30
|
+
const [note, setNote] = useState('');
|
|
31
|
+
const [annotations, setAnnotations] = useState<Annotation[]>([]);
|
|
32
|
+
const [settings, setSettings] = useState<Settings>(DEFAULT_SETTINGS);
|
|
33
|
+
const [loading, setLoading] = useState(true);
|
|
34
|
+
const [error, setError] = useState('');
|
|
35
|
+
|
|
36
|
+
const loadContext = async () => {
|
|
37
|
+
setLoading(true);
|
|
38
|
+
setError('');
|
|
39
|
+
let showHidden = settings.showHidden;
|
|
40
|
+
try {
|
|
41
|
+
// 设置由左下角设置页维护;拿不到(老宿主)就用默认值继续。
|
|
42
|
+
const saved = await api.rpc<Partial<Settings>>('getSettings').catch(() => null);
|
|
43
|
+
if (saved) {
|
|
44
|
+
const merged = { ...DEFAULT_SETTINGS, ...saved };
|
|
45
|
+
setSettings(merged);
|
|
46
|
+
showHidden = merged.showHidden;
|
|
47
|
+
}
|
|
48
|
+
} catch {
|
|
49
|
+
/* ignore */
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const c = await api.host.get<PluginContextView>('/api/plugins/context', {
|
|
53
|
+
topicKey: api.ctx.topicKey || api.ctx.topic?.key || '',
|
|
54
|
+
groupKey: api.ctx.groupKey || api.ctx.topic?.groupKey || '',
|
|
55
|
+
repoKey: api.ctx.repoKey || api.ctx.topic?.repoKey || '',
|
|
56
|
+
cwd: api.ctx.cwd || api.ctx.topic?.cwd || '',
|
|
57
|
+
});
|
|
58
|
+
setContext(c);
|
|
59
|
+
setRepo(null);
|
|
60
|
+
setTree(null);
|
|
61
|
+
setFile(null);
|
|
62
|
+
if (c.topic.kind !== 'group' && c.repo) await pickRepo(c.repo, showHidden);
|
|
63
|
+
} catch (e) {
|
|
64
|
+
setError(String((e as Error).message || e));
|
|
65
|
+
} finally {
|
|
66
|
+
setLoading(false);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const pickRepo = async (next: PluginRepoView, showHidden = settings.showHidden) => {
|
|
71
|
+
setRepo(next);
|
|
72
|
+
setFile(null);
|
|
73
|
+
try {
|
|
74
|
+
const t = await api.host.get<PluginTreeView>('/api/plugins/tree', {
|
|
75
|
+
repoKey: next.key,
|
|
76
|
+
path: '',
|
|
77
|
+
showHidden,
|
|
78
|
+
});
|
|
79
|
+
setTree(t);
|
|
80
|
+
} catch (e) {
|
|
81
|
+
api.toast(String((e as Error).message || e));
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const loadTree = async (path: string) => {
|
|
86
|
+
if (!repo) return;
|
|
87
|
+
try {
|
|
88
|
+
const t = await api.host.get<PluginTreeView>('/api/plugins/tree', {
|
|
89
|
+
repoKey: repo.key,
|
|
90
|
+
path,
|
|
91
|
+
showHidden: settings.showHidden,
|
|
92
|
+
});
|
|
93
|
+
setTree(t);
|
|
94
|
+
} catch (e) {
|
|
95
|
+
api.toast(String((e as Error).message || e));
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const openFile = async (entry: PluginTreeEntry) => {
|
|
100
|
+
if (!repo) return;
|
|
101
|
+
try {
|
|
102
|
+
const f = await api.host.get<PluginFileView>('/api/plugins/file', { repoKey: repo.key, path: entry.path });
|
|
103
|
+
setFile(f);
|
|
104
|
+
} catch (e) {
|
|
105
|
+
api.toast(String((e as Error).message || e));
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const addNote = () => {
|
|
110
|
+
if (!file) {
|
|
111
|
+
api.toast('先从左侧选择一个文件');
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const text = note.trim();
|
|
115
|
+
if (!text) {
|
|
116
|
+
api.toast('批注不能为空');
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
setAnnotations((cur) => [...cur, { path: file.path, note: text }]);
|
|
120
|
+
setNote('');
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const generate = () => {
|
|
124
|
+
if (!context || !repo) return;
|
|
125
|
+
if (!annotations.length) {
|
|
126
|
+
api.toast('还没有批注');
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const isGroup = context.topic.kind === 'group';
|
|
130
|
+
const groupName = context.group?.name || context.topic.groupName || '';
|
|
131
|
+
const lines = [
|
|
132
|
+
'## 目录批注',
|
|
133
|
+
'',
|
|
134
|
+
`- 仓库:${repo.name}(${repo.key})`,
|
|
135
|
+
...(isGroup ? [`- 组:${groupName || '-'}(${context.topic.groupKey})`] : []),
|
|
136
|
+
...(isGroup ? [] : [`- 主题:${context.topic.name || '-'}(${context.topic.kind})`]),
|
|
137
|
+
...(settings.includeDir && tree?.path ? [`- 当前目录:${tree.path}`] : []),
|
|
138
|
+
'',
|
|
139
|
+
'### 文件批注',
|
|
140
|
+
'',
|
|
141
|
+
...annotations.map((a) => `- \`${a.path}\`\n - ${a.note.replace(/\n/g, '\n ')}`),
|
|
142
|
+
];
|
|
143
|
+
const base = isGroup
|
|
144
|
+
? `目录批注 · ${groupName || repo.name} / ${repo.name}`
|
|
145
|
+
: `目录批注 · ${context.topic.name || repo.name}`;
|
|
146
|
+
const title = `${settings.titlePrefix || ''}${base}`;
|
|
147
|
+
// 组主题下插件自选了仓库:草稿归属跟着所选仓库走(宿主缺省用组页当前成员)
|
|
148
|
+
api.createDraft({ title, body: lines.join('\n') }, isGroup ? { project: repo.key } : undefined);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
void loadContext();
|
|
153
|
+
}, []);
|
|
154
|
+
|
|
155
|
+
const segments = (tree?.path || '').split('/').filter(Boolean);
|
|
156
|
+
|
|
157
|
+
return (
|
|
158
|
+
<div className="rp-page da-page">
|
|
159
|
+
<div className="page-head">
|
|
160
|
+
<div className="title-block">
|
|
161
|
+
<h2>目录批注</h2>
|
|
162
|
+
<p className="muted da-sub">
|
|
163
|
+
{context?.topic?.name || '未定位主题'}
|
|
164
|
+
{context?.topic?.kind === 'group' ? ' · 组' : context?.topic?.kind === 'repo' ? ' · 仓库' : ''}
|
|
165
|
+
{repo ? ` · ${repo.name}` : ''}
|
|
166
|
+
</p>
|
|
167
|
+
</div>
|
|
168
|
+
<div className="acts">
|
|
169
|
+
<button type="button" className="btn ghost sm" onClick={() => void loadContext()}>
|
|
170
|
+
刷新
|
|
171
|
+
</button>
|
|
172
|
+
<button type="button" className="btn primary sm" disabled={!annotations.length} onClick={generate}>
|
|
173
|
+
生成任务({annotations.length})
|
|
174
|
+
</button>
|
|
175
|
+
</div>
|
|
176
|
+
</div>
|
|
177
|
+
|
|
178
|
+
{loading ? <div className="muted" style={{ padding: 12 }}>读取目录上下文…</div> : null}
|
|
179
|
+
{error ? (
|
|
180
|
+
<div className="da-error">
|
|
181
|
+
<span>读取失败:{error}</span>
|
|
182
|
+
<button type="button" className="btn ghost sm" onClick={() => void loadContext()}>重试</button>
|
|
183
|
+
</div>
|
|
184
|
+
) : null}
|
|
185
|
+
|
|
186
|
+
{!loading && !error && context && context.topic.kind === 'group' && !repo ? (
|
|
187
|
+
<div className="da-repos">
|
|
188
|
+
<div className="da-repos-title">选择一个仓库</div>
|
|
189
|
+
{context.repos.map((r) => (
|
|
190
|
+
<div className="da-repo-card" key={r.key}>
|
|
191
|
+
<div className="da-repo-main">
|
|
192
|
+
<div className="da-repo-name">{r.name}</div>
|
|
193
|
+
<div className="da-repo-key">{r.key}</div>
|
|
194
|
+
<div className="da-repo-desc">{r.description || '(无描述)'}</div>
|
|
195
|
+
</div>
|
|
196
|
+
<button type="button" className="btn primary sm" onClick={() => void pickRepo(r)}>
|
|
197
|
+
选择
|
|
198
|
+
</button>
|
|
199
|
+
</div>
|
|
200
|
+
))}
|
|
201
|
+
{!context.repos.length ? <div className="muted">这个组还没有成员仓库。</div> : null}
|
|
202
|
+
</div>
|
|
203
|
+
) : null}
|
|
204
|
+
|
|
205
|
+
{!loading && !error && repo ? (
|
|
206
|
+
<div className="da-split">
|
|
207
|
+
<div className="da-tree">
|
|
208
|
+
<div className="da-tree-head">
|
|
209
|
+
<b className="da-tree-repo">{repo.name}</b>
|
|
210
|
+
<span className="da-tree-actions">
|
|
211
|
+
{context?.topic.kind === 'group' ? (
|
|
212
|
+
<button type="button" className="btn ghost xs" onClick={() => { setRepo(null); setTree(null); setFile(null); }}>
|
|
213
|
+
切换仓库
|
|
214
|
+
</button>
|
|
215
|
+
) : null}
|
|
216
|
+
<button type="button" className="btn ghost xs" disabled={!tree?.path} onClick={() => void loadTree(segments.slice(0, -1).join('/'))}>
|
|
217
|
+
上一级
|
|
218
|
+
</button>
|
|
219
|
+
</span>
|
|
220
|
+
</div>
|
|
221
|
+
<div className="da-crumb">
|
|
222
|
+
<button type="button" className="da-crumb-item" onClick={() => void loadTree('')}>{repo.name}</button>
|
|
223
|
+
{segments.map((seg, i) => (
|
|
224
|
+
<span key={`${seg}-${i}`}>
|
|
225
|
+
<span className="da-crumb-sep">/</span>
|
|
226
|
+
<button type="button" className="da-crumb-item" onClick={() => void loadTree(segments.slice(0, i + 1).join('/'))}>
|
|
227
|
+
{seg}
|
|
228
|
+
</button>
|
|
229
|
+
</span>
|
|
230
|
+
))}
|
|
231
|
+
</div>
|
|
232
|
+
<div className="da-tree-list">
|
|
233
|
+
{tree?.entries.map((entry) => (
|
|
234
|
+
<button
|
|
235
|
+
type="button"
|
|
236
|
+
key={entry.path}
|
|
237
|
+
className={'da-tree-row' + (entry.type === 'file' && file?.path === entry.path ? ' active' : '')}
|
|
238
|
+
onClick={() => (entry.type === 'dir' ? void loadTree(entry.path) : void openFile(entry))}
|
|
239
|
+
>
|
|
240
|
+
<span className={`da-kind ${entry.type}`}>{entry.type === 'dir' ? '目录' : '文件'}</span>
|
|
241
|
+
<span className="da-entry-name">{entry.name}</span>
|
|
242
|
+
{entry.type === 'file' && entry.size ? <span className="da-entry-size">{formatSize(entry.size)}</span> : null}
|
|
243
|
+
</button>
|
|
244
|
+
))}
|
|
245
|
+
{tree && !tree.entries.length ? <div className="muted" style={{ padding: 10 }}>空目录</div> : null}
|
|
246
|
+
{tree?.truncated ? <div className="muted" style={{ padding: 10 }}>目录项过多,已截断到前 500 项。</div> : null}
|
|
247
|
+
</div>
|
|
248
|
+
</div>
|
|
249
|
+
|
|
250
|
+
<div className="da-right">
|
|
251
|
+
<div className="da-file">
|
|
252
|
+
{file ? (
|
|
253
|
+
<>
|
|
254
|
+
<div className="da-file-head">
|
|
255
|
+
<code>{file.path}</code>
|
|
256
|
+
<span className="muted">{formatSize(file.size)}{file.truncated ? ' · 已截断' : ''}</span>
|
|
257
|
+
</div>
|
|
258
|
+
{file.binary ? (
|
|
259
|
+
<div className="muted" style={{ padding: 12 }}>二进制文件,无法预览。</div>
|
|
260
|
+
) : (
|
|
261
|
+
<pre className="da-pre">{file.content}</pre>
|
|
262
|
+
)}
|
|
263
|
+
</>
|
|
264
|
+
) : (
|
|
265
|
+
<div className="muted" style={{ padding: 12 }}>从左侧目录选择文件,再写批注。</div>
|
|
266
|
+
)}
|
|
267
|
+
</div>
|
|
268
|
+
|
|
269
|
+
<div className="da-note-box">
|
|
270
|
+
<textarea
|
|
271
|
+
className="da-note"
|
|
272
|
+
rows={3}
|
|
273
|
+
value={note}
|
|
274
|
+
placeholder={file ? `给 ${file.path} 写一条批注…` : '先选文件'}
|
|
275
|
+
disabled={!file}
|
|
276
|
+
onChange={(e) => setNote(e.target.value)}
|
|
277
|
+
/>
|
|
278
|
+
<button type="button" className="btn primary sm" disabled={!file} onClick={addNote}>
|
|
279
|
+
添加批注
|
|
280
|
+
</button>
|
|
281
|
+
</div>
|
|
282
|
+
|
|
283
|
+
<div className="da-annotations">
|
|
284
|
+
<div className="da-ann-title">已添加批注({annotations.length})</div>
|
|
285
|
+
{annotations.map((a, i) => (
|
|
286
|
+
<div className="da-ann-row" key={`${a.path}-${i}`}>
|
|
287
|
+
<div className="da-ann-main">
|
|
288
|
+
<code>{a.path}</code>
|
|
289
|
+
<p>{a.note}</p>
|
|
290
|
+
</div>
|
|
291
|
+
<button
|
|
292
|
+
type="button"
|
|
293
|
+
className="iconbtn"
|
|
294
|
+
onClick={() => setAnnotations((cur) => cur.filter((_, idx) => idx !== i))}
|
|
295
|
+
>
|
|
296
|
+
删除
|
|
297
|
+
</button>
|
|
298
|
+
</div>
|
|
299
|
+
))}
|
|
300
|
+
{!annotations.length ? <div className="muted">还没有批注。</div> : null}
|
|
301
|
+
</div>
|
|
302
|
+
</div>
|
|
303
|
+
</div>
|
|
304
|
+
) : null}
|
|
305
|
+
</div>
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function formatSize(size: number): string {
|
|
310
|
+
if (size < 1024) return `${size} B`;
|
|
311
|
+
if (size < 1024 * 1024) return `${(size / 1024).toFixed(1)} KB`;
|
|
312
|
+
return `${(size / 1024 / 1024).toFixed(1)} MB`;
|
|
313
|
+
}
|