@trim21/personal-pi-extensions 0.0.131 → 0.0.134

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/gh-readonly.ts +35 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trim21/personal-pi-extensions",
3
- "version": "0.0.131",
3
+ "version": "0.0.134",
4
4
  "type": "module",
5
5
  "description": "Custom pi coding-agent extensions: bwrap sandbox, workspace guard, opencode edit, and more",
6
6
  "keywords": [
@@ -258,12 +258,18 @@ function truncate(
258
258
  * Format a successful gh invocation's stdout into a tool result.
259
259
  * Failures are thrown by `ghExec` as `GhError`, so only the success path lives here.
260
260
  */
261
- function toToolResult(stdout: string): {
261
+ function toToolResult(
262
+ stdout: string,
263
+ input?: unknown,
264
+ ): {
262
265
  content: Array<{ type: "text"; text: string }>;
263
266
  details: Record<string, unknown>;
264
267
  } {
265
268
  const { text, truncated } = truncate(stdout);
266
- return { content: [{ type: "text", text }], details: { truncated } };
269
+ return {
270
+ content: [{ type: "text", text }],
271
+ details: { ...(input !== undefined ? { input } : {}), truncated },
272
+ };
267
273
  }
268
274
 
269
275
  interface ListFilters {
@@ -883,6 +889,7 @@ export default function (pi: ExtensionAPI) {
883
889
  ],
884
890
  { cwd: ctx.cwd, signal, input: params },
885
891
  ),
892
+ params,
886
893
  );
887
894
  },
888
895
  });
@@ -907,6 +914,7 @@ export default function (pi: ExtensionAPI) {
907
914
  async execute(_id, params, signal, _onUpdate, ctx) {
908
915
  return toToolResult(
909
916
  await listGithub("issue", params, { cwd: ctx.cwd, signal, input: params }),
917
+ params,
910
918
  );
911
919
  },
912
920
  });
@@ -935,6 +943,7 @@ export default function (pi: ExtensionAPI) {
935
943
  ],
936
944
  { cwd: ctx.cwd, signal, input: params },
937
945
  ),
946
+ params,
938
947
  );
939
948
  },
940
949
  });
@@ -959,7 +968,10 @@ export default function (pi: ExtensionAPI) {
959
968
  limit: Type.Optional(Type.Number({ description: "Max results (default 30)" })),
960
969
  }),
961
970
  async execute(_id, params, signal, _onUpdate, ctx) {
962
- return toToolResult(await listGithub("pr", params, { cwd: ctx.cwd, signal, input: params }));
971
+ return toToolResult(
972
+ await listGithub("pr", params, { cwd: ctx.cwd, signal, input: params }),
973
+ params,
974
+ );
963
975
  },
964
976
  });
965
977
 
@@ -976,7 +988,7 @@ export default function (pi: ExtensionAPI) {
976
988
  async execute(_id, params, signal, _onUpdate, ctx) {
977
989
  const { number, repo } = params;
978
990
  const args = ["pr", "diff", String(number), ...repoArgs(repo)];
979
- return toToolResult(await ghExec(args, { cwd: ctx.cwd, signal, input: params }));
991
+ return toToolResult(await ghExec(args, { cwd: ctx.cwd, signal, input: params }), params);
980
992
  },
981
993
  });
982
994
 
@@ -1003,7 +1015,7 @@ export default function (pi: ExtensionAPI) {
1003
1015
  // Anything else is a real error (cancelled, auth, network, ...)
1004
1016
  throw new GhError(args, final, params);
1005
1017
  }
1006
- return toToolResult(final.stdout);
1018
+ return toToolResult(final.stdout, params);
1007
1019
  },
1008
1020
  });
1009
1021
 
@@ -1067,7 +1079,7 @@ export default function (pi: ExtensionAPI) {
1067
1079
  const { text, truncated } = truncate(out);
1068
1080
  return {
1069
1081
  content: [{ type: "text", text }],
1070
- details: { truncated },
1082
+ details: { input: params, truncated },
1071
1083
  };
1072
1084
  },
1073
1085
  });
@@ -1090,6 +1102,7 @@ export default function (pi: ExtensionAPI) {
1090
1102
  signal,
1091
1103
  input: params,
1092
1104
  }),
1105
+ params,
1093
1106
  );
1094
1107
  },
1095
1108
  });
@@ -1114,7 +1127,7 @@ export default function (pi: ExtensionAPI) {
1114
1127
  if (limit) args.push("--limit", String(limit));
1115
1128
  if (status) args.push("--status", status);
1116
1129
  if (workflow) args.push("--workflow", workflow);
1117
- return toToolResult(await ghExec(args, { cwd: ctx.cwd, signal, input: params }));
1130
+ return toToolResult(await ghExec(args, { cwd: ctx.cwd, signal, input: params }), params);
1118
1131
  },
