@oked/sdk 0.6.12 → 0.6.14
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 -11
- package/dist/describe.d.ts +3 -0
- package/dist/describe.js +21 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/pr-title.d.ts +7 -0
- package/dist/pr-title.js +16 -0
- package/package.json +2 -2
package/dist/classify.js
CHANGED
|
@@ -363,24 +363,32 @@ const MKTEMP_ASSIGN_RE = /^(?:export\s+|declare\s+|local\s+|readonly\s+)?(\w+)=[
|
|
|
363
363
|
// Process names and command lines of local dev servers and dev tooling: Node
|
|
364
364
|
// and Python app servers, bundlers, package-manager scripts, and Node scripts.
|
|
365
365
|
const DEV_PROCESS_RE = /\b(?:node|nodemon|tsx|ts-node|vite|next|nuxt|astro|remix|webpack(?:-dev-server)?|esbuild|parcel|turbo|npm|pnpm|yarn|bun|deno|wrangler|miniflare|uvicorn|gunicorn|flask|runserver|rails|puma|http\.server|http-server|live-server|serve|hugo|jekyll|storybook|expo|metro)\b|\.(?:[cm]?js|tsx?)\b/;
|
|
366
|
+
// Command lines of read-only watchers: a CI watcher (`gh pr checks 136 --watch`,
|
|
367
|
+
// `gh run watch`), a log tail, or a sleep. Stopping one loses nothing, and the
|
|
368
|
+
// agent can start it again.
|
|
369
|
+
const WATCHER_PROCESS_RE = /^(?:gh\s+(?:pr\s+checks|run\s+watch)\b|tail(?:\s+-\w*[fF]\b|$)|sleep\b|watch\b)/;
|
|
370
|
+
function isRestartableProcess(pattern) {
|
|
371
|
+
return DEV_PROCESS_RE.test(pattern) || WATCHER_PROCESS_RE.test(pattern);
|
|
372
|
+
}
|
|
366
373
|
/**
|
|
367
|
-
* A kill of a local dev server: `pkill -f "tsx src/main.ts"`,
|
|
368
|
-
* `kill $(pgrep -f vite)`, or a
|
|
369
|
-
* (`kill $(lsof -t -iTCP:3000 -sTCP:LISTEN)`).
|
|
370
|
-
* ID) for
|
|
371
|
-
*
|
|
374
|
+
* A kill of a local dev server or a read-only watcher: `pkill -f "tsx src/main.ts"`,
|
|
375
|
+
* `pkill -f "gh pr checks 136"`, `killall node`, `kill $(pgrep -f vite)`, or a
|
|
376
|
+
* kill of whatever listens on a port (`kill $(lsof -t -iTCP:3000 -sTCP:LISTEN)`).
|
|
377
|
+
* Oren chose `review` (no Face ID) for dev servers on 2026-10-18 and for
|
|
378
|
+
* watchers on 2026-10-21. A bare `kill <pid>` names no process, so it stays
|
|
379
|
+
* high stakes.
|
|
372
380
|
*/
|
|
373
|
-
function
|
|
381
|
+
function isRestartableKill(stage) {
|
|
374
382
|
const pkill = stage.match(/^pkill\s+(.+)$/);
|
|
375
383
|
if (pkill) {
|
|
376
384
|
const args = splitArgs(pkill[1]).filter((a) => !a.startsWith("-") || a === "-f");
|
|
377
385
|
const pattern = unquote(args[args.indexOf("-f") + 1] ?? args[args.length - 1] ?? "");
|
|
378
|
-
return
|
|
386
|
+
return isRestartableProcess(pattern);
|
|
379
387
|
}
|
|
380
388
|
const killall = stage.match(/^killall\s+(.+)$/);
|
|
381
389
|
if (killall) {
|
|
382
390
|
const names = splitArgs(killall[1]).filter((a) => !a.startsWith("-")).map(unquote);
|
|
383
|
-
return names.length > 0 && names.every((n) =>
|
|
391
|
+
return names.length > 0 && names.every((n) => isRestartableProcess(n));
|
|
384
392
|
}
|
|
385
393
|
const kill = stage.match(/^kill\s+(?:-\w+\s+)*\$\((.+)\)\s*(?:2>\/dev\/null)?$/);
|
|
386
394
|
if (kill) {
|
|
@@ -389,7 +397,7 @@ function isDevServerKill(stage) {
|
|
|
389
397
|
return true;
|
|
390
398
|
const pg = inner.match(/^pgrep\s+(?:-\w+\s+)*(?:-f\s+)?(.+)$/);
|
|
391
399
|
if (pg)
|
|
392
|
-
return
|
|
400
|
+
return isRestartableProcess(unquote(pg[1].trim()));
|
|
393
401
|
}
|
|
394
402
|
return false;
|
|
395
403
|
}
|
|
@@ -1041,8 +1049,9 @@ function classifyStageShellEffects(stage, ephemeralVars = new Set()) {
|
|
|
1041
1049
|
if (/(?:^|\/)scratchpad\//.test(pattern) || EPHEMERAL_PATH_RE.test(pattern))
|
|
1042
1050
|
return "warning";
|
|
1043
1051
|
}
|
|
1044
|
-
// Stopping a local dev server is review: it asks,
|
|
1045
|
-
|
|
1052
|
+
// Stopping a local dev server or a read-only watcher is review: it asks,
|
|
1053
|
+
// without Face ID.
|
|
1054
|
+
if (isRestartableKill(bareStage))
|
|
1046
1055
|
return "review";
|
|
1047
1056
|
for (const pattern of HIGH_STAKES_STAGE) {
|
|
1048
1057
|
if (pattern.test(bareStage))
|
package/dist/describe.d.ts
CHANGED
|
@@ -22,6 +22,9 @@ export interface Rendered {
|
|
|
22
22
|
* package.json behind `npm publish`) to show what an action will touch. */
|
|
23
23
|
export interface DescribeContext {
|
|
24
24
|
cwd?: string;
|
|
25
|
+
/** Title of the PR the card links to, when the command does not say it.
|
|
26
|
+
* `lookupPrTitle()` gets it from GitHub. */
|
|
27
|
+
prTitle?: string;
|
|
25
28
|
}
|
|
26
29
|
export declare function describe(toolName: string, toolInput: Record<string, unknown>, ctx?: DescribeContext): string;
|
|
27
30
|
export declare function describeFields(toolName: string, toolInput: Record<string, unknown>, ctx?: DescribeContext): Record<string, string> | null;
|
package/dist/describe.js
CHANGED
|
@@ -53,6 +53,23 @@ export function describeFields(toolName, toolInput, ctx = {}) {
|
|
|
53
53
|
// Top-level dispatch
|
|
54
54
|
// ───────────────────────────────────────────────────────────────────────
|
|
55
55
|
function summarize(toolName, toolInput, ctx) {
|
|
56
|
+
const r = summarizeTool(toolName, toolInput, ctx);
|
|
57
|
+
return ctx.prTitle ? namePr(r, ctx.prTitle) : r;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* "Merge PR #49 in o/r" says which PR, not what it does. Put the PR title after
|
|
61
|
+
* the number: `Merge PR #49 "feat: OG image" in o/r`. A title that already
|
|
62
|
+
* quotes something keeps it.
|
|
63
|
+
*/
|
|
64
|
+
function namePr(r, prTitle) {
|
|
65
|
+
const num = r.title.match(/\bPR #(\d+)\b/)?.[1];
|
|
66
|
+
// A subject made by `$(…)` or a variable is not known here.
|
|
67
|
+
const name = prTitle.split("\n")[0].replace(new RegExp(`\\s*\\(#${num}\\)$`), "").trim();
|
|
68
|
+
if (!num || !name || /[$`]/.test(name) || r.title.includes('"'))
|
|
69
|
+
return r;
|
|
70
|
+
return { ...r, title: r.title.replace(`PR #${num}`, `PR #${num} "${truncate(name, 60)}"`) };
|
|
71
|
+
}
|
|
72
|
+
function summarizeTool(toolName, toolInput, ctx) {
|
|
56
73
|
const fileSizeBytes = typeof toolInput._file_size_bytes === "number" ? toolInput._file_size_bytes : undefined;
|
|
57
74
|
switch (toolName) {
|
|
58
75
|
case "Bash":
|
|
@@ -498,13 +515,16 @@ function summarizeGh(cmd, cwd) {
|
|
|
498
515
|
if (noun === "pr" && verb === "merge") {
|
|
499
516
|
const how = /\s(?:--squash|-s)\b/.test(rest) ? "squash" : /\s(?:--rebase|-r)\b/.test(rest) ? "rebase" : undefined;
|
|
500
517
|
const auto = /\s--auto\b/.test(rest);
|
|
501
|
-
|
|
518
|
+
// The squash or merge commit subject is the PR title in most merges.
|
|
519
|
+
const subject = rest.match(/\s(?:-t|--subject)[\s=]+(?:'([^']*)'|"((?:[^"\\]|\\.)*)")/);
|
|
520
|
+
const r = {
|
|
502
521
|
title: `Merge PR ${ref}${where}`.replace(/\s+/g, " ").trim(),
|
|
503
522
|
annotation: [how, auto ? "when checks pass" : undefined, /\s(?:--delete-branch|-d)\b/.test(rest) ? "deletes branch" : undefined]
|
|
504
523
|
.filter(Boolean).join(", ") || undefined,
|
|
505
524
|
link,
|
|
506
525
|
kind: "git_pr_merge",
|
|
507
526
|
};
|
|
527
|
+
return subject ? namePr(r, subject[1] ?? subject[2] ?? "") : r;
|
|
508
528
|
}
|
|
509
529
|
if (noun === "api") {
|
|
510
530
|
const args = ` ${verb}${rest}`;
|
package/dist/index.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ export { verifyReceipt, verifyChain, shortReceiptId, type SignedReceipt, type Re
|
|
|
48
48
|
export { TIER_ORDER, degradedDecision } from "./degraded.js";
|
|
49
49
|
export { classify } from "./classify.js";
|
|
50
50
|
export { describe, describeFields } from "./describe.js";
|
|
51
|
+
export { lookupPrTitle } from "./pr-title.js";
|
|
51
52
|
export { applyRules } from "./rules.js";
|
|
52
53
|
export type { Rule, RuleMatch, RuleAction, RuleDecision, FieldOp, } from "./rules.js";
|
|
53
54
|
export type { Rendered } from "./describe.js";
|
package/dist/index.js
CHANGED
|
@@ -399,6 +399,7 @@ export { verifyReceipt, verifyChain, shortReceiptId, } from "@oked/receipt-core"
|
|
|
399
399
|
export { TIER_ORDER, degradedDecision } from "./degraded.js";
|
|
400
400
|
export { classify } from "./classify.js";
|
|
401
401
|
export { describe, describeFields } from "./describe.js";
|
|
402
|
+
export { lookupPrTitle } from "./pr-title.js";
|
|
402
403
|
export { applyRules } from "./rules.js";
|
|
403
404
|
export { CLASSIFIER_VERSION } from "./kinds.js";
|
|
404
405
|
export { loadOKedConfig, OKED_CONFIG_PATH, OKED_RECEIPT_KEYS_PATH } from "./config.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Title of the PR that a card links to, from GitHub (`gh pr view`), for a card
|
|
3
|
+
* whose command does not say it. Pass the result to `describeFields()` as
|
|
4
|
+
* `prTitle`. Returns undefined when the card needs no title, or when gh is not
|
|
5
|
+
* installed, not signed in, or slower than `timeoutMs`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function lookupPrTitle(fields: Record<string, string> | undefined, timeoutMs?: number): Promise<string | undefined>;
|
package/dist/pr-title.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
/**
|
|
3
|
+
* Title of the PR that a card links to, from GitHub (`gh pr view`), for a card
|
|
4
|
+
* whose command does not say it. Pass the result to `describeFields()` as
|
|
5
|
+
* `prTitle`. Returns undefined when the card needs no title, or when gh is not
|
|
6
|
+
* installed, not signed in, or slower than `timeoutMs`.
|
|
7
|
+
*/
|
|
8
|
+
export function lookupPrTitle(fields, timeoutMs = 3000) {
|
|
9
|
+
const link = fields?.Link;
|
|
10
|
+
if (!link || !/^https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/pull\/\d+$/.test(link) || fields.Title?.includes('"')) {
|
|
11
|
+
return Promise.resolve(undefined);
|
|
12
|
+
}
|
|
13
|
+
return new Promise((done) => {
|
|
14
|
+
execFile("gh", ["pr", "view", link, "--json", "title", "--jq", ".title"], { timeout: timeoutMs, env: { ...process.env, GH_PROMPT_DISABLED: "1" } }, (err, stdout) => done(err ? undefined : stdout.trim().split("\n")[0] || undefined));
|
|
15
|
+
});
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oked/sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.14",
|
|
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.14"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^22.13.10",
|