@phren/cli 0.3.37 → 0.3.39

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 (93) hide show
  1. package/dist/bridge/account-failover.d.ts +4 -0
  2. package/dist/bridge/account-failover.js +12 -4
  3. package/dist/bridge/account-usage.d.ts +5 -2
  4. package/dist/bridge/account-usage.js +36 -6
  5. package/dist/bridge/agent-hooks.js +2 -0
  6. package/dist/bridge/changes.d.ts +5 -0
  7. package/dist/bridge/changes.js +4 -0
  8. package/dist/bridge/claude-accounts.d.ts +15 -4
  9. package/dist/bridge/claude-accounts.js +31 -16
  10. package/dist/bridge/claude-credits.d.ts +43 -0
  11. package/dist/bridge/claude-credits.js +236 -0
  12. package/dist/bridge/claude-question-dialog.js +6 -2
  13. package/dist/bridge/command.js +64 -3
  14. package/dist/bridge/device-enroll.d.ts +34 -0
  15. package/dist/bridge/device-enroll.js +57 -0
  16. package/dist/bridge/dispatch-command.d.ts +2 -0
  17. package/dist/bridge/dispatch-command.js +25 -1
  18. package/dist/bridge/dispatch-returns.d.ts +7 -0
  19. package/dist/bridge/dispatch-returns.js +56 -6
  20. package/dist/bridge/dispatch.d.ts +52 -0
  21. package/dist/bridge/dispatch.js +14 -0
  22. package/dist/bridge/file-range.d.ts +3 -0
  23. package/dist/bridge/file-range.js +5 -4
  24. package/dist/bridge/file-search.d.ts +37 -0
  25. package/dist/bridge/file-search.js +87 -0
  26. package/dist/bridge/file-write.d.ts +6 -0
  27. package/dist/bridge/file-write.js +120 -0
  28. package/dist/bridge/git-host-auth.d.ts +31 -0
  29. package/dist/bridge/git-host-auth.js +110 -0
  30. package/dist/bridge/git-host-gitboy.d.ts +46 -0
  31. package/dist/bridge/git-host-gitboy.js +296 -0
  32. package/dist/bridge/git-host-gitlab.d.ts +25 -0
  33. package/dist/bridge/git-host-gitlab.js +229 -0
  34. package/dist/bridge/git-host-http.d.ts +33 -0
  35. package/dist/bridge/git-host-http.js +70 -0
  36. package/dist/bridge/git-hosts.d.ts +92 -0
  37. package/dist/bridge/git-hosts.js +244 -0
  38. package/dist/bridge/git-publish.d.ts +15 -5
  39. package/dist/bridge/git-publish.js +69 -21
  40. package/dist/bridge/git-review.d.ts +23 -0
  41. package/dist/bridge/git-review.js +170 -0
  42. package/dist/bridge/git-sync.d.ts +14 -0
  43. package/dist/bridge/git-sync.js +143 -0
  44. package/dist/bridge/git.d.ts +20 -7
  45. package/dist/bridge/git.js +87 -68
  46. package/dist/bridge/gitboy-contract.d.ts +32 -0
  47. package/dist/bridge/gitboy-contract.js +46 -0
  48. package/dist/bridge/hand-off.d.ts +52 -2
  49. package/dist/bridge/hand-off.js +77 -24
  50. package/dist/bridge/health.d.ts +1 -1
  51. package/dist/bridge/health.js +5 -3
  52. package/dist/bridge/install.d.ts +14 -0
  53. package/dist/bridge/install.js +40 -1
  54. package/dist/bridge/memory-store.d.ts +8 -0
  55. package/dist/bridge/memory-store.js +80 -2
  56. package/dist/bridge/pair.d.ts +6 -1
  57. package/dist/bridge/pair.js +74 -2
  58. package/dist/bridge/project-memory.d.ts +94 -0
  59. package/dist/bridge/project-memory.js +235 -0
  60. package/dist/bridge/push.d.ts +15 -0
  61. package/dist/bridge/push.js +39 -0
  62. package/dist/bridge/scoped-gateway.d.ts +29 -0
  63. package/dist/bridge/scoped-gateway.js +239 -0
  64. package/dist/bridge/server-launch.d.ts +12 -0
  65. package/dist/bridge/server-launch.js +17 -10
  66. package/dist/bridge/server-pane-routes.js +54 -3
  67. package/dist/bridge/server-routes.d.ts +12 -0
  68. package/dist/bridge/server-routes.js +59 -4
  69. package/dist/bridge/server.js +44 -5
  70. package/dist/bridge/session-move.d.ts +288 -0
  71. package/dist/bridge/session-move.js +600 -0
  72. package/dist/bridge/subscription.d.ts +15 -0
  73. package/dist/bridge/subscription.js +23 -0
  74. package/dist/bridge/transport.js +21 -1
  75. package/dist/bridge/usage.d.ts +20 -3
  76. package/dist/bridge/usage.js +61 -11
  77. package/dist/bridge-hook.mjs +12751 -3207
  78. package/dist/cli-registry.js +10 -4
  79. package/dist/computers/command.js +3 -1
  80. package/dist/computers/read.d.ts +3 -0
  81. package/dist/computers/read.js +6 -0
  82. package/dist/content/summarize.d.ts +21 -0
  83. package/dist/content/summarize.js +56 -18
  84. package/dist/modules/registry.js +12 -12
  85. package/dist/project-config.d.ts +12 -0
  86. package/dist/project-config.js +29 -0
  87. package/dist/shared/retrieval.d.ts +1 -0
  88. package/dist/shared/retrieval.js +1 -1
  89. package/dist/sync/conflict-resolve.js +5 -6
  90. package/dist/tools/dispatch.js +18 -1
  91. package/dist/tools/finding.d.ts +25 -0
  92. package/dist/tools/finding.js +2 -1
  93. package/package.json +57 -1
