@oked/sdk 0.6.23 → 0.6.24
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 +20 -0
- package/dist/describe.js +14 -0
- package/package.json +2 -2
package/dist/classify.js
CHANGED
|
@@ -607,6 +607,11 @@ function classifyGhApiStage(stage) {
|
|
|
607
607
|
if (!/^gh\s+api\b/.test(stage))
|
|
608
608
|
return null;
|
|
609
609
|
const method = stage.match(/\s(?:-X|--method)(?:\s+|=)?([A-Za-z]+)\b/)?.[1]?.toUpperCase();
|
|
610
|
+
// A POST to `repos/<owner>/<repo>/pulls` opens a PR. It leaves the machine,
|
|
611
|
+
// but a PR can be closed, so it asks without Face ID.
|
|
612
|
+
if ((!method || method === "POST") && /\s['"]?\/?repos\/[\w.-]+\/[\w.-]+\/pulls['"]?(?:\s|$)/.test(stage)
|
|
613
|
+
&& (method === "POST" || /\s(?:-f|-F|--field|--raw-field|--input)(?:\s|=)/.test(stage)))
|
|
614
|
+
return "review";
|
|
610
615
|
if (method && method !== "GET" && method !== "HEAD")
|
|
611
616
|
return "high_stakes";
|
|
612
617
|
if (/^gh\s+api\s+graphql\b/.test(stage))
|
|
@@ -720,10 +725,23 @@ const CREATED_PATH = "path:";
|
|
|
720
725
|
const TEMP_CWD = "cwd:temp";
|
|
721
726
|
// An earlier stage exported a DATABASE_URL on this machine (see isLocalPrismaDeploy).
|
|
722
727
|
const LOCAL_DB = "db:local";
|
|
728
|
+
// `pid:<NAME>`: an earlier stage set NAME to `$!`, the PID of a job this same
|
|
729
|
+
// command started in the background (`node mock.mjs & MP=$!`).
|
|
730
|
+
const BG_PID = "pid:";
|
|
731
|
+
// `kill $MP` (or `kill "${MP}"`) where an earlier stage set MP=$!: it stops only
|
|
732
|
+
// the background job that this same command started. Nothing outside the
|
|
733
|
+
// command is lost, so it is a reversible local change.
|
|
734
|
+
function isOwnJobKill(stage, vars) {
|
|
735
|
+
const m = stage.match(/^kill\s+(?:-\w+\s+)*"?\$\{?(\w+)\}?"?\s*(?:2>\s*\/dev\/null)?$/);
|
|
736
|
+
return !!m && vars.has(BG_PID + m[1]);
|
|
737
|
+
}
|
|
723
738
|
function noteEphemeralEffects(stage, into) {
|
|
724
739
|
const assign = stage.match(/^(?:export\s+)?(\w+)=("[^"$`]*"|'[^']*'|[^\s;&|$`'"()]+)$/);
|
|
725
740
|
if (assign && isEphemeralPath(unquote(assign[2])))
|
|
726
741
|
into.add(assign[1]);
|
|
742
|
+
const bgPid = stage.match(/(?:^|&\s*)(?:export\s+)?(\w+)=\$!$/);
|
|
743
|
+
if (bgPid)
|
|
744
|
+
into.add(BG_PID + bgPid[1]);
|
|
727
745
|
for (const op of extractShellWriteOps(stage)) {
|
|
728
746
|
if (op.kind === "create" || op.kind === "copy" || op.kind === "touch")
|
|
729
747
|
into.add(CREATED_PATH + unquote(op.target));
|
|
@@ -1750,6 +1768,8 @@ function classifyStageEffects(stage, ephemeralVars, sandboxEnforced) {
|
|
|
1750
1768
|
if (/(?:^|\/)scratchpad\//.test(pattern) || EPHEMERAL_PATH_RE.test(pattern))
|
|
1751
1769
|
return "warning";
|
|
1752
1770
|
}
|
|
1771
|
+
if (isOwnJobKill(bareStage, ephemeralVars))
|
|
1772
|
+
return "warning";
|
|
1753
1773
|
// Stopping a local dev server or a read-only watcher is review: it asks,
|
|
1754
1774
|
// without Face ID.
|
|
1755
1775
|
if (isRestartableKill(bareStage))
|
package/dist/describe.js
CHANGED
|
@@ -555,6 +555,20 @@ function summarizeGh(cmd, cwd) {
|
|
|
555
555
|
return { title: mutation ? "Change data via GitHub GraphQL API" : "Query GitHub GraphQL API", body: truncateBody(cmd), kind: mutation ? "http_post" : "http_get" };
|
|
556
556
|
}
|
|
557
557
|
const m2 = method ?? (/\s(?:-f|-F|--field|--raw-field|--input)(?:\s|=)/.test(args) ? "POST" : "GET");
|
|
558
|
+
// A POST to `repos/<owner>/<repo>/pulls` opens a PR: say so, like `gh pr create`.
|
|
559
|
+
const pulls = endpoint?.match(/^\/?repos\/([\w.-]+\/[\w.-]+)\/pulls$/);
|
|
560
|
+
if (pulls && m2 === "POST") {
|
|
561
|
+
const field = (k) => args.match(new RegExp(`\\s(?:-f|-F|--field|--raw-field)[\\s=]+${k}=(?:'([^']*)'|"((?:[^"\\\\]|\\\\.)*)"|([^\\s'"]+))`));
|
|
562
|
+
const val = (m) => m ? (m[1] ?? m[2] ?? m[3] ?? "") : undefined;
|
|
563
|
+
const head = val(field("head"));
|
|
564
|
+
const base = val(field("base"));
|
|
565
|
+
return {
|
|
566
|
+
title: `Create PR in ${pulls[1]}`,
|
|
567
|
+
target: head && base && !/[$`@]/.test(head + base) ? `${head} → ${base}` : undefined,
|
|
568
|
+
body: truncateBody(cmd),
|
|
569
|
+
kind: "git_pr_create",
|
|
570
|
+
};
|
|
571
|
+
}
|
|
558
572
|
return {
|
|
559
573
|
title: `${m2} request to GitHub API`,
|
|
560
574
|
target: endpoint,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oked/sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.24",
|
|
4
4
|
"description": "OKed SDK - human approval layer for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@oked/receipt-core": "0.6.
|
|
48
|
+
"@oked/receipt-core": "0.6.24"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^26.6.5",
|