@ligeti/workflow-github-small-factory 0.0.0-stage → 1.0.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.
- package/LICENSE +201 -0
- package/README.md +289 -2
- package/dist/checks-handoff.d.ts +30 -0
- package/dist/checks-handoff.d.ts.map +1 -0
- package/dist/checks-handoff.js +85 -0
- package/dist/checks-handoff.js.map +1 -0
- package/dist/diagram.d.ts +2 -0
- package/dist/diagram.d.ts.map +1 -0
- package/dist/diagram.js +66 -0
- package/dist/diagram.js.map +1 -0
- package/dist/failed-checks-file.d.ts +4 -0
- package/dist/failed-checks-file.d.ts.map +1 -0
- package/dist/failed-checks-file.js +27 -0
- package/dist/failed-checks-file.js.map +1 -0
- package/dist/land.d.ts +23 -0
- package/dist/land.d.ts.map +1 -0
- package/dist/land.js +300 -0
- package/dist/land.js.map +1 -0
- package/dist/prompts.d.ts +17 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +54 -0
- package/dist/prompts.js.map +1 -0
- package/dist/pull-request-file.d.ts +9 -0
- package/dist/pull-request-file.d.ts.map +1 -0
- package/dist/pull-request-file.js +32 -0
- package/dist/pull-request-file.js.map +1 -0
- package/dist/rebase.d.ts +21 -0
- package/dist/rebase.d.ts.map +1 -0
- package/dist/rebase.js +72 -0
- package/dist/rebase.js.map +1 -0
- package/dist/workflow.d.ts +76 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +343 -0
- package/dist/workflow.js.map +1 -0
- package/package.json +33 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Viktor "Bika" Nagy
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,290 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ligeti/workflow-github-small-factory
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Reads a GitHub issue and implements it in one Claude Code session -- two chained agent turns, no
|
|
4
|
+
specification round, no review loop, no beads. It is the GitHub counterpart of
|
|
5
|
+
[`@ligeti/workflow-small-factory`](../small-factory/README.md), copied from it rather than shared
|
|
6
|
+
([ADR-0001](../../adr/0001-package-boundaries-and-dependency-rules.md) forbids one workflow
|
|
7
|
+
depending on another). Every push and every pull request change is made by the workflow itself,
|
|
8
|
+
never by the agent: an agent only commits. The workflow reads the repository's default branch,
|
|
9
|
+
rebases the branch onto it (resolving a conflict with one more agent turn), pushes once and only then
|
|
10
|
+
opens the pull request against that branch, as a ready pull request, never a draft, because GitHub
|
|
11
|
+
refuses a pull request with no commits ahead of its base. It then lands the pull request: it waits for the checks, resumes the
|
|
12
|
+
agent session to fix failing checks or a conflict, and squash-merges the pull request once the
|
|
13
|
+
checks are green and it is mergeable. `autoMerge: false` stops after opening and assigning it.
|
|
14
|
+
|
|
15
|
+
## Vocabulary
|
|
16
|
+
|
|
17
|
+
These words are binding on this package. The project-wide vocabulary is
|
|
18
|
+
[`docs/glossary.md`](../../docs/glossary.md); a word that only this package uses is defined here
|
|
19
|
+
instead, per [ADR-0006](../../adr/0006-ubiquitous-language-is-an-enforced-artifact.md). Pull request,
|
|
20
|
+
check and base branch are defined in
|
|
21
|
+
[`steps/github-pr/README.md`](../../steps/github-pr/README.md#vocabulary).
|
|
22
|
+
|
|
23
|
+
| Term | Definition | It is NOT |
|
|
24
|
+
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
25
|
+
| **Turn** | One `@ligeti/step-agent` `runClaude` call: a single Claude Code prompt run to completion (or timeout) -- implementation, commit-and-describe, or, only when needed, one to resolve a rebase conflict or to fix failing checks. | Not a **run** -- a run is the whole workflow execution; a turn is one of the agent turns inside it. Not a review round. Not the issue read, which is a step. |
|
|
26
|
+
| **Fix round** | One spend of the `maxFixRounds` budget while landing the pull request: either a checks-fix turn or a rebase onto the base branch (with a conflict-resolution turn when it conflicts). The rebase before the first push is not a fix round. | Not a **turn** -- a rebase round may run no agent turn at all. Not a review round. |
|
|
27
|
+
|
|
28
|
+
## Inputs
|
|
29
|
+
|
|
30
|
+
| Input | Required | Default | Notes |
|
|
31
|
+
| ------------------------------ | -------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
32
|
+
| `issueUrl` | yes | -- | A full github.com issue URL, e.g. `https://github.com/owner/repo/issues/19`. Any other host, a pull request URL, a trailing slash, a query string or a control character is rejected. |
|
|
33
|
+
| `repoPath` | yes | -- | Main repository checkout the worktree is created from. Its remote must be named `origin`. |
|
|
34
|
+
| `model` | no | `"opus"` | Claude model for every turn. |
|
|
35
|
+
| `turnTimeoutSeconds` | no | `1800` | How long to wait for the commit-and-describe turn (and every later turn) to respond before giving up. |
|
|
36
|
+
| `implementationTimeoutSeconds` | no | `14400` | How long to wait for the implementation turn -- longer because it drives a full implementation-and-test pass through Sonnet/Opus subagents. |
|
|
37
|
+
| `telegramChatId` | no | -- | Telegram chat id to notify when the run ends; defaults to `@ligeti/step-telegram-notify`'s own `LIGETI_TELEGRAM_CHAT_ID` when omitted. |
|
|
38
|
+
| `autoMerge` | no | `true` | After opening and assigning the pull request, wait for its checks, fix failing checks or a conflict, and squash-merge it, deleting its branch. `false` stops after opening and assigning it. |
|
|
39
|
+
| `maxFixRounds` | no | `3` | How many fix rounds the landing loop may spend (a positive integer) before the run fails with `stoppedAt: "pipeline"` or `"merge"`, or hands failing checks to the human. |
|
|
40
|
+
| `startingLabel` | no | -- | GitHub label added to the issue as soon as the run starts. No label is added when omitted. GitHub creates a label that does not exist, so a typo creates a new label. May not contain a comma. |
|
|
41
|
+
| `errorLabel` | no | `"ligeti::error"` | GitHub label added to the issue when the run returns a failed outcome (any `stoppedAt`); a `startingLabel`, when given, is removed afterwards, and a comment names the stopping point. It cannot be turned off. May not contain a comma. |
|
|
42
|
+
|
|
43
|
+
## The run
|
|
44
|
+
|
|
45
|
+
```mermaid
|
|
46
|
+
sequenceDiagram
|
|
47
|
+
participant W as github-small-factory
|
|
48
|
+
participant Git as git remote
|
|
49
|
+
participant GH as GitHub
|
|
50
|
+
participant A as Claude Code (agent)
|
|
51
|
+
|
|
52
|
+
W->>GH: github-issue.comment (run link), add startingLabel
|
|
53
|
+
W->>Git: git.worktree (create issue-<n> branch)
|
|
54
|
+
W->>GH: github-issue.view
|
|
55
|
+
W->>A: implementation turn (fresh session)
|
|
56
|
+
A-->>W: succeeded
|
|
57
|
+
W->>Git: git.write-git-dir-file (empty ligeti/pull-request.md)
|
|
58
|
+
W->>A: commit-and-describe turn (resumed session)
|
|
59
|
+
A-->>W: succeeded, wrote title and body to the file
|
|
60
|
+
W->>Git: git.read-git-dir-file
|
|
61
|
+
W->>GH: github-pr.default-branch
|
|
62
|
+
W->>Git: git.rebase (onto the default branch)
|
|
63
|
+
alt conflict
|
|
64
|
+
W->>A: rebase-conflict turn (resumed session)
|
|
65
|
+
A-->>W: succeeded
|
|
66
|
+
W->>Git: git.rebase (again, to confirm)
|
|
67
|
+
end
|
|
68
|
+
W->>Git: git.push (the rebased head, leased only if the branch exists)
|
|
69
|
+
W->>GH: github-pr.create (base: the default branch), github-pr.assign
|
|
70
|
+
opt autoMerge
|
|
71
|
+
loop until merged or maxFixRounds is spent
|
|
72
|
+
W->>GH: github-pr.await-checks (the pushed sha)
|
|
73
|
+
alt checks failed
|
|
74
|
+
W->>GH: github-pr.failed-check-logs
|
|
75
|
+
W->>Git: git.write-git-dir-file (ligeti/failed-checks.md)
|
|
76
|
+
W->>A: checks-fix turn (resumed session)
|
|
77
|
+
A-->>W: succeeded, new commit
|
|
78
|
+
W->>Git: git.push (the fix)
|
|
79
|
+
else checks failed and the fix is spent
|
|
80
|
+
W->>GH: human.approval, run again calls github-pr.rerun-checks
|
|
81
|
+
else checks green
|
|
82
|
+
W->>GH: github-pr.view (mergeability, rechecked while unknown)
|
|
83
|
+
alt conflict or behind
|
|
84
|
+
W->>Git: git.rebase, with a conflict-resolution turn if needed
|
|
85
|
+
W->>Git: git.push (the rebased head)
|
|
86
|
+
else mergeable
|
|
87
|
+
W->>GH: github-pr.merge (squash, delete branch)
|
|
88
|
+
Note over W,GH: need_rebase also rebases and pushes
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The sequence diagram is the interaction view. `src/diagram.ts` draws the same run as a control-flow
|
|
96
|
+
view -- branches and outcomes -- carried into the manifest and rendered on the shell's workflow
|
|
97
|
+
page.
|
|
98
|
+
|
|
99
|
+
1. **Link, label, worktree, issue read** -- the run's first action is
|
|
100
|
+
`@ligeti/step-github-issue`'s `github-issue.comment`, which posts
|
|
101
|
+
`Ligeti started a github-small-factory run for this issue: <run URL>`; a comment that cannot be
|
|
102
|
+
posted fails the run. With `startingLabel`, `github-issue.add-label` follows, then `git.worktree`
|
|
103
|
+
(named `issue-<n>`) and `github-issue.view`. The issue URL is parsed with `@ligeti/step-github-issue`'s
|
|
104
|
+
`parseIssueUrl`, and every later call quotes the canonical URL rebuilt from `owner`, `repo` and
|
|
105
|
+
number.
|
|
106
|
+
2. **implementation** -- a fresh session whose prompt opens with the issue's URL, title and
|
|
107
|
+
description, followed by fixed instructions (Sonnet subagents for the work, Opus for review, commit
|
|
108
|
+
often, ask with `AskUserQuestion`), the branch to stay on, and the rule that the agent never
|
|
109
|
+
pushes or opens a pull request: the workflow does both once the work is done (`src/prompts.ts`'s
|
|
110
|
+
`implementationPrompt`). The prompts never mention `gh` or `glab`.
|
|
111
|
+
3. **commit-and-describe** -- first the workflow empties `ligeti/pull-request.md` in the worktree's own
|
|
112
|
+
git directory with `git.write-git-dir-file`, which clears any file an earlier attempt left and
|
|
113
|
+
returns the file's absolute path. The turn resumes the implementation session (`forkSession:
|
|
114
|
+
false`), commits any remaining changes using Conventional Commits, and writes the pull request's
|
|
115
|
+
title (first line) and description (the rest, with a `Closes #<n>` line) to that absolute path. The
|
|
116
|
+
file lies in the git directory, outside the working tree, so it is never committed.
|
|
117
|
+
`git.read-git-dir-file` reads it back (`src/pull-request-file.ts`). A blank file, or a title over 256 characters (GitHub's limit), fails the run
|
|
118
|
+
with `stoppedAt: "commit_and_describe"`; a leading Markdown `#` heading marker is stripped from the title. The workflow appends `Closes #<n>` to the description
|
|
119
|
+
when the agent left it out, so the issue is always closed by the merge.
|
|
120
|
+
4. **Rebase onto the default branch** -- `github-pr.default-branch` reads the repository's default
|
|
121
|
+
branch, and `src/rebase.ts`'s `rebaseOntoTarget` runs `git.rebase` onto a fresh fetch of it. A
|
|
122
|
+
conflict goes to one more agent turn that resumes the session, runs the rebase itself and never
|
|
123
|
+
pushes; `git.rebase` then runs again to confirm. A rebase still conflicted stops the run as
|
|
124
|
+
`stoppedAt: "rebase"`. A rebased head that equals the base has nothing to open a pull request for
|
|
125
|
+
and stops the run as `stoppedAt: "commit_and_describe"`.
|
|
126
|
+
5. **Push, open, assign** -- `git.push` of the rebased head, with the target repository's pre-push
|
|
127
|
+
hook running. The branch is new, so there is no lease; only when `git.rebase` reports a remote
|
|
128
|
+
branch (a replayed run) is the push `--force-with-lease` keyed to that sha. `github-pr.create`
|
|
129
|
+
then opens a ready pull request from the branch into the default branch, named explicitly as
|
|
130
|
+
`base`, with the agent's title and description, and `github-pr.assign` assigns it to the owner of
|
|
131
|
+
`GITHUB_TOKEN`. Assigning right after opening means every later outcome has it assigned.
|
|
132
|
+
6. **Land the pull request** -- unless `autoMerge` is `false`, `src/land.ts`'s `landOnTarget` loops,
|
|
133
|
+
bounded by `maxFixRounds`:
|
|
134
|
+
- `github-pr.await-checks` waits for every check on the sha last pushed. A pull request head that
|
|
135
|
+
moved meanwhile stops the run as `stoppedAt: "pipeline"`. The step throws when the wait times
|
|
136
|
+
out -- and a commit with no checks at all times out too -- so a pull request whose repository
|
|
137
|
+
runs no checks surfaces as a rejected run; set `autoMerge` to `false` there.
|
|
138
|
+
- Failing checks cost one fix round: `github-pr.failed-check-logs` reads each failed check,
|
|
139
|
+
`src/failed-checks-file.ts`'s `renderFailedChecks` renders them as Markdown, the workflow writes
|
|
140
|
+
`ligeti/failed-checks.md` into the git directory, and a turn resumes the session with that absolute
|
|
141
|
+
path (the agent has no `gh`, so it reads the logs from the file). The workflow pushes the commit
|
|
142
|
+
the turn made as a plain fast-forward push and awaits the new sha. A failing turn stops the run
|
|
143
|
+
as `stoppedAt: "pipeline"`; a turn that commits nothing hands the checks to the human.
|
|
144
|
+
- Handing the checks to the human raises a `human.approval` (options "Run the checks again" and
|
|
145
|
+
"Give up") and a Telegram message, and waits without a timeout. "Run the checks again" calls
|
|
146
|
+
`github-pr.rerun-checks`, which re-runs the failed GitHub Actions runs, and awaits the same
|
|
147
|
+
sha again; checks that fail again ask again, without new fix rounds, until a rebase pushes a commit
|
|
148
|
+
the human never saw. "Give up", or an approval that times out, stops the run as
|
|
149
|
+
`stoppedAt: "pipeline"`. The human must not push to the branch meanwhile.
|
|
150
|
+
- Green checks are followed by `github-pr.view`, rechecked every 10 seconds (at most 30 times)
|
|
151
|
+
while GitHub is still computing `mergeable`. A pull request that stays unknown, or whose
|
|
152
|
+
`mergeableState` is `blocked` or `draft`, stops the run as `stoppedAt: "merge"`.
|
|
153
|
+
- A conflict (`mergeable: false` or a `mergeableState` of `dirty` or `behind`) costs one fix
|
|
154
|
+
round: the same rebase as step 4, then a push and a new wait for checks. A conflict the turn
|
|
155
|
+
cannot resolve stops the run as `stoppedAt: "rebase"`.
|
|
156
|
+
- A mergeable pull request is merged with `github-pr.merge`: squash, delete the branch, guarded by
|
|
157
|
+
the pushed sha. `need_rebase` is handled as a conflict. A `refused` merge after a clean view is
|
|
158
|
+
mostly transient (GitHub answers 405 "Base branch was modified"), so it is retried like an
|
|
159
|
+
unchanged rebase: a rebase, then up to three tries 10 seconds apart; a refusal that persists
|
|
160
|
+
stops the run as `stoppedAt: "merge"` with the step's detail.
|
|
161
|
+
- A rebase that leaves the head on the sha already pushed pushes nothing, awaits no checks and spends
|
|
162
|
+
no fix round: the loop waits 10 seconds and tries again, and after three in a row the run stops as
|
|
163
|
+
`stoppedAt: "merge"`.
|
|
164
|
+
- Once `maxFixRounds` rounds are spent, further failing checks go to the human, and a further rebase
|
|
165
|
+
need first runs a plain rebase with no agent turn: unchanged head retries, anything else stops the
|
|
166
|
+
run as `stoppedAt: "merge"`.
|
|
167
|
+
|
|
168
|
+
A turn that does not succeed stops the run there; see
|
|
169
|
+
[`steps/agent/README.md`](../../steps/agent/README.md#runclaude) for what "succeed" means for an
|
|
170
|
+
`AgentResult`. A failure outside a turn -- a rejected push, a failed pull request creation, a check
|
|
171
|
+
wait that times out, a missing pull request file -- throws out of the run rather than being reported as
|
|
172
|
+
a `runOutcome: "failed"` output ([ADR-0005](../../adr/0005-steps-throw-results-are-for-expected-traffic.md)).
|
|
173
|
+
|
|
174
|
+
Every recognized outcome the run returns (`completed` or `failed`, at any `stoppedAt`) sends exactly
|
|
175
|
+
one `telegram.notify` message naming the outcome (`github-small-factory <owner>/<repo>#<n> ...`) and
|
|
176
|
+
linking to the run's shell page (`ctx.runUrl()`). A failed outcome then reports the phase
|
|
177
|
+
`labeling_issue_as_failed`, adds `errorLabel` with `github-issue.add-label`, removes `startingLabel`
|
|
178
|
+
(when it was given and differs from `errorLabel`) with `github-issue.remove-label`, and posts a comment
|
|
179
|
+
on the issue naming `stoppedAt`, the detail and the run link, all after the notification and before the
|
|
180
|
+
`done` phase.
|
|
181
|
+
|
|
182
|
+
## Output
|
|
183
|
+
|
|
184
|
+
`runOutcome: "completed"` and `runOutcome: "failed"` are two separate shapes (a discriminated union on
|
|
185
|
+
`runOutcome`):
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
| {
|
|
189
|
+
runOutcome: "completed";
|
|
190
|
+
stoppedAt: "commit_and_describe";
|
|
191
|
+
worktreePath: string;
|
|
192
|
+
branchName: string;
|
|
193
|
+
sessionId: string | null;
|
|
194
|
+
resultText: string | null;
|
|
195
|
+
pullRequestUrl: string;
|
|
196
|
+
merged: boolean; // false only when autoMerge is false
|
|
197
|
+
}
|
|
198
|
+
| {
|
|
199
|
+
runOutcome: "failed";
|
|
200
|
+
stoppedAt: "implementation" | "commit_and_describe" | "rebase" | "pipeline" | "merge";
|
|
201
|
+
worktreePath: string;
|
|
202
|
+
branchName: string;
|
|
203
|
+
sessionId: string | null;
|
|
204
|
+
resultText: string | null;
|
|
205
|
+
detail: string;
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
`stoppedAt: "commit_and_describe"` on a failed run also covers a pull request file the agent left
|
|
210
|
+
blank, a title over 256 characters, and a branch with no commit ahead of the default branch; no
|
|
211
|
+
pull request exists then. `stoppedAt: "pipeline"` keeps `small-factory`'s value for "the
|
|
212
|
+
checks could not be made green": the head moved while awaited, a checks-fix turn failed, or the human
|
|
213
|
+
gave up or did not answer. `stoppedAt: "merge"` means the pull request could not be merged: its
|
|
214
|
+
mergeability stayed unknown, it was blocked, GitHub refused the merge, or it still needed a rebase
|
|
215
|
+
after `maxFixRounds` fix rounds. In both cases the pull request stays open and ready.
|
|
216
|
+
|
|
217
|
+
## Environment variables
|
|
218
|
+
|
|
219
|
+
This package reads no environment of its own; it composes `@ligeti/step-agent`,
|
|
220
|
+
`@ligeti/step-git-worktree`, `@ligeti/step-github-issue`, `@ligeti/step-github-pr`,
|
|
221
|
+
`@ligeti/step-human-approval` and `@ligeti/step-telegram-notify`, whose own settings apply -- see
|
|
222
|
+
[`steps/agent/README.md`](../../steps/agent/README.md),
|
|
223
|
+
[`steps/git-worktree/README.md`](../../steps/git-worktree/README.md),
|
|
224
|
+
[`steps/github-issue/README.md`](../../steps/github-issue/README.md) and
|
|
225
|
+
[`steps/github-pr/README.md`](../../steps/github-pr/README.md#environment-variables), and
|
|
226
|
+
[`steps/telegram-notify/README.md`](../../steps/telegram-notify/README.md). The GitHub steps read
|
|
227
|
+
`GITHUB_TOKEN`; a fine-grained token needs Contents, Pull requests, Issues and Actions (read and
|
|
228
|
+
write) and Checks and Commit statuses (read). `git push` authenticates through SSH or the operator's
|
|
229
|
+
own git configuration, not through `GITHUB_TOKEN`. The final notification needs
|
|
230
|
+
`LIGETI_TELEGRAM_BOT_TOKEN` and, for the run link, the SDK's `LIGETI_PUBLIC_BASE_URL`; it is mandatory,
|
|
231
|
+
so a missing or failing Telegram setup ends the run in `ERROR` even though its work finished.
|
|
232
|
+
|
|
233
|
+
This is one of the default workflows: `ligeti serve` offers it while `LIGETI_WORKFLOWS` is unset.
|
|
234
|
+
Setting `LIGETI_WORKFLOWS` replaces the default list, so it must then list this directory too (see
|
|
235
|
+
[ADR-0029](../../adr/0029-ligeti-installs-from-npm-with-per-user-config-and-state-directories.md)).
|
|
236
|
+
|
|
237
|
+
## Prerequisites
|
|
238
|
+
|
|
239
|
+
Beyond `@ligeti/step-agent`'s own Prerequisites
|
|
240
|
+
([`steps/agent/README.md#prerequisites`](../../steps/agent/README.md#prerequisites)):
|
|
241
|
+
|
|
242
|
+
- The agent's Claude profile must deny `git push`: no turn, including a rebase-conflict turn, ever
|
|
243
|
+
pushes or manages the pull request. The agent needs no forge command line; neither `gh` nor `glab` is
|
|
244
|
+
used.
|
|
245
|
+
- A GitHub token for the issue and pull request steps, and git credentials able to push the
|
|
246
|
+
`issue-<n>` branch to `origin`. The token's user must be allowed to merge into the base branch.
|
|
247
|
+
- The repository must run checks (for example GitHub Actions) on pull requests, because the landing
|
|
248
|
+
loop waits for them; otherwise set `autoMerge` to `false`. Re-running is limited to GitHub Actions.
|
|
249
|
+
- Answering a question the implementation turn asks with `AskUserQuestion` requires the `herdr` agent
|
|
250
|
+
backend.
|
|
251
|
+
|
|
252
|
+
## Differences from small-factory
|
|
253
|
+
|
|
254
|
+
- The pull request is opened after the finished work is rebased onto the default branch and pushed,
|
|
255
|
+
as a ready pull request; there is no draft, no untouched-branch push and no `mark-ready`. The
|
|
256
|
+
pre-push hook therefore runs on the one push. The base is the repository's default branch, read
|
|
257
|
+
with `github-pr.default-branch` before the push, so the rebase happens before the pull request
|
|
258
|
+
exists, as in `small-factory`.
|
|
259
|
+
- The pull request text comes from a file the agent writes in the git directory instead of from
|
|
260
|
+
`glab mr update`.
|
|
261
|
+
- Failed check logs reach the agent as a file the workflow renders instead of through `glab ci`.
|
|
262
|
+
- "Pipeline" means checks: green is every check run and commit status on the sha finished as success,
|
|
263
|
+
neutral or skipped.
|
|
264
|
+
- A red set of checks whose pushed commit changes `.ligeti/gate.json` against the base branch tip
|
|
265
|
+
skips the agent fix turn and asks the human to review the change and add the
|
|
266
|
+
`gate-config-reviewed` label to the pull request, because the repository's `verify-attestation`
|
|
267
|
+
job fails its gate-config drift guard until the label is there. The workflow never adds the label
|
|
268
|
+
itself. `minPipelineId` has no counterpart, because checks belong to a sha.
|
|
269
|
+
|
|
270
|
+
## Known limits
|
|
271
|
+
|
|
272
|
+
- **A run that ends by a thrown step error leaves the pull request open and assigned,** and sends no
|
|
273
|
+
Telegram notification.
|
|
274
|
+
- **A pull request file the agent deleted** makes `git.read-git-dir-file` throw out of the run; only a
|
|
275
|
+
blank, title-less or over-long-title file is a `commit_and_describe` failure.
|
|
276
|
+
- **"Run the checks again" re-runs only GitHub Actions runs.** Checks from other apps are not re-run, so
|
|
277
|
+
they can fail again at once and ask the human again.
|
|
278
|
+
- **A replayed wait right after a re-run can still see the old failure,** because GitHub registers the
|
|
279
|
+
re-run asynchronously; the human is asked again.
|
|
280
|
+
- **The worktree is removed when the run ends**; a failed run's uncommitted changes are lost, anything
|
|
281
|
+
committed and pushed survives on the branch.
|
|
282
|
+
- **A timed-out or failed implementation turn reports no session id.**
|
|
283
|
+
- **A very long issue description can stop the implementation turn from starting**
|
|
284
|
+
(`@ligeti/step-agent`'s `wrapper.sh` refuses a prompt over 100 KB).
|
|
285
|
+
- **A plain-text question ends the turn early;** questions must come through `AskUserQuestion`.
|
|
286
|
+
- **A push that fails throws out of the run** (ADR-0005), for example a lease rejected because
|
|
287
|
+
something else landed on the branch.
|
|
288
|
+
- **The workflow makes only one attempt at resolving a rebase conflict.**
|
|
289
|
+
- **Branch protection can make GitHub refuse a merge no rebase fixes,** such as a required review; the
|
|
290
|
+
run then stops as `stoppedAt: "merge"`.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type WorkflowContext } from "@ligeti/sdk";
|
|
2
|
+
export declare const RUN_AGAIN_OPTION = "Run the checks again";
|
|
3
|
+
export declare const GIVE_UP_OPTION = "Give up";
|
|
4
|
+
export declare const GATE_CONFIG_PATH = ".ligeti/gate.json";
|
|
5
|
+
export declare const GATE_CONFIG_REVIEWED_LABEL = "gate-config-reviewed";
|
|
6
|
+
export declare function changesGateConfig(ctx: WorkflowContext, input: {
|
|
7
|
+
worktreePath: string;
|
|
8
|
+
pushedSha: string;
|
|
9
|
+
baseSha: string;
|
|
10
|
+
}): Promise<boolean>;
|
|
11
|
+
export type ChecksCause = {
|
|
12
|
+
readonly kind: "gate_config_changed";
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: "unresolved";
|
|
15
|
+
readonly reason: string;
|
|
16
|
+
};
|
|
17
|
+
export interface ChecksHandoff {
|
|
18
|
+
readonly pullRequestUrl: string;
|
|
19
|
+
readonly telegramChatId: string | undefined;
|
|
20
|
+
readonly failedChecks: readonly string[];
|
|
21
|
+
readonly cause: ChecksCause;
|
|
22
|
+
}
|
|
23
|
+
export type HandoffAnswer = {
|
|
24
|
+
readonly kind: "run_again";
|
|
25
|
+
} | {
|
|
26
|
+
readonly kind: "gave_up";
|
|
27
|
+
readonly detail: string;
|
|
28
|
+
};
|
|
29
|
+
export declare function askHumanAboutChecks(ctx: WorkflowContext, handoff: ChecksHandoff):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ACpB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,aAAa,CAAC,CAgCxB"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// ABOUTME: Hands failing pull request checks to the human: raises a human.approval with a Telegram message,
|
|
2
|
+
// ABOUTME: waits without a timeout, and reports whether the human chose to run the checks again or to give up.
|
|
3
|
+
import { NO_TIMEOUT_SECONDS } from "@ligeti/sdk";
|
|
4
|
+
import { gitShowFile } from "@ligeti/step-git-worktree";
|
|
5
|
+
import { humanApproval } from "@ligeti/step-human-approval";
|
|
6
|
+
import { telegramNotify } from "@ligeti/step-telegram-notify";
|
|
7
|
+
export const RUN_AGAIN_OPTION = "Run the checks again";
|
|
8
|
+
export const GIVE_UP_OPTION = "Give up";
|
|
9
|
+
export const GATE_CONFIG_PATH = ".ligeti/gate.json";
|
|
10
|
+
export const GATE_CONFIG_REVIEWED_LABEL = "gate-config-reviewed";
|
|
11
|
+
export async function changesGateConfig(ctx, input) {
|
|
12
|
+
const { worktreePath, pushedSha, baseSha } = input;
|
|
13
|
+
const pushed = await ctx.run(gitShowFile, {
|
|
14
|
+
worktreePath,
|
|
15
|
+
commit: pushedSha,
|
|
16
|
+
path: GATE_CONFIG_PATH,
|
|
17
|
+
});
|
|
18
|
+
const base = await ctx.run(gitShowFile, {
|
|
19
|
+
worktreePath,
|
|
20
|
+
commit: baseSha,
|
|
21
|
+
path: GATE_CONFIG_PATH,
|
|
22
|
+
});
|
|
23
|
+
return pushed.content !== base.content;
|
|
24
|
+
}
|
|
25
|
+
function describeChecks(handoff) {
|
|
26
|
+
return handoff.failedChecks.length === 0
|
|
27
|
+
? "no failed check is named"
|
|
28
|
+
: handoff.failedChecks.join(", ");
|
|
29
|
+
}
|
|
30
|
+
function request(cause) {
|
|
31
|
+
return cause.kind === "gate_config_changed"
|
|
32
|
+
? "the checks are waiting for a gate config review"
|
|
33
|
+
: "the checks need a human";
|
|
34
|
+
}
|
|
35
|
+
function explanation(cause) {
|
|
36
|
+
if (cause.kind === "gate_config_changed") {
|
|
37
|
+
return (`The change modifies ${GATE_CONFIG_PATH}, so verify-attestation fails its gate-config drift ` +
|
|
38
|
+
`guard until a human reviews the gate config change and adds the ` +
|
|
39
|
+
`"${GATE_CONFIG_REVIEWED_LABEL}" label to the pull request. An agent cannot fix that. ` +
|
|
40
|
+
`Review it, add the label, then choose "${RUN_AGAIN_OPTION}", which re-runs the failed ` +
|
|
41
|
+
`GitHub Actions runs.`);
|
|
42
|
+
}
|
|
43
|
+
return (`${cause.reason}. Fix the cause without pushing new commits to the branch -- the run lands ` +
|
|
44
|
+
`the commit it pushed -- then choose "${RUN_AGAIN_OPTION}", which re-runs the failed GitHub ` +
|
|
45
|
+
`Actions runs.`);
|
|
46
|
+
}
|
|
47
|
+
function description(handoff) {
|
|
48
|
+
return (`github-small-factory ${handoff.pullRequestUrl}: ${request(handoff.cause)}\n\n` +
|
|
49
|
+
`${explanation(handoff.cause)} Choose "${GIVE_UP_OPTION}" to stop the run.\n\n` +
|
|
50
|
+
`Failed checks: ${describeChecks(handoff)}\n` +
|
|
51
|
+
`Pull request: ${handoff.pullRequestUrl}`);
|
|
52
|
+
}
|
|
53
|
+
export async function askHumanAboutChecks(ctx, handoff) {
|
|
54
|
+
const approval = await ctx.run(humanApproval, {
|
|
55
|
+
description: description(handoff),
|
|
56
|
+
options: [RUN_AGAIN_OPTION, GIVE_UP_OPTION],
|
|
57
|
+
withAnswer: false,
|
|
58
|
+
});
|
|
59
|
+
await ctx.run(telegramNotify, {
|
|
60
|
+
text: `github-small-factory ${handoff.pullRequestUrl}: a human is needed -- ` +
|
|
61
|
+
`${request(handoff.cause)}: ${approval.output.url} -- failed checks: ${describeChecks(handoff)}`,
|
|
62
|
+
...(handoff.telegramChatId === undefined ? {} : { chatId: handoff.telegramChatId }),
|
|
63
|
+
});
|
|
64
|
+
await ctx.status("waiting_for_human", {
|
|
65
|
+
pullRequestUrl: handoff.pullRequestUrl,
|
|
66
|
+
url: approval.output.url,
|
|
67
|
+
});
|
|
68
|
+
const message = await ctx.waitForCallback(humanApproval, approval, {
|
|
69
|
+
timeoutSeconds: NO_TIMEOUT_SECONDS,
|
|
70
|
+
});
|
|
71
|
+
if (message === null) {
|
|
72
|
+
return {
|
|
73
|
+
kind: "gave_up",
|
|
74
|
+
detail: `waiting for the human to handle the failed checks timed out (${handoff.pullRequestUrl})`,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (message.payload.option !== RUN_AGAIN_OPTION) {
|
|
78
|
+
return {
|
|
79
|
+
kind: "gave_up",
|
|
80
|
+
detail: `the human gave up on the failed checks (${handoff.pullRequestUrl})`,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return { kind: "run_again" };
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=checks-handoff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checks-handoff.js","sourceRoot":"","sources":["../src/checks-handoff.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,+GAA+G;AAC/G,OAAO,EAAE,kBAAkB,EAAwB,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,MAAM,CAAC,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;AACvD,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC;AACxC,MAAM,CAAC,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AACpD,MAAM,CAAC,MAAM,0BAA0B,GAAG,sBAAsB,CAAC;AAEjE,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,GAAoB,EACpB,KAAmE;IAEnE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IACnD,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC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,CAAC;QAChD,OAAO;YACL,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,2CAA2C,OAAO,CAAC,cAAc,GAAG;SAC7E,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const githubSmallFactoryDiagram = "flowchart TD\n Start([Start]) --> LinkIssue[Comment the run link on the GitHub issue]\n LinkIssue --> Label{\"startingLabel set?\"}\n Label -->|yes| AddLabel[Add GitHub label]\n Label -->|no| Worktree[Create worktree]\n AddLabel --> Worktree\n Worktree --> ReadIssue[Read GitHub issue]\n ReadIssue --> Implement[\"Run implementation agent\"]\n Implement -->|not succeeded or no session id| Failed1[[\"failed, stoppedAt implementation\"]]\n Implement -->|succeeded| ClearFile[\"Write an empty pull request file\"]\n ClearFile --> CommitDescribe[\"Commit and describe, resume session\"]\n CommitDescribe -->|not succeeded| Failed2[[\"failed, stoppedAt commit_and_describe\"]]\n CommitDescribe -->|succeeded| ReadFile[Read the pull request file]\n ReadFile -->|no title or title over 256 characters| Failed2\n ReadFile -->|title and body| ReadBase[Read the repository's default branch]\n ReadBase --> Rebase[\"Rebase onto the default branch\"]\n Rebase -->|unresolved| Failed3[[\"failed, stoppedAt rebase\"]]\n Rebase -->|no commit ahead of the base| Failed2\n Rebase -->|rebased| PushBranch[\"Push the rebased head, under a lease if the branch exists\"]\n PushBranch --> CreatePr[Open the pull request against the default branch]\n CreatePr --> Assign[Assign it to the GitHub token's owner]\n Assign --> AutoMerge{\"autoMerge?\"}\n AutoMerge -->|false| Completed[[\"completed, merged false\"]]\n AutoMerge -->|true| AwaitChecks[\"Await the pushed commit's checks\"]\n AwaitChecks -->|head moved| Failed4[[\"failed, stoppedAt pipeline\"]]\n AwaitChecks -->|failed, human already answered| HandOff\n AwaitChecks -->|failed| ChecksRounds{\"fix rounds left?\"}\n ChecksRounds -->|no| HandOff{\"Human: run again?\"}\n HandOff -->|give up| Failed4\n HandOff -->|run again| RerunChecks[Re-run the failed GitHub Actions runs]\n RerunChecks -->|refused| Failed4\n RerunChecks --> AwaitChecks\n ChecksRounds -->|yes| WriteLogs[\"Write the failed checks' logs to a file\"]\n WriteLogs --> FixChecks[\"Fix turn, resume session\"]\n FixChecks -->|not succeeded| Failed4\n FixChecks -->|no commit| HandOff\n FixChecks -->|committed| PushFix[Push the fix, fast-forward only]\n PushFix --> AwaitChecks\n AwaitChecks -->|green| Mergeability[\"Read mergeability, recheck while pending\"]\n Mergeability -->|still pending or not mergeable| Failed5[[\"failed, stoppedAt merge\"]]\n Mergeability -->|conflict| RebaseRounds{\"fix rounds left?\"}\n Mergeability -->|mergeable| Merge[\"Squash-merge, delete the branch\"]\n Merge -->|merged| Merged[[\"completed, merged true\"]]\n Merge -->|need_rebase or refused| RebaseRounds\n RebaseRounds -->|no| PlainRebase[\"Plain rebase, no agent turn\"]\n PlainRebase -->|head unchanged| Retry\n PlainRebase -->|conflicted or new head| Failed5\n RebaseRounds -->|yes| RebaseRound[\"Rebase onto base, agent resolves conflicts\"]\n RebaseRound -->|unresolved| Failed3\n RebaseRound -->|head unchanged| Retry[\"Wait, then read mergeability again (three in a row fail)\"]\n Retry --> Mergeability\n Retry -->|third in a row| Failed5\n RebaseRound -->|resolved| PushRebaseAgain[Push the rebased head]\n PushRebaseAgain --> AwaitChecks\n Failed1 --> Notify[\"Telegram: final outcome and run link\"]\n Failed2 --> Notify\n Failed3 --> Notify\n Failed4 --> Notify\n Failed5 --> Notify\n Completed --> Notify\n Merged --> Notify\n Notify -->|failed| ErrorLabel[\"Add errorLabel, remove startingLabel if given, comment the failure on the issue\"]\n";
|
|
2
|
+
//# sourceMappingURL=diagram.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagram.d.ts","sourceRoot":"","sources":["../src/diagram.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,yBAAyB,yjHA8DrC,CAAC"}
|