@osolmaz/pi-workflows 0.11.2 → 0.12.1

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 (177) hide show
  1. package/README.md +15 -10
  2. package/dist/builtins/autoimplement-command-batches.d.ts +52 -0
  3. package/dist/builtins/autoimplement-command-batches.js +258 -0
  4. package/dist/builtins/autoimplement-command-batches.js.map +1 -0
  5. package/dist/builtins/autoimplement.workflow.d.ts +509 -124
  6. package/dist/builtins/autoimplement.workflow.js +884 -327
  7. package/dist/builtins/autoimplement.workflow.js.map +1 -1
  8. package/dist/builtins/catalog.js +5 -3
  9. package/dist/builtins/catalog.js.map +1 -1
  10. package/dist/builtins/index.d.ts +4 -1
  11. package/dist/builtins/index.js +3 -1
  12. package/dist/builtins/index.js.map +1 -1
  13. package/dist/builtins/monitor.workflow.d.ts +2 -4
  14. package/dist/builtins/monitor.workflow.js +26 -128
  15. package/dist/builtins/monitor.workflow.js.map +1 -1
  16. package/dist/builtins/pi-agent-group.d.ts +72 -0
  17. package/dist/builtins/pi-agent-group.js +1087 -0
  18. package/dist/builtins/pi-agent-group.js.map +1 -0
  19. package/dist/builtins/plan-approval.workflow.d.ts +39 -5
  20. package/dist/builtins/plan-approval.workflow.js +92 -14
  21. package/dist/builtins/plan-approval.workflow.js.map +1 -1
  22. package/dist/builtins/plan-change.workflow.d.ts +301 -0
  23. package/dist/builtins/plan-change.workflow.js +256 -0
  24. package/dist/builtins/plan-change.workflow.js.map +1 -0
  25. package/dist/builtins/plan-presentation.js +2 -2
  26. package/dist/builtins/plan-presentation.js.map +1 -1
  27. package/dist/builtins/sanity-check.workflow.d.ts +85 -0
  28. package/dist/builtins/sanity-check.workflow.js +482 -0
  29. package/dist/builtins/sanity-check.workflow.js.map +1 -0
  30. package/dist/controllers/sqlite.d.ts +90 -2
  31. package/dist/controllers/sqlite.js +380 -5
  32. package/dist/controllers/sqlite.js.map +1 -1
  33. package/dist/extension/decision-channels.d.ts +2 -2
  34. package/dist/extension/decision-channels.js +29 -35
  35. package/dist/extension/decision-channels.js.map +1 -1
  36. package/dist/extension/deferred-turn-coordinator.d.ts +32 -0
  37. package/dist/extension/deferred-turn-coordinator.js +143 -0
  38. package/dist/extension/deferred-turn-coordinator.js.map +1 -0
  39. package/dist/extension/deferred-turn.d.ts +44 -0
  40. package/dist/extension/deferred-turn.js +110 -0
  41. package/dist/extension/deferred-turn.js.map +1 -0
  42. package/dist/extension/index.js +348 -80
  43. package/dist/extension/index.js.map +1 -1
  44. package/dist/extension/session-events.d.ts +2 -2
  45. package/dist/extension/step-message.d.ts +1 -0
  46. package/dist/extension/step-message.js.map +1 -1
  47. package/dist/extension/widget.js +23 -3
  48. package/dist/extension/widget.js.map +1 -1
  49. package/dist/herdr/setup.js +4 -4
  50. package/dist/render/graph-render.js +1 -2
  51. package/dist/render/graph-render.js.map +1 -1
  52. package/dist/viewer/render.js +7 -6
  53. package/dist/viewer/render.js.map +1 -1
  54. package/dist/workflows/catalog.js +7 -2
  55. package/dist/workflows/catalog.js.map +1 -1
  56. package/dist/workflows/command-batch.d.ts +38 -0
  57. package/dist/workflows/command-batch.js +176 -0
  58. package/dist/workflows/command-batch.js.map +1 -0
  59. package/dist/workflows/composition.js +8 -0
  60. package/dist/workflows/composition.js.map +1 -1
  61. package/dist/workflows/decision-presentation.d.ts +1 -1
  62. package/dist/workflows/decision-presentation.js +51 -38
  63. package/dist/workflows/decision-presentation.js.map +1 -1
  64. package/dist/workflows/engine.d.ts +2 -2
  65. package/dist/workflows/engine.js +22 -17
  66. package/dist/workflows/engine.js.map +1 -1
  67. package/dist/workflows/errors.d.ts +13 -0
  68. package/dist/workflows/errors.js +15 -0
  69. package/dist/workflows/errors.js.map +1 -1
  70. package/dist/workflows/human-decision.d.ts +16 -4
  71. package/dist/workflows/human-decision.js +175 -72
  72. package/dist/workflows/human-decision.js.map +1 -1
  73. package/dist/workflows/index.d.ts +3 -2
  74. package/dist/workflows/index.js +2 -1
  75. package/dist/workflows/index.js.map +1 -1
  76. package/dist/workflows/progress.d.ts +1 -0
  77. package/dist/workflows/progress.js +15 -3
  78. package/dist/workflows/progress.js.map +1 -1
  79. package/dist/workflows/schema.js +12 -1
  80. package/dist/workflows/schema.js.map +1 -1
  81. package/dist/workflows/shell.d.ts +4 -0
  82. package/dist/workflows/shell.js +6 -0
  83. package/dist/workflows/shell.js.map +1 -1
  84. package/dist/workflows/store.js +8 -1
  85. package/dist/workflows/store.js.map +1 -1
  86. package/dist/workflows/types.d.ts +37 -48
  87. package/docs/2026-08-18-herdr-piw-plan.md +1 -1
  88. package/docs/2026-08-20-durable-workflow-launch-plan.md +19 -23
  89. package/docs/CONTROLLERS.md +2 -2
  90. package/docs/DEFERRED_TURNS.md +298 -0
  91. package/docs/DESIGN_PHILOSOPHY.md +1 -1
  92. package/docs/HUMAN_DECISIONS.md +30 -40
  93. package/docs/HUMAN_DECISION_PRESENTATIONS.md +17 -27
  94. package/docs/MONITOR.md +7 -13
  95. package/docs/WORKFLOW_COMPOSITION.md +10 -9
  96. package/docs/WORKFLOW_STEP_MESSAGES.md +5 -5
  97. package/docs/WORKFLOW_UPDATES.md +28 -5
  98. package/docs/plans/2026-08-04-controller-runtime-plan.md +1 -1
  99. package/docs/plans/2026-08-05-always-on-workflows-plan.md +1 -1
  100. package/docs/plans/2026-08-10-agent-managed-monitor-workflows-plan.md +9 -9
  101. package/docs/plans/2026-08-13-built-in-workflow-catalog-plan.md +1 -1
  102. package/docs/plans/2026-08-13-session-addressed-workflow-notifications-plan.md +1 -1
  103. package/docs/plans/2026-08-16-workflow-updates-plan.md +3 -3
  104. package/docs/plans/2026-08-17-bundled-skills-plan.md +6 -6
  105. package/docs/plans/2026-08-19-human-decision-gates-plan.md +5 -5
  106. package/docs/plans/2026-08-19-human-decision-presentations-plan.md +1 -1
  107. package/docs/plans/2026-08-19-provider-compatible-workflow-tool-schema-plan.md +1 -1
  108. package/docs/plans/2026-08-19-workflow-composition-plan.md +6 -6
  109. package/docs/plans/2026-08-20-autoimplement-blocker-challenge-plan.md +3 -3
  110. package/docs/plans/2026-08-20-bounded-command-batches-plan.md +206 -0
  111. package/docs/plans/2026-08-20-herdr-plugin-sync-plan.md +9 -9
  112. package/docs/plans/2026-08-21-autoimplement-timeout-fallback-plan.md +242 -0
  113. package/docs/plans/2026-08-21-deferred-turn-intents-plan.md +324 -0
  114. package/docs/plans/2026-08-21-plan-change-approval-policy-plan.md +322 -0
  115. package/docs/plans/2026-08-21-sanity-check-plan.md +283 -0
  116. package/docs/run-bundles.md +8 -6
  117. package/docs/workflows.md +85 -22
  118. package/examples/workflows/approved-plan.workflow.ts +19 -46
  119. package/examples/workflows/command-batch.workflow.ts +50 -0
  120. package/examples/workflows/sanity-check.workflow.ts +1 -0
  121. package/herdr-plugin.toml +3 -3
  122. package/package.json +7 -7
  123. package/schemas/decision-presentation-v1.schema.json +1 -1
  124. package/schemas/human-decision-accepted-v1.schema.json +16 -4
  125. package/schemas/human-decision-answer-attempt-v1.schema.json +1 -1
  126. package/schemas/human-decision-cancellation-v1.schema.json +1 -1
  127. package/schemas/human-decision-continuation-v1.schema.json +11 -2
  128. package/schemas/human-decision-delivery-v1.schema.json +9 -1
  129. package/schemas/human-decision-receipt-v1.schema.json +9 -1
  130. package/schemas/human-decision-request-v1.schema.json +25 -5
  131. package/schemas/human-decision-resolution-v1.schema.json +1 -1
  132. package/schemas/human-decision-settlement-v1.schema.json +1 -1
  133. package/skills/autodoc/SKILL.md +33 -2
  134. package/skills/autoimplement/SKILL.md +93 -12
  135. package/skills/autoplan/SKILL.md +26 -2
  136. package/skills/monitor/SKILL.md +66 -24
  137. package/skills/pi-workflows/SKILL.md +21 -6
  138. package/skills/sanity-check/SKILL.md +44 -0
  139. package/src/builtins/autoimplement-command-batches.ts +364 -0
  140. package/src/builtins/autoimplement.workflow.ts +1075 -370
  141. package/src/builtins/catalog.ts +5 -3
  142. package/src/builtins/index.ts +24 -0
  143. package/src/builtins/monitor.workflow.ts +27 -150
  144. package/src/builtins/pi-agent-group.ts +1407 -0
  145. package/src/builtins/plan-approval.workflow.ts +157 -24
  146. package/src/builtins/plan-change.workflow.ts +321 -0
  147. package/src/builtins/plan-presentation.ts +2 -2
  148. package/src/builtins/sanity-check.workflow.ts +769 -0
  149. package/src/controllers/sqlite.ts +580 -7
  150. package/src/extension/decision-channels.ts +36 -66
  151. package/src/extension/deferred-turn-coordinator.ts +171 -0
  152. package/src/extension/deferred-turn.ts +166 -0
  153. package/src/extension/index.ts +438 -90
  154. package/src/extension/session-events.ts +2 -2
  155. package/src/extension/step-message.ts +1 -0
  156. package/src/extension/widget.ts +24 -5
  157. package/src/herdr/setup.ts +4 -4
  158. package/src/render/graph-render.ts +1 -2
  159. package/src/viewer/render.ts +7 -6
  160. package/src/workflows/catalog.ts +7 -2
  161. package/src/workflows/command-batch.ts +254 -0
  162. package/src/workflows/composition.ts +9 -0
  163. package/src/workflows/decision-presentation.ts +56 -43
  164. package/src/workflows/engine.ts +25 -20
  165. package/src/workflows/errors.ts +24 -0
  166. package/src/workflows/human-decision.ts +218 -101
  167. package/src/workflows/index.ts +20 -11
  168. package/src/workflows/progress.ts +18 -3
  169. package/src/workflows/schema.ts +19 -1
  170. package/src/workflows/shell.ts +10 -0
  171. package/src/workflows/store.ts +8 -1
  172. package/src/workflows/types.ts +43 -59
  173. package/schemas/human-decision-accepted-v2.schema.json +0 -50
  174. package/schemas/human-decision-delivery-v2.schema.json +0 -36
  175. package/schemas/human-decision-receipt-v2.schema.json +0 -39
  176. package/schemas/human-decision-request-v2.schema.json +0 -69
  177. package/schemas/human-decision-resolution-v2.schema.json +0 -27
