@popoverai/dotrequirements 0.37.1 → 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 { prStatusCommand, pullRequestCommand } from "./pull-request.js";
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, read 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
- * with `op: "status"`, for where the open one stands.
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();
@@ -7,7 +7,9 @@ import type { Plan, PlanPart } from "./types.js";
7
7
  * So a scenario naming Scores alone, of the default plan, runs the scores
8
8
  * with the pitch an input. An outcome on one left out is kept on that
9
9
  * one's surface instead. The checkpoints on what is kept stay, presenting
10
- * what is still there; loops go, since part of a plan starts or ends
10
+ * what is still there, and one named into a phase the part doesn't have
11
+ * names none; a pull-request surface's ready for review or draft on an
12
+ * outcome left out goes; and loops go, since part of a plan starts or ends
11
13
  * nothing.
12
14
  *
13
15
  * The one exception is the outcome that makes the solution exist: the
@@ -35,7 +35,9 @@ const worksFrom = (plan, outcome) => [
35
35
  * So a scenario naming Scores alone, of the default plan, runs the scores
36
36
  * with the pitch an input. An outcome on one left out is kept on that
37
37
  * one's surface instead. The checkpoints on what is kept stay, presenting
38
- * what is still there; loops go, since part of a plan starts or ends
38
+ * what is still there, and one named into a phase the part doesn't have
39
+ * names none; a pull-request surface's ready for review or draft on an
40
+ * outcome left out goes; and loops go, since part of a plan starts or ends
39
41
  * nothing.
40
42
  *
41
43
  * The one exception is the outcome that makes the solution exist: the
@@ -85,18 +87,38 @@ export function planForOutcomes(plan, names) {
85
87
  const known = new Set([...kept, ...inputs]);
86
88
  const keptOn = (on) => kept.has(on) ||
87
89
  [...kept].some((name) => surfaceOf(plan, name) === on && name !== on);
90
+ // A checkpoint named into a phase the part no longer has sits after what
91
+ // it presents, as it would naming none.
92
+ const placed = (checkpoint) => {
93
+ if (checkpoint.phase === undefined ||
94
+ phases.some((phase) => phase.name === checkpoint.phase)) {
95
+ return checkpoint;
96
+ }
97
+ const { phase: _phase, ...rest } = checkpoint;
98
+ return rest;
99
+ };
88
100
  const checkpoints = plan.checkpoints.flatMap((checkpoint) => {
89
101
  if (!keptOn(checkpoint.on))
90
102
  return [];
91
103
  if (!checkpoint.presents?.length)
92
- return [checkpoint];
104
+ return [placed(checkpoint)];
93
105
  const presents = checkpoint.presents.filter((name) => known.has(name));
94
- return presents.length > 0 ? [{ ...checkpoint, presents }] : [];
106
+ return presents.length > 0 ? [placed({ ...checkpoint, presents })] : [];
95
107
  });
96
108
  return {
97
109
  format: "outcomes",
98
110
  inputs,
99
- surfaces: plan.surfaces,
111
+ // A pull request's moment on an outcome left out never comes (PULL-7.3).
112
+ surfaces: plan.surfaces.map((surface) => {
113
+ const own = { ...surface };
114
+ if (surface.readyForReview && !kept.has(surface.readyForReview.outcome)) {
115
+ delete own.readyForReview;
116
+ }
117
+ if (surface.draft && !kept.has(surface.draft.outcome)) {
118
+ delete own.draft;
119
+ }
120
+ return own;
121
+ }),
100
122
  phases,
101
123
  checkpoints,
102
124
  agents: plan.agents,
@@ -93,6 +93,16 @@ export type Plan = {
93
93
  surfaces: Array<{
94
94
  name: string;
95
95
  kind: string;
96
+ /** When a pull-request surface's pull request asks for review, or goes back to draft (PULL-7). */
97
+ readyForReview?: {
98
+ outcome: string;
99
+ when: string;
100
+ };
101
+ draft?: {
102
+ outcome: string;
103
+ when: string;
104
+ };
105
+ watchedBy?: string;
96
106
  }>;
97
107
  phases: Array<{
98
108
  name: string;
@@ -103,6 +113,7 @@ export type Plan = {
103
113
  name: string;
104
114
  on: string;
105
115
  presents?: string[];
116
+ phase?: string;
106
117
  }>;
107
118
  agents: Array<{
108
119
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popoverai/dotrequirements",
3
- "version": "0.37.1",
3
+ "version": "0.38.0",
4
4
  "description": "Requirements as testable, human-readable data — CLI and test harness for spec-driven development with AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {