@clemrig/factory 0.18.3 → 0.20.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.
Files changed (70) hide show
  1. package/README.md +25 -23
  2. package/dist/app/board.js +1 -0
  3. package/dist/app/board.js.map +1 -1
  4. package/dist/app/factory.d.ts +2 -0
  5. package/dist/app/factory.js +5 -1
  6. package/dist/app/factory.js.map +1 -1
  7. package/dist/app/review.d.ts +16 -0
  8. package/dist/app/review.js +87 -0
  9. package/dist/app/review.js.map +1 -0
  10. package/dist/app/spec-page.d.ts +11 -0
  11. package/dist/app/spec-page.js +37 -0
  12. package/dist/app/spec-page.js.map +1 -0
  13. package/dist/app/workflows/implement.js +3 -7
  14. package/dist/app/workflows/implement.js.map +1 -1
  15. package/dist/app/workflows/issue-save.d.ts +4 -1
  16. package/dist/app/workflows/issue-save.js +35 -4
  17. package/dist/app/workflows/issue-save.js.map +1 -1
  18. package/dist/app/workflows/stages/deliver.d.ts +5 -4
  19. package/dist/app/workflows/stages/deliver.js +47 -53
  20. package/dist/app/workflows/stages/deliver.js.map +1 -1
  21. package/dist/app/workflows/stages/prepare.js +11 -7
  22. package/dist/app/workflows/stages/prepare.js.map +1 -1
  23. package/dist/app/workflows/stages/resume.js +0 -4
  24. package/dist/app/workflows/stages/resume.js.map +1 -1
  25. package/dist/app/workflows/stages/run.d.ts +1 -2
  26. package/dist/app/workflows/tidy.js +2 -3
  27. package/dist/app/workflows/tidy.js.map +1 -1
  28. package/dist/cli/ui.d.ts +5 -2
  29. package/dist/cli/ui.js +24 -5
  30. package/dist/cli/ui.js.map +1 -1
  31. package/dist/domain/board.d.ts +6 -0
  32. package/dist/domain/board.js +5 -1
  33. package/dist/domain/board.js.map +1 -1
  34. package/dist/domain/description.d.ts +57 -5
  35. package/dist/domain/description.js +133 -12
  36. package/dist/domain/description.js.map +1 -1
  37. package/dist/domain/diff.d.ts +8 -0
  38. package/dist/domain/diff.js +90 -0
  39. package/dist/domain/diff.js.map +1 -0
  40. package/dist/domain/pull-request.d.ts +9 -21
  41. package/dist/domain/pull-request.js +43 -228
  42. package/dist/domain/pull-request.js.map +1 -1
  43. package/dist/domain/review-page.d.ts +171 -0
  44. package/dist/domain/review-page.js +200 -0
  45. package/dist/domain/review-page.js.map +1 -0
  46. package/dist/domain/spec-page.d.ts +132 -0
  47. package/dist/domain/spec-page.js +155 -0
  48. package/dist/domain/spec-page.js.map +1 -0
  49. package/dist/system/environment.d.ts +6 -0
  50. package/dist/system/environment.js +19 -0
  51. package/dist/system/environment.js.map +1 -1
  52. package/dist/system/factory.d.ts +2 -0
  53. package/dist/system/factory.js +4 -0
  54. package/dist/system/factory.js.map +1 -1
  55. package/dist/system/git.d.ts +5 -1
  56. package/dist/system/git.js +19 -2
  57. package/dist/system/git.js.map +1 -1
  58. package/dist/system/github.d.ts +3 -12
  59. package/dist/system/github.js +7 -31
  60. package/dist/system/github.js.map +1 -1
  61. package/dist/system/issues.d.ts +10 -0
  62. package/dist/system/issues.js +57 -1
  63. package/dist/system/issues.js.map +1 -1
  64. package/dist/system/run-files.d.ts +14 -0
  65. package/dist/system/run-files.js +51 -8
  66. package/dist/system/run-files.js.map +1 -1
  67. package/package.json +2 -2
  68. package/prompts/describe.md +36 -15
  69. package/templates/init/gitignore +1 -0
  70. package/templates/skills/issue/SKILL.md +49 -7
@@ -1,14 +1,39 @@
1
1
  import { z } from "@clemrig/flow";
2
+ import { diffExcerpt } from "./diff.js";
2
3
  const text = z.string().trim().min(1);
