nx-kv 0.64.0 → 0.65.2
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 +70 -0
- package/assets/nx-kv/SKILL.md +5 -2
- package/assets/nx-kv/references/A03-/346/226/207/346/241/243/344/270/216/345/275/222/345/261/236.md +6 -0
- package/assets/nx-kv/references/A04-/344/273/223/345/272/223/344/270/216/351/241/271/347/233/256/347/273/204.md +79 -6
- package/assets/nx-kv/templates/ref-main-doc.md +46 -0
- package/package.json +1 -1
- package/src/core/db/seed-templates.ts +2 -86
- package/src/modules/localtask/task-lifecycle.ts +1 -1
- package/src/modules/promptplug/actions/_manifest.generated.ts +9 -0
- package/src/modules/promptplug/actions/prompt-registry.ts +4 -1
- package/src/modules/promptplug/actions/prompt-template-activate.ts +31 -0
- package/src/modules/promptplug/actions/prompt-template-delete.ts +30 -0
- package/src/modules/promptplug/actions/prompt-template-save.ts +52 -0
- package/src/modules/promptplug/delivery.ts +151 -0
- package/src/modules/promptplug/factory.ts +16 -8
- package/src/modules/promptplug/index.ts +3 -1
- package/src/modules/promptplug/plugins/doneguard.ts +3 -0
- package/src/modules/promptplug/plugins/getloop.ts +8 -7
- package/src/modules/{tasktool/plugins/goal-template.ts → promptplug/plugins/goal-prompt.ts} +57 -4
- package/src/modules/promptplug/plugins/goal-shape.ts +17 -0
- package/src/modules/promptplug/plugins/goalhint.ts +22 -9
- package/src/modules/promptplug/plugins/timecheck.ts +25 -14
- package/src/modules/promptplug/registry.ts +3 -3
- package/src/modules/promptplug/template-store.ts +145 -0
- package/src/modules/tasktool/delivery.ts +231 -0
- package/src/modules/tasktool/get.ts +2 -2
- package/src/modules/tasktool/plugins/taskgoal-store.ts +28 -22
- package/src/modules/tasktool/plugins/timegoal-task-store.ts +70 -5
- package/src/modules/tasktool/plugins/waitgoal-config.ts +1 -25
- package/src/modules/tasktool/plugins/waitgoal.ts +0 -4
- package/src/modules/tasktool/preview.ts +3 -4
- package/src/modules/tasktool/wait.ts +16 -284
- package/src/modules/templates/actions/templates-default.ts +2 -5
- package/src/modules/templates/actions/templates-update.ts +1 -3
- package/src/modules/templates/service.ts +11 -13
- package/src/modules/templates/support.ts +0 -15
- package/src/web/frontend/App.tsx +0 -12
- package/src/web/frontend/api/cli-tree.json +58 -0
- package/src/web/frontend/api/client.generated.ts +32 -2
- package/src/web/frontend/components/doc/doc-head.tsx +13 -4
- package/src/web/frontend/components/icons.tsx +9 -199
- package/src/web/frontend/components/md/live-block.tsx +1 -5
- package/src/web/frontend/components/md/md-panes-root.tsx +0 -4
- package/src/web/frontend/components/md/md-panes.tsx +1 -11
- package/src/web/frontend/components/md/tool-bar.tsx +9 -0
- package/src/web/frontend/components/sidebar/index.tsx +13 -2
- package/src/web/frontend/components/sidebar/model.ts +3 -0
- package/src/web/frontend/components/tool-acts/bar.tsx +40 -29
- package/src/web/frontend/components/tool-acts/layout-panel.tsx +7 -3
- package/src/web/frontend/components/tool-acts/modules.ts +53 -51
- package/src/web/frontend/components/tool-acts/style.css +7 -3
- package/src/web/frontend/modules/md/styles/docs.css +0 -7
- package/src/web/frontend/modules/md/styles/editor.css +0 -17
- package/src/web/frontend/modules/md/styles/shell.css +3 -0
- package/src/web/frontend/modules/md/use-templates.ts +3 -13
- package/src/web/frontend/page/dir/index.tsx +3 -15
- package/src/web/frontend/page/dir/task-actions.ts +1 -16
- package/src/web/frontend/page/dir/task.tsx +2 -16
- package/src/web/frontend/page/group/index.tsx +6 -19
- package/src/web/frontend/page/repos/branch-persist.ts +32 -0
- package/src/web/frontend/page/repos/icons.tsx +47 -229
- package/src/web/frontend/page/repos/index.tsx +12 -8
- package/src/web/frontend/page/repos/repo-table.tsx +24 -3
- package/src/web/frontend/page/settings/api.ts +20 -0
- package/src/web/frontend/page/settings/index.tsx +1 -1
- package/src/web/frontend/page/settings/prompt-template-editor.tsx +180 -0
- package/src/web/frontend/page/settings/prompt-templates-section.tsx +39 -34
- package/src/web/frontend/page/settings/style.css +30 -0
- package/src/web/frontend/page/templates/index.tsx +5 -54
- package/src/web/frontend/page/templates/manage.tsx +1 -5
- package/src/web/frontend/page/templates/style.css +1 -43
- package/src/web/frontend/page/templates/template-list.tsx +7 -15
- package/src/web/frontend/routes/route-eq.ts +2 -3
- package/src/web/frontend/routes/static.ts +2 -2
- package/src/web/frontend/routes/templates.ts +0 -10
- package/src/web/frontend/styles/repos.css +22 -0
- package/src/web/frontend/styles-v2/shell.css +7 -0
- package/src/web/frontend/svghub/catalog-act.ts +168 -0
- package/src/web/frontend/svghub/catalog-doc.ts +102 -0
- package/src/web/frontend/svghub/catalog-nav.ts +192 -0
- package/src/web/frontend/svghub/catalog-repo.ts +102 -0
- package/src/web/frontend/svghub/catalog-state.ts +70 -0
- package/src/web/frontend/svghub/icon.tsx +95 -0
- package/src/web/frontend/svghub/index.ts +66 -0
- package/src/web/frontend/svghub/serialize.ts +39 -0
- package/src/web/frontend/svghub/types.ts +67 -0
- package/src/web/frontend/types.ts +2 -1
- package/src/web/public/assets/app-context-BqCBcDsx.js +1 -0
- package/src/web/public/assets/bar-Dc5Tq1eE.js +1 -0
- package/src/web/public/assets/{button-BEWXOABr.js → button-3JlUeln_.js} +1 -1
- package/src/web/public/assets/{composer-launch-DRi9mZE1.js → composer-launch-fp2IzGzQ.js} +1 -1
- package/src/web/public/assets/{composer-panel-swmDqlPw.js → composer-panel-Dh681iO6.js} +1 -1
- package/src/web/public/assets/dag-DnaU0I_z.js +1 -0
- package/src/web/public/assets/dir-d16q1GLe.js +3 -0
- package/src/web/public/assets/doc-DRSKD0Re.js +6 -0
- package/src/web/public/assets/group-Dc3ZgW24.js +1 -0
- package/src/web/public/assets/index-BIVxGd6t.css +1 -0
- package/src/web/public/assets/index-Bg0m8gbJ.js +2 -0
- package/src/web/public/assets/{list-filter-D-x94TvA.js → list-filter-CWxiOSg_.js} +1 -1
- package/src/web/public/assets/md-history-CLIs9Dr0.css +1 -0
- package/src/web/public/assets/md-history-DNtgaIdH.js +39 -0
- package/src/web/public/assets/{member-picker-Cvbv24IK.js → member-picker-BZgE3HGb.js} +1 -1
- package/src/web/public/assets/model-CtG2jIDv.js +2 -0
- package/src/web/public/assets/{overview-CctJfO3D.js → overview-C68QpcT9.js} +1 -1
- package/src/web/public/assets/popup-DZ2Khv2c.js +1 -0
- package/src/web/public/assets/progress-CEmAFxo9.js +3 -0
- package/src/web/public/assets/refs-TzxZYy7T.js +2 -0
- package/src/web/public/assets/repo-form-modal-Dg3hJWUV.js +1 -0
- package/src/web/public/assets/repos-uNqSR5YB.js +12 -0
- package/src/web/public/assets/{route-crumb-BcDPd7Ht.js → route-crumb-C4DgkJ8G.js} +1 -1
- package/src/web/public/assets/{settings-Cc6puKd5.css → settings-BWHjNegB.css} +1 -1
- package/src/web/public/assets/settings-BzIllshQ.js +1 -0
- package/src/web/public/assets/{status-tag-BD_0iWMB.js → status-tag-8cLH8hl9.js} +1 -1
- package/src/web/public/assets/task-DuFOXLPC.js +11 -0
- package/src/web/public/assets/{task-row-CQgzQmzu.js → task-row-CRjuAfKW.js} +1 -1
- package/src/web/public/assets/{task-utils-bJH1-Cjy.js → task-utils-DAPxKm4c.js} +1 -1
- package/src/web/public/assets/templates-CwYDIBYn.css +1 -0
- package/src/web/public/assets/templates-DNiGvmdq.js +10 -0
- package/src/web/public/assets/{use-rail-drag-ufwy2XZB.js → use-rail-drag-DxIYcszo.js} +1 -1
- package/src/web/public/assets/{workspace-D3jbcTwf.js → workspace-DojQ3RP4.js} +2 -2
- package/src/web/public/index.html +15 -16
- package/src/web/frontend/modules/md/fill-session.ts +0 -36
- package/src/web/frontend/modules/md/new-task-from-template.ts +0 -22
- package/src/web/frontend/modules/md/task-intent.ts +0 -29
- package/src/web/frontend/modules/prompts/render-template-body.ts +0 -14
- package/src/web/frontend/modules/prompts/template-preview.ts +0 -62
- package/src/web/frontend/page/templates/fill.tsx +0 -124
- package/src/web/public/assets/app-context-DDQnrPSP.js +0 -1
- package/src/web/public/assets/bar-j14ON7uZ.js +0 -1
- package/src/web/public/assets/dag-BzdFYMml.js +0 -1
- package/src/web/public/assets/dir-DhsB1ZhL.js +0 -3
- package/src/web/public/assets/doc-D4po3sDc.js +0 -6
- package/src/web/public/assets/fill-session-fHxQHFaD.js +0 -1
- package/src/web/public/assets/group-BxmSNzIB.js +0 -1
- package/src/web/public/assets/index-CMjG5NVU.js +0 -2
- package/src/web/public/assets/index-uMjSWNVr.css +0 -1
- package/src/web/public/assets/md-history-1h2zairf.css +0 -1
- package/src/web/public/assets/md-history-CZUF_FhN.js +0 -39
- package/src/web/public/assets/model-Cc2EoUQp.js +0 -2
- package/src/web/public/assets/new-task-from-template-DDWu4yR4.js +0 -1
- package/src/web/public/assets/popup-D8KWI6-Q.js +0 -1
- package/src/web/public/assets/progress-CawQRCQf.js +0 -3
- package/src/web/public/assets/refs-TuuoaRs7.js +0 -2
- package/src/web/public/assets/render-template-body-bXdedFig.js +0 -1
- package/src/web/public/assets/repo-form-modal-BD4N37MI.js +0 -1
- package/src/web/public/assets/repos-BPeuX4N9.js +0 -12
- package/src/web/public/assets/settings-CZJaKLZW.js +0 -1
- package/src/web/public/assets/task-DgbbF5gy.js +0 -11
- package/src/web/public/assets/task-intent-CX5DZccN.js +0 -1
- package/src/web/public/assets/templates-CBXlwyof.js +0 -11
- package/src/web/public/assets/templates-plA8R7jJ.css +0 -1
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
import { getSettings } from '../localtask/service.js';
|
|
17
17
|
import { PLUGIN_IDS, groupIndex, pluginMeta } from '../promptplug/index.js';
|
|
18
18
|
import { deliveryPlainText } from './delivery-text.js';
|
|
19
|
-
import { getLoopForCwd,
|
|
20
|
-
import { buildTaskDelivery } from './
|
|
19
|
+
import { getLoopForCwd, type GetLoopState } from './getloop.js';
|
|
20
|
+
import { buildTaskDelivery } from './delivery.js';
|
|
21
21
|
|
|
22
22
|
export interface PreviewTaskDeliveryOptions {
|
|
23
23
|
/** 任务行(库存形状;草稿由调用方合成 { id:0, text }) */
|
|
@@ -44,7 +44,6 @@ export async function previewTaskDelivery({ task, cwd, key, summary, params }: P
|
|
|
44
44
|
// 内文固定取全局区块默认值,仓库侧只有开关 + 分钟)。
|
|
45
45
|
// 统一交给 buildTaskDelivery 编排成 getloop 区块,预览与真实领取不会各拼一份。
|
|
46
46
|
const loop: GetLoopState = await getLoopForCwd(cwd).catch(() => ({ enabled: false }));
|
|
47
|
-
const getLoopTpl = getLoopInstruction(loop);
|
|
48
47
|
const delivery: any = await buildTaskDelivery(task, {
|
|
49
48
|
source: 'local',
|
|
50
49
|
summary: summary || '',
|
|
@@ -54,7 +53,7 @@ export async function previewTaskDelivery({ task, cwd, key, summary, params }: P
|
|
|
54
53
|
params: params || {},
|
|
55
54
|
preview: true,
|
|
56
55
|
trace: segments,
|
|
57
|
-
|
|
56
|
+
getLoopEnabled: !!loop.enabled,
|
|
58
57
|
getLoopWaitMinutes: loop.enabled ? loop.waitMinutes || 0 : 0,
|
|
59
58
|
});
|
|
60
59
|
|
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
// 边界(tasktool = 任务工具语义,localtask = 队列本体):
|
|
4
4
|
// - 队列读写、唤醒注册表、presence/面板注册表都在 localtask(serve 路由与
|
|
5
5
|
// panel-guard 的一半也长在那边),这里只做**队列编排**:快路径领取 → 阻塞窗口
|
|
6
|
-
// (跨进程轮询 / goal 到点收尾 /
|
|
6
|
+
// (跨进程轮询 / goal 到点收尾 / 用户关闭)。
|
|
7
|
+
// - 交付组装已拆到 delivery.ts(宿主取数 → promptplug 的 assembleDelivery)——
|
|
8
|
+
// 本文件在拿到任务的那一刻调 buildTaskDelivery,不碰模板与渲染。
|
|
7
9
|
// - 面板随行(确保主面板 / 深链 / 窗口重开防风暴)已拆到 panel-escort.js——
|
|
8
10
|
// 这里只经 escortPanel({ stop() }) 一点相接。
|
|
9
11
|
// - 与队列的耦合全部走 localtask/service.js 的导出面;与计时目标的耦合走
|
|
10
|
-
// 同模块的 timegoal.js
|
|
12
|
+
// 同模块的 timegoal.js(探针只读;goal 到点自动收尾本轮)。
|
|
11
13
|
import { DEFAULT_PORT } from '../../core/paths.js';
|
|
12
|
-
import { formatGoalTiming, renderInstruction } from '../../core/instruction-template.js';
|
|
13
|
-
import { parseFrontmatter } from '../../shared/frontmatter.js';
|
|
14
|
-
import { reorderRoundsForDelivery } from '../../shared/feedback-text.js';
|
|
15
14
|
import {
|
|
16
15
|
clampTimeoutSec,
|
|
17
16
|
clearWaiting,
|
|
@@ -22,7 +21,6 @@ import {
|
|
|
22
21
|
isGlobalKey,
|
|
23
22
|
normalizeCwd,
|
|
24
23
|
normalizeSummary,
|
|
25
|
-
pendingQueueInfo,
|
|
26
24
|
probeEffectivePresence,
|
|
27
25
|
registerGlobalWaiter,
|
|
28
26
|
registerTopicWaiter,
|
|
@@ -32,67 +30,19 @@ import {
|
|
|
32
30
|
unregisterTopicWaiter,
|
|
33
31
|
} from '../localtask/service.js';
|
|
34
32
|
import { ensureMainPanel, deepLinkUrl, escortPanel } from './panel-escort.js';
|
|
35
|
-
import {
|
|
36
|
-
import { formatDuration } from '../../core/instruction-template.js';
|
|
37
|
-
import { readGroupContext } from './groupctx.js';
|
|
38
|
-
import { annotateTaskDelivery, attachTemplateCtx } from './attach.js';
|
|
39
|
-
import { compose, type RenderTraceEntry, type SegmentMeta } from '../promptplug/compose.js';
|
|
40
|
-
import { buildPlugins } from '../promptplug/index.js';
|
|
33
|
+
import { buildTaskDelivery } from './delivery.js';
|
|
41
34
|
import * as timegoal from './timegoal.js';
|
|
42
35
|
|
|
43
36
|
// 跨进程兜底轮询间隔(只定这里的读取节奏;队列写入节奏与它无关)
|
|
44
37
|
const POLL_MS = 500;
|
|
45
38
|
|
|
46
|
-
//
|
|
47
|
-
function parseStampMs(v: unknown): number {
|
|
48
|
-
const m = /^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2}):(\d{2})$/.exec(String(v || ''));
|
|
49
|
-
if (!m) return NaN;
|
|
50
|
-
return new Date(Number(m?.[1]), Number(m?.[2]) - 1, Number(m?.[3]), Number(m?.[4]), Number(m?.[5]), Number(m?.[6])).getTime();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// goal 上下文的**时间运算字段**统一在这里补齐(任务 #82:模板层要能拿剩余/超时做运算,
|
|
54
|
-
// 不能只有人话的 remainingHuman)。目录级 show 自带 reached/remainingSec/overtimeSec;
|
|
55
|
-
// 任务级只有 deadline 戳——同式解析补算。缺哪个补哪个,已有的不覆盖。
|
|
56
|
-
export function enrichGoalTiming(g: any): any {
|
|
57
|
-
if (!g) return g;
|
|
58
|
-
let { remainingSec, overtimeSec, reached } = g;
|
|
59
|
-
remainingSec = Number(remainingSec);
|
|
60
|
-
overtimeSec = Number(overtimeSec);
|
|
61
|
-
if (!Number.isFinite(remainingSec) && !Number.isFinite(overtimeSec)) {
|
|
62
|
-
const ms = parseStampMs(g.deadline);
|
|
63
|
-
if (Number.isFinite(ms)) {
|
|
64
|
-
const diff = Math.round((ms - Date.now()) / 1000);
|
|
65
|
-
remainingSec = diff >= 0 ? diff : 0;
|
|
66
|
-
overtimeSec = diff >= 0 ? 0 : -diff;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (reached === undefined) {
|
|
70
|
-
if (Number.isFinite(overtimeSec)) reached = overtimeSec > 0;
|
|
71
|
-
else if (Number.isFinite(remainingSec)) reached = remainingSec <= 0;
|
|
72
|
-
}
|
|
73
|
-
if (Number.isFinite(remainingSec)) {
|
|
74
|
-
g.remainingSec = remainingSec;
|
|
75
|
-
g.remainingMin = Math.ceil(remainingSec / 60);
|
|
76
|
-
}
|
|
77
|
-
if (Number.isFinite(overtimeSec)) g.overtimeSec = overtimeSec;
|
|
78
|
-
if (reached !== undefined) g.reached = reached;
|
|
79
|
-
// 任务 #87:模板里要能直接写「持续 {{goal.durationHuman}}」——人话时长统一在这里补。
|
|
80
|
-
if (Number.isFinite(Number(g.durationSec)) && Number(g.durationSec) > 0) {
|
|
81
|
-
g.durationHuman = g.durationHuman || formatDuration(Number(g.durationSec));
|
|
82
|
-
}
|
|
83
|
-
if (Number.isFinite(Number(g.elapsedSec))) {
|
|
84
|
-
g.elapsedHuman = g.elapsedHuman || formatDuration(Number(g.elapsedSec));
|
|
85
|
-
}
|
|
86
|
-
return g;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// ─── 时间目标探针与交付时刻的目标上下文 ──────────────────────────────
|
|
39
|
+
// ─── 时间目标探针(阻塞期间到点自动收尾本轮) ────────────────────────
|
|
90
40
|
//
|
|
91
|
-
// 与 localtask wait
|
|
41
|
+
// 与 localtask wait 的融合(fail-open:timegoal 坏了绝不拖垮 wait):
|
|
92
42
|
// - 阻塞期间到点 → 本轮立刻收尾(goalPoll,见 waitForTask);
|
|
93
|
-
// - 返回时刻把目标状态渲染进 instruction(goal
|
|
94
|
-
// 探针按 key 服务于 500ms
|
|
95
|
-
//
|
|
43
|
+
// - 返回时刻把目标状态渲染进 instruction(goal 段)——那半边在 delivery.ts。
|
|
44
|
+
// 探针按 key 服务于 500ms 轮询。读取时机是**阻塞开始**不是返回时刻:
|
|
45
|
+
// 只认「等待开始时还在跑」的目标,已到点的不参与自动取消。
|
|
96
46
|
|
|
97
47
|
// 等待期到点探针(只读、不写盘):返回该目录目标的截止 epoch ms;已到点/无目标 → 0
|
|
98
48
|
async function readGoalDeadlineMs(key: unknown): Promise<number> {
|
|
@@ -107,226 +57,8 @@ async function readGoalDeadlineMs(key: unknown): Promise<number> {
|
|
|
107
57
|
}
|
|
108
58
|
}
|
|
109
59
|
|
|
110
|
-
// wait/get **返回时刻**的目标上下文(渲染 instruction 用)。fail-open:加载失败 /
|
|
111
|
-
// 读不到 / 没目标 / 出错 → null,instruction 照常渲染(goal 段被整段丢弃)。
|
|
112
|
-
// 绝不写盘:showTimegoal 走 loadRecycledStore({persist:false})——timegoals.json
|
|
113
|
-
// 字节数不变,goal-expiry 单测字节比对钉着。
|
|
114
|
-
async function readGoalCtx(cwd: unknown): Promise<Record<string, any> | null> {
|
|
115
|
-
if (!cwd || isGlobalKey(cwd)) return null; // cwd 是路径,isGlobalKey 恒 false——纯防御
|
|
116
|
-
try {
|
|
117
|
-
const show = await timegoal.showTimegoal({ cwd });
|
|
118
|
-
if (!show || !show.hasGoal) return null;
|
|
119
|
-
const g = show.goal || {};
|
|
120
|
-
return {
|
|
121
|
-
name: g.name || show.name || '',
|
|
122
|
-
deadline: g.deadline || '',
|
|
123
|
-
prompt: g.prompt || '',
|
|
124
|
-
reached: !!show.reached,
|
|
125
|
-
remainingSec: show.remainingSec,
|
|
126
|
-
overtimeSec: show.overtimeSec,
|
|
127
|
-
remainingHuman: formatGoalTiming({
|
|
128
|
-
reached: show.reached,
|
|
129
|
-
remainingSec: show.remainingSec,
|
|
130
|
-
overtimeSec: show.overtimeSec,
|
|
131
|
-
}),
|
|
132
|
-
};
|
|
133
|
-
} catch {
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
60
|
// ─── 阻塞等待:核心入口 ─────────────────────────────────────────────
|
|
139
61
|
|
|
140
|
-
// 组装 wait/get 返回的任务载荷 + 指令。**单一路径**:
|
|
141
|
-
// 所有段落(上下文 / 附件 / 时间目标 / ack / 持续 get)一律进返回载荷的
|
|
142
|
-
// instruction 字段;task.text 始终是库存原文,绝不把系统提示词拼进正文。
|
|
143
|
-
// 旧 rule 区块已删除:done 指令与收尾要求统一由 ack 区块承载。
|
|
144
|
-
// 任何异常都降级为「只回任务」——wait 绝不能因渲染挂掉(与探针同一条 fail-open 纪律)。
|
|
145
|
-
//
|
|
146
|
-
// preview / trace(任务 #65「预览 get 提示词」):
|
|
147
|
-
// preview=true → **零副作用**:不启动任务级 timegoal 计时、不写库、不领取;
|
|
148
|
-
// timegoal 的 check 指令用声明现算(与真实领取同一份)。其余渲染路径与真实领取
|
|
149
|
-
// 完全同一条代码,所以预览出来的字符串就是 agent 会拿到的那一份。
|
|
150
|
-
// trace=[] → 按顺序记下每一段的来源(谁贡献的、开关是否开着),供面板展示
|
|
151
|
-
// 「这段是哪来的」。真实领取不传 trace,行为与改造前逐字节一致。
|
|
152
|
-
export interface DeliveryOptions {
|
|
153
|
-
source?: string;
|
|
154
|
-
summary?: unknown;
|
|
155
|
-
cwd?: unknown;
|
|
156
|
-
name?: unknown;
|
|
157
|
-
topicKey?: unknown;
|
|
158
|
-
params?: Record<string, string>;
|
|
159
|
-
preview?: boolean;
|
|
160
|
-
trace?: RenderTraceEntry[];
|
|
161
|
-
getLoopTpl?: string;
|
|
162
|
-
getLoopWaitMinutes?: number;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export async function buildTaskDelivery(
|
|
166
|
-
task: any,
|
|
167
|
-
{ source, summary, cwd, name, topicKey, params, preview = false, trace, getLoopTpl = '', getLoopWaitMinutes = 0 }: DeliveryOptions = {},
|
|
168
|
-
): Promise<Record<string, any>> {
|
|
169
|
-
// 附件标注(任务 #15:正文里的  嵌入 → 附件清单 + 本地路径)。
|
|
170
|
-
// fail-open:标注失败绝不拖垮交付;正文没有引用时 annotateTaskDelivery 返回
|
|
171
|
-
// null,载荷与改造前**逐字节一致**(与 localtask 读任务的同一条纪律)。
|
|
172
|
-
let att: any = null;
|
|
173
|
-
try {
|
|
174
|
-
// inlineDocs(#162):文档资料绑定(role=doc)随交付带全文——只读盘(自有树 /
|
|
175
|
-
// 绑定闭包),预览同样安全;读不到内容留空,不阻断交付。
|
|
176
|
-
const a = await annotateTaskDelivery(task, { topicKey, inlineDocs: true });
|
|
177
|
-
if (a) {
|
|
178
|
-
task = a.task;
|
|
179
|
-
att = a;
|
|
180
|
-
}
|
|
181
|
-
} catch {
|
|
182
|
-
/* 标注失败照常交付(agent 还能从正文里的嵌入自行处理) */
|
|
183
|
-
}
|
|
184
|
-
try {
|
|
185
|
-
// 任务级 timegoal(发布带 --duration):**领取即计时**——这里起表(幂等),
|
|
186
|
-
// goal 上下文换成任务级(prompt = check 指令,固化进 timegoal 存储,之后每轮原文回显)。
|
|
187
|
-
// 目录级 goal 仍作兜底:任务没带时间目标时,渲染等待方目录的目标状态。
|
|
188
|
-
let taskGoalCtx: any = null;
|
|
189
|
-
if (task && task.timegoal && topicKey) {
|
|
190
|
-
const title = (String(task.text || '')
|
|
191
|
-
.split('\n')
|
|
192
|
-
.map((l) => l.trim())
|
|
193
|
-
.find(Boolean) || `任务 #${task.id}`).slice(0, 40);
|
|
194
|
-
// 预览走只读版本:同一份 check 指令文本,但不落盘、不起表
|
|
195
|
-
taskGoalCtx = preview
|
|
196
|
-
? await previewTaskGoal({ topicKey, taskId: task.id, cwd, name: title, timegoal: task.timegoal, text: task.text })
|
|
197
|
-
: await ensureTaskGoal({
|
|
198
|
-
topicKey,
|
|
199
|
-
taskId: task.id,
|
|
200
|
-
cwd,
|
|
201
|
-
name: title,
|
|
202
|
-
text: task.text,
|
|
203
|
-
timegoal: task.timegoal,
|
|
204
|
-
startedAtMs: parseStampMs(task.consumedAt) || undefined,
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
const goal = enrichGoalTiming(taskGoalCtx || (await readGoalCtx(cwd)));
|
|
208
|
-
|
|
209
|
-
// 项目组上下文(组概念 + 本项目位置 + 兄弟成员 + 参考文件地址):只进 instruction。
|
|
210
|
-
// #64 作用域:组材料只挂**组任务**(正文 frontmatter 带 board);单 repo 主题里
|
|
211
|
-
// 提交的纯项目任务只带项目介绍,不把所属组的材料挂进来。
|
|
212
|
-
const boardMark = String(parseFrontmatter(String((task && task.text) || '')).board || '').trim();
|
|
213
|
-
const groupCtx = await readGroupContext(cwd as string, { board: boardMark });
|
|
214
|
-
const settings: any = (await getSettings().catch(() => null)) || {};
|
|
215
|
-
|
|
216
|
-
// ── 插件化组装(promptplug):宿主完成领域取数,插件 data() 做同步变换 ──
|
|
217
|
-
// 任务级 goal → 完整 check 指令;目录级 goal → 状态行(二者都进 timecheck 段)。
|
|
218
|
-
const goalCheck = taskGoalCtx ? taskGoalCtx.prompt : null;
|
|
219
|
-
const goalStatus = !taskGoalCtx && goal
|
|
220
|
-
? `〔时间目标「${goal.name || ''}」${goal.remainingHuman || ''}〕`
|
|
221
|
-
: null;
|
|
222
|
-
const goalCtx = goal
|
|
223
|
-
? {
|
|
224
|
-
...goal,
|
|
225
|
-
// 任务 #87:goal.extra(附加要求,领取后可动态改)与 goalKey 供模板直接引用
|
|
226
|
-
extra: taskGoalCtx ? taskGoalCtx.extra || '' : '',
|
|
227
|
-
goalKey: taskGoalCtx ? taskGoalCtx.goalKey || '' : '',
|
|
228
|
-
check: goalCheck || '',
|
|
229
|
-
statusLine: goalStatus || '',
|
|
230
|
-
}
|
|
231
|
-
: null;
|
|
232
|
-
const attach = att ? attachTemplateCtx(att.task.attachments).attach : null;
|
|
233
|
-
|
|
234
|
-
// 「持续 get」指令模板自身也是模板(可含 {{task.id}} 等):先渲染成文本,
|
|
235
|
-
// 再由 getloop 插件放进 ctx。渲染失败记告警(不静默)。
|
|
236
|
-
// 注:渲染上下文用 seed(task / goal / cwd…)——默认指令只引用 task.id /
|
|
237
|
-
// getloop.waitMinutes;历史 baseCtx 里的 repo/attach 变量不进入项目级收尾指令。
|
|
238
|
-
const renderWarnings: { block: string; label: string; message: string }[] = [];
|
|
239
|
-
// 平面扩展(原 buildDeliveryCtx 语义):外部参数 {{k}} 顶层直接取,内建键不被覆盖
|
|
240
|
-
const flat: Record<string, unknown> = {};
|
|
241
|
-
for (const [k, v] of Object.entries(params || {})) {
|
|
242
|
-
if (['task', 'goal', 'cwd', 'source', 'summary', 'name', 'repo', 'group', 'refRepos', 'groups'].includes(k)) continue;
|
|
243
|
-
flat[k] = v;
|
|
244
|
-
}
|
|
245
|
-
const seedCtx: Record<string, any> = {
|
|
246
|
-
task: task ? { id: task.id, text: reorderRoundsForDelivery(String(task.text || '')) } : null,
|
|
247
|
-
goal: goalCtx,
|
|
248
|
-
source: source || '',
|
|
249
|
-
summary: summary || '',
|
|
250
|
-
cwd: cwd || '',
|
|
251
|
-
name: name || '',
|
|
252
|
-
params: { ...(params || {}) },
|
|
253
|
-
...flat,
|
|
254
|
-
};
|
|
255
|
-
let loopText = '';
|
|
256
|
-
if (getLoopTpl) {
|
|
257
|
-
try {
|
|
258
|
-
loopText = renderInstruction(getLoopTpl, seedCtx) || '';
|
|
259
|
-
} catch (e) {
|
|
260
|
-
renderWarnings.push({
|
|
261
|
-
block: 'getloop',
|
|
262
|
-
label: '持续 get 指令(项目级)',
|
|
263
|
-
message: String((e as Error).message || e).replace(/\s+/g, ' ').trim(),
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// ext(队列余量):同主题还有多少待领取任务 + 标题。现算(同主题一次读取);
|
|
269
|
-
// 读取失败不阻断领取:按缺失处理,并把原因记进 renderWarnings。
|
|
270
|
-
let queueInfo: { topic: string; count: number; list: { id: number; title: string }[] } | null = null;
|
|
271
|
-
try {
|
|
272
|
-
const q = await pendingQueueInfo(topicKey as string, task && task.id);
|
|
273
|
-
if (q && q.count > 0) queueInfo = { topic: q.topic, count: q.count, list: q.list };
|
|
274
|
-
} catch (e) {
|
|
275
|
-
renderWarnings.push({
|
|
276
|
-
block: 'ext',
|
|
277
|
-
label: '待领取队列(ext)',
|
|
278
|
-
message: String((e as Error).message || e).replace(/\s+/g, ' ').trim(),
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
const mode: 'xml' | 'plain' = settings.appendMode === 'plain' ? 'plain' : 'xml';
|
|
283
|
-
// #152:模板是插件类的内置正文(不再从 settings 解析)。
|
|
284
|
-
// 交付一次给全三条链(get → check → done,合并后按类声明的 order 全局排序):
|
|
285
|
-
// - check(时间目标 / 进度提示)与 done(完成门禁)没有独立的注入点——
|
|
286
|
-
// 它们本来就是「领取时告诉 agent 每轮怎么检查、什么时候才能收口」,
|
|
287
|
-
// 等 agent 真去 done 再给已经晚了;三者链内都是条件渲染,无数据即不出段。
|
|
288
|
-
const plugins = [...buildPlugins('get', {
|
|
289
|
-
groupCtx: () => groupCtx,
|
|
290
|
-
attach: () => attach,
|
|
291
|
-
queueInfo: () => queueInfo,
|
|
292
|
-
loopText: () => loopText,
|
|
293
|
-
waitMinutes: () => Number(getLoopWaitMinutes) || 0,
|
|
294
|
-
}), ...buildPlugins('check'), ...buildPlugins('done')];
|
|
295
|
-
const segments: SegmentMeta[] = [
|
|
296
|
-
{ id: 'context', label: '组 / 项目上下文(模板)', traceId: 'delivery' },
|
|
297
|
-
{ id: 'attachment', label: '附件段(清单 / 本地路径)', traceId: 'attach' },
|
|
298
|
-
{ id: 'timecheck', label: '时间目标(状态 / check 指令)', traceId: 'goal' },
|
|
299
|
-
{ id: 'goalhint', label: '特殊功能提示(timegoal)', traceId: 'goalhint' },
|
|
300
|
-
{ id: 'doneguard', label: '完成门禁提示(timegoal)', traceId: 'doneguard' },
|
|
301
|
-
{ id: 'ext', label: '待领取队列(ext)', traceId: 'ext' },
|
|
302
|
-
{ id: 'ack', label: 'ack 完成总结提示词', traceId: 'ack' },
|
|
303
|
-
{ id: 'getloop', label: '持续 get 指令(项目级)', traceId: 'getloop' },
|
|
304
|
-
];
|
|
305
|
-
const full = await compose({
|
|
306
|
-
plugins,
|
|
307
|
-
groups: ['get', 'check', 'done'],
|
|
308
|
-
seed: seedCtx,
|
|
309
|
-
mode,
|
|
310
|
-
trace,
|
|
311
|
-
segments,
|
|
312
|
-
});
|
|
313
|
-
const warnField = renderWarnings.length ? { renderWarnings } : {};
|
|
314
|
-
if (!full) {
|
|
315
|
-
return { task, ...warnField };
|
|
316
|
-
}
|
|
317
|
-
// coversBody = 本次交付链的任一模板含 {{task.text}}(instruction 自包含任务正文)。
|
|
318
|
-
// 由服务端判定,避免 CLI 端做子串猜测。
|
|
319
|
-
return {
|
|
320
|
-
task,
|
|
321
|
-
instruction: full,
|
|
322
|
-
coversBody: plugins.some((p) => /\{\{\s*task\.text\s*\}\}/.test(p.get())),
|
|
323
|
-
...warnField,
|
|
324
|
-
};
|
|
325
|
-
} catch {
|
|
326
|
-
return { task };
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
62
|
export interface WaitForTaskOptions {
|
|
331
63
|
/** 工作目录(主题按目录名识别);缺省 → 进程当前 cwd。显式传 cwd **不会**关闭全局兜底 */
|
|
332
64
|
cwd?: unknown;
|
|
@@ -344,8 +76,8 @@ export interface WaitForTaskOptions {
|
|
|
344
76
|
params?: Record<string, string>;
|
|
345
77
|
/** get 的「直接领」形态:没有 pending 立即空手而回,不开窗不阻塞 */
|
|
346
78
|
instant?: boolean;
|
|
347
|
-
/** 项目级「持续 get
|
|
348
|
-
|
|
79
|
+
/** 项目级「持续 get」开关(仅 get/preview 传;wait 不传 → 不出现该区块) */
|
|
80
|
+
getLoopEnabled?: boolean;
|
|
349
81
|
/** 项目级阻塞窗口(分钟):进 getloop 模板 ctx,让 agent 知道每轮会等多久 */
|
|
350
82
|
getLoopWaitMinutes?: number;
|
|
351
83
|
}
|
|
@@ -370,7 +102,7 @@ export async function waitForTask({
|
|
|
370
102
|
onReady,
|
|
371
103
|
params = {}, // 外部参数(平面扩展):进交付模板的 ctx(--param k=v)
|
|
372
104
|
instant = false, // get 的「直接领」形态:没有 pending 立即空手而回,不开窗不阻塞
|
|
373
|
-
|
|
105
|
+
getLoopEnabled = false, // 项目级「持续 get」开关(仅 get/preview 传;wait 不传 → 不出现该区块)
|
|
374
106
|
getLoopWaitMinutes = 0, // 项目级阻塞窗口(分钟):进 getloop 模板 ctx,让 agent 知道每轮会等多久
|
|
375
107
|
}: WaitForTaskOptions = {}): Promise<Record<string, any>> {
|
|
376
108
|
// paths.normalizeCwd 的 @returns 标注漏了 name(运行时恒返回 {cwd, name, key})
|
|
@@ -395,7 +127,7 @@ export async function waitForTask({
|
|
|
395
127
|
// 1. 主题队列已有 pending → 立即取走,不开窗、不阻塞;记录本轮完成总结
|
|
396
128
|
const queued = await consumeFirstPending(key, summary, by);
|
|
397
129
|
if (queued) {
|
|
398
|
-
const delivery = await buildTaskDelivery(queued, { source: 'local', summary, cwd, name, topicKey: key, params,
|
|
130
|
+
const delivery = await buildTaskDelivery(queued, { source: 'local', summary, cwd, name, topicKey: key, params, getLoopEnabled, getLoopWaitMinutes });
|
|
399
131
|
return { status: 'ok', key, cwd, name, summary, ...delivery, queued: true, source: 'local', repo: repoCtx };
|
|
400
132
|
}
|
|
401
133
|
|
|
@@ -412,7 +144,7 @@ export async function waitForTask({
|
|
|
412
144
|
if (fromGlobal) {
|
|
413
145
|
// 全局池投递渲染的仍是**等待方目录**的 goal——目标绑定在等待中的 agent 目录上,
|
|
414
146
|
// 与任务来自哪个队列无关。
|
|
415
|
-
const delivery = await buildTaskDelivery(fromGlobal, { source: 'global', summary, cwd, name, topicKey: key, params,
|
|
147
|
+
const delivery = await buildTaskDelivery(fromGlobal, { source: 'global', summary, cwd, name, topicKey: key, params, getLoopEnabled, getLoopWaitMinutes });
|
|
416
148
|
return {
|
|
417
149
|
status: 'ok',
|
|
418
150
|
key,
|
|
@@ -532,7 +264,7 @@ export async function waitForTask({
|
|
|
532
264
|
// 只对拿到任务的结果生效——timeout/goal_expired/cancelled 的返回形状是钉死的契约,不动。
|
|
533
265
|
const delivery =
|
|
534
266
|
r.kind === 'task'
|
|
535
|
-
? await buildTaskDelivery(r.task, { source: r.source || 'local', summary, cwd, name, topicKey: key, params,
|
|
267
|
+
? await buildTaskDelivery(r.task, { source: r.source || 'local', summary, cwd, name, topicKey: key, params, getLoopEnabled, getLoopWaitMinutes })
|
|
536
268
|
: null;
|
|
537
269
|
result =
|
|
538
270
|
r.kind === 'timeout'
|
|
@@ -6,7 +6,7 @@ import { z } from 'zod';
|
|
|
6
6
|
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
7
|
import * as serviceNs from '../service.js';
|
|
8
8
|
import { } from 'node:path';
|
|
9
|
-
import {
|
|
9
|
+
import { parseScope } from '../support.js';
|
|
10
10
|
const service: any = serviceNs;
|
|
11
11
|
|
|
12
12
|
/** templates.default 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
@@ -14,7 +14,6 @@ const input = z.object({
|
|
|
14
14
|
id: z.string(),
|
|
15
15
|
name: z.string().optional().describe("新名字(配合 --body/--scope 时改默认模板本身)"),
|
|
16
16
|
body: z.string().optional().describe("新正文(配合时改默认模板本身)"),
|
|
17
|
-
values: z.unknown().optional().describe("槽位值 JSON(CLI 传 JSON 串;HTTP 可直接给对象)"),
|
|
18
17
|
scope: z.unknown().optional().describe("可见域(#128):* / topic:<key> / repo:<key> / group:<key>,JSON 数组或逗号短写"),
|
|
19
18
|
});
|
|
20
19
|
|
|
@@ -31,14 +30,12 @@ export class TemplatesDefaultAction extends ActionBase<typeof input> {
|
|
|
31
30
|
override async run(ctx: ActionInput<this['_input']>) {
|
|
32
31
|
|
|
33
32
|
if (
|
|
34
|
-
ctx.body !== undefined || ctx.name !== undefined ||
|
|
35
|
-
ctx.values !== undefined || ctx.scope !== undefined
|
|
33
|
+
ctx.body !== undefined || ctx.name !== undefined || ctx.scope !== undefined
|
|
36
34
|
) {
|
|
37
35
|
return service.updateTemplate({
|
|
38
36
|
id: ctx.id || 'default',
|
|
39
37
|
name: ctx.name,
|
|
40
38
|
body: ctx.body,
|
|
41
|
-
values: parseValues(ctx.values),
|
|
42
39
|
scope: parseScope(ctx.scope),
|
|
43
40
|
});
|
|
44
41
|
}
|
|
@@ -6,7 +6,7 @@ import { z } from 'zod';
|
|
|
6
6
|
import { ActionBase, type ActionInput, type ActionRunMeta } from '../../../runtime/action-base.js';
|
|
7
7
|
import * as serviceNs from '../service.js';
|
|
8
8
|
import { } from 'node:path';
|
|
9
|
-
import { parseScope
|
|
9
|
+
import { parseScope } from '../support.js';
|
|
10
10
|
const service: any = serviceNs;
|
|
11
11
|
|
|
12
12
|
/** templates.update 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
@@ -17,7 +17,6 @@ const input = z.object({
|
|
|
17
17
|
bodyFile: z.string().optional().describe("从文件读新正文(--body 优先);`-` = 读标准输入"),
|
|
18
18
|
'body-file': z.string().optional().describe("同 --bodyFile(连字符写法)"),
|
|
19
19
|
scope: z.unknown().optional().describe("可见域(#128):* / topic:<key> / repo:<key> / group:<key>,JSON 数组或逗号短写(不传保持不变)"),
|
|
20
|
-
values: z.string().optional().describe("槽位值 JSON(形如 {\"背景\":\"要做的事\"})——老模板正文里的 {{槽位名}} 处填这段文字(新模板直接写正文即可)"),
|
|
21
20
|
});
|
|
22
21
|
|
|
23
22
|
export class TemplatesUpdateAction extends ActionBase<typeof input> {
|
|
@@ -38,7 +37,6 @@ export class TemplatesUpdateAction extends ActionBase<typeof input> {
|
|
|
38
37
|
body: ctx.body,
|
|
39
38
|
bodyFile: opts && opts.transport === 'http' ? undefined : (ctx.bodyFile ?? ctx['body-file']),
|
|
40
39
|
scope: parseScope(ctx.scope),
|
|
41
|
-
values: parseValues(ctx.values),
|
|
42
40
|
});
|
|
43
41
|
|
|
44
42
|
}
|
|
@@ -6,15 +6,14 @@
|
|
|
6
6
|
//
|
|
7
7
|
// 内置模板(`builtin=1`,由 core/db/seed-templates 在开库时 INSERT OR IGNORE
|
|
8
8
|
// seed,永远在场):**不可删,可编辑**。T06 起骨架也可改 —— 用户改了
|
|
9
|
-
// builtin 的 body
|
|
9
|
+
// builtin 的 body 改后重启原样保留(seed 是 OR IGNORE,绝不覆盖用户编辑)。
|
|
10
10
|
// #137:出厂正文只有**一份**(core/db/seed-templates 的 NEWTASK_REF_BODY,
|
|
11
11
|
// 即新建任务模板「ref 生成」);前端不再自带第二份副本(漂移的根源)。
|
|
12
12
|
//
|
|
13
13
|
// ── 与 schema 列的映射 ────────────────────────────────────────────────
|
|
14
14
|
// 旧 JSON 字段 → 列
|
|
15
|
-
// values
|
|
16
|
-
//
|
|
17
|
-
// vars 填值,声明里不放默认值)
|
|
15
|
+
// values(旧数据对象) → vars(JSON;**列名换了**,对外视图仍叫 values ——
|
|
16
|
+
// DB 兼容列,插槽机制移除后恒为空对象)
|
|
18
17
|
// builtin → builtin 列
|
|
19
18
|
// defaultId → 同类目 `is_default=1` 的那行(ux_templates_default
|
|
20
19
|
// 保证每类目最多一个默认;**没有**另落 settings 键 ——
|
|
@@ -66,9 +65,9 @@ const NEWTASK_CATEGORY = 'newtask';
|
|
|
66
65
|
|
|
67
66
|
const repo = repoLayer;
|
|
68
67
|
|
|
69
|
-
// #137:内置只有一份出厂文本(新建任务模板「ref
|
|
70
|
-
// 槽位默认值不再需要(出厂文本里没有 {{槽位}} 标记)。
|
|
68
|
+
// #137:内置只有一份出厂文本(新建任务模板「ref 生成」)。空正文兜底用它。
|
|
71
69
|
export const BUILTIN_BODY = NEWTASK_REF_BODY;
|
|
70
|
+
/** DB vars 列兼容位:始终空对象(模板已无插槽机制)。 */
|
|
72
71
|
export const BUILTIN_VALUES: Record<string, string> = {};
|
|
73
72
|
|
|
74
73
|
// ─── 视图:行 ⇄ 旧 JSON 形状(调用方消费的是 values/builtin 这些旧字段)──
|
|
@@ -178,9 +177,8 @@ function normalizeBody(raw: unknown): string {
|
|
|
178
177
|
}
|
|
179
178
|
|
|
180
179
|
/**
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
* 正文里当 {{名字}},名字太长就没法当占位符用了。
|
|
180
|
+
* 归一化模板的 vars(DB 兼容字段,对外仍叫 values);仅留字符串、逐条截断。
|
|
181
|
+
* 插槽机制已移除,调用方不再传值,此处只保证写库形状合法。
|
|
184
182
|
*/
|
|
185
183
|
export function normalizeValues(raw: unknown, base: any = {}): Record<string, string> {
|
|
186
184
|
const out: Record<string, string> = { ...base };
|
|
@@ -261,7 +259,7 @@ export async function addTemplate({
|
|
|
261
259
|
id: 't_' + crypto.randomBytes(5).toString('hex'),
|
|
262
260
|
name,
|
|
263
261
|
body,
|
|
264
|
-
//
|
|
262
|
+
// DB vars 列兼容:无调用方传值,写空对象
|
|
265
263
|
values: normalizeValues(values),
|
|
266
264
|
};
|
|
267
265
|
repo.templates.insertIfAbsent(conn, {
|
|
@@ -318,7 +316,7 @@ export async function removeTemplate({ id }: { id?: unknown } = {}): Promise<{
|
|
|
318
316
|
});
|
|
319
317
|
}
|
|
320
318
|
|
|
321
|
-
/** 编辑模板(改名 / 改正文 /
|
|
319
|
+
/** 编辑模板(改名 / 改正文 / 改可见域;只改传入的字段)。 */
|
|
322
320
|
export async function updateTemplate({ id, name: rawName, body: rawBody, bodyFile, values, scope: rawScope }: {
|
|
323
321
|
id?: unknown;
|
|
324
322
|
name?: unknown;
|
|
@@ -338,8 +336,8 @@ export async function updateTemplate({ id, name: rawName, body: rawBody, bodyFil
|
|
|
338
336
|
if (bodyIn !== undefined) patch.body = normalizeBody(bodyIn);
|
|
339
337
|
if (rawScope !== undefined) patch.scope = normalizeScope(rawScope, { strict: true });
|
|
340
338
|
if (values !== undefined) {
|
|
341
|
-
//
|
|
342
|
-
patch.vars = normalizeValues(values,
|
|
339
|
+
// DB vars 列兼容写入;插槽机制已移除,无调用方传值
|
|
340
|
+
patch.vars = normalizeValues(values, BUILTIN_VALUES);
|
|
343
341
|
}
|
|
344
342
|
repo.templates.updateRow(conn, want, patch, nowMs());
|
|
345
343
|
return { status: 'ok', template: rowToView(repo.templates.getRow(want, conn)) };
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
// 参数与返回值暂用宽松类型(迁移期),服务层类型化推进时逐个收紧。
|
|
4
4
|
import { topicKeyOf } from '../../core/topic-key.js';
|
|
5
5
|
import { resolve as resolvePath } from 'node:path';
|
|
6
|
-
import { badInput } from '../../core/errors.js';
|
|
7
6
|
|
|
8
7
|
export const renderList: any = (d: any) => {
|
|
9
8
|
const lines: any = [`模板 ${d.templates.length} 个(默认: ${d.defaultId})`];
|
|
@@ -31,17 +30,3 @@ export function topicFromCwd(raw: any) {
|
|
|
31
30
|
if (!s) return undefined;
|
|
32
31
|
return topicKeyOf(resolvePath(s), '');
|
|
33
32
|
}
|
|
34
|
-
|
|
35
|
-
export function parseValues(raw: any) {
|
|
36
|
-
if (raw === undefined || raw === null) return undefined;
|
|
37
|
-
if (typeof raw === 'object') return raw;
|
|
38
|
-
const s: any = String(raw).trim();
|
|
39
|
-
if (!s) return undefined;
|
|
40
|
-
try {
|
|
41
|
-
const v: any = JSON.parse(s);
|
|
42
|
-
if (!v || typeof v !== 'object' || Array.isArray(v)) throw new Error('不是对象');
|
|
43
|
-
return v;
|
|
44
|
-
} catch (e: any) {
|
|
45
|
-
throw badInput(`--values 要传 JSON 对象(形如 {"背景":"要做的事"}):${e.message || e}`);
|
|
46
|
-
}
|
|
47
|
-
}
|
package/src/web/frontend/App.tsx
CHANGED
|
@@ -128,18 +128,6 @@ function routeFromHash(): AppRoute {
|
|
|
128
128
|
scope: '',
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
|
-
// #151:参数填写中间页(#/templates/fill/<sessionId>,会话在内存里)
|
|
132
|
-
if (rest.startsWith('fill/')) {
|
|
133
|
-
return {
|
|
134
|
-
view: 'templates',
|
|
135
|
-
key: '',
|
|
136
|
-
task: '',
|
|
137
|
-
mode: 'fill',
|
|
138
|
-
id: decodeURIComponent(rest.slice(5)),
|
|
139
|
-
topic: '',
|
|
140
|
-
scope: '',
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
131
|
if (rest === 'new') {
|
|
144
132
|
return {
|
|
145
133
|
view: 'templates',
|
|
@@ -2148,6 +2148,64 @@
|
|
|
2148
2148
|
"http": "GET /api/prompt/registry"
|
|
2149
2149
|
},
|
|
2150
2150
|
"children": []
|
|
2151
|
+
},
|
|
2152
|
+
{
|
|
2153
|
+
"name": "template",
|
|
2154
|
+
"path": [
|
|
2155
|
+
"prompt",
|
|
2156
|
+
"template"
|
|
2157
|
+
],
|
|
2158
|
+
"action": null,
|
|
2159
|
+
"children": [
|
|
2160
|
+
{
|
|
2161
|
+
"name": "activate",
|
|
2162
|
+
"path": [
|
|
2163
|
+
"prompt",
|
|
2164
|
+
"template",
|
|
2165
|
+
"activate"
|
|
2166
|
+
],
|
|
2167
|
+
"action": {
|
|
2168
|
+
"id": "prompt.template.activate",
|
|
2169
|
+
"module": "promptplug",
|
|
2170
|
+
"summary": "切换提示词段启用的模板(builtin 或用户条目)",
|
|
2171
|
+
"usage": "prompt template activate",
|
|
2172
|
+
"http": "POST /api/prompt/template/activate"
|
|
2173
|
+
},
|
|
2174
|
+
"children": []
|
|
2175
|
+
},
|
|
2176
|
+
{
|
|
2177
|
+
"name": "delete",
|
|
2178
|
+
"path": [
|
|
2179
|
+
"prompt",
|
|
2180
|
+
"template",
|
|
2181
|
+
"delete"
|
|
2182
|
+
],
|
|
2183
|
+
"action": {
|
|
2184
|
+
"id": "prompt.template.delete",
|
|
2185
|
+
"module": "promptplug",
|
|
2186
|
+
"summary": "删除提示词段的用户模板(启用中的删除后回落 builtin)",
|
|
2187
|
+
"usage": "prompt template delete",
|
|
2188
|
+
"http": "POST /api/prompt/template/delete"
|
|
2189
|
+
},
|
|
2190
|
+
"children": []
|
|
2191
|
+
},
|
|
2192
|
+
{
|
|
2193
|
+
"name": "save",
|
|
2194
|
+
"path": [
|
|
2195
|
+
"prompt",
|
|
2196
|
+
"template",
|
|
2197
|
+
"save"
|
|
2198
|
+
],
|
|
2199
|
+
"action": {
|
|
2200
|
+
"id": "prompt.template.save",
|
|
2201
|
+
"module": "promptplug",
|
|
2202
|
+
"summary": "保存提示词段模板(新建/编辑用户条目;保存前按该段变量白名单校验)",
|
|
2203
|
+
"usage": "prompt template save",
|
|
2204
|
+
"http": "POST /api/prompt/template/save"
|
|
2205
|
+
},
|
|
2206
|
+
"children": []
|
|
2207
|
+
}
|
|
2208
|
+
]
|
|
2151
2209
|
}
|
|
2152
2210
|
]
|
|
2153
2211
|
},
|