@operad-io/dev 0.1.1 → 0.3.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 (50) hide show
  1. package/README.md +1 -1
  2. package/dev.schema.json +53 -31
  3. package/package.json +9 -6
  4. package/skills/git/SKILL.md +70 -0
  5. package/skills/setup/SKILL.md +74 -0
  6. package/src/access-grants.ts +59 -0
  7. package/src/actions.ts +81 -17
  8. package/src/announce.ts +134 -17
  9. package/src/chat.ts +586 -36
  10. package/src/check-host.ts +111 -0
  11. package/src/check-load.ts +67 -0
  12. package/src/check.ts +45 -22
  13. package/src/clock.ts +29 -0
  14. package/src/clone-chat.ts +32 -0
  15. package/src/commands.ts +103 -34
  16. package/src/create-actions.ts +210 -0
  17. package/src/flaky.ts +45 -29
  18. package/src/flow-compiler.ts +156 -69
  19. package/src/followups.ts +20 -22
  20. package/src/gate.ts +254 -88
  21. package/src/git-state.ts +155 -0
  22. package/src/git.ts +92 -4
  23. package/src/index.ts +52 -6
  24. package/src/integrate.ts +162 -62
  25. package/src/integration-queue.ts +23 -10
  26. package/src/lock.ts +101 -5
  27. package/src/mainclone.ts +61 -5
  28. package/src/model-error.ts +70 -0
  29. package/src/model.ts +61 -35
  30. package/src/notcode.ts +51 -15
  31. package/src/places.ts +2 -2
  32. package/src/prepare.ts +7 -2
  33. package/src/project-flows.ts +135 -4
  34. package/src/project-settings.ts +110 -3
  35. package/src/register-requests.ts +121 -0
  36. package/src/repository-key.ts +4 -0
  37. package/src/rerun.ts +23 -7
  38. package/src/retry.ts +2 -12
  39. package/src/rework.ts +8 -0
  40. package/src/schedule.ts +342 -93
  41. package/src/service.ts +241 -185
  42. package/src/settings.ts +409 -65
  43. package/src/setup-git.ts +366 -0
  44. package/src/standing.ts +23 -6
  45. package/src/step-edge.ts +22 -0
  46. package/src/steps.ts +945 -179
  47. package/src/throughput.ts +4 -21
  48. package/src/timeouts.ts +10 -2
  49. package/src/views.ts +325 -86
  50. package/src/waits.ts +59 -0
package/src/waits.ts CHANGED
@@ -6,6 +6,7 @@
6
6
  * drift apart.
7
7
  */
8
8
 
9
+ import type { ChoiceInfo } from "@operad-io/engine";
9
10
  import { isIntegrating, type ReviewRecord, type TaskData } from "./model.ts";
10
11
 
11
12
  /** The actions a person wait answers. */
@@ -18,9 +19,21 @@ export const WAIT_STEPS = {
18
19
  "review-timeout": "wait_review_timeout",
19
20
  "review-unavailable": "wait_review_unavailable",
20
21
  "review-out-of-time": "wait_review_out_of_time",
22
+ // A worker's own question, such as a permission ask from its harness.
23
+ "work-question": "wait_work_question",
21
24
  } as const;
22
25
  export type WaitKind = keyof typeof WAIT_STEPS;
23
26
 
27
+ /** The answers a worker's harness may ask for when its question outlives its grace. */
28
+ export const WORK_QUESTION_CHOICES = ["allow_once", "reject_once"] as const;
29
+ export const WORK_QUESTION_LATE_CHOICES = ["allow_always"] as const;
30
+
31
+ /** True for the wait a worker's own question goes to (one per code stage). */
32
+ export function isWorkQuestionWait(id: string): boolean {
33
+ const base = WAIT_STEPS["work-question"];
34
+ return id === base || id.startsWith(`${base}_`);
35
+ }
36
+
24
37
  const WAIT_ACCEPTS: Readonly<Record<WaitKind, readonly WaitAction[]>> = {
25
38
  person: WAIT_ACTIONS,
26
39
  // A timed-out or out-of-time review is the reviewer's business: a person can
@@ -29,6 +42,8 @@ const WAIT_ACCEPTS: Readonly<Record<WaitKind, readonly WaitAction[]>> = {
29
42
  "review-out-of-time": ["merge", "reject", "rework"],
30
43
  // The reviewer may be back: the same commit can be checked again.
31
44
  "review-unavailable": ["merge", "reject", "rework", "reverify"],
45
+ // The worker's own question is not one of dev's task actions.
46
+ "work-question": [],
32
47
  };
33
48
 
34
49
  /** The choices of a wait; a flow with no check or review has nothing to reverify. */
@@ -40,6 +55,50 @@ export function waitChoices(
40
55
  return hasReverify ? accepts : accepts.filter((action) => action !== "reverify");
41
56
  }
42
57
 
58
+ /** What each task wait choice is, apart from whether merge is the recommended one. */
59
+ const WAIT_CHOICE_INFO: Readonly<Record<WaitAction, ChoiceInfo>> = {
60
+ merge: {
61
+ label: "Merge",
62
+ hint: "Merge the task's changes into main.",
63
+ },
64
+ rework: {
65
+ label: "Rework",
66
+ hint: "Send the task back to the agent with your note.",
67
+ // dev:rework refuses an empty note, so a client must ask for one.
68
+ note: "required",
69
+ },
70
+ reverify: {
71
+ label: "Check again",
72
+ hint: "Run the checks and the review again.",
73
+ },
74
+ reject: {
75
+ label: "Reject",
76
+ hint: "Discard the task's changes.",
77
+ role: "destructive",
78
+ },
79
+ };
80
+
81
+ /**
82
+ * What the offered choices say. `primary` marks merge as the recommended answer;
83
+ * a wait after a failed check, failed work or no change leaves it out.
84
+ */
85
+ export function waitChoiceInfo(
86
+ choices: readonly string[],
87
+ primary: boolean,
88
+ ): Readonly<Record<string, ChoiceInfo>> {
89
+ const info: Record<string, ChoiceInfo> = {};
90
+ for (const choice of choices) {
91
+ if (!(WAIT_ACTIONS as readonly string[]).includes(choice)) continue;
92
+ const action = choice as WaitAction;
93
+ const copy = WAIT_CHOICE_INFO[action];
94
+ info[choice] =
95
+ action === "merge" && primary
96
+ ? { ...copy, role: "primary" }
97
+ : copy;
98
+ }
99
+ return info;
100
+ }
101
+
43
102
  /**
44
103
  * True while a review waits for its model to come back. The flow is not asking
45
104
  * a person anything then, so no wait action is offered.