@trim21/personal-pi-extensions 0.0.238 → 0.0.240

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
@@ -56,7 +56,7 @@ bash 工具(opencode 风格 `bash`、Claude Code 风格 `Bash`)注册了 `da
56
56
 
57
57
  配置文件(项目优先于全局):
58
58
 
59
- - `~/.pi/agent/extensions/bwrap.json`(全局)
59
+ - `~/.pi/agent/bwrap.json`(全局)
60
60
  - `.pi/bwrap.json`(项目)
61
61
 
62
62
  ```jsonc
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trim21/personal-pi-extensions",
3
- "version": "0.0.238",
3
+ "version": "0.0.240",
4
4
  "type": "module",
5
5
  "description": "Custom pi coding-agent extensions: bwrap sandbox, workspace guard, opencode edit, and more",
6
6
  "keywords": [
package/src/bwrap/core.ts CHANGED
@@ -126,7 +126,7 @@ export interface BwrapConfigPaths {
126
126
 
127
127
  export function getBwrapConfigPaths(cwd: string): BwrapConfigPaths {
128
128
  return {
129
- global: join(getAgentDir(), "extensions", "bwrap.json"),
129
+ global: join(getAgentDir(), "bwrap.json"),
130
130
  project: join(cwd, ".pi", "bwrap.json"),
131
131
  };
132
132
  }
@@ -46,6 +46,8 @@ interface GhResult {
46
46
  combined: string;
47
47
  /** Why the process was killed, when `killed` is true. */
48
48
  reason?: "timeout" | "abort";
49
+ /** When the process could not be started at all (e.g. `gh` not found in PATH). */
50
+ spawnError?: string;
49
51
  }
50
52
 
51
53
  // ── helpers ──────────────────────────────────────────────────────────────────
@@ -131,12 +133,22 @@ export function runGh(
131
133
  });
132
134
  });
133
135
 
134
- proc.on("error", () => {
136
+ proc.on("error", (err: Error) => {
135
137
  if (timeoutId) clearTimeout(timeoutId);
136
138
  if (onAbort && ctx.signal) {
137
139
  ctx.signal.removeEventListener("abort", onAbort);
138
140
  }
139
- resolve({ stdout, stderr, code: 1, killed, combined: combined.join(""), reason: killReason });
141
+ // spawn 失败(如 gh 不在 PATH ENOENT、cwd 不存在)时进程从未启动,
142
+ // 没有任何 stdout/stderr;把底层错误带上,否则会退化成无信息的 "exit code 1"。
143
+ resolve({
144
+ stdout,
145
+ stderr,
146
+ code: 1,
147
+ killed,
148
+ combined: combined.join(""),
149
+ reason: killReason,
150
+ spawnError: err.message,
151
+ });
140
152
  });
141
153
  });
142
154
  }
@@ -162,9 +174,21 @@ export class GhError extends Error {
162
174
  ? " (command aborted)"
163
175
  : ""
164
176
  : "";
165
- super(
166
- `${inputText}<output>${result.combined.trim() || `exit code ${result.code}`}${killedText}<output>`,
167
- );
177
+
178
+ // The process never started (e.g. `gh` not found): surface the spawn error.
179
+ // Otherwise show the command's own output; an empty output with a non-zero
180
+ // exit is explicitly marked, so a bare "exit code 1" can't be mistaken for
181
+ // a specific failure.
182
+ let outputText: string;
183
+ if (result.spawnError) {
184
+ outputText = `spawn failed: ${result.spawnError}`;
185
+ } else if (result.combined.trim()) {
186
+ outputText = result.combined.trim();
187
+ } else {
188
+ outputText = `exit code ${result.code} (no output)`;
189
+ }
190
+
191
+ super(`${inputText}<output>${outputText}${killedText}<output>`);
168
192
  this.name = "GhError";
169
193
  this.args = args;
170
194
  this.code = result.code;