@popoverai/dotrequirements 0.37.2 → 0.38.0
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.
|
@@ -7,7 +7,7 @@ import { REQUEST_CONTRACT } from "./contract.js";
|
|
|
7
7
|
import { createCommand } from "./create.js";
|
|
8
8
|
import { thingsCommand } from "./look-up.js";
|
|
9
9
|
import { nextCommand } from "./next.js";
|
|
10
|
-
import {
|
|
10
|
+
import { pullRequestCommand } from "./pull-request.js";
|
|
11
11
|
import { rehearseCommand } from "./rehearse.js";
|
|
12
12
|
import { reviewCommand } from "./review.js";
|
|
13
13
|
import { doneCommand } from "./share.js";
|
|
@@ -92,17 +92,6 @@ Examples:
|
|
|
92
92
|
dotreq solution author file:src/checkout.ts@guest pr:12 image:checkout.png --comment "Guest path, behind the flag."
|
|
93
93
|
dotreq solution author "preview:8080/design/roll-count pnpm dev" file:src/RollCount.tsx --title "Roll count after three dice" --title "Roll count component" --comment "The roll count, as a dev-only page."
|
|
94
94
|
`;
|
|
95
|
-
/** What `pr status` says, on its `--help` (PULL-4). */
|
|
96
|
-
const PR_STATUS_HELP = `
|
|
97
|
-
Reads the pull request of the outcome you are at, or of the outcome it awaits that
|
|
98
|
-
is kept on one, as GitHub reports it. The merge state is GitHub's word for whether
|
|
99
|
-
it can merge: clean means it can, with every required check passing and no
|
|
100
|
-
conflict. Failed checks come with a link to them and what they reported, as GitHub
|
|
101
|
-
gives it: their output and annotations, or the end of their job's log. Checks still
|
|
102
|
-
running are named. Each review follows, with its verdict and its comments, from the
|
|
103
|
-
repository's owners, members and collaborators and the apps installed on it; those
|
|
104
|
-
by anyone else are left out and counted. Reading it changes nothing.
|
|
105
|
-
`;
|
|
106
95
|
/** What `pr open` does, on its `--help`, where `author --help` sends the agent (PULL-2). */
|
|
107
96
|
const PULL_REQUEST_HELP = `
|
|
108
97
|
Pushes your commits to the solution's branch, then opens a pull request from it
|
|
@@ -238,18 +227,12 @@ export function registerSolution(program) {
|
|
|
238
227
|
.action(wrap(authorCommand));
|
|
239
228
|
const pr = solution
|
|
240
229
|
.command("pr", HIDDEN)
|
|
241
|
-
.description("The solution's pull request: open it,
|
|
230
|
+
.description("The solution's pull request: open it. Read it on GitHub, with your GitHub tools");
|
|
242
231
|
whereOptions(pr
|
|
243
232
|
.command("open")
|
|
244
233
|
.description("Push the solution's branch and open its pull request, or find the one open; prints its reference, pr:<number>, to submit"))
|
|
245
234
|
.addHelpText("after", PULL_REQUEST_HELP)
|
|
246
235
|
.action(wrap(pullRequestCommand));
|
|
247
|
-
whereOptions(pr
|
|
248
|
-
.command("status")
|
|
249
|
-
.description("Where the pull request of the outcome you are at stands, in GitHub's words: its merge state, conflicts, review decision and checks"))
|
|
250
|
-
.option("--json", "Print as JSON")
|
|
251
|
-
.addHelpText("after", PR_STATUS_HELP)
|
|
252
|
-
.action(wrap(prStatusCommand));
|
|
253
236
|
whereOptions(solution
|
|
254
237
|
.command("review <result> [video...]", HIDDEN)
|
|
255
238
|
.description("Record the review's result: approved, approved-with-revisions or needs-revision"))
|
|
@@ -6,37 +6,6 @@ export type PullRequest = {
|
|
|
6
6
|
};
|
|
7
7
|
/** The command that opens the solution's pull request and prints its reference. */
|
|
8
8
|
export declare const OPEN_IT = "dotreq solution pr open";
|
|
9
|
-
/** Where a pull request stands, in GitHub's words (web: lib/runner/github.ts). */
|
|
10
|
-
export type PullRequestState = {
|
|
11
|
-
number: number;
|
|
12
|
-
url: string;
|
|
13
|
-
mergeState: string;
|
|
14
|
-
mergeable: string;
|
|
15
|
-
reviewDecision: string | null;
|
|
16
|
-
checks: string | null;
|
|
17
|
-
failed: Array<{
|
|
18
|
-
name: string;
|
|
19
|
-
result: string;
|
|
20
|
-
link: string | null;
|
|
21
|
-
/** What the check reported, as GitHub gave it, or why it couldn't (PULL-4.7). */
|
|
22
|
-
reported?: unknown;
|
|
23
|
-
}>;
|
|
24
|
-
running: Array<{
|
|
25
|
-
name: string;
|
|
26
|
-
link: string | null;
|
|
27
|
-
}>;
|
|
28
|
-
head: string;
|
|
29
|
-
reviews?: unknown;
|
|
30
|
-
};
|
|
31
|
-
/** Where the pull request stands, as a reviewer reads it (PULL-4). */
|
|
32
|
-
export declare function describeState(state: PullRequestState): string;
|
|
33
|
-
/**
|
|
34
|
-
* `dotreq solution pr status`: where the pull request of the outcome the
|
|
35
|
-
* agent is at stands, in GitHub's words (PULL-4). Changes nothing (4.6).
|
|
36
|
-
*/
|
|
37
|
-
export declare function prStatusCommand(options: WhereOptions & {
|
|
38
|
-
json?: boolean;
|
|
39
|
-
}): Promise<void>;
|
|
40
9
|
/**
|
|
41
10
|
* `dotreq solution pr open`: the solution's pull request, opened or
|
|
42
11
|
* found (PULL-2). Inside a runner the branch is pushed first, as a submission
|
|
@@ -6,73 +6,6 @@ import { requireWhere } from "./run-file.js";
|
|
|
6
6
|
import { outcomeFor } from "./status.js";
|
|
7
7
|
/** The command that opens the solution's pull request and prints its reference. */
|
|
8
8
|
export const OPEN_IT = "dotreq solution pr open";
|
|
9
|
-
/** The pull request the outcome the agent is at reads, as the app finds it (PULL-4.0, 4.0.0). */
|
|
10
|
-
async function stateFor(where) {
|
|
11
|
-
const said = await ask({
|
|
12
|
-
solutionId: where.solutionId,
|
|
13
|
-
agent: where.agent,
|
|
14
|
-
...(where.outcome ? { outcome: where.outcome } : {}),
|
|
15
|
-
op: "status",
|
|
16
|
-
});
|
|
17
|
-
if (said.noRepository) {
|
|
18
|
-
// PULL-4.5.
|
|
19
|
-
throw new Error("There's no pull request: a pull request needs a repository, and this project has none connected.");
|
|
20
|
-
}
|
|
21
|
-
if (said.noBranch || said.none) {
|
|
22
|
-
// PULL-4.4.
|
|
23
|
-
throw new Error(`There's no pull request open for it. Its drafter opens one with \`${OPEN_IT}\`.`);
|
|
24
|
-
}
|
|
25
|
-
if (said.refused) {
|
|
26
|
-
throw new Error(`Couldn't read the pull request from the repository: ${said.refused}`);
|
|
27
|
-
}
|
|
28
|
-
if (!said.state)
|
|
29
|
-
throw new Error("The app gave no pull request.");
|
|
30
|
-
return said.reviews === undefined
|
|
31
|
-
? said.state
|
|
32
|
-
: { ...said.state, reviews: said.reviews };
|
|
33
|
-
}
|
|
34
|
-
/** What GitHub reported, as it gave it, indented under the line it belongs to. */
|
|
35
|
-
function asGiven(reported, indent) {
|
|
36
|
-
const text = typeof reported === "string" ? reported : JSON.stringify(reported, null, 2);
|
|
37
|
-
return text.split("\n").map((line) => `${indent}${line}`);
|
|
38
|
-
}
|
|
39
|
-
/** Where the pull request stands, as a reviewer reads it (PULL-4). */
|
|
40
|
-
export function describeState(state) {
|
|
41
|
-
const lines = [
|
|
42
|
-
`pr:${state.number} (${state.url}), at ${state.head.slice(0, 7)}`,
|
|
43
|
-
`Merge state: ${state.mergeState}`,
|
|
44
|
-
`Conflicts with the branch it merges into: ${state.mergeable === "conflicting" ? "yes" : state.mergeable === "mergeable" ? "no" : "not worked out yet"}`,
|
|
45
|
-
`Review decision: ${state.reviewDecision ?? "none required"}`,
|
|
46
|
-
`Checks: ${state.checks ?? "none"}`,
|
|
47
|
-
];
|
|
48
|
-
for (const check of state.failed) {
|
|
49
|
-
lines.push(` failed: ${check.name} (${check.result})${check.link ? ` ${check.link}` : ""}`);
|
|
50
|
-
// PULL-4.7: what it reported, as GitHub gave it.
|
|
51
|
-
if (check.reported !== undefined) {
|
|
52
|
-
lines.push(" It reported:", ...asGiven(check.reported, " "));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
for (const check of state.running) {
|
|
56
|
-
lines.push(` still running: ${check.name}${check.link ? ` ${check.link}` : ""}`);
|
|
57
|
-
}
|
|
58
|
-
if (state.mergeable === "unknown") {
|
|
59
|
-
// PULL-4.3.
|
|
60
|
-
lines.push("GitHub hasn't yet worked out whether it can merge: read it again shortly.");
|
|
61
|
-
}
|
|
62
|
-
// PULL-4.8: each review, with its verdict and its comments.
|
|
63
|
-
if (state.reviews !== undefined) {
|
|
64
|
-
lines.push("Reviews and their comments, as GitHub gave them:", ...asGiven(state.reviews, " "));
|
|
65
|
-
}
|
|
66
|
-
return lines.join("\n");
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* `dotreq solution pr status`: where the pull request of the outcome the
|
|
70
|
-
* agent is at stands, in GitHub's words (PULL-4). Changes nothing (4.6).
|
|
71
|
-
*/
|
|
72
|
-
export async function prStatusCommand(options) {
|
|
73
|
-
const state = await stateFor(requireWhere(options));
|
|
74
|
-
console.log(options.json ? JSON.stringify(state) : describeState(state));
|
|
75
|
-
}
|
|
76
9
|
/**
|
|
77
10
|
* `dotreq solution pr open`: the solution's pull request, opened or
|
|
78
11
|
* found (PULL-2). Inside a runner the branch is pushed first, as a submission
|
|
@@ -165,8 +98,8 @@ function pullRequestIn(said) {
|
|
|
165
98
|
/**
|
|
166
99
|
* Ask the app's pull-request route, on the project's credentials: with the
|
|
167
100
|
* outcome, to open the pull request it is kept on; with a number, to check
|
|
168
|
-
* that one is the solution's open pull request, which needs no outcome
|
|
169
|
-
*
|
|
101
|
+
* that one is the solution's open pull request, which needs no outcome.
|
|
102
|
+
* Agents read where it stands on GitHub itself (PULL-4).
|
|
170
103
|
*/
|
|
171
104
|
async function ask(body) {
|
|
172
105
|
const { projectId, projectSecret } = getProjectCredentials();
|
package/package.json
CHANGED