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
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "ES2022",
|
|
5
|
+
"lib": ["ES2023"],
|
|
6
|
+
"module": "NodeNext",
|
|
7
|
+
"moduleResolution": "NodeNext",
|
|
8
|
+
"rootDir": "src/server",
|
|
9
|
+
"outDir": "dist/server",
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"sourceMap": true,
|
|
12
|
+
"composite": false,
|
|
13
|
+
"types": ["node"]
|
|
14
|
+
},
|
|
15
|
+
"include": ["src/server/**/*.ts"]
|
|
16
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
const PACKAGE_DIR = fileURLToPath(new URL('.', import.meta.url));
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
root: PACKAGE_DIR,
|
|
9
|
+
plugins: [react()],
|
|
10
|
+
build: {
|
|
11
|
+
outDir: 'dist/client',
|
|
12
|
+
emptyOutDir: true,
|
|
13
|
+
cssCodeSplit: false,
|
|
14
|
+
lib: {
|
|
15
|
+
entry: 'src/client/index.tsx',
|
|
16
|
+
formats: ['iife'],
|
|
17
|
+
name: 'NxkvPluginDirAnnotate',
|
|
18
|
+
fileName: () => 'client.js',
|
|
19
|
+
},
|
|
20
|
+
rollupOptions: {
|
|
21
|
+
external: ['react', 'react-dom', 'react/jsx-runtime'],
|
|
22
|
+
output: {
|
|
23
|
+
globals: {
|
|
24
|
+
react: 'NxkvReact',
|
|
25
|
+
'react-dom': 'NxkvReactDOM',
|
|
26
|
+
'react/jsx-runtime': 'NxkvJsxRuntime',
|
|
27
|
+
},
|
|
28
|
+
assetFileNames: (asset) =>
|
|
29
|
+
asset.name && asset.name.endsWith('.css') ? 'style.css' : 'assets/[name][extname]',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { EntryView, PretaskContext, PretaskDraft } from './index.js';
|
|
3
|
+
export type { PluginContextView, PluginFileView, PluginRepoView, PluginTreeEntry, PluginTreeView, PluginTopicInfo, } from './index.js';
|
|
4
|
+
export interface PluginClientApi {
|
|
5
|
+
pluginId: string;
|
|
6
|
+
ctx: PretaskContext;
|
|
7
|
+
/** entry-form 页面才有。 */
|
|
8
|
+
entry?: EntryView;
|
|
9
|
+
rpc(method: string, params?: unknown): Promise<any>;
|
|
10
|
+
/** 请求宿主 HTTP(只允许 /api/ 路径);缺上下文时用它自行构造内容。 */
|
|
11
|
+
host: {
|
|
12
|
+
get<T = any>(path: string, params?: Record<string, string | number | boolean | null | undefined>): Promise<T>;
|
|
13
|
+
};
|
|
14
|
+
draft(entryId: string, values: Record<string, string>): Promise<PretaskDraft>;
|
|
15
|
+
/**
|
|
16
|
+
* 宿主写草稿并打开 task 编辑页。
|
|
17
|
+
* opts.project / opts.board:组场景下插件自选仓库时覆盖落点归属(缺省用 ctx)。
|
|
18
|
+
*/
|
|
19
|
+
createDraft(draft: PretaskDraft, opts?: {
|
|
20
|
+
submit?: boolean;
|
|
21
|
+
project?: string;
|
|
22
|
+
board?: string;
|
|
23
|
+
}): void;
|
|
24
|
+
navigate(hash: string): void;
|
|
25
|
+
closePage(): void;
|
|
26
|
+
toast(msg: string): void;
|
|
27
|
+
}
|
|
28
|
+
export interface PluginSidebarEntry {
|
|
29
|
+
id: string;
|
|
30
|
+
label: string;
|
|
31
|
+
icon?: string;
|
|
32
|
+
order?: number;
|
|
33
|
+
/** 指向 pages 的 key。 */
|
|
34
|
+
page: string;
|
|
35
|
+
}
|
|
36
|
+
export interface PluginUiDefinition {
|
|
37
|
+
api: '^1' | string;
|
|
38
|
+
components: Record<string, ComponentType<any>>;
|
|
39
|
+
pages?: Record<string, {
|
|
40
|
+
title: string;
|
|
41
|
+
}>;
|
|
42
|
+
sidebar?: PluginSidebarEntry[];
|
|
43
|
+
}
|
|
44
|
+
export interface PluginHostGlobal {
|
|
45
|
+
api: string;
|
|
46
|
+
registerPlugin(id: string, def: PluginUiDefinition): void;
|
|
47
|
+
}
|
|
48
|
+
declare global {
|
|
49
|
+
interface Window {
|
|
50
|
+
NxkvPluginHost?: PluginHostGlobal;
|
|
51
|
+
NxkvReact?: unknown;
|
|
52
|
+
NxkvReactDOM?: unknown;
|
|
53
|
+
NxkvJsxRuntime?: unknown;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1E,YAAY,EACV,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,cAAc,CAAC;IACpB,uBAAuB;IACvB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACpD,6CAA6C;IAC7C,IAAI,EAAE;QACJ,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;KAC/G,CAAC;IACF,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAC9E;;;OAGG;IACH,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI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""}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
export declare const PLUGIN_API = "^1";
|
|
2
|
+
/** 插件可用的最小 DB 形状(宿主把它包在 single-writer 事务里传进来)。 */
|
|
3
|
+
export interface PluginDb {
|
|
4
|
+
path?: string;
|
|
5
|
+
readOnly?: boolean;
|
|
6
|
+
exec(sql: string): void;
|
|
7
|
+
get(sql: string, params?: unknown): any;
|
|
8
|
+
all(sql: string, params?: unknown): any[];
|
|
9
|
+
run(sql: string, params?: unknown): {
|
|
10
|
+
changes?: number | bigint;
|
|
11
|
+
lastInsertRowid?: number | bigint;
|
|
12
|
+
};
|
|
13
|
+
scalar?(sql: string, params?: unknown): any;
|
|
14
|
+
}
|
|
15
|
+
export type TopicKind = 'repo' | 'group' | 'unknown';
|
|
16
|
+
/** 当前 topic 的完整定位;插件缺东西时可用 host.get('/api/plugins/context') 再取。 */
|
|
17
|
+
export interface PluginTopicInfo {
|
|
18
|
+
key: string;
|
|
19
|
+
name: string;
|
|
20
|
+
kind: TopicKind;
|
|
21
|
+
cwd: string;
|
|
22
|
+
repoKey: string;
|
|
23
|
+
groupKey: string;
|
|
24
|
+
repoName?: string;
|
|
25
|
+
groupName?: string;
|
|
26
|
+
/** 仓库本机根目录(repo topic 或 group topic 的成员 repo) */
|
|
27
|
+
repoRoot?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface PluginLocation {
|
|
30
|
+
dirKey?: string;
|
|
31
|
+
groupId?: string;
|
|
32
|
+
board?: string;
|
|
33
|
+
project?: string;
|
|
34
|
+
taskId?: string;
|
|
35
|
+
}
|
|
36
|
+
/** /api/plugins/context 里的仓库行。 */
|
|
37
|
+
export interface PluginRepoView {
|
|
38
|
+
key: string;
|
|
39
|
+
type: string;
|
|
40
|
+
name: string;
|
|
41
|
+
path: string;
|
|
42
|
+
description: string;
|
|
43
|
+
}
|
|
44
|
+
/** /api/plugins/context 的返回:topic + 当前 repo/group + 组内 repo 列表。 */
|
|
45
|
+
export interface PluginContextView {
|
|
46
|
+
topic: PluginTopicInfo;
|
|
47
|
+
repo: PluginRepoView | null;
|
|
48
|
+
group: PluginRepoView | null;
|
|
49
|
+
repos: PluginRepoView[];
|
|
50
|
+
}
|
|
51
|
+
/** /api/plugins/tree 的目录项。 */
|
|
52
|
+
export interface PluginTreeEntry {
|
|
53
|
+
name: string;
|
|
54
|
+
path: string;
|
|
55
|
+
type: 'dir' | 'file';
|
|
56
|
+
size?: number;
|
|
57
|
+
}
|
|
58
|
+
/** /api/plugins/tree 的返回。 */
|
|
59
|
+
export interface PluginTreeView {
|
|
60
|
+
repoKey: string;
|
|
61
|
+
repoName: string;
|
|
62
|
+
repoRoot: string;
|
|
63
|
+
path: string;
|
|
64
|
+
entries: PluginTreeEntry[];
|
|
65
|
+
truncated: boolean;
|
|
66
|
+
}
|
|
67
|
+
/** /api/plugins/file 的返回(二进制不给正文)。 */
|
|
68
|
+
export interface PluginFileView {
|
|
69
|
+
repoKey: string;
|
|
70
|
+
path: string;
|
|
71
|
+
size: number;
|
|
72
|
+
binary: boolean;
|
|
73
|
+
truncated: boolean;
|
|
74
|
+
content: string;
|
|
75
|
+
}
|
|
76
|
+
/** 插件看到的宿主上下文:只给任务/主题定位,不给宿主内部对象。 */
|
|
77
|
+
export interface PretaskContext {
|
|
78
|
+
topicKey?: string;
|
|
79
|
+
groupKey?: string;
|
|
80
|
+
repoKey?: string;
|
|
81
|
+
cwd?: string;
|
|
82
|
+
dirKey?: string;
|
|
83
|
+
groupId?: string;
|
|
84
|
+
board?: string;
|
|
85
|
+
project?: string;
|
|
86
|
+
/** 宿主解析后的完整 topic(前端可传,宿主会按 DB 补全) */
|
|
87
|
+
topic?: PluginTopicInfo | null;
|
|
88
|
+
/** 组/看板/项目等定位(前端上下文透传) */
|
|
89
|
+
location?: PluginLocation;
|
|
90
|
+
}
|
|
91
|
+
export interface SlotDecl {
|
|
92
|
+
key: string;
|
|
93
|
+
label: string;
|
|
94
|
+
type: 'text';
|
|
95
|
+
required?: boolean;
|
|
96
|
+
hint?: string;
|
|
97
|
+
default?: string;
|
|
98
|
+
}
|
|
99
|
+
export interface PretaskDraft {
|
|
100
|
+
body: string;
|
|
101
|
+
title?: string;
|
|
102
|
+
}
|
|
103
|
+
export interface EntryView {
|
|
104
|
+
/** `${pluginId}:${localId}`,全局唯一、稳定。 */
|
|
105
|
+
id: string;
|
|
106
|
+
pluginId: string;
|
|
107
|
+
label: string;
|
|
108
|
+
description?: string;
|
|
109
|
+
icon?: string;
|
|
110
|
+
kind: 'draft' | 'panel';
|
|
111
|
+
order: number;
|
|
112
|
+
default?: boolean;
|
|
113
|
+
builtin?: boolean;
|
|
114
|
+
/** kind=draft:模板槽位与原始正文。 */
|
|
115
|
+
slots?: SlotDecl[];
|
|
116
|
+
previewBody?: string;
|
|
117
|
+
values?: Record<string, string>;
|
|
118
|
+
/** 插件 client bundle 注册的 UI 组件 key。 */
|
|
119
|
+
ui?: {
|
|
120
|
+
row?: string;
|
|
121
|
+
form?: string;
|
|
122
|
+
panel?: string;
|
|
123
|
+
};
|
|
124
|
+
/** kind=panel 的兜底元信息。 */
|
|
125
|
+
panel?: {
|
|
126
|
+
title?: string;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
export interface PluginContext extends PretaskContext {
|
|
130
|
+
storage: PluginDb;
|
|
131
|
+
storageVersion: number;
|
|
132
|
+
log: (level: string, msg: string) => void;
|
|
133
|
+
/** 宿主暂存的旧数据(如 v18 templates);插件成功导入后宿主会删除。 */
|
|
134
|
+
legacy: {
|
|
135
|
+
take(kind: string): Promise<unknown | null>;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
export interface NxkvPlugin {
|
|
139
|
+
id: string;
|
|
140
|
+
version: string;
|
|
141
|
+
api: typeof PLUGIN_API | string;
|
|
142
|
+
name: string;
|
|
143
|
+
description?: string;
|
|
144
|
+
order: number;
|
|
145
|
+
defaultEnabled: boolean;
|
|
146
|
+
entries(ctx: PluginContext): Promise<EntryView[]> | EntryView[];
|
|
147
|
+
buildDraft(ctx: PluginContext, entryId: string, values: Record<string, string>): Promise<PretaskDraft>;
|
|
148
|
+
rpc?: Record<string, (ctx: PluginContext, params: any) => Promise<any>>;
|
|
149
|
+
/** 插件自己的表结构目标版本;宿主据此记录 plugin_storage_migrations。 */
|
|
150
|
+
storageVersion?: number;
|
|
151
|
+
/** 插件自己的建表/升级逻辑;fromVersion 由宿主传入。 */
|
|
152
|
+
migrateStorage?(db: PluginDb, fromVersion: number): number | void;
|
|
153
|
+
/** 宿主暂存数据的一次性导入;按业务 id 幂等。 */
|
|
154
|
+
migrateLegacy?(ctx: PluginContext, kind: string, payload: unknown): Promise<void>;
|
|
155
|
+
}
|
|
156
|
+
/** 插件 server 入口的默认导出必须包一层,宿主据此做运行时校验。 */
|
|
157
|
+
export declare function definePlugin(plugin: NxkvPlugin): NxkvPlugin;
|
|
158
|
+
/** 供插件做 rpc 参数兜底:把未知值收成普通对象。 */
|
|
159
|
+
export declare function paramsOf(raw: unknown): Record<string, any>;
|
|
160
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU,OAAO,CAAC;AAE/B,kDAAkD;AAClD,MAAM,WAAW,QAAQ;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,GAAG,CAAC;IACxC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,GAAG,EAAE,CAAC;IAC1C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG;QAAE,OAAO,CAAC,EA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