@trim21/personal-pi-extensions 0.1.20261019144232 → 0.1.20261022015401

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trim21/personal-pi-extensions",
3
- "version": "0.1.20261019144232",
3
+ "version": "0.1.20261022015401",
4
4
  "type": "module",
5
5
  "description": "Custom pi coding-agent extensions: bwrap sandbox, workspace guard, opencode edit, and more",
6
6
  "keywords": [
@@ -21,6 +21,7 @@ import {
21
21
  BASH_MAX_TIMEOUT_MS,
22
22
  bashStructuredSchema,
23
23
  spilledOutput,
24
+ systemReminder,
24
25
  } from "../lib/bash-tool.js";
25
26
  import { resolveWorkdir } from "../lib/path.js";
26
27
  import { defineStructuredTool, type ToolBus } from "../lib/tool-bus.js";
@@ -163,7 +164,9 @@ export function registerShellTools(bus: ToolBus, pi: ExtensionAPI, runtime: Bwra
163
164
  if (error.kind === "aborted") {
164
165
  // 用户取消:直接返回已捕获的输出,不抛错;时长只算命令真正运行的时间,
165
166
  // 不含审批弹窗等 UI 交互
166
- const status = `Command aborted by user after ${formatElapsedSeconds(error.elapsedMs)}`;
167
+ const status = systemReminder(
168
+ `Command aborted by user after ${formatElapsedSeconds(error.elapsedMs)}`,
169
+ );
167
170
  return {
168
171
  content: [
169
172
  { type: "text" as const, text: text ? `${text}\n\n${status}` : status },
@@ -183,9 +186,8 @@ export function registerShellTools(bus: ToolBus, pi: ExtensionAPI, runtime: Bwra
183
186
  },
184
187
  };
185
188
  }
186
- const full = text
187
- ? `${text}\n\nCommand timed out after ${timeout} milliseconds`
188
- : `Command timed out after ${timeout} milliseconds`;
189
+ const status = systemReminder(`Command timed out after ${timeout} milliseconds`);
190
+ const full = text ? `${text}\n\n${status}` : status;
189
191
  return {
190
192
  content: [
191
193
  { type: "text" as const, text: full },
@@ -14,6 +14,11 @@ import { Type } from "typebox";
14
14
  export const BASH_DEFAULT_TIMEOUT_MS = 120_000;
15
15
  export const BASH_MAX_TIMEOUT_MS = 7_200_000;
16
16
 
17
+ /** 工具追加的状态行(超时、用户取消)统一包成系统提醒,避免被当成命令输出。 */
18
+ export function systemReminder(text: string): string {
19
+ return `<system-reminder>\n${text}\n</system-reminder>`;
20
+ }
21
+
17
22
  /**
18
23
  * `Bash` 的结构化结果:只有退出码与完整输出——命令非零退出不是失败,所以载荷里没有成败
19
24
  * 标志,脚本直接读 `exitCode` 分支;超时/中止时 `exitCode` 为 `null`(原因在模型侧文本里)。
@@ -16,6 +16,7 @@ import {
16
16
  BASH_MAX_TIMEOUT_MS,
17
17
  bashStructuredSchema,
18
18
  spilledOutput,
19
+ systemReminder,
19
20
  } from "../lib/bash-tool.js";
20
21
  import { resolveWorkdir } from "../lib/path.js";
21
22
  import { createRequestPolicy } from "../lib/request-policy.js";
@@ -127,10 +128,11 @@ export function registerBashTool(bus: ToolBus, pi: ExtensionAPI, runtime: BwrapR
127
128
  error.partial.truncation,
128
129
  error.partial.fullOutputPath,
129
130
  );
130
- const status =
131
+ const status = systemReminder(
131
132
  error.kind === "timeout"
132
133
  ? `Command exceeded timeout of ${timeout} ms. Retry with a larger timeout if the command is expected to take longer.`
133
- : `Command aborted by user after ${formatElapsedSeconds(error.elapsedMs)}`;
134
+ : `Command aborted by user after ${formatElapsedSeconds(error.elapsedMs)}`,
135
+ );
134
136
  const full = text ? `${text}\n\n${status}` : status;
135
137
  // 对齐上游 opencode:超时与中断都不抛错,输出与状态文本一起返回;
136
138
  // 超时可能是沙箱的网络限制导致的,附加沙箱状态(用户中断与沙箱无关)