pi-distill 1.6.0 → 1.7.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 CHANGED
@@ -111,6 +111,7 @@ Agent consumes a result suited to the current decision, with auditable diagnosti
111
111
  3. The `tool_result` handler sees the actual output and decides what to do; it does not rely on the agent predicting the output size.
112
112
  4. Every tool call must include a non-empty `outputRequest`. A prompt containing only `RAW` explicitly requests the original. Any other non-empty prompt permits distillation once the configured threshold is reached.
113
113
  5. OpenAI-compatible completion requests enable native JSON mode with `response_format: { "type": "json_object" }`; OpenAI Responses-compatible requests use the equivalent `text.format`. A timed-out attempt is retried according to `timeoutRetryCount`, while other provider failures use `errorRetryCount` (both default to one retry). If a non-empty model response is only invalid JSON or violates the response schema, pi-distill makes one JSON-only repair call with the malformed response and validation error; it does not resend the tool output or run summarization again. If repair fails, no model is available, or compression is ineffective, the original facts are retained and the status is exposed through details and the audit card. JSON responses wrapped in Markdown fences such as `````json … ````` are also accepted.
114
+ 6. Interrupting the parent Agent request aborts any in-flight distillation request immediately and disables retries for that interrupted result; the original tool output remains available through the normal fail-open path.
114
115
 
115
116
  ## Output contract
116
117
 
package/README.zh-CN.md CHANGED
@@ -113,6 +113,7 @@ Agent 消费更适合当前决策的结果,并获得可审计的处理诊断
113
113
  3. `tool_result` 事件拿到真实输出后再做判断,不依赖 Agent 对输出长度的预测。
114
114
  4. 每次工具调用都必须包含非空的 `outputRequest`;严格的 `RAW` 表示明确要求原文;其他非空 prompt 才允许进入提炼流程。
115
115
  5. OpenAI-compatible Completions 提炼请求会通过 `response_format: { "type": "json_object" }` 启用原生 JSON 模式;OpenAI Responses-compatible 请求使用等价的 `text.format`。单次提炼超时后按照 `timeoutRetryCount` 重试,其他模型调用异常按照 `errorRetryCount` 重试(两者默认都重试 1 次);如果模型已经返回文本,但只是 JSON 语法或响应结构校验失败,扩展会把坏响应和校验错误交给一次 JSON-only 修复 prompt,不会再次发送工具输出,也不会重新总结;修复失败、没有可用模型或结果收益过低时,扩展保留原始事实,并通过 details 和审计卡片暴露状态;模型用 Markdown 的 JSON 代码围栏(如 `````json … `````)包裹响应时也会兼容解析。
116
+ 6. 用户打断上级 Agent 请求时,所有尚未完成的提炼请求会立即取消,并且不会为这次中断继续重试;原始工具结果仍按 fail-open 路径保留。
116
117
 
117
118
  ## 输出处理契约
118
119
 
package/SKILL.md ADDED
@@ -0,0 +1,31 @@
1
+ ---
2
+ name: configure-pi-distill
3
+ description: "配置与排查 pi-distill 的模型、压缩阈值、重试、工具开关和审计卡片。Use when configuring pi-distill or diagnosing output distillation."
4
+ ---
5
+
6
+ # 配置 pi-distill
7
+
8
+ ## 诊断
9
+
10
+ 1. 定位实际 Pi agent 目录;默认是 `~/.pi/agent`,设置 `PI_CODING_AGENT_DIR` 时使用该目录。
11
+ 2. 读取 `extensions/pi-distill/config.json`;不存在时从包内 `config.example.json` 建立,不猜字段。
12
+ 3. 同时检查 `PI_DISTILL_*` 和旧 `PI_BASH_SUMMARY_*` 环境变量。JSON 配置优先;环境变量中同名的新 `PI_DISTILL_*` 优先于旧 `PI_BASH_SUMMARY_*`。
13
+
14
+ ## 修改
15
+
16
+ 优先让用户在 Pi 中运行 `/config:distill`;`/pi-distill` 只是兼容别名。手工配置时只使用包内 `config.example.json` 已声明的字段:
17
+
18
+ - `model` 留空时使用当前会话模型,否则必须是可用的 `provider/model`;
19
+ - `minChars` 控制何时提炼,`maxChars` 与 `maxOutputChars` 控制大结果落盘和返回上限;
20
+ - `timeoutRetryCount`、`errorRetryCount` 是额外重试次数;
21
+ - `summarizeErrors` 默认 `true`,控制达到 `minChars` 的错误结果是否提炼;环境变量依次为 `PI_DISTILL_SUMMARIZE_ERRORS`、旧 `PI_BASH_SUMMARY_SUMMARIZE_ERRORS`;
22
+ - `tools.<name>.enabled` 控制单个工具;`edit`、`write` 默认关闭,其他未配置工具默认开启;
23
+ - `render` 只控制展示,不改变提炼语义。
24
+
25
+ 不要把需要完整原文的调用配置成摘要;调用方应传 `outputRequest: "RAW"`。不要为非文本结果启用文本提炼假设。
26
+
27
+ ## 验证
28
+
29
+ - 用 `/distill:stats` 查看当前会话成功、失败、回退、压缩率和模型消耗。
30
+ - 对达到 `minChars` 的文本工具结果观察提炼;再用 `RAW` 确认完整性路径。
31
+ - 当前会话无可用模型或模型调用失败时,必须报告原始结果被保留的 fail-open 行为,不能宣称提炼成功。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-distill",
3
- "version": "1.6.0",
3
+ "version": "1.7.2",
4
4
  "description": "Pi tool-output distillation with file-first configuration",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
@@ -14,7 +14,8 @@
14
14
  "assets",
15
15
  "config.example.json",
16
16
  "README.md",
17
- "README.zh-CN.md"
17
+ "README.zh-CN.md",
18
+ "SKILL.md"
18
19
  ],
19
20
  "scripts": {
20
21
  "test": "tsx --test tests/bash-output-summary.test.ts",
@@ -27,6 +28,9 @@
27
28
  "./index.ts",
28
29
  "../pi-extensions-i18n/index.ts",
29
30
  "../pi-extensions-tool-display/index.ts"
31
+ ],
32
+ "skills": [
33
+ "./SKILL.md"
30
34
  ]
31
35
  },
32
36
  "engines": {
@@ -57,8 +61,8 @@
57
61
  "@earendil-works/pi-tui": ">=0.80.0 <0.81.0"
58
62
  },
59
63
  "dependencies": {
60
- "pi-extensions-i18n": "^0.3.1",
61
- "pi-extensions-tool-display": "^1.0.1"
64
+ "pi-extensions-i18n": "^0.4.0",
65
+ "pi-extensions-tool-display": "^1.1.1"
62
66
  },
63
67
  "devDependencies": {
64
68
  "@earendil-works/pi-ai": "0.80.10",
package/src/index.ts CHANGED
@@ -1628,6 +1628,7 @@ export default function piDistillExtension(pi: ExtensionAPI) {
1628
1628
  toolCallId: event.toolCallId,
1629
1629
  params: { ...event.input, outputRequest },
1630
1630
  originalUserPrompt: pending?.originalUserPrompt ?? originalUserPrompt,
1631
+ signal: ctx.signal,
1631
1632
  ctx,
1632
1633
  },
1633
1634
  {