@openagt/skill-branches 0.1.0 → 0.1.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.
package/dist/publish.d.ts DELETED
@@ -1,138 +0,0 @@
1
- import { type GitRunner } from '@gemstack/agent-data';
2
- /**
3
- * Publishing a checkout (#1774): the agent's own last step. Push the branch, open its pull
4
- * request with the title and body the agent wrote, and arm the merge when the agent was told
5
- * the work may land on its own. One rule before any of it: the tree is clean, since what is
6
- * published is what is committed, and nothing is committed on the agent's behalf.
7
- *
8
- * A branch that already has an open pull request gets no second one: the request is reported as
9
- * it is, and only the push and the merge arming happen.
10
- *
11
- * The merge is GitHub's auto-merge where the repository allows it. Where it does not, this tool's
12
- * own watcher waits for the checks and merges (`merge-watch.ts`); where the request is already
13
- * green, GitHub will not arm anything and the request is merged at once.
14
- *
15
- * A checkout under a hold (`merge-hold.ts`) arms nothing: the merge is recorded as wanted, the
16
- * request's body says it is held, and the caller who put the hold releases it (`releaseMerge`).
17
- *
18
- * A person publishes a finished agent's work through the same door (#1774), by branch
19
- * (`publishBranch`): the agent's checkout when one is still on the branch, under the same clean
20
- * rule; else the branch itself, pushed when this machine has it, as it is when only the remote
21
- * does. And lands its request (`mergePr`): a draft is marked ready first, then the merge is
22
- * armed exactly as `--merge` arms it.
23
- */
24
- /** A `gh` runner: the standard output of one invocation; rejects with gh's own line on failure. */
25
- export type GhRunner = (args: string[], cwd: string) => Promise<string>;
26
- /** `gh` on PATH, one minute per call: these talk to the network. */
27
- export declare function nodeGhRunner(): GhRunner;
28
- export interface PublishOptions {
29
- /** The pull request's title: one line naming what the change does. */
30
- title: string;
31
- /** The pull request's body: what changed and why. */
32
- body?: string;
33
- /** Arm the merge: the request lands on its own once its checks pass. */
34
- merge?: boolean;
35
- /** Start the merge watcher for a request (default {@link spawnMergeWatch}). For tests. */
36
- watch?: (repo: string, number: number) => Promise<void>;
37
- /** Open the request as a draft. Not with `merge`: a draft cannot be merged. */
38
- draft?: boolean;
39
- git?: GitRunner;
40
- gh?: GhRunner;
41
- }
42
- /** Why a checkout was not published. */
43
- export type PublishRefusal =
44
- /** The directory is not a git worktree root. */
45
- 'not-a-worktree'
46
- /** The checkout is on no branch. */
47
- | 'no-branch'
48
- /** The tree holds uncommitted work: commit or delete it first. */
49
- | 'dirty'
50
- /** The branch could not be pushed. */
51
- | 'push-failed'
52
- /** The pull request could not be opened. */
53
- | 'pr-failed';
54
- export type PublishOutcome = {
55
- ok: true;
56
- branch: string;
57
- pr: {
58
- number: number;
59
- url: string;
60
- };
61
- /** Whether the request was open already. */
62
- existing: boolean;
63
- /**
64
- * How the merge arming went, when asked for: GitHub's auto-merge armed, merged at once (the
65
- * request was already green), this tool's watcher started (the repository does not allow
66
- * auto-merge), or held (the checkout is under a hold; armed at its release).
67
- */
68
- merge?: MergeArming | {
69
- outcome: 'held';
70
- };
71
- } | {
72
- ok: false;
73
- reason: 'not-a-worktree';
74
- }
75
- /** The checkout is on no branch; or, published by name, neither this machine nor the remote has the branch. */
76
- | {
77
- ok: false;
78
- reason: 'no-branch';
79
- branch?: string;
80
- } | {
81
- ok: false;
82
- reason: 'dirty' | 'push-failed' | 'pr-failed';
83
- branch: string;
84
- detail?: string;
85
- };
86
- /** How arming a merge went. */
87
- export type MergeArming = {
88
- outcome: 'auto-armed' | 'merged' | 'watching';
89
- } | {
90
- outcome: 'failed';
91
- error: string;
92
- };
93
- export declare function publishCheckout(path: string, opts: PublishOptions): Promise<PublishOutcome>;
94
- /**
95
- * Publish a branch by name, from the project (#1774): the caller's form, for a person landing a
96
- * finished agent's work. The checkout under `.branches/` that is on the branch, when one is,
97
- * is published as the agent would publish it, its clean rule included. Without one, the branch
98
- * itself: pushed when this machine has it; left as it is when only `origin` has it (a branch
99
- * pushed from elsewhere, with nothing here to push). Neither: `no-branch`. No hold applies
100
- * without a checkout: a hold is a checkout's.
101
- */
102
- export declare function publishBranch(repo: string, branch: string, opts: PublishOptions): Promise<PublishOutcome>;
103
- /** What landing a request for a person did: armed as `--merge` arms, or why not. */
104
- export type MergePrOutcome = MergeArming | {
105
- outcome: 'not-open';
106
- state: string;
107
- };
108
- export interface MergePrOptions {
109
- gh?: GhRunner;
110
- /** Start the merge watcher for a request (default {@link spawnMergeWatch}). For tests. */
111
- watch?: (repo: string, number: number) => Promise<void>;
112
- }
113
- /**
114
- * Land a pull request for a person (#1774): "it is good, land it". A draft is marked ready
115
- * first, since asking for the merge is the statement that its review happened; then the merge
116
- * is armed exactly as `publish --merge` arms it. A request that is not open is `not-open` with
117
- * its state: already merged is an answer, not an action.
118
- */
119
- export declare function mergePr(repo: string, number: number, opts?: MergePrOptions): Promise<MergePrOutcome>;
120
- export type ReleaseOutcome = MergeArming | {
121
- outcome: 'not-held';
122
- } | {
123
- outcome: 'closed';
124
- state: string;
125
- };
126
- export interface ReleaseOptions {
127
- gh?: GhRunner;
128
- /** Start the merge watcher for a request (default {@link spawnMergeWatch}). For tests. */
129
- watch?: (repo: string, number: number) => Promise<void>;
130
- }
131
- /**
132
- * Release a held merge: the request's merge is armed the way `publish --merge` arms it, and then
133
- * the held note leaves its body. A request with no held merge is `not-held` (its publish never asked
134
- * to merge), one no longer open is `closed` and its record dropped. A failed arming keeps the
135
- * record and the note, so the release can be tried again and the request still says it is held.
136
- */
137
- export declare function releaseMerge(repo: string, number: number, opts?: ReleaseOptions): Promise<ReleaseOutcome>;
138
- //# sourceMappingURL=publish.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAKhF;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,mGAAmG;AACnG,MAAM,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;AAEvE,oEAAoE;AACpE,w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1F,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACxD;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,cAAc,CAAC,CAoBnH"}
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,EAA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