@zhushanwen/pi-goal 0.14.13 → 0.14.14

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 CHANGED
@@ -26,6 +26,16 @@ ln -s /path/to/taiji/extensions/universal/goal \
26
26
  pi install npm:@zhushanwen/pi-goal
27
27
  ```
28
28
 
29
+ ## 工具激活(deferred)
30
+
31
+ `goal_control` 工具为 `exposure: "deferred"`——不占常驻工具声明,由 pi 内置 `tool_search` 工具检索命中后按需激活。taiji 宿主内开箱即用(宿主启动时已激活 `tool_search`);独立 pi 使用需在 `<agentDir>/settings.json`(默认 `~/.pi/agent/settings.json`)开启:
32
+
33
+ ```json
34
+ { "defaultTools": ["+tool_search"] }
35
+ ```
36
+
37
+ `+` 前缀是增量修饰(保留 read/bash/edit/write 默认集)。未开启 `tool_search` 时该工具对模型不可见。
38
+
29
39
  ## 使用
30
40
 
31
41
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhushanwen/pi-goal",
3
- "version": "0.14.13",
3
+ "version": "0.14.14",
4
4
  "description": "Codex-style /goal command for Pi — persistent goal-driven autonomous loop with evidence-based completion, token budget, agent-reported blocking, and steering templates.",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -29,7 +29,7 @@
29
29
  "@earendil-works/pi-coding-agent": "^1.0.0",
30
30
  "@earendil-works/pi-tui": "^1.0.0",
31
31
  "typebox": "1.3.27",
32
- "@zhushanwen/pi-pending-notifications": "0.8.4"
32
+ "@zhushanwen/pi-pending-notifications": "0.8.5"
33
33
  },
34
34
  "dependencies": {
35
35
  "@zhushanwen/extension-protocol": "0.20.0",
@@ -1,14 +1,19 @@
1
1
  /**
2
- * goal_control prompt guidance — successCriteria 三层引导文本独立 prompt-lock
2
+ * goal_control prompt guidance — successCriteria 粒度约束的单源分布锁(D1)
3
3
  *
4
- * W1(plan U24):粒度约束分布在三层,每层独立锁死,删掉任一层约束本文件对应 describe 必红:
4
+ * 设计 tool-declaration-slimming.md §3.3 D1(信息单源化)落地后,粒度约束的承载
5
+ * 分布从「三层重复」收敛为「单源 + 指向」:
5
6
  * 1. 参数层:GoalControlParams.successCriteria 的 schema description(导出对象直读)
6
- * 2. 工具层:registerGoalControlTool 工具 description 的 create 段(源码文本切片)
7
- * 3. guidelines 层:promptGuidelines 的 create 条目(源码文本按赋值块切片)
7
+ * ——粒度约束的唯一承载位(1~8 条 / 单行 / 高层终态条件 / 只引用不复制 / 禁止倾倒)
8
+ * 2. 工具层:registerGoalControlTool 工具 description(源码文本切片)——只留动作
9
+ * 枚举与指向,**不复述**粒度约束(负断言)
10
+ * 3. guidelines 层:promptGuidelines 的 create 条目(源码文本按赋值块切片)——只留
11
+ * 触发纪律(何时建/何时不建),**不复述**粒度约束(负断言)
8
12
  *
9
13
  * 为什么源码文本断言:description / promptGuidelines 内联在 registerGoalControlTool、
10
14
  * 未导出常量;按变量边界切片(marker 定位 + 范围内断言),禁止跨块 [\s\S]*? 全文穿越——
11
15
  * 否则删掉某层约束后其余层文本仍能命中,测试假绿(review 发现的历史缺陷)。
16
+ * 负断言同样按切片范围生效:回填复述 = 违反单源化,对应 describe 必红。
12
17
  */
13
18
  import { readFileSync } from "node:fs";
14
19
  import { dirname, join } from "node:path";
@@ -46,8 +51,6 @@ const PARAM_DESCRIPTION =
46
51
  // ── 第 2 层切片:工具 description 模板字面量("description: `" 到闭合反引号)──
47
52
 
