nx-kv 0.63.0 → 0.64.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 +29 -0
- package/assets/nx-kv/references/A03-/346/226/207/346/241/243/344/270/216/345/275/222/345/261/236.md +6 -5
- package/package.json +2 -2
- package/src/core/attachmentdb/docs.ts +3 -6
- package/src/core/attachmentdb/query.ts +2 -2
- package/src/core/attachmentdb/relations.ts +36 -21
- package/src/core/db/import-json/refs.ts +17 -19
- package/src/core/db/import-json/repos.ts +4 -8
- package/src/core/db/migrations/index.ts +2 -0
- package/src/core/db/migrations/v13.sql +24 -0
- package/src/core/db/seed-templates.ts +15 -4
- package/src/core/db/version.ts +3 -1
- package/src/modules/docs/actions/_manifest.generated.ts +0 -3
- package/src/modules/docs/actions/doc-attach.ts +0 -1
- package/src/modules/docs/actions/docs-bindings.ts +2 -5
- package/src/modules/docs/actions/docs-link.ts +1 -2
- package/src/modules/docs/attach.ts +1 -36
- package/src/modules/docs/bound-docs.ts +2 -2
- package/src/modules/docs/brief.ts +0 -2
- package/src/modules/docs/docref.ts +7 -17
- package/src/modules/docs/knowledge-md.ts +1 -1
- package/src/modules/docs/knowledge.ts +48 -45
- package/src/modules/docs/ref-sync.ts +1 -5
- package/src/modules/docs/refs.ts +7 -10
- package/src/modules/docs/service.ts +1 -3
- package/src/modules/localtask/actions/localtask-config.ts +19 -58
- package/src/modules/localtask/actions/localtask-prune.ts +7 -2
- package/src/modules/localtask/repo/open.ts +0 -4
- package/src/modules/localtask/repo/settings.ts +20 -196
- package/src/modules/localtask/task-lifecycle.ts +7 -9
- package/src/modules/localtask/task-templates.ts +4 -4
- package/src/modules/localtask/task-view.ts +4 -0
- package/src/modules/localtask/topics.ts +30 -28
- package/src/modules/promptplug/actions/_manifest.generated.ts +0 -3
- package/src/modules/promptplug/actions/prompt-registry.ts +19 -30
- package/src/modules/promptplug/base.ts +69 -25
- package/src/modules/promptplug/compose.ts +40 -23
- package/src/modules/promptplug/factory.ts +91 -59
- package/src/modules/promptplug/index.ts +25 -11
- package/src/modules/promptplug/plugins/ack.ts +28 -0
- package/src/modules/promptplug/plugins/attachment.ts +237 -19
- package/src/modules/promptplug/plugins/context.ts +124 -30
- package/src/modules/promptplug/plugins/doneguard.ts +33 -0
- package/src/modules/promptplug/plugins/ext.ts +34 -11
- package/src/modules/promptplug/plugins/getloop.ts +29 -8
- package/src/modules/promptplug/plugins/goal-shape.ts +34 -0
- package/src/modules/promptplug/plugins/goalhint.ts +33 -0
- package/src/modules/promptplug/plugins/timecheck.ts +33 -0
- package/src/modules/promptplug/registry.ts +99 -0
- package/src/modules/promptplug/schema-bridge.ts +77 -13
- package/src/modules/repos/actions/board-rekey.ts +1 -1
- package/src/modules/repos/actions/repo-doc-add.ts +2 -3
- package/src/modules/repos/boards/core.ts +1 -13
- package/src/modules/repos/boards/docs.ts +2 -12
- package/src/modules/repos/boards/members.ts +2 -14
- package/src/modules/repos/boards/transfer.ts +2 -11
- package/src/modules/repos/keys.ts +4 -11
- package/src/modules/repos/repo/refs.ts +3 -5
- package/src/modules/repos/repo/repos.ts +12 -13
- package/src/modules/repos/repo/rows.ts +2 -8
- package/src/modules/repos/service/context.ts +0 -2
- package/src/modules/repos/service/crud.ts +1 -4
- package/src/modules/repos/service/store.ts +6 -7
- package/src/modules/repos/transfer/export.ts +3 -8
- package/src/modules/repos/transfer/import.ts +0 -13
- package/src/modules/repos/transfer/layout.ts +2 -2
- package/src/modules/tasktool/attach-template.ts +3 -3
- package/src/modules/tasktool/groupctx.ts +4 -5
- package/src/modules/tasktool/plugins/waitgoal-config.ts +5 -6
- package/src/modules/tasktool/preview.ts +20 -23
- package/src/modules/tasktool/wait.ts +24 -46
- package/src/modules/templates/actions/_manifest.generated.ts +3 -0
- package/src/modules/templates/actions/templates-reorder.ts +28 -0
- package/src/modules/templates/repo/templates.ts +32 -2
- package/src/modules/templates/service.ts +45 -0
- package/src/shared/prompt-blocks.ts +7 -173
- package/src/shared/prompt-plugin.ts +79 -59
- package/src/web/frontend/App.tsx +27 -1
- package/src/web/frontend/api/cli-tree.json +20 -35
- package/src/web/frontend/api/client.generated.ts +22 -32
- package/src/web/frontend/components/Introduction/rail.tsx +2 -2
- package/src/web/frontend/components/Introduction/use-intro.ts +2 -5
- package/src/web/frontend/components/bindings/bind-tags.tsx +1 -3
- package/src/web/frontend/components/list-search.tsx +37 -0
- package/src/web/frontend/components/md/attach-area.tsx +10 -15
- package/src/web/frontend/components/md/live-block.tsx +5 -14
- package/src/web/frontend/components/md/md-panes.tsx +3 -19
- package/src/web/frontend/modules/list-filter.ts +37 -0
- package/src/web/frontend/modules/md/fill-session.ts +36 -0
- package/src/web/frontend/modules/md/manage-session.ts +24 -0
- package/src/web/frontend/modules/md/new-task-from-template.ts +22 -0
- package/src/web/frontend/modules/md/styles/editor.css +5 -12
- package/src/web/frontend/modules/md/styles/shell.css +4 -0
- package/src/web/frontend/modules/md/task-intent.ts +29 -0
- package/src/web/frontend/modules/md/use-templates.ts +8 -0
- package/src/web/frontend/modules/prompts/template-preview.ts +12 -20
- package/src/web/frontend/modules/refs/api.ts +0 -1
- package/src/web/frontend/page/dir/index.tsx +20 -5
- package/src/web/frontend/page/dir/task-actions.ts +14 -0
- package/src/web/frontend/page/dir/task-preview-modal.tsx +1 -1
- package/src/web/frontend/page/dir/task.tsx +19 -0
- package/src/web/frontend/page/doc/api.ts +2 -3
- package/src/web/frontend/page/doc/bindings.tsx +46 -16
- package/src/web/frontend/page/doc/index.tsx +3 -4
- package/src/web/frontend/page/group/index.tsx +65 -117
- package/src/web/frontend/page/refs/index.tsx +27 -3
- package/src/web/frontend/page/refs/style.css +3 -0
- package/src/web/frontend/page/repos/bind-modals.tsx +18 -2
- package/src/web/frontend/page/repos/board-admin.tsx +1 -1
- package/src/web/frontend/page/repos/index.tsx +4 -8
- package/src/web/frontend/page/repos/ref-block.tsx +5 -12
- package/src/web/frontend/page/repos/ref-panel.tsx +3 -4
- package/src/web/frontend/page/repos/repo-form-modal.tsx +1 -8
- package/src/web/frontend/page/repos/repo-table.tsx +4 -29
- package/src/web/frontend/page/repos/use-repos-derive.ts +4 -5
- package/src/web/frontend/page/settings/api.ts +7 -15
- package/src/web/frontend/page/settings/prompt-templates-section.tsx +261 -289
- package/src/web/frontend/page/settings/prompt-vars.ts +56 -0
- package/src/web/frontend/page/settings/style.css +46 -64
- package/src/web/frontend/page/templates/fill.tsx +124 -0
- package/src/web/frontend/page/templates/index.tsx +11 -0
- package/src/web/frontend/page/templates/manage.tsx +218 -0
- package/src/web/frontend/page/templates/style.css +46 -0
- package/src/web/frontend/page/templates/template-list.tsx +58 -54
- package/src/web/frontend/refs/api.ts +0 -2
- package/src/web/frontend/routes/route-eq.ts +22 -0
- package/src/web/frontend/routes/templates.ts +20 -0
- package/src/web/frontend/style.css +1 -0
- package/src/web/frontend/styles/list-search.css +44 -0
- package/src/web/frontend/types.ts +5 -1
- package/src/web/public/assets/{bar-CYWfxHfm.js → bar-j14ON7uZ.js} +1 -1
- package/src/web/public/assets/{composer-launch-Bor4ngrQ.js → composer-launch-DRi9mZE1.js} +1 -1
- package/src/web/public/assets/{composer-panel-C7mNI7EW.js → composer-panel-swmDqlPw.js} +1 -1
- package/src/web/public/assets/dir-DhsB1ZhL.js +3 -0
- package/src/web/public/assets/doc-D4po3sDc.js +6 -0
- package/src/web/public/assets/fill-session-fHxQHFaD.js +1 -0
- package/src/web/public/assets/group-BxmSNzIB.js +1 -0
- package/src/web/public/assets/index-CMjG5NVU.js +2 -0
- package/src/web/public/assets/index-uMjSWNVr.css +1 -0
- package/src/web/public/assets/list-filter-D-x94TvA.js +1 -0
- package/src/web/public/assets/manage-session-CS8UvmUd.js +1 -0
- package/src/web/public/assets/md-history-CZUF_FhN.js +39 -0
- package/src/web/public/assets/new-task-from-template-DDWu4yR4.js +1 -0
- package/src/web/public/assets/refs-TuuoaRs7.js +2 -0
- package/src/web/public/assets/refs-zSA2k_45.css +1 -0
- package/src/web/public/assets/render-template-body-bXdedFig.js +1 -0
- package/src/web/public/assets/repo-form-modal-BD4N37MI.js +1 -0
- package/src/web/public/assets/repos-BPeuX4N9.js +12 -0
- package/src/web/public/assets/settings-CZJaKLZW.js +1 -0
- package/src/web/public/assets/settings-Cc6puKd5.css +1 -0
- package/src/web/public/assets/task-DgbbF5gy.js +11 -0
- package/src/web/public/assets/task-intent-CX5DZccN.js +1 -0
- package/src/web/public/assets/{task-utils-DpnPjZKJ.js → task-utils-bJH1-Cjy.js} +1 -1
- package/src/web/public/assets/templates-CBXlwyof.js +11 -0
- package/src/web/public/assets/templates-plA8R7jJ.css +1 -0
- package/src/web/public/assets/use-rail-drag-ufwy2XZB.js +1 -0
- package/src/web/public/index.html +8 -6
- package/src/modules/docs/actions/doc-attach-note.ts +0 -32
- package/src/modules/promptplug/Template/blockTemplates.json +0 -90
- package/src/modules/promptplug/actions/prompt-order.ts +0 -38
- package/src/modules/promptplug/ensure.ts +0 -57
- package/src/modules/promptplug/keys.ts +0 -9
- package/src/modules/promptplug/plugins/readonly-blocks.ts +0 -75
- package/src/modules/promptplug/template-bundle.ts +0 -59
- package/src/web/frontend/modules/md/template-locks.ts +0 -105
- package/src/web/frontend/page/settings/prompt-editor.tsx +0 -279
- package/src/web/frontend/page/settings/prompt-rail.tsx +0 -170
- package/src/web/public/assets/dir-CcffxXL2.js +0 -3
- package/src/web/public/assets/doc-BxWVzWkw.js +0 -6
- package/src/web/public/assets/group-C5Yu3oJr.js +0 -1
- package/src/web/public/assets/index-BvyZ1MA2.js +0 -2
- package/src/web/public/assets/index-Cp-TtHyA.css +0 -1
- package/src/web/public/assets/md-history-DejKuR12.js +0 -39
- package/src/web/public/assets/refs-DJdKV8_H.css +0 -1
- package/src/web/public/assets/refs-VbDnDTV0.js +0 -2
- package/src/web/public/assets/repo-form-modal-Dkdvu_uN.js +0 -1
- package/src/web/public/assets/repos-CY0eZheu.js +0 -16
- package/src/web/public/assets/settings-AwzLRYUu.css +0 -1
- package/src/web/public/assets/settings-D3T-vgCl.js +0 -1
- package/src/web/public/assets/task-CkCD82h_.js +0 -11
- package/src/web/public/assets/templates-BcuCbT4U.js +0 -10
- package/src/web/public/assets/templates-gNdtaMI2.css +0 -1
- package/src/web/public/assets/use-rail-drag-DMvr8-GE.js +0 -1
|
@@ -45,7 +45,6 @@ export interface DocBriefView {
|
|
|
45
45
|
desc: string;
|
|
46
46
|
/** 正文摘要(首个非标题行);没有正文时为空 */
|
|
47
47
|
summary: string;
|
|
48
|
-
note: string;
|
|
49
48
|
/** 有正文(外部镜像也算存在:正文在库外) */
|
|
50
49
|
exists: boolean;
|
|
51
50
|
missing?: boolean;
|
|
@@ -103,7 +102,6 @@ export async function docSetOf(owner: any, _kind: 'repo' | 'board' = 'repo'): Pr
|
|
|
103
102
|
title,
|
|
104
103
|
desc: row.desc,
|
|
105
104
|
summary: body ? summaryFromMd(body) : '',
|
|
106
|
-
note: String((raw && raw.note) || ''),
|
|
107
105
|
exists: row.hasBody || row.origin === 'external',
|
|
108
106
|
...(row.hasBody || row.origin === 'external' ? {} : { missing: true }),
|
|
109
107
|
};
|
|
@@ -10,17 +10,16 @@
|
|
|
10
10
|
import { badInput } from '../../core/errors.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* DocRef:{ ref }
|
|
13
|
+
* DocRef:{ ref } 指向文档库条目。
|
|
14
14
|
*
|
|
15
|
-
* #137
|
|
15
|
+
* #137 的 `tag` 已在 v12 删掉;#148 的 `note`(列表条目注解)在 v13 删掉——
|
|
16
|
+
* 描述走 ref 自己的 desc + 正文标题,关系表不再挂业务字段。
|
|
16
17
|
*/
|
|
17
18
|
export interface DocRef {
|
|
18
19
|
ref?: string;
|
|
19
|
-
/** 链接级注解(note,docLinks 条目用) */
|
|
20
|
-
note?: string;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
/** DocRef
|
|
22
|
+
/** 兼容旧调用方的类型别名(现在与 DocRef 同形)。 */
|
|
24
23
|
export type DocRefWithMeta = DocRef;
|
|
25
24
|
|
|
26
25
|
const REF_ID_RE = /^ref_[0-9a-f]{16}$/i;
|
|
@@ -52,18 +51,9 @@ export function sanitizeDocRef(raw: unknown): DocRef | null {
|
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
* 注解要过三道关(写入口合并 / 读归一化回贴 / 导出保留),三处口径必须一致——
|
|
59
|
-
* 实现只此一份,docs/refs 与 repos/service、transfer 都从这里拿。
|
|
60
|
-
* 空串/缺省 = 不落字段(对已有条目即「清掉」)。
|
|
61
|
-
*/
|
|
62
|
-
export function withLinkMeta(ref: DocRef, raw: { note?: unknown } = {}): DocRefWithMeta {
|
|
63
|
-
const note = typeof raw.note === 'string' ? raw.note.trim() : '';
|
|
64
|
-
const entry: DocRefWithMeta = { ...ref };
|
|
65
|
-
if (note) entry.note = note;
|
|
66
|
-
return entry;
|
|
54
|
+
/** 归一化一条文档条目(v13 去 note 后就是浅拷贝,保留名字让调用方语义统一)。 */
|
|
55
|
+
export function withLinkMeta(ref: DocRef): DocRefWithMeta {
|
|
56
|
+
return { ...ref };
|
|
67
57
|
}
|
|
68
58
|
|
|
69
59
|
// ─── docId(前后端统一寻址)────────────────────────────────────────────
|
|
@@ -40,7 +40,7 @@ export function renderRepoKnowledgeMd(k: RepoKnowledgeResult): string {
|
|
|
40
40
|
heading('## 参考仓库');
|
|
41
41
|
for (const r of k.refRepos) {
|
|
42
42
|
const src = r.direct && !r.groups.length ? '[直接绑定]' : r.direct ? '[组 + 直接绑定]' : '';
|
|
43
|
-
lines.push(`- ${r.name}${r.remote ? `(${r.remote})` : ''}${src}
|
|
43
|
+
lines.push(`- ${r.name}${r.remote ? `(${r.remote})` : ''}${src}`);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
return lines.join('\n');
|
|
@@ -9,6 +9,7 @@ import { reposBridge } from './repos-bridge.js';
|
|
|
9
9
|
import { getDb } from '../../core/db/index.js';
|
|
10
10
|
import { refDocById } from '../../core/attachmentdb.js';
|
|
11
11
|
import { renderRepoKnowledgeMd } from './knowledge-md.js';
|
|
12
|
+
import { docTitleFromMd } from '../../shared/doc-title.js';
|
|
12
13
|
import type { DocRef } from './docref.js';
|
|
13
14
|
|
|
14
15
|
const MAX_DOC_BYTES = 256 * 1024;
|
|
@@ -53,7 +54,6 @@ export interface RefRepoItem {
|
|
|
53
54
|
name: string;
|
|
54
55
|
path: string;
|
|
55
56
|
remote: string;
|
|
56
|
-
note: string;
|
|
57
57
|
groups: string[];
|
|
58
58
|
direct: boolean;
|
|
59
59
|
}
|
|
@@ -145,7 +145,7 @@ async function readRefDocs(raw: DocRef | null | undefined, opts: ReadOpts): Prom
|
|
|
145
145
|
}
|
|
146
146
|
return docs;
|
|
147
147
|
}
|
|
148
|
-
return [{ ...one, refId
|
|
148
|
+
return [{ ...one, refId }];
|
|
149
149
|
}
|
|
150
150
|
if (!row.hasBody) {
|
|
151
151
|
return [{
|
|
@@ -153,13 +153,11 @@ async function readRefDocs(raw: DocRef | null | undefined, opts: ReadOpts): Prom
|
|
|
153
153
|
refId,
|
|
154
154
|
docId: 'ref:' + refId,
|
|
155
155
|
title: row.desc,
|
|
156
|
-
note: String((raw && raw.note) || ''),
|
|
157
156
|
}];
|
|
158
157
|
}
|
|
159
158
|
return [{
|
|
160
159
|
...docOut('ref:' + refId, row.body ?? '', opts),
|
|
161
160
|
refId,
|
|
162
|
-
note: String((raw && raw.note) || ''),
|
|
163
161
|
}];
|
|
164
162
|
}
|
|
165
163
|
|
|
@@ -230,10 +228,9 @@ export async function repoKnowledge(locator?: string, { md = false }: { md?: boo
|
|
|
230
228
|
const hit = seenRefRepos.get(l.id);
|
|
231
229
|
if (hit) {
|
|
232
230
|
if (!hit.groups.includes(b.name)) hit.groups.push(b.name);
|
|
233
|
-
if (l.note && !hit.note) hit.note = l.note;
|
|
234
231
|
continue;
|
|
235
232
|
}
|
|
236
|
-
const item: RefRepoItem = { name: r.name, path: r.path || '', remote: r.remote || '',
|
|
233
|
+
const item: RefRepoItem = { name: r.name, path: r.path || '', remote: r.remote || '', groups: [b.name], direct: false };
|
|
237
234
|
seenRefRepos.set(l.id, item);
|
|
238
235
|
refRepos.push(item);
|
|
239
236
|
}
|
|
@@ -246,10 +243,9 @@ export async function repoKnowledge(locator?: string, { md = false }: { md?: boo
|
|
|
246
243
|
const hit = seenRefRepos.get(id);
|
|
247
244
|
if (hit) {
|
|
248
245
|
hit.direct = true;
|
|
249
|
-
if (l.note && !hit.note) hit.note = l.note;
|
|
250
246
|
continue;
|
|
251
247
|
}
|
|
252
|
-
const item: RefRepoItem = { name: r.name, path: r.path || '', remote: r.remote || '',
|
|
248
|
+
const item: RefRepoItem = { name: r.name, path: r.path || '', remote: r.remote || '', groups: [], direct: true };
|
|
253
249
|
seenRefRepos.set(id, item);
|
|
254
250
|
refRepos.push(item);
|
|
255
251
|
}
|
|
@@ -295,31 +291,36 @@ export async function groupContextFor(cwd: unknown, { board = '' }: { board?: st
|
|
|
295
291
|
refId: (repoMain && repoMain.refId) || '',
|
|
296
292
|
desc: '',
|
|
297
293
|
};
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
294
|
+
// #148:补充篇的 title/desc 必须从 refs 查真实值——原来写死 title:''、desc:note,
|
|
295
|
+
// 模板里 {{title}} 永远空、{{desc}} 拿到的是 note。DB 查不到时留空由模板回落。
|
|
296
|
+
const repoDocLinks: BoundDoc[] = (Array.isArray(repo.docLinks) ? repo.docLinks : []).map((l: any) => {
|
|
297
|
+
const refId = String(l.ref || '');
|
|
298
|
+
const d = refDocById(getDb(), refId);
|
|
299
|
+
return {
|
|
300
|
+
refId,
|
|
301
|
+
desc: String((d && d.desc) || ''),
|
|
302
|
+
title: d && d.hasBody ? docTitleFromMd(String(d.body ?? '')) : '',
|
|
303
|
+
hasBody: !!(d && (d.hasBody || d.origin === 'external')),
|
|
304
|
+
origin: '',
|
|
305
|
+
type: 'repo' as const,
|
|
306
|
+
repoKey: rk,
|
|
307
|
+
groupKey: null,
|
|
308
|
+
position: 0,
|
|
309
|
+
body: '',
|
|
310
|
+
};
|
|
311
|
+
});
|
|
311
312
|
|
|
312
313
|
// 参考仓库(repos 里 type=ref,不是文档库 refs):本仓库直接绑定与组级绑定
|
|
313
|
-
//
|
|
314
|
-
const refRepoItemOf = (id: unknown
|
|
314
|
+
// 是两类并列来源,交付时给「名称 + 本机路径」;说明走绑定 ref 的文档列表(v13)。
|
|
315
|
+
const refRepoItemOf = (id: unknown): { key: string; name: string; path: string } | null => {
|
|
315
316
|
const rr = s.repos.find((x: any) => x.type === 'ref' && deriveKey(x) === String(id));
|
|
316
317
|
if (!rr) return null;
|
|
317
|
-
return { key: String(id), name: rr.name, path: rr.path || ''
|
|
318
|
+
return { key: String(id), name: rr.name, path: rr.path || '' };
|
|
318
319
|
};
|
|
319
320
|
const repoRefRepos = (Array.isArray(repo.linked) ? repo.linked : [])
|
|
320
321
|
.filter((l: any) => l && l.kind === 'ref')
|
|
321
|
-
.map((l: any) => refRepoItemOf(l.id
|
|
322
|
-
.filter(Boolean) as Array<{ key: string; name: string; path: string
|
|
322
|
+
.map((l: any) => refRepoItemOf(l.id))
|
|
323
|
+
.filter(Boolean) as Array<{ key: string; name: string; path: string }>;
|
|
323
324
|
|
|
324
325
|
// #64 作用域:只有组任务(正文 frontmatter 带 board)才挂组上下文。
|
|
325
326
|
const wantBoard = String(board || '').trim();
|
|
@@ -338,19 +339,22 @@ export async function groupContextFor(cwd: unknown, { board = '' }: { board?: st
|
|
|
338
339
|
refId: (gMain && gMain.refId) || '',
|
|
339
340
|
desc: '',
|
|
340
341
|
};
|
|
341
|
-
const docLinks: BoundDoc[] = (Array.isArray(b.docLinks) ? b.docLinks : []).map((l: any) =>
|
|
342
|
-
refId
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
342
|
+
const docLinks: BoundDoc[] = (Array.isArray(b.docLinks) ? b.docLinks : []).map((l: any) => {
|
|
343
|
+
const refId = String(l.ref || '');
|
|
344
|
+
const d = refDocById(getDb(), refId);
|
|
345
|
+
return {
|
|
346
|
+
refId,
|
|
347
|
+
desc: String((d && d.desc) || ''),
|
|
348
|
+
title: d && d.hasBody ? docTitleFromMd(String(d.body ?? '')) : '',
|
|
349
|
+
hasBody: !!(d && (d.hasBody || d.origin === 'external')),
|
|
350
|
+
origin: '',
|
|
351
|
+
type: 'group' as const,
|
|
352
|
+
repoKey: gkey,
|
|
353
|
+
groupKey: null,
|
|
354
|
+
position: 0,
|
|
355
|
+
body: '',
|
|
356
|
+
};
|
|
357
|
+
});
|
|
354
358
|
// 本项目在组里的位置
|
|
355
359
|
const noteDocs = await readRefDocs((b.repoDocs || {})[rk], { warnings, label: `组内描述·${b.name}` });
|
|
356
360
|
const noteOwn = noteDocs[0] || null;
|
|
@@ -364,7 +368,7 @@ export async function groupContextFor(cwd: unknown, { board = '' }: { board?: st
|
|
|
364
368
|
const peer = peerDocs[0];
|
|
365
369
|
peers.push({
|
|
366
370
|
name: mname,
|
|
367
|
-
note: (peer && peer.body) ||
|
|
371
|
+
note: (peer && peer.body) || '',
|
|
368
372
|
path: (mr && mr.path) || '',
|
|
369
373
|
});
|
|
370
374
|
}
|
|
@@ -374,10 +378,10 @@ export async function groupContextFor(cwd: unknown, { board = '' }: { board?: st
|
|
|
374
378
|
desc: b.desc || '',
|
|
375
379
|
intro,
|
|
376
380
|
introSet: { main: null, extras: [], count: 0 },
|
|
377
|
-
note: (
|
|
381
|
+
note: (noteOwn && noteOwn.body) || '',
|
|
378
382
|
peers,
|
|
379
383
|
docLinks,
|
|
380
|
-
refRepos: (Array.isArray(b.refs) ? b.refs : []).map((l: any) => refRepoItemOf(l.id
|
|
384
|
+
refRepos: (Array.isArray(b.refs) ? b.refs : []).map((l: any) => refRepoItemOf(l.id)).filter(Boolean) as Array<{ key: string; name: string; path: string }>,
|
|
381
385
|
});
|
|
382
386
|
}
|
|
383
387
|
return {
|
|
@@ -405,7 +409,7 @@ export interface GroupContextGroup {
|
|
|
405
409
|
note: string;
|
|
406
410
|
peers: Array<{ name: string; path: string; note: string }>;
|
|
407
411
|
docLinks: BoundDoc[];
|
|
408
|
-
refRepos: Array<{ key: string; name: string; path: string
|
|
412
|
+
refRepos: Array<{ key: string; name: string; path: string }>;
|
|
409
413
|
}
|
|
410
414
|
|
|
411
415
|
/** groupContextFor 的出参。 */
|
|
@@ -416,7 +420,7 @@ export interface GroupContextResult {
|
|
|
416
420
|
intro: ContextIntro;
|
|
417
421
|
introSet: IntroSet;
|
|
418
422
|
docLinks: BoundDoc[];
|
|
419
|
-
refRepos: Array<{ key: string; name: string; path: string
|
|
423
|
+
refRepos: Array<{ key: string; name: string; path: string }>;
|
|
420
424
|
};
|
|
421
425
|
groups: GroupContextGroup[];
|
|
422
426
|
}
|
|
@@ -432,6 +436,5 @@ interface BoundDoc {
|
|
|
432
436
|
repoKey: string;
|
|
433
437
|
groupKey: string | null;
|
|
434
438
|
position: number;
|
|
435
|
-
note: string;
|
|
436
439
|
body: string;
|
|
437
440
|
}
|
|
@@ -21,7 +21,6 @@ interface DesiredBinding {
|
|
|
21
21
|
type: 'repo' | 'group' | 'group_repo';
|
|
22
22
|
refId: string;
|
|
23
23
|
position: number;
|
|
24
|
-
note: string;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
export interface SyncRefIndexInput {
|
|
@@ -43,8 +42,7 @@ export function desiredBindings(s: any): DesiredBinding[] {
|
|
|
43
42
|
groupKey: string | null,
|
|
44
43
|
type: DesiredBinding['type'],
|
|
45
44
|
raw: any,
|
|
46
|
-
position: number
|
|
47
|
-
note = ''
|
|
45
|
+
position: number
|
|
48
46
|
): void => {
|
|
49
47
|
const refId = String((raw && raw.ref) || '').trim();
|
|
50
48
|
if (!refId) return;
|
|
@@ -54,7 +52,6 @@ export function desiredBindings(s: any): DesiredBinding[] {
|
|
|
54
52
|
type,
|
|
55
53
|
refId,
|
|
56
54
|
position: Number(position) || 0,
|
|
57
|
-
note: String((raw && raw.note) ?? note ?? ''),
|
|
58
55
|
});
|
|
59
56
|
};
|
|
60
57
|
|
|
@@ -111,7 +108,6 @@ export async function syncRefIndex({ store: s }: SyncRefIndexInput = {}): Promis
|
|
|
111
108
|
refId: b.refId,
|
|
112
109
|
type: b.type,
|
|
113
110
|
position: b.position,
|
|
114
|
-
note: b.note,
|
|
115
111
|
});
|
|
116
112
|
markRefBound(conn, b.refId);
|
|
117
113
|
n += 1;
|
package/src/modules/docs/refs.ts
CHANGED
|
@@ -213,7 +213,6 @@ export interface SetDocLinkInput {
|
|
|
213
213
|
board?: string;
|
|
214
214
|
ref?: string;
|
|
215
215
|
path?: string;
|
|
216
|
-
note?: string;
|
|
217
216
|
remove?: number;
|
|
218
217
|
before?: number;
|
|
219
218
|
}
|
|
@@ -221,13 +220,12 @@ export interface SetDocLinkInput {
|
|
|
221
220
|
/**
|
|
222
221
|
* 维护组的 docLinks。
|
|
223
222
|
* --ref <refId> 或 --path <绝对路径>(外部只读)
|
|
224
|
-
* note 条目注解
|
|
225
223
|
* remove --remove <序号>(1 起)
|
|
226
224
|
* before --before <序号>(插到该条之前;缺省追加)
|
|
227
225
|
*
|
|
228
|
-
* 同 ref 重复添加 =
|
|
226
|
+
* 同 ref 重复添加 = 把该条移到新位置。
|
|
229
227
|
*/
|
|
230
|
-
export async function setDocLink({ board, ref, path,
|
|
228
|
+
export async function setDocLink({ board, ref, path, remove, before }: SetDocLinkInput = {}): Promise<any> {
|
|
231
229
|
if (!board) throw badInput('缺少看板(id / key / 名称)');
|
|
232
230
|
const { mutateStore, boardKeyOf } = await reposBridge();
|
|
233
231
|
const docRef = remove === undefined ? await docRefOf({ ref, path }) : null;
|
|
@@ -249,8 +247,8 @@ export async function setDocLink({ board, ref, path, note, remove, before }: Set
|
|
|
249
247
|
return { boardName: b.name, removed: describeLink(gone), count: b.docLinks.length };
|
|
250
248
|
}
|
|
251
249
|
|
|
252
|
-
// 条目 = DocRef
|
|
253
|
-
const entry = withLinkMeta(docRef
|
|
250
|
+
// 条目 = DocRef(去 note 后只剩 ref 本体)
|
|
251
|
+
const entry = withLinkMeta(docRef!);
|
|
254
252
|
const at = b.docLinks.findIndex((x: any) => (x && x.ref) === entry.ref);
|
|
255
253
|
if (at >= 0) b.docLinks.splice(at, 1);
|
|
256
254
|
const want = before !== undefined ? idxOf(before) : -1;
|
|
@@ -291,20 +289,19 @@ export async function listRepoDocs(locator: string): Promise<any> {
|
|
|
291
289
|
};
|
|
292
290
|
}
|
|
293
291
|
|
|
294
|
-
/** addRepoDoc 的入参(refId
|
|
292
|
+
/** addRepoDoc 的入参(refId 或外部路径)。 */
|
|
295
293
|
export interface AddRepoDocInput {
|
|
296
294
|
ref?: string;
|
|
297
295
|
path?: string;
|
|
298
|
-
note?: string;
|
|
299
296
|
}
|
|
300
297
|
|
|
301
|
-
/** 往项目的介绍文档集里加一篇(同 ref 重复添加 =
|
|
298
|
+
/** 往项目的介绍文档集里加一篇(同 ref 重复添加 = 移到末尾)。 */
|
|
302
299
|
export async function addRepoDoc(locator: string, raw: unknown): Promise<any> {
|
|
303
300
|
const { getRepo, deriveKey, mutateStore } = await reposBridge();
|
|
304
301
|
const repo = await getRepo(locator);
|
|
305
302
|
const input = (raw && typeof raw === 'object' ? raw : {}) as AddRepoDocInput;
|
|
306
303
|
const docRef = await docRefOf({ ref: input.ref, path: input.path });
|
|
307
|
-
const entry = withLinkMeta(docRef
|
|
304
|
+
const entry = withLinkMeta(docRef);
|
|
308
305
|
const res = await mutateStore((s: any) => {
|
|
309
306
|
const r = s.repos.find((x: any) => deriveKey(x) === deriveKey(repo));
|
|
310
307
|
if (!r) throw notFound('repo 不存在: ' + locator);
|
|
@@ -81,7 +81,6 @@ export interface RefBindingView {
|
|
|
81
81
|
repoKey: string;
|
|
82
82
|
groupKey: string | null;
|
|
83
83
|
position: number;
|
|
84
|
-
note: string;
|
|
85
84
|
main: boolean;
|
|
86
85
|
}
|
|
87
86
|
|
|
@@ -197,7 +196,7 @@ function bindingsOfRef(refId: string): RefBindingView[] {
|
|
|
197
196
|
if (!clean(refId)) return [];
|
|
198
197
|
return getDb()
|
|
199
198
|
.all(
|
|
200
|
-
`SELECT type, repo_key AS repoKey, group_key AS groupKey, position
|
|
199
|
+
`SELECT type, repo_key AS repoKey, group_key AS groupKey, position
|
|
201
200
|
FROM ref_bindings WHERE ref_id = :id ORDER BY type, position`,
|
|
202
201
|
{ id: refId }
|
|
203
202
|
)
|
|
@@ -206,7 +205,6 @@ function bindingsOfRef(refId: string): RefBindingView[] {
|
|
|
206
205
|
repoKey: String(r.repoKey),
|
|
207
206
|
groupKey: r.groupKey == null ? null : String(r.groupKey),
|
|
208
207
|
position: Number(r.position) || 0,
|
|
209
|
-
note: String(r.note || ''),
|
|
210
208
|
main: (Number(r.position) || 0) === 0,
|
|
211
209
|
}));
|
|
212
210
|
}
|
|
@@ -1,34 +1,26 @@
|
|
|
1
1
|
// localtask.config —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
2
|
//
|
|
3
3
|
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
|
+
//
|
|
5
|
+
// #152 起提示词模板不可再从这里写:模板正文的唯一真相是插件类
|
|
6
|
+
// (modules/promptplug/plugins/*.ts 的 `templates`),DB 不再存模板,
|
|
7
|
+
// 因此 ack / delivery-template / attach-template / block-templates 四组入参全部移除。
|
|
4
8
|
import { action } from '../../../runtime/action-decorator.js';
|
|
5
9
|
import { z } from 'zod';
|
|
6
10
|
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
11
|
import * as serviceNs from '../service.js';
|
|
8
|
-
import {
|
|
9
|
-
import { badInput as _badInput } from '../../../core/errors.js';
|
|
12
|
+
import { PLUGIN_IDS as _PLUGIN_IDS } from '../../promptplug/index.js';
|
|
10
13
|
const service: any = serviceNs;
|
|
11
|
-
const
|
|
12
|
-
const resolveBlockTemplates: any = _resolveBlockTemplates;
|
|
13
|
-
const badInput: any = _badInput;
|
|
14
|
+
const PLUGIN_IDS: any = _PLUGIN_IDS;
|
|
14
15
|
|
|
15
16
|
/** localtask.config 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
16
17
|
const input = z.object({
|
|
17
|
-
timeout: z.number().optional().describe(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
'attach-template': z.string().optional().describe("附件段提示词(写入 attachment 区块的「命令行」模板并启用);置空 = 恢复内置默认模板"),
|
|
24
|
-
attachTemplate: z.string().optional().describe("同 --attach-template(驼峰写法,HTTP body 用)"),
|
|
25
|
-
'reset-attach-template': z.boolean().optional().describe("恢复 attachment 区块内置模板"),
|
|
26
|
-
'append-mode': z.string().optional().describe("系统上下文追加模式(全局):xml(默认,每段包独立标签)/ plain(按空行直接拼正文)。HTTP body 用 appendMode"),
|
|
27
|
-
appendMode: z.string().optional().describe("同 --append-mode(驼峰写法,HTTP body 用)"),
|
|
28
|
-
'block-templates': z.string().optional().describe("每区块模板列表(JSON 对象):{\"context\":{\"active\":\"builtin\",\"list\":[…]},…}。HTTP body 用 blockTemplates(对象)"),
|
|
29
|
-
// #104:HTTP 驼峰别名此前漏声明——设置面板 PATCH 的 blockTemplates/appendMode 被
|
|
30
|
-
// zod 静默剥离,patch 落空报「请至少指定一项」,web 端提示词模板完全无法保存。
|
|
31
|
-
blockTemplates: z.unknown().optional().describe("同 --block-templates(HTTP body 直接传对象,不走 JSON 字符串)"),
|
|
18
|
+
timeout: z.number().optional().describe('超时秒数(1-600)'),
|
|
19
|
+
'append-mode': z
|
|
20
|
+
.string()
|
|
21
|
+
.optional()
|
|
22
|
+
.describe('系统上下文追加模式(全局):xml(默认,每段包独立标签)/ plain(按空行直接拼正文)。HTTP body 用 appendMode'),
|
|
23
|
+
appendMode: z.string().optional().describe('同 --append-mode(驼峰写法,HTTP body 用)'),
|
|
32
24
|
});
|
|
33
25
|
|
|
34
26
|
export class LocaltaskConfigAction extends ActionBase<typeof input> {
|
|
@@ -36,49 +28,18 @@ export class LocaltaskConfigAction extends ActionBase<typeof input> {
|
|
|
36
28
|
id: 'localtask.config',
|
|
37
29
|
cli: ['localtask', 'config'],
|
|
38
30
|
http: ['PATCH', '/api/localtasks/setting'],
|
|
39
|
-
summary: '配置等待超时(秒)/
|
|
31
|
+
summary: '配置等待超时(秒)/ 系统上下文追加模式(提示词模板正文固定在插件类里,不再可配)',
|
|
40
32
|
input,
|
|
41
33
|
render: (s: any) => {
|
|
42
|
-
const ack: any = s.ackPromptList && s.ackPromptList.length ? `ack 提示词 ${s.ackPromptList.length} 条` : 'ack 提示词已清空';
|
|
43
34
|
const mode: any = s.appendMode === 'plain' ? '正文直追加' : 'XML 区块';
|
|
44
|
-
|
|
45
|
-
const blocks: any = PROMPT_BLOCK_IDS.map((id: any) => `${id}=${active[id].builtin ? '内置' : `「${active[id].name}」`}`).join(',');
|
|
46
|
-
return `已配置等待超时 ${s.timeoutSec} 秒(推荐 ${s.recommendedSec},最大 ${s.maxSec})· ${ack} · 追加模式:${mode} · 区块模板:${blocks}`;
|
|
35
|
+
return `已配置等待超时 ${s.timeoutSec} 秒(推荐 ${s.recommendedSec},最大 ${s.maxSec})· 追加模式:${mode} · 提示词模板:${PLUGIN_IDS.length} 段全部内置(不可在此修改)`;
|
|
47
36
|
},
|
|
48
37
|
})
|
|
49
38
|
override async run(ctx: ActionInput<this['_input']>) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (ctx.ack !== undefined) throw badInput('--ack-list 不能与 --ack 同用');
|
|
56
|
-
patch.ackPrompt = ackList;
|
|
57
|
-
}
|
|
58
|
-
// 交付上下文模板(任务 #62):置空 = 恢复内置默认模板
|
|
59
|
-
if (ctx['delivery-template'] !== undefined) patch.deliveryTemplate = ctx['delivery-template'];
|
|
60
|
-
if (ctx['reset-delivery-template']) patch.deliveryTemplate = '';
|
|
61
|
-
// 附件段提示词(任务 #82):置空 = 恢复内置默认
|
|
62
|
-
const attachTpl: any = ctx.attachTemplate ?? ctx['attach-template'];
|
|
63
|
-
if (attachTpl !== undefined) patch.attachTemplate = attachTpl;
|
|
64
|
-
if (ctx['reset-attach-template']) patch.attachTemplate = '';
|
|
65
|
-
// 系统上下文追加模式(全局)——HTTP body 用驼峰别名 appendMode(#104)
|
|
66
|
-
const appendMode: any = ctx.appendMode ?? ctx['append-mode'];
|
|
67
|
-
if (appendMode !== undefined) patch.appendMode = appendMode;
|
|
68
|
-
// 每区块模板列表(设置面板「提示词模板」模块):HTTP body 传对象(blockTemplates)、
|
|
69
|
-
// CLI 传 JSON 字符串(--block-templates);对象是 zod 'raw' 原样透传(#104)
|
|
70
|
-
let blockTemplates: any = ctx.blockTemplates ?? ctx['block-templates'];
|
|
71
|
-
if (typeof blockTemplates === 'string') {
|
|
72
|
-
try {
|
|
73
|
-
blockTemplates = JSON.parse(blockTemplates);
|
|
74
|
-
} catch {
|
|
75
|
-
throw badInput(
|
|
76
|
-
'--block-templates 需为合法 JSON 对象(形如 {"context":{"active":"builtin","list":[…]}})'
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (blockTemplates !== undefined) patch.blockTemplates = blockTemplates;
|
|
81
|
-
return service.updateSettings(patch);
|
|
82
|
-
|
|
39
|
+
const patch: any = { timeoutSec: ctx.timeout };
|
|
40
|
+
// 系统上下文追加模式(全局)——HTTP body 用驼峰别名 appendMode(#104)
|
|
41
|
+
const appendMode: any = ctx.appendMode ?? ctx['append-mode'];
|
|
42
|
+
if (appendMode !== undefined) patch.appendMode = appendMode;
|
|
43
|
+
return service.updateSettings(patch);
|
|
83
44
|
}
|
|
84
45
|
}
|
|
@@ -11,6 +11,7 @@ const service: any = serviceNs;
|
|
|
11
11
|
const input = z.object({
|
|
12
12
|
'all-finished': z.boolean().optional().describe("连同已全部领取、无待领的主题一起清"),
|
|
13
13
|
'dry-run': z.boolean().optional().describe("只报告将清理哪些,不实际删除"),
|
|
14
|
+
'missing-dir': z.boolean().optional().describe("连同「工作目录已不存在且没有待领任务」的主题一起清(删掉的临时目录 / 测试残留;外接盘未挂载也会命中,默认关闭)"),
|
|
14
15
|
});
|
|
15
16
|
|
|
16
17
|
export class LocaltaskPruneAction extends ActionBase<typeof input> {
|
|
@@ -18,7 +19,7 @@ export class LocaltaskPruneAction extends ActionBase<typeof input> {
|
|
|
18
19
|
id: 'localtask.prune',
|
|
19
20
|
cli: ['localtask', 'prune'],
|
|
20
21
|
http: ['POST', '/api/localtasks/prune'],
|
|
21
|
-
summary: '
|
|
22
|
+
summary: '清理旧脏数据(旧模型无目录主题、空主题;--missing-dir 连目录已不存在的主题一起清;等待中一律保留)',
|
|
22
23
|
input,
|
|
23
24
|
render: (d: any) => {
|
|
24
25
|
const head: any = d.dryRun ? '(预演)将清理' : '已清理';
|
|
@@ -28,7 +29,11 @@ export class LocaltaskPruneAction extends ActionBase<typeof input> {
|
|
|
28
29
|
})
|
|
29
30
|
override async run(ctx: ActionInput<this['_input']>) {
|
|
30
31
|
|
|
31
|
-
return service.pruneTopics({
|
|
32
|
+
return service.pruneTopics({
|
|
33
|
+
allFinished: ctx['all-finished'],
|
|
34
|
+
dryRun: ctx['dry-run'],
|
|
35
|
+
missingDir: ctx['missing-dir'],
|
|
36
|
+
});
|
|
32
37
|
|
|
33
38
|
}
|
|
34
39
|
}
|
|
@@ -16,7 +16,6 @@ import { openStore, getDb, closeDb, isStoreOpen, tx } from '../../../core/db/ind
|
|
|
16
16
|
import { checkNodeVersion } from '../../../core/db/version.js';
|
|
17
17
|
import type { DbApi } from '../../../core/db/driver.js';
|
|
18
18
|
import type { TxOptions } from '../../../core/db/tx.js';
|
|
19
|
-
import { ensurePromptTemplates } from '../../promptplug/ensure.js';
|
|
20
19
|
|
|
21
20
|
/** 当前连接是按哪个库路径打开的(env 变了要关旧开新;null = 尚未打开)。 */
|
|
22
21
|
let openedFor: string | null | undefined = null;
|
|
@@ -40,9 +39,6 @@ export function openLocaltaskStore(): DbApi {
|
|
|
40
39
|
if (isStoreOpen()) closeDb();
|
|
41
40
|
openStore({ path: target.path, appDir: target.appDir, importLegacyData: true });
|
|
42
41
|
openedFor = target.path;
|
|
43
|
-
// 出厂提示词模板:首启落库 / 版本落后时只刷 builtin(幂等;已最新 → 零写)。
|
|
44
|
-
// 放这里而非 runtime 启动行:db() 是全仓唯一的库打开入口,任何命令先经它。
|
|
45
|
-
ensurePromptTemplates(getDb());
|
|
46
42
|
return getDb();
|
|
47
43
|
}
|
|
48
44
|
|