@oked/sdk 0.3.3 → 0.3.4

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/dist/describe.js +21 -7
  2. package/package.json +1 -1
package/dist/describe.js CHANGED
@@ -130,8 +130,12 @@ function summarizeBash(command, sizeBytes) {
130
130
  const shellWrite = summarizeShellWrite(cmd);
131
131
  if (shellWrite)
132
132
  return shellWrite;
133
- // rm / trash — file deletion
134
- const rmMatch = cmd.match(/\b(?:rm|trash|trash-put|rmdir)\s+(?:(-rf?|-fr|--recursive|-r)\s+)?(.+)$/);
133
+ // rm / trash — file deletion. Match the delete's OWN line (`[^\n]+`), not
134
+ // `(.+)$`: without the `m` flag `$` only reaches end-of-string, so a `rm` on
135
+ // an interior line of a multi-line script (e.g. `rm "$WT/node_modules"` before
136
+ // a trailing `cd … && git status`) wouldn't match and the card fell back to
137
+ // the generic "Run command".
138
+ const rmMatch = cmd.match(/\b(?:rm|trash|trash-put|rmdir)\s+(?:(-rf?|-fr|--recursive|-r)\s+)?([^\n]+)/);
135
139
  if (rmMatch) {
136
140
  const recursive = !!rmMatch[1] || /^rm\s+-/.test(cmd);
137
141
  const targets = parseRmTargets(rmMatch[2]);
@@ -222,6 +226,19 @@ function summarizeBash(command, sizeBytes) {
222
226
  if (h)
223
227
  return h;
224
228
  }
229
+ // Process kill in COMMAND POSITION — headline it ahead of the compound
230
+ // "Run command" catch-all below, so a cleanup script like
231
+ // `if pgrep …; then pkill -f …; fi` reads "Kill processes", not "Run command".
232
+ // Command-position only (stage start, after ;/&&/||/newline/$( / a keyword),
233
+ // so "kill" inside echo text (e.g. "killing it") doesn't mislabel.
234
+ const killM = cmd.match(/(?:^|[\n;&|`({]|\$\(|\b(?:sudo|then|do|else|command|xargs)\s+)\s*(killall|pkill|kill)\b/);
235
+ if (killM) {
236
+ return {
237
+ title: killM[1].toLowerCase() === "kill" ? "Kill process" : "Kill processes",
238
+ body: truncateBody(cmd),
239
+ kind: "kill_process",
240
+ };
241
+ }
225
242
  // Multi-step pipeline
226
243
  if (/&&|\|\||;/.test(cmd))
227
244
  return { title: "Run command", body: truncateBody(cmd), kind: "shell_pipeline" };
@@ -252,11 +269,8 @@ function summarizeBash(command, sizeBytes) {
252
269
  return { title: "Unpublish package from npm", kind: "npm_unpublish" };
253
270
  if (/\bnpx\s+.*\s+deploy\b/.test(cmd))
254
271
  return { title: "Deploy via npx", body: truncateBody(cmd), kind: "npx_deploy" };
255
- // kill / sudo / chmod
256
- if (/\bkillall\b|\bpkill\b/.test(cmd))
257
- return { title: "Kill processes", body: truncateBody(cmd), kind: "kill_process" };
258
- if (/\bkill\b/.test(cmd))
259
- return { title: "Kill process", body: truncateBody(cmd), kind: "kill_process" };
272
+ // sudo / chmod (kill/pkill/killall are handled in command position above,
273
+ // ahead of the compound catch-all).
260
274
  if (/\bsudo\b/.test(cmd)) {
261
275
  const inner = cmd.replace(/^sudo\s+/, "");
262
276
  return { title: `Run as root: ${truncate(inner, COMMAND_INLINE_MAX)}`, body: truncateBody(cmd), kind: "sudo" };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oked/sdk",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "OKed SDK - human approval layer for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",