@xgjktech/xg-openclaw-harness-tools 0.4.0 → 0.4.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/README.md +23 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/plan-prompt.d.ts +13 -0
- package/dist/plan-prompt.d.ts.map +1 -0
- package/dist/plan-prompt.js +20 -0
- package/dist/plan-view-tool.d.ts.map +1 -1
- package/dist/plan-view-tool.js +1 -0
- package/dist/plan-write-tool.d.ts.map +1 -1
- package/dist/plan-write-tool.js +13 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -105,6 +105,29 @@ task;写入 schema 不接受 steps,但读取旧计划仍兼容旧 steps 数
|
|
|
105
105
|
两个工具的完整参数 schema 见 `src/plan-write-tool.ts` / `src/plan-view-tool.ts`
|
|
106
106
|
中的 `PLAN_WRITE_DESCRIPTION` / `PLAN_VIEW_DESCRIPTION`。
|
|
107
107
|
|
|
108
|
+
## 主动计划提示词注入(before_prompt_build)
|
|
109
|
+
|
|
110
|
+
插件在 `register` 时挂载 `before_prompt_build` hook,用 `appendSystemContext` 向每个 agent 的
|
|
111
|
+
system prompt 追加一段"主动工作计划"纪律(`src/plan-prompt.ts`):多步工作先建计划、逐项整张回写、
|
|
112
|
+
blocked 带 note、台账≠执行。内容与工具 description 一致,仅抬升"主动触发"的优先级。
|
|
113
|
+
|
|
114
|
+
- **与其他注入不冲突**:IM 通道的 `GroupSystemPrompt` 落在 base system prompt,本段追加在其后,
|
|
115
|
+
纯叠加不覆盖;对内置 runtime 与 Codex runtime 均生效。
|
|
116
|
+
- **如需关闭**:在部署配置里对该插件入口设 `hooks.allowPromptInjection: false`(默认放行):
|
|
117
|
+
|
|
118
|
+
```jsonc
|
|
119
|
+
{
|
|
120
|
+
"plugins": {
|
|
121
|
+
"entries": {
|
|
122
|
+
"xg-harness-tools": { "hooks": { "allowPromptInjection": false } }
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
- 若部署方同时手工把 `docs/09-plan-usage-guide.md` 的 System Prompt 模版写进 AGENTS.md/频道
|
|
129
|
+
systemPrompt,会与本段叠加——冗余无害,可按需取舍。
|
|
130
|
+
|
|
108
131
|
## 部署 checklist
|
|
109
132
|
|
|
110
133
|
- [ ] Node ≥ 22.19.0
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
export default
|
|
1
|
+
declare const pluginEntry: import("openclaw/plugin-sdk/tool-plugin").DefinedToolPluginEntry;
|
|
2
|
+
export default pluginEntry;
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmBA,QAAA,MAAM,WAAW,kEAqDf,CAAC;AAUH,eAAe,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,9 @@ import { PLAN_WRITE_DESCRIPTION, PlanWriteParams, buildPlanWriteTool } from "./p
|
|
|
4
4
|
import { PLAN_VIEW_DESCRIPTION, PlanViewParams, buildPlanViewTool, } from "./plan-view-tool.js";
|
|
5
5
|
import { ACTION_DISPATCH_DESCRIPTION, ActionDispatchParams, buildActionDispatchTool, } from "./action-dispatch-tool.js";
|
|
6
6
|
import { toPlanOrigin } from "./plan-origin.js";
|
|
7
|
+
import { buildPlanPromptInjection } from "./plan-prompt.js";
|
|
7
8
|
const PLUGIN_ID = "xg-harness-tools";
|
|
8
|
-
|
|
9
|
+
const pluginEntry = defineToolPlugin({
|
|
9
10
|
id: PLUGIN_ID,
|
|
10
11
|
name: "XG Harness Tools",
|
|
11
12
|
description: "企业工具插件:计划管理与通用动作分发(plan_write / plan_view / action_dispatch)",
|
|
@@ -54,3 +55,11 @@ export default defineToolPlugin({
|
|
|
54
55
|
];
|
|
55
56
|
},
|
|
56
57
|
});
|
|
58
|
+
// defineToolPlugin 只负责工具注册;主动建计划纪律以 before_prompt_build hook 追加到 system prompt。
|
|
59
|
+
// 就地覆写 register(保留 tool-plugin metadata),先走原工具注册,再挂 prompt 注入。
|
|
60
|
+
const baseRegister = pluginEntry.register;
|
|
61
|
+
pluginEntry.register = (api) => {
|
|
62
|
+
baseRegister(api);
|
|
63
|
+
api.on("before_prompt_build", buildPlanPromptInjection);
|
|
64
|
+
};
|
|
65
|
+
export default pluginEntry;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PluginHookBeforePromptBuildResult } from "openclaw/plugin-sdk/types";
|
|
2
|
+
/**
|
|
3
|
+
* 追加到 agent system prompt 的"主动建计划"纪律(appendSystemContext)。
|
|
4
|
+
* 与 IM 通道的 GroupSystemPrompt 纯叠加不冲突:本段拼在 base systemPrompt 之后。
|
|
5
|
+
* 保持稳定文本,利于 provider 缓存。
|
|
6
|
+
*/
|
|
7
|
+
export declare const PLAN_FIRST_SYSTEM_CONTEXT: string;
|
|
8
|
+
/**
|
|
9
|
+
* before_prompt_build 钩子处理器:向 agent system prompt 追加主动建计划纪律。
|
|
10
|
+
* 返回 void 语义由宿主管控,插件侧始终返回该静态段。
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildPlanPromptInjection(): PluginHookBeforePromptBuildResult;
|
|
13
|
+
//# sourceMappingURL=plan-prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-prompt.d.ts","sourceRoot":"","sources":["../src/plan-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAEnF;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,QAO1B,CAAC;AAEb;;;GAGG;AACH,wBAAgB,wBAAwB,IAAI,iCAAiC,CAE5E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 追加到 agent system prompt 的"主动建计划"纪律(appendSystemContext)。
|
|
3
|
+
* 与 IM 通道的 GroupSystemPrompt 纯叠加不冲突:本段拼在 base systemPrompt 之后。
|
|
4
|
+
* 保持稳定文本,利于 provider 缓存。
|
|
5
|
+
*/
|
|
6
|
+
export const PLAN_FIRST_SYSTEM_CONTEXT = [
|
|
7
|
+
"## 主动工作计划(xg-harness-tools)",
|
|
8
|
+
"- 开始执行任何多步骤工作之前,应主动调用 xg_plan_write 建立计划,不要等用户要求。",
|
|
9
|
+
"- 触发情形:目标需要两个或更多连续动作;预计跨多轮或中断后继续;需等待用户、审批或外部系统。",
|
|
10
|
+
"- 工作流:开工前建计划 → 每完成一项用 xg_plan_write 整张重交回写状态 → 全部完成提交最终版。",
|
|
11
|
+
"- 无法当场完成:标 in_progress 或 blocked(blocked 必须带 note 写明原因),后续回合继续。",
|
|
12
|
+
"- xg_plan_write / xg_plan_view 只是台账,不执行、不调度、无后台运行;保存/查看之后必须继续逐项实际执行任务。",
|
|
13
|
+
].join("\n");
|
|
14
|
+
/**
|
|
15
|
+
* before_prompt_build 钩子处理器:向 agent system prompt 追加主动建计划纪律。
|
|
16
|
+
* 返回 void 语义由宿主管控,插件侧始终返回该静态段。
|
|
17
|
+
*/
|
|
18
|
+
export function buildPlanPromptInjection() {
|
|
19
|
+
return { appendSystemContext: PLAN_FIRST_SYSTEM_CONTEXT };
|
|
20
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-view-tool.d.ts","sourceRoot":"","sources":["../src/plan-view-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,SAAS,EAEf,MAAM,8BAA8B,CAAC;AAKtC,eAAO,MAAM,cAAc;;EAK1B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"plan-view-tool.d.ts","sourceRoot":"","sources":["../src/plan-view-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,SAAS,EAEf,MAAM,8BAA8B,CAAC;AAKtC,eAAO,MAAM,cAAc;;EAK1B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D,eAAO,MAAM,qBAAqB,QAStB,CAAC;AAuBb,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,MAAM,CAAC,EAAE,UAAU,CAAA;CAAE,GAAG,YAAY,CAmD/F"}
|
package/dist/plan-view-tool.js
CHANGED
|
@@ -13,6 +13,7 @@ export const PLAN_VIEW_DESCRIPTION = [
|
|
|
13
13
|
"- 带 planId:返回该计划当前的完整清单。",
|
|
14
14
|
"- 不带 planId:返回最近计划的摘要列表,用于忘记或跨会话找回 planId。",
|
|
15
15
|
"",
|
|
16
|
+
"若当前要推进的工作还没有对应计划,应先调用 xg_plan_write 建立计划再开始执行。",
|
|
16
17
|
"重要:查看不等于执行。若计划存在未完成任务,你必须继续实际执行它们,完成一项后用 xg_plan_write 回写状态。",
|
|
17
18
|
].join("\n");
|
|
18
19
|
function summarizePlan(plan) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-write-tool.d.ts","sourceRoot":"","sources":["../src/plan-write-tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAIL,KAAK,UAAU,EACf,KAAK,SAAS,EAGf,MAAM,8BAA8B,CAAC;AA8BtC,eAAO,MAAM,eAAe;;;;;;;;;EAwB3B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"plan-write-tool.d.ts","sourceRoot":"","sources":["../src/plan-write-tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAIL,KAAK,UAAU,EACf,KAAK,SAAS,EAGf,MAAM,8BAA8B,CAAC;AA8BtC,eAAO,MAAM,eAAe;;;;;;;;;EAwB3B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D,eAAO,MAAM,sBAAsB,QA4BvB,CAAC;AA0Eb,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,YAAY,CA0HtF"}
|
package/dist/plan-write-tool.js
CHANGED
|
@@ -33,17 +33,21 @@ export const PlanWriteParams = Type.Object({
|
|
|
33
33
|
cancel: Type.Optional(Type.Boolean({ description: "取消该计划;true 时只需带 planId,不带 goal/tasks" })),
|
|
34
34
|
}, { additionalProperties: false });
|
|
35
35
|
export const PLAN_WRITE_DESCRIPTION = [
|
|
36
|
-
"
|
|
36
|
+
"用途:为用户可见、可跨回合保存的工作创建或更新任务清单。每次调用都是整张替换,不是增量更新。",
|
|
37
37
|
"",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"-
|
|
41
|
-
"-
|
|
38
|
+
"【主动建计划:不要等用户要求】",
|
|
39
|
+
"识别到以下任一情形,都应主动调用本工具建立计划,而不是仅用文字回复或直接闷头推进:",
|
|
40
|
+
"- 目标需要两个或更多连续动作才能完成。",
|
|
41
|
+
"- 预计需要多轮推进,或可能中断后继续(跨回合/跨天)。",
|
|
42
|
+
"- 需要等待人的回复、审批或外部系统。",
|
|
43
|
+
"- 用户交代的是一个完整工作目标,而非单个简单问题。",
|
|
44
|
+
"",
|
|
45
|
+
"工作流:开工前先建计划 → 每完成一项就整张重交更新状态 → 全部完成后提交最终版本。",
|
|
42
46
|
"",
|
|
43
|
-
"
|
|
44
|
-
"-
|
|
45
|
-
"-
|
|
46
|
-
"-
|
|
47
|
+
"无需建计划的窄例外:",
|
|
48
|
+
"- 纯单轮问答、查询、解释概念,不产生需要跟踪的工作。",
|
|
49
|
+
"- 单个动作在当前回合即可直接完成。",
|
|
50
|
+
"- 不要把分析、思考和试错过程写成 task;只记录需要向用户展示的工作项。",
|
|
47
51
|
"",
|
|
48
52
|
"执行纪律(必须遵守):",
|
|
49
53
|
"- 本工具只把计划清单落库:不执行、不调度、无后台运行。保存计划 ≠ 完成工作。",
|