@oked/sdk 0.3.3 → 0.3.5
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/dist/classify.js +13 -1
- package/dist/describe.js +21 -7
- package/package.json +1 -1
package/dist/classify.js
CHANGED
|
@@ -1123,7 +1123,19 @@ function splitArgs(s) {
|
|
|
1123
1123
|
function classifyMcpTool(toolName) {
|
|
1124
1124
|
const parts = toolName.split("__");
|
|
1125
1125
|
const tool = parts[parts.length - 1] || "";
|
|
1126
|
-
|
|
1126
|
+
// Read-only retrieval verbs.
|
|
1127
|
+
if (tool.startsWith("list_") || tool.startsWith("get_") || tool.startsWith("search_") ||
|
|
1128
|
+
tool.startsWith("read_") || tool.startsWith("fetch_") || tool.startsWith("query_") ||
|
|
1129
|
+
tool.startsWith("find_") || tool.startsWith("view_") || tool.startsWith("show_") ||
|
|
1130
|
+
tool.startsWith("describe_") || tool.startsWith("inspect_") || tool.startsWith("check_") ||
|
|
1131
|
+
tool.startsWith("count_")) {
|
|
1132
|
+
return "safe";
|
|
1133
|
+
}
|
|
1134
|
+
// Annotation / transcript-marker verbs — they label or organize the session
|
|
1135
|
+
// (mark a chapter, flag a follow-up, dismiss a chip) without touching the
|
|
1136
|
+
// filesystem, network, or any external service, so they auto-allow silently.
|
|
1137
|
+
if (tool.startsWith("mark_") || tool.startsWith("annotate_") || tool.startsWith("tag_") ||
|
|
1138
|
+
tool.startsWith("label_") || tool.startsWith("dismiss_")) {
|
|
1127
1139
|
return "safe";
|
|
1128
1140
|
}
|
|
1129
1141
|
if (tool.endsWith("_status") || tool.endsWith("_info") || tool.endsWith("_count") ||
|
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
|
-
|
|
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
|
-
//
|
|
256
|
-
|
|
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" };
|