pi-web-ui 0.114.0 → 0.114.1
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 +28 -0
- package/README.md +187 -187
- package/README.zh-CN.md +227 -227
- package/README.zh-TW.md +227 -227
- package/bin/device-hub-cli.mjs +577 -577
- package/bin/frp-manager.mjs +1573 -1573
- package/bin/pi-device-hub.mjs +9 -9
- package/bin/pi-web-ui.mjs +4081 -4073
- package/deploy/nginx-subpath.conf +100 -100
- package/deploy/pi-web-ui.service +36 -36
- package/dist/server/agent-service.js +131 -55
- package/dist/server/attachments.js +51 -5
- package/dist/server/canvas/canvas-agent-tool.js +3 -3
- package/dist/server/canvas/canvas-cards.js +1 -1
- package/dist/server/canvas/canvas-orchestrator.js +3 -3
- package/dist/server/canvas/canvas-scheduled-task.js +45 -0
- package/dist/server/canvas/canvas-validation.js +1 -1
- package/dist/server/client-state.js +6 -2
- package/dist/server/compaction-instructions.js +8 -8
- package/dist/server/device-center/connector.js +33 -14
- package/dist/server/device-center/desktop-page.js +228 -228
- package/dist/server/device-center/hub-page.js +64 -64
- package/dist/server/device-center/hub.js +2 -1
- package/dist/server/device-center/local-hub.js +92 -0
- package/dist/server/device-center/local.js +60 -7
- package/dist/server/device-center/native-desktop/macos.js +190 -190
- package/dist/server/device-center/native-desktop/windows.js +116 -116
- package/dist/server/device-center/path-portal.js +1 -1
- package/dist/server/device-center/relay.js +45 -8
- package/dist/server/dispatch-domain-handlers.js +1 -0
- package/dist/server/dsh/dsh-agent-service.js +5 -1
- package/dist/server/dsh/runtime/cordis.yml +1 -1
- package/dist/server/dsh/runtime/custom-prompt.mjs +33 -33
- package/dist/server/dsh/runtime/goal-rpc.mjs +1309 -1309
- package/dist/server/dsh/runtime/launcher.mjs +235 -235
- package/dist/server/dsh/runtime/override.patch.yml +89 -89
- package/dist/server/dsh/runtime/runtime-root.mjs +405 -405
- package/dist/server/engine-probe.js +36 -6
- package/dist/server/eval-tool.js +135 -135
- package/dist/server/global-loader.js +40 -2
- package/dist/server/index.js +56 -32
- package/dist/server/patch-bash-process.js +125 -0
- package/dist/server/patch-tool.js +9 -9
- package/dist/server/patch-turn-end-boundary.js +3 -3
- package/dist/server/persona-chain.js +8 -8
- package/dist/server/plugins.js +26 -2
- package/dist/server/preset-fields.js +7 -0
- package/dist/server/preset-share.js +1 -0
- package/dist/server/prompt-templates.js +106 -0
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/remote-ssh-service.js +39 -39
- package/dist/server/resolve-global-sdk.js +2 -0
- package/dist/server/schedule-agent-tool.js +39 -21
- package/dist/server/scheduler-tasks.js +45 -9
- package/dist/server/scm-commitmsg.js +10 -10
- package/dist/server/settings-service.js +6 -0
- package/dist/server/setup-page.js +620 -620
- package/dist/server/text-quote.js +9 -0
- package/dist/server/tool-manager.js +2 -1
- package/dist/server/universal/drivers/claude-code.js +5 -0
- package/dist/server/universal/drivers/codex.js +336 -0
- package/dist/server/universal/index.js +1 -0
- package/dist/server/universal/universal-attachments.js +24 -1
- package/dist/server/universal/universal-session.js +23 -0
- package/dist/server/vision-bridge.js +18 -18
- package/docs/device-center.md +148 -142
- package/docs/device-desktop.md +48 -48
- package/docs/dsh-engine.md +493 -493
- package/extensions/webui.ts +335 -335
- package/package.json +2 -2
- package/plugin-sdk/README.md +174 -174
- package/plugin-sdk/client-utils.mjs +279 -279
- package/plugin-sdk/import-check.mjs +210 -210
- package/plugin-sdk/index.d.ts +698 -698
- package/plugin-sdk/index.mjs +696 -696
- package/plugin-sdk/package.json +13 -13
- package/plugin-sdk/ssh-host-trust.mjs +225 -225
- package/plugins/catalog.json +10 -0
- package/themes/aetheris.css +501 -501
- package/themes/ayu-light.css +116 -116
- package/themes/bases/flow-base.css +1357 -1357
- package/themes/bases/obsidian-base.css +895 -895
- package/themes/bases/statusbar-flat-base.css +112 -112
- package/themes/bases/zhujian-base.css +688 -688
- package/themes/bases/zhupi-base.css +660 -660
- package/themes/catppuccin-latte.css +119 -119
- package/themes/catppuccin.css +116 -116
- package/themes/claude-code-dark.css +147 -147
- package/themes/codex.css +114 -114
- package/themes/cyberpunk.css +50 -50
- package/themes/dark-teal.css +264 -264
- package/themes/dazzle.css +38 -38
- package/themes/everforest-light.css +115 -115
- package/themes/flow-light.css +164 -164
- package/themes/flow.css +161 -161
- package/themes/geist.css +114 -114
- package/themes/gruvbox-light.css +115 -115
- package/themes/kanagawa-lotus.css +115 -115
- package/themes/md-preview.css +24 -24
- package/themes/mist.css +166 -166
- package/themes/nord.css +107 -107
- package/themes/one-dark.css +106 -106
- package/themes/paper.css +174 -174
- package/themes/rose-pine-dawn.css +114 -114
- package/themes/sakura.css +166 -166
- package/themes/solarized-light.css +114 -114
- package/themes/tokyo-night.css +115 -115
- package/themes/translucent.css +85 -85
- package/themes/transparent.css +116 -116
- package/themes/vs-code-dark.css +147 -147
- package/themes/wallpaper-flow.css +382 -382
- package/themes/wallpaper-obsidian.css +74 -74
- package/themes/white.css +164 -164
- package/themes/zhujian-dark.css +115 -115
- package/themes/zhujian.css +114 -114
- package/themes/zhupi-dark.css +115 -115
- package/themes/zhupi.css +114 -114
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/BgTasksModal-BcXJ20RO.js +1 -0
- package/web/dist/assets/BgTasksModal-DjQmiKnE.js +1 -0
- package/web/dist/assets/{CanvasStudio-BEJZE5BI.js → CanvasStudio-PI9pid0Y.js} +3 -3
- package/web/dist/assets/{CanvasStudio-CgUNHqos.js → CanvasStudio-nf5-HxLM.js} +3 -3
- package/web/dist/assets/DeviceCenter-CYttJw2a.js +3 -0
- package/web/dist/assets/DeviceCenter-DPe4sz74.js +3 -0
- package/web/dist/assets/DeviceGroups-D2rogxEN.js +1 -0
- package/web/dist/assets/Dropdown-ZLS04O8p.js +1 -0
- package/web/dist/assets/FilePreview-C9Ut4Lq6.js +2 -0
- package/web/dist/assets/FilePreview-CvK3ZzX5.js +2 -0
- package/web/dist/assets/GlobalSearchModal-C5e-OCw2.js +1 -0
- package/web/dist/assets/GlobalSearchModal-H7pFK2UC.js +1 -0
- package/web/dist/assets/GroupConversation-C2wNM0dQ.js +1 -0
- package/web/dist/assets/GroupConversation-ChN3TWQK.js +1 -0
- package/web/dist/assets/ModelConfigModal-DDZccDYt.js +2 -0
- package/web/dist/assets/PiSetupModal-DHbqfx8T.js +1 -0
- package/web/dist/assets/ProviderOAuthControls-C-MK36Dk.js +1 -0
- package/web/dist/assets/SCMPanel-buTGziDB.js +2 -0
- package/web/dist/assets/SCMPanel-kx-SCL2s.js +2 -0
- package/web/dist/assets/SettingsModal-BsUF8jqr.js +20 -0
- package/web/dist/assets/SettingsModal-D357Ky7P.js +20 -0
- package/web/dist/assets/{TerminalPanel-DL20uKgU.js → TerminalPanel-BBuM_Sez.js} +2 -2
- package/web/dist/assets/{TerminalPanel-D6cPRFei.js → TerminalPanel-D6x6xz8Q.js} +2 -2
- package/web/dist/assets/TuiOverlayModal-CdbGV3Za.js +1 -0
- package/web/dist/assets/TuiOverlayModal-d6x9u25n.js +1 -0
- package/web/dist/assets/app-globals-DcyO0UPi.js +1 -0
- package/web/dist/assets/{desktop-DPyTy4M3.js → desktop-YguLbrX1.js} +1 -1
- package/web/dist/assets/fi-DaSO0Q-m.js +325 -0
- package/web/dist/assets/index-BPvpea8t.js +85 -0
- package/web/dist/assets/index-D6u8xH0o.js +85 -0
- package/web/dist/assets/index-DDZMv6LO.css +1 -0
- package/web/dist/assets/{plugin-host-CqA4yW6w.js → plugin-host-BRBg6zmQ.js} +1 -1
- package/web/dist/assets/theme-DDl-Oy1b.js +1 -0
- package/web/dist/index.html +37 -36
- package/web/dist/sw.js +179 -179
- package/web/public/sw.js +179 -179
- package/dist/gh-comment-781.md +0 -5
- package/dist/server/device-center/local-page.js +0 -17
- package/dist/server/device-center/smoke-preview.js +0 -3
- package/dist/server/durable/durable-capabilities.js +0 -11
- package/dist/server/markers/builtins/services.js +0 -123
- package/dist/server/markers/builtins/todo.js +0 -189
- package/dist/server/markers-list-tool.js +0 -34
- package/dist/server/orchestrator.js +0 -109
- package/dist/server/system-prompt-soul.js +0 -41
- package/dist/server/univer-service.js +0 -448
- package/dist/server/universal/drivers/dsh-driver.js +0 -379
- package/dist/test-artifact.md +0 -9
- package/dist/test-preview-modal.md +0 -11
- package/dist/test-report.html +0 -20
- package/web/dist/assets/BgTasksModal-CS7UNzcw.js +0 -1
- package/web/dist/assets/BgTasksModal-Dk-tp78W.js +0 -1
- package/web/dist/assets/DeviceCenter-C8_CbxQ3.js +0 -3
- package/web/dist/assets/DeviceCenter-CVblvhNX.js +0 -3
- package/web/dist/assets/Dropdown-Oug0DDte.js +0 -1
- package/web/dist/assets/FilePreview-CvdX6nr6.js +0 -2
- package/web/dist/assets/FilePreview-kCZhfBAF.js +0 -2
- package/web/dist/assets/GlobalSearchModal-BLH63yYP.js +0 -1
- package/web/dist/assets/GlobalSearchModal-DAkvlvp6.js +0 -1
- package/web/dist/assets/GroupConversation-Cgo4xbpa.js +0 -1
- package/web/dist/assets/GroupConversation-DZ71jEi8.js +0 -1
- package/web/dist/assets/ModelConfigModal-BpWdFdQC.js +0 -2
- package/web/dist/assets/PiSetupModal-mkWPSxMj.js +0 -1
- package/web/dist/assets/ProviderOAuthControls-VK_jqXYS.js +0 -1
- package/web/dist/assets/SCMPanel-BP1TUT-V.js +0 -2
- package/web/dist/assets/SCMPanel-BscPm9kf.js +0 -2
- package/web/dist/assets/SettingsModal-C8UgMjVM.js +0 -20
- package/web/dist/assets/SettingsModal-VynB7jNb.js +0 -20
- package/web/dist/assets/TuiOverlayModal-Dst3BmT8.js +0 -1
- package/web/dist/assets/TuiOverlayModal-NCkpNtTp.js +0 -1
- package/web/dist/assets/UniversalPathPicker-CfQFc_c3.js +0 -1
- package/web/dist/assets/UniversalPathPicker-DwxwNcFw.js +0 -1
- package/web/dist/assets/app-globals-CnO6KlEM.js +0 -325
- package/web/dist/assets/index-CPgAH5q7.js +0 -83
- package/web/dist/assets/index-Cje8iugL.js +0 -83
- package/web/dist/assets/index-DnKeiDbj.css +0 -1
- package/web/dist/assets/theme-BqdAjEjF.js +0 -1
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* builtins/todo.ts — 内置任务标记(复刻 pi-marker-tools)。
|
|
3
|
-
*/
|
|
4
|
-
import { getServerBlock, pick } from "../../i18n.js";
|
|
5
|
-
export const TODO_NAMESPACE = "todo";
|
|
6
|
-
export function initTodoState() {
|
|
7
|
-
return { tasks: [], nextId: 1 };
|
|
8
|
-
}
|
|
9
|
-
function findTask(state, id) {
|
|
10
|
-
return state.tasks.find((t) => t.id === id && t.status !== "deleted");
|
|
11
|
-
}
|
|
12
|
-
function parseId(raw) {
|
|
13
|
-
if (raw === undefined)
|
|
14
|
-
return null;
|
|
15
|
-
const n = Number(raw);
|
|
16
|
-
return Number.isInteger(n) && n > 0 ? n : null;
|
|
17
|
-
}
|
|
18
|
-
const TODO_GUIDANCE_ZH = [
|
|
19
|
-
"- 标记语法:[[todo:new:<主题>]] 新建;[[todo:set:<id>,completed|in_progress|pending]] 状态;[[todo:remove:<id>]] 删除;[[todo:dep:<id>,blocks=<依赖id,逗号分隔>]] 设依赖。",
|
|
20
|
-
"- 状态变化全部用上面的 [[todo:...]] 内联标记表达,不会中断回答,无需等待返回。",
|
|
21
|
-
"- 想查看/list 当前任务列表时,才用 `todo_list` 工具(读操作走工具)。",
|
|
22
|
-
"- 不要编造不存在的任务 id;id 由 [[todo:new:...]] 分配,首次分配是自增整数。",
|
|
23
|
-
];
|
|
24
|
-
const TODO_GUIDANCE_EN = [
|
|
25
|
-
"- Marker syntax: [[todo:new:<subject>]] to create; [[todo:set:<id>,completed|in_progress|pending]] for status; [[todo:remove:<id>]] to delete; [[todo:dep:<id>,blocks=<dep ids, comma-separated>]] to set dependencies.",
|
|
26
|
-
"- Express all status changes with the [[todo:...]] inline markers above; they never interrupt your reply and need no waiting for a result.",
|
|
27
|
-
"- Only use the `todo_list` tool (the read path goes through the tool) when you want to list the current tasks.",
|
|
28
|
-
"- Never invent task ids; ids are assigned by [[todo:new:...]], starting from incrementing integers.",
|
|
29
|
-
];
|
|
30
|
-
/** 语言感知的 todo guidance(issue #91):en 用英译、zh 用中文,默认英文。 */
|
|
31
|
-
export function getTodoGuidance(lang = "en") {
|
|
32
|
-
return getServerBlock(lang, "markers.todo.guidance", TODO_GUIDANCE_ZH, TODO_GUIDANCE_EN);
|
|
33
|
-
}
|
|
34
|
-
export const todoMarker = {
|
|
35
|
-
name: "todo",
|
|
36
|
-
guidance: TODO_GUIDANCE_ZH,
|
|
37
|
-
getGuidance: getTodoGuidance,
|
|
38
|
-
async apply(token, _ctx, _state, lang = "en") {
|
|
39
|
-
const state = _state;
|
|
40
|
-
const op = token.op;
|
|
41
|
-
switch (op) {
|
|
42
|
-
case "new": {
|
|
43
|
-
// #499:subject 是唯一「整段自由文本」参数——args.join 还原含逗号的主题,
|
|
44
|
-
// 否则 `[[todo:new:修复登录页,同步改注册页]]` 的后半段被静默丢弃。
|
|
45
|
-
const subject = token.args.join(",").trim();
|
|
46
|
-
if (!subject)
|
|
47
|
-
return {
|
|
48
|
-
applied: false,
|
|
49
|
-
error: pick(lang, "todo:new 需要一个主题参数 [[todo:new:<主题>]]", "todo:new requires a subject argument [[todo:new:<subject>]]", "markers.todo.new.requires.subject"),
|
|
50
|
-
};
|
|
51
|
-
const id = state.nextId++;
|
|
52
|
-
state.tasks.push({ id, subject, status: "pending", blockedBy: [], createdAt: Date.now() });
|
|
53
|
-
return {
|
|
54
|
-
applied: true,
|
|
55
|
-
feedback: pick(lang, `已创建 #${id}:${subject}(pending)`, `Created #${id}: ${subject} (pending)`, "markers.todo.new.created", { id: id, subject: subject }),
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
case "set": {
|
|
59
|
-
const id = parseId(token.args[0]);
|
|
60
|
-
if (id === null) {
|
|
61
|
-
const rawId = token.args[0] ?? "";
|
|
62
|
-
return {
|
|
63
|
-
applied: false,
|
|
64
|
-
error: pick(lang, `todo:set 的 id 无效: "${rawId}"`, `todo:set has an invalid id: "${rawId}"`, "markers.todo.set.invalid.id", { rawId: rawId }),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
const status = token.args[1]?.trim();
|
|
68
|
-
if (!status || !(status === "pending" || status === "in_progress" || status === "completed")) {
|
|
69
|
-
const statusText = status ?? "";
|
|
70
|
-
return {
|
|
71
|
-
applied: false,
|
|
72
|
-
error: pick(lang, `todo:set 状态无效: "${statusText}",应为 pending|in_progress|completed`, `todo:set has an invalid status: "${statusText}", expected pending|in_progress|completed`, "markers.todo.set.invalid.status", { statusText: statusText }),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
const task = findTask(state, id);
|
|
76
|
-
if (!task)
|
|
77
|
-
return {
|
|
78
|
-
applied: false,
|
|
79
|
-
error: pick(lang, `todo:set 任务 #${id} 不存在`, `todo:set task #${id} does not exist`, "markers.todo.set.task.missing", { id: id }),
|
|
80
|
-
};
|
|
81
|
-
const activeForm = token.kwargs["activeForm"];
|
|
82
|
-
const from = task.status;
|
|
83
|
-
if (status === "pending" && from === "completed") {
|
|
84
|
-
return {
|
|
85
|
-
applied: false,
|
|
86
|
-
error: pick(lang, `任务 #${id} 已完成,不能置回 pending`, `Task #${id} is completed and cannot be set back to pending`, "markers.todo.set.completed.no.pending", { id: id }),
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
if (status === "in_progress" && from === "completed") {
|
|
90
|
-
return {
|
|
91
|
-
applied: false,
|
|
92
|
-
error: pick(lang, `任务 #${id} 已完成,不能重新进行中`, `Task #${id} is completed and cannot be set back to in_progress`, "markers.todo.set.completed.no.inprogress", { id: id }),
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
task.status = status;
|
|
96
|
-
if (status === "in_progress" && activeForm)
|
|
97
|
-
task.activeForm = activeForm;
|
|
98
|
-
const change = from !== status ? ` (${from} → ${status})` : "";
|
|
99
|
-
return {
|
|
100
|
-
applied: true,
|
|
101
|
-
feedback: pick(lang, `已更新 #${id}${change}`, `Updated #${id}${change}`, "markers.todo.set.updated", {
|
|
102
|
-
id: id,
|
|
103
|
-
change: change,
|
|
104
|
-
}),
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
case "remove": {
|
|
108
|
-
const id = parseId(token.args[0]);
|
|
109
|
-
if (id === null) {
|
|
110
|
-
const rawId = token.args[0] ?? "";
|
|
111
|
-
return {
|
|
112
|
-
applied: false,
|
|
113
|
-
error: pick(lang, `todo:remove 的 id 无效: "${rawId}"`, `todo:remove has an invalid id: "${rawId}"`, "markers.todo.remove.invalid.id", { rawId: rawId }),
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
const task = findTask(state, id);
|
|
117
|
-
if (!task)
|
|
118
|
-
return {
|
|
119
|
-
applied: false,
|
|
120
|
-
error: pick(lang, `todo:remove 任务 #${id} 不存在`, `todo:remove task #${id} does not exist`, "markers.todo.remove.task.missing", { id: id }),
|
|
121
|
-
};
|
|
122
|
-
task.status = "deleted";
|
|
123
|
-
return {
|
|
124
|
-
applied: true,
|
|
125
|
-
feedback: pick(lang, `已删除 #${id}:${task.subject}`, `Deleted #${id}: ${task.subject}`, "markers.todo.remove.deleted", { id: id, "task.subject": task.subject }),
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
case "dep": {
|
|
129
|
-
const id = parseId(token.args[0]);
|
|
130
|
-
if (id === null) {
|
|
131
|
-
const rawId = token.args[0] ?? "";
|
|
132
|
-
return {
|
|
133
|
-
applied: false,
|
|
134
|
-
error: pick(lang, `todo:dep 的 id 无效: "${rawId}"`, `todo:dep has an invalid id: "${rawId}"`, "markers.todo.dep.invalid.id", { rawId: rawId }),
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
const task = findTask(state, id);
|
|
138
|
-
if (!task)
|
|
139
|
-
return {
|
|
140
|
-
applied: false,
|
|
141
|
-
error: pick(lang, `todo:dep 任务 #${id} 不存在`, `todo:dep task #${id} does not exist`, "markers.todo.dep.task.missing", { id: id }),
|
|
142
|
-
};
|
|
143
|
-
const depRaw = token.kwargs["blocks"] ?? token.args[1] ?? "";
|
|
144
|
-
const deps = depRaw
|
|
145
|
-
.split(",")
|
|
146
|
-
.map((x) => parseId(x.trim()))
|
|
147
|
-
.filter((x) => x !== null);
|
|
148
|
-
const bad = deps.filter((d) => d === id || !findTask(state, d));
|
|
149
|
-
if (bad.length) {
|
|
150
|
-
const badList = bad.join(",");
|
|
151
|
-
return {
|
|
152
|
-
applied: false,
|
|
153
|
-
error: pick(lang, `todo:dep 检测到非法依赖 ${badList}(不存在或自环)`, `todo:dep detected invalid dependencies ${badList} (missing or self-referencing)`, "markers.todo.dep.invalid.dependencies", { badList: badList }),
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
task.blockedBy = deps;
|
|
157
|
-
const depsText = deps.length ? deps.join(",") : lang === "zh" ? "(无)" : "(none)";
|
|
158
|
-
return {
|
|
159
|
-
applied: true,
|
|
160
|
-
feedback: pick(lang, `#${id} 依赖:${depsText}`,
|
|
161
|
-
// #499:实现是 blockedBy(deps 先完成)——原英文 "blocks" 把依赖方向说反了。
|
|
162
|
-
`#${id} is blocked by: ${depsText}`, "markers.todo.dep.blocks.updated", { id: id, depsText: depsText }),
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
default:
|
|
166
|
-
return {
|
|
167
|
-
applied: false,
|
|
168
|
-
error: pick(lang, `todo 未知操作: ${op}`, `todo unknown operation: ${op}`, "markers.todo.unknown.operation", {
|
|
169
|
-
op: op,
|
|
170
|
-
}),
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
overlay(state) {
|
|
175
|
-
if (!state || state.tasks.length === 0)
|
|
176
|
-
return undefined;
|
|
177
|
-
const visible = state.tasks.filter((t) => t.status !== "deleted");
|
|
178
|
-
if (visible.length === 0)
|
|
179
|
-
return undefined;
|
|
180
|
-
const done = visible.filter((t) => t.status === "completed").length;
|
|
181
|
-
const lines = visible.map((t) => {
|
|
182
|
-
const mark = t.status === "completed" ? "✓" : t.status === "in_progress" ? "◐" : "○";
|
|
183
|
-
const form = t.status === "in_progress" && t.activeForm ? ` (${t.activeForm})` : "";
|
|
184
|
-
return ` ${mark} #${t.id} ${t.subject}${form}`;
|
|
185
|
-
});
|
|
186
|
-
return { tool: "todo", lines: [`${done}/${visible.length} done`, ...lines] };
|
|
187
|
-
},
|
|
188
|
-
init: initTodoState,
|
|
189
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* markers-list-tool — 任务列表只读查询工具(todo_list)。
|
|
3
|
-
*
|
|
4
|
-
* 读操作仍走真工具;所有写操作由模型在回复正文中使用行内标记([[todo:new:...]] 等)。
|
|
5
|
-
* 从 agent-service.ts 抽出为独立模块。
|
|
6
|
-
*/
|
|
7
|
-
import { Type } from "typebox";
|
|
8
|
-
import { MARKERS_LIST_TOOL_NAME } from "./tool-manager.js";
|
|
9
|
-
export function makeMarkersListTool(getActiveId, markerSvc) {
|
|
10
|
-
return {
|
|
11
|
-
name: MARKERS_LIST_TOOL_NAME,
|
|
12
|
-
promptSnippet: "list inline-marker tasks (read-only; writes use [[todo:...]])",
|
|
13
|
-
label: "List marker state",
|
|
14
|
-
description: "Read-only query of inline marker state. All WRITE operations must use inline markers ([[todo:new:...]] etc.) in the reply body — never this tool.",
|
|
15
|
-
parameters: Type.Object({
|
|
16
|
-
action: Type.Unsafe({ type: "string", enum: ["list"] }),
|
|
17
|
-
tool: Type.Optional(Type.Literal("todo")),
|
|
18
|
-
includeDeleted: Type.Optional(Type.Boolean({
|
|
19
|
-
description: "Include deleted tasks (tombstones, todo only).",
|
|
20
|
-
})),
|
|
21
|
-
}),
|
|
22
|
-
execute: async (_id, params) => {
|
|
23
|
-
const p = params;
|
|
24
|
-
const convId = getActiveId();
|
|
25
|
-
const text = markerSvc.describe(convId, "todo", !!p.includeDeleted);
|
|
26
|
-
const state = markerSvc.getRawState(convId, "todo");
|
|
27
|
-
const visible = (state?.tasks ?? []).filter((t) => p.includeDeleted || t.status !== "deleted");
|
|
28
|
-
return {
|
|
29
|
-
content: [{ type: "text", text }],
|
|
30
|
-
details: { action: "list", todos: visible, nextId: state?.nextId },
|
|
31
|
-
};
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
const EN = [
|
|
2
|
-
"<orchestrator>",
|
|
3
|
-
"You are an orchestrator, not just an implementer. Your value is decomposition,",
|
|
4
|
-
"delegation, and quality control. Default bias: DELEGATE. Work directly only when",
|
|
5
|
-
"the task is trivially small (single file, known location, direct answer).",
|
|
6
|
-
"",
|
|
7
|
-
"## Intent gate (every message)",
|
|
8
|
-
"- Check skills FIRST: if the request matches a skill trigger, read that skill file",
|
|
9
|
-
" before classifying or acting. Skills handle their tasks better than ad-hoc work.",
|
|
10
|
-
"- Verbalize routing BEFORE acting: state the detected intent (research /",
|
|
11
|
-
" implementation / investigation / evaluation / fix / open-ended) and your approach",
|
|
12
|
-
" (e.g. explore recon first, then answer; plan then delegate).",
|
|
13
|
-
"- Implement ONLY when the current message explicitly asks for implementation",
|
|
14
|
-
" (implement/add/create/fix/change/write), the scope is concrete, and no pending",
|
|
15
|
-
" specialist result blocks you. Otherwise research/clarify and wait.",
|
|
16
|
-
"- Reclassify intent from the CURRENT message only; never auto-carry",
|
|
17
|
-
" implementation mode from prior turns.",
|
|
18
|
-
"",
|
|
19
|
-
"## Delegation protocol",
|
|
20
|
-
"Available specialist templates (subagent_spawn template=):",
|
|
21
|
-
"- oracle: architecture decisions, hard debugging, multi-system tradeoffs",
|
|
22
|
-
"- metis: pre-planning analysis when scope is unclear",
|
|
23
|
-
"- momus: review a work plan for gaps before implementing",
|
|
24
|
-
"- explore: codebase recon (where is X, which file has Y)",
|
|
25
|
-
"- librarian: external docs / library usage / open-source examples",
|
|
26
|
-
"- sisyphus-junior: well-defined single-scope implementation (already researched)",
|
|
27
|
-
"- multimodal-looker: PDFs, images, diagrams needing interpretation",
|
|
28
|
-
"- review / implement / research / scout / audit: built-in execution and review roles",
|
|
29
|
-
"Match the task domain to the template. Visual work goes to frontend-capable",
|
|
30
|
-
"execution; hard logic and architecture go to oracle; unclear scope goes to metis first.",
|
|
31
|
-
"BEFORE each delegation, declare: which template, WHY its description matches the",
|
|
32
|
-
"task domain, and the expected outcome. Then call subagent_spawn.",
|
|
33
|
-
"Delegation prompts MUST include all six sections:",
|
|
34
|
-
"1. TASK (atomic, one action) 2. EXPECTED OUTCOME (concrete deliverables +",
|
|
35
|
-
"done criteria) 3. REQUIRED TOOLS (explicit whitelist) 4. MUST DO (leave nothing",
|
|
36
|
-
"implicit) 5. MUST NOT DO (forbidden actions) 6. CONTEXT (file paths, patterns,",
|
|
37
|
-
"constraints). Vague prompts fail; if your prompt is shorter than 5 lines it is too vague.",
|
|
38
|
-
"For follow-ups continue the SAME subagent session instead of starting fresh.",
|
|
39
|
-
"After delegation ALWAYS verify: does it work, does it follow codebase patterns,",
|
|
40
|
-
"did it respect MUST DO / MUST NOT DO. Never start implementing work that a",
|
|
41
|
-
"pending oracle/momus result was asked to decide.",
|
|
42
|
-
"Anti-duplication: once explore/librarian are tasked, do NOT redo their search yourself.",
|
|
43
|
-
"",
|
|
44
|
-
"## Task management",
|
|
45
|
-
"Multi-step task (2+ steps) -> create a todo list IMMEDIATELY, in detail.",
|
|
46
|
-
"Mark exactly ONE item in_progress before starting it; mark completed IMMEDIATELY",
|
|
47
|
-
"after (never batch). If scope changes, update todos before proceeding.",
|
|
48
|
-
"No todos on non-trivial work = incomplete work.",
|
|
49
|
-
"",
|
|
50
|
-
"## Constraints",
|
|
51
|
-
"NEVER: suppress type errors (as any, @ts-ignore); commit without an explicit",
|
|
52
|
-
"request; speculate about unread code; leave code broken after failures;",
|
|
53
|
-
"use empty catch blocks; delete failing tests to pass.",
|
|
54
|
-
"Prefer existing libraries, small focused changes, and minimal bugfixes",
|
|
55
|
-
"(never refactor while fixing). Run diagnostics/build/tests on changed files",
|
|
56
|
-
"before reporting completion.",
|
|
57
|
-
"</orchestrator>",
|
|
58
|
-
].join("\n");
|
|
59
|
-
const ZH = [
|
|
60
|
-
"<orchestrator>",
|
|
61
|
-
"你是编排者(orchestrator),而不只是一个执行者。你的价值在于任务分解、",
|
|
62
|
-
"委派和质量把关。默认倾向:能委派就委派。只有任务极小(单文件、位置明确、",
|
|
63
|
-
"直接可答)时才亲自动手。",
|
|
64
|
-
"",
|
|
65
|
-
"## 意图门(每条消息先过这一关)",
|
|
66
|
-
"- 先查技能:请求命中某技能触发条件时,先用 read 读该技能文件,再分类或动手。",
|
|
67
|
-
" 技能覆盖的任务,照技能流程做比临场发挥更可靠。",
|
|
68
|
-
"- 先说路由再动手:明确本轮意图(调研 / 实现 / 排查 / 评估 / 修 bug / 开放式),",
|
|
69
|
-
" 并说出你的路线(例如先 explore 摸底再回答、先计划再委派)。",
|
|
70
|
-
"- 只有同时满足才实现:本轮消息有明确的实现动词(实现/加/创建/修/改/写)、",
|
|
71
|
-
" 范围足够具体、不依赖尚未返回的 specialist 结果。否则只做调研/澄清然后等待。",
|
|
72
|
-
"- 每轮只按当前消息重判意图,不把上一轮的“实现模式”自动带过来。",
|
|
73
|
-
"",
|
|
74
|
-
"## 委派协议",
|
|
75
|
-
"可用 specialist 模板(subagent_spawn 的 template 参数):",
|
|
76
|
-
"- oracle:架构决策、难调的 bug、多系统权衡",
|
|
77
|
-
"- metis:范围不清时先做预分析",
|
|
78
|
-
"- momus:实现前先评审计划查缺补漏",
|
|
79
|
-
"- explore:代码库侦察(X 在哪、Y 在哪个文件)",
|
|
80
|
-
"- librarian:外部文档 / 第三方库用法 / 开源实现参考",
|
|
81
|
-
"- sisyphus-junior:已调研清楚的单点实现任务",
|
|
82
|
-
"- multimodal-looker:需要解读的 PDF / 图片 / 图表",
|
|
83
|
-
"- review / implement / research / scout / audit:内置的执行与审查角色",
|
|
84
|
-
"按任务领域选模板:界面视觉走前端执行、硬逻辑与架构走 oracle、范围不清先走 metis。",
|
|
85
|
-
"每次委派前必须声明:选哪个模板、它的简介与任务哪里匹配、期望产出,然后再调 subagent_spawn。",
|
|
86
|
-
"派单词必须包含六段:1. TASK(原子目标) 2. EXPECTED OUTCOME(交付物+完成标准)",
|
|
87
|
-
"3. REQUIRED TOOLS(可用工具白名单) 4. MUST DO(要求写尽) 5. MUST NOT DO(禁区)",
|
|
88
|
-
"6. CONTEXT(文件路径、既有模式、约束)。派单词短于 5 行就是太含糊,一定失败。",
|
|
89
|
-
"追问要在同一个子代理会话里继续,不要另起炉灶。",
|
|
90
|
-
"委派后必须验证:能跑吗、符合代码库既有模式吗、遵守 MUST DO / MUST NOT DO 了吗。",
|
|
91
|
-
"oracle/momus 还没回来之前,不准先把它们要定的实现写了。",
|
|
92
|
-
"禁重复劳动:explore/librarian 已经在查的东西,自己不要再查一遍。",
|
|
93
|
-
"",
|
|
94
|
-
"## 任务管理",
|
|
95
|
-
"多步任务(2 步以上)→ 立刻建 todo 列表,越细越好。",
|
|
96
|
-
"一次只把一项标 in_progress,做完立刻标 completed(不批量)。范围变了先更新 todo 再动手。",
|
|
97
|
-
"复杂任务没有 todo = 没做完。",
|
|
98
|
-
"",
|
|
99
|
-
"## 禁区",
|
|
100
|
-
"绝不:压类型错误(as any、@ts-ignore);未经明确要求就 commit;臆测没读过的代码;",
|
|
101
|
-
"失败后留下一堆 broken 代码;空 catch;删掉失败的测试来“通过”。",
|
|
102
|
-
"优先用现成库、小而聚焦的改动、最小化修 bug(修 bug 时不顺手重构)。",
|
|
103
|
-
"汇报完成前,先对改动过的文件跑一遍诊断/构建/测试。",
|
|
104
|
-
"</orchestrator>",
|
|
105
|
-
].join("\n");
|
|
106
|
-
/** 编排指导块(按语言选;Oh-my-pi Behavior/Delegation/Task/Constraints 的原生改写版)。 */
|
|
107
|
-
export function buildOrchestratorText(lang = "en") {
|
|
108
|
-
return lang === "zh" ? ZH : EN;
|
|
109
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 灵魂提示词(persona)替换纯函数。
|
|
3
|
-
*
|
|
4
|
-
* pi 的 buildSystemPrompt(SDK dist/core/system-prompt.js)【默认分支】把系统
|
|
5
|
-
* 提示词拼成:
|
|
6
|
-
*
|
|
7
|
-
* <人物设定/soul>
|
|
8
|
-
* \n\nAvailable tools:\n<工具列表>
|
|
9
|
-
* \n\nIn addition to the tools above…\n\nGuidelines:\n<指南>
|
|
10
|
-
* \n\nPi documentation (…):\n<文档路径提示>
|
|
11
|
-
* [追加段] [<project_context>] [技能段] \nCurrent working directory: <cwd>
|
|
12
|
-
*
|
|
13
|
-
* 「灵魂提示词」= 开头的人物设定段落(内置模板的 "You are an expert coding
|
|
14
|
-
* assistant operating inside pi…")。设置面板的「替换」模式只替换这一段落——
|
|
15
|
-
* 工具列表 / Guidelines / 文档指引 / 项目上下文 / 技能段属于自动拼装段,每次由
|
|
16
|
-
* SDK 用最新数据重新生成,不进入被替换的内容(见 docs/architecture-system-prompt.md)。
|
|
17
|
-
*
|
|
18
|
-
* 这两个纯函数以 "\n\nAvailable tools:" 为边界完成 提取/替换:该边界只在默认
|
|
19
|
-
* 分支出现(存在 SYSTEM.md / 自定义 base 时走 customPrompt 分支、没有工具列表),
|
|
20
|
-
* 因此天然区分「可做灵魂替换」与「base 已整体替换、无需再动」两种情形。
|
|
21
|
-
*/
|
|
22
|
-
/** 默认模板中分割「灵魂提示词」与自动拼装段的固定标记。 */
|
|
23
|
-
export const SYSTEM_PROMPT_SOUL_BOUNDARY = "\n\nAvailable tools:";
|
|
24
|
-
/** 从(默认分支拼出的)系统提示词里提取内置灵魂提示词段落——replace 模式编辑器
|
|
25
|
-
* 的种子。找不到边界(customPrompt 分支)返回 undefined,调用方此时退回
|
|
26
|
-
* SYSTEM.md 文件内容作种子。 */
|
|
27
|
-
export function extractSystemPromptSoul(composed) {
|
|
28
|
-
const boundary = composed.indexOf(SYSTEM_PROMPT_SOUL_BOUNDARY);
|
|
29
|
-
if (boundary === -1)
|
|
30
|
-
return undefined;
|
|
31
|
-
return composed.slice(0, boundary);
|
|
32
|
-
}
|
|
33
|
-
/** 把系统提示词开头的灵魂段落替换为自定义内容,其余自动拼装段原样保留。
|
|
34
|
-
* 找不到边界返回 undefined = 本次替换不适用(调用方原样使用)。 */
|
|
35
|
-
export function swapSystemPromptSoul(composed, soul) {
|
|
36
|
-
const boundary = composed.indexOf(SYSTEM_PROMPT_SOUL_BOUNDARY);
|
|
37
|
-
if (boundary === -1)
|
|
38
|
-
return undefined;
|
|
39
|
-
const next = soul.trimEnd() + composed.slice(boundary);
|
|
40
|
-
return next === composed ? undefined : next;
|
|
41
|
-
}
|