48
53
  const TOOL_DESCRIPTION = sliceBetween(ADAPTER_SRC, "description: `", "`");
49
- // create 段:从 "- create:" 行首到 "- complete:" 行首(同在 description 块内)
50
- const TOOL_DESCRIPTION_CREATE_SEGMENT = sliceBetween(TOOL_DESCRIPTION, "- create:", "- complete:");
51
54
 
52
55
  // ── 第 3 层切片:promptGuidelines 赋值块 ─────────────────────
53
56
  // 闭合 "]" 不能用 indexOf 找——块内 guideline 文本自身含 "string[]" 的 "]",
@@ -76,9 +79,9 @@ if (CREATE_GUIDELINE_LINE === undefined) {
76
79
  throw new Error('create guideline line not found in promptGuidelines block of goal-control-adapter.ts');
77
80
  }
78
81
 
79
- // ── 第 1 层:successCriteria 参数 schema description ─────────
82
+ // ── 第 1 层:successCriteria 参数 schema description(粒度约束唯一承载位)──
80
83
 
81
- describe("第 1 层:successCriteria 参数 schema description(粒度约束)", () => {
84
+ describe("第 1 层:successCriteria 参数 schema description(粒度约束唯一承载位)", () => {
82
85
  it("schema 结构为 string[](type: array + items type: string)", () => {
83
86
  expect(successCriteriaSchema.type).toBe("array");
84
87
  expect(successCriteriaSchema.items.type).toBe("string");
@@ -108,38 +111,38 @@ describe("第 1 层:successCriteria 参数 schema description(粒度约束
108
111
  });
109
112
  });
110
113
 
111
- // ── 第 2 层:工具 description create 段 ─────────────────────
114
+ // ── 第 2 层:工具 description —— 单源化后只留枚举 + 指向,不复述粒度约束 ──
112
115
 
113
- describe("第 2 层:工具 description create 段(粒度约束)", () => {
114
- it("create 段含 successCriteria 条数约束(3~8 条高层终态条件)", () => {
115
- expect(TOOL_DESCRIPTION_CREATE_SEGMENT).toContain("successCriteria");
116
- expect(TOOL_DESCRIPTION_CREATE_SEGMENT).toMatch(/3~8\s*条/);
117
- expect(TOOL_DESCRIPTION_CREATE_SEGMENT).toContain("高层终态条件");
116
+ describe("第 2 层:工具 description(单源化:枚举 + 指向,不复述)", () => {
117
+ it("description 含 action 枚举与 schema 字段说明指向", () => {
118
+ expect(TOOL_DESCRIPTION).toContain("create(创建)| complete(完成)| report_blocked(阻塞报告)");
119
+ expect(TOOL_DESCRIPTION).toContain("见 schema 字段说明");
118
120
  });
119
121
 
120
- it("create 段含细粒度清单只引用不复制语义", () => {
121
- expect(TOOL_DESCRIPTION_CREATE_SEGMENT).toContain("细粒度检查清单放 todo/plan");
122
- expect(TOOL_DESCRIPTION_CREATE_SEGMENT).toContain("只引用不复制");
123
- });
124
-
125
- it("create 段含禁止倾倒完整规格语义", () => {
126
- expect(TOOL_DESCRIPTION_CREATE_SEGMENT).toContain("禁止倾倒完整规格");
122
+ it("description 不复述粒度约束(负断言:回填即红)", () => {
123
+ expect(TOOL_DESCRIPTION).not.toMatch(/3~8\s*条/);
124
+ expect(TOOL_DESCRIPTION).not.toContain("细粒度检查清单放 todo/plan");
125
+ expect(TOOL_DESCRIPTION).not.toContain("只引用不复制");
126
+ expect(TOOL_DESCRIPTION).not.toContain("禁止倾倒完整规格");
127
127
  });
128
128
  });
129
129
 
130
- // ── 第 3 层:promptGuidelines create 条目 ────────────────────
130
+ // ── 第 3 层:promptGuidelines create 条目 —— 触发纪律,不复述粒度约束 ──
131
131
 
132
- describe("第 3 层:promptGuidelines create 条目(粒度约束)", () => {
133
- it("create 条目含 3~8 条高层终态条件 + string[] 语义", () => {
134
- expect(CREATE_GUIDELINE_LINE).toMatch(/3~8 high-level terminal conditions as string\[\]/);
132
+ describe("第 3 层:promptGuidelines create 条目(触发纪律,不复述粒度约束)", () => {
133
+ it("create 条目含主动触发纪律(复杂多步骤工作 + 值得追踪自查)", () => {
134
+ expect(CREATE_GUIDELINE_LINE).toMatch(/proactively start a goal for complex, multi-step work/);
135
+ expect(CREATE_GUIDELINE_LINE).toContain("is this worth tracking to completion with verification?");
135
136
  });
136
137
 
137
- it("create 条目含细粒度清单只引用不复制语义(reference, do not copy)", () => {
138
- expect(CREATE_GUIDELINE_LINE).toContain("Fine-grained checklists belong in todo/plan");
139
- expect(CREATE_GUIDELINE_LINE).toContain("reference them, do not copy");
138
+ it("create 条目含禁止场景纪律(琐碎任务/已有目标不建 + 恢复指引)", () => {
139
+ expect(CREATE_GUIDELINE_LINE).toContain("trivial single-step tasks");
140
+ expect(CREATE_GUIDELINE_LINE).toContain("/goal resume or /goal clear");
140
141
  });
141
142
 
142
- it("create 条目含禁止倾倒完整规格语义(Do NOT dump full specs)", () => {
143
- expect(CREATE_GUIDELINE_LINE).toContain("Do NOT dump full specs into successCriteria");
143
+ it("create 条目不复述粒度约束(负断言:回填即红)", () => {
144
+ expect(CREATE_GUIDELINE_LINE).not.toMatch(/3~8 high-level terminal conditions as string\[\]/);
145
+ expect(CREATE_GUIDELINE_LINE).not.toContain("Fine-grained checklists belong in todo/plan");
146
+ expect(CREATE_GUIDELINE_LINE).not.toContain("Do NOT dump full specs into successCriteria");
144
147
  });
145
148
  });
@@ -1,14 +1,16 @@
1
- // 提示词质量回归:goal_control tool description + runtime 错误文案必须是
2
- // "可纠正的行为约束器",而非干巴巴的错误。
1
+ // 提示词质量回归:goal_control tool 声明按 D1 三层分工单源化后(设计
2
+ // tool-declaration-slimming.md §3.3 D1),本测试锁定单源分布——
3
+ // - description:功能定位 + action 枚举 + 控制权归属(不再复述各 action 触发纪律
4
+ // 与预算策略(含设预算与报告最终 token 用量)——纪律单源在 promptGuidelines,
5
+ // 字段语义单源在 schema 字段说明)
6
+ // - promptGuidelines:使用纪律唯一承载位(create/complete/report_blocked 何时调用、
7
+ // budget 何时可设)
8
+ // - runtime 错误文案:'Correct:' 纠正正例(schema 为扁平 Type.Object + action 字段级
9
+ // union,字段全部 Optional——缺失必填由 handler 运行时校验兜底)
3
10
  //
4
- // agent(LLM)唯一能看到的 tool 元信息就是 description + 报错文案。description 用中文
5
- // 重写(动作 create/complete/report_blocked + 规则 + §2.5 终态语义),删除英文 Examples/Don't
6
- // 段;runtime throw 保留 .trim() 空串校验 + 'Correct:' 纠正正例(schema 为扁平 Type.Object
7
- // + action 字段级 union,字段全部 Optional——缺失必填由 handler 运行时校验兜底)。
8
- //
9
- // 本测试用源码断言(读 .ts 文件文本)锁定这些约束,防止后续重构把中文语义/纠错文案/
10
- // union 结构删掉。读源码而非 import,避免 mock 链(goal-control-adapter.ts 依赖
11
- // pi-ai/typebox/pi-tui/ExtensionAPI 等值导入)。
11
+ // 本测试用源码断言(读 .ts 文件文本)锁定这些约束,防止后续重构把单源分布改回
12
+ // 多层复述、或把纠错文案删掉。读源码而非 import,避免 mock 链(goal-control-adapter.ts
13
+ // 依赖 pi-ai/typebox/pi-tui/ExtensionAPI 等值导入)。
12
14
 
13
15
  import { readFileSync } from "node:fs";
14
16
  import { dirname, join } from "node:path";
@@ -31,23 +33,17 @@ function extractDescription(src: string): string {
31
33
 
32
34
  const DESCRIPTION = extractDescription(ADAPTER_SRC);
33
35
 
34
- describe("goal_control description — 中文化 + 动作覆盖", () => {
35
- it("含管理目标总述 + complete 须满足每条 successCriteria 条件", () => {
36
+ describe("goal_control description — 功能定位 + action 枚举 + 控制权归属", () => {
37
+ it("含管理目标总述 + 三动作枚举(create/complete/report_blocked)", () => {
36
38
  expect(DESCRIPTION).toContain("管理当前会话的目标");
37
- expect(DESCRIPTION).toContain("满足每条 successCriteria 条件");
39
+ expect(DESCRIPTION).toContain("create(创建)| complete(完成)| report_blocked(阻塞报告)");
38
40
  });
39
- });
40
41
 
41
- describe("goal_control description — §2.5 终态语义", () => {
42
- it("create 失败提示 / complete 报告 token / pause-resume-budget 归用户 / 不反复报告阻塞", () => {
43
- expect(DESCRIPTION).toContain("请让用户运行 /goal resume 或 /goal clear");
44
- expect(DESCRIPTION).toContain("报告最终 token 用量");
42
+ it("含 pause-resume-budget 归用户;报告预算纪律不复述(D1 单源在 guidelines)", () => {
45
43
  expect(DESCRIPTION).toContain("pause/resume 和 budget 变更由用户经 /goal 命令控制");
46
- expect(DESCRIPTION).toContain("不要反复报告同一阻塞");
44
+ expect(DESCRIPTION).not.toContain("报告最终 token 用量");
47
45
  });
48
- });
49
46
 
50
- describe("goal_control description — 删除 Examples/Don't 英文段", () => {
51
47
  it("不含 Examples JSON 正例段 + 不含 Don't 段", () => {
52
48
  // Examples 段已删,description 不再含裸 JSON 正例
53
49
  expect(DESCRIPTION).not.toContain('{"action":"create"');
@@ -55,23 +51,52 @@ describe("goal_control description — 删除 Examples/Don't 英文段", () => {
55
51
  });
56
52
  });
57
53
 
58
- describe("goal_control schema — 扁平 Type.Object(OpenAI 兼容)+ handler 运行时校验", () => {
59
- it("字段级 Type.Union + additionalProperties:false + 无 timeBudgetMinutes", () => {
60
- expect(ADAPTER_SRC).toMatch(/Type\.Union\(/);
61
- expect(ADAPTER_SRC).toContain("additionalProperties: false");
62
- expect(ADAPTER_SRC).not.toMatch(/timeBudgetMinutes/);
54
+ describe("goal_control description — D1 单源化(不复述纪律与字段语义)", () => {
55
+ it("不再复述各 action 触发纪律(纪律单源在 promptGuidelines)", () => {
56
+ // create/complete/report_blocked 的触发条件只在 guidelines;
57
+ // 完成门槛(successCriteria 逐条满足)只在 schema successCriteria 说明
58
+ expect(DESCRIPTION).not.toContain("琐碎的单步任务");
59
+ expect(DESCRIPTION).not.toContain("仅在穷尽替代方案后使用");
60
+ expect(DESCRIPTION).not.toContain("满足每条 successCriteria 条件");
61
+ });
62
+
63
+ it("不再复述预算策略段(budget 纪律单源在 promptGuidelines)", () => {
64
+ expect(DESCRIPTION).not.toContain("默认不设 tokenBudget");
65
+ expect(DESCRIPTION).not.toContain("切勿自行决定");
63
66
  });
64
67
  });
65
68
 
66
- describe("goal_control promptGuidelines — complete/report_blocked 主动触发引导", () => {
67
- it("含 promptGuidelines 字段 + complete/report_blocked 主动触发信号", () => {
69
+ describe("goal_control promptGuidelines — 使用纪律唯一承载位(锚词保留清单)", () => {
70
+ it("含 promptGuidelines 字段 + create 主动触发纪律(复杂多步骤才建 + 已有目标不建)", () => {
68
71
  expect(ADAPTER_SRC).toMatch(/promptGuidelines:\s*\[/);
72
+ expect(ADAPTER_SRC).toMatch(
73
+ /create: proactively start a goal for complex, multi-step work/s,
74
+ );
75
+ expect(ADAPTER_SRC).toContain("/goal resume or /goal clear");
76
+ });
77
+
78
+ it("含 complete 主动触发纪律(objective 实际达成 + evidence 对照每条 successCriteria)+ 报告预算纪律锚", () => {
69
79
  expect(ADAPTER_SRC).toMatch(/complete:.*proactively call.*objective is actually achieved/s);
80
+ expect(ADAPTER_SRC).toContain("Evidence must meet every successCriteria condition");
81
+ // 报告预算纪律的唯一承载位锚(description 侧负断言见上组——删 guidelines 此句而
82
+ // 不删 description 侧时本锚防静默丢失)
83
+ expect(ADAPTER_SRC).toContain("report the final token usage in your summary");
84
+ });
85
+
86
+ it("含 report_blocked 主动触发纪律(穷尽方案 + 不反复报告)", () => {
70
87
  expect(ADAPTER_SRC).toMatch(/report_blocked:.*proactively call.*≥3 distinct alternative approaches/s);
71
88
  expect(ADAPTER_SRC).toContain("do not repeatedly report the same blocker");
72
89
  });
73
90
  });
74
91
 
92
+ describe("goal_control schema — 扁平 Type.Object(OpenAI 兼容)+ handler 运行时校验", () => {
93
+ it("字段级 Type.Union + additionalProperties:false + 无 timeBudgetMinutes", () => {
94
+ expect(ADAPTER_SRC).toMatch(/Type\.Union\(/);
95
+ expect(ADAPTER_SRC).toContain("additionalProperties: false");
96
+ expect(ADAPTER_SRC).not.toMatch(/timeBudgetMinutes/);
97
+ });
98
+ });
99
+
75
100
  describe("goal_control runtime 错误文案 — 含 'Correct:' 纠正正例", () => {
76
101
  it("≥4 处 'Correct:'(4 条空串 throw 各一带正例)+ objective/evidence 报错带正例", () => {
77
102
  // objective/successCriteria/evidence/reason 四条空串 throw 各应带完整 JSON 正例,
@@ -93,19 +118,22 @@ describe("goal_control 描述修正(A1/slug optional)", () => {
93
118
  });
94
119
  });
95
120
 
96
- describe("goal_control budget 默认策略锁定(S-8:三层信号冗余,防回滚无声)", () => {
97
- // 新增的 budget-policy prompt 文本散落在三处(description 段 / promptGuidelines 项 /
98
- // tokenBudget 参数 description),任一处被回滚都应触发测试失败——这是 prompt-lock 的核心诉求。
99
- it("description 模板含中文 '默认不设 tokenBudget' 预算策略段", () => {
100
- expect(DESCRIPTION).toContain("默认不设 tokenBudget");
121
+ describe("goal_control budget 纪律单源化(S-8 替换:三层冗余锁 → 单源分布锁)", () => {
122
+ // D1 单源化后预算策略纪律只在 promptGuidelines 一处;description 与 tokenBudget
123
+ // 参数说明不再复述纪律(schema 只留字段语义「默认不设」+ 指引)。
124
+ // 任一层回填复述 = 违反单源化,本组负断言红灯。
125
+ it("promptGuidelines budget 条含纪律锚词(never set on own initiative + 先问用户)", () => {
126
+ expect(ADAPTER_SRC).toContain("never set tokenBudget on your own initiative");
127
+ expect(ADAPTER_SRC).toContain("ask the user before creating the goal");
101
128
  });
102
129
 
103
- it("promptGuidelines budget 项含英文 'never set tokenBudget on your own initiative'", () => {
104
- expect(ADAPTER_SRC).toContain("never set tokenBudget on your own initiative");
130
+ it("description 不含预算策略段(不复述)", () => {
131
+ expect(DESCRIPTION).not.toContain("仅在用户明确要求");
132
+ expect(DESCRIPTION).not.toContain("获得明确同意");
105
133
  });
106
134
 
107
- it("tokenBudget 参数 description 含 '默认不设' + '切勿自行决定设置预算'", () => {
108
- // 参数 schema description 是第三层信号(与上面两层对齐,三层冗余,见 adapter 源码注释)
109
- expect(ADAPTER_SRC).toMatch(/tokenBudget:[\s\S]*?默认不设[\s\S]*?切勿自行决定设置预算/);
135
+ it("tokenBudget 参数 description 只留字段语义(默认不设 + 指引,不含纪律复述)", () => {
136
+ expect(ADAPTER_SRC).toMatch(/tokenBudget:[\s\S]*?默认不设/);
137
+ expect(ADAPTER_SRC).not.toMatch(/tokenBudget:[\s\S]*?切勿自行决定设置预算/);
110
138
  });
111
139
  });
@@ -92,7 +92,7 @@ export const GoalControlParams = Type.Object(
92
92
  tokenBudget: Type.Optional(
93
93
  Type.Number({
94
94
  description:
95
- "可选。新目标的 token 预算(正数)。默认不设——仅在用户明确要求(如「控制在 1 万 token 内」)或你已获得用户明确同意时才设。切勿自行决定设置预算。",
95
+ "可选。新目标的 token 预算(正数)。默认不设——设置条件见 guidelines 的 budget 条目。",
96
96
  }),
97
97
  ),
98
98
  evidence: Type.Optional(
@@ -337,34 +337,27 @@ export function registerGoalControlTool(pi: ExtensionAPI, session: GoalSession):
337
337
  pi.registerTool({
338
338
  name: "goal_control",
339
339
  label: "Goal Control",
340
- description: `管理当前会话的目标(goal)。目标用于追踪需要完成验证的复杂工作。
340
+ // deferred(tool-declaration-slimming D4):不常驻声明,tool_search 命中即激活;
341
+ // 迁移写入的 +tool_search 条目(runtime pi-codemode-settings)承载检索入口
342
+ exposure: "deferred",
343
+ description: `管理当前会话的目标(goal)。目标用于追踪需要完成验证的复杂工作。动作:create(创建)| complete(完成)| report_blocked(阻塞报告)——各参数必填性与用法见 schema 字段说明,触发纪律见 guidelines。
341
344
 
342
- 预算策略:默认不设 tokenBudget。仅在用户明确要求(如「控制在 1 万 token 内」)或用户的指令明确暗示了一个限制时才设。若你认为应该设预算但用户从未提及,先询问用户获得明确同意,切勿自行决定。
343
-
344
- 动作:
345
- - create:为复杂的多步骤工作(3+ 步骤、多文件改动、或需要完成验证的工作)主动创建目标。用自己的话重述真实目标,定义可检查的 successCriteria(完成条件数组,3~8 条高层终态条件)。细粒度检查清单放 todo/plan,只引用不复制。禁止倾倒完整规格。琐碎的单步任务、普通提问、查找类任务不要创建目标。若已有 active/paused/blocked 目标会失败——请让用户运行 /goal resume 或 /goal clear 后再创建。
346
- - complete:标记当前 active 目标完成。需要 evidence(具体证据:改动的文件、通过的测试、运行的命令),且必须满足每条 successCriteria 条件。若有预算,在总结里报告最终 token 用量。不要基于假设、意图或部分进度标记完成。
347
- - report_blocked:标记当前 active 目标被真实阻碍阻塞。需要 reason 描述阻塞条件和已尝试的方案。仅在穷尽替代方案后使用——不要用于困难、缓慢或不确定的工作。
348
-
349
- 控制权归属:
350
- - pause/resume 和 budget 变更由用户经 /goal 命令控制,你不能修改。
351
- - 达到阻塞阈值后报告,不要反复报告同一阻塞。
352
-
353
- 完成验证标准由你在 create 时定义的 successCriteria 决定——complete 时必须逐条满足。`,
345
+ 控制权归属:pause/resume 和 budget 变更由用户经 /goal 命令控制,你不能修改。`,
354
346
  promptSnippet:
355
347
  "用 goal_control 管理会话目标:为复杂多步骤工作主动 create(含 slug + objective + successCriteria),达成时 complete(含满足每条 successCriteria 的 evidence),穷尽方案后 report_blocked(含 reason)。",
356
348
  // promptGuidelines:进 system prompt guidelines 段(强信号位)。
357
- // 三个 action 的正向触发引导——create(复杂任务主动启动)、complete(对照 successCriteria 验证达成)、
358
- // report_blocked(穷尽替代方案后)。措辞主动,给 system prompt 层常驻强信号。
349
+ // D1 单源化后本层是使用纪律的唯一承载位(何时该用/禁用什么);字段语义
350
+ // (参数是什么、必填性、合法值)单源在 schema 字段说明,此处不复述。
359
351
  promptGuidelines: [
360
- // create:主动用于复杂多步骤任务。翻转原「显式启动」策略——让 goal 真正可用。
352
+ // create:主动用于复杂多步骤任务,翻转原「显式启动」策略——让 goal 真正可用。
361
353
  // 门槛:3+ 步骤 / 多文件 / 需完成验证,避免对琐碎任务滥建 goal 变噪音。
362
- "create: proactively start a goal for complex, multi-step work (3+ steps, multi-file, or needs completion verification) — restate the real objective and define checkable successCriteria (3~8 high-level terminal conditions as string[]). Fine-grained checklists belong in todo/plan — reference them, do not copy. Do NOT dump full specs into successCriteria. Do NOT create for trivial single-step tasks, ordinary lookups, or when a goal is already active. Test: 'is this worth tracking to completion with verification?' — if yes, create a goal.",
363
- // budget:默认不设预算——仅当用户显式要求(或明确同意)时才设。
364
- // 对齐 description 的预算策略段 + tokenBudget 参数的 description(三层信号冗余)。
354
+ // 非终态旧 goal 挡 create——恢复/清理由用户经 /goal 命令做。
355
+ "create: proactively start a goal for complex, multi-step work (3+ steps, multi-file, or needs completion verification). Do NOT create for trivial single-step tasks, ordinary lookups, or when an active/paused/blocked goal already exists — creating then fails; ask the user to run /goal resume or /goal clear first. Test: 'is this worth tracking to completion with verification?' — if yes, create a goal.",
356
+ // budget:默认不设预算——仅当用户显式要求(或明确同意)时才设(纪律单源位,
357
+ // description 与 tokenBudget 参数说明不再复述)。
365
358
  "budget: never set tokenBudget on your own initiative — the default is no budget. Set a budget only when the user explicitly requested one (e.g. \"keep it under 10k tokens\") or you obtained explicit user consent first. If you think a budget is warranted but the user never mentioned one, ask the user before creating the goal.",
366
359
  // 全解耦下 todo 非硬前置——objective 实际达成才算(与 handleComplete「todo 由 AI 自判」一致)
367
- "complete: proactively call when the active goal's objective is actually achieved, not merely in progress. Evidence must be concrete artifacts (files changed, tests green, commands run) meeting every successCriteria condition. Finishing all todos (incl. verification todos) is the usual readiness signal, but the real bar is the objective being met — you decide.",
360
+ "complete: proactively call when the active goal's objective is actually achieved, not merely in progress. Evidence must meet every successCriteria condition — not assumptions, intent, or partial progress. Finishing all todos (incl. verification todos) is the usual readiness signal, but the real bar is the objective being met — you decide. If a budget was set, report the final token usage in your summary.",
368
361
  // ≥3 distinct approaches 或同一 blocker 跨连续 turns(T7);达到阈值后报告,不反复报告同一 blocker
369
362
  "report_blocked: proactively call when genuinely blocked after ≥3 distinct alternative approaches or when the same blocker persists across consecutive turns — not for hard/slow work or uncertainty. State the blocker and what you tried. Once the threshold is met, report — do not repeatedly report the same blocker. Do NOT silently stop or leave the goal hanging.",
370
363
  ],