nx-kv 0.60.0 → 0.62.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 +55 -0
- package/bin/kv.mjs +10 -0
- package/package.json +1 -1
- package/src/modules/localtask/actions/localtask-config.ts +3 -3
- package/src/modules/localtask/repo/open.ts +4 -0
- package/src/modules/localtask/repo/settings.ts +72 -202
- package/src/modules/localtask/task-templates.ts +10 -12
- package/src/modules/promptplug/Template/blockTemplates.json +90 -0
- package/src/modules/promptplug/actions/_manifest.generated.ts +20 -0
- package/src/modules/promptplug/actions/prompt-order.ts +38 -0
- package/src/modules/promptplug/actions/prompt-registry.ts +51 -0
- package/src/modules/promptplug/base.ts +70 -0
- package/src/modules/promptplug/compose.ts +86 -0
- package/src/modules/promptplug/ensure.ts +57 -0
- package/src/modules/promptplug/factory.ts +105 -0
- package/src/modules/promptplug/index.ts +39 -0
- package/src/modules/promptplug/keys.ts +9 -0
- package/src/modules/promptplug/plugins/attachment.ts +36 -0
- package/src/modules/promptplug/plugins/context.ts +167 -0
- package/src/modules/promptplug/plugins/ext.ts +32 -0
- package/src/modules/promptplug/plugins/getloop.ts +29 -0
- package/src/modules/promptplug/plugins/readonly-blocks.ts +75 -0
- package/src/modules/promptplug/schema-bridge.ts +88 -0
- package/src/modules/promptplug/template-bundle.ts +59 -0
- package/src/modules/tasktool/attach-template.ts +31 -1
- package/src/modules/tasktool/plugins/waitgoal-config.ts +11 -3
- package/src/modules/tasktool/preview.ts +7 -8
- package/src/modules/tasktool/wait.ts +78 -54
- package/src/runtime/registry.ts +2 -0
- package/src/shared/prompt-blocks.ts +93 -338
- package/src/shared/prompt-plugin.ts +182 -0
- package/src/web/frontend/api/cli-tree.json +39 -0
- package/src/web/frontend/api/client.generated.ts +20 -0
- package/src/web/frontend/components/md/block-rail.tsx +141 -0
- package/src/web/frontend/components/md/live-block.tsx +14 -2
- package/src/web/frontend/components/md/md-panes.tsx +36 -1
- package/src/web/frontend/components/md/use-block-drag.ts +68 -0
- package/src/web/frontend/components/md/use-live-preview.ts +46 -1
- package/src/web/frontend/modules/md/md-edit-ops.ts +32 -0
- package/src/web/frontend/modules/md/md-render.ts +61 -1
- package/src/web/frontend/modules/md/styles/docs.css +11 -0
- package/src/web/frontend/modules/md/styles/editor.css +35 -0
- package/src/web/frontend/modules/md/use-templates.ts +1 -1
- package/src/web/frontend/modules/prompts/render-template-body.ts +14 -0
- package/src/web/frontend/page/dir/index.tsx +1 -1
- package/src/web/frontend/page/group/index.tsx +1 -1
- package/src/web/frontend/page/repos/block-tabs.tsx +68 -0
- package/src/web/frontend/page/repos/branch-picker.tsx +138 -0
- package/src/web/frontend/page/repos/doc-block.tsx +244 -0
- package/src/web/frontend/page/repos/icons.tsx +198 -0
- package/src/web/frontend/page/repos/index.tsx +250 -258
- package/src/web/frontend/page/repos/ref-block.tsx +166 -0
- package/src/web/frontend/page/repos/repo-table.tsx +60 -52
- package/src/web/frontend/page/repos/use-repos-derive.ts +234 -0
- package/src/web/frontend/page/settings/api.ts +29 -0
- package/src/web/frontend/page/settings/prompt-editor.tsx +279 -0
- package/src/web/frontend/page/settings/prompt-rail.tsx +170 -0
- package/src/web/frontend/page/settings/prompt-templates-section.tsx +218 -323
- package/src/web/frontend/page/settings/style.css +166 -42
- package/src/web/frontend/page/templates/index.tsx +1 -1
- package/src/web/frontend/style.css +1 -0
- package/src/web/frontend/styles/repos-branch.css +443 -0
- package/src/web/frontend/styles/repos.css +0 -1
- package/src/web/public/assets/bar-CGEZ954x.js +1 -0
- package/src/web/public/assets/{composer-launch-h-8g0f8A.js → composer-launch-Dhrj1gNT.js} +1 -1
- package/src/web/public/assets/{composer-panel-BhT_eFic.js → composer-panel-Dou1Xwih.js} +1 -1
- package/src/web/public/assets/{dir-1w7D_lg7.js → dir-Bfn4tG10.js} +1 -1
- package/src/web/public/assets/doc-Nk0fieHx.js +6 -0
- package/src/web/public/assets/{group-BsvhgO5r.js → group-DT_vHiWd.js} +1 -1
- package/src/web/public/assets/index-IzwqMhg-.css +1 -0
- package/src/web/public/assets/{index-CBVkXanT.js → index-RX7knClE.js} +2 -2
- package/src/web/public/assets/md-history-BRw2I-G_.js +39 -0
- package/src/web/public/assets/refs-FIEXTEYm.js +2 -0
- package/src/web/public/assets/{repo-form-modal-BafSPVlv.js → repo-form-modal-CZRdlCn6.js} +1 -1
- package/src/web/public/assets/repos-BCdFev-O.js +16 -0
- package/src/web/public/assets/settings-AwzLRYUu.css +1 -0
- package/src/web/public/assets/settings-Z0Y4UhKP.js +1 -0
- package/src/web/public/assets/{task-Ci94al50.js → task-Bk7h0vlJ.js} +5 -5
- package/src/web/public/assets/{task-utils-WfeuGNak.js → task-utils-dgdA6Pxs.js} +1 -1
- package/src/web/public/assets/{templates-Dc5Pln-Q.js → templates-DxBtkzVI.js} +1 -1
- package/src/web/public/assets/use-rail-drag-H0M8oQ0Z.js +1 -0
- package/src/web/public/index.html +7 -7
- package/src/modules/tasktool/delivery-template.ts +0 -235
- package/src/modules/tasktool/system-blocks.ts +0 -112
- package/src/web/frontend/modules/prompts/placeholders.ts +0 -106
- package/src/web/frontend/page/repos/board-refs.tsx +0 -104
- package/src/web/frontend/page/repos/doc-search-modal.tsx +0 -273
- package/src/web/frontend/page/repos/filters-bar.tsx +0 -54
- package/src/web/frontend/page/settings/prompt-template-params.ts +0 -296
- package/src/web/public/assets/bar-CmzzOYQi.js +0 -1
- package/src/web/public/assets/doc-Dn4-viog.js +0 -6
- package/src/web/public/assets/index-BPxgsnXM.css +0 -1
- package/src/web/public/assets/md-history-BF85zuFo.js +0 -39
- package/src/web/public/assets/refs-BHzLZnJn.js +0 -2
- package/src/web/public/assets/repos-CmlsSN0h.js +0 -11
- package/src/web/public/assets/settings-C_Dkc9gQ.js +0 -8
- package/src/web/public/assets/settings-ZgyeQVU1.css +0 -1
- package/src/web/public/assets/use-rail-drag-B1RQzqcB.js +0 -1
- /package/src/web/public/assets/{use-rail-drag-1h2zairf.css → md-history-1h2zairf.css} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,61 @@
|
|
|
2
2
|
|
|
3
3
|
本文件记录对外可见的变更。格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/)。
|
|
4
4
|
|
|
5
|
+
## [0.62.0] - 2026-11-16 仓库管理页重构:组 = 分支,三块横向切换(#143)
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- **仓库管理页按「分支 × 区块」重排**(用户口径:「完全把 group 作为分支概念,原生本地
|
|
10
|
+
开发 repo 作为主分支」「把参考仓库和文档全部融合进,主分支就是全部」):
|
|
11
|
+
- **分支下拉**(照 GitHub / GitLab 的 branch 选择器):标题右侧「⑂ main ▾」,点开是
|
|
12
|
+
带**筛选框**的分支清单——`main`(全部)→ 各组(= 分支)→ `default`(未归组的落点),
|
|
13
|
+
每行报这一支的仓库数,当前分支打勾;
|
|
14
|
+
- **`default` 是前端虚拟分支**:不写库、不建组,只表达「未分组」这个视图;
|
|
15
|
+
- **三个独立区块横向切换**:`仓库 / 参考仓库 / 文档`,计数长在按钮上,右侧统一搜索框
|
|
16
|
+
(切区块保留关键词);
|
|
17
|
+
- **组分支没有文档区块**:分支条上直接给「文档 N →」,点了打开右侧栏「<组> · 文档列表」
|
|
18
|
+
并提示「在右侧看」——组的文档本来就收敛在那里;
|
|
19
|
+
- **main 的文档区块装「全部文档」**:含没有主篇、也没绑宿主的 ref(右侧栏按宿主收敛,
|
|
20
|
+
这类文档在那边看不见),归属列用徽章列出「仓 / 参考 / 组 / 组内」并支持点击跳宿主,
|
|
21
|
+
行内可删除;
|
|
22
|
+
- **仓库表删掉「分组」列**:组已经是「分支」这个全局维度,再摆一列只是重复上下文;
|
|
23
|
+
组分支里改为在仓库名下方显示**组内描述**,并多一枚「移出本组」(只摘这一支的归属);
|
|
24
|
+
- **参考仓库从弹窗提升为与仓库同构的区块**:同样的表头、同样的搜索,`main` 与组两个
|
|
25
|
+
视角口径一致(组视角第三列换成组内描述);克隆 / 存储根 / 批量检查仍在「参考仓库
|
|
26
|
+
管理」面板里;
|
|
27
|
+
- 新增一套**内联 SVG 图标**(分支 / 仓库 / 参考仓库 / 文档 / 搜索 / 同步 / 打开 / 摘除…),
|
|
28
|
+
替掉原来靠文字和 emoji 表达的地方。
|
|
29
|
+
|
|
30
|
+
### Removed
|
|
31
|
+
|
|
32
|
+
- `page/repos/filters-bar.tsx`(旧筛选条)、`page/repos/doc-search-modal.tsx`(旧文档检索
|
|
33
|
+
弹窗,其「删除文档」能力并入文档区块的行内动作)、`page/repos/board-refs.tsx`(组参考
|
|
34
|
+
区块,内容被参考仓库区块 + 分支信息条覆盖):三者的能力全部并入新骨架,文件删除。
|
|
35
|
+
|
|
36
|
+
### Added
|
|
37
|
+
|
|
38
|
+
- `tests/unit/repos-branch-rows.test.mjs`(8 条):分支清单顺序(main → 各组 → default)、
|
|
39
|
+
计数只算 present 成员、`main` = 全部 / 组 = 按 key 认成员 / `default` = 未归组、
|
|
40
|
+
关键词同时命中仓库字段与它自己的文档标题、参考仓库三视角(main / 组 / default)与
|
|
41
|
+
名称·远程地址检索。
|
|
42
|
+
- 分支计算提成纯函数(`use-repos-derive.ts` 的 `branchOptions` / `branchRepoRows` /
|
|
43
|
+
`branchRefRows`),页面只做装配——页面本身从 573 行降到 564 行,逻辑可单测。
|
|
44
|
+
|
|
45
|
+
## [0.61.0] - 2026-11-16 正文里的 HTTP 链接自动识别为可点外链(#142)
|
|
46
|
+
|
|
47
|
+
### Added
|
|
48
|
+
|
|
49
|
+
- **文档 / 任务正文里的 `http(s)` 地址不再是「裸文本」**——用户在面板里看到的每一条
|
|
50
|
+
网址,现在都是可点链接,点开在新标签打开(`target="_blank"` + `rel="noopener noreferrer"`):
|
|
51
|
+
- **裸 URL 自动识别**:`见 https://example.com/a?b=1 这篇` 里的地址自己变成链接;
|
|
52
|
+
句末的 `. , ; : ! ?` 与中文标点不算地址的一部分(`https://x.com/a。` 的句号留在链接外);
|
|
53
|
+
- **markdown 语法**:`[文本](https://…)` 用方括号里的文本当显示名(以前这一整串原样显示);
|
|
54
|
+
- **覆盖面**:标题 / 列表 / 引用 / callout / 表格之外的段落全走同一条 `inline()`,
|
|
55
|
+
文档页、任务页正文、完成总结、模板预览都是同一份渲染器;
|
|
56
|
+
- **不误伤**:行内 `code` 与 fenced code 里的 URL 保持纯文本(命令示例不能被点走),
|
|
57
|
+
已经在 `<a>` 里的地址不重复包一层,相对路径 / `ftp:` / `nxkv://` 内链口径不变;
|
|
58
|
+
- 地址里的引号与尖括号仍是转义后的(`"` 等),逃不出属性。
|
|
59
|
+
|
|
5
60
|
## [0.60.0] - 2026-11-16 去掉「分类标签」这个无效概念(tag 整个退役)
|
|
6
61
|
|
|
7
62
|
### Removed
|
package/bin/kv.mjs
CHANGED
|
@@ -18,6 +18,16 @@
|
|
|
18
18
|
// 所以先查版本、给出人话错误,再**动态** import 业务入口(动态 import 保证
|
|
19
19
|
// 检查发生在求值之前)。version.ts 自身不碰 node:sqlite,import 它是安全的。
|
|
20
20
|
//
|
|
21
|
+
// 已知取舍:node:sqlite 是实验特性,import 链上(registry → modules → repo →
|
|
22
|
+
// core/db)一加载就往 stderr 打 ExperimentalWarning。仓库已锁定 Node >= 22.13
|
|
23
|
+
// 并接受该状态(db-bootstrap.test 钉住「CLI stderr 必须干净」),所以在这里
|
|
24
|
+
// 过滤这一条警告——只这一条,其它实验警告照常透出。
|
|
25
|
+
const origEmitWarning = process.emitWarning.bind(process);
|
|
26
|
+
process.emitWarning = (warning, ...args) => {
|
|
27
|
+
if (String(warning).includes('SQLite is an experimental feature')) return;
|
|
28
|
+
return origEmitWarning(warning, ...args);
|
|
29
|
+
};
|
|
30
|
+
//
|
|
21
31
|
// 源码毕业为 TS 后,源码里的 `xxx.js` 路径要靠 tsx loader 解析到同名 `.ts`——
|
|
22
32
|
// 注册 loader 本身不导入任何业务代码,所以「先注册、再查版本」仍满足上面这条铁律。
|
|
23
33
|
import { register } from 'tsx/esm/api';
|
package/package.json
CHANGED
|
@@ -5,10 +5,10 @@ import { action } from '../../../runtime/action-decorator.js';
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
7
|
import * as serviceNs from '../service.js';
|
|
8
|
-
import {
|
|
8
|
+
import { resolveBlockTemplates as _resolveBlockTemplates, PROMPT_BLOCK_IDS as _PROMPT_BLOCK_IDS } from '../../../shared/prompt-blocks.js';
|
|
9
9
|
import { badInput as _badInput } from '../../../core/errors.js';
|
|
10
10
|
const service: any = serviceNs;
|
|
11
|
-
const
|
|
11
|
+
const PROMPT_BLOCK_IDS: any = _PROMPT_BLOCK_IDS;
|
|
12
12
|
const resolveBlockTemplates: any = _resolveBlockTemplates;
|
|
13
13
|
const badInput: any = _badInput;
|
|
14
14
|
|
|
@@ -42,7 +42,7 @@ export class LocaltaskConfigAction extends ActionBase<typeof input> {
|
|
|
42
42
|
const ack: any = s.ackPromptList && s.ackPromptList.length ? `ack 提示词 ${s.ackPromptList.length} 条` : 'ack 提示词已清空';
|
|
43
43
|
const mode: any = s.appendMode === 'plain' ? '正文直追加' : 'XML 区块';
|
|
44
44
|
const active: any = resolveBlockTemplates(s.blockTemplates);
|
|
45
|
-
const blocks: any =
|
|
45
|
+
const blocks: any = PROMPT_BLOCK_IDS.map((id: any) => `${id}=${active[id].builtin ? '内置' : `「${active[id].name}」`}`).join(',');
|
|
46
46
|
return `已配置等待超时 ${s.timeoutSec} 秒(推荐 ${s.recommendedSec},最大 ${s.maxSec})· ${ack} · 追加模式:${mode} · 区块模板:${blocks}`;
|
|
47
47
|
},
|
|
48
48
|
})
|
|
@@ -16,6 +16,7 @@ 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';
|
|
19
20
|
|
|
20
21
|
/** 当前连接是按哪个库路径打开的(env 变了要关旧开新;null = 尚未打开)。 */
|
|
21
22
|
let openedFor: string | null | undefined = null;
|
|
@@ -39,6 +40,9 @@ export function openLocaltaskStore(): DbApi {
|
|
|
39
40
|
if (isStoreOpen()) closeDb();
|
|
40
41
|
openStore({ path: target.path, appDir: target.appDir, importLegacyData: true });
|
|
41
42
|
openedFor = target.path;
|
|
43
|
+
// 出厂提示词模板:首启落库 / 版本落后时只刷 builtin(幂等;已最新 → 零写)。
|
|
44
|
+
// 放这里而非 runtime 启动行:db() 是全仓唯一的库打开入口,任何命令先经它。
|
|
45
|
+
ensurePromptTemplates(getDb());
|
|
42
46
|
return getDb();
|
|
43
47
|
}
|
|
44
48
|
|
|
@@ -4,16 +4,13 @@
|
|
|
4
4
|
// value 一律 JSON 文本('240' / '["a","b"]' / '"…"'),读写都在这里序列化。
|
|
5
5
|
// 凭据(token/baseUrl/email/userId/groupId)**绝不进这张表** —— 它们留在 config.json。
|
|
6
6
|
//
|
|
7
|
-
// 提示词模型(
|
|
7
|
+
// 提示词模型(v6,唯一基准方案 docs/research/prompt-plugin-single-route.md §4):
|
|
8
8
|
// - `lt.blockTemplates` 是唯一权威来源:`{ [blockId]: { active, list } }`,
|
|
9
|
-
// 每个区块各自一份模板列表、各自指定生效项;内置条目 `builtin`
|
|
9
|
+
// 每个区块各自一份模板列表、各自指定生效项;内置条目 `builtin` 常驻不可改。
|
|
10
|
+
// 首启落库由 promptplug/ensure.ts 完成(open.ts 挂 ensure)——本文件**不做任何
|
|
11
|
+
// 合成与旧键折算**(§4.1 纯校验;旧 lt.* 键、rule 键、数组简写形态已全部下线)。
|
|
10
12
|
// - 全局只有 `lt.appendMode`(xml / plain)对所有区块整体生效。
|
|
11
|
-
// -
|
|
12
|
-
// lt.deliveryTemplate / lt.attachTemplate / lt.taskSuffix / lt.ackPrompt`
|
|
13
|
-
// 只作**一次性迁移来源**:读取时若还没有 `lt.blockTemplates`,把它们折算进
|
|
14
|
-
// 各区块的列表;之后不再读写这些旧键。
|
|
15
|
-
// - 旧语法模板(`{{#repo}}…{{/repo}}` 等)迁移时会被校验拒绝(不进入新列表),
|
|
16
|
-
// 旧模板不保证可用——这是「不再维护新旧两套语法」的明确取舍。
|
|
13
|
+
// - 没有落库行 = 事故,抛错(ensure 恒先于本文件的任何读取执行)。
|
|
17
14
|
import { db, txw } from './open.js';
|
|
18
15
|
import { nowMs } from '../../../core/db/time.js';
|
|
19
16
|
import { badInput } from '../../../core/errors.js';
|
|
@@ -30,40 +27,25 @@ import {
|
|
|
30
27
|
clampAppendMode,
|
|
31
28
|
} from '../task-templates.js';
|
|
32
29
|
import {
|
|
33
|
-
BLOCK_DEFS,
|
|
34
30
|
BUILTIN_TEMPLATE_ID,
|
|
35
|
-
BUILTIN_TEMPLATE_NAME,
|
|
36
|
-
DEFAULT_ACK_PROMPT,
|
|
37
31
|
MAX_BLOCK_TEMPLATE_LEN,
|
|
38
|
-
|
|
32
|
+
PROMPT_BLOCK_IDS,
|
|
39
33
|
normalizeBlockTemplateLists,
|
|
40
34
|
resolveBlockTemplates,
|
|
41
35
|
} from '../../../shared/prompt-blocks.js';
|
|
42
|
-
import type { BlockTemplateList } from '../../../shared/prompt-blocks.js';
|
|
36
|
+
import type { BlockLists, BlockTemplateList } from '../../../shared/prompt-blocks.js';
|
|
43
37
|
import type { DbApi } from '../../../core/db/driver.js';
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
type BlockLists = Record<string, BlockTemplateList>;
|
|
38
|
+
import { undeclaredTemplateVars } from '../../../shared/prompt-plugin.js';
|
|
39
|
+
import { globalTemplateVarScope, blockLabelOf } from '../../promptplug/index.js';
|
|
47
40
|
|
|
48
41
|
const KEYS = {
|
|
49
42
|
timeoutSec: 'lt.timeoutSec',
|
|
50
43
|
appendMode: 'lt.appendMode',
|
|
51
44
|
blockTemplates: 'lt.blockTemplates',
|
|
52
|
-
// 以下旧键只用于读取迁移,不再写回
|
|
53
|
-
taskSuffix: 'lt.taskSuffix',
|
|
54
|
-
ackPrompt: 'lt.ackPrompt',
|
|
55
|
-
deliveryTemplate: 'lt.deliveryTemplate',
|
|
56
|
-
attachTemplate: 'lt.attachTemplate',
|
|
57
|
-
xmlBlocks: 'lt.xmlBlocks',
|
|
58
|
-
promptTemplates: 'lt.promptTemplates',
|
|
59
|
-
activePromptTemplate: 'lt.activePromptTemplate',
|
|
60
45
|
};
|
|
61
46
|
|
|
62
|
-
/**
|
|
63
|
-
const LEGACY_ENTRY_ID = 'legacy';
|
|
47
|
+
/** 命令行便捷写入使用的固定条目 id(不影响用户自己新建的模板)。 */
|
|
64
48
|
const CLI_ENTRY_ID = 'cli';
|
|
65
|
-
/** 旧 rule 并入 ack 后的固定条目 id。 */
|
|
66
|
-
const RULE_LEGACY_ENTRY_ID = 'legacy-rule';
|
|
67
49
|
|
|
68
50
|
function readSetting(conn: DbApi, key: string): any {
|
|
69
51
|
const row = conn.get('SELECT value FROM settings WHERE key = :k', { k: key });
|
|
@@ -83,7 +65,7 @@ function writeSetting(conn: DbApi, key: string, value: unknown): void {
|
|
|
83
65
|
);
|
|
84
66
|
}
|
|
85
67
|
|
|
86
|
-
/**
|
|
68
|
+
/** 多条设置按空行拼成一条模板(CLI 便捷入口用)。 */
|
|
87
69
|
function joinEntries(list?: string[]): string {
|
|
88
70
|
return (list || []).join('\n\n');
|
|
89
71
|
}
|
|
@@ -99,156 +81,17 @@ function clampTemplate(v: unknown): string {
|
|
|
99
81
|
return s.length > MAX_BLOCK_TEMPLATE_LEN ? s.slice(0, MAX_BLOCK_TEMPLATE_LEN) : s;
|
|
100
82
|
}
|
|
101
83
|
|
|
102
|
-
/** 迁移只接受「新语法」模板:旧语法/语法错误的旧模板不进入新列表(旧模板不保证可用)。 */
|
|
103
|
-
function migratableTemplate(v: unknown): string {
|
|
104
|
-
const t = clampTemplate(v);
|
|
105
|
-
if (!t) return '';
|
|
106
|
-
return validateTemplate(t).ok ? t : '';
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* 把旧模板写进某区块的列表(只有内容有效且不同于内置模板时才建条目)。
|
|
111
|
-
* @param {object} lists 归一化后的 lists(就地修改)
|
|
112
|
-
*/
|
|
113
|
-
function applyMigration(lists: BlockLists, blockId: string, template: unknown, name: string = '迁移模板'): void {
|
|
114
|
-
const def = BLOCK_DEFS.find((d) => d.id === blockId);
|
|
115
|
-
const t = migratableTemplate(template);
|
|
116
|
-
if (!def || !t || t === def.defaultTemplate) return;
|
|
117
|
-
const builtin = lists[blockId]!.list.find((x) => x.id === BUILTIN_TEMPLATE_ID)!;
|
|
118
|
-
lists[blockId] = {
|
|
119
|
-
active: LEGACY_ENTRY_ID,
|
|
120
|
-
list: [builtin, { id: LEGACY_ENTRY_ID, name, template: t, builtin: false }],
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* 把旧 rule 区块的模板内容并入 ack:done 指令与收尾要求只保留 ack 一个出口。
|
|
126
|
-
* 合并后的条目设为生效;原 ack 生效模板作为基底一起保留——内容不静默丢。
|
|
127
|
-
*/
|
|
128
|
-
function mergeRuleIntoAck(lists: BlockLists, template: unknown, name: string = '迁移:原 rule(已并入 ack)'): void {
|
|
129
|
-
const def = BLOCK_DEFS.find((d) => d.id === 'ack')!;
|
|
130
|
-
const t = migratableTemplate(template);
|
|
131
|
-
if (!def || !t) return;
|
|
132
|
-
const ack = lists.ack!; // BlockLists 恒含全部 BLOCK_DEFS 区块(normalize 保证)
|
|
133
|
-
const builtin = ack.list.find((x) => x.id === BUILTIN_TEMPLATE_ID) || {
|
|
134
|
-
id: BUILTIN_TEMPLATE_ID,
|
|
135
|
-
name: BUILTIN_TEMPLATE_NAME,
|
|
136
|
-
template: def.defaultTemplate,
|
|
137
|
-
builtin: true,
|
|
138
|
-
};
|
|
139
|
-
const current = ack.list.find((x) => x.id === ack.active) || builtin;
|
|
140
|
-
const base = String(current.template || '').trim() || def.defaultTemplate;
|
|
141
|
-
if (base.includes(t)) return; // 同一条内容已在 ack 里,不重复拼接
|
|
142
|
-
const rest = ack.list.filter((x) => x.id !== BUILTIN_TEMPLATE_ID && x.id !== current.id);
|
|
143
|
-
lists.ack = {
|
|
144
|
-
active: RULE_LEGACY_ENTRY_ID,
|
|
145
|
-
list: [
|
|
146
|
-
builtin,
|
|
147
|
-
{ id: RULE_LEGACY_ENTRY_ID, name, template: `${base}\n\n${t}`, builtin: false },
|
|
148
|
-
...rest,
|
|
149
|
-
],
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/** 已落盘的 blockTemplates 里若还带 rule:读时并入 ack(之后保存自然不再写 rule 键)。 */
|
|
154
|
-
function absorbStoredRule(stored: unknown): BlockLists {
|
|
155
|
-
const lists = normalizeBlockTemplateLists(stored);
|
|
156
|
-
const rule = stored && typeof stored === 'object' && !Array.isArray(stored)
|
|
157
|
-
? (stored as Record<string, any>).rule
|
|
158
|
-
: null;
|
|
159
|
-
if (!rule || typeof rule !== 'object') return lists;
|
|
160
|
-
const texts = (Array.isArray(rule.list) ? rule.list : [])
|
|
161
|
-
.filter((x: any) => x && !x.builtin && x.id !== BUILTIN_TEMPLATE_ID)
|
|
162
|
-
.map((x: any) => migratableTemplate(x.template))
|
|
163
|
-
.filter(Boolean);
|
|
164
|
-
if (!texts.length && typeof rule.template === 'string') {
|
|
165
|
-
const t = migratableTemplate(rule.template);
|
|
166
|
-
if (t) texts.push(t);
|
|
167
|
-
}
|
|
168
|
-
const uniq = [...new Set(texts)];
|
|
169
|
-
if (uniq.length) mergeRuleIntoAck(lists, uniq.join('\n\n'));
|
|
170
|
-
return normalizeBlockTemplateLists(lists);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* 旧库迁移:没有 `lt.blockTemplates` 时,把旧键折算成每区块列表。
|
|
175
|
-
* 优先级:旧「整体模板」的当前启用项 > 旧 `lt.xmlBlocks` > 旧的单项键。
|
|
176
|
-
* 旧 rule 模板(整体模板 / xmlBlocks / lt.taskSuffix)统一并入 ack,不再单独成块。
|
|
177
|
-
*/
|
|
178
|
-
function migrateLegacy(conn: DbApi): { lists: BlockLists; appendMode: string } {
|
|
179
|
-
const lists = defaultBlockTemplateLists();
|
|
180
|
-
let legacyRule = '';
|
|
181
|
-
|
|
182
|
-
// 1) 旧「整体模板集合 + activePromptTemplate」:只迁移当前启用模板(其它整组模板丢弃)
|
|
183
|
-
const templates = readSetting(conn, KEYS.promptTemplates);
|
|
184
|
-
let appendMode = clampAppendMode(readSetting(conn, KEYS.appendMode));
|
|
185
|
-
if (Array.isArray(templates) && templates.length) {
|
|
186
|
-
const wanted = String(readSetting(conn, KEYS.activePromptTemplate) || '').trim();
|
|
187
|
-
const active = templates.find((t: any) => t && t.id === wanted) || templates[0];
|
|
188
|
-
if (active && typeof active === 'object') {
|
|
189
|
-
const blocks = active.blocks && typeof active.blocks === 'object' ? active.blocks : {};
|
|
190
|
-
for (const def of BLOCK_DEFS) {
|
|
191
|
-
const b = blocks[def.id];
|
|
192
|
-
if (b && typeof b === 'object' && typeof b.template === 'string') {
|
|
193
|
-
applyMigration(lists, def.id, b.template);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
const b = blocks.rule;
|
|
197
|
-
if (b && typeof b === 'object' && typeof b.template === 'string') legacyRule = b.template;
|
|
198
|
-
if (active.appendMode === 'plain' || active.appendMode === 'xml') appendMode = active.appendMode;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// 2) 旧 xmlBlocks(v3 的 { [id]: { enabled, template } }):逐块迁移有效模板
|
|
203
|
-
const xmlBlocks = readSetting(conn, KEYS.xmlBlocks);
|
|
204
|
-
if (xmlBlocks && typeof xmlBlocks === 'object' && !Array.isArray(xmlBlocks)) {
|
|
205
|
-
for (const def of BLOCK_DEFS) {
|
|
206
|
-
const b = xmlBlocks[def.id];
|
|
207
|
-
// 已由整体模板迁移过的不再覆盖(优先级更高)
|
|
208
|
-
if (lists[def.id]!.active !== BUILTIN_TEMPLATE_ID) continue;
|
|
209
|
-
if (b && typeof b === 'object' && typeof b.template === 'string') {
|
|
210
|
-
applyMigration(lists, def.id, b.template);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
const b = xmlBlocks.rule;
|
|
214
|
-
if (!legacyRule && b && typeof b === 'object' && typeof b.template === 'string') {
|
|
215
|
-
legacyRule = b.template;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// 3) 旧的单项键(对应区块仍只有内置时生效)
|
|
220
|
-
if (lists.context!.active === BUILTIN_TEMPLATE_ID) {
|
|
221
|
-
applyMigration(lists, 'context', clampDeliveryTemplate(readSetting(conn, KEYS.deliveryTemplate)));
|
|
222
|
-
}
|
|
223
|
-
if (lists.attachment!.active === BUILTIN_TEMPLATE_ID) {
|
|
224
|
-
applyMigration(lists, 'attachment', clampAttachTemplate(readSetting(conn, KEYS.attachTemplate)));
|
|
225
|
-
}
|
|
226
|
-
if (lists.ack!.active === BUILTIN_TEMPLATE_ID) {
|
|
227
|
-
applyMigration(lists, 'ack', joinEntries(clampAckPromptList(readSetting(conn, KEYS.ackPrompt))));
|
|
228
|
-
}
|
|
229
|
-
if (!legacyRule) {
|
|
230
|
-
const raw = readSetting(conn, KEYS.taskSuffix);
|
|
231
|
-
const list: unknown[] = Array.isArray(raw) ? raw : raw == null ? [] : [raw];
|
|
232
|
-
legacyRule = joinEntries(list.map((x) => String(x ?? '').trim()).filter(Boolean) as string[]);
|
|
233
|
-
}
|
|
234
|
-
mergeRuleIntoAck(lists, legacyRule);
|
|
235
|
-
|
|
236
|
-
return { lists: normalizeBlockTemplateLists(lists), appendMode };
|
|
237
|
-
}
|
|
238
|
-
|
|
239
84
|
/**
|
|
240
|
-
* 读「每区块模板列表 +
|
|
241
|
-
*
|
|
85
|
+
* 读「每区块模板列表 + 全局追加模式」(**纯读 + 纯校验**)。
|
|
86
|
+
* `lt.blockTemplates` 恒存在(open.ts 的 ensurePromptTemplates 首启落库);
|
|
87
|
+
* 没有行 / 校验不过都是事故,抛错——不合成、不补齐(方案 §4.1)。
|
|
242
88
|
*/
|
|
243
89
|
function readBlockState(conn: DbApi): { lists: BlockLists; appendMode: string } {
|
|
244
90
|
const stored = readSetting(conn, KEYS.blockTemplates);
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
return migrateLegacy(conn);
|
|
91
|
+
return {
|
|
92
|
+
lists: normalizeBlockTemplateLists(stored),
|
|
93
|
+
appendMode: clampAppendMode(readSetting(conn, KEYS.appendMode)),
|
|
94
|
+
};
|
|
252
95
|
}
|
|
253
96
|
|
|
254
97
|
/** 当前生效模板 → 旧版派生字段(仅用于 CLI/旧面板视图兼容,不是读写模型)。 */
|
|
@@ -262,7 +105,7 @@ function derivedOf(lists: BlockLists): { ackPrompt: string[]; deliveryTemplate:
|
|
|
262
105
|
};
|
|
263
106
|
}
|
|
264
107
|
|
|
265
|
-
/** 读全部 lt.*
|
|
108
|
+
/** 读全部 lt.* 设置(校验不过即抛——落库行被人为写坏是事故)。 */
|
|
266
109
|
export function getLtSettings(): Record<string, any> {
|
|
267
110
|
const conn = db();
|
|
268
111
|
const { lists, appendMode } = readBlockState(conn);
|
|
@@ -275,19 +118,37 @@ export function getLtSettings(): Record<string, any> {
|
|
|
275
118
|
}
|
|
276
119
|
|
|
277
120
|
/**
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
121
|
+
* 保存前的模板校验(方案 §4.2,三道):
|
|
122
|
+
* 1. 语法错误**拒绝保存**并指出模板 / 区块 / 出错位置(渲染期不再回落);
|
|
123
|
+
* 2. 当前生效(active)模板为空 → 拒绝——空模板在运行期是配置错误(S1 起
|
|
124
|
+
* compose 的 assertPluginList 直接抛),不许「保存成功、领取时整次失败」;
|
|
125
|
+
* 3. 变量白名单:全局段集 + 点路径全路径命中 fields 并集(落地裁决见方案 §4.2 补记;
|
|
126
|
+
* `params` 动态键放行,`{{#each}}` 块内放行但 each 目标必须已声明)。
|
|
282
127
|
*/
|
|
283
128
|
function assertBlockTemplatesValid(lists: BlockLists): void {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
129
|
+
const scope = globalTemplateVarScope();
|
|
130
|
+
for (const blockId of PROMPT_BLOCK_IDS) {
|
|
131
|
+
const b = lists[blockId]!;
|
|
132
|
+
const label = blockLabelOf(blockId);
|
|
133
|
+
for (const item of b.list) {
|
|
134
|
+
if (!item.template) continue; // 非 active 的空条目合法(不渲染,仅存档)
|
|
287
135
|
const r = validateTemplate(item.template);
|
|
288
136
|
if (!r.ok) {
|
|
289
137
|
throw badInput(
|
|
290
|
-
`提示词模板「${item.name}」的「${
|
|
138
|
+
`提示词模板「${item.name}」的「${label}」区块语法错误:${r.error}`
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// 生效模板的空 / 变量白名单
|
|
143
|
+
const active = b.list.find((x) => x.id === b.active);
|
|
144
|
+
if (active && !active.template.trim()) {
|
|
145
|
+
throw badInput(`「${label}」区块当前生效的模板「${active.name}」是空的:换回内置或改成有内容的模板后再保存`);
|
|
146
|
+
}
|
|
147
|
+
if (active && active.template) {
|
|
148
|
+
const undeclared = undeclaredTemplateVars(active.template, scope.allowedSegments, scope.fieldKeys);
|
|
149
|
+
if (undeclared.length) {
|
|
150
|
+
throw badInput(
|
|
151
|
+
`「${label}」区块的生效模板「${active.name}」引用了未声明的变量:${undeclared.join('、')}。可用变量见设置页「插入变量」目录`
|
|
291
152
|
);
|
|
292
153
|
}
|
|
293
154
|
}
|
|
@@ -297,15 +158,13 @@ function assertBlockTemplatesValid(lists: BlockLists): void {
|
|
|
297
158
|
/**
|
|
298
159
|
* 命令行便捷入口:把一条模板写入某区块的固定条目(`cli`)并设为生效;
|
|
299
160
|
* 空模板 = 恢复内置(保留用户其它条目,只把 active 指回 builtin)。
|
|
161
|
+
* 内置条目恒在(normalize 校验保证),直接从现值取——不再按代码重建。
|
|
300
162
|
*/
|
|
301
163
|
function setCustomActive(lists: BlockLists, blockId: string, template: unknown, { name = '命令行' }: { name?: string } = {}): void {
|
|
302
|
-
const b = lists[blockId]
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
template: BLOCK_DEFS.find((d) => d.id === blockId)!.defaultTemplate,
|
|
307
|
-
builtin: true,
|
|
308
|
-
};
|
|
164
|
+
const b = lists[blockId]; // normalize 保证全部区块存在
|
|
165
|
+
if (!b) throw badInput(`未知提示词区块:${blockId}`);
|
|
166
|
+
const builtin = b.list.find((x) => x.id === BUILTIN_TEMPLATE_ID);
|
|
167
|
+
if (!builtin) throw badInput(`「${blockLabelOf(blockId)}」区块缺内置条目(落库行被写坏)`);
|
|
309
168
|
const t = clampTemplate(template);
|
|
310
169
|
if (!t) {
|
|
311
170
|
lists[blockId] = { active: BUILTIN_TEMPLATE_ID, list: b.list };
|
|
@@ -346,23 +205,33 @@ export function setLtSettings(patch: LtSettingsPatch = {}): Record<string, any>
|
|
|
346
205
|
const current = readBlockState(conn);
|
|
347
206
|
let lists = current.lists;
|
|
348
207
|
|
|
349
|
-
//
|
|
208
|
+
// 新模型:按区块合并(只传某个区块时不动其它区块的列表),整体过纯校验。
|
|
209
|
+
// 历史 rule 键已下线:patch 里带 rule 直接忽略(§11 不做旧配置兼容)。
|
|
350
210
|
if (patch.blockTemplates !== undefined) {
|
|
351
211
|
const raw = patch.blockTemplates as Record<string, any> | undefined;
|
|
352
212
|
const merged = { ...lists };
|
|
353
213
|
if (raw && typeof raw === 'object' && !Array.isArray(raw)) {
|
|
354
|
-
for (const
|
|
355
|
-
if (raw[
|
|
214
|
+
for (const blockId of PROMPT_BLOCK_IDS) {
|
|
215
|
+
if (raw[blockId] !== undefined) merged[blockId] = raw[blockId];
|
|
216
|
+
}
|
|
217
|
+
// 内置不可改(§4.2 第 1 道):被 patch 的区块里,builtin 条目一律替换回
|
|
218
|
+
// 库内现值(含 name / template / 位置)——落库后 builtin 是真数据,
|
|
219
|
+
// 客户端传什么都不生效;patch 缺 builtin 条目时补回。
|
|
220
|
+
for (const blockId of PROMPT_BLOCK_IDS) {
|
|
221
|
+
const next = merged[blockId];
|
|
222
|
+
const cur = lists[blockId];
|
|
223
|
+
if (raw[blockId] === undefined || !next || !cur) continue;
|
|
224
|
+
const curBuiltin = cur.list.find((x) => x.id === BUILTIN_TEMPLATE_ID)!;
|
|
225
|
+
const rest = (Array.isArray(next.list) ? next.list : []).filter(
|
|
226
|
+
(x: any) => x && x.id !== BUILTIN_TEMPLATE_ID && x.builtin !== true,
|
|
227
|
+
);
|
|
228
|
+
merged[blockId] = { ...next, list: [curBuiltin, ...rest] };
|
|
356
229
|
}
|
|
357
230
|
}
|
|
358
|
-
|
|
359
|
-
lists =
|
|
360
|
-
raw && typeof raw === 'object' && !Array.isArray(raw) && raw.rule !== undefined
|
|
361
|
-
? absorbStoredRule({ ...merged, rule: raw.rule })
|
|
362
|
-
: normalizeBlockTemplateLists(merged);
|
|
231
|
+
lists = normalizeBlockTemplateLists(merged);
|
|
363
232
|
}
|
|
364
233
|
|
|
365
|
-
//
|
|
234
|
+
// CLI 便捷入口:写入对应区块的 `cli` 条目并启用(空 = 恢复内置)。
|
|
366
235
|
if (patch.ackPrompt !== undefined) {
|
|
367
236
|
setCustomActive(lists, 'ack', joinEntries(clampAckPromptList(patch.ackPrompt)));
|
|
368
237
|
}
|
|
@@ -373,7 +242,6 @@ export function setLtSettings(patch: LtSettingsPatch = {}): Record<string, any>
|
|
|
373
242
|
setCustomActive(lists, 'attachment', clampAttachTemplate(patch.attachTemplate));
|
|
374
243
|
}
|
|
375
244
|
|
|
376
|
-
lists = normalizeBlockTemplateLists(lists);
|
|
377
245
|
assertBlockTemplatesValid(lists);
|
|
378
246
|
|
|
379
247
|
const appendMode =
|
|
@@ -399,4 +267,6 @@ export function settingsView(): Record<string, any> {
|
|
|
399
267
|
};
|
|
400
268
|
}
|
|
401
269
|
|
|
402
|
-
export { DEFAULT_TIMEOUT_SEC, MAX_TIMEOUT_SEC
|
|
270
|
+
export { DEFAULT_TIMEOUT_SEC, MAX_TIMEOUT_SEC } from '../store-io.js';
|
|
271
|
+
export { DEFAULT_ACK_PROMPT } from '../task-templates.js';
|
|
272
|
+
export type { BlockTemplateList };
|
|
@@ -2,23 +2,21 @@
|
|
|
2
2
|
// settings.ackPrompt 的存储形态、条数/长度上限与缺省值,以及交付模板的钳制都在这里。
|
|
3
3
|
// 完成后的汇报要求与收尾要求统一落在 ack 区块(DEFAULT_ACK_PROMPT,设置页可见可改);
|
|
4
4
|
// 旧 rule 区块已删除,其内容迁移时并入 ack。
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 默认 ack:完成任务就调用 localtask done 回填结果(任务 51 的职责合并决定)。
|
|
8
|
+
* v6 起唯一归属在本文件——shared/prompt-blocks 不再持有任何模板正文,模板真相在
|
|
9
|
+
* 出厂快照 blockTemplates.json;这里的文本 ≡ 快照 ack 段内置文本,一致性由
|
|
10
|
+
* tests/unit/prompt-ensure.test.mjs 对账;改任何一处都要同步另一处并跑单测。
|
|
11
|
+
*/
|
|
12
|
+
export const DEFAULT_ACK_PROMPT =
|
|
13
|
+
'完成之后必须调用 nx-kv localtask done --id {{task.id}} --summary "<完成总结>" 汇报结果。';
|
|
14
|
+
|
|
5
15
|
import {
|
|
6
16
|
DEFAULT_APPEND_MODE,
|
|
7
|
-
DEFAULT_ACK_PROMPT,
|
|
8
17
|
APPEND_MODES,
|
|
9
18
|
} from '../../shared/prompt-blocks.js';
|
|
10
19
|
|
|
11
|
-
export { DEFAULT_ACK_PROMPT };
|
|
12
|
-
|
|
13
|
-
// ─── ack 完成总结提示词(settings.ackPrompt)─────────────────────────
|
|
14
|
-
//
|
|
15
|
-
// agent 完成任务时写的**完成总结(ack)**该按什么格式——收进 ack 区块的模板列表,
|
|
16
|
-
// 多条按空行拼成一段,随领取交付的 instruction 一起给到 agent。
|
|
17
|
-
// **缺省就是默认汇报要求**(可见、可改;显式 '' / [] 恢复内置而不是关掉)。
|
|
18
|
-
// done 指令只存在于 ack 区块(旧 rule 已删除,其内容迁移时并入这里)。
|
|
19
|
-
/** 默认 ack:完成任务就调用 localtask done 回填结果(任务 51 的职责合并决定)。
|
|
20
|
-
* 文案与区块默认模板同源(shared/prompt-blocks.js),上面已重导出。 */
|
|
21
|
-
|
|
22
20
|
/** 交付上下文模板(任务 #62)的长度上限——防把整本书塞进设置。 */
|
|
23
21
|
export const MAX_DELIVERY_TEMPLATE_LEN = 8000;
|
|
24
22
|
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"context": {
|
|
3
|
+
"active": "builtin",
|
|
4
|
+
"list": [
|
|
5
|
+
{
|
|
6
|
+
"id": "builtin",
|
|
7
|
+
"name": "系统内置",
|
|
8
|
+
"template": "{{#if repo}}\n{{#if repo.intro}}\n〔项目介绍 · {{repo.name}}〕\n{{repo.intro}}\n{{/if}}\n{{#if repo.docs}}\n〔项目文档〕按需取用:nx-kv docs get --ref <refId>\n{{#each repo.docs}}\n - {{#if desc}}{{desc}}{{else}}{{#if title}}{{title}}{{else}}未命名文档{{/if}}{{/if}}{{#if note}} # {{note}}{{/if}}\n 取用:nx-kv docs get --ref {{refId}}\n{{/each}}\n{{/if}}\n{{#if repo.intro}}{{else}}{{#if repo.docs}}{{else}}\n〔项目上下文 · {{repo.name}}〕已登记为本机仓库({{repo.key}}),但没有项目介绍文档:nx-kv repo doc add {{repo.key}} --ref <refId>\n{{/if}}{{/if}}\n{{/if}}\n{{#if repo}}{{else}}{{#if cwd}}\n〔项目上下文〕工作目录 {{cwd}} 未登记为本机仓库,本次交付没有项目介绍 / 组上下文。登记(不需要 .git,给 key 即可):nx-kv repo add \"{{cwd}}\" --key <key>\n{{/if}}{{/if}}\n{{#if group}}\n〔项目组上下文 · {{group.name}}〕\n{{#if group.desc}}\n组定位:{{group.desc}}\n{{/if}}\n{{#if group.note}}\n本项目在组里的位置:{{group.note}}\n{{/if}}\n{{#if group.introRefId}}\n组介绍:{{#if group.introDesc}}{{group.introDesc}}{{else}}(无描述){{/if}}\n 取用:nx-kv docs get --ref {{group.introRefId}}\n{{/if}}\n{{#if group.peers}}\n组内成员:\n{{#each group.peers}}\n - {{name}}:{{#if note}}{{note}}{{else}}(无组内描述){{/if}}{{#if path}}({{path}}){{/if}}\n{{/each}}\n{{/if}}\n{{#if group.docs}}\n组文档(按需取用):\n{{#each group.docs}}\n - {{#if desc}}{{desc}}{{else}}{{#if title}}{{title}}{{else}}未命名文档{{/if}}{{/if}}{{#if note}} # {{note}}{{/if}}\n 取用:nx-kv docs get --ref {{refId}}\n{{/each}}\n{{/if}}\n{{/if}}\n{{#if refRepos.count}}\n参考仓库(可直接读取,共 {{refRepos.count}} 个):\n{{#each refRepos.list}}\n - {{name}}{{#if path}}({{path}}){{/if}}{{#if note}} # {{note}}{{/if}}\n{{/each}}\n{{/if}}",
|
|
9
|
+
"builtin": true
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
"attachment": {
|
|
14
|
+
"active": "builtin",
|
|
15
|
+
"list": [
|
|
16
|
+
{
|
|
17
|
+
"id": "builtin",
|
|
18
|
+
"name": "系统内置",
|
|
19
|
+
"template": "{{#if attach}}\n〔附件〕本任务包含 {{attach.count}} 个附件(正文内嵌 {{attach.inlineCount}} · 附件区 {{attach.areaCount}})。请先识别附件内容(图片先看图、文档先读内容、文件夹先列目录)再开始处理,不要跳过附件。\n\n附件清单:\n{{#each attach.list}}\n - [{{originLabel}}] {{kindLabel}} {{name}}{{#if sizeText}}({{sizeText}}){{/if}}:{{#if file}}{{#if file.exists}}{{file.localPath}}{{else}}未同步到本地(fileId {{file.fileId}}){{/if}}{{/if}}{{#if url}}{{url.href}}{{/if}}{{#if task}}{{#if task.resolved}}#{{task.seq}} {{task.title}} · 地址 {{task.address}}({{task.statusLabel}}){{else}}地址 {{task.address}}({{task.statusLabel}}){{/if}}{{/if}}{{#if ref}}{{ref.title}}{{/if}}{{#if mdfile}}{{mdfile.absPath}}{{#if mdfile.missing}}(源文件已不在){{/if}}{{/if}}{{#if folder}}{{folder.absPath}}{{#if folder.missing}}(目录已不在){{/if}}{{/if}}{{#if note}} # {{note}}{{/if}}\n{{/each}}\n\n取用方式:\n{{#each attach.list}}\n - {{kindLabel}} 《{{name}}》:{{usage}}\n{{/each}}\n{{#each attach.list}}{{#if mdfile}}{{#if mdfile.content}}〔外部 md · {{name}}〕({{mdfile.absPath}}{{#if mdfile.truncated}},已截断{{/if}}{{#if mdfile.stale}},内容有变化{{/if}}):\n\n{{mdfile.content}}\n\n{{/if}}{{/if}}{{/each}}\n{{#each attach.list}}{{#if ref}}{{#if ref.content}}〔文档原文 · {{ref.title}}〕:\n\n{{ref.content}}\n\n{{/if}}{{/if}}{{/each}}\n{{/if}}",
|
|
20
|
+
"builtin": true
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"timecheck": {
|
|
25
|
+
"active": "builtin",
|
|
26
|
+
"list": [
|
|
27
|
+
{
|
|
28
|
+
"id": "builtin",
|
|
29
|
+
"name": "系统内置",
|
|
30
|
+
"template": "{{#if goal.check}}\n{{goal.check}}\n{{/if}}\n{{#if goal.statusLine}}\n{{goal.statusLine}}\n{{/if}}",
|
|
31
|
+
"builtin": true
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"goalhint": {
|
|
36
|
+
"active": "builtin",
|
|
37
|
+
"list": [
|
|
38
|
+
{
|
|
39
|
+
"id": "builtin",
|
|
40
|
+
"name": "系统内置",
|
|
41
|
+
"template": "{{#if goal.check}}\n〔特殊功能提示 · 时间目标〕任务 #{{task.id}} 正在计时:持续 {{goal.durationHuman}},已过 {{goal.elapsedHuman}}({{percent goal.elapsedSec goal.durationSec}}%),{{#if goal.reached}}已到点(超时 {{formatDuration goal.overtimeSec}}){{else}}剩余 {{goal.remainingHuman}}{{/if}}。\n{{#if goal.reached}}——时间已到:可以收口,把改动收敛成可交付状态,补验证与说明后按 ack 段 done。\n{{else}}{{#if (gte (percent goal.elapsedSec goal.durationSec) 67)}}——已过 2/3:进入收尾整理(收敛改动 / 补验证 / 写清遗留),别开新战线。\n{{else}}{{#if (gte (percent goal.elapsedSec goal.durationSec) 50)}}——已过半:先确认主线走到哪,剩余时间只做收尾必需项。\n{{else}}——时间尚足:先做主线,再补细节。{{/if}}{{/if}}{{/if}}\n{{/if}}",
|
|
42
|
+
"builtin": true
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"doneguard": {
|
|
47
|
+
"active": "builtin",
|
|
48
|
+
"list": [
|
|
49
|
+
{
|
|
50
|
+
"id": "builtin",
|
|
51
|
+
"name": "系统内置",
|
|
52
|
+
"template": "{{#if goal.blocked}}\n〔完成门禁 · 时间未到〕任务 #{{task.id}} 还不能 done:持续 {{goal.durationHuman}},已过 {{goal.elapsedHuman}}({{percent goal.elapsedSec goal.durationSec}}%),剩余 {{goal.remainingHuman}}。\n- 现在可做:{{#if (gte (percent goal.elapsedSec goal.durationSec) 67)}}收尾整理(收敛改动 / 补验证 / 写清遗留),或派 sub agent 提出新的需求继续推进{{else}}继续推进主线,并派 sub agent 重新提出新的需求{{/if}}。\n- 每轮推进先跑:nx-kv timegoal check --task {{goal.goalKey}} --summary \"<本轮现状>\"\n- 到点后再:nx-kv localtask done --id {{task.id}} --summary \"<完成总结>\"\n{{/if}}",
|
|
53
|
+
"builtin": true
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
"ext": {
|
|
58
|
+
"active": "builtin",
|
|
59
|
+
"list": [
|
|
60
|
+
{
|
|
61
|
+
"id": "builtin",
|
|
62
|
+
"name": "系统内置",
|
|
63
|
+
"template": "{{#if ext.count}}\n本队列({{ext.topic}})还有 {{ext.count}} 条待领取任务:\n{{#each ext.list}}\n - #{{id}} {{title}}\n{{/each}}\n先完成当前任务,再领取下一条;不要因为后面还有活就提前收尾或分心。\n{{/if}}",
|
|
64
|
+
"builtin": true
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
"ack": {
|
|
69
|
+
"active": "builtin",
|
|
70
|
+
"list": [
|
|
71
|
+
{
|
|
72
|
+
"id": "builtin",
|
|
73
|
+
"name": "系统内置",
|
|
74
|
+
"template": "完成之后必须调用 nx-kv localtask done --id {{task.id}} --summary \"<完成总结>\" 汇报结果。",
|
|
75
|
+
"builtin": true
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
"getloop": {
|
|
80
|
+
"active": "builtin",
|
|
81
|
+
"list": [
|
|
82
|
+
{
|
|
83
|
+
"id": "builtin",
|
|
84
|
+
"name": "系统内置",
|
|
85
|
+
"template": "{{#if getloop}}\n{{#if task}}不要直接结束本轮:完成上面的任务({{task.id}})之后,继续调用 nx-kv localtask get 领取下一条任务。队列里有活会立即返回;{{#if (gt getloop.waitMinutes 0)}}没活时每次最多阻塞 {{getloop.waitMinutes}} 分钟,直到 get 返回 timeout 为止。{{/if}}{{/if}}\n{{/if}}",
|
|
86
|
+
"builtin": true
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
}
|