@@ -0,0 +1,87 @@
1
+ import { z } from "zod";
2
+ import { git } from "./projects.js";
3
+ import { BridgeError } from "./protocol.js";
4
+ /** What find-in-files accepts: a literal or extended regular expression, the
5
+ * usual case and whole-word switches, and optional git pathspecs to include. */
6
+ export const fileSearchSchema = z.object({
7
+ query: z.string().min(1).max(200).refine(value => !/[\x00\n\r]/.test(value), "One line of text only."),
8
+ regex: z.boolean().optional(),
9
+ caseSensitive: z.boolean().optional(),
10
+ wholeWord: z.boolean().optional(),
11
+ include: z.array(z.string().min(1).max(200).refine(value => !value.startsWith(":") && !value.includes("\0") && !value.split("/").includes(".."), "Invalid path pattern.")).max(8).optional(),
12
+ limit: z.number().int().min(1).max(1000).optional(),
13
+ });
14
+ const MAX_PER_FILE = 50;
15
+ const MAX_TEXT = 300;
16
+ /**
17
+ * Find in files for the desktop editor: `git grep` over tracked and untracked
18
+ * (not ignored) text files in the repository root the server chose, so it works
19
+ * wherever git does and respects .gitignore. Results are grouped by file with
20
+ * 1-based line and column; long lines are cut around the match.
21
+ */
22
+ export async function searchRepository(root, input) {
23
+ const limit = input.limit ?? 300;
24
+ const args = ["grep", "-n", "--column", "-I", "--untracked", "--no-color", "--full-name", "-z",
25
+ `--max-count=${MAX_PER_FILE}`, input.regex ? "-E" : "-F"];
26
+ if (!input.caseSensitive)
27
+ args.push("-i");
28
+ if (input.wholeWord)
29
+ args.push("-w");
30
+ args.push("-e", input.query, "--");
31
+ // Literal pathspecs only through glob magic, never other pathspec magic.
32
+ // A bare pattern like "*.ts" matches in every folder, as editors expect.
33
+ for (const pattern of input.include ?? [])
34
+ args.push(`:(glob)${pattern.includes("/") ? pattern : `**/${pattern}`}`);
35
+ let output;
36
+ try {
37
+ output = await git(root, ...args);
38
+ }
39
+ catch (error) {
40
+ // git grep exits 1 when nothing matches; that is an empty result, not a failure.
41
+ if (error instanceof BridgeError && error.details?.exitCode === "1" && error.details?.code === "git-failed" && /could not complete$/.test(error.message)) {
42
+ return { matches: [], files: 0, total: 0, truncated: false };
43
+ }
44
+ if (error instanceof BridgeError && error.details?.code === "git-output-limit") {
45
+ throw new BridgeError(413, "Too many matches. Narrow the search or add a path pattern.", { code: "search-too-broad" });
46
+ }
47
+ if (error instanceof BridgeError && /fatal: .*(regexp|regex|Invalid)/i.test(error.message)) {
48
+ throw new BridgeError(400, "That regular expression is not valid.", { code: "search-invalid-regex" });
49
+ }
50
+ throw error;
51
+ }
52
+ const groups = new Map();
53
+ let total = 0;
54
+ let truncated = false;
55
+ for (const row of output.split("\n")) {
56
+ if (!row)
57
+ continue;
58
+ const [file, line, column, ...rest] = row.split("\0");
59
+ const text = rest.join("\0");
60
+ if (!file || !line || !column)
61
+ continue;
62
+ if (total >= limit) {
63
+ truncated = true;
64
+ break;
65
+ }
66
+ total += 1;
67
+ const col = Number(column);
68
+ // Keep the match in view when a line is long: start a little before it.
69
+ const start = text.length > MAX_TEXT ? Math.max(0, Math.min(col - 1 - 40, text.length - MAX_TEXT)) : 0;
70
+ const shown = text.slice(start, start + MAX_TEXT);
71
+ const entry = { line: Number(line), column: col, text: shown, ...(start ? { offset: start } : {}) };
72
+ const list = groups.get(file) ?? [];
73
+ list.push(entry);
74
+ groups.set(file, list);
75
+ }
76
+ return {
77
+ matches: [...groups].map(([file, lines]) => ({ file, lines })),
78
+ files: groups.size, total, truncated,
79
+ };
80
+ }
81
+ const MAX_LISTED = 20_000;
82
+ /** Every tracked and untracked (not ignored) file path, for the editor's quick open. */
83
+ export async function listRepositoryFiles(root) {
84
+ const output = await git(root, "ls-files", "-z", "--cached", "--others", "--exclude-standard", "--full-name");
85
+ const all = [...new Set(output.split("\0").filter(Boolean))];
86
+ return { files: all.slice(0, MAX_LISTED), total: all.length, truncated: all.length > MAX_LISTED };
87
+ }
@@ -0,0 +1,6 @@
1
+ export declare function writeRepoFile(root: string, requested: string, content: string, expectedVersion?: string): Promise<{
2
+ path: string;
3
+ version: string;
4
+ size: number;
5
+ created: boolean;
6
+ }>;
@@ -0,0 +1,120 @@
1
+ import { randomBytes } from "node:crypto";
2
+ import { constants } from "node:fs";
3
+ import { lstat, open, realpath, rename, rm } from "node:fs/promises";
4
+ import path from "node:path";
5
+ import { fileVersion, MAX_FILE_RANGE } from "./file-range.js";
6
+ import { BridgeError } from "./protocol.js";
7
+ /**
8
+ * Write one text file inside a repository root the server chose (a pane's
9
+ * checkout), for the desktop editor. The same path rules as reads: relative,
10
+ * no `..`, no `.git`, no symbolic link anywhere on the way, no control
11
+ * characters. An update must name the version the editor read
12
+ * (`fileVersion`) and fails with 409 `file-changed` when the file moved since;
13
+ * leaving the version out creates a new file and fails with `file-exists`
14
+ * when one is there. Updates go through a temp file in the same folder and a
15
+ * rename, keeping the file's mode, so a reader never sees half a file.
16
+ */
17
+ /** One write at a time per file in this Hook, so two saves naming the same
18
+ * version cannot both pass the check and overwrite each other. */
19
+ const fileLocks = new Map();
20
+ async function serialized(key, work) {
21
+ const previous = fileLocks.get(key) ?? Promise.resolve();
22
+ const run = previous.catch(() => undefined).then(work);
23
+ fileLocks.set(key, run);
24
+ try {
25
+ return await run;
26
+ }
27
+ finally {
28
+ if (fileLocks.get(key) === run)
29
+ fileLocks.delete(key);
30
+ }
31
+ }
32
+ export async function writeRepoFile(root, requested, content, expectedVersion) {
33
+ const key = `${await realpath(root).catch(() => root)}\u0000${requested}`;
34
+ return serialized(key, () => writeRepoFileNow(root, requested, content, expectedVersion));
35
+ }
36
+ async function writeRepoFileNow(root, requested, content, expectedVersion) {
37
+ if (typeof requested !== "string" || !requested || requested.length > 4096 || path.isAbsolute(requested)
38
+ || /[\x00-\x1f\x7f\\]/.test(requested) || requested.split("/").some(part => part === ".." || part.toLowerCase() === ".git" || part === "")) {
39
+ throw new BridgeError(400, "Invalid file path.");
40
+ }
41
+ if (typeof content !== "string")
42
+ throw new BridgeError(400, "Supply the file's text.");
43
+ const bytes = Buffer.from(content, "utf8");
44
+ if (bytes.length > MAX_FILE_RANGE)
45
+ throw new BridgeError(413, "Files over 4 MiB cannot be saved from here.");
46
+ if (expectedVersion !== undefined && (typeof expectedVersion !== "string" || expectedVersion.length > 200))
47
+ throw new BridgeError(400, "Invalid file version.");
48
+ const base = await realpath(root);
49
+ const parts = requested.split("/");
50
+ let directory = base;
51
+ for (const part of parts.slice(0, -1)) {
52
+ directory = path.join(directory, part);
53
+ const info = await lstat(directory).catch(() => undefined);
54
+ if (!info)
55
+ throw new BridgeError(404, "That folder does not exist.");
56
+ if (info.isSymbolicLink())
57
+ throw new BridgeError(403, "Symbolic links cannot be written through.");
58
+ if (!info.isDirectory())
59
+ throw new BridgeError(400, "That folder is not a directory.");
60
+ }
61
+ if ((await realpath(directory)) !== directory)
62
+ throw new BridgeError(403, "This file is outside the repository.");
63
+ const file = path.join(directory, parts[parts.length - 1]);
64
+ if (file !== base && !file.startsWith(base + path.sep))
65
+ throw new BridgeError(403, "This file is outside the repository.");
66
+ const existing = await lstat(file).catch((error) => {
67
+ if (error.code === "ENOENT")
68
+ return undefined;
69
+ throw error;
70
+ });
71
+ if (existing?.isSymbolicLink())
72
+ throw new BridgeError(403, "Symbolic links cannot be written through.");
73
+ if (existing && !existing.isFile())
74
+ throw new BridgeError(400, "Only regular files can be saved.");
75
+ if (expectedVersion === undefined) {
76
+ if (existing)
77
+ throw new BridgeError(409, "A file with that name already exists.", { code: "file-exists" });
78
+ // Exclusive create: a file that appears in between is never overwritten.
79
+ const handle = await open(file, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o644).catch((error) => {
80
+ if (error.code === "EEXIST")
81
+ throw new BridgeError(409, "A file with that name already exists.", { code: "file-exists" });
82
+ throw error;
83
+ });
84
+ try {
85
+ await handle.writeFile(bytes);
86
+ await handle.sync();
87
+ }
88
+ finally {
89
+ await handle.close();
90
+ }
91
+ const created = await lstat(file);
92
+ return { path: requested, version: fileVersion(created), size: created.size, created: true };
93
+ }
94
+ if (!existing)
95
+ throw new BridgeError(409, "The file is gone. It changed since you opened it.", { code: "file-changed" });
96
+ if (fileVersion(existing) !== expectedVersion)
97
+ throw new BridgeError(409, "The file changed since you opened it.", { code: "file-changed" });
98
+ const temporary = path.join(directory, `.${parts[parts.length - 1]}.phren-${randomBytes(6).toString("hex")}.tmp`);
99
+ try {
100
+ const handle = await open(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, existing.mode & 0o777);
101
+ try {
102
+ await handle.writeFile(bytes);
103
+ await handle.sync();
104
+ }
105
+ finally {
106
+ await handle.close();
107
+ }
108
+ // Recheck right before the swap so a write that landed meanwhile is not lost.
109
+ const current = await lstat(file).catch(() => undefined);
110
+ if (!current || current.isSymbolicLink() || fileVersion(current) !== expectedVersion) {
111
+ throw new BridgeError(409, "The file changed since you opened it.", { code: "file-changed" });
112
+ }
113
+ await rename(temporary, file);
114
+ }
115
+ finally {
116
+ await rm(temporary, { force: true });
117
+ }
118
+ const saved = await lstat(file);
119
+ return { path: requested, version: fileVersion(saved), size: saved.size, created: false };
120
+ }
@@ -0,0 +1,31 @@
1
+ /** Tokens for the git hosts the Hook reads over HTTP (GitLab, gitboy). GitHub
2
+ * goes through gh, which keeps its own sign-in.
3
+ *
4
+ * A token comes from, in order: the host's own environment variable, the
5
+ * Hook's git-hosts.json (machine config like elevenlabs.json: mode 600, never
6
+ * in the synced store), then the host's CLI where it has one (glab). The Hook
7
+ * runs as a service that doesn't see shell env, so the file is the durable
8
+ * source, written by `phren bridge git-host set` or the desktop's Connect. */
9
+ export type TokenHostKind = "gitlab" | "gitboy";
10
+ export type TokenSource = "environment" | "file" | "cli";
11
+ export interface HostToken {
12
+ token: string;
13
+ source: TokenSource;
14
+ user?: string;
15
+ }
16
+ export declare function gitHostsFile(): string;
17
+ /** Store (or, with an empty token, forget) one domain's token. */
18
+ export declare function writeHostToken(domain: string, kind: TokenHostKind, token: string, user?: string, file?: string): Promise<void>;
19
+ export interface TokenLookup {
20
+ env?: NodeJS.ProcessEnv;
21
+ file?: string;
22
+ cli?: boolean;
23
+ }
24
+ export declare function resolveHostToken(kind: TokenHostKind, domain: string, options?: TokenLookup): Promise<HostToken | undefined>;
25
+ /** Each stored domain with its kind and who it signs in as. Never a token. */
26
+ export declare function listHostTokens(file?: string): Promise<{
27
+ domain: string;
28
+ kind: TokenHostKind;
29
+ user?: string;
30
+ savedAt?: string;
31
+ }[] | "unsafe">;
@@ -0,0 +1,110 @@
1
+ import { execFile } from "node:child_process";
2
+ import { mkdir, readFile, stat } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { promisify } from "node:util";
5
+ import { atomic, bridgeRoot } from "./protocol.js";
6
+ const exec = promisify(execFile);
7
+ export function gitHostsFile() {
8
+ return path.join(bridgeRoot(), "git-hosts.json");
9
+ }
10
+ function clean(value) {
11
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
12
+ }
13
+ function normalDomain(domain) {
14
+ return domain.trim().toLowerCase().replace(/\.$/, "");
15
+ }
16
+ /** The stored tokens. A file other users can read is ignored, as apns.json is. */
17
+ async function readStore(file = gitHostsFile()) {
18
+ let info;
19
+ try {
20
+ info = await stat(file);
21
+ }
22
+ catch {
23
+ return null;
24
+ }
25
+ if (!info.isFile())
26
+ return null;
27
+ if (process.platform !== "win32" && ((info.mode & 0o077) !== 0 || (process.getuid && info.uid !== process.getuid())))
28
+ return "unsafe";
29
+ try {
30
+ const parsed = JSON.parse(await readFile(file, "utf8"));
31
+ const hosts = {};
32
+ if (parsed.hosts && typeof parsed.hosts === "object") {
33
+ for (const [domain, raw] of Object.entries(parsed.hosts)) {
34
+ const entry = raw && typeof raw === "object" ? raw : {};
35
+ const token = clean(entry.token);
36
+ const kind = entry.kind === "gitlab" || entry.kind === "gitboy" ? entry.kind : null;
37
+ if (token && kind)
38
+ hosts[normalDomain(domain)] = { kind, token, ...(clean(entry.user) ? { user: clean(entry.user) } : {}), ...(clean(entry.savedAt) ? { savedAt: clean(entry.savedAt) } : {}) };
39
+ }
40
+ }
41
+ return { hosts };
42
+ }
43
+ catch {
44
+ return null;
45
+ }
46
+ }
47
+ /** Store (or, with an empty token, forget) one domain's token. */
48
+ export async function writeHostToken(domain, kind, token, user, file = gitHostsFile()) {
49
+ const key = normalDomain(domain);
50
+ if (!key || /[\s/]/.test(key))
51
+ throw new Error("That is not a host name.");
52
+ const current = await readStore(file);
53
+ const hosts = current && current !== "unsafe" ? { ...current.hosts } : {};
54
+ const value = clean(token);
55
+ if (value)
56
+ hosts[key] = { kind, token: value, ...(user ? { user } : {}), savedAt: new Date().toISOString() };
57
+ else
58
+ delete hosts[key];
59
+ await mkdir(path.dirname(file), { recursive: true, mode: 0o700 });
60
+ await atomic(file, JSON.stringify({ hosts }, null, 2) + "\n", 0o600);
61
+ }
62
+ /** The environment variables each host's own tools read. GITLAB_TOKEN is
63
+ * glab's; it applies to gitlab.com, or to the domain GITLAB_HOST names.
64
+ * GITBOY_TOKEN applies only to the domain GITBOY_HOST names. */
65
+ function fromEnv(kind, domain, env) {
66
+ if (kind === "gitlab") {
67
+ const named = clean(env.GITLAB_HOST)?.replace(/^https?:\/\//, "").replace(/\/.*$/, "").toLowerCase();
68
+ if (domain === "gitlab.com" ? !named || named === "gitlab.com" : named === domain)
69
+ return clean(env.GITLAB_TOKEN) ?? clean(env.GL_TOKEN);
70
+ return undefined;
71
+ }
72
+ // gitboy runs on any domain, so its token goes only to the one GITBOY_HOST names.
73
+ const named = clean(env.GITBOY_HOST)?.replace(/^https?:\/\//, "").replace(/\/.*$/, "").toLowerCase();
74
+ return named && named === domain ? clean(env.GITBOY_TOKEN) : undefined;
75
+ }
76
+ /** glab's stored token for a domain, when glab is installed and signed in. */
77
+ async function fromCli(kind, domain) {
78
+ if (kind !== "gitlab")
79
+ return undefined;
80
+ try {
81
+ const { stdout } = await exec("glab", ["config", "get", "token", "--host", domain], { timeout: 5_000, env: { ...process.env, NO_COLOR: "1", GLAB_NO_PROMPT: "1" } });
82
+ return clean(stdout);
83
+ }
84
+ catch {
85
+ return undefined;
86
+ }
87
+ }
88
+ export async function resolveHostToken(kind, domain, options = {}) {
89
+ const key = normalDomain(domain);
90
+ const env = fromEnv(kind, key, options.env ?? process.env);
91
+ if (env)
92
+ return { token: env, source: "environment" };
93
+ const store = await readStore(options.file);
94
+ const stored = store && store !== "unsafe" ? store.hosts[key] : undefined;
95
+ if (stored && stored.kind === kind)
96
+ return { token: stored.token, source: "file", ...(stored.user ? { user: stored.user } : {}) };
97
+ if (options.cli !== false) {
98
+ const cli = await fromCli(kind, key);
99
+ if (cli)
100
+ return { token: cli, source: "cli" };
101
+ }
102
+ return undefined;
103
+ }
104
+ /** Each stored domain with its kind and who it signs in as. Never a token. */
105
+ export async function listHostTokens(file = gitHostsFile()) {
106
+ const store = await readStore(file);
107
+ if (store === "unsafe")
108
+ return "unsafe";
109
+ return Object.entries(store?.hosts ?? {}).map(([domain, { kind, user, savedAt }]) => ({ domain, kind, ...(user ? { user } : {}), ...(savedAt ? { savedAt } : {}) }));
110
+ }
@@ -0,0 +1,46 @@
1
+ import type { GitHostProvider, HostTerms } from "./git-hosts.js";
2
+ import { HostApiError } from "./git-host-http.js";
3
+ import type { Json } from "./protocol.js";
4
+ /** gitboy, the self-hosted forge, over its REST API (/api/v1). gitboy names a
5
+ * pull request by `index`, and an older gitboy has no draft state, no aggregate review decision
6
+ * and no web links in its answers, so this provider derives them: web pages
7
+ * are `<origin>/<owner>/<repo>/pulls/<n>` and `/pipelines/<iid>?job=<id>`, a
8
+ * review decision counts approvals on the head commit, and a newer gitboy
9
+ * that sends `html_url`, `draft` or `review_decision` is taken at its word.
10
+ * The token is GITBOY_TOKEN (for the domain GITBOY_HOST names) or the Hook's stored one, a gbp_ personal access
11
+ * token with read:user and read:repo (write:repo to open or merge); gitboy's
12
+ * "Phren Hook" token preset grants exactly those. A gitboy with head_branch and
13
+ * sha filters gets them; an older one ignores them and the client filters below
14
+ * still pick the right rows. */
15
+ export declare const PULL_TERMS: HostTerms;
16
+ type Order = "failing" | "pending" | "passing" | "skipped" | "neutral";
17
+ /** A gitboy job or pipeline status as one state word. */
18
+ export declare function gitboyState(status: unknown, allowFailure?: boolean): Order;
19
+ interface Ctx {
20
+ api: string;
21
+ web: string;
22
+ repo: string;
23
+ token: string;
24
+ domain: string;
25
+ account: {
26
+ source: string;
27
+ user?: string;
28
+ };
29
+ }
30
+ /** Whether a pull request's head lives in this repository rather than a fork
31
+ * with a branch of the same name. gitboy names it in `head_repository`
32
+ * (owner_username, name); a row without one is taken as this repository's. */
33
+ export declare function sameRepository(ctx: Pick<Ctx, "repo">, pull: Json): boolean;
34
+ /** gitboy's reasons it will not merge: a 409's `details`, else the message. */
35
+ export declare function refusalReasons(error: HostApiError): string;
36
+ /** GitHub's reviewDecision from gitboy's reviews: each reviewer's latest
37
+ * verdict on the head commit, the author's own left out. */
38
+ export declare function gitboyReviewDecision(pull: Json): string | undefined;
39
+ /** gitboy's mergeability and blockers in GitHub's mergeStateStatus words. */
40
+ export declare function gitboyMergeState(pull: Json): {
41
+ mergeState?: string;
42
+ mergeDetail?: string;
43
+ blockers?: string[];
44
+ };
45
+ export declare const gitboy: GitHostProvider;
46
+ export {};