3
- /** What GitHub draws: a mermaid diagram; a diff or a text block shows a shape as it is. */
4
+ const line = z.number().int().min(1);
5
+ /** What the review page draws: a mermaid diagram; a diff or a text block shows a shape as it is. */
4
6
  export const visualKinds = ["mermaid", "diff", "text"];
5
- /** The image files a pull request shows, as GitHub accepts them. */
7
+ /** The image files the review page shows. */
6
8
  const imageExtensions = [".png", ".jpg", ".jpeg", ".gif", ".webp"];
7
- /** GitHub's limit for an image attached to a pull request. */
9
+ /** The largest screenshot: the review page loads it whole, on a phone too. */
8
10
  export const maxScreenshotBytes = 10 * 1024 * 1024;
11
+ /** What a decision departs from: the spec's scope, a test that existed, or the spec's letter. */
12
+ export const decisionKinds = [
13
+ "beyond_spec",
14
+ "changed_test",
15
+ "spec_reading",
16
+ ];
17
+ /** What a decision's card shows: one of these, with its own fields. */
18
+ export const decisionVisualKinds = [
19
+ "reading",
20
+ "diff",
21
+ "screenshots",
22
+ "list",
23
+ ];
24
+ /** The fields each kind of visual takes. */
25
+ const visualFields = {
26
+ reading: { spec: true, read: true },
27
+ diff: { file: true, from: true, to: true },
28
+ screenshots: { files: true },
29
+ list: { items: true },
30
+ };
31
+ /** The longest excerpt of the diff a card shows, in lines of the file. */
32
+ const maxExcerptLines = 60;
9
33
  /**
10
34
  * The describing agent's response: what a reader who forgot the issue needs
11
- * to review its pull request. As many items as the change calls for.
35
+ * to review its pull request, on the review page. As many items as the
36
+ * change calls for.
12
37
  */