1119
1132
  });
1120
1133
 
@@ -1172,12 +1185,13 @@ export default function (pi: ExtensionAPI) {
1172
1185
  content: [{ type: "text", text: `Fetching job list...` }],
1173
1186
  details: {},
1174
1187
  });
1175
- return renderStepLog(
1188
+ const stepResult = await renderStepLog(
1176
1189
  { runId: String(run_id), job, step, offset, limit },
1177
1190
  jobs,
1178
1191
  fetchJobLog,
1179
1192
  onUpdate,
1180
1193
  );
1194
+ return { ...stepResult, details: { ...stepResult.details, input: params } };
1181
1195
  }
1182
1196
 
1183
1197
  // ── List jobs/steps, with failed step logs expanded ────────────────
@@ -1185,7 +1199,12 @@ export default function (pi: ExtensionAPI) {
1185
1199
  content: [{ type: "text", text: `Fetching job list...` }],
1186
1200
  details: {},
1187
1201
  });
1188
- return renderJobLogs({ runId: String(run_id), job, offset, limit }, jobs, fetchJobLog);
1202
+ const jobsResult = await renderJobLogs(
1203
+ { runId: String(run_id), job, offset, limit },
1204
+ jobs,
1205
+ fetchJobLog,
1206
+ );
1207
+ return { ...jobsResult, details: { ...jobsResult.details, input: params } };
1189
1208
  },
1190
1209
  });
1191
1210
 
@@ -1209,6 +1228,7 @@ export default function (pi: ExtensionAPI) {
1209
1228
  signal,
1210
1229
  input: params,
1211
1230
  }),
1231
+ params,
1212
1232
  );
1213
1233
  },
1214
1234
  });
@@ -1226,7 +1246,7 @@ export default function (pi: ExtensionAPI) {
1226
1246
  const { repo } = params;
1227
1247
  const args = ["repo", "view"];
1228
1248
  if (repo) args.push(repo);
1229
- return toToolResult(await ghExec(args, { cwd: ctx.cwd, signal, input: params }));
1249
+ return toToolResult(await ghExec(args, { cwd: ctx.cwd, signal, input: params }), params);
1230
1250
  },
1231
1251
  });
1232
1252
 
@@ -1244,7 +1264,7 @@ export default function (pi: ExtensionAPI) {
1244
1264
  const { repo, limit } = params;
1245
1265
  const args = ["release", "list", ...repoArgs(repo)];
1246
1266
  if (limit) args.push("--limit", String(limit));
1247
- return toToolResult(await ghExec(args, { cwd: ctx.cwd, signal, input: params }));
1267
+ return toToolResult(await ghExec(args, { cwd: ctx.cwd, signal, input: params }), params);
1248
1268
  },
1249
1269
  });
1250
1270
 
@@ -1266,6 +1286,7 @@ export default function (pi: ExtensionAPI) {
1266
1286
  signal,
1267
1287
  input: params,
1268
1288
  }),
1289
+ params,
1269
1290
  );
1270
1291
  },
1271
1292
  });
@@ -1308,7 +1329,7 @@ export default function (pi: ExtensionAPI) {
1308
1329
  content: [
1309
1330
  { type: "text", text: `## PR #${number} CI Checks - FAILED\n\n${stdout}\n${stderr}` },
1310
1331
  ],
1311
- details: { status: "failure", exitCode },
1332
+ details: { status: "failure", exitCode, input: params },
1312
1333
  };
1313
1334
  }
1314
1335
 
@@ -1318,7 +1339,7 @@ export default function (pi: ExtensionAPI) {
1318
1339
 
1319
1340
  return {
1320
1341
  content: [{ type: "text", text: `## PR #${number} CI Checks - PASSED\n\n${stdout}` }],
1321
- details: { status: "success", exitCode: 0 },
1342
+ details: { status: "success", exitCode: 0, input: params },
1322
1343
  };
1323
1344
  },
1324
1345
  });
@@ -1357,7 +1378,7 @@ export default function (pi: ExtensionAPI) {
1357
1378
  content: [
1358
1379
  { type: "text", text: `## Workflow Run ${run_id} Completed\n\n${result.stdout}` },
1359
1380
  ],
1360
- details: { exitCode: 0 },
1381
+ details: { exitCode: 0, input: params },
1361
1382
  };
1362
1383
  },
1363
1384
  });