@openagt/skill-branches 0.1.0 → 0.1.2

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/dist/publish.js DELETED
@@ -1,215 +0,0 @@
1
- import { nodeGitRunner, pushBranch } from '@gemstack/agent-data';
2
- import { currentBranch, isWorktreeRoot, projectRoot, worktreeBranch, worktreeClean, worktreeDirEntries } from './worktree.js';
3
- import { spawnMergeWatch } from './merge-watch.js';
4
- import { dropHeldMerge, heldMergeRecorded, MERGE_HELD_NOTE, mergeHeld, recordHeldMerge, withHeldNote, withoutHeldNote } from './merge-hold.js';
5
- /** `gh` on PATH, one minute per call: these talk to the network. */
6
- export function nodeGhRunner() {
7
- return async (args, cwd) => {
8
- const { execFile } = await import('node:child_process');
9
- return new Promise((resolve, reject) => {
10
- execFile('gh', args, { cwd, timeout: 60_000 }, (err, stdout, stderr) => {
11
- if (err)
12
- reject(new Error(String(stderr).trim() || err.message));
13
- else
14
- resolve(String(stdout));
15
- });
16
- });
17
- };
18
- }
19
- export async function publishCheckout(path, opts) {
20
- const git = opts.git ?? nodeGitRunner();
21
- const gh = opts.gh ?? nodeGhRunner();
22
- if (!(await isWorktreeRoot(path, git)))
23
- return { ok: false, reason: 'not-a-worktree' };
24
- const branch = await currentBranch(path, git);
25
- if (!branch)
26
- return { ok: false, reason: 'no-branch' };
27
- if (!(await worktreeClean(path, git).catch(() => false)))
28
- return { ok: false, reason: 'dirty', branch };
29
- const repo = await projectRoot(path, git);
30
- const held = opts.merge === true && (await mergeHeld(path, git));
31
- const pushed = await pushBranch(repo, branch, git);
32
- if (!pushed.ok)
33
- return { ok: false, reason: 'push-failed', branch, detail: pushed.error };
34
- return openAndArm(repo, path, branch, opts, held, gh);
35
- }
36
- /**
37
- * Publish a branch by name, from the project (#1774): the caller's form, for a person landing a
38
- * finished agent's work. The checkout under `.branches/` that is on the branch, when one is,
39
- * is published as the agent would publish it, its clean rule included. Without one, the branch
40
- * itself: pushed when this machine has it; left as it is when only `origin` has it (a branch
41
- * pushed from elsewhere, with nothing here to push). Neither: `no-branch`. No hold applies
42
- * without a checkout: a hold is a checkout's.
43
- */
44
- export async function publishBranch(repo, branch, opts) {
45
- const git = opts.git ?? nodeGitRunner();
46
- const gh = opts.gh ?? nodeGhRunner();
47
- for (const entry of await worktreeDirEntries(repo)) {
48
- if ((await worktreeBranch(entry.path, git)) === branch)
49
- return publishCheckout(entry.path, opts);
50
- }
51
- const local = await git(['rev-parse', '--verify', '--quiet', `refs/heads/${branch}`], repo).then(out => out.trim() !== '', () => false);
52
- if (local) {
53
- const pushed = await pushBranch(repo, branch, git);
54
- if (!pushed.ok)
55
- return { ok: false, reason: 'push-failed', branch, detail: pushed.error };
56
- }
57
- else {
58
- const remote = await git(['rev-parse', '--verify', '--quiet', `refs/remotes/origin/${branch}`], repo).then(out => out.trim() !== '', () => false);
59
- if (!remote)
60
- return { ok: false, reason: 'no-branch', branch };
61
- }
62
- return openAndArm(repo, repo, branch, opts, false, gh);
63
- }
64
- /** The half after the push: the open request or a new one, then the merge arming, the hold honored. */
65
- async function openAndArm(repo, cwd, branch, opts, held, gh) {
66
- let pr = await openPr(cwd, branch, gh);
67
- let existing = true;
68
- if (!pr) {
69
- existing = false;
70
- try {
71
- const args = ['pr', 'create', '--head', branch, '--title', opts.title, '--body', held ? withHeldNote(opts.body ?? '') : (opts.body ?? '')];
72
- if (opts.draft && !opts.merge)
73
- args.push('--draft');
74
- const out = await gh(args, cwd);
75
- const url = out.trim().split('\n').filter(Boolean).at(-1);
76
- const number = prNumber(url);
77
- pr = url && number !== undefined ? { number, url } : await openPr(cwd, branch, gh);
78
- if (!pr)
79
- return { ok: false, reason: 'pr-failed', branch, detail: 'gh printed no pull request URL' };
80
- }
81
- catch (err) {
82
- return { ok: false, reason: 'pr-failed', branch, detail: errorMessage(err) };
83
- }
84
- }
85
- const outcome = { ok: true, branch, pr, existing };
86
- if (held) {
87
- await recordHeldMerge(repo, pr.number);
88
- if (existing)
89
- await noteHeld(cwd, pr.number, gh);
90
- outcome.merge = { outcome: 'held' };
91
- }
92
- else if (opts.merge) {
93
- outcome.merge = await armMerge(repo, pr.number, gh, opts.watch ?? spawnMergeWatch);
94
- }
95
- return outcome;
96
- }
97
- /**
98
- * Land a pull request for a person (#1774): "it is good, land it". A draft is marked ready
99
- * first, since asking for the merge is the statement that its review happened; then the merge
100
- * is armed exactly as `publish --merge` arms it. A request that is not open is `not-open` with
101
- * its state: already merged is an answer, not an action.
102
- */
103
- export async function mergePr(repo, number, opts = {}) {
104
- const gh = opts.gh ?? nodeGhRunner();
105
- let view;
106
- try {
107
- view = JSON.parse(await gh(['pr', 'view', String(number), '--json', 'state,isDraft'], repo));
108
- }
109
- catch (err) {
110
- return { outcome: 'failed', error: errorMessage(err) };
111
- }
112
- const state = typeof view.state === 'string' ? view.state : 'OPEN';
113
- if (state !== 'OPEN')
114
- return { outcome: 'not-open', state };
115
- if (view.isDraft === true) {
116
- try {
117
- await gh(['pr', 'ready', String(number)], repo);
118
- }
119
- catch (err) {
120
- return { outcome: 'failed', error: errorMessage(err) };
121
- }
122
- }
123
- return armMerge(repo, number, gh, opts.watch ?? spawnMergeWatch);
124
- }
125
- /** An open request's body gains the held note, once. The note is for a person: an edit gh refuses never fails the publish. */
126
- async function noteHeld(cwd, number, gh) {
127
- try {
128
- const body = String(JSON.parse(await gh(['pr', 'view', String(number), '--json', 'body'], cwd)).body ?? '');
129
- if (!body.includes(MERGE_HELD_NOTE))
130
- await gh(['pr', 'edit', String(number), '--body', withHeldNote(body)], cwd);
131
- }
132
- catch {
133
- // The record is written; only the line for a person is missing.
134
- }
135
- }
136
- /**
137
- * Release a held merge: the request's merge is armed the way `publish --merge` arms it, and then
138
- * the held note leaves its body. A request with no held merge is `not-held` (its publish never asked
139
- * to merge), one no longer open is `closed` and its record dropped. A failed arming keeps the
140
- * record and the note, so the release can be tried again and the request still says it is held.
141
- */
142
- export async function releaseMerge(repo, number, opts = {}) {
143
- const gh = opts.gh ?? nodeGhRunner();
144
- if (!(await heldMergeRecorded(repo, number)))
145
- return { outcome: 'not-held' };
146
- let view;
147
- try {
148
- view = JSON.parse(await gh(['pr', 'view', String(number), '--json', 'state,body'], repo));
149
- }
150
- catch (err) {
151
- return { outcome: 'failed', error: errorMessage(err) };
152
- }
153
- const state = typeof view.state === 'string' ? view.state : 'OPEN';
154
- if (state !== 'OPEN') {
155
- await dropHeldMerge(repo, number);
156
- return { outcome: 'closed', state };
157
- }
158
- const merge = await armMerge(repo, number, gh, opts.watch ?? spawnMergeWatch);
159
- if (merge.outcome === 'failed')
160
- return merge;
161
- await dropHeldMerge(repo, number);
162
- const body = typeof view.body === 'string' ? view.body : '';
163
- if (body.includes(MERGE_HELD_NOTE))
164
- await gh(['pr', 'edit', String(number), '--body', withoutHeldNote(body)], repo).catch(() => { });
165
- return merge;
166
- }
167
- /**
168
- * GitHub's words for "auto-merge is not allowed in this repository" and for "this request is
169
- * already green, so there is nothing to wait for". Matched loosely on purpose: a rephrase on
170
- * GitHub's side lands in `failed`, said out loud, never in a wrong merge.
171
- */
172
- const AUTO_MERGE_OFF = /auto[- ]?merge is not allowed/i;
173
- const ALREADY_GREEN = /clean status/i;
174
- async function armMerge(repo, number, gh, watch) {
175
- try {
176
- await gh(['pr', 'merge', String(number), '--squash', '--auto'], repo);
177
- return { outcome: 'auto-armed' };
178
- }
179
- catch (err) {
180
- const refusal = errorMessage(err);
181
- try {
182
- if (ALREADY_GREEN.test(refusal)) {
183
- await gh(['pr', 'merge', String(number), '--squash'], repo);
184
- return { outcome: 'merged' };
185
- }
186
- if (AUTO_MERGE_OFF.test(refusal)) {
187
- await watch(repo, number);
188
- return { outcome: 'watching' };
189
- }
190
- }
191
- catch (next) {
192
- return { outcome: 'failed', error: errorMessage(next) };
193
- }
194
- return { outcome: 'failed', error: refusal };
195
- }
196
- }
197
- /** The open pull request of a branch, or `undefined`. */
198
- async function openPr(cwd, branch, gh) {
199
- try {
200
- const list = JSON.parse(await gh(['pr', 'list', '--head', branch, '--state', 'open', '--limit', '1', '--json', 'number,url'], cwd));
201
- const first = list[0];
202
- return first && typeof first.number === 'number' && typeof first.url === 'string' ? { number: first.number, url: first.url } : undefined;
203
- }
204
- catch {
205
- return undefined;
206
- }
207
- }
208
- function prNumber(url) {
209
- const match = url?.match(/\/pull\/(\d+)(?:$|[/?#])/);
210
- return match ? Number(match[1]) : undefined;
211
- }
212
- function errorMessage(err) {
213
- return err instanceof Error ? err.message : String(err);
214
- }
215
- //# sourceMappingURL=publish.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"publish.js","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAkB,MAAM,sBAAsB,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAC7H,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AA4B9I,oEAAoE;AACpE,MAAM,UAAU,YAAY;IAC1B,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QACzB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAA;QACvD,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC7C,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;gBACrE,IAAI,GAAG;oBAAE,MAAM,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI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