@oked/sdk 0.6.11 → 0.6.12
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/describe.d.ts +2 -1
- package/dist/describe.js +17 -5
- package/package.json +2 -2
package/dist/describe.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* approvals. Output is a sentence-shaped Rendered value: title + optional
|
|
4
4
|
* subline + optional body (quoted block) + optional footnote.
|
|
5
5
|
*
|
|
6
|
-
* Surfaces (Telegram, dashboard) consume Title/Subline/Body/Footnote keys
|
|
6
|
+
* Surfaces (Telegram, dashboard) consume Title/Subline/Body/Footnote/Link keys
|
|
7
7
|
* from the `fields` payload. `describe()` returns just the title for
|
|
8
8
|
* backwards-compatible single-line consumers (audit logs, SMS).
|
|
9
9
|
*/
|
|
@@ -15,6 +15,7 @@ export interface Rendered {
|
|
|
15
15
|
subline?: string;
|
|
16
16
|
body?: string;
|
|
17
17
|
footnote?: string;
|
|
18
|
+
link?: string;
|
|
18
19
|
kind: OperationKind;
|
|
19
20
|
}
|
|
20
21
|
/** Optional caller context. `cwd` lets describers read local files (e.g. the
|
package/dist/describe.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* approvals. Output is a sentence-shaped Rendered value: title + optional
|
|
4
4
|
* subline + optional body (quoted block) + optional footnote.
|
|
5
5
|
*
|
|
6
|
-
* Surfaces (Telegram, dashboard) consume Title/Subline/Body/Footnote keys
|
|
6
|
+
* Surfaces (Telegram, dashboard) consume Title/Subline/Body/Footnote/Link keys
|
|
7
7
|
* from the `fields` payload. `describe()` returns just the title for
|
|
8
8
|
* backwards-compatible single-line consumers (audit logs, SMS).
|
|
9
9
|
*/
|
|
@@ -45,6 +45,8 @@ export function describeFields(toolName, toolInput, ctx = {}) {
|
|
|
45
45
|
out.Body = r.body;
|
|
46
46
|
if (r.footnote)
|
|
47
47
|
out.Footnote = r.footnote;
|
|
48
|
+
if (r.link)
|
|
49
|
+
out.Link = r.link;
|
|
48
50
|
return out;
|
|
49
51
|
}
|
|
50
52
|
// ───────────────────────────────────────────────────────────────────────
|
|
@@ -321,7 +323,7 @@ function summarizeBash(command, sizeBytes, cwd) {
|
|
|
321
323
|
? { title: `Git commit "${truncate(m[1].split("\n")[0].trim(), 60)}"${where}`, kind: "git_commit" }
|
|
322
324
|
: { title: `Git commit${where}`, kind: "git_commit" };
|
|
323
325
|
}
|
|
324
|
-
const gh = summarizeGh(cmd);
|
|
326
|
+
const gh = summarizeGh(cmd, cwd);
|
|
325
327
|
if (gh)
|
|
326
328
|
return gh;
|
|
327
329
|
// gh pr create — reversible (PRs can be closed). Extract --title when present.
|
|
@@ -475,17 +477,24 @@ function describeStep(step, cwd) {
|
|
|
475
477
|
return r.target && !r.title.includes(r.target) ? `${r.title} ${r.target}` : r.title;
|
|
476
478
|
}
|
|
477
479
|
/** GitHub CLI writes: which PR, issue or release, in which repo. */
|
|
478
|
-
|
|
479
|
-
|
|
480
|
+
const GH_RE = /\bgh\s+(pr|issue|release|repo|workflow|run|secret|variable|api)\s+(\S+)(.*)$/s;
|
|
481
|
+
function summarizeGh(cmd, cwd) {
|
|
482
|
+
const m = cmd.match(GH_RE);
|
|
480
483
|
if (!m)
|
|
481
484
|
return null;
|
|
482
485
|
const [, noun, verb, rest] = m;
|
|
483
486
|
const url = rest.match(/https:\/\/github\.com\/([^/\s]+\/[^/\s]+)\/(?:pull|issues)\/(\d+)/);
|
|
484
487
|
const repoFlag = rest.match(/\s(?:-R|--repo)[\s=]+(\S+)/)?.[1];
|
|
485
|
-
|
|
488
|
+
// With no URL and no --repo, gh acts on the GitHub repo of its folder.
|
|
489
|
+
const repo = url?.[1] ?? (repoFlag ? stripQuotes(repoFlag) : undefined) ?? gitRepoFor(cmd, GH_RE, cwd)?.github;
|
|
486
490
|
const num = url?.[2] ?? rest.match(/^\s+#?(\d+)\b/)?.[1];
|
|
487
491
|
const ref = num ? `#${num}` : "";
|
|
488
492
|
const where = repo ? ` in ${repo}` : "";
|
|
493
|
+
// `-R github.com/owner/name` and `-R owner/name` are on github.com; other hosts get no link.
|
|
494
|
+
const slug = repo?.replace(/^github\.com\//, "");
|
|
495
|
+
const link = slug && /^[^/]+\/[^/]+$/.test(slug) && num && (noun === "pr" || noun === "issue")
|
|
496
|
+
? `https://github.com/${slug}/${noun === "pr" ? "pull" : "issues"}/${num}`
|
|
497
|
+
: undefined;
|
|
489
498
|
if (noun === "pr" && verb === "merge") {
|
|
490
499
|
const how = /\s(?:--squash|-s)\b/.test(rest) ? "squash" : /\s(?:--rebase|-r)\b/.test(rest) ? "rebase" : undefined;
|
|
491
500
|
const auto = /\s--auto\b/.test(rest);
|
|
@@ -493,6 +502,7 @@ function summarizeGh(cmd) {
|
|
|
493
502
|
title: `Merge PR ${ref}${where}`.replace(/\s+/g, " ").trim(),
|
|
494
503
|
annotation: [how, auto ? "when checks pass" : undefined, /\s(?:--delete-branch|-d)\b/.test(rest) ? "deletes branch" : undefined]
|
|
495
504
|
.filter(Boolean).join(", ") || undefined,
|
|
505
|
+
link,
|
|
496
506
|
kind: "git_pr_merge",
|
|
497
507
|
};
|
|
498
508
|
}
|
|
@@ -531,6 +541,7 @@ function summarizeGh(cmd) {
|
|
|
531
541
|
return {
|
|
532
542
|
title: `${phrase}${where}`,
|
|
533
543
|
body: body ? truncateBody(body[1] ?? body[2] ?? "") : undefined,
|
|
544
|
+
link,
|
|
534
545
|
kind: noun === "pr" ? "git_pr_write" : "gh_write",
|
|
535
546
|
};
|
|
536
547
|
}
|
|
@@ -1811,6 +1822,7 @@ function readGitRepo(start) {
|
|
|
1811
1822
|
const mainTop = basename(commonDir) === ".git" ? dirname(commonDir) : top;
|
|
1812
1823
|
return {
|
|
1813
1824
|
name: repoSlug(remotes.get("origin")) ?? basename(mainTop),
|
|
1825
|
+
github: /^(?:https?:\/\/(?:[^@/]+@)?|ssh:\/\/[^@/]+@|[^@\s/]+@)github\.com[:/]/i.test(remotes.get("origin") ?? "") ? repoSlug(remotes.get("origin")) : undefined,
|
|
1814
1826
|
remotes,
|
|
1815
1827
|
branch: head.match(/^ref:\s*refs\/heads\/(.+?)\s*$/m)?.[1],
|
|
1816
1828
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oked/sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.12",
|
|
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.12"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^22.13.10",
|