package/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # pi-workflows
2
2
 
3
+ <p align="center">
4
+ <img src="assets/cover.svg" alt="pi-workflows: a representative multi-step workflow graph with plan, implement, verify, review, a fix loop, and a clean finish" width="880">
5
+ </p>
6
+
3
7
  pi-workflows is a workflow extension for the [pi coding agent](https://pi.dev).
4
8
  It lets you define multi-step agent workflows as TypeScript graphs, trigger
5
9
  them at any point in a pi conversation with `/workflow`, and watch them run
@@ -36,13 +40,14 @@ Or try the npm package without installing it:
36
40
  pi -e npm:@osolmaz/pi-workflows
37
41
  ```
38
42
 
39
- The Pi package includes the extension and five optional skills:
43
+ The Pi package includes the extension and six optional skills:
40
44
 
41
45
  - `pi-workflows` teaches the agent how to operate and author workflows.
42
46
  - `monitor` starts and operates the built-in monitor workflow.
43
47
  - `autoplan` selects the best practical solution and writes an implementation plan.
44
48
  - `autodoc` records an existing plan in canonical documentation.
45
49
  - `autoimplement` implements an existing plan and verifies the result.
50
+ - `sanity-check` reviews whether a contribution is necessary, focused, and well supported.
46
51
 
47
52
  Pi discovers these skills when it loads the package. Use `pi config` to disable
48
53
  the extension, all bundled skills, or one skill independently. The equivalent
@@ -76,14 +81,14 @@ or run it in place with `npx tsx src/viewer/cli.ts`.
76
81
 
77
82
  ## Herdr integration
78
83
 
79
- Pi Workflows also ships as a [Herdr](https://herdr.dev) plugin. After installing
80
- `piw` and Pi Workflows, synchronize the bundled plugin:
84
+ pi-workflows also ships as a [Herdr](https://herdr.dev) plugin. After installing
85
+ `piw` and pi-workflows, synchronize the bundled plugin:
81
86
 
82
87
  ```bash
83
88
  pi-workflows herdr sync
84
89
  ```
85
90
 
86
- Run the same command after a Pi Workflows update. It finds the package that
91
+ Run the same command after a pi-workflows update. It finds the package that
87
92
  provides the running CLI and repairs a Herdr link when npm moved that package.
88
93
  `pi-workflows herdr setup` remains an alias for existing installations. Use
89
94
  `--json` for versioned machine-readable output. The [Herdr plugin sync
@@ -94,7 +99,7 @@ When Pi runs inside Herdr, a workflow widget shows `Ctrl+Shift+R piw`. When the
94
99
  The shortcut opens the exact run bundle and lets you choose a split, tab, or new
95
100
  workspace. `/piw` opens the same menu, and `/piw right`, `/piw below`, `/piw
96
101
  left`, `/piw above`, `/piw tab`, or `/piw workspace` selects a placement
97
- directly. If a viewer for that run already exists, Pi Workflows focuses it
102
+ directly. If a viewer for that run already exists, pi-workflows focuses it
98
103
  instead of opening a duplicate.
99
104
 
100
105
  The plugin uses Herdr's public pane APIs and runs no service or polling loop. It
@@ -130,7 +135,7 @@ Then, from any pi conversation:
130
135
  ```
131
136
 
132
137
  A model-started workflow is saved before the tool reports it as queued. The returned run ID works
133
- with `workflow status` and `workflow cancel` before execution starts. Pi Workflows waits for the
138
+ with `workflow status` and `workflow cancel` before execution starts. pi-workflows waits for the
134
139
  current agent turn to settle before activation. If activation fails, it saves the failure and sends
135
140
  one follow-up turn so the model can correct the cause and start a new run.
136
141
 
@@ -191,7 +196,7 @@ The model can use the same `workflow` tool to list, start, inspect, pause,
191
196
  resume, cancel, and answer workflows. Step contracts use the tool's `submit`
192
197
  action. Slash commands and model actions share one lifecycle implementation.
193
198
 
194
- Pi Workflows includes a `monitor` workflow for plain-language requests such as:
199
+ pi-workflows includes a `monitor` workflow for plain-language requests such as:
195
200
 
196
201
  > Monitor PR 123 every 30 minutes. Report failed checks. Stop when it is merged or closed.
197
202
 
@@ -352,7 +357,7 @@ example set. Copy any of them into `.pi/workflows/` to use them:
352
357
  a detailed implementation plan, using the ideal end state as guidance rather
353
358
  than an out-of-scope requirement.
354
359
  - `autoimplement` finds a clear existing plan, documents it when needed,
355
- implements and verifies it, writes and runs the exact Pi Reviewer command,
360
+ implements and verifies it, writes and runs the exact pi-reviewer command,
356
361
  tracks P0 through P2, handles PR comments and CI, and
357
362
  finalizes the PR. P0 and P1 fixes require another review. P2-only work is
358
363
  verified without another reviewer round. A five-minute CI wait routes to
@@ -361,8 +366,8 @@ example set. Copy any of them into `.pi/workflows/` to use them:
361
366
  - `human-decision` shows a reusable verified-human gate with a structured
362
367
  machine subject, a separate readable operator presentation, plain choices,
363
368
  and exact replan text.
364
- - `approved-plan` composes autoplan, autodoc, and the reusable plan-approval
365
- workflow without copying their internal nodes.
369
+ - `approved-plan` includes the shared plan-change workflow, which composes
370
+ autoplan, autodoc, the configurable plan decision, and bounded replanning.
366
371
  - `autoresearch` runs an iterative feature-search loop in the style of
367
372
  [karpathy/autoresearch](https://github.com/karpathy/autoresearch): setup
368
373
  creates a frozen evaluation harness, one editable feature file, and a
@@ -0,0 +1,52 @@
1
+ import { type CommandBatchItem } from "../workflows/command-batch.js";
2
+ export declare const REVIEW_TIMEOUT_MS: number;
3
+ export declare const CI_WATCH_TIMEOUT_MS: number;
4
+ export declare const VERIFICATION_TIMEOUT_MS: number;
5
+ export declare const AUTOIMPLEMENT_BATCH_MAX_OUTPUT_CHARS = 1000000;
6
+ export declare const AUTOIMPLEMENT_MAX_CONCURRENCY = 8;
7
+ export type AutoimplementConcurrency = {
8
+ reviewer: number;
9
+ ciWatch: number;
10
+ verification: number;
11
+ };
12
+ export type PublishedRepository = {
13
+ id: string;
14
+ repository: string;
15
+ branch: string;
16
+ baseBranch: string;
17
+ headRevision: string;
18
+ pr: string;
19
+ dependencyFingerprint?: string;
20
+ };
21
+ export type PublishedRepositories = {
22
+ repositories: PublishedRepository[];
23
+ };
24
+ export type VerificationCommandPlan = {
25
+ commands: CommandBatchItem[];
26
+ untested: string[];
27
+ };
28
+ export type CiTargetInspection = {
29
+ id: string;
30
+ repository: string;
31
+ headRevision: string;
32
+ pr: string;
33
+ route: "green" | "failed" | "pending" | "unavailable";
34
+ reason: string;
35
+ relatedFailures: string[];
36
+ unrelatedFailures: string[];
37
+ trackingCommand?: CommandBatchItem;
38
+ };
39
+ export type CiInspectionBatch = {
40
+ route: "green" | "failed" | "pending" | "unavailable";
41
+ reason: string;
42
+ relatedFailures: string[];
43
+ unrelatedFailures: string[];
44
+ targets: CiTargetInspection[];
45
+ };
46
+ export declare function parseAutoimplementConcurrency(value: unknown): AutoimplementConcurrency;
47
+ export declare function parsePublishedRepositories(value: unknown): PublishedRepositories;
48
+ export declare function reviewerCommand(repository: PublishedRepository): CommandBatchItem;
49
+ export declare function parseVerificationCommandPlan(value: unknown): VerificationCommandPlan;
50
+ export declare function parseCiInspectionBatch(value: unknown): CiInspectionBatch;
51
+ export declare function parseCiCommand(value: unknown, id: string, repository: string, pr: string): CommandBatchItem;
52
+ export declare function repositoryId(repository: string): string;
@@ -0,0 +1,258 @@
1
+ import { createHash } from "node:crypto";
2
+ import path from "node:path";
3
+ import { MAX_COMMAND_BATCH_ITEMS, validateCommandBatchRequest, } from "../workflows/command-batch.js";
4
+ export const REVIEW_TIMEOUT_MS = 10 * 60_000;
5
+ export const CI_WATCH_TIMEOUT_MS = 5 * 60_000;
6
+ export const VERIFICATION_TIMEOUT_MS = 45 * 60_000;
7
+ export const AUTOIMPLEMENT_BATCH_MAX_OUTPUT_CHARS = 1_000_000;
8
+ export const AUTOIMPLEMENT_MAX_CONCURRENCY = 8;
9
+ export function parseAutoimplementConcurrency(value) {
10
+ if (value === undefined)
11
+ return { reviewer: 4, ciWatch: 4, verification: 2 };
12
+ const input = requireRecord(value, "autoimplement concurrency");
13
+ for (const key of Object.keys(input)) {
14
+ if (key !== "reviewer" && key !== "ciWatch" && key !== "verification") {
15
+ throw new Error(`autoimplement concurrency.${key} is not supported`);
16
+ }
17
+ }
18
+ return {
19
+ reviewer: concurrencyValue(input.reviewer ?? 4, "reviewer"),
20
+ ciWatch: concurrencyValue(input.ciWatch ?? 4, "ciWatch"),
21
+ verification: concurrencyValue(input.verification ?? 2, "verification"),
22
+ };
23
+ }
24
+ export function parsePublishedRepositories(value) {
25
+ const result = requireRecord(value, "publication result");
26
+ if (!Array.isArray(result.repositories) || result.repositories.length === 0) {
27
+ throw new Error("publication result repositories must be a non-empty array");
28
+ }
29
+ if (result.repositories.length > MAX_COMMAND_BATCH_ITEMS) {
30
+ throw new Error(`publication result repositories must contain at most ${MAX_COMMAND_BATCH_ITEMS} entries`);
31
+ }
32
+ const ids = new Set();
33
+ const repositories = result.repositories.map((entry, index) => {
34
+ const raw = requireRecord(entry, `publication repositories[${index}]`);
35
+ const repository = requireAbsolutePath(raw.repository, `publication repositories[${index}].repository`);
36
+ const id = repositoryId(repository);
37
+ if (ids.has(id))
38
+ throw new Error(`publication repository is duplicated: ${repository}`);
39
+ ids.add(id);
40
+ const dependencyFingerprint = optionalString(raw.dependencyFingerprint, `publication repositories[${index}].dependencyFingerprint`);
41
+ if (raw.pushed !== true) {
42
+ throw new Error(`publication repositories[${index}].pushed must be true`);
43
+ }
44
+ return {
45
+ id,
46
+ repository,
47
+ branch: requireString(raw.branch, `publication repositories[${index}].branch`),
48
+ baseBranch: requireString(raw.baseBranch, `publication repositories[${index}].baseBranch`),
49
+ headRevision: requireString(raw.headRevision, `publication repositories[${index}].headRevision`),
50
+ pr: requireString(raw.pr, `publication repositories[${index}].pr`),
51
+ ...(dependencyFingerprint !== undefined ? { dependencyFingerprint } : {}),
52
+ };
53
+ });
54
+ return { repositories };
55
+ }
56
+ export function reviewerCommand(repository) {
57
+ return {
58
+ id: repository.id,
59
+ command: "pi-reviewer",
60
+ args: ["--base", repository.baseBranch],
61
+ cwd: repository.repository,
62
+ timeoutMs: REVIEW_TIMEOUT_MS,
63
+ maxOutputChars: AUTOIMPLEMENT_BATCH_MAX_OUTPUT_CHARS,
64
+ };
65
+ }
66
+ export function parseVerificationCommandPlan(value) {
67
+ const result = requireRecord(value, "verification command plan");
68
+ if (!Array.isArray(result.commands) || result.commands.length === 0) {
69
+ throw new Error("verification commands must be a non-empty array");
70
+ }
71
+ const directories = new Set();
72
+ const commands = result.commands.map((entry, index) => {
73
+ const command = parseCommandItem(entry, `verification commands[${index}]`, {
74
+ maxTimeoutMs: VERIFICATION_TIMEOUT_MS,
75
+ });
76
+ if (directories.has(command.cwd)) {
77
+ throw new Error(`verification commands must use distinct working directories: ${command.cwd}`);
78
+ }
79
+ directories.add(command.cwd);
80
+ validateVerificationCommand(command, index);
81
+ return command;
82
+ });
83
+ const validated = validateCommandBatchRequest({ items: commands, maxConcurrency: 1 });
84
+ return {
85
+ commands: validated.items,
86
+ untested: stringArray(result.untested ?? [], "verification untested"),
87
+ };
88
+ }
89
+ export function parseCiInspectionBatch(value) {
90
+ const result = requireRecord(value, "CI inspection");
91
+ if (!Array.isArray(result.targets) || result.targets.length === 0) {
92
+ throw new Error("CI inspection targets must be a non-empty array");
93
+ }
94
+ if (result.targets.length > MAX_COMMAND_BATCH_ITEMS) {
95
+ throw new Error(`CI inspection targets must contain at most ${MAX_COMMAND_BATCH_ITEMS} entries`);
96
+ }
97
+ const ids = new Set();
98
+ const targets = result.targets.map((entry, index) => {
99
+ const raw = requireRecord(entry, `CI targets[${index}]`);
100
+ const repository = requireAbsolutePath(raw.repository, `CI targets[${index}].repository`);
101
+ const id = repositoryId(repository);
102
+ if (ids.has(id))
103
+ throw new Error(`CI target is duplicated: ${repository}`);
104
+ ids.add(id);
105
+ if (raw.route !== "green" &&
106
+ raw.route !== "failed" &&
107
+ raw.route !== "pending" &&
108
+ raw.route !== "unavailable") {
109
+ throw new Error(`CI targets[${index}].route is invalid`);
110
+ }
111
+ const pr = requireString(raw.pr, `CI targets[${index}].pr`);
112
+ const target = {
113
+ id,
114
+ repository,
115
+ headRevision: requireString(raw.headRevision, `CI targets[${index}].headRevision`),
116
+ pr,
117
+ route: raw.route,
118
+ reason: requireString(raw.reason, `CI targets[${index}].reason`),
119
+ relatedFailures: stringArray(raw.relatedFailures ?? [], `CI targets[${index}].relatedFailures`),
120
+ unrelatedFailures: stringArray(raw.unrelatedFailures ?? [], `CI targets[${index}].unrelatedFailures`),
121
+ };
122
+ if (raw.route === "pending") {
123
+ target.trackingCommand = parseCiCommand(raw.trackingCommand, id, repository, pr);
124
+ }
125
+ return target;
126
+ });
127
+ const route = targets.some((target) => target.route === "failed")
128
+ ? "failed"
129
+ : targets.some((target) => target.route === "pending")
130
+ ? "pending"
131
+ : targets.some((target) => target.route === "unavailable")
132
+ ? "unavailable"
133
+ : "green";
134
+ return {
135
+ route,
136
+ reason: targets.map((target) => `${target.id}: ${target.reason}`).join("; "),
137
+ relatedFailures: targets.flatMap((target) => target.relatedFailures),
138
+ unrelatedFailures: targets.flatMap((target) => target.unrelatedFailures),
139
+ targets,
140
+ };
141
+ }
142
+ export function parseCiCommand(value, id, repository, pr) {
143
+ const raw = requireRecord(value, "CI tracking command");
144
+ if (raw.id !== id)
145
+ throw new Error("CI tracking command id must match the target repository");
146
+ const command = parseCommandItem(raw, "CI tracking command", {
147
+ id,
148
+ command: "gh",
149
+ cwd: repository,
150
+ maxTimeoutMs: CI_WATCH_TIMEOUT_MS,
151
+ });
152
+ const args = command.args;
153
+ const prWatch = (args.length === 3 && args[0] === "pr" && args[1] === "checks" && args[2] === "--watch") ||
154
+ (args.length === 4 &&
155
+ args[0] === "pr" &&
156
+ args[1] === "checks" &&
157
+ args[2] === pr &&
158
+ args[3] === "--watch");
159
+ const runWatch = args.length === 3 &&
160
+ args[0] === "run" &&
161
+ args[1] === "watch" &&
162
+ /^[1-9]\d*$/.test(args[2] ?? "");
163
+ if (!prWatch && !runWatch) {
164
+ throw new Error("CI tracking command args are not allowed for the target PR");
165
+ }
166
+ return { ...command, args: ["pr", "checks", pr, "--watch"] };
167
+ }
168
+ export function repositoryId(repository) {
169
+ const canonical = path.resolve(repository);
170
+ return createHash("sha256").update(canonical).digest("hex").slice(0, 16);
171
+ }
172
+ function parseCommandItem(value, label, options) {
173
+ const raw = requireRecord(value, label);
174
+ const id = options.id ?? requireString(raw.id, `${label}.id`);
175
+ const command = options.command ?? requireString(raw.command, `${label}.command`);
176
+ if (options.command !== undefined && raw.command !== options.command) {
177
+ throw new Error(`${label}.command must be ${options.command}`);
178
+ }
179
+ if (!Array.isArray(raw.args) || raw.args.some((arg) => typeof arg !== "string")) {
180
+ throw new Error(`${label}.args must be an array of strings`);
181
+ }
182
+ const cwd = options.cwd ?? requireAbsolutePath(raw.cwd, `${label}.cwd`);
183
+ if (options.cwd !== undefined && path.resolve(String(raw.cwd)) !== options.cwd) {
184
+ throw new Error(`${label}.cwd must match the target repository`);
185
+ }
186
+ const timeoutMs = positiveInteger(raw.timeoutMs, `${label}.timeoutMs`, options.maxTimeoutMs);
187
+ const maxOutputChars = positiveInteger(raw.maxOutputChars ?? AUTOIMPLEMENT_BATCH_MAX_OUTPUT_CHARS, `${label}.maxOutputChars`, AUTOIMPLEMENT_BATCH_MAX_OUTPUT_CHARS);
188
+ return { id, command, args: [...raw.args], cwd, timeoutMs, maxOutputChars };
189
+ }
190
+ function validateVerificationCommand(command, index) {
191
+ const forbiddenCommands = new Set([
192
+ "ash",
193
+ "bash",
194
+ "cmd",
195
+ "cmd.exe",
196
+ "csh",
197
+ "dash",
198
+ "fish",
199
+ "gh",
200
+ "git",
201
+ "ksh",
202
+ "powershell",
203
+ "powershell.exe",
204
+ "pwsh",
205
+ "pwsh.exe",
206
+ "rm",
207
+ "sh",
208
+ "tcsh",
209
+ "zsh",
210
+ ]);
211
+ const executable = path.win32.basename(path.basename(command.command)).toLowerCase();
212
+ if (forbiddenCommands.has(executable)) {
213
+ throw new Error(`verification commands[${index}].command is not allowed`);
214
+ }
215
+ const joined = command.args.join(" ").toLowerCase();
216
+ if (/\b(publish|release|deploy|push|merge)\b/.test(joined)) {
217
+ throw new Error(`verification commands[${index}] contains a mutation or publication action`);
218
+ }
219
+ }
220
+ function concurrencyValue(value, field) {
221
+ return positiveInteger(value, `autoimplement concurrency.${field}`, AUTOIMPLEMENT_MAX_CONCURRENCY);
222
+ }
223
+ function positiveInteger(value, label, maximum) {
224
+ if (!Number.isSafeInteger(value) || value < 1 || value > maximum) {
225
+ throw new Error(`${label} must be an integer from 1 through ${maximum}`);
226
+ }
227
+ return value;
228
+ }
229
+ function stringArray(value, label) {
230
+ if (!Array.isArray(value) || value.some((item) => typeof item !== "string")) {
231
+ throw new Error(`${label} must be an array of strings`);
232
+ }
233
+ return [...value];
234
+ }
235
+ function requireRecord(value, label) {
236
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
237
+ throw new Error(`${label} must be an object`);
238
+ }
239
+ return value;
240
+ }
241
+ function requireString(value, label) {
242
+ if (typeof value !== "string" || value.trim().length === 0) {
243
+ throw new Error(`${label} must be a non-empty string`);
244
+ }
245
+ return value;
246
+ }
247
+ function optionalString(value, label) {
248
+ if (value === undefined)
249
+ return undefined;
250
+ return requireString(value, label);
251
+ }
252
+ function requireAbsolutePath(value, label) {
253
+ const resolved = requireString(value, label);
254
+ if (!path.isAbsolute(resolved))
255
+ throw new Error(`${label} must be absolute`);
256
+ return path.resolve(resolved);
257
+ }
258
+ //# sourceMappingURL=autoimplement-command-batches.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autoimplement-command-batches.js","sourceRoot":"","sources":["../../src/builtins/autoimplement-command-batches.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,uBAAuB,EACvB,2BAA2B,GAE5B,MAAM,+BAA+B,CAAC;AAEvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,GAAG,MAAM,CAAC;AAC7C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAG,MAAM,CAAC;AAC9C,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,GAAG,MAAM,CAAC;AACnD,MAAM,CAAC,MAAM,oCAAoC,GAAG,SAAS,CAAC;AAC9D,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC;AA+C/C,MAAM,UAAU,6BAA6B,CAAC,KAAc;IAC1D,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;IAC7E,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,EAAE,2BAA2B,CAAC,CAAC;IAChE,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,IAAI,GAAG,KAAK,UAAU,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,cAAc,EAAE,CAAC;YACtE,MAAM,IAAI,KAAK,CAAC,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