nx-kv 0.69.0 → 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 +69 -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 +10 -0
- package/src/core/db/migrations/v16-data.ts +0 -1
- package/src/core/db/migrations/v18.sql +24 -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 +9 -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-add.ts +4 -4
- package/src/modules/localtask/actions/localtask-boardtasks.ts +4 -17
- 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 +16 -5
- 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 +164 -50
- package/src/web/frontend/api/client.generated.ts +160 -61
- 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/attachments/attach-modal.tsx +1 -1
- package/src/web/frontend/components/md/composer/composer-panel.tsx +14 -144
- package/src/web/frontend/components/md/hooks/use-live-preview.ts +1 -1
- package/src/web/frontend/components/md/model/divider/index.ts +0 -3
- package/src/web/frontend/components/md/panes/md-panes-helpers.ts +1 -3
- 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/editor.css +0 -26
- 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-BL344XZg.js +0 -1
- package/src/web/public/assets/composer-panel-D0ojgf7z.js +0 -1
- package/src/web/public/assets/dag-BY0lf-Nl.js +0 -1
- package/src/web/public/assets/dir-BNHyviHQ.js +0 -1
- package/src/web/public/assets/doc-Ka-2V5jn.css +0 -1
- package/src/web/public/assets/doc-wmc4swmo.js +0 -6
- package/src/web/public/assets/group-BSQ9_Gjs.js +0 -1
- package/src/web/public/assets/index-D2P-v30u.js +0 -3
- package/src/web/public/assets/index-DHLeXl42.css +0 -1
- package/src/web/public/assets/manage-session-CuaL7QqQ.js +0 -1
- package/src/web/public/assets/md-history-D0bYVPZY.js +0 -47
- 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-Cf4ZbAra.js +0 -2
- package/src/web/public/assets/repo-form-modal-BahZhXq3.js +0 -1
- package/src/web/public/assets/repos-C2cZtRFo.js +0 -12
- package/src/web/public/assets/route-crumb-DS76cmRK.js +0 -1
- package/src/web/public/assets/settings-C_VmzG7F.js +0 -1
- package/src/web/public/assets/task-C4Sqe4vT.js +0 -14
- package/src/web/public/assets/task-Dcd2eA8B.css +0 -1
- package/src/web/public/assets/task-ops-SFagO-OC.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-B8jnGSAl.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-CtZxisjE.js +0 -1
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// 目录批注设置页(左下角侧栏条目):控制插件在新建页里的默认行为。
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import type { PluginClientApi } from '@nx-kv/plugin-sdk/client';
|
|
4
|
+
|
|
5
|
+
interface Settings {
|
|
6
|
+
showHidden: boolean;
|
|
7
|
+
includeDir: boolean;
|
|
8
|
+
titlePrefix: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const DEFAULTS: Settings = { showHidden: false, includeDir: true, titlePrefix: '' };
|
|
12
|
+
|
|
13
|
+
export default function SettingsPage({ api }: { api: PluginClientApi }) {
|
|
14
|
+
const [settings, setSettings] = useState<Settings>(DEFAULTS);
|
|
15
|
+
const [loading, setLoading] = useState(true);
|
|
16
|
+
const [busy, setBusy] = useState(false);
|
|
17
|
+
const [error, setError] = useState('');
|
|
18
|
+
|
|
19
|
+
const load = async () => {
|
|
20
|
+
setLoading(true);
|
|
21
|
+
setError('');
|
|
22
|
+
try {
|
|
23
|
+
const loaded = await api.rpc<Partial<Settings>>('getSettings');
|
|
24
|
+
setSettings({ ...DEFAULTS, ...(loaded || {}) });
|
|
25
|
+
} catch (e) {
|
|
26
|
+
setError(String((e as Error).message || e));
|
|
27
|
+
} finally {
|
|
28
|
+
setLoading(false);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const save = async () => {
|
|
33
|
+
setBusy(true);
|
|
34
|
+
try {
|
|
35
|
+
const saved = await api.rpc<Partial<Settings>>('setSettings', settings);
|
|
36
|
+
setSettings({ ...DEFAULTS, ...(saved || {}) });
|
|
37
|
+
api.toast('已保存目录批注设置');
|
|
38
|
+
} catch (e) {
|
|
39
|
+
api.toast(String((e as Error).message || e));
|
|
40
|
+
} finally {
|
|
41
|
+
setBusy(false);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
void load();
|
|
47
|
+
}, []);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<div className="rp-page da-page da-settings">
|
|
51
|
+
<div className="page-head">
|
|
52
|
+
<div className="title-block">
|
|
53
|
+
<h2>目录批注设置</h2>
|
|
54
|
+
<p className="muted da-sub">这些是插件自己的默认行为,保存在插件表里,按本机生效。</p>
|
|
55
|
+
</div>
|
|
56
|
+
<div className="acts">
|
|
57
|
+
<button type="button" className="btn ghost sm" disabled={busy || loading} onClick={() => void load()}>
|
|
58
|
+
刷新
|
|
59
|
+
</button>
|
|
60
|
+
<button type="button" className="btn primary sm" disabled={busy || loading} onClick={() => void save()}>
|
|
61
|
+
保存
|
|
62
|
+
</button>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
{loading ? <div className="muted" style={{ padding: 12 }}>读取设置…</div> : null}
|
|
67
|
+
{error ? (
|
|
68
|
+
<div className="da-error">
|
|
69
|
+
<span>读取失败:{error}</span>
|
|
70
|
+
<button type="button" className="btn ghost sm" onClick={() => void load()}>重试</button>
|
|
71
|
+
</div>
|
|
72
|
+
) : null}
|
|
73
|
+
|
|
74
|
+
{!loading && !error ? (
|
|
75
|
+
<div className="da-setting-list">
|
|
76
|
+
<label className="da-setting-row">
|
|
77
|
+
<input
|
|
78
|
+
type="checkbox"
|
|
79
|
+
checked={settings.showHidden}
|
|
80
|
+
onChange={(e) => setSettings((cur) => ({ ...cur, showHidden: e.target.checked }))}
|
|
81
|
+
/>
|
|
82
|
+
<span className="da-setting-main">
|
|
83
|
+
<b>显示隐藏文件</b>
|
|
84
|
+
<span className="muted">目录树里显示以 . 开头的文件和目录(如 .env、.github)。</span>
|
|
85
|
+
</span>
|
|
86
|
+
</label>
|
|
87
|
+
|
|
88
|
+
<label className="da-setting-row">
|
|
89
|
+
<input
|
|
90
|
+
type="checkbox"
|
|
91
|
+
checked={settings.includeDir}
|
|
92
|
+
onChange={(e) => setSettings((cur) => ({ ...cur, includeDir: e.target.checked }))}
|
|
93
|
+
/>
|
|
94
|
+
<span className="da-setting-main">
|
|
95
|
+
<b>带入当前目录</b>
|
|
96
|
+
<span className="muted">生成任务时在正文里写「当前目录」,方便接手的人先定位。</span>
|
|
97
|
+
</span>
|
|
98
|
+
</label>
|
|
99
|
+
|
|
100
|
+
<div className="da-setting-row da-setting-col">
|
|
101
|
+
<b>任务标题前缀</b>
|
|
102
|
+
<input
|
|
103
|
+
type="text"
|
|
104
|
+
className="da-setting-input"
|
|
105
|
+
maxLength={40}
|
|
106
|
+
placeholder="可空,如【批注】"
|
|
107
|
+
value={settings.titlePrefix}
|
|
108
|
+
onChange={(e) => setSettings((cur) => ({ ...cur, titlePrefix: e.target.value }))}
|
|
109
|
+
/>
|
|
110
|
+
<span className="muted">生成的任务标题形如「前缀 + 目录批注 · 仓库名」。</span>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
) : null}
|
|
114
|
+
</div>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// 目录批注插件 client:新建任务下拉的 annotate 页面 + 左下角自注册设置页。
|
|
2
|
+
import type { PluginUiDefinition } from '@nx-kv/plugin-sdk/client';
|
|
3
|
+
import AnnotatePage from './AnnotatePage.js';
|
|
4
|
+
import SettingsPage from './SettingsPage.js';
|
|
5
|
+
import './style.css';
|
|
6
|
+
|
|
7
|
+
const definition: PluginUiDefinition = {
|
|
8
|
+
api: '^1',
|
|
9
|
+
components: { annotate: AnnotatePage, settings: SettingsPage },
|
|
10
|
+
pages: {
|
|
11
|
+
annotate: { title: '目录批注' },
|
|
12
|
+
settings: { title: '目录批注设置' },
|
|
13
|
+
},
|
|
14
|
+
sidebar: [
|
|
15
|
+
{ id: 'settings', label: '目录批注设置', icon: 'gear', order: 20, page: 'settings' },
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
if (window.NxkvPluginHost) {
|
|
20
|
+
window.NxkvPluginHost.registerPlugin('dir-annotate', definition);
|
|
21
|
+
} else {
|
|
22
|
+
console.warn('[dir-annotate] NxkvPluginHost 未注入,插件 UI 未注册');
|
|
23
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/* 目录批注插件 UI:左树右文件/批注;沿用宿主 .rp-page/.page-head/.btn 口径。 */
|
|
2
|
+
.da-page{display:flex;flex-direction:column;gap:12px;min-height:0}
|
|
3
|
+
.da-sub{margin:2px 0 0;font-size:12px}
|
|
4
|
+
.da-error{display:flex;align-items:center;gap:10px;padding:10px 12px;border:1px solid #E7C4C0;border-radius:8px;background:#FCF3F2;color:#9A3B32;font-size:12px}
|
|
5
|
+
|
|
6
|
+
.da-repos{display:flex;flex-direction:column;gap:8px;max-width:760px}
|
|
7
|
+
.da-repos-title{font-size:12px;font-weight:600;color:var(--ink-2,#4B515A);margin-bottom:2px}
|
|
8
|
+
.da-repo-card{
|
|
9
|
+
display:flex;align-items:center;justify-content:space-between;gap:12px;
|
|
10
|
+
padding:10px 12px;border:1px solid var(--line,#E4E2DC);border-radius:10px;background:var(--paper,#fff);
|
|
11
|
+
}
|
|
12
|
+
.da-repo-main{min-width:0}
|
|
13
|
+
.da-repo-name{font-size:13px;font-weight:600;color:var(--ink,#222)}
|
|
14
|
+
.da-repo-key{font-size:10.5px;color:var(--mid,#8A8578);margin-top:2px}
|
|
15
|
+
.da-repo-desc{font-size:11.5px;color:var(--ink-2,#4B515A);margin-top:4px;line-height:1.6}
|
|
16
|
+
|
|
17
|
+
.da-split{display:grid;grid-template-columns:minmax(260px,340px) minmax(0,1fr);gap:12px;min-height:0;flex:1}
|
|
18
|
+
.da-tree{
|
|
19
|
+
display:flex;flex-direction:column;min-height:0;border:1px solid var(--line,#E4E2DC);
|
|
20
|
+
border-radius:10px;background:var(--paper,#fff);overflow:hidden;
|
|
21
|
+
}
|
|
22
|
+
.da-tree-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 10px;border-bottom:1px solid var(--line,#E4E2DC)}
|
|
23
|
+
.da-tree-repo{font-size:12.5px;color:var(--ink,#222);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
24
|
+
.da-tree-actions{display:flex;gap:4px;flex:none}
|
|
25
|
+
.da-crumb{display:flex;align-items:center;flex-wrap:wrap;gap:1px;padding:6px 8px;border-bottom:1px dashed var(--line,#E4E2DC);font-size:11px}
|
|
26
|
+
.da-crumb-item{border:0;background:transparent;padding:1px 3px;color:var(--mid,#8A8578);cursor:pointer;border-radius:4px;max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
27
|
+
.da-crumb-item:hover{color:var(--ink,#222);background:var(--soft,#F1F0EC)}
|
|
28
|
+
.da-crumb-sep{color:var(--faint,#B6B1A6);padding:0 1px}
|
|
29
|
+
.da-tree-list{flex:1;min-height:0;overflow:auto;padding:4px}
|
|
30
|
+
.da-tree-row{
|
|
31
|
+
display:flex;align-items:center;gap:7px;width:100%;padding:5px 7px;border:0;border-radius:6px;
|
|
32
|
+
background:transparent;text-align:left;cursor:pointer;color:var(--ink,#222);font:inherit;
|
|
33
|
+
}
|
|
34
|
+
.da-tree-row:hover{background:var(--soft,#F1F0EC)}
|
|
35
|
+
.da-tree-row.active{background:var(--mdw-accent-soft,#E8F2EE);color:var(--mdw-accent,#2F6F5E)}
|
|
36
|
+
.da-kind{
|
|
37
|
+
flex:none;font-size:9.5px;line-height:1.5;padding:0 5px;border-radius:4px;
|
|
38
|
+
color:var(--mid,#8A8578);background:var(--soft,#F1F0EC);
|
|
39
|
+
}
|
|
40
|
+
.da-kind.dir{color:#6B5A2E;background:#F7F1DF}
|
|
41
|
+
.da-entry-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px}
|
|
42
|
+
.da-entry-size{flex:none;margin-left:auto;font-size:10px;color:var(--faint,#B6B1A6)}
|
|
43
|
+
|
|
44
|
+
.da-right{display:flex;flex-direction:column;gap:10px;min-width:0;min-height:0}
|
|
45
|
+
.da-file{border:1px solid var(--line,#E4E2DC);border-radius:10px;background:var(--paper,#fff);overflow:hidden;min-height:120px}
|
|
46
|
+
.da-file-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:7px 10px;border-bottom:1px solid var(--line,#E4E2DC);font-size:11px}
|
|
47
|
+
.da-file-head code{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
48
|
+
.da-pre{
|
|
49
|
+
margin:0;padding:10px 12px;max-height:340px;overflow:auto;font:400 12px/1.6 ui-monospace,Consolas,monospace;
|
|
50
|
+
color:var(--ink-2,#4B515A);background:var(--paper,#fff);white-space:pre;
|
|
51
|
+
}
|
|
52
|
+
.da-note-box{display:flex;gap:8px;align-items:flex-start}
|
|
53
|
+
.da-note{
|
|
54
|
+
flex:1;min-height:64px;resize:vertical;box-sizing:border-box;padding:8px 10px;
|
|
55
|
+
font:400 12.5px/1.6 inherit;color:var(--ink,#222);background:var(--paper,#fff);
|
|
56
|
+
border:1px solid var(--line,#E4E2DC);border-radius:8px;
|
|
57
|
+
}
|
|
58
|
+
.da-note:focus{outline:none;border-color:var(--mdw-accent-line,#B7D4C8)}
|
|
59
|
+
.da-annotations{display:flex;flex-direction:column;gap:6px;min-height:0;overflow:auto}
|
|
60
|
+
.da-ann-title{font-size:11.5px;font-weight:600;color:var(--ink-2,#4B515A)}
|
|
61
|
+
.da-ann-row{
|
|
62
|
+
display:flex;align-items:flex-start;justify-content:space-between;gap:8px;
|
|
63
|
+
padding:7px 9px;border:1px solid var(--line,#E4E2DC);border-radius:8px;background:var(--paper,#fff);
|
|
64
|
+
}
|
|
65
|
+
.da-ann-main{min-width:0}
|
|
66
|
+
.da-ann-main code{font-size:11px;color:var(--mdw-accent,#2F6F5E)}
|
|
67
|
+
.da-ann-main p{margin:3px 0 0;font-size:12px;line-height:1.6;color:var(--ink-2,#4B515A);white-space:pre-wrap}
|
|
68
|
+
|
|
69
|
+
.da-settings{max-width:760px}
|
|
70
|
+
.da-setting-list{display:flex;flex-direction:column;gap:8px}
|
|
71
|
+
.da-setting-row{
|
|
72
|
+
display:flex;align-items:flex-start;gap:10px;padding:10px 12px;
|
|
73
|
+
border:1px solid var(--line,#E4E2DC);border-radius:10px;background:var(--paper,#fff);
|
|
74
|
+
}
|
|
75
|
+
.da-setting-row input[type="checkbox"]{margin-top:3px}
|
|
76
|
+
.da-setting-main{display:flex;flex-direction:column;gap:2px;min-width:0}
|
|
77
|
+
.da-setting-main b{font-size:12.5px;color:var(--ink,#222)}
|
|
78
|
+
.da-setting-main .muted{font-size:11.5px;line-height:1.6}
|
|
79
|
+
.da-setting-col{flex-direction:column;gap:6px}
|
|
80
|
+
.da-setting-col b{font-size:12.5px;color:var(--ink,#222)}
|
|
81
|
+
.da-setting-col .muted{font-size:11.5px}
|
|
82
|
+
.da-setting-input{
|
|
83
|
+
width:100%;box-sizing:border-box;padding:6px 9px;font:400 12.5px/1.6 inherit;color:var(--ink,#222);
|
|
84
|
+
background:var(--paper,#fff);border:1px solid var(--line,#E4E2DC);border-radius:8px;
|
|
85
|
+
}
|
|
86
|
+
.da-setting-input:focus{outline:none;border-color:var(--mdw-accent-line,#B7D4C8)}
|
|
87
|
+
|
|
88
|
+
@media (max-width: 900px){
|
|
89
|
+
.da-split{grid-template-columns:1fr}
|
|
90
|
+
.da-tree{max-height:320px}
|
|
91
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// 目录批注插件:新建任务下拉只注册一个 panel 入口;文件树/批注 UI 与设置页全在 client 包。
|
|
2
|
+
import { definePlugin, paramsOf } from '@nx-kv/plugin-sdk';
|
|
3
|
+
import { migrateStorage, readSettings, STORAGE_VERSION, writeSettings } from './settings.js';
|
|
4
|
+
|
|
5
|
+
export default definePlugin({
|
|
6
|
+
id: 'dir-annotate',
|
|
7
|
+
version: '0.1.0',
|
|
8
|
+
api: '^1',
|
|
9
|
+
name: '目录批注',
|
|
10
|
+
description: '选择项目目录中的文件、添加批注,最后生成一条任务草稿。',
|
|
11
|
+
order: 20,
|
|
12
|
+
defaultEnabled: true,
|
|
13
|
+
storageVersion: STORAGE_VERSION,
|
|
14
|
+
migrateStorage,
|
|
15
|
+
entries(ctx) {
|
|
16
|
+
const kind = ctx.topic?.kind || (ctx.groupKey ? 'group' : ctx.repoKey ? 'repo' : 'unknown');
|
|
17
|
+
if (kind === 'unknown') return [];
|
|
18
|
+
return [
|
|
19
|
+
{
|
|
20
|
+
id: 'dir-annotate:open',
|
|
21
|
+
pluginId: 'dir-annotate',
|
|
22
|
+
label: '目录批注…',
|
|
23
|
+
description: kind === 'group' ? '先选仓库,再选文件添加批注' : '选择项目文件并添加批注',
|
|
24
|
+
icon: 'folder',
|
|
25
|
+
kind: 'panel',
|
|
26
|
+
order: 20,
|
|
27
|
+
ui: { panel: 'annotate' },
|
|
28
|
+
panel: { title: '目录批注' },
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
},
|
|
32
|
+
async buildDraft() {
|
|
33
|
+
throw new Error('目录批注入口通过面板生成任务,不走 pretask.draft');
|
|
34
|
+
},
|
|
35
|
+
rpc: {
|
|
36
|
+
async getSettings(ctx) {
|
|
37
|
+
return readSettings(ctx.storage);
|
|
38
|
+
},
|
|
39
|
+
async setSettings(ctx, raw) {
|
|
40
|
+
return writeSettings(ctx.storage, paramsOf(raw));
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// 目录批注插件的自有设置表(插件包自己的结构,宿主只记版本号)。
|
|
2
|
+
import type { PluginDb } from '@nx-kv/plugin-sdk';
|
|
3
|
+
|
|
4
|
+
export interface DirAnnotateSettings {
|
|
5
|
+
/** 文件树是否显示以 . 开头的隐藏项 */
|
|
6
|
+
showHidden: boolean;
|
|
7
|
+
/** 生成任务正文时是否带「当前目录」 */
|
|
8
|
+
includeDir: boolean;
|
|
9
|
+
/** 生成任务标题前缀(如「【批注】」),空 = 不加 */
|
|
10
|
+
titlePrefix: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const STORAGE_VERSION = 1;
|
|
14
|
+
|
|
15
|
+
const DEFAULTS: DirAnnotateSettings = { showHidden: false, includeDir: true, titlePrefix: '' };
|
|
16
|
+
|
|
17
|
+
export function migrateStorage(db: PluginDb, fromVersion: number): number {
|
|
18
|
+
if (fromVersion < 1) {
|
|
19
|
+
db.exec(
|
|
20
|
+
`CREATE TABLE IF NOT EXISTS dir_annotate_settings (
|
|
21
|
+
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
22
|
+
show_hidden INTEGER NOT NULL DEFAULT 0 CHECK (show_hidden IN (0, 1)),
|
|
23
|
+
include_dir INTEGER NOT NULL DEFAULT 1 CHECK (include_dir IN (0, 1)),
|
|
24
|
+
title_prefix TEXT NOT NULL DEFAULT '',
|
|
25
|
+
updated_at INTEGER NOT NULL
|
|
26
|
+
)`,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return STORAGE_VERSION;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function truthy(value: unknown, fallback: boolean): boolean {
|
|
33
|
+
if (value === undefined || 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
|
+
|
|
39
|
+
export function readSettings(db: PluginDb): DirAnnotateSettings {
|
|
40
|
+
const row = db.get('SELECT show_hidden, include_dir, title_prefix FROM dir_annotate_settings WHERE id = 1');
|
|
41
|
+
if (!row) return { ...DEFAULTS };
|
|
42
|
+
return {
|
|
43
|
+
showHidden: !!Number(row.show_hidden),
|
|
44
|
+
includeDir: !!Number(row.include_dir),
|
|
45
|
+
titlePrefix: String(row.title_prefix || ''),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** 合并写入;只认三个字段,titlePrefix 截到 40 字。 */
|
|
50
|
+
export function writeSettings(db: PluginDb, patch: Record<string, unknown>): DirAnnotateSettings {
|
|
51
|
+
const cur = readSettings(db);
|
|
52
|
+
const next: DirAnnotateSettings = {
|
|
53
|
+
showHidden: truthy(patch.showHidden, cur.showHidden),
|
|
54
|
+
includeDir: truthy(patch.includeDir, cur.includeDir),
|
|
55
|
+
titlePrefix: patch.titlePrefix === undefined
|
|
56
|
+
? cur.titlePrefix
|
|
57
|
+
: String(patch.titlePrefix || '').trim().slice(0, 40),
|
|
58
|
+
};
|
|
59
|
+
db.run(
|
|
60
|
+
`INSERT INTO dir_annotate_settings (id, show_hidden, include_dir, title_prefix, updated_at)
|
|
61
|
+
VALUES (1, :hide, :dir, :prefix, :at)
|
|
62
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
63
|
+
show_hidden = excluded.show_hidden,
|
|
64
|
+
include_dir = excluded.include_dir,
|
|
65
|
+
title_prefix = excluded.title_prefix,
|
|
66
|
+
updated_at = excluded.updated_at`,
|
|
67
|
+
{
|
|
68
|
+
hide: next.showHidden ? 1 : 0,
|
|
69
|
+
dir: next.includeDir ? 1 : 0,
|
|
70
|
+
prefix: next.titlePrefix,
|
|
71
|
+
at: Date.now(),
|
|
72
|
+
},
|
|
73
|
+
);
|
|
74
|
+
return next;
|
|
75
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "ES2022",
|
|
5
|
+
"lib": ["ES2023", "DOM", "DOM.Iterable"],
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"moduleResolution": "bundler",
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"noEmit": true,
|
|
10
|
+
"types": ["vite/client"]
|
|
11
|
+
},
|
|
12
|
+
"include": ["src/client/**/*.ts", "src/client/**/*.tsx"]
|
|
13
|
+
}
|