13
38
  export const descriptionOutput = z.strictObject({
14
39
  /** Each change of behavior, as a user, a client or an operator observes it. */
@@ -41,12 +66,110 @@ export const descriptionOutput = z.strictObject({
41
66
  screenshots: z.array(z.strictObject({ file: text, caption: text })),
42
67
  /** Why there is no screenshot, when there is none. */
43
68
  noScreenshots: text.optional(),
69
+ /**
70
+ * What a person decides before merging, one card each: every change beyond
71
+ * the spec, every existing test whose expectation changed, every reading of
72
+ * the spec beyond its letter.
73
+ */
74
+ decisions: z.array(z.strictObject({
75
+ kind: z.enum(decisionKinds),
76
+ /** The decision, in a sentence. */
77
+ title: text,
78
+ /** The criterion it bears on. */
79
+ criterion: text.optional(),
80
+ /** The answer advised. */
81
+ advice: z.enum(["accept", "revise"]),
82
+ /** Why that answer, in a sentence or two. */
83
+ recommendation: text,
84
+ /** Why it needs a person. */
85
+ why: text,
86
+ /** The interpretation (`I1`…) or deviation (`D1`…) it comes from. */
87
+ source: z
88
+ .string()
89
+ .regex(/^[ID][1-9]\d*$/)
90
+ .optional(),
91
+ /** The changed file to open. */
92
+ file: text.optional(),
93
+ /** What its card shows; the fields of its kind only. */
94
+ visual: z
95
+ .strictObject({
96
+ kind: z.enum(decisionVisualKinds),
97
+ /** `reading`: the spec's words, and the plan's reading of them. */
98
+ spec: text.optional(),
99
+ read: text.optional(),
100
+ /** `diff`: a changed file and lines of its new version (of its old one, for a deleted file). */
101
+ file: text.optional(),
102
+ from: line.optional(),
103
+ to: line.optional(),
104
+ /** `screenshots`: screenshots of the description, by file. */
105
+ files: z.array(text).min(1).optional(),
106
+ /** `list`: a few short items. */
107
+ items: z.array(text).min(1).optional(),
108
+ })
109
+ .optional(),
110
+ })),
111
+ /** What only a person can check, which the run could not: on a real device, with real data. */
112
+ manualChecks: z.array(z.strictObject({
113
+ /** What to do, in a sentence. */
114
+ title: text,
115
+ /** What should happen. */
116
+ expect: text,
117
+ /** Why the run could not check it. */
118
+ why: text,
119
+ })),
44
120
  });
45
- /** What `gh` attaches in one command. */
46
- const maxScreenshots = 50;
47
- /** What is wrong with a description of these changed files, the screenshots' files aside. */
48
- export function descriptionProblems(description, files) {
49
- const changed = new Set(files.map(({ path }) => path));
121
+ /** What is wrong with a decision's visual. */
122
+ function visualProblems(visual, where, { diff }, shots) {
123
+ const fields = Object.keys(visualFields[visual.kind]);
124
+ const given = Object.entries(visual).flatMap(([key, value]) => key !== "kind" && value !== undefined ? [key] : []);
125
+ const problems = [
126
+ ...fields
127
+ .filter((field) => !given.includes(field))
128
+ .map((field) => `${where}: ${visual.kind} needs ${field}`),
129
+ ...given
130
+ .filter((field) => !fields.includes(field))
131
+ .map((field) => `${where}: ${visual.kind} takes no ${field}`),
132
+ ];
133
+ if (problems.length > 0)
134
+ return problems;
135
+ const { file, from, to, files = [] } = visual;
136
+ if (file !== undefined && from !== undefined && to !== undefined) {
137
+ if (to < from || to - from >= maxExcerptLines)
138
+ problems.push(`${where}: from ${from} to ${to}, give at most ${maxExcerptLines} lines, in order`);
139
+ else if (!diffExcerpt(diff, file, from, to))
140
+ problems.push(`${where}: the diff changes no line of ${file} from ${from} to ${to}`);
141
+ }
142
+ for (const shot of files)
143
+ if (!shots.includes(shot))
144
+ problems.push(`${where}: ${shot} is not one of the screenshots`);
145
+ return problems;
146
+ }
147
+ /** What is wrong with the decisions: their sources, criteria, files and visuals. */
148
+ function decisionProblems({ decisions, screenshots }, described, changed) {
149
+ const shots = screenshots.map(({ file }) => file);
150
+ const ids = described.criteria.map(({ id }) => id);
151
+ return decisions.flatMap((decision, index) => {
152
+ const where = `decisions[${index}]`;
153
+ const problems = [];
154
+ if (decision.criterion !== undefined && !ids.includes(decision.criterion))
155
+ problems.push(`${where}: ${decision.criterion} is not a criterion`);
156
+ if (decision.source !== undefined) {
157
+ const count = decision.source[0] === "I"
158
+ ? described.interpretations
159
+ : described.deviations;
160
+ if (Number(decision.source.slice(1)) > count)
161
+ problems.push(`${where}: there is no ${decision.source}`);
162
+ }
163
+ if (decision.file !== undefined && !changed.has(decision.file))
164
+ problems.push(`${where}: ${decision.file} is not a changed file`);
165
+ if (decision.visual)
166
+ problems.push(...visualProblems(decision.visual, `${where}.visual`, described, shots));
167
+ return problems;
168
+ });
169
+ }
170
+ /** What is wrong with a description of this change, the screenshots' files aside. */
171
+ export function descriptionProblems(description, described) {
172
+ const changed = new Set(described.files.map(({ path }) => path));
50
173
  const problems = [];
51
174
  const { start, groups } = description.guide;
52
175
  if (!changed.has(start.file))
@@ -67,12 +190,10 @@ export function descriptionProblems(description, files) {
67
190
  if (shots.indexOf(file) !== shots.lastIndexOf(file))
68
191
  problems.push(`screenshots: ${file} is listed twice`);
69
192
  }
70
- if (shots.length > maxScreenshots)
71
- problems.push(`screenshots: ${maxScreenshots} at most`);
72
193
  if (shots.length === 0 && !description.noScreenshots)
73
194
  problems.push("noScreenshots: say why there is no screenshot");
74
195
  if (shots.length > 0 && description.noScreenshots)
75
196
  problems.push("noScreenshots: give it only when there is no screenshot");
76
- return problems;
197
+ return [...problems, ...decisionProblems(description, described, changed)];
77
198
  }
78
199
  //# sourceMappingURL=description.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"description.js","sourceRoot":"","sources":["../../src/domain/description.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAGlC,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAEtC,2FAA2F;AAC3F,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAEhE,oEAAoE;AACpE,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnE,8DAA8D;AAC9D,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,YAAY,CAAC;IAC9C,+EAA+E;IAC/E,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,0FAA0F;IAC1F,OAAO,EAAE,CAAC,CAAC,KAAK,CACd,CAAC,CAAC,YAAY,CAAC;QACb,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC;QACzB,OAAO,EAAE,IAAI;KACd,CAAC,CACH;IACD,MAAM,EAAE,CAAC,CAAC,YAAY,CAAC;QACrB,2EAA2E;QAC3E,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACpC,MAAM,EAAE,IAAI;QACZ,4DAA4D;QAC5D,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;QAC7C,aAAa,EAAE,IAAI;QACnB,0CAA0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,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IAC9D,KAAK,MAAM,IAAI,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAClC,IAAI,CAAC,8BAA8B,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5C,QAAQ,CAAC,IAAI,CACX,gBAAgB,IAAI,gEAAgE,CACrF,CAAC;aACC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YACrE,QAAQ,CAAC,IAAI,CACX,gBAAgB,IAAI,sBAAsB,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACxE,CAAC;QACJ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC;YACjD,QAAQ,CAAC,IAAI,CAAC,gBAAgB,IAAI,kBAAkB,CAAC,CAAC;IAC1D,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa;QAClD,QAAQ,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;IACjE,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,WAAW,CAAC,aAAa;QAC/C,QAAQ,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;IAC3E,OAAO,CAAC,GAAG,QAAQ,EAAE,GAAG,gBAAgB,CAAC,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;AAC7E,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The excerpt of `path`'s diff that shows lines `from` to `to` of its new
3
+ * version (of its old one, for a deleted file), with the lines removed just
4
+ * before each of them; each line keeps its mark, the common indentation
5
+ * removed, and `…` separates two hunks. `undefined` when it changes none of
6
+ * these lines.
7
+ */
8
+ export declare function diffExcerpt(diff: string, path: string, from: number, to: number): string | undefined;
@@ -0,0 +1,90 @@
1
+ const escapes = {
2
+ a: "\x07",
3
+ b: "\b",
4
+ t: "\t",
5
+ n: "\n",
6
+ v: "\v",
7
+ f: "\f",
8
+ r: "\r",
9
+ };
10
+ /**
11
+ * A name of a `---` or `+++` line, as Git writes it: followed by a tab when
12
+ * it has a space, quoted C style when it has special characters, its bytes
13
+ * outside ASCII in octal.
14
+ */
15
+ function nameOf(written) {
16
+ const name = written.replace(/\t$/, "");
17
+ if (!name.startsWith('"'))
18
+ return name;
19
+ const bytes = [];
20
+ for (const [, octal, escaped, plain] of name
21
+ .slice(1, -1)
22
+ .matchAll(/\\([0-7]{3})|\\(.)|([^\\]+)/gs)) {
23
+ if (octal)
24
+ bytes.push(Number.parseInt(octal, 8));
25
+ else
26
+ bytes.push(...new TextEncoder().encode(escaped === undefined ? plain : (escapes[escaped] ?? escaped)));
27
+ }
28
+ return new TextDecoder().decode(new Uint8Array(bytes));
29
+ }
30
+ /**
31
+ * The lines of `path`'s hunks in a unified diff of several files, its names
32
+ * after `a/` and `b/`; `undefined` when the diff does not change it.
33
+ */
34
+ function linesOf(diff, path) {
35
+ for (const section of diff.split(/^(?=diff --git )/m)) {
36
+ const lines = section.split("\n");
37
+ const start = lines.findIndex((line) => line.startsWith("@@ "));
38
+ const head = start === -1 ? lines : lines.slice(0, start);
39
+ const named = (marker) => {
40
+ const line = head.find((each) => each.startsWith(marker));
41
+ return line === undefined ? undefined : nameOf(line.slice(4));
42
+ };
43
+ const deleted = named("+++ ") === "/dev/null";
44
+ if (deleted ? named("--- ") !== `a/${path}` : named("+++ ") !== `b/${path}`)
45
+ continue;
46
+ const numbered = [];
47
+ let hunk = -1;
48
+ let next = 0;
49
+ for (const line of start === -1 ? [] : lines.slice(start)) {
50
+ const range = /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(line);
51
+ if (range) {
52
+ hunk += 1;
53
+ next = Number(deleted ? range[1] : range[2]);
54
+ continue;
55
+ }
56
+ const mark = line[0];
57
+ // `` is no line of the file.
58
+ if (mark !== "+" && mark !== "-" && mark !== " ")
59
+ continue;
60
+ numbered.push({ mark, text: line.slice(1), hunk, number: next });
61
+ if (deleted ? mark !== "+" : mark !== "-")
62
+ next += 1;
63
+ }
64
+ return numbered;
65
+ }
66
+ return undefined;
67
+ }
68
+ /**
69
+ * The excerpt of `path`'s diff that shows lines `from` to `to` of its new
70
+ * version (of its old one, for a deleted file), with the lines removed just
71
+ * before each of them; each line keeps its mark, the common indentation
72
+ * removed, and `…` separates two hunks. `undefined` when it changes none of
73
+ * these lines.
74
+ */
75
+ export function diffExcerpt(diff, path, from, to) {
76
+ const kept = (linesOf(diff, path) ?? []).filter(({ number }) => number >= from && number <= to);
77
+ if (!kept.some(({ mark }) => mark !== " "))
78
+ return undefined;
79
+ const indents = kept
80
+ .filter(({ text }) => text.trim() !== "")
81
+ .map(({ text }) => /^[ \t]*/.exec(text)?.[0].length ?? 0);
82
+ const indent = indents.length > 0 ? Math.min(...indents) : 0;
83
+ return kept
84
+ .flatMap(({ mark, text, hunk }, index) => [
85
+ ...(index > 0 && kept[index - 1]?.hunk !== hunk ? [" …"] : []),
86
+ `${mark}${text.slice(indent).replaceAll("\t", " ")}`,
87
+ ])
88
+ .join("\n");
89
+ }
90
+ //# sourceMappingURL=diff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/domain/diff.ts"],"names":[],"mappings":"AAcA,MAAM,OAAO,GAA2B;IACtC,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IAAI;CACR,CAAC;AAEF;;;;GAIG;AACH,SAAS,MAAM,CAAC,OAAe;IAC7B,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACx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E,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC;QACxC,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9D,GAAG,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE;KACtD,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
@@ -1,23 +1,11 @@
1
1
  import type { Description } from "./description.js";
2
2
  import { type ChangedFile, type Review } from "./review.js";
3
3
  import type { Criterion } from "./spec.js";
4
- import { type CheckResult } from "./verification.js";
5
- /** The first `gh` that attaches images to a pull request (`--attach`). */
6
- export declare const minimumGhVersion = "2.99.0";
7
- /** Why this `gh` cannot open the pull request, if it cannot. */
8
- export declare function ghVersionProblem(version: string): string | undefined;
9
- /** Below GitHub's limit for a pull request's body (65,536 characters), with room for the screenshots' links. */
10
- export declare const maxBodyLength = 60000;
4
+ import type { CheckResult } from "./verification.js";
11
5
  export interface PullRequestFacts {
12
- /** The spec's Objective: why the change exists. */
13
- objective: string;
14
6
  criteria: Criterion[];
15
7
  /** Where the implementation departs from the plan, and why. */
16
8
  deviations: string[];
17
- /** The plan's reading of the spec where it reads more than one way: to confirm before merging. */
18
- interpretations: string[];
19
- /** What the plan assumed: its risks. */
20
- assumptions: string[];
21
9
  review: Review;
22
10
  /**
23
11
  * Whether the operator delivered the change as the review left it: its
@@ -37,21 +25,21 @@ export interface PullRequestFacts {
37
25
  /** The change's files, since the plan's commit. */
38
26
  files: ChangedFile[];
39
27
  description: Description;
40
- /**
41
- * Whether the screenshots are still to attach. Once attached, the body names
42
- * each by its file, which gh replaces with its upload's link.
43
- */
44
- screenshotsPending: boolean;
45
28
  /** Where a reader opens the spec and the plan, at the commits the run read and wrote them. */
46
29
  links: {
47
30
  spec: string;
48
31
  plan: string;
49
32
  };
50
33
  runId: string;
34
+ /** The review page's address, when `factory ui` has one others can reach. */
35
+ reviewPage?: string;
51
36
  }
52
- /** Everything needed to review the change without remembering its issue or opening the run. */
37
+ /** The review page's address, relative to where `factory ui` serves. */
38
+ export declare function reviewPath(runId: string): string;
39
+ /**
40
+ * The pull request's body: what it risks and proves at a glance, and the
41
+ * link to its review page, which shows everything else from the run.
42
+ */
53
43
  export declare function pullRequestBody(facts: PullRequestFacts): string;
54
- /** How many readings of the spec the plan chose, as the terminal shows them once the pull request is open. */
55
- export declare function interpretationsLine(count: number): string;
56
44
  /** The danger of merging, as the terminal shows it once the pull request is open. */
57
45
  export declare function mergeDangerLine({ danger }: Description): string;